@gitlab/eslint-plugin 21.5.0 → 23.0.0
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 +299 -0
- package/README.md +16 -11
- package/docs/development.md +2 -1
- package/docs/usage.md +158 -47
- package/eslint9/index.js +6 -7
- package/lib/configs/base/best-practices.js +0 -4
- package/lib/configs/base/es6.js +1 -13
- package/lib/configs/base/imports.js +86 -106
- package/lib/configs/base/node.js +0 -4
- package/lib/confusing-browser-globals.js +68 -0
- package/lib/flat-configs/base.js +122 -0
- package/lib/flat-configs/default.js +13 -0
- package/lib/flat-configs/i18n.js +14 -0
- package/lib/flat-configs/jest.js +20 -0
- package/lib/flat-configs/tailwind.js +19 -0
- package/lib/flat-configs/typescript.js +136 -0
- package/lib/flat-configs/vue.js +16 -0
- package/lib/index.js +30 -39
- package/lib/plugin.js +32 -0
- package/lib/prettier-rules.js +10 -0
- package/lib/rules/no-runtime-template-compiler.js +6 -3
- package/lib/rules/require-i18n-strings.js +4 -4
- package/lib/rules/vtu-no-explicit-wrapper-destroy.js +1 -1
- package/lib/rules/vue-no-new-non-primitive-in-template.js +1 -1
- package/lib/rules/vue-no-undef-apollo-properties.js +1 -1
- package/lib/rules/vue-prefer-dollar-scopedslots.js +1 -1
- package/lib/rules/vue-require-required-key.js +1 -1
- package/lib/rules/vue-slot-name-casing.js +2 -3
- package/lib/utils/hardcoded-urls.js +1 -1
- package/lib/utils/string-utils.js +6 -8
- package/lib/vue-fragments.js +111 -0
- package/package.json +31 -12
- package/scripts/benchmarking/checkAllStrings.js +1 -1
- package/scripts/helpers/getConfigs.js +15 -6
- package/scripts/publish_npm_package.mjs +0 -2
- package/scripts/updateFiles.js +30 -6
- package/eslint9/configs/base.js +0 -140
- package/eslint9/configs/typescript.js +0 -134
- package/lib/configs/base.js +0 -115
- package/lib/configs/default.js +0 -17
- package/lib/configs/i18n.js +0 -10
- package/lib/configs/jest.js +0 -21
- package/lib/configs/tailwind.js +0 -10
- package/lib/configs/typescript.js +0 -95
- package/lib/configs/vue.js +0 -91
|
@@ -1,64 +1,49 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
es6: true,
|
|
4
|
-
},
|
|
5
|
-
parserOptions: {
|
|
6
|
-
ecmaVersion: 6,
|
|
7
|
-
sourceType: 'module',
|
|
8
|
-
},
|
|
9
|
-
plugins: ['import'],
|
|
10
|
-
|
|
11
2
|
settings: {
|
|
12
|
-
'import/
|
|
13
|
-
|
|
14
|
-
extensions: ['.mjs', '.js', '.json'],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
'import/extensions': ['.js', '.mjs', '.jsx'],
|
|
18
|
-
'import/core-modules': [],
|
|
19
|
-
'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'],
|
|
3
|
+
'import-x/extensions': ['.js', '.mjs', '.jsx'],
|
|
4
|
+
'import-x/ignore': ['node_modules'],
|
|
20
5
|
},
|
|
21
6
|
|
|
22
7
|
rules: {
|
|
23
8
|
// Static analysis:
|
|
24
9
|
|
|
25
10
|
// ensure imports point to files/modules that can be resolved
|
|
26
|
-
// https://github.com/
|
|
27
|
-
'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
|
|
11
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
|
|
12
|
+
'import-x/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
|
|
28
13
|
|
|
29
14
|
// ensure named imports coupled with named exports
|
|
30
|
-
// https://github.com/
|
|
31
|
-
'import/named': 'error',
|
|
15
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/named.md#when-not-to-use-it
|
|
16
|
+
'import-x/named': 'error',
|
|
32
17
|
|
|
33
18
|
// ensure default import coupled with default export
|
|
34
|
-
// https://github.com/
|
|
35
|
-
'import/default': 'off',
|
|
19
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/default.md#when-not-to-use-it
|
|
20
|
+
'import-x/default': 'off',
|
|
36
21
|
|
|
37
|
-
// https://github.com/
|
|
38
|
-
'import/namespace': 'off',
|
|
22
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/namespace.md
|
|
23
|
+
'import-x/namespace': 'off',
|
|
39
24
|
|
|
40
25
|
// Helpful warnings:
|
|
41
26
|
|
|
42
27
|
// disallow invalid exports, e.g. multiple defaults
|
|
43
|
-
// https://github.com/
|
|
44
|
-
'import/export': 'error',
|
|
28
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
|
|
29
|
+
'import-x/export': 'error',
|
|
45
30
|
|
|
46
31
|
// do not allow a default import name to match a named export
|
|
47
|
-
// https://github.com/
|
|
48
|
-
'import/no-named-as-default': 'error',
|
|
32
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default.md
|
|
33
|
+
'import-x/no-named-as-default': 'error',
|
|
49
34
|
|
|
50
35
|
// warn on accessing default export property names that are also named exports
|
|
51
|
-
// https://github.com/
|
|
52
|
-
'import/no-named-as-default-member': 'error',
|
|
36
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default-member.md
|
|
37
|
+
'import-x/no-named-as-default-member': 'error',
|
|
53
38
|
|
|
54
39
|
// disallow use of jsdoc-marked-deprecated imports
|
|
55
|
-
// https://github.com/
|
|
56
|
-
'import/no-deprecated': 'off',
|
|
40
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md
|
|
41
|
+
'import-x/no-deprecated': 'off',
|
|
57
42
|
|
|
58
43
|
// Forbid the use of extraneous packages
|
|
59
|
-
// https://github.com/
|
|
44
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
60
45
|
// paths are treated both as absolute paths, and relative to process.cwd()
|
|
61
|
-
'import/no-extraneous-dependencies': [
|
|
46
|
+
'import-x/no-extraneous-dependencies': [
|
|
62
47
|
'error',
|
|
63
48
|
{
|
|
64
49
|
devDependencies: [
|
|
@@ -90,47 +75,42 @@ module.exports = {
|
|
|
90
75
|
],
|
|
91
76
|
|
|
92
77
|
// Forbid mutable exports
|
|
93
|
-
// https://github.com/
|
|
94
|
-
'import/no-mutable-exports': 'error',
|
|
78
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-mutable-exports.md
|
|
79
|
+
'import-x/no-mutable-exports': 'error',
|
|
95
80
|
|
|
96
81
|
// Module systems:
|
|
97
82
|
|
|
98
83
|
// disallow require()
|
|
99
|
-
// https://github.com/
|
|
100
|
-
'import/no-commonjs': 'off',
|
|
84
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-commonjs.md
|
|
85
|
+
'import-x/no-commonjs': 'off',
|
|
101
86
|
|
|
102
87
|
// disallow AMD require/define
|
|
103
|
-
// https://github.com/
|
|
104
|
-
'import/no-amd': 'error',
|
|
88
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-amd.md
|
|
89
|
+
'import-x/no-amd': 'error',
|
|
105
90
|
|
|
106
91
|
// No Node.js builtin modules
|
|
107
|
-
// https://github.com/
|
|
92
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-nodejs-modules.md
|
|
108
93
|
// TODO: enable?
|
|
109
|
-
'import/no-nodejs-modules': 'off',
|
|
94
|
+
'import-x/no-nodejs-modules': 'off',
|
|
110
95
|
|
|
111
96
|
// Style guide:
|
|
112
97
|
|
|
113
98
|
// disallow non-import statements appearing before import statements
|
|
114
|
-
// https://github.com/
|
|
115
|
-
'import/first': 'error',
|
|
116
|
-
|
|
117
|
-
// disallow non-import statements appearing before import statements
|
|
118
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
|
|
119
|
-
// deprecated: use `import/first`
|
|
120
|
-
'import/imports-first': 'off',
|
|
99
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/first.md
|
|
100
|
+
'import-x/first': 'error',
|
|
121
101
|
|
|
122
102
|
// disallow duplicate imports
|
|
123
|
-
// https://github.com/
|
|
124
|
-
'import/no-duplicates': 'error',
|
|
103
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-duplicates.md
|
|
104
|
+
'import-x/no-duplicates': 'error',
|
|
125
105
|
|
|
126
106
|
// disallow namespace imports
|
|
127
107
|
// TODO: enable?
|
|
128
|
-
// https://github.com/
|
|
129
|
-
'import/no-namespace': 'off',
|
|
108
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-namespace.md
|
|
109
|
+
'import-x/no-namespace': 'off',
|
|
130
110
|
|
|
131
111
|
// Ensure consistent use of file extension within the import path
|
|
132
|
-
// https://github.com/
|
|
133
|
-
'import/extensions': [
|
|
112
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
|
|
113
|
+
'import-x/extensions': [
|
|
134
114
|
'error',
|
|
135
115
|
'ignorePackages',
|
|
136
116
|
{
|
|
@@ -141,37 +121,37 @@ module.exports = {
|
|
|
141
121
|
],
|
|
142
122
|
|
|
143
123
|
// ensure absolute imports are above relative imports and that unassigned imports are ignored
|
|
144
|
-
// https://github.com/
|
|
124
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/order.md
|
|
145
125
|
// TODO: enforce a stricter convention in module import order?
|
|
146
|
-
'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
|
|
126
|
+
'import-x/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
|
|
147
127
|
|
|
148
128
|
// Require a newline after the last import/require in a group
|
|
149
|
-
// https://github.com/
|
|
150
|
-
'import/newline-after-import': 'error',
|
|
129
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/newline-after-import.md
|
|
130
|
+
'import-x/newline-after-import': 'error',
|
|
151
131
|
|
|
152
132
|
// Require modules with a single export to use a default export
|
|
153
|
-
// https://github.com/
|
|
154
|
-
'import/prefer-default-export': 'error',
|
|
133
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/prefer-default-export.md
|
|
134
|
+
'import-x/prefer-default-export': 'error',
|
|
155
135
|
|
|
156
136
|
// Restrict which files can be imported in a given folder
|
|
157
|
-
// https://github.com/
|
|
158
|
-
'import/no-restricted-paths': 'off',
|
|
137
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-restricted-paths.md
|
|
138
|
+
'import-x/no-restricted-paths': 'off',
|
|
159
139
|
|
|
160
140
|
// Forbid modules to have too many dependencies
|
|
161
|
-
// https://github.com/
|
|
162
|
-
'import/max-dependencies': ['off', { max: 10 }],
|
|
141
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/max-dependencies.md
|
|
142
|
+
'import-x/max-dependencies': ['off', { max: 10 }],
|
|
163
143
|
|
|
164
144
|
// Forbid import of modules using absolute paths
|
|
165
|
-
// https://github.com/
|
|
166
|
-
'import/no-absolute-path': 'error',
|
|
145
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-absolute-path.md
|
|
146
|
+
'import-x/no-absolute-path': 'error',
|
|
167
147
|
|
|
168
148
|
// Forbid require() calls with expressions
|
|
169
|
-
// https://github.com/
|
|
170
|
-
'import/no-dynamic-require': 'error',
|
|
149
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-dynamic-require.md
|
|
150
|
+
'import-x/no-dynamic-require': 'error',
|
|
171
151
|
|
|
172
152
|
// prevent importing the submodules of other modules
|
|
173
|
-
// https://github.com/
|
|
174
|
-
'import/no-internal-modules': [
|
|
153
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-internal-modules.md
|
|
154
|
+
'import-x/no-internal-modules': [
|
|
175
155
|
'off',
|
|
176
156
|
{
|
|
177
157
|
allow: [],
|
|
@@ -180,27 +160,27 @@ module.exports = {
|
|
|
180
160
|
|
|
181
161
|
// Warn if a module could be mistakenly parsed as a script by a consumer
|
|
182
162
|
// leveraging Unambiguous JavaScript Grammar
|
|
183
|
-
// https://github.com/
|
|
163
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/unambiguous.md
|
|
184
164
|
// this should not be enabled until this proposal has at least been *presented* to TC39.
|
|
185
165
|
// At the moment, it's not a thing.
|
|
186
|
-
'import/unambiguous': 'off',
|
|
166
|
+
'import-x/unambiguous': 'off',
|
|
187
167
|
|
|
188
168
|
// Forbid Webpack loader syntax in imports
|
|
189
|
-
// https://github.com/
|
|
190
|
-
'import/no-webpack-loader-syntax': 'error',
|
|
169
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
|
|
170
|
+
'import-x/no-webpack-loader-syntax': 'error',
|
|
191
171
|
|
|
192
172
|
// Prevent unassigned imports
|
|
193
|
-
// https://github.com/
|
|
173
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unassigned-import.md
|
|
194
174
|
// importing for side effects is perfectly acceptable, if you need side effects.
|
|
195
|
-
'import/no-unassigned-import': 'off',
|
|
175
|
+
'import-x/no-unassigned-import': 'off',
|
|
196
176
|
|
|
197
177
|
// Prevent importing the default as if it were named
|
|
198
|
-
// https://github.com/
|
|
199
|
-
'import/no-named-default': 'error',
|
|
178
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-default.md
|
|
179
|
+
'import-x/no-named-default': 'error',
|
|
200
180
|
|
|
201
181
|
// Reports if a module's default export is unnamed
|
|
202
|
-
// https://github.com/
|
|
203
|
-
'import/no-anonymous-default-export': [
|
|
182
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-anonymous-default-export.md
|
|
183
|
+
'import-x/no-anonymous-default-export': [
|
|
204
184
|
'off',
|
|
205
185
|
{
|
|
206
186
|
allowArray: false,
|
|
@@ -213,39 +193,39 @@ module.exports = {
|
|
|
213
193
|
],
|
|
214
194
|
|
|
215
195
|
// This rule enforces that all exports are declared at the bottom of the file.
|
|
216
|
-
// https://github.com/
|
|
196
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/exports-last.md
|
|
217
197
|
// TODO: enable?
|
|
218
|
-
'import/exports-last': 'off',
|
|
198
|
+
'import-x/exports-last': 'off',
|
|
219
199
|
|
|
220
200
|
// Reports when named exports are not grouped together in a single export declaration
|
|
221
201
|
// or when multiple assignments to CommonJS module.exports or exports object are present
|
|
222
202
|
// in a single file.
|
|
223
|
-
// https://github.com/
|
|
224
|
-
'import/group-exports': 'off',
|
|
203
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/group-exports.md
|
|
204
|
+
'import-x/group-exports': 'off',
|
|
225
205
|
|
|
226
206
|
// forbid default exports. this is a terrible rule, do not use it.
|
|
227
|
-
// https://github.com/
|
|
228
|
-
'import/no-default-export': 'off',
|
|
207
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-default-export.md
|
|
208
|
+
'import-x/no-default-export': 'off',
|
|
229
209
|
|
|
230
210
|
// Prohibit named exports. this is a terrible rule, do not use it.
|
|
231
|
-
// https://github.com/
|
|
232
|
-
'import/no-named-export': 'off',
|
|
211
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-export.md
|
|
212
|
+
'import-x/no-named-export': 'off',
|
|
233
213
|
|
|
234
214
|
// Forbid a module from importing itself
|
|
235
|
-
// https://github.com/
|
|
236
|
-
'import/no-self-import': 'error',
|
|
215
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-self-import.md
|
|
216
|
+
'import-x/no-self-import': 'error',
|
|
237
217
|
|
|
238
218
|
// Forbid cyclical dependencies between modules
|
|
239
|
-
// https://github.com/
|
|
240
|
-
'import/no-cycle': ['error', { maxDepth: '∞' }],
|
|
219
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-cycle.md
|
|
220
|
+
'import-x/no-cycle': ['error', { maxDepth: '∞' }],
|
|
241
221
|
|
|
242
222
|
// Ensures that there are no useless path segments
|
|
243
|
-
// https://github.com/
|
|
244
|
-
'import/no-useless-path-segments': ['error', { commonjs: true }],
|
|
223
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
|
|
224
|
+
'import-x/no-useless-path-segments': ['error', { commonjs: true }],
|
|
245
225
|
|
|
246
226
|
// dynamic imports require a leading comment with a webpackChunkName
|
|
247
|
-
// https://github.com/
|
|
248
|
-
'import/dynamic-import-chunkname': [
|
|
227
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/dynamic-import-chunkname.md
|
|
228
|
+
'import-x/dynamic-import-chunkname': [
|
|
249
229
|
'off',
|
|
250
230
|
{
|
|
251
231
|
importFunctions: [],
|
|
@@ -254,13 +234,13 @@ module.exports = {
|
|
|
254
234
|
],
|
|
255
235
|
|
|
256
236
|
// Use this rule to prevent imports to folders in relative parent paths.
|
|
257
|
-
// https://github.com/
|
|
258
|
-
'import/no-relative-parent-imports': 'off',
|
|
237
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-parent-imports.md
|
|
238
|
+
'import-x/no-relative-parent-imports': 'off',
|
|
259
239
|
|
|
260
240
|
// Reports modules without any exports, or with unused exports
|
|
261
|
-
// https://github.com/
|
|
241
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unused-modules.md
|
|
262
242
|
// TODO: enable once it supports CJS
|
|
263
|
-
'import/no-unused-modules': [
|
|
243
|
+
'import-x/no-unused-modules': [
|
|
264
244
|
'off',
|
|
265
245
|
{
|
|
266
246
|
ignoreExports: [],
|
|
@@ -270,8 +250,8 @@ module.exports = {
|
|
|
270
250
|
],
|
|
271
251
|
|
|
272
252
|
// Reports the use of import declarations with CommonJS exports in any module except for the main module.
|
|
273
|
-
// https://github.com/
|
|
274
|
-
'import/no-import-module-exports': [
|
|
253
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
|
|
254
|
+
'import-x/no-import-module-exports': [
|
|
275
255
|
'error',
|
|
276
256
|
{
|
|
277
257
|
exceptions: [],
|
|
@@ -279,7 +259,7 @@ module.exports = {
|
|
|
279
259
|
],
|
|
280
260
|
|
|
281
261
|
// Use this rule to prevent importing packages through relative paths.
|
|
282
|
-
// https://github.com/
|
|
283
|
-
'import/no-relative-packages': 'error',
|
|
262
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
|
|
263
|
+
'import-x/no-relative-packages': 'error',
|
|
284
264
|
},
|
|
285
265
|
};
|
package/lib/configs/base/node.js
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined from the `confusing-browser-globals` package.
|
|
3
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* See: https://www.npmjs.com/package/confusing-browser-globals
|
|
6
|
+
*/
|
|
7
|
+
const confusingBrowserGlobals = [
|
|
8
|
+
'addEventListener',
|
|
9
|
+
'blur',
|
|
10
|
+
'close',
|
|
11
|
+
'closed',
|
|
12
|
+
'confirm',
|
|
13
|
+
'defaultStatus',
|
|
14
|
+
'defaultstatus',
|
|
15
|
+
'event',
|
|
16
|
+
'external',
|
|
17
|
+
'find',
|
|
18
|
+
'focus',
|
|
19
|
+
'frameElement',
|
|
20
|
+
'frames',
|
|
21
|
+
'history',
|
|
22
|
+
'innerHeight',
|
|
23
|
+
'innerWidth',
|
|
24
|
+
'length',
|
|
25
|
+
'location',
|
|
26
|
+
'locationbar',
|
|
27
|
+
'menubar',
|
|
28
|
+
'moveBy',
|
|
29
|
+
'moveTo',
|
|
30
|
+
'name',
|
|
31
|
+
'onblur',
|
|
32
|
+
'onerror',
|
|
33
|
+
'onfocus',
|
|
34
|
+
'onload',
|
|
35
|
+
'onresize',
|
|
36
|
+
'onunload',
|
|
37
|
+
'open',
|
|
38
|
+
'opener',
|
|
39
|
+
'opera',
|
|
40
|
+
'outerHeight',
|
|
41
|
+
'outerWidth',
|
|
42
|
+
'pageXOffset',
|
|
43
|
+
'pageYOffset',
|
|
44
|
+
'parent',
|
|
45
|
+
'print',
|
|
46
|
+
'removeEventListener',
|
|
47
|
+
'resizeBy',
|
|
48
|
+
'resizeTo',
|
|
49
|
+
'screen',
|
|
50
|
+
'screenLeft',
|
|
51
|
+
'screenTop',
|
|
52
|
+
'screenX',
|
|
53
|
+
'screenY',
|
|
54
|
+
'scroll',
|
|
55
|
+
'scrollbars',
|
|
56
|
+
'scrollBy',
|
|
57
|
+
'scrollTo',
|
|
58
|
+
'scrollX',
|
|
59
|
+
'scrollY',
|
|
60
|
+
'self',
|
|
61
|
+
'status',
|
|
62
|
+
'statusbar',
|
|
63
|
+
'stop',
|
|
64
|
+
'toolbar',
|
|
65
|
+
'top',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
module.exports = confusingBrowserGlobals;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const globals = require('globals');
|
|
2
|
+
const unicornPlugin = require('eslint-plugin-unicorn');
|
|
3
|
+
const promisePlugin = require('eslint-plugin-promise');
|
|
4
|
+
const importPlugin = require('eslint-plugin-import-x');
|
|
5
|
+
|
|
6
|
+
const confusingBrowserGlobals = require('../confusing-browser-globals');
|
|
7
|
+
const gitlabPlugin = require('../plugin.js');
|
|
8
|
+
const prettierRules = require('../prettier-rules');
|
|
9
|
+
|
|
10
|
+
const bestPractices = require('../configs/base/best-practices');
|
|
11
|
+
const errors = require('../configs/base/errors');
|
|
12
|
+
const node = require('../configs/base/node');
|
|
13
|
+
const style = require('../configs/base/style');
|
|
14
|
+
const variables = require('../configs/base/variables');
|
|
15
|
+
const es6 = require('../configs/base/es6');
|
|
16
|
+
const imports = require('../configs/base/imports');
|
|
17
|
+
const strict = require('../configs/base/strict');
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
Rules related to the GitLab JavaScript style guide.
|
|
21
|
+
Vue-specific rules live in lib/flat-configs/vue.js
|
|
22
|
+
*/
|
|
23
|
+
module.exports = [
|
|
24
|
+
{
|
|
25
|
+
languageOptions: {
|
|
26
|
+
globals: {
|
|
27
|
+
...globals.browser,
|
|
28
|
+
...globals.es2020,
|
|
29
|
+
...globals.es2015,
|
|
30
|
+
...globals.node,
|
|
31
|
+
},
|
|
32
|
+
ecmaVersion: 'latest',
|
|
33
|
+
sourceType: 'module',
|
|
34
|
+
},
|
|
35
|
+
plugins: {
|
|
36
|
+
unicorn: unicornPlugin,
|
|
37
|
+
promise: promisePlugin,
|
|
38
|
+
'import-x': importPlugin,
|
|
39
|
+
'@gitlab': gitlabPlugin,
|
|
40
|
+
},
|
|
41
|
+
settings: imports.settings,
|
|
42
|
+
},
|
|
43
|
+
/*
|
|
44
|
+
One config object per rule set, not one merged `rules` block: a
|
|
45
|
+
severity-only override later in the array (`'no-restricted-syntax': 'off'`)
|
|
46
|
+
keeps the options it inherits from an earlier object. Merging these would
|
|
47
|
+
strip the inherited options from 56 rules at unchanged severity.
|
|
48
|
+
*/
|
|
49
|
+
{ rules: bestPractices.rules },
|
|
50
|
+
{ rules: errors.rules },
|
|
51
|
+
{ rules: node.rules },
|
|
52
|
+
{ rules: style.rules },
|
|
53
|
+
{ rules: variables.rules },
|
|
54
|
+
{ rules: es6.rules },
|
|
55
|
+
{ rules: imports.rules },
|
|
56
|
+
{ rules: strict.rules },
|
|
57
|
+
{ rules: promisePlugin.configs['flat/recommended'].rules },
|
|
58
|
+
{ rules: prettierRules },
|
|
59
|
+
{
|
|
60
|
+
rules: {
|
|
61
|
+
camelcase: ['error', { properties: 'never', ignoreDestructuring: true }],
|
|
62
|
+
'default-param-last': 'off',
|
|
63
|
+
'arrow-body-style': 'off',
|
|
64
|
+
'unicorn/filename-case': ['error', { case: 'snakeCase' }],
|
|
65
|
+
'unicorn/no-array-callback-reference': 'error',
|
|
66
|
+
'import-x/prefer-default-export': 'off',
|
|
67
|
+
'import-x/no-default-export': 'error',
|
|
68
|
+
'import-x/no-deprecated': 'error',
|
|
69
|
+
'import-x/no-dynamic-require': ['error', { esmodule: true }],
|
|
70
|
+
'no-implicit-coercion': ['error', { boolean: true, number: true, string: true }],
|
|
71
|
+
'no-param-reassign': [
|
|
72
|
+
'error',
|
|
73
|
+
{
|
|
74
|
+
props: true,
|
|
75
|
+
ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
'no-restricted-exports': [
|
|
79
|
+
'error',
|
|
80
|
+
{
|
|
81
|
+
restrictedNamedExports: [
|
|
82
|
+
'then', // avoid confusion when used with dynamic `import()` promise
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
'no-restricted-syntax': 'off',
|
|
87
|
+
'no-sequences': ['error', { allowInParentheses: false }],
|
|
88
|
+
'promise/catch-or-return': ['error', { allowFinally: true }],
|
|
89
|
+
'no-restricted-globals': [
|
|
90
|
+
'error',
|
|
91
|
+
{
|
|
92
|
+
name: 'isFinite',
|
|
93
|
+
message:
|
|
94
|
+
'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'isNaN',
|
|
98
|
+
message:
|
|
99
|
+
'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'escape',
|
|
103
|
+
message:
|
|
104
|
+
"The global `escape` function is unsafe. Did you mean to use `encodeURI`, `encodeURIComponent` or lodash's `escape` instead?",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'unescape',
|
|
108
|
+
message:
|
|
109
|
+
"The global `unescape` function is unsafe. Did you mean to use `decodeURI`, `decodeURIComponent` or lodash's `unescape` instead?",
|
|
110
|
+
},
|
|
111
|
+
].concat(confusingBrowserGlobals),
|
|
112
|
+
'import-x/order': [
|
|
113
|
+
'error',
|
|
114
|
+
{
|
|
115
|
+
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
// https://docs.gitlab.com/ee/development/fe_guide/style/javascript.html#limit-number-of-parameters
|
|
119
|
+
'max-params': ['error', { max: 3 }],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const base = require('./base');
|
|
2
|
+
const { presetAndSetup, gitlabRules } = require('../vue-fragments');
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
The GitLab JavaScript and Vue rules combined. This is the config most
|
|
6
|
+
consumers want.
|
|
7
|
+
|
|
8
|
+
Not `[...base, ...vue]`. base already contributes eslint-config-prettier, and
|
|
9
|
+
it lands *before* the vue preset here, where lib/flat-configs/vue.js puts it
|
|
10
|
+
after -- so six vue formatting rules stay at the preset's `warn` in this
|
|
11
|
+
config and are `off` in vue. That asymmetry is inherited, not a bug.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = [...base, ...presetAndSetup, ...gitlabRules];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const gitlabPlugin = require('../plugin.js');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
plugins: { '@gitlab': gitlabPlugin },
|
|
6
|
+
rules: {
|
|
7
|
+
'@gitlab/require-i18n-strings': 'error',
|
|
8
|
+
'@gitlab/vue-require-i18n-attribute-strings': 'error',
|
|
9
|
+
'@gitlab/vue-require-i18n-strings': 'error',
|
|
10
|
+
'@gitlab/require-valid-i18n-helpers': 'error',
|
|
11
|
+
'@gitlab/vue-require-valid-i18n-helpers': 'error',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const jestPlugin = require('eslint-plugin-jest');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
jestPlugin.configs['flat/recommended'],
|
|
5
|
+
{
|
|
6
|
+
rules: {
|
|
7
|
+
'jest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
|
|
8
|
+
'jest/no-conditional-expect': 'off',
|
|
9
|
+
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
|
|
10
|
+
'jest/no-restricted-matchers': [
|
|
11
|
+
'error',
|
|
12
|
+
{
|
|
13
|
+
toBeFalsy: 'Prefer a stronger matcher like `toBe(false)`',
|
|
14
|
+
toBeTruthy: 'Prefer a stronger matcher like `toBe(true)`',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
'jest/prefer-to-have-length': 'error',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const tailwindPlugin = require('eslint-plugin-tailwindcss');
|
|
2
|
+
|
|
3
|
+
const gitlabPlugin = require('../plugin.js');
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
{
|
|
7
|
+
plugins: {
|
|
8
|
+
'@gitlab': gitlabPlugin,
|
|
9
|
+
tailwindcss: tailwindPlugin,
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'@gitlab/tailwind-no-interpolation': 'error',
|
|
13
|
+
'@gitlab/vue-tailwind-no-interpolation': 'error',
|
|
14
|
+
'@gitlab/tailwind-no-max-width-media-queries': 'error',
|
|
15
|
+
'@gitlab/vue-tailwind-no-max-width-media-queries': 'error',
|
|
16
|
+
'tailwindcss/no-arbitrary-value': 'error',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|