Gathering detailed insights and metrics for @hishprorg/quas-quia-pariatur
Gathering detailed insights and metrics for @hishprorg/quas-quia-pariatur
Gathering detailed insights and metrics for @hishprorg/quas-quia-pariatur
Gathering detailed insights and metrics for @hishprorg/quas-quia-pariatur
npm install @hishprorg/quas-quia-pariatur
Typescript
Module System
Node Version
NPM Version
56.3
Supply Chain
83.5
Quality
85.9
Maintenance
100
Vulnerability
99.3
License
Cumulative downloads
Total Downloads
Last day
0%
0
Compared to previous day
Last week
0%
0
Compared to previous week
Last month
0%
0
Compared to previous month
Last year
0%
0
Compared to previous year
48
ESLint rules for Canonical ruleset.
1npm install eslint --save-dev 2npm install @typescript-eslint/parser --save-dev 3npm install @hishprorg/quas-quia-pariatur --save-dev
parser
property to @typescript-eslint/parser
.plugins
section and specify @hishprorg/quas-quia-pariatur
as a plugin.1{ 2 "parser": "@typescript-eslint/parser", 3 "plugins": [ 4 "canonical" 5 ], 6 "rules": { 7 "canonical/filename-match-exported": 0, 8 "canonical/filename-match-regex": 0, 9 "canonical/filename-no-index": 0, 10 "canonical/id-match": [ 11 2, 12 "(^[A-Za-z]+(?:[A-Z][a-z]*)*\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\d$)*$)|(^(_|\\$)$)", 13 { 14 "ignoreDestructuring": true, 15 "ignoreNamedImports": true, 16 "onlyDeclarations": true, 17 "properties": true 18 } 19 ], 20 "canonical/no-restricted-strings": 0, 21 "canonical/no-use-extend-native": 2, 22 "canonical/prefer-inline-type-import": 2, 23 "canonical/sort-keys": [ 24 2, 25 "asc", 26 { 27 "caseSensitive": false, 28 "natural": true 29 } 30 ] 31 } 32}
This plugin exports a recommended configuration that enforces Canonical type good practices.
To enable this configuration use the extends property in your .eslintrc
config file:
1{ 2 "extends": [ 3 "plugin:canonical/recommended" 4 ], 5 "plugins": [ 6 "canonical" 7 ] 8}
See ESLint documentation for more information about extending configuration files.
destructuring-property-newline
Like object-property-newline
, but for destructuring.
1const {a,b} = obj; 2// Message: undefined 3 4const [a,b] = obj; 5// Message: undefined 6 7const {a,b,c} = obj; 8// Message: undefined 9// Message: undefined 10 11const { 12a,b} = obj; 13// Message: undefined 14 15({a,b}) => {}; 16// Message: undefined
The following patterns are not considered problems:
1const {a, 2b} = obj; 3 4// Options: [{"allowAllPropertiesOnSameLine":true}] 5const {a,b} = obj; 6 7// Options: [{"allowAllPropertiesOnSameLine":true}] 8const [a,b] = obj; 9 10const {a} = obj; 11 12const { 13a 14} = obj; 15 16({a, 17b}) => {}; 18 19const [a,,b] = obj;
export-specifier-newline
Forces every export specifier to be on a new line.
Tip: Combine this rule with object-curly-newline
to have every specifier on its own line.
1"object-curly-newline": [ 2 2, 3 { 4 "ExportDeclaration": "always" 5 } 6],
Working together, both rules will produces exports such as:
1export { 2 a, 3 b, 4 c 5};
1const a = 1; const b = 2; const c = 3; export { a, b, c }; 2// Message: undefined 3// Message: undefined 4 5const a = 1; const b = 2; const c = 3; export { a, b, c, }; 6// Message: undefined 7// Message: undefined 8 9const a = 1; const b = 2; export { a as default, b } 10// Message: undefined
The following patterns are not considered problems:
1export { 2 a, 3b, 4c 5 } from 'foo' 6 7const a = 1; const b = 2; const c = 3; export { 8 a, 9b, 10c 11 }; 12 13export * from 'foo'
filename-match-exported
Match 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.
1// Considered problem only if the file isn't named foo.js or foo/index.js 2export default function foo() {} 3 4// Considered problem only if the file isn't named Foo.js or Foo/index.js 5module.exports = class Foo() {} 6 7// Considered problem only if the file isn't named someVariable.js or someVariable/index.js 8module.exports = someVariable; 9 10// Never considered a problem 11export default { foo: "bar" };
If your filename policy doesn't quite match with your variable naming policy, you can add one or multiple transforms:
1"canonical/filename-match-exported": [ 2, { "transforms": "kebab" } ]
Now, in your code:
1// Considered problem only if file isn't named variable-name.js or variable-name/index.js 2export default function variableName;
Available transforms:
snake
kebab
camel
pascal
For multiple transforms simply specify an array like this (null in this case stands for no transform):
1"canonical/filename-match-exported": [2, { "transforms": [ null, "kebab", "snake" ] } ]
If 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.
1"canonical/filename-match-exported": [ 2, { "suffix": "\\.react$" } ]
Now, in your code:
1// Considered problem only if file isn't named variableName.react.js, variableName.js or variableName/index.js 2export default function variableName;
If you also want to match exported function calls you can use the third option (a boolean flag).
1"canonical/filename-match-exported": [ 2, { "matchCallExpression": true } ]
Now, in your code:
1// Considered problem only if file isn't named functionName.js or functionName/index.js 2export default functionName();
1module.exports = exported; 2// Message: undefined 3 4module.exports = class Foo {}; 5// Message: undefined 6 7module.exports = class Foo { render() { return <span>Test Class</span>; } }; 8// Message: undefined 9 10module.exports = function foo() {}; 11// Message: undefined 12 13module.exports = function foo() { return <span>Test Fn</span> }; 14// Message: undefined 15 16export default exported; 17// Message: undefined 18 19export default class Foo {}; 20// Message: undefined 21 22export default class Foo { render() { return <span>Test Class</span>; } }; 23// Message: undefined 24 25export default function foo() {}; 26// Message: undefined 27 28export default function foo() { return <span>Test Fn</span> }; 29// Message: undefined 30 31module.exports = exported; 32// Message: undefined 33 34module.exports = class Foo { render() { return <span>Test Class</span>; } }; 35// Message: undefined 36 37// Options: [{"transforms":"snake"}] 38module.exports = variableName; 39// Message: undefined 40 41// Options: [{"transforms":"kebab"}] 42export default variableName; 43// Message: undefined 44 45// Options: [{"transforms":"pascal"}] 46export default variableName; 47// Message: undefined 48 49// Options: [{"transforms":["pascal","snake"]}] 50export default variableName; 51// Message: undefined 52 53// Options: [{"suffix":"\\.react$"}] 54export default class Foo { render() { return <span>Test Class</span>; } }; 55// Message: undefined 56 57// Options: [{"suffix":"\\.react$"}] 58export default class Foo { render() { return <span>Test Class</span>; } }; 59// Message: undefined 60 61// Options: [{"matchCallExpression":true}] 62module.exports = foo(); 63// Message: undefined
The following patterns are not considered problems:
1module.exports = function() {}; 2 3var foo = 'bar'; 4 5export default foo(); 6 7module.exports = exported; 8 9module.exports = class Foo {}; 10 11module.exports = class Foo { render() { return <span>Test Class</span>; } }; 12 13module.exports = function foo() {}; 14 15module.exports = foo(); 16 17module.exports = function foo() { return <span>Test Fn</span> }; 18 19export default exported; 20 21export default class Foo {}; 22 23export default class Foo { render() { return <span>Test Class</span>; } }; 24 25export default function foo() {}; 26 27export default function foo() { return <span>Test Fn</span> }; 28 29export default function foo() {}; 30 31export default function foo() { return <span>Test Fn</span> }; 32 33export default function index() {}; 34 35// Options: [{"transforms":"snake"}] 36module.exports = variableName; 37 38// Options: [{"transforms":"snake"}] 39module.exports = variableName; 40 41// Options: [{"transforms":"kebab"}] 42module.exports = variableName; 43 44// Options: [{"transforms":"camel"}] 45module.exports = variable_name; 46 47// Options: [{"transforms":"snake"}] 48export default variableName; 49 50// Options: [{"transforms":"kebab"}] 51export default variableName; 52 53// Options: [{"transforms":"camel"}] 54export default variable_name; 55 56// Options: [{"transforms":"pascal"}] 57export default variable_name; 58 59// Options: [{"transforms":["pascal","camel"]}] 60export default variable_name; 61 62// Options: [{"transforms":["pascal","camel"]}] 63export default variable_name; 64 65// Options: [{"suffix":"\\.react$"}] 66module.exports = class Foo { render() { return <span>Test Class</span>; } }; 67 68// Options: [{"suffix":"\\.react$"}] 69export default class Foo { render() { return <span>Test Class</span>; } }; 70 71// Options: [{"matchCallExpression":true}] 72module.exports = foo();
filename-match-regex
Enforce a certain file naming convention using a regular expression.
The convention can be configured using a regular expression (the default is camelCase.js
). Additionally
exporting files can be ignored with a second configuration parameter.
1"canonical/filename-match-regex": [2, { "regex": "^[a-z_]+$", "ignoreExporting": true }]
With these configuration options, camelCase.js
will be reported as an error while snake_case.js
will pass.
Additionally the files that have a named default export (according to the logic in the match-exported
rule) will be
ignored. They could be linted with the match-exported
rule. Please note that exported function calls are not
respected in this case.
1var foo = 'bar'; 2// Message: undefined 3 4var foo = 'bar'; 5// Message: undefined 6 7var foo = 'bar'; 8// Message: undefined 9 10// Options: [{"regex":"^[a-z_]$"}] 11var foo = 'bar'; 12// Message: undefined
The following patterns are not considered problems:
1var foo = 'bar'; 2 3var foo = 'bar'; 4 5var foo = 'bar'; 6 7// Options: [{"regex":"^[a-z_]+$"}] 8var foo = 'bar'; 9 10// Options: [{"regex":"^[a-z_]+$"}] 11var foo = 'bar'; 12 13var foo = 'bar'; 14 15// Options: [{"ignoreExporting":true}] 16module.exports = foo 17 18// Options: [{"ignoreExporting":true,"regex":"^[a-z_]$"}] 19module.exports = foo 20 21// Options: [{"ignoreExporting":true,"regex":"^[a-z_]+$"}] 22module.exports = foo()
filename-no-index
Having a bunch of index.js
files can have negative influence on developer experience, e.g. when
opening files by name. When enabling this rule. index.js
files will always be considered a problem.
1var foo = 'bar'; 2// Message: undefined 3 4var foo = 'bar'; 5// Message: undefined
The following patterns are not considered problems:
1var foo = 'bar'; 2 3var foo = 'bar'; 4 5var foo = 'bar'; 6 7var foo = 'bar';
id-match
The --fix
option on the command line automatically fixes problems reported by this rule.
Note: This rule is equivalent to id-match
, except for addition of ignoreNamedImports
.
This rule requires identifiers in assignments and function
definitions to match a specified regular expression.
"properties": false
(default) does not check object properties"properties": true
requires object literal properties and member expression assignment properties to match the specified regular expression"classFields": false
(default) does not class field names"classFields": true
requires class field names to match the specified regular expression"onlyDeclarations": false
(default) requires all variable names to match the specified regular expression"onlyDeclarations": true
requires only var
, function
, and class
declarations to match the specified regular expression"ignoreDestructuring": false
(default) enforces id-match
for destructured identifiers"ignoreDestructuring": true
does not check destructured identifiers"ignoreNamedImports": false
(default) enforces id-match
for named imports"ignoreNamedImports": true
does not check named imports1// Options: ["^[a-z]+$",{"onlyDeclarations":true}] 2var __foo = "Matthieu" 3// Message: undefined 4 5// Options: ["^[a-z]+$"] 6first_name = "Matthieu" 7// Message: undefined 8 9// Options: ["^z"] 10first_name = "Matthieu" 11// Message: undefined 12 13// Options: ["^[a-z]+(_[A-Z][a-z])*$"] 14Last_Name = "Larcher" 15// Message: undefined 16 17// Options: ["^[^_]+$",{"properties":true}] 18var obj = {key: no_under} 19// Message: undefined 20 21// Options: ["^[^_]+$"] 22function no_under21(){} 23// Message: undefined 24 25// Options: ["^[^_]+$",{"properties":true}] 26obj.no_under22 = function(){}; 27// Message: undefined 28 29// Options: ["^[^_]+$",{"properties":true}] 30no_under23.foo = function(){}; 31// Message: undefined 32 33// Options: ["^[^_]+$",{"properties":true}] 34[no_under24.baz] 35// Message: undefined 36 37// Options: ["^[^_]+$",{"properties":true}] 38if (foo.bar_baz === boom.bam_pow) { [no_under25.baz] } 39// Message: undefined 40 41// Options: ["^[^_]+$",{"properties":true}] 42foo.no_under26 = boom.bam_pow 43// Message: undefined 44 45// Options: ["^[^_]+$",{"properties":true}] 46var foo = { no_under27: boom.bam_pow } 47// Message: undefined 48 49// Options: ["^[^_]+$",{"properties":true}] 50foo.qux.no_under28 = { bar: boom.bam_pow } 51// Message: undefined 52 53// Options: ["^[^_]+$",{"properties":true}] 54var o = {no_under29: 1} 55// Message: undefined 56 57// Options: ["^[^_]+$",{"properties":true}] 58obj.no_under30 = 2; 59// Message: undefined 60 61// Options: ["^[^_]+$",{"properties":true}] 62var { category_id: category_alias } = query; 63// Message: undefined 64 65// Options: ["^[^_]+$",{"ignoreDestructuring":true,"properties":true}] 66var { category_id: category_alias } = query; 67// Message: undefined 68 69// Options: ["^[^_]+$",{"ignoreDestructuring":true,"properties":true}] 70var { category_id: categoryId, ...other_props } = query; 71// Message: undefined 72 73// Options: ["^[^_]+$",{"properties":true}] 74var { category_id } = query; 75// Message: undefined 76 77// Options: ["^[^_]+$",{"properties":true}] 78var { category_id = 1 } = query; 79// Message: undefined 80 81// Options: ["^[^_]+$",{"properties":true}] 82import no_camelcased from "external-module"; 83// Message: undefined 84 85// Options: ["^[^_]+$",{"properties":true}] 86import * as no_camelcased from "external-module"; 87// Message: undefined 88 89// Options: ["^[^_]+$"] 90export * as no_camelcased from "external-module"; 91// Message: undefined 92 93// Options: ["^[^_]+$",{"properties":true}] 94import { no_camelcased as no_camel_cased } from "external module"; 95// Message: undefined 96 97// Options: ["^[^_]+$",{"properties":true}] 98import { camelCased as no_camel_cased } from "external module"; 99// Message: undefined 100 101// Options: ["^[^_]+$",{"properties":true}] 102import { camelCased, no_camelcased } from "external-module"; 103// Message: undefined 104 105// Options: ["^[^_]+$",{"properties":true}] 106import { no_camelcased as camelCased, another_no_camelcased } from "external-module"; 107// Message: undefined 108 109// Options: ["^[^_]+$",{"properties":true}] 110import camelCased, { no_camelcased } from "external-module"; 111// Message: undefined 112 113// Options: ["^[^_]+$",{"properties":true}] 114import no_camelcased, { another_no_camelcased as camelCased } from "external-module"; 115// Message: undefined 116 117// Options: ["^[^_]+$",{"properties":true}] 118function foo({ no_camelcased }) {}; 119// Message: undefined 120 121// Options: ["^[^_]+$",{"properties":true}] 122function foo({ no_camelcased = 'default value' }) {}; 123// Message: undefined 124 125// Options: ["^[^_]+$",{"properties":true}] 126const no_camelcased = 0; function foo({ camelcased_value = no_camelcased }) {} 127// Message: undefined 128// Message: undefined 129 130// Options: ["^[^_]+$",{"properties":true}] 131const { bar: no_camelcased } = foo; 132// Message: undefined 133 134// Options: ["^[^_]+$",{"properties":true}] 135function foo({ value_1: my_default }) {} 136// Message: undefined 137 138// Options: ["^[^_]+$",{"properties":true}] 139function foo({ isCamelcased: no_camelcased }) {}; 140// Message: undefined 141 142// Options: ["^[^_]+$",{"properties":true}] 143var { foo: bar_baz = 1 } = quz; 144// Message: undefined 145 146// Options: ["^[^_]+$",{"properties":true}] 147const { no_camelcased = false } = bar; 148// Message: undefined 149 150// Options: ["^[^_]+$"] 151class x { _foo() {} } 152// Message: undefined 153 154// Options: ["^[^_]+$",{"classFields":true}] 155class x { _foo = 1; } 156// Message: undefined 157 158// Options: ["^[^_]+$",{"ignoreNamedImports":false}] 159import { no_camelcased } from "external-module"; 160// Message: undefined
The following patterns are not considered problems:
1// Options: ["^[a-z]+$",{"onlyDeclarations":true}] 2__foo = "Matthieu" 3 4// Options: ["^[a-z]+$"] 5firstname = "Matthieu" 6 7// Options: ["[a-z]+"] 8first_name = "Matthieu" 9 10// Options: ["^f"] 11firstname = "Matthieu" 12 13// Options: ["^[a-z]+(_[A-Z][a-z]+)*$"] 14last_Name = "Larcher" 15 16// Options: ["^[a-z]+(_[A-Z][a-z])*$"] 17param = "none" 18 19// Options: ["^[^_]+$"] 20function noUnder(){} 21 22// Options: ["^[^_]+$"] 23no_under() 24 25// Options: ["^[^_]+$"] 26foo.no_under2() 27 28// Options: ["^[^_]+$"] 29var foo = bar.no_under3; 30 31// Options: ["^[^_]+$"] 32var foo = bar.no_under4.something; 33 34// Options: ["^[^_]+$"] 35foo.no_under5.qux = bar.no_under6.something; 36 37// Options: ["^[^_]+$"] 38if (bar.no_under7) {} 39 40// Options: ["^[^_]+$"] 41var obj = { key: foo.no_under8 }; 42 43// Options: ["^[^_]+$"] 44var arr = [foo.no_under9]; 45 46// Options: ["^[^_]+$"] 47[foo.no_under10] 48 49// Options: ["^[^_]+$"] 50var arr = [foo.no_under11.qux]; 51 52// Options: ["^[^_]+$"] 53[foo.no_under12.nesting] 54 55// Options: ["^[^_]+$"] 56if (foo.no_under13 === boom.no_under14) { [foo.no_under15] } 57 58// Options: ["^[a-z$]+([A-Z][a-z]+)*$"] 59var myArray = new Array(); var myDate = new Date(); 60 61// Options: ["^[^_]+$"] 62var x = obj._foo; 63 64// Options: ["^[^_]+$",{"onlyDeclarations":true,"properties":true}] 65var obj = {key: no_under} 66 67// Options: ["^[^_]+$",{"properties":true}] 68var {key_no_under: key} = {} 69 70// Options: ["^[^_]+$",{"ignoreDestructuring":true,"properties":true}] 71var { category_id } = query; 72 73// Options: ["^[^_]+$",{"ignoreDestructuring":true,"properties":true}] 74var { category_id: category_id } = query; 75 76// Options: ["^[^_]+$",{"ignoreDestructuring":true,"properties":true}] 77var { category_id = 1 } = query; 78 79// Options: ["^[^_]+$",{"properties":true}] 80var o = {key: 1} 81 82// Options: ["^[^_]+$",{"properties":false}] 83var o = {no_under16: 1} 84 85// Options: ["^[^_]+$",{"properties":false}] 86obj.no_under17 = 2; 87 88// Options: ["^[^_]+$",{"properties":false}] 89var obj = { 90 no_under18: 1 91}; 92 obj.no_under19 = 2; 93 94// Options: ["^[^_]+$",{"properties":false}] 95obj.no_under20 = function(){}; 96 97// Options: ["^[^_]+$",{"properties":false}] 98var x = obj._foo2; 99 100// Options: ["^[^_]+$"] 101class x { foo() {} } 102 103// Options: ["^[^_]+$"] 104class x { #foo() {} } 105 106// Options: ["^[^_]+$",{"ignoreNamedImports":true}] 107import { no_camelcased } from "external-module"; 108 109// Options: ["^[a-zA-Z\\d]+$"] 110 111 const { 112 index, 113 '0': n0, 114 '1': n1, 115 } = exampleCode; 116
import-specifier-newline
Forces every import specifier to be on a new line.
Tip: Combine this rule with object-curly-newline
to have every specifier on its own line.
1"object-curly-newline": [ 2 2, 3 { 4 "ImportDeclaration": "always" 5 } 6],
Working together, both rules will produces imports such as:
1import { 2 a, 3 b, 4 c 5} from 'foo';
1import {a, b} from 'foo'; 2// Message: undefined 3 4import a, {b, c} from 'foo'; 5// Message: undefined
The following patterns are not considered problems:
1import {a, 2b} from 'foo' 3 4import a, {b, 5c} from 'foo'
no-barrel-import
The --fix
option on the command line automatically fixes problems reported by this rule.
Requires that resources are imported from the same files in which they are defined.
This rule converts the following:
1// foo.ts 2import { bar } from './bar'; 3// bar.ts 4export { baz as bar } from './baz'; 5// baz.ts 6export const baz = 'BAZ';
to:
1// foo.ts 2import { baz as bar } from './baz'; 3// baz.ts 4export const baz = 'BAZ';
This rule handles
You must configure import/parsers
and import/resolver
for this rule to work, e.g.
1settings: { 2 'import/parsers': { 3 '@typescript-eslint/parser': ['.ts', '.tsx'], 4 }, 5 'import/resolver': { 6 typescript: { 7 project: path.resolve( 8 __dirname, 9 'tsconfig.json', 10 ), 11 }, 12 }, 13},
1// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/barrelImport/tsconfig.json"}}} 2import { foo } from './bar'; 3 4// Message: undefined 5 6// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/barrelImportAliased/tsconfig.json"}}} 7import { foo as FOO } from './bar'; 8 9// Message: undefined 10 11// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/barrelImportAliasedReexport/tsconfig.json"}}} 12import { bar } from './bar'; 13 14// Message: undefined 15 16// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/barrelImportDeep/tsconfig.json"}}} 17import { foo } from './baz'; 18 19// Message: undefined 20 21// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/barrelImportDefault/tsconfig.json"}}} 22import foo from './bar'; 23 24// Message: undefined 25 26// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/barrelTypeImport/tsconfig.json"}}} 27import { type Foo } from './bar'; 28 29// Message: undefined 30 31// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/invalid/mixedImport/tsconfig.json"}}} 32import { foo, bar } from './bar'; 33 34// Message: undefined
The following patterns are not considered problems:
1// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/valid/directImport/tsconfig.json"}}} 2import { foo } from './foo'; 3 4 5// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/valid/directImportDefault/tsconfig.json"}}} 6import foo from './foo'; 7 8 9// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noBarrelImport/valid/packageImport/tsconfig.json"}}} 10import { logLevels } from 'roarr'; 11
no-export-all
The --fix
option on the command line automatically fixes problems reported by this rule.
Requite that re-exports are named.
1// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noExportAll/invalid/namespaceExport/tsconfig.json"}}} 2export * from './foo'; 3 4// Message: undefined 5 6// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noExportAll/invalid/reExport/tsconfig.json"}}} 7export * from './foo'; 8 9// Message: undefined
The following patterns are not considered problems:
1// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noExportAll/valid/namedExport/tsconfig.json"}}} 2export { FOO } from './foo'; 3 4 5// Settings: {"import/parsers":{"@typescript-eslint/parser":[".ts",".tsx"]},"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noExportAll/valid/aliasedReExport/tsconfig.json"}}} 6export * as foo from './foo'; 7
no-import-namespace-destructure
Disallows 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.
1import * as bar from 'bar'; const { foo } = bar; 2// Message: undefined
The following patterns are not considered problems:
1import * as bar from 'bar'
no-re-export
Disallows re-exports of imports.
1 2 import Button1 from 'app/CustomButton'; 3 export const CustomButton = Button1; 4 5// Message: undefined 6 7 8 import { Button as CustomButton2 } from 'app/CustomButton'; 9 export const CustomButton = CustomButton2; 10 11// Message: undefined 12 13 14 import * as Button3 from "app/Button"; 15 export const CustomButton = Button3; 16 17// Message: undefined 18 19 20 import Button4 from 'app/CustomButton'; 21 export default Button4; 22 23// Message: undefined 24 25 26 export { default as Button5 } from 'app/CustomButton'; 27 28// Message: undefined 29 30 31 import Button6 from 'app/CustomButton'; 32 export { 33 Button6 34 }; 35 36// Message: undefined 37 38 39 import Button7 from 'app/CustomButton'; 40 export const Buttons = { 41 Button: Button7 42 }; 43 44// Message: undefined 45 46 47 import Button8 from 'app/CustomButton'; 48 export default Button8; 49 export { Button8 } 50 51// Message: undefined 52// Message: undefined 53 54 55 export * from 'app/CustomButton'; 56 57// Message: undefined
[!NOTE] This rule was originally developed by @christianvuerings as part of https://github.com/christianvuerings/eslint-plugin-no-re-export
no-reassign-imports
Restricts re-assigning imports to variables that are exported.
1import { Foo } from './Foo'; 2 3export const Bar = { 4 Foo, 5}; 6 7// Message: undefined 8 9import { Foo } from './Foo'; 10 11export default { 12 Foo, 13}; 14 15// Message: undefined
no-restricted-imports
Disallow specified modules when loaded by import
This rule is similar to no-restricted-imports
except that it allows you to specify unique messages for each restricted import (a workaround for issue issues#15261).
Note: Unlike the ESLint rule, this rule does not support the
patterns
option and it does not handle exports.
1// Options: [{"paths":[{"importName":"*","message":"foo is restricted","name":"bar"}]}] 2import * as bar from 'bar' 3// Message: undefined 4 5// Options: [{"paths":[{"importName":"foo","message":"foo is restricted","name":"bar"}]}] 6import { foo } from 'bar' 7// Message: undefined 8 9// Options: [{"paths":[{"importName":"default","message":"foo is restricted","name":"bar"}]}] 10import { default as bar } from 'bar' 11// Message: undefined 12 13// Options: [{"paths":[{"message":"foo is restricted","name":"bar"}]}] 14import bar from 'bar' 15// Message: undefined
The following patterns are not considered problems:
1// Options: [{"paths":[{"importName":"foo","message":"foo is restricted","name":"bar"}]}] 2import { bar } from 'bar'
no-restricted-strings
Disallow specified strings.
1// Options: [["bar"]] 2var foo = "bar" 3// Message: undefined 4 5// Options: [["bar"]] 6const foo = `bar ${baz}`; 7// Message: undefined
The following patterns are not considered problems:
1const foo = "bar";
The 1st option is an array of strings that cannot be contained in the codebase.
no-unused-exports
Identifies unused TypeScript exports.
Note This rule is implemented using
ts-unused-exports
.
Config | Type | Required | Default | Description |
---|---|---|---|---|
tsConfigPath | string | Required | Path to tsconfig.json | |
allowUnusedEnums | boolean | false | Allow unused enum s. | |
allowUnusedTypes | boolean | false | Allow unused type and interface . |
1// Options: [{"tsConfigPath":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noUnusedExports/tsconfig.json"}] 2export const FOO = ''; 3 4// Message: undefined
The following patterns are not considered problems:
1// Options: [{"tsConfigPath":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/noUnusedExports/tsconfig.json"}] 2export const BAR = ''; 3
no-use-extend-native
1Array.prototype.custom 2// Message: undefined 3 4Array.to 5// Message: undefined 6 7Array.to() 8// Message: undefined 9 10[].length() 11// Message: undefined 12 13'unicorn'.green 14// Message: undefined 15 16[].custom() 17// Message: undefined 18 19({}).custom() 20// Message: undefined 21 22/match_this/.custom() 23// Message: undefined 24 25'string'.custom() 26// Message: undefined 27 28console.log('foo'.custom) 29// Message: undefined 30 31console.log('foo'.custom()) 32// Message: undefined 33 34('str' + 'ing').custom() 35// Message: undefined 36 37('str' + 'i' + 'ng').custom() 38// Message: undefined 39 40(1 + 'ing').custom() 41// Message: undefined 42 43(/regex/ + 'ing').custom() 44// Message: undefined 45 46(1 + 1).toLowerCase() 47// Message: undefined 48 49(1 + 1 + 1).toLowerCase() 50// Message: undefined 51 52(function testFunction() {}).custom() 53// Message: undefined 54 55new Array().custom() 56// Message: undefined 57 58new ArrayBuffer().custom() 59// Message: undefined 60 61new Boolean().custom() 62// Message: undefined 63 64new DataView().custom() 65// Message: undefined 66 67new Date().custom() 68// Message: undefined 69 70new Error().custom() 71// Message: undefined 72 73new Float32Array().custom() 74// Message: undefined 75 76new Float64Array().custom() 77// Message: undefined 78 79new Function().custom() 80// Message: undefined 81 82new Int16Array().custom() 83// Message: undefined 84 85new Int32Array().custom() 86// Message: undefined 87 88new Int8Array().custom() 89// Message: undefined 90 91new Map().custom() 92// Message: undefined 93 94new Number().custom() 95// Message: undefined 96 97new Object().custom() 98// Message: undefined 99 100new Promise().custom() 101// Message: undefined 102 103new RegExp().custom() 104// Message: undefined 105 106new Set().custom() 107// Message: undefined 108 109new String().custom() 110// Message: undefined 111 112new Symbol().custom() 113// Message: undefined 114 115new Uint16Array().custom() 116// Message: undefined 117 118new Uint32Array().custom() 119// Message: undefined 120 121new Uint8Array().custom() 122// Message: undefined 123 124new Uint8ClampedArray().custom() 125// Message: undefined 126 127new WeakMap().custom() 128// Message: undefined 129 130new WeakSet().custom() 131// Message: undefined 132 133new Array()['custom'] 134// Message: undefined 135 136new Array()['custom']() 137// Message: undefined
The following patterns are not considered problems:
1error.plugin 2 3error.plugn() 4 5array.custom 6 7Object.assign() 8 9Object.keys 10 11Object.keys() 12 13gulp.task() 14 15Custom.prototype.custom 16 17Array.prototype.map 18 19Array.prototype.map.call([1,2,3], function (x) { console.log(x) }) 20 21Array.apply 22 23Array.call(null, 1, 2, 3) 24 25[].push(1) 26 27[][0] 28 29{}[i] 30 31{}[3] 32 33{}[j][k] 34 35({foo: {bar: 1, baz: 2}}[i][j]) 36 37({}).toString() 38 39/match_this/.test() 40 41'foo'.length 42 43'hi'.padEnd 44 45'hi'.padEnd() 46 47console.log('foo'.length) 48 49console.log('foo'.toString) 50 51console.log('foo'.toString()) 52 53console.log(gulp.task) 54 55console.log(gulp.task()) 56 57'string'.toString() 58 59(1).toFixed() 60 611..toFixed() 62 631.0.toFixed() 64 65('str' + 'ing').toString() 66 67('str' + 'i' + 'ng').toString() 68 69(1 + 1).valueOf() 70 71(1 + 1 + (1 + 1)).valueOf() 72 73(1 + 1 + 1).valueOf() 74 75(1 + 'string').toString() 76 77(/regex/ + /regex/).toString() 78 79(/regex/ + 1).toString() 80 81([1] + [2]).toString() 82 83(function testFunction() {}).toString() 84 85Test.prototype 86 87new Array().toString() 88 89new ArrayBuffer().constructor() 90 91new Boolean().toString() 92 93new DataView().buffer() 94 95new Date().getDate() 96 97new Error().message() 98 99new Error().stack 100 101new Error().stack.slice(1) 102 103new Float32Array().values() 104 105new Float64Array().values() 106 107new Function().toString() 108 109new Int16Array().values() 110 111new Int32Array().values() 112 113new Int8Array().values() 114 115new Map().clear() 116 117new Number().toString() 118 119new Object().toString() 120 121new Object().toString 122 123new Promise().then() 124 125new RegExp().test() 126 127new Set().values() 128 129new String().toString() 130 131new Symbol().toString() 132 133new Uint16Array().values() 134 135new Uint32Array().values() 136 137new Uint8ClampedArray().values() 138 139new WeakMap().get() 140 141new WeakSet().has() 142 143new Array()['length'] 144 145new Array()['toString']()
prefer-import-alias
The --fix
option on the command line automatically fixes problems reported by this rule.
Restrict imports to path aliases or relative imports limited by depth.
The same alias can be applied using multiple rules, e.g.
1'canonical/prefer-import-alias': [ 2 2, 3 { 4 aliases: [ 5 { 6 alias: '@/', 7 matchParent: path.resolve(__dirname, 'src'), 8 matchPath: '^src\\/', 9 }, 10 { 11 alias: '@/', 12 matchPath: '^src\\/', 13 maxRelativeDepth: 2, 14 }, 15 ], 16 }, 17],
In this example, we are saying:
^src\/
path.resolve(__dirname, 'src')
^src\/
The grandfather directory is essentially whichever directory that is accessed by the doubledot (../
) by the import path.
1// Options: [{"aliases":[{"alias":"@/a/","matchPath":"^a\\/","maxRelativeDepth":-1}],"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 2import { bar } from './bar'; 3// Message: undefined 4 5// Options: [{"aliases":[{"alias":"@/a/","matchPath":"^a\\/","maxRelativeDepth":1}],"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 6import { baz } from '../baz'; 7// Message: undefined 8 9// Options: [{"aliases":[{"alias":"@/a/","matchPath":"^a\\/"}],"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 10import { bar } from '../bar'; 11// Message: undefined
The following patterns are not considered problems:
1// Options: [{"aliases":[{"alias":"@/a/","matchParent":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias","matchPath":"^a\\/"}],"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 2import { bar } from '../bar'; 3 4// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 5import { foo } from '@bar/baz'; 6 7// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 8import Foo from '@bar/baz'; 9 10// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 11import Foo, { Foo } from 'bar'; 12 13// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 14import { foo } from './foo'; 15 16// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 17import { foo } from '../foo'; 18 19// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 20import { foo } from '.././foo'; 21 22// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 23import { foo } from '././../foo'; 24 25// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 26import { foo } from '@bar/baz'; 27 28// Options: [{"baseDirectory":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/fixtures/preferImportAlias"}] 29import { foo } from '../../foo';
prefer-inline-type-import
The --fix
option on the command line automatically fixes problems reported by this rule.
TypeScript 4.5 introduced type modifiers 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.
1import type {foo} from 'bar' 2// Message: undefined 3 4import type {foo, baz} from 'bar' 5// Message: undefined
The following patterns are not considered problems:
1import {type foo} from 'bar' 2 3import type Foo from 'bar' 4 5import type * as Foo from 'bar'
prefer-react-lazy
Requires that components that can be loaded lazily be imported using the React.lazy()
function.
1import { lazy } from 'react'; 2import { Foo } from './Foo'; 3 4export default () => { 5 return Math.random() > 0.5 ? <Foo /> : null; 6};
This rule converts the above code to:
1import { lazy } from 'react'; 2 3const Foo = lazy(() => import('./Foo.js').then(({ Foo }) => ({ default: Foo }))); 4 5export default () => { 6 return Math.random() > 0.5 ? <Foo /> : null; 7};
1import React from 'react'; 2import { Foo } from './Foo'; 3 4export default () => { 5 return <> 6 {Math.random() > 0.5 ? <Foo /> : null} 7 </>; 8}; 9// Message: undefined 10 11import React from 'react'; 12import { Foo } from './Foo'; 13 14export default () => { 15 return <> 16 {Math.random() > 0.5 ? <div> 17 <Foo /> 18 </div> : null} 19 </>; 20}; 21// Message: undefined 22 23import React from 'react'; 24import { Foo } from './Foo'; 25 26export default () => { 27 return Math.random() > 0.5 ? <Foo /> : null; 28}; 29// Message: undefined
The following patterns are not considered problems:
1import React, { lazy } from 'react'; 2 3const Foo = lazy(() => import('./Foo').then(({ Foo }) => ({ default: Foo }))); 4 5export default () => { 6 return Math.random() > 0.5 ? <Foo /> : null; 7};
prefer-use-mount
In React, it is common to use 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. For this reason, it is better to use an abstraction such as useMount
that handles this use case.
1useEffect(() => {}, []) 2// Message: undefined
The following patterns are not considered problems:
1useEffect(() => {}, [foo]) 2 3useMount(() => {}, [])
require-extension
The --fix
option on the command line automatically fixes problems reported by this rule.
Adds .js
extension to all imports and exports.
It resolves the following cases:
Relative imports that resolve to a file of the same name:
1import './foo'; // => import './foo.js';
Relative imports that resolve to an index file:
1import './foo'; // => import './foo/index.js';
The above examples would also work if the file extension was .ts
or .tsx
, i.e.
1import './foo'; // => import './foo.ts'; 2import './foo'; // => import './foo/index.tsx';
For this to work, you have to configure import/resolver
:
1settings: { 2 'import/resolver': { 3 typescript: { 4 project: path.resolve(__dirname, 'tsconfig.json'), 5 }, 6 }, 7},
Imports that resolve to a file of the same name:
1import { foo } from '@/foo'; // => import { foo } from '@/foo.js';
Imports that resolve to an index file:
1import { foo } from '@/foo'; // => import { foo } from '@/foo/index.js';
1// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/pathsImport/tsconfig.json"}}} 2import { foo } from '@/foo'; 3 4// Message: undefined 5 6// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/pathsImportWithIndex/tsconfig.json"}}} 7import { foo } from '@/foo'; 8 9// Message: undefined 10 11// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/pathsImportWithIndex/tsconfig.json"}}} 12import { foo } from '@/foo'; 13 14// Message: undefined 15 16// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/relativeImport/tsconfig.json"}}} 17import { foo } from './foo'; 18 19// Message: undefined 20 21// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/relativeImportWithIndex/tsconfig.json"}}} 22import { foo } from './foo'; 23 24// Message: undefined 25 26// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/relativeNamedExport/tsconfig.json"}}} 27export { foo } from './foo'; 28 29// Message: undefined 30 31// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/exportAllDeclaration/tsconfig.json"}}} 32export * from './foo'; 33 34// Message: undefined
The following patterns are not considered problems:
1// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/pathsImportIgnoreSearchParams/tsconfig.json"}}} 2// @ts-expect-error ignore search params 3import { foo } from './foo.svg?url'; 4 5 6// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/pathsImportIgnoreUnknownExtensions/tsconfig.json"}}} 7import { foo } from '@/foo.css'; 8 9 10// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/pathsImportWithExtension/tsconfig.json"}}} 11import { foo } from '@/foo.js'; 12 13 14// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/relativeImportIgnoreUnknownExtensions/tsconfig.json"}}} 15import { foo } from './foo.css'; 16 17 18// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/relativeImportWithExtension/tsconfig.json"}}} 19import { foo } from './foo.js'; 20 21 22// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/typedPackageImport/tsconfig.json"}}} 23// Note that this resolves to roarr, which is a package with TypeScript types. 24// Compare this test to the "packageTypesImport" test which imports dependency's types. 25import { Roarr } from 'roarr'; 26 27 28// Settings: {"import/resolver":{"typescript":{"project":"/Users/gajus/Developer/gajus/@hishprorg/quas-quia-pariatur/tests/fixtures/requireExtension/packageTypesImport/tsconfig.json"}}} 29// Note that this resolves to @types/chance, which is a TypeScript declaration file. 30// Compare this test to the "typedPackageImport" test which imports a typed dependency. 31import { Chance } from 'chance'; 32
sort-destructure-keys
The --fix
option on the command line automatically fixes problems reported by this rule.
Requires that object destructuring properties are sorted alphabetically.
1const {b, a} = foo 2// Message: undefined 3 4// Options: [{"caseSensitive":true}] 5const {a, B} = foo 6// Message: undefined
The following patterns are not considered problems:
1const {a, b} = foo
sort-keys
The --fix
option on the command line automatically fixes problems reported by this rule.
Note: This rule is equivalent to sort-keys
, except that it is fixable.
This rule requires identifiers in assignments and function
definitions to match a specified regular expression.
The 1st option is "asc" or "desc".
The 2nd option is an object which has 3 properties.
caseSensitive
- if true, enforce properties to be in case-sensitive order. Default is true.minKeys
- Specifies the minimum number of keys that an object should have in order for the object's unsorted keys to produce an error. Default is 2, which means by default all objects with unsorted keys will result in lint errors.natural
- if true, enforce properties to be in natural order. Default is false. Natural Order compares strings containing combination of letters and numbers in the way a human being would sort. It basically sorts numerically, instead of sorting alphabetically. So the number 10 comes after the number 3 in Natural Sorting.1var obj = { 2// comment 3// comment 2 4a:1, 5_:2, 6b:3 7} 8// Message: undefined 9 10var obj = { 11/* comment 12 comment 2 */ 13a:1, 14_:2, 15b:3 16} 17// Message: undefined 18 19var obj = {a:1, _:2, b:3} // default 20// Message: undefined 21 22var obj = {a:1, c:2, b:3} 23// Message: undefined 24 25var obj = {b_:1, a:2, b:3} 26// Message: undefined 27 28var obj = {b_:1, c:2, C:3} 29// Message: undefined 30 31var obj = {$:1, _:2, A:3, a:4} 32// Message: undefined 33 34var obj = {1:1, 2:4, A:3, '11':2} 35// Message: undefined 36 37var obj = {'#':1, À:3, 'Z':2, è:4} 38// Message: undefined 39 40var obj = {...z, c:1, b:1} 41// Message: undefined 42 43var obj = {...z, ...c, d:4, b:1, ...y, ...f, e:2, a:1} 44// Message: undefined 45// Message: undefined 46 47var obj = {c:1, b:1, ...a} 48// Message: undefined 49 50var obj = {...z, ...a, c:1, b:1} 51// Message: undefined 52 53var obj = {...z, b:1, a:1, ...d, ...c} 54// Message: undefined 55 56// Options: ["desc"] 57var obj = {...z, a:2, b:0, ...x, ...c} 58// Message: undefined 59 60// Options: ["desc"] 61var obj = {...z, a:2, b:0, ...x} 62// Message: undefined 63 64// Options: ["desc"] 65var obj = {...z, '':1, a:2} 66// Message: undefined 67 68var obj = {a:1, [b+c]:2, '':3} 69// Message: undefined 70 71// Options: ["desc"] 72var obj = {'':1, [b+c]:2, a:3} 73// Message: undefined 74 75// Options: ["desc"] 76var obj = {b:1, [f()]:2, '':3, a:4} 77// Message: undefined 78 79var obj = {a:1, b:3, [a]: -1, c:2} 80// Message: undefined 81 82var obj = {a:1, c:{y:1, x:1}, b:1} 83// Message: undefined 84// Message: undefined 85 86// Options: ["asc"] 87var obj = {a:1, _:2, b:3} // asc 88// Message: undefined 89 90// Options: ["asc"] 91var obj = {a:1, c:2, b:3} 92// Message: undefined 93 94// Options: ["asc"] 95var obj = {b_:1, a:2, b:3} 96// Message: undefined 97 98// Options: ["asc"] 99var obj = {b_:1, c:2, C:3} 100// Message: undefined 101 102// Options: ["asc"] 103var obj = {$:1, _:2, A:3, a:4} 104// Message: undefined 105 106// Options: ["asc"] 107var obj = {1:1, 2:4, A:3, '11':2} 108// Message: undefined 109 110// Options: ["asc"] 111var obj = {'#':1, À:3, 'Z':2, è:4} 112// Message: undefined 113 114// Options: ["asc",{"caseSensitive":false}] 115var obj = {a:1, _:2, b:3} // asc, insensitive 116// Message: undefined 117 118// Options: ["asc",{"caseSensitive":false}] 119var obj = {a:1, c:2, b:3} 120// Message: undefined 121 122// Options: ["asc",{"caseSensitive":false}] 123var obj = {b_:1, a:2, b:3} 124// Message: undefined 125 126// Options: ["asc",{"caseSensitive":false}] 127var obj = {$:1, A:3, _:2, a:4} 128// Message: undefined 129 130// Options: ["asc",{"caseSensitive":false}] 131var obj = {1:1, 2:4, A:3, '11':2} 132// Message: undefined 133 134// Options: ["asc",{"caseSensitive":false}] 135var obj = {'#':1, À:3, 'Z':2, è:4} 136// Message: undefined 137 138// Options: ["asc",{"natural":true}] 139var obj = {a:1, _:2, b:3} // asc, natural 140// Message: undefined 141 142// Options: ["asc",{"natural":true}] 143var obj = {a:1, c:2, b:3} 144// Message: undefined 145 146// Options: ["asc",{"natural":true}] 147var obj = {b_:1, a:2, b:3} 148// Message: undefined 149 150// Options: ["asc",{"natural":true}] 151var obj = {b_:1, c:2, C:3} 152// Message: undefined 153 154// Options: ["asc",{"natural":true}] 155var obj = {$:1, A:3, _:2, a:4} 156// Message: undefined 157 158// Options: ["asc",{"natural":true}] 159var obj = {1:1, 2:4, A:3, '11':2} 160// Message: undefined 161 162// Options: ["asc",{"natural":true}] 163var obj = {'#':1, À:3, 'Z':2, è:4} 164// Message: undefined 165 166// Options: ["asc",{"caseSensitive":false,"natural":true}] 167var obj = {a:1, _:2, b:3} // asc, natural, insensitive 168// Message: undefined 169 170// Options: ["asc",{"caseSensitive":false,"natural":true}] 171var obj = {a:1, c:2, b:3} 172// Message: undefined 173 174// Options: ["asc",{"caseSensitive":false,"natural":true}] 175var obj = {b_:1, a:2, b:3} 176// Message: undefined 177 178// Options: ["asc",{"caseSensitive":false,"natural":true}] 179var obj = {$:1, A:3, _:2, a:4} 180// Message: undefined 181 182// Options: ["asc",{"caseSensitive":false,"natural":true}] 183var obj = {1:1, '11':2, 2:4, A:3} 184// Message: undefined 185 186// Options: ["asc",{"caseSensitive":false,"natural":true}] 187var obj = {'#':1, À:3, 'Z':2, è:4} 188// Message: undefined 189 190// Options: ["desc"] 191var obj = {a:1, _:2, b:3} // desc 192// Message: undefined 193 194// Options: ["desc"] 195var obj = {a:1, c:2, b:3} 196// Message: undefined 197 198// Options: ["desc"] 199var obj = {b_:1, a:2, b:3} 200// Message: undefined 201 202// Options: ["desc"] 203var obj = {b_:1, c:2, C:3} 204// Message: undefined 205 206// Options: ["desc"] 207var obj = {$:1, _:2, A:3, a:4} 208// Message: undefined 209// Message: undefined 210 211// Options: ["desc"] 212var obj = {1:1, 2:4, A:3, '11':2} 213// Message: undefined 214// Message: undefined 215 216// Options: ["desc"] 217var obj = {'#':1, À:3, 'Z':2, è:4} 218// Message: undefined 219// Message: undefined 220 221// Options: ["desc",{"caseSensitive":false}] 222var obj = {a:1, _:2, b:3} // desc, insensitive 223// Message: undefined 224 225// Options: ["desc",{"caseSensitive":false}] 226var obj = {a:1, c:2, b:3} 227// Message: undefined 228 229// Options: ["desc",{"caseSensitive":false}] 230var obj = {b_:1, a:2, b:3} 231// Message: undefined 232 233// Options: ["desc",{"caseSensitive":false}] 234var obj = {b_:1, c:2, C:3} 235// Message: undefined 236 237// Options: ["desc",{"caseSensitive":false}] 238var obj = {$:1, _:2, A:3, a:4} 239// Message: undefined 240// Message: undefined 241 242// Options: ["desc",{"caseSensitive":false}] 243var obj = {1:1, 2:4, A:3, '11':2} 244// Message: undefined 245// Message: undefined 246 247// Options: ["desc",{"caseSensitive":false}] 248var obj = {'#':1, À:3, 'Z':2, è:4} 249// Message: undefined 250// Message: undefined 251 252// Options: ["desc",{"natural":true}] 253var obj = {a:1, _:2, b:3} // desc, natural 254// Message: undefined 255 256// Options: ["desc",{"natural":true}] 257var obj = {a:1, c:2, b:3} 258// Message: undefined 259 260// Options: ["desc",{"natural":true}] 261var obj = {b_:1, a:2, b:3} 262// Message: undefined 263 264// Options: ["desc",{"natural":true}] 265var obj = {b_:1, c:2, C:3} 266// Message: undefined 267 268// Options: ["desc",{"natural":true}] 269var obj = {$:1, _:2, A:3, a:4} 270// Message: undefined 271// Message: undefined 272// Message: undefined 273 274// Options: ["desc",{"natural":true}] 275var obj = {1:1, 2:4, A:3, '11':2} 276// Message: undefined 277// Message: undefined 278 279// Options: ["desc",{"natural":true}] 280var obj = {'#':1, À:3, 'Z':2, è:4} 281// Message: undefined 282// Message: undefined 283 284// Options: ["desc",{"caseSensitive":false,"natural":true}] 285var obj = {a:1, _:2, b:3} // desc, natural, insensitive 286// Message: undefined 287 288// Options: ["desc",{"caseSensitive":false,"natural":true}] 289var obj = {a:1, c:2, b:3} 290// Message: undefined 291 292// Options: ["desc",{"caseSensitive":false,"natural":true}] 293var obj = {b_:1, a:2, b:3} 294// Message: undefined 295 296// Options: ["desc",{"caseSensitive":false,"natural":true}] 297var obj = {b_:1, c:2, C:3} 298// Message: undefined 299 300// Options: ["desc",{"caseSensitive":false,"natural":true}] 301var obj = {$:1, _:2, A:3, a:4} 302// Message: undefined 303// Message: undefined 304 305// Options: ["desc",{"caseSensitive":false,"natural":true}] 306var obj = {1:1, 2:4, '11':2, A:3} 307// Message: undefined 308// Message: undefined 309// Message: undefined 310 311// Options: ["desc",{"caseSensitive":false,"natural":true}] 312var obj = {'#':1, À:3, 'Z':2, è:4} 313// Message: undefined 314// Message: undefined
The following patterns are not considered problems:
1// Options: []
2var obj = {_:2, a:1, b:3} // default
3
4// Options: []
5var obj = {a:1, b:3, c:2}
6
7// Options: []
8var obj = {a:2, b:3, b_:1}
9
10// Options: []
11var obj = {C:3, b_:1, c:2}
12
13// Options: []
14var obj = {$:1, A:3, _:2, a:4}
15
16// Options: []
17var obj = {1:1, '11':2, 2:4, A:3}
18
19// Options: []
20var obj = {'#':1, 'Z':2, À:3, è:4}
21
22// Options: []
23var obj = {a:1, b:3, [a + b]: -1, c:2}
24
25// Options: []
26var obj = {'':1, [f()]:2, a:3}
27
28// Options: ["desc"]
29var obj = {a:1, [b++]:2, '':3}
30
31// Options: []
32var obj = {a:1, ...z, b:1}
33
34// Options: []
35var obj = {b:1, ...z, a:1}
36
37// Options: []
38var obj = {...a, b:1, ...c, d:1}
39
40// Options: []
41var obj = {...a, b:1, ...d, ...c, e:2, z:5}
42
43// Options: []
44var obj = {b:1, ...c, ...d, e:2}
45
46// Options: []
47var obj = {a:1, ...z, '':2}
48
49// Options: ["desc"]
50var obj = {'':1, ...z, 'a':2}
51
52// Options: []
53var obj = {...z, a:1, b:1}
54
55// Options: []
56var obj = {...z, ...c, a:1, b:1}
57
58// Options: []
59var obj = {a:1, b:1, ...z}
60
61// Options: ["desc"]
62var obj = {...z, ...x, a:1, ...c, ...d, f:5, e:4}
63
64// Options: []
65function fn(...args) { return [...args].length; }
66
67// Options: []
68function g() {}; function f(...args) { return g(...args); }
69
70// Options: []
71let {a, b} = {}
72
73// Options: []
74var obj = {a:1, b:{x:1, y:1}, c:1}
75
76// Options: ["asc"]
77var obj = {_:2, a:1, b:3} // asc
78
79// Options: ["asc"]
80var obj = {a:1, b:3, c:2}
81
82// Options: ["asc"]
83var obj = {a:2, b:3, b_:1}
84
85// Options: ["asc"]
86var obj = {C:3, b_:1, c:2}
87
88// Options: ["asc"]
89var obj = {$:1, A:3, _:2, a:4}
90
91// Options: ["asc"]
92var obj = {1:1, '11':2, 2:4, A:3}
93
94// Options: ["asc"]
95var obj = {'#':1, 'Z':2, À:3, è:4}
96
97// Options: ["asc",{"caseSensitive":false}]
98var obj = {_:2, a:1, b:3} // asc, insensitive
99
100// Options: ["asc",{"caseSensitive":false}]
101var obj = {a:1, b:3, c:2}
102
103// Options: ["asc",{"caseSensitive":false}]
104var obj = {a:2, b:3, b_:1}
105
106// Options: ["asc",{"caseSensitive":false}]
107var obj = {b_:1, C:3, c:2}
108
109// Options: ["asc",{"caseSensitive":false}]
110var obj = {b_:1, c:3, C:2}
111
112// Options: ["asc",{"caseSensitive":false}]
113var obj = {$:1, _:2, A:3, a:4}
114
115// Options: ["asc",{"caseSensitive":false}]
116var obj = {1:1, '11':2, 2:4, A:3}
117
118// Options: ["asc",{"caseSensitive":false}]
119var obj = {'#':1, 'Z':2, À:3, è:4}
120
121// Options: ["asc",{"natural":true}]
122var obj = {_:2, a:1, b:3} // asc, natural
123
124// Options: ["asc",{"natural":true}]
125var obj = {a:1, b:3, c:2}
126
127// Options: ["asc",{"natural":true}]
128var obj = {a:2, b:3, b_:1}
129
130// Options: ["asc",{"natural":true}]
131var obj = {C:3, b_:1, c:2}
132
133// Options: ["asc",{"natural":true}]
134var obj = {$:1, _:2, A:3, a:4}
135
136// Options: ["asc",{"natural":true}]
137var obj = {1:1, 2:4, '11':2, A:3}
138
139// Options: ["asc",{"natural":true}]
140var obj = {'#':1, 'Z':2, À:3, è:4}
141
142// Options: ["asc",{"caseSensitive":false,"natural":true}]
143var obj = {_:2, a:1, b:3} // asc, natural, insensitive
144
145// Options: ["asc",{"caseSensitive":false,"natural":true}]
146var obj = {a:1, b:3, c:2}
147
148// Options: ["asc",{"caseSensitive":false,"natural":true}]
149var obj = {a:2, b:3, b_:1}
150
151// Options: ["asc",{"caseSensitive":false,"natural":true}]
152var obj = {b_:1, C:3, c:2}
153
154// Options: ["asc",{"caseSensitive":false,"natural":true}]
155var obj = {b_:1, c:3, C:2}
156
157// Options: ["asc",{"caseSensitive":false,"natural":true}]
158var obj = {$:1, _:2, A:3, a:4}
159
160// Options: ["asc",{"caseSensitive":false,"natural":true}]
161var obj = {1:1, 2:4, '11':2, A:3}
162
163// Options: ["asc",{"caseSensitive":false,"natural":true}]
164var obj = {'#':1, 'Z':2, À:3, è:4}
165
166// Options: ["desc"]
167var obj = {b:3, a:1, _:2} // desc
168
169// Options: ["desc"]
170var obj = {c:2, b:3, a:1}
171
172// Options: ["desc"]
173var obj = {b_:1, b:3, a:2}
174
175// Options: ["desc"]
176var obj = {c:2, b_:1, C:3}
177
178// Options: ["desc"]
179var obj = {a:4, _:2, A:3, $:1}
180
181// Options: ["desc"]
182var obj = {A:3, 2:4, '11':2, 1:1}
183
184// Options: ["desc"]
185var obj = {è:4, À:3, 'Z':2, '#':1}
186
187// Options: ["desc",{"caseSensitive":false}]
188var obj = {b:3, a:1, _:2} // desc, insensitive
189
190// Options: ["desc",{"caseSensitive":false}]
191var obj = {c:2, b:3, a:1}
192
193// Options: ["desc",{"caseSensitive":false}]
194var obj = {b_:1, b:3, a:2}
195
196// Options: ["desc",{"caseSensitive":false}]
197var obj = {c:2, C:3, b_:1}
198
199// Options: ["desc",{"caseSensitive":false}]
200var obj = {C:2, c:3, b_:1}
201
202// Options: ["desc",{"caseSensitive":false}]
203var obj = {a:4, A:3, _:2, $:1}
204
205// Options: ["desc",{"caseSensitive":false}]
206var obj = {A:3, 2:4, '11':2,
No vulnerabilities found.
No security vulnerabilities found.