{"name":"eslint-config-canonical","version":"44.3.17","keywords":["eslint","config","canonical"],"author":{"url":"http://gajus.com","name":"Gajus Kuizinas","email":"gajus@gajus.com"},"license":"BSD-3-Clause","_id":"eslint-config-canonical@44.3.17","maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"homepage":"https://github.com/gajus/eslint-config-canonical#readme","bugs":{"url":"https://github.com/gajus/eslint-config-canonical/issues"},"dist":{"shasum":"128c62515ee8aa2e53572691d6a5dd42a5b7f147","tarball":"http://registry-npm.ywwl.com/eslint-config-canonical/download/eslint-config-canonical-44.3.17.tgz","fileCount":46,"integrity":"sha512-z3asqrGpDpoHLEIxeEaEMNp4DyfSPh/IRkVzQXoffoBO+K0tjLRic0I3wU27CiDpd8MWy7zXraa4+Ih5du9UlQ==","signatures":[{"sig":"MEUCIDm6jv8LRWrbS2FJMIeox0XM82sZoflQoovyo5CxaTAAAiEAhOKjIaxE/SWrlU3442HUyjWzf+K3uZebdjVGpYKd0W4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1017663,"size":206912,"noattachment":false,"key":"/eslint-config-canonical/-/eslint-config-canonical-44.3.17.tgz"},"main":"./eslintrc.js","engines":{"node":">=16.0.0"},"gitHead":"ce07b5df1674f6ebd3a3e4ec07382bc86b6c2ac2","scripts":{"lint":"eslint --report-unused-disable-directives .","test":"ava --verbose --serial","build":"true","compare":"(cd compare; node compare.js)","setup-dev":"(npm link; cd compare; npm install; npm link eslint-config-canonical; node compare.js)","find-deprecated":"(cd compare; node find-deprecated.js)","generate-typescript-compatibility-rules":"node bin/generate-typescript-compatibility-rules.js > configurations/typescript-compatibility.js && eslint configurations/typescript-compatibility.js --fix"},"_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"repository":{"url":"git+https://github.com/gajus/eslint-config-canonical.git","type":"git"},"_npmVersion":"10.8.0","description":"Canonical ESLint Shareable Config","directories":{},"_nodeVersion":"22.10.0","dependencies":{"ramda":"^0.30.1","globals":"^15.12.0","graphql":"^16.9.0","prettier":"^3.3.3","eslint-plugin-n":"^17.13.1","eslint-plugin-fp":"^2.3.0","eslint-plugin-ava":"^15.0.1","eslint-plugin-yml":"^1.15.0","eslint-plugin-zod":"^1.4.0","eslint-plugin-jest":"^28.9.0","yaml-eslint-parser":"^1.2.3","eslint-plugin-jsdoc":"^50.4.3","eslint-plugin-jsonc":"^2.18.1","eslint-plugin-mocha":"^10.5.0","eslint-plugin-react":"^7.37.2","eslint-plugin-import":"npm:eslint-plugin-import-x@^4.4.0","eslint-plugin-lodash":"^8.0.0","eslint-plugin-regexp":"^2.6.0","eslint-plugin-vitest":"^0.5.4","eslint-plugin-cypress":"^4.1.0","eslint-plugin-promise":"^7.1.0","eslint-plugin-unicorn":"^56.0.0","eslint-config-prettier":"^9.1.0","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-prettier":"^5.2.1","eslint-plugin-canonical":"^5.0.0","@next/eslint-plugin-next":"^14.2.15","@stylistic/eslint-plugin":"^2.10.1","@typescript-eslint/parser":"^8.13.0","eslint-plugin-react-hooks":"^5.1.0-rc-b57d2823-20240822","eslint-plugin-perfectionist":"^3.9.1","@graphql-eslint/eslint-plugin":"^3.20.1","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-modules-newline":"0.0.6","@typescript-eslint/eslint-plugin":"^8.13.0","eslint-import-resolver-typescript":"^3.6.3"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^6.2.0","got":"^14.4.4","husky":"^9.1.6","eslint":"^9.14.0","typescript":"^5.6.3","semantic-release":"^24.2.0","@semantic-release/npm":"^12.0.1","@semantic-release/github":"^11.0.1","@semantic-release/commit-analyzer":"^13.0.0"},"peerDependencies":{"eslint":"^9"},"_npmOperationalInternal":{"tmp":"tmp/eslint-config-canonical_44.3.17_1731343865636_0.6770314490015004","host":"s3://npm-registry-packages"},"readme":"# Canonical ESLint Config\n\n[![NPM version](http://img.shields.io/npm/v/eslint-config-canonical.svg?style=flat-square)](https://www.npmjs.org/package/eslint-config-canonical)\n\nThe most comprehensive code style guide.\n\nCanonical consists of 1,000+ rules (40% auto-fixable), some of which are [custom written](https://github.com/gajus/eslint-plugin-canonical) for Canonical. Canonical goal is to reduce noise in code version control and promote use of the latest ES features.\n\n## Usage\n\nMost projects should simply extend from [`canonical/auto`](#canonicalauto-ruleset):\n\n```ts\n// eslint.config.ts\nimport auto from 'eslint-config-canonical/auto';\nimport tseslint from 'typescript-eslint';\n\nexport default tseslint.config(auto);\n```\n\n## Rulesets\n\n> **Note** Most projects should just use [`canonical/auto`](#canonicalauto-ruleset) and override settings when necessary for individual frameworks or file patterns (e.g. vitest vs ava).\n\nThis package includes the following rulesets:\n\n* [`canonical/auto`](./configurations/auto.ts) – The Canonical code style guide.\n* [`canonical/ava`](./configurations/ava.ts) – for projects that use [AVA](https://ava.li/).\n* [`canonical/browser`](./configurations/browser.ts) – for projects that use DOM and other browser APIs.\n* [`canonical/graphql`](./configurations/graphql.ts) – for projects that use [GraphQL](https://graphql.org/).\n* [`canonical/jest`](./configurations/jest.ts) – for projects that use [jest](https://facebook.github.io/jest/).\n* [`canonical/jsdoc`](./configurations/jsdoc.ts) – for projects that use [JSDoc](https://jsdoc.app/).\n* [`canonical/json`](./configurations/json.ts) – for projects that use JSON.\n* [`canonical/jsx-a11y`](./configurations/jsx-a11y.ts) – for projects that use [React](https://facebook.github.io/react/) and want to include [accessibility checks](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y).\n* [`canonical/lodash`](./configurations/lodash.ts) – for projects that use [lodash](https://lodash.com/).\n* [`canonical/mocha`](./configurations/mocha.ts) – for projects that use [Mocha](https://mochajs.org/).\n* [`canonical/module`](./configurations/module.ts) – for projects that use ESM modules.\n* [`canonical/next`](./configurations/next.ts) – for projects that use [Next.js](https://nextjs.org/).\n* [`canonical/node`](./configurations/node.ts) – for projects that use Node.js.\n* [`canonical/prettier`](./configurations/prettier.ts) – applies [Prettier](https://prettier.io/) formatting.\n* [`canonical/react`](./configurations/react.ts) – for projects that use [React](https://facebook.github.io/react/).\n* [`canonical/react-hooks`](./configurations/react-hooks.ts) – for projects that use [React Hooks](https://react.dev/reference/react/hooks).\n* [`canonical/regexp`](./configurations/regexp.ts) – for projects that use regular expressions.\n* [`canonical/typescript-type-checking`](./configurations/typescript-type-checking.ts) – for projects that use [TypeScript](http://typescriptlang.org/) and want additional rules that require type information (rules using type information take longer to run).\n* [`canonical/typescript`](./configurations/typescript.ts) – for projects that use [TypeScript](http://typescriptlang.org/).\n* [`canonical/vitest`](./configurations/vitest.ts) – for projects that use [Vitest](https://vitest.dev/).\n* [`canonical/yaml`](./configurations/yaml.ts) – for projects that use YAML.\n* [`canonical/zod`](./configurations/zod.ts) – for projects that use [Zod](https://github.com/colinhacks/zod).\n\n## `canonical/auto` ruleset\n\n[`canonical/auto`](./configurations/auto.ts) is a special ruleset that uses [overrides](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work) to only apply relevant style guides. This reduces the linting time and the number of false-positives.\n\n`canonical/auto` can be fine-tuned using `overrides` just like any other ESLint ruleset, e.g.\n\n```json\n{\n  \"extends\": [\n    \"canonical/auto\"\n  ],\n  \"overrides\": [\n    {\n      \"extends\": [\n        \"canonical/jsx-a11y\"\n      ],\n      \"files\": \"*.tsx\"\n    },\n    {\n      \"extends\": [\n        \"canonical/vitest\"\n      ],\n      \"files\": \"*.test.{ts,tsx}\"\n    }\n  ],\n  \"root\": true\n}\n```\n\n### Compatibility with Prettier\n\nFor the most part, Prettier and Canonical are already compatible. There are only a few transformations that are incompatible, e.g. Prettier enforces line-length and Canonical does not. As such, there is no good reason to use both. However, if you wish to use Prettier, you can do so by using `canonical/prettier` ruleset, which uses [`eslint-plugin-prettier`](https://www.npmjs.com/package/eslint-plugin-prettier) to apply Prettier formatting after applying Canonical rules.\n\n```json\n{\n  \"extends\": [\n    \"canonical\",\n    \"canonical/jsdoc\",\n    \"canonical/regexp\",\n    \"canonical/react\",\n    \"canonical/react-hooks\",\n    \"canonical/typescript\",\n    \"canonical/jest\",\n    \"canonical/prettier\"\n  ]\n}\n```\n\n> **Note** The reason for using Prettier as an ESLint plugin (as opposed to a separate tool) is because having multiple tools that apply formatting complicates IDE and other tooling setup.\n\n> **Note** Your local `.prettierrc` is going to be ignored when using `canonical/prettier`.\n\n### Compatibility with other style guides\n\nSince Canonical style guide includes more rules than any other style guide, you can have your codebase compatible with a specific style guide (e.g. [airbnb](https://www.npmjs.com/package/eslint-config-airbnb)) and benefit from Canonical for rules that are not covered by the other guide. All you have to do is extend from the Canonical style guide before extending from the desired style guide, e.g.\n\n```json\n{\n  \"extends\": [\n    \"canonical\",\n    \"canonical/jsdoc\",\n    \"canonical/regexp\",\n    \"canonical/react\",\n    \"canonical/react-hooks\",\n    \"airbnb\"\n  ]\n}\n```\n\n## Integrations\n\n### Visual Studio Code\n\nUse the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension that Microsoft provides officially.\n\nExample `.vscode/settings.json`:\n\n```json\n{\n  \"eslint.validate\": [\n    \"css\",\n    \"html\",\n    \"javascript\",\n    \"javascriptreact\",\n    \"json\",\n    \"markdown\",\n    \"typescript\",\n    \"typescriptreact\",\n    \"yaml\"\n  ]\n}\n```\n\nThe setting below turns on _Auto Fix_ for all providers including ESLint:\n\n```json\n{\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  },\n  \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\",\n  \"editor.formatOnSave\": true\n}\n```\n\nAdditionally, we found it that being explicit about which formatter you are using for each file improves DX:\n\n```json\n{\n  \"[css][html][javascript][javascriptreact][json][markdown][typescript][typescriptreact][yaml]\": {\n    \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\"\n  }\n}\n```\n\nWhile not required if you've configured explicit formatter for each file type, I advise that you explicitly disable `prettier` extension in your project:\n\n```json\n{\n  \"prettier.enable\": false,\n}\n```\n\nSharing these settings in your project should be sufficient to prevent local settings accidentally overriding the desired formatter behavior.\n\n## Benchmark\n\n### Canonical vs Prettier\n\nThis benchmark compares running ESLint using Canonical style guide against a project with 3,000+ files VS linting the same project using Prettier.\n\n```\nSystem:\n  OS: macOS 11.6\n  CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz\n  Memory: 64.00 GB\nnpmPackages:\n  eslint: 8.1.0\n  prettier: 2.4.1\n```\n\nAs you may expect, Prettier is going to complete checks quicker – this is because it runs a lot fewer transforms and it only runs style checks (as opposed to static analyses).\n\nThe first time you run ESLint, it will take significantly more time. However, if you enable [`--cache`](https://eslint.org/docs/user-guide/command-line-interface#--cache), then the follow up checks will complete in no time.\n\n```bash\n$ time prettier src\n27.06s user\n1.74s system\n166% cpu\n17.335 total\n\n$ eslint --cache src\n182.43s user\n9.13s system\n126% cpu\n2:31.22 total\n\n$ eslint --cache src\n1.96s user\n0.39s system\n107% cpu\n2.188 total\n```\n\nUsing ESLint cache will dramatically improve ESLint running time by ensuring that only changed files are linted. This is useful if you are using ESLint to run `pre-commit` / `pre-push` [git hooks](https://git-scm.com/docs/githooks) or otherwise depend on these checks completing in real-time.\n\nAdditionally, if performance is a consideration, you may consider:\n\n* [`jest-eslint-runner`](https://github.com/jest-community/jest-runner-eslint)\n* [Integrations](#integrations)\n\nThese options provide near instant feedback just how you are used to when using Prettier.\n\n## Table of Comparison\n\n[COMPARISON_TABLE.md](./COMPARISON_TABLE.md)\n\n## Versioning Policy\n\nAll breaking changes will bump the major version as per the semver convention. Therefore, every new rule addition will increase the major version.\n\n## Development\n\nFirst, run `npm install` and then `npm run setup-dev`. Then, any time that ESLint dependencies are updated you must:\n\n1. Run `npm run generate-typescript-compatibility-rules` script. It disables and override any TypeScript rules that are incompatible with ESLint built-in rules.\n1. Run `npm run compare` script. It generates ruleset comparison table, updates README.md, and identifies rules that are not configured.\n\n## Incompatible rules\n\n[INCOMPATIBLE_RULES.md](./INCOMPATIBLE_RULES.md)\n","publish_time":1731343865925,"_cnpm_publish_time":1731343865925,"dist-tags":{"latest":"47.4.2"}}