eslint-config-gristow 2.0.19 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -0
- package/eslint.config.js +96 -0
- package/index.js +18 -3
- package/package.json +43 -45
- package/readme.md +66 -56
- package/rules/airbnb-base-rules.js +34 -0
- package/rules/airbnb-best-practices.js +319 -0
- package/rules/airbnb-errors.js +141 -0
- package/rules/airbnb-es6.js +119 -0
- package/rules/airbnb-imports.js +185 -0
- package/rules/airbnb-style.js +350 -0
- package/rules/airbnb-variables.js +118 -0
- package/rules/import-rules.js +4 -1
- package/rules/{naming-convention.cjs → naming-convention.js} +4 -1
- package/rules/{shared-rules.cjs → shared-rules.js} +4 -2
- package/rules/{typescript-only-rules.cjs → typescript-only-rules.js} +4 -1
- package/.eslintrc.cjs +0 -44
- package/.eslintrc.cjs.recent.bak +0 -68
- package/.eslintrc.cjs.working.bak +0 -40
- package/.eslintrc.js.original.bak +0 -82
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -20
- package/rules/svelte-rules.cjs +0 -12
- package/svelte/svelte.eslintrc.cjs +0 -28
- package/svelte.js +0 -3
- package/test-js-export.js +0 -3
- package/test-ts-export.ts +0 -8
- package/test.js +0 -44
- package/test.ts +0 -64
- package/tsconfig.json +0 -17
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Airbnb Import Rules
|
|
3
|
+
* Extracted from eslint-config-airbnb-base for ESLint 9 compatibility
|
|
4
|
+
* @see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js
|
|
5
|
+
*/
|
|
6
|
+
export default {
|
|
7
|
+
// Ensure imports point to files/modules that can be resolved
|
|
8
|
+
'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
|
|
9
|
+
|
|
10
|
+
// Ensure named imports coupled with named exports
|
|
11
|
+
'import/named': 'error',
|
|
12
|
+
|
|
13
|
+
// Ensure default import coupled with default export
|
|
14
|
+
'import/default': 'off',
|
|
15
|
+
|
|
16
|
+
// Ensure imported namespaces contain dereferenced properties as they are dereferenced
|
|
17
|
+
'import/namespace': 'off',
|
|
18
|
+
|
|
19
|
+
// Report any invalid exports, i.e. re-export of the same name
|
|
20
|
+
'import/export': 'error',
|
|
21
|
+
|
|
22
|
+
// Do not allow a default import name to match a named export
|
|
23
|
+
'import/no-named-as-default': 'error',
|
|
24
|
+
|
|
25
|
+
// Warn on accessing default export property names that are also named exports
|
|
26
|
+
'import/no-named-as-default-member': 'error',
|
|
27
|
+
|
|
28
|
+
// Disallow use of jsdoc-marked-deprecated imports
|
|
29
|
+
'import/no-deprecated': 'off',
|
|
30
|
+
|
|
31
|
+
// Forbid the use of extraneous packages
|
|
32
|
+
'import/no-extraneous-dependencies': ['error', {
|
|
33
|
+
devDependencies: [
|
|
34
|
+
'test/**', // tape, common npm pattern
|
|
35
|
+
'tests/**', // also common npm pattern
|
|
36
|
+
'spec/**', // mocha, rspec-like pattern
|
|
37
|
+
'**/__tests__/**', // jest pattern
|
|
38
|
+
'**/__mocks__/**', // jest pattern
|
|
39
|
+
'test.{js,jsx}', // repos with a single test file
|
|
40
|
+
'test-*.{js,jsx}', // repos with multiple top-level test files
|
|
41
|
+
'**/*{.,_}{test,spec}.{js,jsx}', // tests where the weights is suffixed
|
|
42
|
+
'**/jest.config.js', // jest config
|
|
43
|
+
'**/jest.setup.js', // jest setup
|
|
44
|
+
'**/vue.config.js', // vue-cli config
|
|
45
|
+
'**/webpack.config.js', // webpack config
|
|
46
|
+
'**/webpack.config.*.js', // webpack config
|
|
47
|
+
'**/rollup.config.js', // rollup config
|
|
48
|
+
'**/rollup.config.*.js', // rollup config
|
|
49
|
+
'**/gulpfile.js', // gulp config
|
|
50
|
+
'**/gulpfile.*.js', // gulp config
|
|
51
|
+
'**/Gruntfile{,.js}', // grunt config
|
|
52
|
+
'**/protractor.conf.js', // protractor config
|
|
53
|
+
'**/protractor.conf.*.js', // protractor config
|
|
54
|
+
'**/karma.conf.js', // karma config
|
|
55
|
+
'**/.eslintrc.js', // eslint config
|
|
56
|
+
],
|
|
57
|
+
optionalDependencies: false,
|
|
58
|
+
}],
|
|
59
|
+
|
|
60
|
+
// Forbid mutable exports
|
|
61
|
+
'import/no-mutable-exports': 'error',
|
|
62
|
+
|
|
63
|
+
// Disallow require()
|
|
64
|
+
'import/no-commonjs': 'off',
|
|
65
|
+
|
|
66
|
+
// Disallow AMD require/define
|
|
67
|
+
'import/no-amd': 'error',
|
|
68
|
+
|
|
69
|
+
// Disallow Node.js builtin modules
|
|
70
|
+
'import/no-nodejs-modules': 'off',
|
|
71
|
+
|
|
72
|
+
// Ensure all imports appear before other statements
|
|
73
|
+
'import/first': 'error',
|
|
74
|
+
|
|
75
|
+
// Disallow non-import statements appearing before import statements
|
|
76
|
+
'import/imports-first': 'off',
|
|
77
|
+
|
|
78
|
+
// Disallow duplicate imports
|
|
79
|
+
'import/no-duplicates': 'error',
|
|
80
|
+
|
|
81
|
+
// Disallow namespace imports
|
|
82
|
+
'import/no-namespace': 'off',
|
|
83
|
+
|
|
84
|
+
// Ensure consistent use of file extension within the import path
|
|
85
|
+
'import/extensions': ['error', 'ignorePackages', {
|
|
86
|
+
js: 'never',
|
|
87
|
+
mjs: 'never',
|
|
88
|
+
jsx: 'never',
|
|
89
|
+
}],
|
|
90
|
+
|
|
91
|
+
// Ensure absolute imports are above relative imports
|
|
92
|
+
'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
|
|
93
|
+
|
|
94
|
+
// Require a newline after the last import/require in a group
|
|
95
|
+
'import/newline-after-import': 'error',
|
|
96
|
+
|
|
97
|
+
// Prefer a default export if module exports a single name
|
|
98
|
+
'import/prefer-default-export': 'error',
|
|
99
|
+
|
|
100
|
+
// Restrict which files can be imported in a given folder
|
|
101
|
+
'import/no-restricted-paths': 'off',
|
|
102
|
+
|
|
103
|
+
// Limit the maximum number of dependencies a module can have
|
|
104
|
+
'import/max-dependencies': ['off', { max: 10 }],
|
|
105
|
+
|
|
106
|
+
// Forbid import of modules using absolute paths
|
|
107
|
+
'import/no-absolute-path': 'error',
|
|
108
|
+
|
|
109
|
+
// Forbid require() calls with expressions
|
|
110
|
+
'import/no-dynamic-require': 'error',
|
|
111
|
+
|
|
112
|
+
// Prevent importing the submodules of other modules
|
|
113
|
+
'import/no-internal-modules': ['off', { allow: [] }],
|
|
114
|
+
|
|
115
|
+
// Warn if a module could be mistakenly parsed as a script by a consumer
|
|
116
|
+
'import/unambiguous': 'off',
|
|
117
|
+
|
|
118
|
+
// Forbid Webpack loader syntax in imports
|
|
119
|
+
'import/no-webpack-loader-syntax': 'error',
|
|
120
|
+
|
|
121
|
+
// Prevent unassigned imports
|
|
122
|
+
'import/no-unassigned-import': 'off',
|
|
123
|
+
|
|
124
|
+
// Prevent importing the default as if it were named
|
|
125
|
+
'import/no-named-default': 'error',
|
|
126
|
+
|
|
127
|
+
// Reports if a module's default export is unnamed
|
|
128
|
+
'import/no-anonymous-default-export': ['off', {
|
|
129
|
+
allowArray: false,
|
|
130
|
+
allowArrowFunction: false,
|
|
131
|
+
allowAnonymousClass: false,
|
|
132
|
+
allowAnonymousFunction: false,
|
|
133
|
+
allowLiteral: false,
|
|
134
|
+
allowObject: false,
|
|
135
|
+
}],
|
|
136
|
+
|
|
137
|
+
// Prefer named exports to be grouped together in a single export declaration
|
|
138
|
+
'import/exports-last': 'off',
|
|
139
|
+
|
|
140
|
+
// Reports when named exports are not grouped together
|
|
141
|
+
'import/group-exports': 'off',
|
|
142
|
+
|
|
143
|
+
// Forbid default exports
|
|
144
|
+
'import/no-default-export': 'off',
|
|
145
|
+
|
|
146
|
+
// Forbid named exports
|
|
147
|
+
'import/no-named-export': 'off',
|
|
148
|
+
|
|
149
|
+
// Forbid a module from importing itself
|
|
150
|
+
'import/no-self-import': 'error',
|
|
151
|
+
|
|
152
|
+
// Forbid cyclical dependencies between modules
|
|
153
|
+
'import/no-cycle': ['error', { maxDepth: '∞', ignoreExternal: true }],
|
|
154
|
+
|
|
155
|
+
// Ensures that there are no useless path segments
|
|
156
|
+
'import/no-useless-path-segments': ['error', { commonjs: true }],
|
|
157
|
+
|
|
158
|
+
// Enforce a leading comment with the webpackChunkName for dynamic imports
|
|
159
|
+
'import/dynamic-import-chunkname': ['off', {
|
|
160
|
+
importFunctions: [],
|
|
161
|
+
webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
|
|
162
|
+
}],
|
|
163
|
+
|
|
164
|
+
// Forbid importing modules from parent directories
|
|
165
|
+
'import/no-relative-parent-imports': 'off',
|
|
166
|
+
|
|
167
|
+
// Reports modules without any exports, or with unused exports
|
|
168
|
+
'import/no-unused-modules': ['off', {
|
|
169
|
+
ignoreExports: [],
|
|
170
|
+
missingExports: true,
|
|
171
|
+
unusedExports: true,
|
|
172
|
+
}],
|
|
173
|
+
|
|
174
|
+
// Reports the use of import declarations with CommonJS exports
|
|
175
|
+
'import/no-import-module-exports': ['error', { exceptions: [] }],
|
|
176
|
+
|
|
177
|
+
// Forbid importing packages through relative paths
|
|
178
|
+
'import/no-relative-packages': 'error',
|
|
179
|
+
|
|
180
|
+
// Enforce a consistent style for type specifiers (inline vs top-level)
|
|
181
|
+
'import/consistent-type-specifier-style': ['off', 'prefer-inline'],
|
|
182
|
+
|
|
183
|
+
// Forbid empty named import blocks
|
|
184
|
+
'import/no-empty-named-blocks': 'off',
|
|
185
|
+
};
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Airbnb Style Rules
|
|
3
|
+
* Extracted from eslint-config-airbnb-base for ESLint 9 compatibility
|
|
4
|
+
*
|
|
5
|
+
* NOTE: Formatting rules are disabled as they are handled by Prettier.
|
|
6
|
+
* Only semantic/code-quality rules are enabled.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
|
|
9
|
+
*/
|
|
10
|
+
export default {
|
|
11
|
+
// ============================================================
|
|
12
|
+
// DISABLED - Handled by Prettier
|
|
13
|
+
// ============================================================
|
|
14
|
+
|
|
15
|
+
// Enforce line breaks after opening and before closing array brackets
|
|
16
|
+
'array-bracket-newline': 'off',
|
|
17
|
+
|
|
18
|
+
// Enforce line breaks between array elements
|
|
19
|
+
'array-element-newline': 'off',
|
|
20
|
+
|
|
21
|
+
// Enforce spacing inside array brackets
|
|
22
|
+
'array-bracket-spacing': 'off',
|
|
23
|
+
|
|
24
|
+
// Enforce spacing inside single-line blocks
|
|
25
|
+
'block-spacing': 'off',
|
|
26
|
+
|
|
27
|
+
// Enforce one true brace style
|
|
28
|
+
'brace-style': 'off',
|
|
29
|
+
|
|
30
|
+
// Require trailing commas in multiline object literals
|
|
31
|
+
'comma-dangle': 'off',
|
|
32
|
+
|
|
33
|
+
// Enforce spacing before and after comma
|
|
34
|
+
'comma-spacing': 'off',
|
|
35
|
+
|
|
36
|
+
// Enforce one true comma style
|
|
37
|
+
'comma-style': 'off',
|
|
38
|
+
|
|
39
|
+
// Disallow padding inside computed properties
|
|
40
|
+
'computed-property-spacing': 'off',
|
|
41
|
+
|
|
42
|
+
// Enforce newline at the end of file, with no multiple empty lines
|
|
43
|
+
'eol-last': 'off',
|
|
44
|
+
|
|
45
|
+
// Enforce line breaks between arguments of a function call
|
|
46
|
+
'function-call-argument-newline': 'off',
|
|
47
|
+
|
|
48
|
+
// Enforce spacing between functions and their invocations
|
|
49
|
+
'func-call-spacing': 'off',
|
|
50
|
+
|
|
51
|
+
// Enforce consistent line breaks inside function parentheses
|
|
52
|
+
'function-paren-newline': 'off',
|
|
53
|
+
|
|
54
|
+
// Enforce the location of arrow function bodies with implicit returns
|
|
55
|
+
'implicit-arrow-linebreak': 'off',
|
|
56
|
+
|
|
57
|
+
// This option sets a specific tab width for your code
|
|
58
|
+
'indent': 'off',
|
|
59
|
+
|
|
60
|
+
// Specify whether double or single quotes should be used in JSX attributes
|
|
61
|
+
'jsx-quotes': 'off',
|
|
62
|
+
|
|
63
|
+
// Enforces spacing between keys and values in object literal properties
|
|
64
|
+
'key-spacing': 'off',
|
|
65
|
+
|
|
66
|
+
// Require a space before & after certain keywords
|
|
67
|
+
'keyword-spacing': 'off',
|
|
68
|
+
|
|
69
|
+
// Disallow mixed 'LF' and 'CRLF' as linebreaks
|
|
70
|
+
'linebreak-style': 'off',
|
|
71
|
+
|
|
72
|
+
// Specify the maximum length of a line in your program
|
|
73
|
+
'max-len': 'off',
|
|
74
|
+
|
|
75
|
+
// Require multiline ternary
|
|
76
|
+
'multiline-ternary': 'off',
|
|
77
|
+
|
|
78
|
+
// Disallow the omission of parentheses when invoking a constructor with no arguments
|
|
79
|
+
'new-parens': 'off',
|
|
80
|
+
|
|
81
|
+
// Enforces new line after each method call in the chain to make it more readable
|
|
82
|
+
'newline-per-chained-call': 'off',
|
|
83
|
+
|
|
84
|
+
// Disallow mixed spaces and tabs for indentation
|
|
85
|
+
'no-mixed-spaces-and-tabs': 'off',
|
|
86
|
+
|
|
87
|
+
// Disallow multiple empty lines, only one newline at the end
|
|
88
|
+
'no-multiple-empty-lines': 'off',
|
|
89
|
+
|
|
90
|
+
// Disallow use of tabs
|
|
91
|
+
'no-tabs': 'off',
|
|
92
|
+
|
|
93
|
+
// Disallow trailing whitespace at the end of lines
|
|
94
|
+
'no-trailing-spaces': 'off',
|
|
95
|
+
|
|
96
|
+
// Disallow whitespace before properties
|
|
97
|
+
'no-whitespace-before-property': 'off',
|
|
98
|
+
|
|
99
|
+
// Enforce the location of single-line statements
|
|
100
|
+
'nonblock-statement-body-position': 'off',
|
|
101
|
+
|
|
102
|
+
// Require padding inside curly braces
|
|
103
|
+
'object-curly-spacing': 'off',
|
|
104
|
+
|
|
105
|
+
// Enforce line breaks between braces
|
|
106
|
+
'object-curly-newline': 'off',
|
|
107
|
+
|
|
108
|
+
// Enforce "same line" or "multiple line" on object properties
|
|
109
|
+
'object-property-newline': 'off',
|
|
110
|
+
|
|
111
|
+
// Require a newline around variable declaration
|
|
112
|
+
'one-var-declaration-per-line': 'off',
|
|
113
|
+
|
|
114
|
+
// Requires operator at the beginning of the line in multiline statements
|
|
115
|
+
'operator-linebreak': 'off',
|
|
116
|
+
|
|
117
|
+
// Disallow padding within blocks
|
|
118
|
+
'padded-blocks': 'off',
|
|
119
|
+
|
|
120
|
+
// Require quotes around object literal property names
|
|
121
|
+
'quote-props': 'off',
|
|
122
|
+
|
|
123
|
+
// Specify whether double or single quotes should be used
|
|
124
|
+
'quotes': 'off',
|
|
125
|
+
|
|
126
|
+
// Require or disallow use of semicolons instead of ASI
|
|
127
|
+
'semi': 'off',
|
|
128
|
+
|
|
129
|
+
// Enforce spacing before and after semicolons
|
|
130
|
+
'semi-spacing': 'off',
|
|
131
|
+
|
|
132
|
+
// Enforce location of semicolons
|
|
133
|
+
'semi-style': 'off',
|
|
134
|
+
|
|
135
|
+
// Require or disallow space before blocks
|
|
136
|
+
'space-before-blocks': 'off',
|
|
137
|
+
|
|
138
|
+
// Require or disallow space before function opening parenthesis
|
|
139
|
+
'space-before-function-paren': 'off',
|
|
140
|
+
|
|
141
|
+
// Require or disallow spaces inside parentheses
|
|
142
|
+
'space-in-parens': 'off',
|
|
143
|
+
|
|
144
|
+
// Require spaces around operators
|
|
145
|
+
'space-infix-ops': 'off',
|
|
146
|
+
|
|
147
|
+
// Require or disallow spaces before/after unary operators
|
|
148
|
+
'space-unary-ops': 'off',
|
|
149
|
+
|
|
150
|
+
// Enforce spacing around colons of switch statements
|
|
151
|
+
'switch-colon-spacing': 'off',
|
|
152
|
+
|
|
153
|
+
// Require or disallow spacing between template tags and their literals
|
|
154
|
+
'template-tag-spacing': 'off',
|
|
155
|
+
|
|
156
|
+
// Require regex literals to be wrapped in parentheses
|
|
157
|
+
'wrap-regex': 'off',
|
|
158
|
+
|
|
159
|
+
// ============================================================
|
|
160
|
+
// ENABLED - Semantic/Code Quality Rules
|
|
161
|
+
// ============================================================
|
|
162
|
+
|
|
163
|
+
// Require camel case names
|
|
164
|
+
'camelcase': ['error', { properties: 'never', ignoreDestructuring: false }],
|
|
165
|
+
|
|
166
|
+
// Enforce or disallow capitalization of the first letter of a comment
|
|
167
|
+
'capitalized-comments': 'off',
|
|
168
|
+
|
|
169
|
+
// Enforces consistent naming when capturing the current execution context
|
|
170
|
+
'consistent-this': 'off',
|
|
171
|
+
|
|
172
|
+
// Requires function names to match the name of the variable or property
|
|
173
|
+
'func-name-matching': 'off',
|
|
174
|
+
|
|
175
|
+
// Require function expressions to have a name
|
|
176
|
+
'func-names': 'warn',
|
|
177
|
+
|
|
178
|
+
// Enforces use of function declarations or expressions
|
|
179
|
+
'func-style': 'off',
|
|
180
|
+
|
|
181
|
+
// Disallow specified identifiers
|
|
182
|
+
'id-denylist': 'off',
|
|
183
|
+
|
|
184
|
+
// This option enforces minimum and maximum identifier lengths
|
|
185
|
+
'id-length': 'off',
|
|
186
|
+
|
|
187
|
+
// Require identifiers to match the provided regular expression
|
|
188
|
+
'id-match': 'off',
|
|
189
|
+
|
|
190
|
+
// Enforce position of line comments
|
|
191
|
+
'line-comment-position': 'off',
|
|
192
|
+
|
|
193
|
+
// Require or disallow an empty line between class members
|
|
194
|
+
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
|
|
195
|
+
|
|
196
|
+
// Enforces empty lines around comments
|
|
197
|
+
'lines-around-comment': 'off',
|
|
198
|
+
|
|
199
|
+
// Require or disallow logical assignment logical operator shorthand
|
|
200
|
+
'logical-assignment-operators': 'off',
|
|
201
|
+
|
|
202
|
+
// Specify the maximum depth that blocks can be nested
|
|
203
|
+
'max-depth': 'off',
|
|
204
|
+
|
|
205
|
+
// Specify the max number of lines in a file
|
|
206
|
+
'max-lines': 'off',
|
|
207
|
+
|
|
208
|
+
// Enforce a maximum function length
|
|
209
|
+
'max-lines-per-function': 'off',
|
|
210
|
+
|
|
211
|
+
// Specify the maximum depth callbacks can be nested
|
|
212
|
+
'max-nested-callbacks': 'off',
|
|
213
|
+
|
|
214
|
+
// Limits the number of parameters that can be used in the function declaration
|
|
215
|
+
'max-params': 'off',
|
|
216
|
+
|
|
217
|
+
// Specify the maximum number of statement allowed in a function
|
|
218
|
+
'max-statements': 'off',
|
|
219
|
+
|
|
220
|
+
// Restrict the number of statements per line
|
|
221
|
+
'max-statements-per-line': 'off',
|
|
222
|
+
|
|
223
|
+
// Enforce a particular style for multiline comments
|
|
224
|
+
'multiline-comment-style': 'off',
|
|
225
|
+
|
|
226
|
+
// Require a capital letter for constructors
|
|
227
|
+
'new-cap': ['error', {
|
|
228
|
+
newIsCap: true,
|
|
229
|
+
newIsCapExceptions: [],
|
|
230
|
+
capIsNew: false,
|
|
231
|
+
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
|
|
232
|
+
}],
|
|
233
|
+
|
|
234
|
+
// Disallow use of the Array constructor
|
|
235
|
+
'no-array-constructor': 'error',
|
|
236
|
+
|
|
237
|
+
// Disallow use of bitwise operators
|
|
238
|
+
'no-bitwise': 'error',
|
|
239
|
+
|
|
240
|
+
// Disallow use of the continue statement
|
|
241
|
+
'no-continue': 'error',
|
|
242
|
+
|
|
243
|
+
// Disallow comments inline after code
|
|
244
|
+
'no-inline-comments': 'off',
|
|
245
|
+
|
|
246
|
+
// Disallow if as the only statement in an else block
|
|
247
|
+
'no-lonely-if': 'error',
|
|
248
|
+
|
|
249
|
+
// Disallow un-paren'd mixes of different operators
|
|
250
|
+
'no-mixed-operators': ['error', {
|
|
251
|
+
groups: [
|
|
252
|
+
['%', '**'],
|
|
253
|
+
['%', '+'],
|
|
254
|
+
['%', '-'],
|
|
255
|
+
['%', '*'],
|
|
256
|
+
['%', '/'],
|
|
257
|
+
['/', '*'],
|
|
258
|
+
['&', '|', '<<', '>>', '>>>'],
|
|
259
|
+
['==', '!=', '===', '!=='],
|
|
260
|
+
['&&', '||'],
|
|
261
|
+
],
|
|
262
|
+
allowSamePrecedence: false,
|
|
263
|
+
}],
|
|
264
|
+
|
|
265
|
+
// Disallow use of chained assignment expressions
|
|
266
|
+
'no-multi-assign': ['error'],
|
|
267
|
+
|
|
268
|
+
// Disallow negated conditions
|
|
269
|
+
'no-negated-condition': 'off',
|
|
270
|
+
|
|
271
|
+
// Disallow nested ternary expressions
|
|
272
|
+
'no-nested-ternary': 'error',
|
|
273
|
+
|
|
274
|
+
// Disallow use of the Object constructor
|
|
275
|
+
'no-new-object': 'error',
|
|
276
|
+
|
|
277
|
+
// Disallow use of unary operators, ++ and --
|
|
278
|
+
'no-plusplus': 'error',
|
|
279
|
+
|
|
280
|
+
// Disallow certain syntax forms
|
|
281
|
+
'no-restricted-syntax': ['error',
|
|
282
|
+
{
|
|
283
|
+
selector: 'ForInStatement',
|
|
284
|
+
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
selector: 'ForOfStatement',
|
|
288
|
+
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
selector: 'LabeledStatement',
|
|
292
|
+
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
selector: 'WithStatement',
|
|
296
|
+
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
|
|
300
|
+
// Disallow the use of ternary operators
|
|
301
|
+
'no-ternary': 'off',
|
|
302
|
+
|
|
303
|
+
// Disallow dangling underscores in identifiers
|
|
304
|
+
'no-underscore-dangle': ['error', {
|
|
305
|
+
allow: [],
|
|
306
|
+
allowAfterThis: false,
|
|
307
|
+
allowAfterSuper: false,
|
|
308
|
+
enforceInMethodNames: true,
|
|
309
|
+
}],
|
|
310
|
+
|
|
311
|
+
// Disallow the use of Boolean literals in conditional expressions
|
|
312
|
+
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
|
313
|
+
|
|
314
|
+
// Allow just one var statement per function
|
|
315
|
+
'one-var': ['error', 'never'],
|
|
316
|
+
|
|
317
|
+
// Require assignment operator shorthand where possible or prohibit it entirely
|
|
318
|
+
'operator-assignment': ['error', 'always'],
|
|
319
|
+
|
|
320
|
+
// Require or disallow padding lines between statements
|
|
321
|
+
'padding-line-between-statements': 'off',
|
|
322
|
+
|
|
323
|
+
// Prefer use of an exponentiation operator over Math.pow
|
|
324
|
+
'prefer-exponentiation-operator': 'error',
|
|
325
|
+
|
|
326
|
+
// Prefer use of an object spread over Object.assign
|
|
327
|
+
'prefer-object-spread': 'error',
|
|
328
|
+
|
|
329
|
+
// Requires object keys to be sorted
|
|
330
|
+
'sort-keys': 'off',
|
|
331
|
+
|
|
332
|
+
// Sort variables within the same declaration block
|
|
333
|
+
'sort-vars': 'off',
|
|
334
|
+
|
|
335
|
+
// Require or disallow a space immediately following the // or /* in a comment
|
|
336
|
+
'spaced-comment': ['error', 'always', {
|
|
337
|
+
line: {
|
|
338
|
+
exceptions: ['-', '+'],
|
|
339
|
+
markers: ['=', '!', '/'],
|
|
340
|
+
},
|
|
341
|
+
block: {
|
|
342
|
+
exceptions: ['-', '+'],
|
|
343
|
+
markers: ['=', '!', ':', '::'],
|
|
344
|
+
balanced: true,
|
|
345
|
+
},
|
|
346
|
+
}],
|
|
347
|
+
|
|
348
|
+
// Require or disallow the Unicode Byte Order Mark
|
|
349
|
+
'unicode-bom': ['error', 'never'],
|
|
350
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Airbnb Variables Rules
|
|
3
|
+
* Extracted from eslint-config-airbnb-base for ESLint 9 compatibility
|
|
4
|
+
* @see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/variables.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// List of confusing browser globals that should be explicitly referenced from window
|
|
8
|
+
const restrictedGlobals = [
|
|
9
|
+
'addEventListener',
|
|
10
|
+
'blur',
|
|
11
|
+
'close',
|
|
12
|
+
'closed',
|
|
13
|
+
'confirm',
|
|
14
|
+
'defaultStatus',
|
|
15
|
+
'defaultstatus',
|
|
16
|
+
'event',
|
|
17
|
+
'external',
|
|
18
|
+
'find',
|
|
19
|
+
'focus',
|
|
20
|
+
'frameElement',
|
|
21
|
+
'frames',
|
|
22
|
+
'history',
|
|
23
|
+
'innerHeight',
|
|
24
|
+
'innerWidth',
|
|
25
|
+
'length',
|
|
26
|
+
'location',
|
|
27
|
+
'locationbar',
|
|
28
|
+
'menubar',
|
|
29
|
+
'moveBy',
|
|
30
|
+
'moveTo',
|
|
31
|
+
'name',
|
|
32
|
+
'onblur',
|
|
33
|
+
'onerror',
|
|
34
|
+
'onfocus',
|
|
35
|
+
'onload',
|
|
36
|
+
'onresize',
|
|
37
|
+
'onunload',
|
|
38
|
+
'open',
|
|
39
|
+
'opener',
|
|
40
|
+
'opera',
|
|
41
|
+
'outerHeight',
|
|
42
|
+
'outerWidth',
|
|
43
|
+
'pageXOffset',
|
|
44
|
+
'pageYOffset',
|
|
45
|
+
'parent',
|
|
46
|
+
'print',
|
|
47
|
+
'removeEventListener',
|
|
48
|
+
'resizeBy',
|
|
49
|
+
'resizeTo',
|
|
50
|
+
'screen',
|
|
51
|
+
'screenLeft',
|
|
52
|
+
'screenTop',
|
|
53
|
+
'screenX',
|
|
54
|
+
'screenY',
|
|
55
|
+
'scroll',
|
|
56
|
+
'scrollbars',
|
|
57
|
+
'scrollBy',
|
|
58
|
+
'scrollTo',
|
|
59
|
+
'scrollX',
|
|
60
|
+
'scrollY',
|
|
61
|
+
'self',
|
|
62
|
+
'status',
|
|
63
|
+
'statusbar',
|
|
64
|
+
'stop',
|
|
65
|
+
'toolbar',
|
|
66
|
+
'top',
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
// Enforce or disallow variable initializations at definition
|
|
71
|
+
'init-declarations': 'off',
|
|
72
|
+
|
|
73
|
+
// Disallow the catch clause parameter name being the same as a variable in the outer scope
|
|
74
|
+
'no-catch-shadow': 'off',
|
|
75
|
+
|
|
76
|
+
// Disallow deletion of variables
|
|
77
|
+
'no-delete-var': 'error',
|
|
78
|
+
|
|
79
|
+
// Disallow labels that share a name with a variable
|
|
80
|
+
'no-label-var': 'error',
|
|
81
|
+
|
|
82
|
+
// Disallow specific globals
|
|
83
|
+
'no-restricted-globals': ['error',
|
|
84
|
+
{
|
|
85
|
+
name: 'isFinite',
|
|
86
|
+
message: 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'isNaN',
|
|
90
|
+
message: 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
|
|
91
|
+
},
|
|
92
|
+
...restrictedGlobals.map((g) => ({
|
|
93
|
+
name: g,
|
|
94
|
+
message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
|
|
95
|
+
})),
|
|
96
|
+
],
|
|
97
|
+
|
|
98
|
+
// Disallow declaration of variables already declared in the outer scope
|
|
99
|
+
'no-shadow': 'error',
|
|
100
|
+
|
|
101
|
+
// Disallow shadowing of names such as arguments
|
|
102
|
+
'no-shadow-restricted-names': 'error',
|
|
103
|
+
|
|
104
|
+
// Disallow use of undeclared variables unless mentioned in a /*global */ block
|
|
105
|
+
'no-undef': 'error',
|
|
106
|
+
|
|
107
|
+
// Disallow use of undefined when initializing variables
|
|
108
|
+
'no-undef-init': 'error',
|
|
109
|
+
|
|
110
|
+
// Disallow use of undefined variable
|
|
111
|
+
'no-undefined': 'off',
|
|
112
|
+
|
|
113
|
+
// Disallow declaration of variables that are not used in the code
|
|
114
|
+
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
|
|
115
|
+
|
|
116
|
+
// Disallow use of variables before they are defined
|
|
117
|
+
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
|
|
118
|
+
};
|
package/rules/import-rules.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import namingConvention from './naming-convention.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* These rules are shared by both .js and .ts
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
export default {
|
|
7
7
|
// We disable eslint's no-unused vars, and enable typescript's because
|
|
8
8
|
// otherwise local vars listed in function overloads are flagged.
|
|
9
9
|
'no-unused-vars': 'off',
|
|
@@ -104,4 +104,6 @@ module.exports = {
|
|
|
104
104
|
camelcase: 'off',
|
|
105
105
|
...namingConvention,
|
|
106
106
|
'@typescript-eslint/no-unnecessary-condition': ['warn'],
|
|
107
|
+
// Allow default exports (Airbnb restricts this, but it's a valid pattern)
|
|
108
|
+
'no-restricted-exports': 'off',
|
|
107
109
|
};
|