{"name":"eslint-plugin-canonical","version":"5.1.1","keywords":["eslint","plugin","canonical"],"author":{"url":"http://gajus.com","name":"Gajus Kuizinas","email":"gajus@gajus.com"},"license":"BSD-3-Clause","_id":"eslint-plugin-canonical@5.1.1","homepage":"https://github.com/gajus/eslint-plugin-canonical#readme","bugs":{"url":"https://github.com/gajus/eslint-plugin-canonical/issues"},"dist":{"shasum":"528a4b2eee2c47d5cc53a3c46beca6fbfaeba6a4","tarball":"http://registry-npm.ywwl.com/eslint-plugin-canonical/download/eslint-plugin-canonical-5.1.1.tgz","fileCount":74,"integrity":"sha512-EmiNq0SnM2JeFHQzN1ZqqOnJDbfSgwq4RvRwL4YUr0Z8xTKRoeoowAzltSiZb22YqIM9b5s/SOgm/VtzjPnYbQ==","signatures":[{"sig":"MEUCIQD0BSGMvzNYjRr0SBDIyjoDqzZpiJxbxamtBIpBr16SawIge2vpIlEzcqZMVea1zjAG2OTirbotpppErtLjYvxWVxI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":202638,"size":39483,"noattachment":false,"key":"/eslint-plugin-canonical/-/eslint-plugin-canonical-5.1.1.tgz"},"main":"./dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"a3d2f1b3045bf4f514ef75eac61e0c9ef8a8034f","scripts":{"lint":"eslint .","test":"mocha --require tsx './tests/rules/*'","build":"rm -fr ./dist && tsc --project ./tsconfig.build.json","prepare":"husky install","generate":"gitdown ./.README/README.md --output-file ./README.md && tsx ./src/bin/addAssertions"},"_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"repository":{"url":"git+https://github.com/gajus/eslint-plugin-canonical.git","type":"git"},"_npmVersion":"10.8.2","description":"Canonical linting rules for ESLint.","directories":{},"_nodeVersion":"18.20.5","dependencies":{"debug":"^4.4.0","roarr":"^7.21.1","chance":"^1.1.12","lodash":"^4.17.21","recast":"^0.23.9","gitdown":"^4.1.1","xregexp":"^5.1.1","is-js-type":"^2.0.0","is-obj-prop":"^1.0.0","is-proto-prop":"^2.0.0","array-includes":"^3.1.8","is-get-set-prop":"^1.0.0","natural-orderby":"^5.0.0","eslint-module-utils":"^2.12.0","@typescript-eslint/utils":"^8.18.1","eslint-import-resolver-typescript":"^3.7.0"},"_hasShrinkwrap":false,"devDependencies":{"ajv":"^8.17.1","tsx":"^4.19.2","glob":"^7.2.0","husky":"^7.0.4","mocha":"^10.2.0","react":"^18.2.0","eslint":"^9.17.0","typescript":"^5.7.2","@types/node":"^22.10.2","@types/chance":"^1.1.6","semantic-release":"^20.0.0","typescript-eslint":"^8.18.1","@semantic-release/npm":"^9.0.1","eslint-config-canonical":"^44.3.35","@semantic-release/github":"^8.0.7","@typescript-eslint/types":"^8.18.1","@typescript-eslint/parser":"^8.18.1","@typescript-eslint/rule-tester":"^8.18.1","@semantic-release/commit-analyzer":"^9.0.2"},"_npmOperationalInternal":{"tmp":"tmp/eslint-plugin-canonical_5.1.1_1734539150185_0.013941200550896538","host":"s3://npm-registry-packages-npm-production"},"readme":"<a name=\"user-content-eslint-plugin-canonical\"></a>\n<a name=\"eslint-plugin-canonical\"></a>\n# eslint-plugin-canonical\n\n[![NPM version](http://img.shields.io/npm/v/eslint-plugin-canonical.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-canonical)\n[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n\nESLint rules for [Canonical ruleset](https://github.com/gajus/eslint-config-canonical).\n\n<a name=\"user-content-eslint-plugin-canonical-installation\"></a>\n<a name=\"eslint-plugin-canonical-installation\"></a>\n## Installation\n\n<!-- -->\n\n```bash\nnpm install eslint --save-dev\nnpm install @typescript-eslint/parser --save-dev\nnpm install eslint-plugin-canonical --save-dev\n```\n\n<a name=\"user-content-eslint-plugin-canonical-configuration\"></a>\n<a name=\"eslint-plugin-canonical-configuration\"></a>\n## Configuration\n\n1. Set `parser` property to `@typescript-eslint/parser`.\n1. Add `plugins` section and specify `eslint-plugin-canonical` as a plugin.\n1. Enable rules.\n\n<!-- -->\n\n```json\n{\n  \"parser\": \"@typescript-eslint/parser\",\n  \"plugins\": [\n    \"canonical\"\n  ],\n  \"rules\": {\n    \"canonical/filename-match-exported\": 0,\n    \"canonical/filename-match-regex\": 0,\n    \"canonical/filename-no-index\": 0,\n    \"canonical/id-match\": [\n      2,\n      \"(^[A-Za-z]+(?:[A-Z][a-z]*)*\\\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\\\d$)*$)|(^(_|\\\\$)$)\",\n      {\n        \"ignoreDestructuring\": true,\n        \"ignoreNamedImports\": true,\n        \"onlyDeclarations\": true,\n        \"properties\": true\n      }\n    ],\n    \"canonical/no-restricted-strings\": 0,\n    \"canonical/no-use-extend-native\": 2,\n    \"canonical/prefer-inline-type-import\": 2,\n    \"canonical/sort-keys\": [\n      2,\n      \"asc\",\n      {\n        \"caseSensitive\": false,\n        \"natural\": true\n      }\n    ]\n  }\n}\n```\n\n<a name=\"user-content-eslint-plugin-canonical-configuration-shareable-configurations\"></a>\n<a name=\"eslint-plugin-canonical-configuration-shareable-configurations\"></a>\n### Shareable configurations\n\n<a name=\"user-content-eslint-plugin-canonical-configuration-shareable-configurations-recommended\"></a>\n<a name=\"eslint-plugin-canonical-configuration-shareable-configurations-recommended\"></a>\n#### Recommended\n\nThis plugin exports a [recommended configuration](./src/configs/recommended.json) that enforces Canonical type good practices.\n\nTo enable this configuration use the extends property in your `.eslintrc` config file:\n\n```json\n{\n  \"extends\": [\n    \"plugin:canonical/recommended\"\n  ],\n  \"plugins\": [\n    \"canonical\"\n  ]\n}\n```\n\nSee [ESLint documentation](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files) for more information about extending configuration files.\n\n<a name=\"user-content-eslint-plugin-canonical-rules\"></a>\n<a name=\"eslint-plugin-canonical-rules\"></a>\n## Rules\n\n<!-- Rules are sorted alphabetically. -->\n\n<a name=\"user-content-eslint-plugin-canonical-rules-destructuring-property-newline\"></a>\n<a name=\"eslint-plugin-canonical-rules-destructuring-property-newline\"></a>\n### <code>destructuring-property-newline</code>\n\nLike [`object-property-newline`](https://eslint.org/docs/rules/object-property-newline), but for destructuring.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nconst {a,b} = obj;\n// Message: undefined\n\nconst [a,b] = obj;\n// Message: undefined\n\nconst {a,b,c} = obj;\n// Message: undefined\n// Message: undefined\n\nconst {\na,b} = obj;\n// Message: undefined\n\n({a,b}) => {};\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nconst {a,\nb} = obj;\n\n// Options: [{\"allowAllPropertiesOnSameLine\":true}]\nconst {a,b} = obj;\n\n// Options: [{\"allowAllPropertiesOnSameLine\":true}]\nconst [a,b] = obj;\n\nconst {a} = obj;\n\nconst {\na\n} = obj;\n\n({a,\nb}) => {};\n\nconst [a,,b] = obj;\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-export-specifier-newline\"></a>\n<a name=\"eslint-plugin-canonical-rules-export-specifier-newline\"></a>\n### <code>export-specifier-newline</code>\n\nForces every export specifier to be on a new line.\n\nTip: Combine this rule with `object-curly-newline` to have every specifier on its own line.\n\n```json\n\"object-curly-newline\": [\n  2,\n  {\n    \"ExportDeclaration\": \"always\"\n  }\n],\n```\n\nWorking together, both rules will produces exports such as:\n\n```ts\nexport { \n  a,\n  b,\n  c\n};\n```\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nconst a = 1; const b = 2; const c = 3; export { a, b, c };\n// Message: undefined\n// Message: undefined\n\nconst a = 1; const b = 2; const c = 3; export { a, b, c, };\n// Message: undefined\n// Message: undefined\n\nconst a = 1; const b = 2; export { a as default, b }\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nexport { \n a,\nb,\nc\n } from 'foo'\n\nconst a = 1; const b = 2; const c = 3; export { \n a,\nb,\nc\n };\n\nexport * from 'foo'\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-filename-match-exported\"></a>\n<a name=\"eslint-plugin-canonical-rules-filename-match-exported\"></a>\n### <code>filename-match-exported</code>\n\nMatch the file name against the default exported value in the module. Files that don't have a default export will be ignored. The exports of `index.js` are matched against their parent directory.\n\n```js\n// Considered problem only if the file isn't named foo.js or foo/index.js\nexport default function foo() {}\n\n// Considered problem only if the file isn't named Foo.js or Foo/index.js\nmodule.exports = class Foo() {}\n\n// Considered problem only if the file isn't named someVariable.js or someVariable/index.js\nmodule.exports = someVariable;\n\n// Never considered a problem\nexport default { foo: \"bar\" };\n```\n\nIf your filename policy doesn't quite match with your variable naming policy, you can add one or multiple transforms:\n\n```json\n\"canonical/filename-match-exported\": [ 2, { \"transforms\": \"kebab\" } ]\n```\n\nNow, in your code:\n\n```js\n// Considered problem only if file isn't named variable-name.js or variable-name/index.js\nexport default function variableName;\n```\n\nAvailable transforms:\n\n* `snake`\n* `kebab`\n* `camel`\n* `pascal`\n\nFor multiple transforms simply specify an array like this (null in this case stands for no transform):\n\n```json\n\"canonical/filename-match-exported\": [2, { \"transforms\": [ null, \"kebab\", \"snake\" ] } ]\n```\n\nIf you prefer to use suffixes for your files (e.g. `Foo.react.js` for a React component file), you can use a second configuration parameter. It allows you to remove parts of a filename matching a regex pattern before transforming and matching against the export.\n\n```json\n\"canonical/filename-match-exported\": [ 2, { \"suffix\": \"\\\\.react$\" } ]\n```\n\nNow, in your code:\n\n```js\n// Considered problem only if file isn't named variableName.react.js, variableName.js or variableName/index.js\nexport default function variableName;\n```\n\nIf you also want to match exported function calls you can use the third option (a boolean flag).\n\n```json\n\"canonical/filename-match-exported\": [ 2, { \"matchCallExpression\": true } ]\n```\n\nNow, in your code:\n\n```js\n// Considered problem only if file isn't named functionName.js or functionName/index.js\nexport default functionName();\n```\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nmodule.exports = exported;\n// Message: undefined\n\nmodule.exports = class Foo {};\n// Message: undefined\n\nmodule.exports = class Foo { render() { return <span>Test Class</span>; } };\n// Message: undefined\n\nmodule.exports = function foo() {};\n// Message: undefined\n\nmodule.exports = function foo() { return <span>Test Fn</span> };\n// Message: undefined\n\nexport default exported;\n// Message: undefined\n\nexport default class Foo {};\n// Message: undefined\n\nexport default class Foo { render() { return <span>Test Class</span>; } };\n// Message: undefined\n\nexport default function foo() {};\n// Message: undefined\n\nexport default function foo() { return <span>Test Fn</span> };\n// Message: undefined\n\nmodule.exports = exported;\n// Message: undefined\n\nmodule.exports = class Foo { render() { return <span>Test Class</span>; } };\n// Message: undefined\n\n// Options: [{\"transforms\":\"snake\"}]\nmodule.exports = variableName;\n// Message: undefined\n\n// Options: [{\"transforms\":\"kebab\"}]\nexport default variableName;\n// Message: undefined\n\n// Options: [{\"transforms\":\"pascal\"}]\nexport default variableName;\n// Message: undefined\n\n// Options: [{\"transforms\":[\"pascal\",\"snake\"]}]\nexport default variableName;\n// Message: undefined\n\n// Options: [{\"suffix\":\"\\\\.react$\"}]\nexport default class Foo { render() { return <span>Test Class</span>; } };\n// Message: undefined\n\n// Options: [{\"suffix\":\"\\\\.react$\"}]\nexport default class Foo { render() { return <span>Test Class</span>; } };\n// Message: undefined\n\n// Options: [{\"matchCallExpression\":true}]\nmodule.exports = foo();\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nmodule.exports = function() {};\n\nvar foo = 'bar';\n\nexport default foo();\n\nmodule.exports = exported;\n\nmodule.exports = class Foo {};\n\nmodule.exports = class Foo { render() { return <span>Test Class</span>; } };\n\nmodule.exports = function foo() {};\n\nmodule.exports = foo();\n\nmodule.exports = function foo() { return <span>Test Fn</span> };\n\nexport default exported;\n\nexport default class Foo {};\n\nexport default class Foo { render() { return <span>Test Class</span>; } };\n\nexport default function foo() {};\n\nexport default function foo() { return <span>Test Fn</span> };\n\nexport default function foo() {};\n\nexport default function foo() { return <span>Test Fn</span> };\n\nexport default function index() {};\n\n// Options: [{\"transforms\":\"snake\"}]\nmodule.exports = variableName;\n\n// Options: [{\"transforms\":\"snake\"}]\nmodule.exports = variableName;\n\n// Options: [{\"transforms\":\"kebab\"}]\nmodule.exports = variableName;\n\n// Options: [{\"transforms\":\"camel\"}]\nmodule.exports = variable_name;\n\n// Options: [{\"transforms\":\"snake\"}]\nexport default variableName;\n\n// Options: [{\"transforms\":\"kebab\"}]\nexport default variableName;\n\n// Options: [{\"transforms\":\"camel\"}]\nexport default variable_name;\n\n// Options: [{\"transforms\":\"pascal\"}]\nexport default variable_name;\n\n// Options: [{\"transforms\":[\"pascal\",\"camel\"]}]\nexport default variable_name;\n\n// Options: [{\"transforms\":[\"pascal\",\"camel\"]}]\nexport default variable_name;\n\n// Options: [{\"suffix\":\"\\\\.react$\"}]\nmodule.exports = class Foo { render() { return <span>Test Class</span>; } };\n\n// Options: [{\"suffix\":\"\\\\.react$\"}]\nexport default class Foo { render() { return <span>Test Class</span>; } };\n\n// Options: [{\"matchCallExpression\":true}]\nmodule.exports = foo();\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-filename-match-regex\"></a>\n<a name=\"eslint-plugin-canonical-rules-filename-match-regex\"></a>\n### <code>filename-match-regex</code>\n\nEnforce a certain file naming convention using a regular expression.\n\nThe convention can be configured using a regular expression (the default is `camelCase.js`). Additionally\nexporting files can be ignored with a second configuration parameter.\n\n```json\n\"canonical/filename-match-regex\": [2, { \"regex\": \"^[a-z_]+$\", \"ignoreExporting\": true }]\n```\n\nWith these configuration options, `camelCase.js` will be reported as an error while `snake_case.js` will pass.\nAdditionally the files that have a named default export (according to the logic in the `match-exported` rule) will be\nignored.  They could be linted with the `match-exported` rule. Please note that exported function calls are not\nrespected in this case.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nvar foo = 'bar';\n// Message: undefined\n\nvar foo = 'bar';\n// Message: undefined\n\nvar foo = 'bar';\n// Message: undefined\n\n// Options: [{\"regex\":\"^[a-z_]$\"}]\nvar foo = 'bar';\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nvar foo = 'bar';\n\nvar foo = 'bar';\n\nvar foo = 'bar';\n\n// Options: [{\"regex\":\"^[a-z_]+$\"}]\nvar foo = 'bar';\n\n// Options: [{\"regex\":\"^[a-z_]+$\"}]\nvar foo = 'bar';\n\nvar foo = 'bar';\n\n// Options: [{\"ignoreExporting\":true}]\nmodule.exports = foo\n\n// Options: [{\"ignoreExporting\":true,\"regex\":\"^[a-z_]$\"}]\nmodule.exports = foo\n\n// Options: [{\"ignoreExporting\":true,\"regex\":\"^[a-z_]+$\"}]\nmodule.exports = foo()\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-filename-no-index\"></a>\n<a name=\"eslint-plugin-canonical-rules-filename-no-index\"></a>\n### <code>filename-no-index</code>\n\nHaving a bunch of `index.js` files can have negative influence on developer experience, e.g. when\nopening files by name. When enabling this rule. `index.js` files will always be considered a problem.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nvar foo = 'bar';\n// Message: undefined\n\nvar foo = 'bar';\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nvar foo = 'bar';\n\nvar foo = 'bar';\n\nvar foo = 'bar';\n\nvar foo = 'bar';\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-id-match\"></a>\n<a name=\"eslint-plugin-canonical-rules-id-match\"></a>\n### <code>id-match</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nNote: This rule is equivalent to [`id-match`](https://eslint.org/docs/rules/id-match), except for addition of `ignoreNamedImports`.\n\nThis rule requires identifiers in assignments and `function` definitions to match a specified regular expression.\n\n<a name=\"user-content-eslint-plugin-canonical-rules-id-match-options\"></a>\n<a name=\"eslint-plugin-canonical-rules-id-match-options\"></a>\n#### Options\n\n* `\"properties\": false` (default) does not check object properties\n* `\"properties\": true` requires object literal properties and member expression assignment properties to match the specified regular expression\n* `\"classFields\": false` (default) does not class field names\n* `\"classFields\": true` requires class field names to match the specified regular expression\n* `\"onlyDeclarations\": false` (default) requires all variable names to match the specified regular expression\n* `\"onlyDeclarations\": true` requires only `var`, `function`, and `class` declarations to match the specified regular expression\n* `\"ignoreDestructuring\": false` (default) enforces `id-match` for destructured identifiers\n* `\"ignoreDestructuring\": true` does not check destructured identifiers\n* `\"ignoreNamedImports\": false` (default) enforces `id-match` for named imports\n* `\"ignoreNamedImports\": true` does not check named imports\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Options: [\"^[a-z]+$\",{\"onlyDeclarations\":true}]\nvar __foo = \"Matthieu\"\n// Message: undefined\n\n// Options: [\"^[a-z]+$\"]\nfirst_name = \"Matthieu\"\n// Message: undefined\n\n// Options: [\"^z\"]\nfirst_name = \"Matthieu\"\n// Message: undefined\n\n// Options: [\"^[a-z]+(_[A-Z][a-z])*$\"]\nLast_Name = \"Larcher\"\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar obj = {key: no_under}\n// Message: undefined\n\n// Options: [\"^[^_]+$\"]\nfunction no_under21(){}\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nobj.no_under22 = function(){};\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nno_under23.foo = function(){};\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\n[no_under24.baz]\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nif (foo.bar_baz === boom.bam_pow) { [no_under25.baz] }\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nfoo.no_under26 = boom.bam_pow\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar foo = { no_under27: boom.bam_pow }\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nfoo.qux.no_under28 = { bar: boom.bam_pow }\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar o = {no_under29: 1}\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nobj.no_under30 = 2;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar { category_id: category_alias } = query;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"ignoreDestructuring\":true,\"properties\":true}]\nvar { category_id: category_alias } = query;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"ignoreDestructuring\":true,\"properties\":true}]\nvar { category_id: categoryId, ...other_props } = query;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar { category_id } = query;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar { category_id = 1 } = query;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport no_camelcased from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport * as no_camelcased from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\"]\nexport * as no_camelcased from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport { no_camelcased as no_camel_cased } from \"external module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport { camelCased as no_camel_cased } from \"external module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport { camelCased, no_camelcased } from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport { no_camelcased as camelCased, another_no_camelcased } from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport camelCased, { no_camelcased } from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nimport no_camelcased, { another_no_camelcased as camelCased } from \"external-module\";\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nfunction foo({ no_camelcased }) {};\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nfunction foo({ no_camelcased = 'default value' }) {};\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nconst no_camelcased = 0; function foo({ camelcased_value = no_camelcased }) {}\n// Message: undefined\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nconst { bar: no_camelcased } = foo;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nfunction foo({ value_1: my_default }) {}\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nfunction foo({ isCamelcased: no_camelcased }) {};\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar { foo: bar_baz = 1 } = quz;\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nconst { no_camelcased = false } = bar;\n// Message: undefined\n\n// Options: [\"^[^_]+$\"]\nclass x { _foo() {} }\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"classFields\":true}]\nclass x { _foo = 1; }\n// Message: undefined\n\n// Options: [\"^[^_]+$\",{\"ignoreNamedImports\":false}]\nimport { no_camelcased } from \"external-module\";\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\n// Options: [\"^[a-z]+$\",{\"onlyDeclarations\":true}]\n__foo = \"Matthieu\"\n\n// Options: [\"^[a-z]+$\"]\nfirstname = \"Matthieu\"\n\n// Options: [\"[a-z]+\"]\nfirst_name = \"Matthieu\"\n\n// Options: [\"^f\"]\nfirstname = \"Matthieu\"\n\n// Options: [\"^[a-z]+(_[A-Z][a-z]+)*$\"]\nlast_Name = \"Larcher\"\n\n// Options: [\"^[a-z]+(_[A-Z][a-z])*$\"]\nparam = \"none\"\n\n// Options: [\"^[^_]+$\"]\nfunction noUnder(){}\n\n// Options: [\"^[^_]+$\"]\nno_under()\n\n// Options: [\"^[^_]+$\"]\nfoo.no_under2()\n\n// Options: [\"^[^_]+$\"]\nvar foo = bar.no_under3;\n\n// Options: [\"^[^_]+$\"]\nvar foo = bar.no_under4.something;\n\n// Options: [\"^[^_]+$\"]\nfoo.no_under5.qux = bar.no_under6.something;\n\n// Options: [\"^[^_]+$\"]\nif (bar.no_under7) {}\n\n// Options: [\"^[^_]+$\"]\nvar obj = { key: foo.no_under8 };\n\n// Options: [\"^[^_]+$\"]\nvar arr = [foo.no_under9];\n\n// Options: [\"^[^_]+$\"]\n[foo.no_under10]\n\n// Options: [\"^[^_]+$\"]\nvar arr = [foo.no_under11.qux];\n\n// Options: [\"^[^_]+$\"]\n[foo.no_under12.nesting]\n\n// Options: [\"^[^_]+$\"]\nif (foo.no_under13 === boom.no_under14) { [foo.no_under15] }\n\n// Options: [\"^[a-z$]+([A-Z][a-z]+)*$\"]\nvar myArray = new Array(); var myDate = new Date();\n\n// Options: [\"^[^_]+$\"]\nvar x = obj._foo;\n\n// Options: [\"^[^_]+$\",{\"onlyDeclarations\":true,\"properties\":true}]\nvar obj = {key: no_under}\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar {key_no_under: key} = {}\n\n// Options: [\"^[^_]+$\",{\"ignoreDestructuring\":true,\"properties\":true}]\nvar { category_id } = query;\n\n// Options: [\"^[^_]+$\",{\"ignoreDestructuring\":true,\"properties\":true}]\nvar { category_id: category_id } = query;\n\n// Options: [\"^[^_]+$\",{\"ignoreDestructuring\":true,\"properties\":true}]\nvar { category_id = 1 } = query;\n\n// Options: [\"^[^_]+$\",{\"properties\":true}]\nvar o = {key: 1}\n\n// Options: [\"^[^_]+$\",{\"properties\":false}]\nvar o = {no_under16: 1}\n\n// Options: [\"^[^_]+$\",{\"properties\":false}]\nobj.no_under17 = 2;\n\n// Options: [\"^[^_]+$\",{\"properties\":false}]\nvar obj = {\n no_under18: 1 \n};\n obj.no_under19 = 2;\n\n// Options: [\"^[^_]+$\",{\"properties\":false}]\nobj.no_under20 = function(){};\n\n// Options: [\"^[^_]+$\",{\"properties\":false}]\nvar x = obj._foo2;\n\n// Options: [\"^[^_]+$\"]\nclass x { foo() {} }\n\n// Options: [\"^[^_]+$\"]\nclass x { #foo() {} }\n\n// Options: [\"^[^_]+$\",{\"ignoreNamedImports\":true}]\nimport { no_camelcased } from \"external-module\";\n\n// Options: [\"^[a-zA-Z\\\\d]+$\"]\n\n        const {\n          index,\n          '0': n0,\n          '1': n1,\n        } = exampleCode;\n      \n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-import-specifier-newline\"></a>\n<a name=\"eslint-plugin-canonical-rules-import-specifier-newline\"></a>\n### <code>import-specifier-newline</code>\n\nForces every import specifier to be on a new line.\n\nTip: Combine this rule with `object-curly-newline` to have every specifier on its own line.\n\n```json\n\"object-curly-newline\": [\n  2,\n  {\n    \"ImportDeclaration\": \"always\"\n  }\n],\n```\n\nWorking together, both rules will produces imports such as:\n\n```ts\nimport { \n  a,\n  b,\n  c\n} from 'foo';\n```\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nimport {a, b} from 'foo';\n// Message: undefined\n\nimport a, {b, c} from 'foo';\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nimport {a,\nb} from 'foo'\n\nimport a, {b,\nc} from 'foo'\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-barrel-import\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-barrel-import\"></a>\n### <code>no-barrel-import</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nRequires that resources are imported from the same files in which they are defined.\n\nThis rule converts the following:\n\n```ts\n// foo.ts\nimport { bar } from './bar';\n// bar.ts\nexport { baz as bar } from './baz';\n// baz.ts\nexport const baz = 'BAZ';\n```\n\nto:\n\n```ts\n// foo.ts\nimport { baz as bar } from './baz';\n// baz.ts\nexport const baz = 'BAZ';\n```\n\nThis rule handles\n\n* named imports\n* default imports\n* aliased imports\n\nYou must configure `import/parsers` and `import/resolver` for this rule to work, e.g.\n\n```ts\nsettings: {\n  'import/parsers': {\n    '@typescript-eslint/parser': ['.ts', '.tsx'],\n  },\n  'import/resolver': {\n    typescript: {\n      project: path.resolve(\n        __dirname,\n        'tsconfig.json',\n      ),\n    },\n  },\n},\n```\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/barrelImport/tsconfig.json\"}}}\nimport { foo } from './bar';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/barrelImportAliased/tsconfig.json\"}}}\nimport { foo as FOO } from './bar';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/barrelImportAliasedReexport/tsconfig.json\"}}}\nimport { bar } from './bar';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/barrelImportDeep/tsconfig.json\"}}}\nimport { foo } from './baz';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/barrelImportDefault/tsconfig.json\"}}}\nimport foo from './bar';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/barrelTypeImport/tsconfig.json\"}}}\nimport { type Foo } from './bar';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/invalid/mixedImport/tsconfig.json\"}}}\nimport { foo, bar } from './bar';\n\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/valid/directImport/tsconfig.json\"}}}\nimport { foo } from './foo';\n\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/valid/directImportDefault/tsconfig.json\"}}}\nimport foo from './foo';\n\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noBarrelImport/valid/packageImport/tsconfig.json\"}}}\nimport { logLevels } from 'roarr';\n\n```\n\n</details>\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-export-all\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-export-all\"></a>\n### <code>no-export-all</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nRequite that re-exports are named.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noExportAll/invalid/namespaceExport/tsconfig.json\"}}}\nexport * from './foo';\n\n// Message: undefined\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noExportAll/invalid/reExport/tsconfig.json\"}}}\nexport * from './foo';\n\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noExportAll/valid/namedExport/tsconfig.json\"}}}\nexport { FOO } from './foo';\n\n\n// Settings: {\"import/parsers\":{\"@typescript-eslint/parser\":[\".ts\",\".tsx\"]},\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/noExportAll/valid/aliasedReExport/tsconfig.json\"}}}\nexport * as foo from './foo';\n\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-import-namespace-destructure\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-import-namespace-destructure\"></a>\n### <code>no-import-namespace-destructure</code>\n\nDisallows the practice of importing an entire module's namespace using import * as Namespace and then destructuring specific exports from it. Instead, it encourages direct importing of only the necessary named exports from a module.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nimport * as bar from 'bar'; const { foo } = bar;\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nimport * as bar from 'bar'\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-re-export\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-re-export\"></a>\n### <code>no-re-export</code>\n\nDisallows re-exports of imports.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n\n          import Button1 from 'app/CustomButton';\n          export const CustomButton = Button1;\n        \n// Message: undefined\n\n\n          import { Button as CustomButton2 } from 'app/CustomButton';\n          export const CustomButton = CustomButton2;\n        \n// Message: undefined\n\n\n          import * as Button3 from \"app/Button\";\n          export const CustomButton = Button3;\n        \n// Message: undefined\n\n\n          import Button4 from 'app/CustomButton';\n          export default Button4;\n        \n// Message: undefined\n\n\n          export { default as Button5 } from 'app/CustomButton';\n        \n// Message: undefined\n\n\n          import Button6 from 'app/CustomButton';\n          export {\n            Button6\n          };\n        \n// Message: undefined\n\n\n          import Button7 from 'app/CustomButton';\n          export const Buttons = {\n            Button: Button7\n          };\n        \n// Message: undefined\n\n\n          import Button8 from 'app/CustomButton';\n          export default Button8;\n          export { Button8 }\n        \n// Message: undefined\n// Message: undefined\n\n\n          export * from 'app/CustomButton';\n        \n// Message: undefined\n```\n\n</details>\n\n\n> [!NOTE]\n> This rule was originally developed by @christianvuerings as part of https://github.com/christianvuerings/eslint-plugin-no-re-export\n<a name=\"user-content-eslint-plugin-canonical-rules-no-reassign-imports\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-reassign-imports\"></a>\n### <code>no-reassign-imports</code>\n\nRestricts re-assigning imports to variables that are exported.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nimport { Foo } from './Foo';\n\nexport const Bar = {\n  Foo,\n};\n\n// Message: undefined\n\nimport { Foo } from './Foo';\n\nexport default {\n  Foo,\n};\n\n// Message: undefined\n```\n\n</details>\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-restricted-imports\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-restricted-imports\"></a>\n### <code>no-restricted-imports</code>\n\nDisallow specified modules when loaded by `import`\n\nThis rule is similar to [`no-restricted-imports`](https://eslint.org/docs/latest/rules/no-restricted-imports) except that it allows you to specify unique messages for each restricted import (a workaround for issue [issues#15261](https://github.com/eslint/eslint/issues/15261)).\n\n> **Note:** Unlike the ESLint rule, this rule does not support the `patterns` option and it does not handle exports.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Options: [{\"paths\":[{\"importName\":\"*\",\"message\":\"foo is restricted\",\"name\":\"bar\"}]}]\nimport * as bar from 'bar'\n// Message: undefined\n\n// Options: [{\"paths\":[{\"importName\":\"foo\",\"message\":\"foo is restricted\",\"name\":\"bar\"}]}]\nimport { foo } from 'bar'\n// Message: undefined\n\n// Options: [{\"paths\":[{\"importName\":\"default\",\"message\":\"foo is restricted\",\"name\":\"bar\"}]}]\nimport { default as bar } from 'bar'\n// Message: undefined\n\n// Options: [{\"paths\":[{\"message\":\"foo is restricted\",\"name\":\"bar\"}]}]\nimport bar from 'bar'\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\n// Options: [{\"paths\":[{\"importName\":\"foo\",\"message\":\"foo is restricted\",\"name\":\"bar\"}]}]\nimport { bar } from 'bar'\n```\n\n</details>\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-restricted-strings\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-restricted-strings\"></a>\n### <code>no-restricted-strings</code>\n\nDisallow specified strings.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Options: [[\"bar\"]]\nvar foo = \"bar\"\n// Message: undefined\n\n// Options: [[\"bar\"]]\nconst foo = `bar ${baz}`;\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nconst foo = \"bar\";\n```\n\n</details>\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-restricted-strings-options-1\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-restricted-strings-options-1\"></a>\n#### Options\n\nThe 1st option is an array of strings that cannot be contained in the codebase.\n\n<a name=\"user-content-eslint-plugin-canonical-rules-no-use-extend-native\"></a>\n<a name=\"eslint-plugin-canonical-rules-no-use-extend-native\"></a>\n### <code>no-use-extend-native</code>\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nArray.prototype.custom\n// Message: undefined\n\nArray.to\n// Message: undefined\n\nArray.to()\n// Message: undefined\n\n[].length()\n// Message: undefined\n\n'unicorn'.green\n// Message: undefined\n\n[].custom()\n// Message: undefined\n\n({}).custom()\n// Message: undefined\n\n/match_this/.custom()\n// Message: undefined\n\n'string'.custom()\n// Message: undefined\n\nconsole.log('foo'.custom)\n// Message: undefined\n\nconsole.log('foo'.custom())\n// Message: undefined\n\n('str' + 'ing').custom()\n// Message: undefined\n\n('str' + 'i' + 'ng').custom()\n// Message: undefined\n\n(1 + 'ing').custom()\n// Message: undefined\n\n(/regex/ + 'ing').custom()\n// Message: undefined\n\n(1 + 1).toLowerCase()\n// Message: undefined\n\n(1 + 1 + 1).toLowerCase()\n// Message: undefined\n\n(function testFunction() {}).custom()\n// Message: undefined\n\nnew Array().custom()\n// Message: undefined\n\nnew ArrayBuffer().custom()\n// Message: undefined\n\nnew Boolean().custom()\n// Message: undefined\n\nnew DataView().custom()\n// Message: undefined\n\nnew Date().custom()\n// Message: undefined\n\nnew Error().custom()\n// Message: undefined\n\nnew Float32Array().custom()\n// Message: undefined\n\nnew Float64Array().custom()\n// Message: undefined\n\nnew Function().custom()\n// Message: undefined\n\nnew Int16Array().custom()\n// Message: undefined\n\nnew Int32Array().custom()\n// Message: undefined\n\nnew Int8Array().custom()\n// Message: undefined\n\nnew Map().custom()\n// Message: undefined\n\nnew Number().custom()\n// Message: undefined\n\nnew Object().custom()\n// Message: undefined\n\nnew Promise().custom()\n// Message: undefined\n\nnew RegExp().custom()\n// Message: undefined\n\nnew Set().custom()\n// Message: undefined\n\nnew String().custom()\n// Message: undefined\n\nnew Symbol().custom()\n// Message: undefined\n\nnew Uint16Array().custom()\n// Message: undefined\n\nnew Uint32Array().custom()\n// Message: undefined\n\nnew Uint8Array().custom()\n// Message: undefined\n\nnew Uint8ClampedArray().custom()\n// Message: undefined\n\nnew WeakMap().custom()\n// Message: undefined\n\nnew WeakSet().custom()\n// Message: undefined\n\nnew Array()['custom']\n// Message: undefined\n\nnew Array()['custom']()\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nerror.plugin\n\nerror.plugn()\n\narray.custom\n\nObject.groupBy()\n\nObject.assign()\n\nObject.keys\n\nObject.keys()\n\ngulp.task()\n\nCustom.prototype.custom\n\nArray.prototype.map\n\nArray.prototype.map.call([1,2,3], function (x) { console.log(x) })\n\nArray.apply\n\nArray.call(null, 1, 2, 3)\n\n[].push(1)\n\n[][0]\n\n{}[i]\n\n{}[3]\n\n{}[j][k]\n\n({foo: {bar: 1, baz: 2}}[i][j])\n\n({}).toString()\n\n/match_this/.test()\n\n'foo'.length\n\n'hi'.padEnd\n\n'hi'.padEnd()\n\nconsole.log('foo'.length)\n\nconsole.log('foo'.toString)\n\nconsole.log('foo'.toString())\n\nconsole.log(gulp.task)\n\nconsole.log(gulp.task())\n\n'string'.toString()\n\n(1).toFixed()\n\n1..toFixed()\n\n1.0.toFixed()\n\n('str' + 'ing').toString()\n\n('str' + 'i' + 'ng').toString()\n\n(1 + 1).valueOf()\n\n(1 + 1 + (1 + 1)).valueOf()\n\n(1 + 1 + 1).valueOf()\n\n(1 + 'string').toString()\n\n(/regex/ + /regex/).toString()\n\n(/regex/ + 1).toString()\n\n([1] + [2]).toString()\n\n(function testFunction() {}).toString()\n\nTest.prototype\n\nnew Array().toString()\n\nnew ArrayBuffer().constructor()\n\nnew Boolean().toString()\n\nnew DataView().buffer()\n\nnew Date().getDate()\n\nnew Error().message()\n\nnew Error().stack\n\nnew Error().stack.slice(1)\n\nnew Float32Array().values()\n\nnew Float64Array().values()\n\nnew Function().toString()\n\nnew Int16Array().values()\n\nnew Int32Array().values()\n\nnew Int8Array().values()\n\nnew Map().clear()\n\nnew Number().toString()\n\nnew Object().toString()\n\nnew Object().toString\n\nnew Promise().then()\n\nnew RegExp().test()\n\nnew Set().values()\n\nnew String().toString()\n\nnew Symbol().toString()\n\nnew Uint16Array().values()\n\nnew Uint32Array().values()\n\nnew Uint8ClampedArray().values()\n\nnew WeakMap().get()\n\nnew WeakSet().has()\n\nnew Array()['length']\n\nnew Array()['toString']()\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-prefer-import-alias\"></a>\n<a name=\"eslint-plugin-canonical-rules-prefer-import-alias\"></a>\n### <code>prefer-import-alias</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nRestrict imports to path aliases or relative imports limited by depth.\n\nThe same alias can be applied using multiple rules, e.g.\n\n```ts\n'canonical/prefer-import-alias': [\n  2,\n  {\n    aliases: [\n      {\n        alias: '@/',\n        matchParent: path.resolve(__dirname, 'src'),\n        matchPath: '^src\\\\/',\n      },\n      {\n        alias: '@/',\n        matchPath: '^src\\\\/',\n        maxRelativeDepth: 2,\n      },\n    ],\n  },\n],\n```\n\nIn this example, we are saying:\n\n* rewrite import path to use alias when\n  * import path matches `^src\\/`\n  * the grandfather directory is `path.resolve(__dirname, 'src')`\n* rewrite import path to use alias when\n  * import path matches `^src\\/`\n  * relative import is greater than 2\n\nThe grandfather directory is essentially whichever directory that is accessed by the doubledot (`../`) by the import path.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Options: [{\"aliases\":[{\"alias\":\"@/a/\",\"matchPath\":\"^a\\\\/\",\"maxRelativeDepth\":-1}],\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { bar } from './bar';\n// Message: undefined\n\n// Options: [{\"aliases\":[{\"alias\":\"@/a/\",\"matchPath\":\"^a\\\\/\",\"maxRelativeDepth\":1}],\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { baz } from '../baz';\n// Message: undefined\n\n// Options: [{\"aliases\":[{\"alias\":\"@/a/\",\"matchPath\":\"^a\\\\/\"}],\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { bar } from '../bar';\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\n// Options: [{\"aliases\":[{\"alias\":\"@/a/\",\"matchParent\":\"<baseDir>/fixtures/preferImportAlias\",\"matchPath\":\"^a\\\\/\"}],\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { bar } from '../bar';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport Foo from '@bar/baz';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport Foo, { Foo } from 'bar';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { foo } from './foo';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { foo } from '../foo';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { foo } from '.././foo';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { foo } from '././../foo';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { foo } from '@bar/baz';\n\n// Options: [{\"baseDirectory\":\"<baseDir>/fixtures/preferImportAlias\"}]\nimport { foo } from '../../foo';\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-prefer-inline-type-import\"></a>\n<a name=\"eslint-plugin-canonical-rules-prefer-inline-type-import\"></a>\n### <code>prefer-inline-type-import</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nTypeScript 4.5 introduced [type modifiers](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names) that allow to inline type imports as opposed to having dedicated `import type`. This allows to remove duplicate type imports. This rule enforces use of import type modifiers.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nimport type {foo} from 'bar'\n// Message: undefined\n\nimport type {foo, baz} from 'bar'\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nimport {type foo} from 'bar'\n\nimport type Foo from 'bar'\n\nimport type * as Foo from 'bar'\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-prefer-react-lazy\"></a>\n<a name=\"eslint-plugin-canonical-rules-prefer-react-lazy\"></a>\n### <code>prefer-react-lazy</code>\n\nRequires that components that can be loaded lazily be imported using the `React.lazy()` function.\n\n```tsx\nimport { lazy } from 'react';\nimport { Foo } from './Foo';\n\nexport default () => {\n  return Math.random() > 0.5 ? <Foo /> : null;\n};\n```\n\nThis rule converts the above code to:\n\n```tsx\nimport { lazy } from 'react';\n\nconst Foo = lazy(() => import('./Foo.js').then(({ Foo }) => ({ default: Foo })));\n\nexport default () => {\n  return Math.random() > 0.5 ? <Foo /> : null;\n};\n```\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nimport React from 'react';\nimport { Foo } from './Foo';\n\nexport default () => {\n  return <>\n    {Math.random() > 0.5 ? <Foo /> : null}\n  </>;\n};\n// Message: undefined\n\nimport React from 'react';\nimport { Foo } from './Foo';\n\nexport default () => {\n  return <>\n    {Math.random() > 0.5 ? <div>\n      <Foo />\n    </div> : null}\n  </>;\n};\n// Message: undefined\n\nimport React from 'react';\nimport { Foo } from './Foo';\n\nexport default () => {\n  return Math.random() > 0.5 ? <Foo /> : null;\n};\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nimport React, { lazy } from 'react';\n\nconst Foo = lazy(() => import('./Foo').then(({ Foo }) => ({ default: Foo })));\n\nexport default () => {\n  return Math.random() > 0.5 ? <Foo /> : null;\n};\n```\n\n</details>\n\n<a name=\"user-content-eslint-plugin-canonical-rules-prefer-use-mount\"></a>\n<a name=\"eslint-plugin-canonical-rules-prefer-use-mount\"></a>\n### <code>prefer-use-mount</code>\n\nIn React, it is common to use [`useEffect`](https://reactjs.org/docs/hooks-reference.html#useeffect) without dependencies when the intent is to run the effect only once (on mount and unmount). However, just doing that may lead to undesired side-effects, such as the effect being called twice in [Strict Mode](https://reactjs.org/docs/strict-mode.html). For this reason, it is better to use an abstraction such as [`useMount`](https://stackoverflow.com/a/72319081/368691) that handles this use case.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nuseEffect(() => {}, [])\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nuseEffect(() => {}, [foo])\n\nuseMount(() => {}, [])\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-rules-require-extension\"></a>\n<a name=\"eslint-plugin-canonical-rules-require-extension\"></a>\n### <code>require-extension</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nAdds `.js` extension to all imports and exports.\n\nIt resolves the following cases:\n\n<a name=\"user-content-eslint-plugin-canonical-rules-require-extension-relative-imports\"></a>\n<a name=\"eslint-plugin-canonical-rules-require-extension-relative-imports\"></a>\n#### Relative imports\n\nRelative imports that resolve to a file of the same name:\n\n```js\nimport './foo'; // => import './foo.js';\n```\n\nRelative imports that resolve to an index file:\n\n```js\nimport './foo'; // => import './foo/index.js';\n```\n\nThe above examples would also work if the file extension was `.ts` or `.tsx`, i.e.\n\n```js\nimport './foo'; // => import './foo.ts';\nimport './foo'; // => import './foo/index.tsx';\n```\n\n<a name=\"user-content-eslint-plugin-canonical-rules-require-extension-typescript-paths\"></a>\n<a name=\"eslint-plugin-canonical-rules-require-extension-typescript-paths\"></a>\n#### TypeScript paths\n\nFor this to work, you have to [configure `import/resolver`](https://www.npmjs.com/package/eslint-import-resolver-typescript):\n\n```ts\nsettings: {\n  'import/resolver': {\n    typescript: {\n      project: path.resolve(__dirname, 'tsconfig.json'),\n    },\n  },\n},\n```\n\nImports that resolve to a file of the same name:\n\n```js\nimport { foo } from '@/foo'; // => import { foo } from '@/foo.js';\n```\n\nImports that resolve to an index file:\n\n```js\nimport { foo } from '@/foo'; // => import { foo } from '@/foo/index.js';\n```\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/pathsImport/tsconfig.json\"}}}\nimport { foo } from '@/foo';\n\n// Message: undefined\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/pathsImportWithIndex/tsconfig.json\"}}}\nimport { foo } from '@/foo';\n\n// Message: undefined\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/relativeImport/tsconfig.json\"}}}\nimport { foo } from './foo';\n\n// Message: undefined\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/relativeImportWithIndex/tsconfig.json\"}}}\nimport { foo } from './foo';\n\n// Message: undefined\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/relativeNamedExport/tsconfig.json\"}}}\nexport { foo } from './foo';\n\n// Message: undefined\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/exportAllDeclaration/tsconfig.json\"}}}\nexport * from './foo';\n\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/pathsImportIgnoreSearchParams/tsconfig.json\"}}}\n// @ts-expect-error ignore search params\nimport { foo } from './foo.svg?url';\n\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/pathsImportIgnoreUnknownExtensions/tsconfig.json\"}}}\nimport { foo } from '@/foo.css';\n\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/pathsImportWithExtension/tsconfig.json\"}}}\nimport { foo } from '@/foo.js';\n\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/relativeImportIgnoreUnknownExtensions/tsconfig.json\"}}}\nimport { foo } from './foo.css';\n\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/relativeImportWithExtension/tsconfig.json\"}}}\nimport { foo } from './foo.js';\n\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/typedPackageImport/tsconfig.json\"}}}\n// Note that this resolves to roarr, which is a package with TypeScript types.\n// Compare this test to the \"packageTypesImport\" test which imports dependency's types.\nimport { Roarr } from 'roarr';\n\n\n// Settings: {\"import/resolver\":{\"typescript\":{\"project\":\"<baseDir>/tests/fixtures/requireExtension/packageTypesImport/tsconfig.json\"}}}\n// Note that this resolves to @types/chance, which is a TypeScript declaration file.\n// Compare this test to the \"typedPackageImport\" test which imports a typed dependency.\nimport { Chance } from 'chance';\n\n```\n\n</details>\n\n<a name=\"user-content-eslint-plugin-canonical-rules-sort-react-dependencies\"></a>\n<a name=\"eslint-plugin-canonical-rules-sort-react-dependencies\"></a>\n### <code>sort-react-dependencies</code>\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nRequires that dependencies of React methods (`useEffect`, `useCallback` and `useMemo`) are sorted alphabetically.\n\n<details><summary>📖 Examples</summary>\nThe following patterns are considered problems:\n\n```js\nuseEffect(() => {}, [b, a])\n// Message: undefined\n```\n\nThe following patterns are not considered problems:\n\n```js\nuseEffect(() => {}, [a, b])\n```\n\n</details>\n\n\n<a name=\"user-content-eslint-plugin-canonical-faq\"></a>\n<a name=\"eslint-plugin-canonical-faq\"></a>\n## FAQ\n\n<a name=\"user-content-eslint-plugin-canonical-faq-why-is-the-typescript-eslint-parser\"></a>\n<a name=\"eslint-plugin-canonical-faq-why-is-the-typescript-eslint-parser\"></a>\n### Why is the <code>@typescript-eslint/parser</code>?\n\nThis ESLint plugin is written using `@typescript-eslint/utils`, which assume that `@typescript-eslint/parser` is used.\n\nSome rules may work without `@typescript-eslint/parser`. However, rules are implemented and tested assuming that `@typescript-eslint/parser` is used.","publish_time":1734539150402,"maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"_cnpm_publish_time":1734539150402,"dist-tags":{"latest":"5.1.3"}}