@storm-software/linting-tools 1.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/LICENSE +201 -0
- package/README.md +142 -0
- package/alex/.alexignore +5 -0
- package/alex/.alexrc +43 -0
- package/bin/cli.js +13 -0
- package/cli/index.js +315082 -0
- package/cspell/config.js +212 -0
- package/cspell/dictionary.txt +239 -0
- package/eslint/graphql/index.js +133 -0
- package/eslint/javascript/index.js +376 -0
- package/eslint/jest/index.js +24 -0
- package/eslint/json/index.js +100 -0
- package/eslint/next/index.js +95 -0
- package/eslint/react/index.js +144 -0
- package/eslint/typescript/index.js +577 -0
- package/manypkg/index.js +25626 -0
- package/package.json +118 -0
- package/prettier/.prettierignore +15 -0
- package/prettier/config.json +28 -0
- package/tsconfig/reset.d.ts +2 -0
- package/tsconfig/tsconfig.root.json +24 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { fileURLToPath as _fileURLToPath } from 'url';
|
|
2
|
+
import _path from 'node:path';
|
|
3
|
+
import { createRequire as topLevelCreateRequire } from 'module';
|
|
4
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = _fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = _path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
// packages/linting-tools/src/eslint/rules/import.ts
|
|
9
|
+
var config = {
|
|
10
|
+
/**
|
|
11
|
+
* Disallow non-import statements appearing before import statements.
|
|
12
|
+
*
|
|
13
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
|
|
14
|
+
*/
|
|
15
|
+
"import/first": "error",
|
|
16
|
+
/**
|
|
17
|
+
* Require a newline after the last import/require.
|
|
18
|
+
*
|
|
19
|
+
* 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md
|
|
20
|
+
*/
|
|
21
|
+
"import/newline-after-import": "warn",
|
|
22
|
+
/**
|
|
23
|
+
* Disallow import of modules using absolute paths.
|
|
24
|
+
*
|
|
25
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md
|
|
26
|
+
*/
|
|
27
|
+
"import/no-absolute-path": "error",
|
|
28
|
+
/**
|
|
29
|
+
* Disallow cyclical dependencies between modules.
|
|
30
|
+
*
|
|
31
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
|
|
32
|
+
*/
|
|
33
|
+
"import/no-cycle": "error",
|
|
34
|
+
/**
|
|
35
|
+
* Disallow default exports.
|
|
36
|
+
*
|
|
37
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
|
|
38
|
+
*/
|
|
39
|
+
"import/no-default-export": "error",
|
|
40
|
+
/**
|
|
41
|
+
* Disallow the use of extraneous packages.
|
|
42
|
+
*
|
|
43
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
|
|
44
|
+
*/
|
|
45
|
+
"import/no-extraneous-dependencies": [
|
|
46
|
+
"error",
|
|
47
|
+
{ includeInternal: true, includeTypes: true }
|
|
48
|
+
],
|
|
49
|
+
/**
|
|
50
|
+
* Disallow mutable exports.
|
|
51
|
+
*
|
|
52
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md
|
|
53
|
+
*/
|
|
54
|
+
"import/no-mutable-exports": "error",
|
|
55
|
+
/**
|
|
56
|
+
* Disallow importing packages through relative paths.
|
|
57
|
+
*
|
|
58
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-packages.md
|
|
59
|
+
*/
|
|
60
|
+
"import/no-relative-packages": "warn",
|
|
61
|
+
/**
|
|
62
|
+
* Disallow a module from importing itself.
|
|
63
|
+
*
|
|
64
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md
|
|
65
|
+
*/
|
|
66
|
+
"import/no-self-import": "error",
|
|
67
|
+
/**
|
|
68
|
+
* Ensures that there are no useless path segments.
|
|
69
|
+
*
|
|
70
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-useless-path-segments.md
|
|
71
|
+
*/
|
|
72
|
+
"import/no-useless-path-segments": ["error"],
|
|
73
|
+
/**
|
|
74
|
+
* Enforce a module import order convention.
|
|
75
|
+
*
|
|
76
|
+
* 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
|
|
77
|
+
*/
|
|
78
|
+
"import/order": [
|
|
79
|
+
"warn",
|
|
80
|
+
{
|
|
81
|
+
groups: [
|
|
82
|
+
"builtin",
|
|
83
|
+
// Node.js built-in modules
|
|
84
|
+
"external",
|
|
85
|
+
// Packages
|
|
86
|
+
"internal",
|
|
87
|
+
// Aliased modules
|
|
88
|
+
"parent",
|
|
89
|
+
// Relative parent
|
|
90
|
+
"sibling",
|
|
91
|
+
// Relative sibling
|
|
92
|
+
"index"
|
|
93
|
+
// Relative index
|
|
94
|
+
],
|
|
95
|
+
"newlines-between": "never"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
var import_default = config;
|
|
100
|
+
|
|
101
|
+
// packages/linting-tools/src/eslint/rules/storm.ts
|
|
102
|
+
var config2 = {
|
|
103
|
+
/**
|
|
104
|
+
* Require return statements in array methods callbacks.
|
|
105
|
+
*
|
|
106
|
+
* 🚫 Not fixable -https://eslint.org/docs/rules/array-callback-return
|
|
107
|
+
*/
|
|
108
|
+
"array-callback-return": ["error", { allowImplicit: true }],
|
|
109
|
+
/**
|
|
110
|
+
* Treat `var` statements as if they were block scoped.
|
|
111
|
+
*
|
|
112
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/block-scoped-var
|
|
113
|
+
*/
|
|
114
|
+
"block-scoped-var": "error",
|
|
115
|
+
/**
|
|
116
|
+
* Require curly braces for multiline blocks.
|
|
117
|
+
*
|
|
118
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/curly
|
|
119
|
+
*/
|
|
120
|
+
curly: ["warn", "multi-line"],
|
|
121
|
+
/**
|
|
122
|
+
* Require default clauses in switch statements to be last (if used).
|
|
123
|
+
*
|
|
124
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/default-case-last
|
|
125
|
+
*/
|
|
126
|
+
"default-case-last": "error",
|
|
127
|
+
/**
|
|
128
|
+
* Require triple equals (`===` and `!==`).
|
|
129
|
+
*
|
|
130
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/eqeqeq
|
|
131
|
+
*/
|
|
132
|
+
eqeqeq: "error",
|
|
133
|
+
/**
|
|
134
|
+
* Require grouped accessor pairs in object literals and classes.
|
|
135
|
+
*
|
|
136
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/grouped-accessor-pairs
|
|
137
|
+
*/
|
|
138
|
+
"grouped-accessor-pairs": "error",
|
|
139
|
+
/**
|
|
140
|
+
* Disallow use of `alert()`.
|
|
141
|
+
*
|
|
142
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-alert
|
|
143
|
+
*/
|
|
144
|
+
"no-alert": "error",
|
|
145
|
+
/**
|
|
146
|
+
* Disallow use of `caller`/`callee`.
|
|
147
|
+
*
|
|
148
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-caller
|
|
149
|
+
*/
|
|
150
|
+
"no-caller": "error",
|
|
151
|
+
/**
|
|
152
|
+
* Disallow returning value in constructor.
|
|
153
|
+
*
|
|
154
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-constructor-return
|
|
155
|
+
*/
|
|
156
|
+
"no-constructor-return": "error",
|
|
157
|
+
/**
|
|
158
|
+
* Disallow using an `else` if the `if` block contains a return.
|
|
159
|
+
*
|
|
160
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-else-return
|
|
161
|
+
*/
|
|
162
|
+
"no-else-return": "warn",
|
|
163
|
+
/**
|
|
164
|
+
* Disallow `eval()`.
|
|
165
|
+
*
|
|
166
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-eval
|
|
167
|
+
*/
|
|
168
|
+
"no-eval": "error",
|
|
169
|
+
/**
|
|
170
|
+
* Disallow extending native objects.
|
|
171
|
+
*
|
|
172
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-extend-native
|
|
173
|
+
*/
|
|
174
|
+
"no-extend-native": "error",
|
|
175
|
+
/**
|
|
176
|
+
* Disallow unnecessary function binding.
|
|
177
|
+
*
|
|
178
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-extra-bind
|
|
179
|
+
*/
|
|
180
|
+
"no-extra-bind": "error",
|
|
181
|
+
/**
|
|
182
|
+
* Disallow unnecessary labels.
|
|
183
|
+
*
|
|
184
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-extra-label
|
|
185
|
+
*/
|
|
186
|
+
"no-extra-label": "error",
|
|
187
|
+
/**
|
|
188
|
+
* Disallow floating decimals.
|
|
189
|
+
*
|
|
190
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-floating-decimal
|
|
191
|
+
*/
|
|
192
|
+
"no-floating-decimal": "error",
|
|
193
|
+
/**
|
|
194
|
+
* Make people convert types explicitly e.g. `Boolean(foo)` instead of `!!foo`.
|
|
195
|
+
*
|
|
196
|
+
* 🔧 Partially Fixable - https://eslint.org/docs/rules/no-implicit-coercion
|
|
197
|
+
*/
|
|
198
|
+
"no-implicit-coercion": "error",
|
|
199
|
+
/**
|
|
200
|
+
* Disallow use of `eval()`-like methods.
|
|
201
|
+
*
|
|
202
|
+
* https://eslint.org/docs/rules/no-implied-eval
|
|
203
|
+
*/
|
|
204
|
+
"no-implied-eval": "error",
|
|
205
|
+
/**
|
|
206
|
+
* Disallow usage of `__iterator__` property.
|
|
207
|
+
*
|
|
208
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-iterator
|
|
209
|
+
*/
|
|
210
|
+
"no-iterator": "error",
|
|
211
|
+
/**
|
|
212
|
+
* Disallow use of labels for anything other than loops and switches.
|
|
213
|
+
*
|
|
214
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-labels
|
|
215
|
+
*/
|
|
216
|
+
"no-labels": ["error"],
|
|
217
|
+
/**
|
|
218
|
+
* Disallow unnecessary nested blocks.
|
|
219
|
+
*
|
|
220
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-lone-blocks
|
|
221
|
+
*/
|
|
222
|
+
"no-lone-blocks": "error",
|
|
223
|
+
/**
|
|
224
|
+
* Disallow `new` for side effects.
|
|
225
|
+
*
|
|
226
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-new
|
|
227
|
+
*/
|
|
228
|
+
"no-new": "error",
|
|
229
|
+
/**
|
|
230
|
+
* Disallow function constructors.
|
|
231
|
+
*
|
|
232
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-new-func
|
|
233
|
+
*/
|
|
234
|
+
"no-new-func": "error",
|
|
235
|
+
/**
|
|
236
|
+
* Disallow base types wrapper instances, such as `new String('foo')`.
|
|
237
|
+
*
|
|
238
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-new-wrappers
|
|
239
|
+
*/
|
|
240
|
+
"no-new-wrappers": "error",
|
|
241
|
+
/**
|
|
242
|
+
* Disallow use of octal escape sequences in string literals.
|
|
243
|
+
*
|
|
244
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-octal-escape
|
|
245
|
+
*/
|
|
246
|
+
"no-octal-escape": "error",
|
|
247
|
+
/**
|
|
248
|
+
* Disallow reassignment of function parameters.
|
|
249
|
+
*
|
|
250
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-param-reassign
|
|
251
|
+
*/
|
|
252
|
+
"no-param-reassign": "error",
|
|
253
|
+
/**
|
|
254
|
+
* Disallow usage of the deprecated `__proto__` property.
|
|
255
|
+
*
|
|
256
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-proto
|
|
257
|
+
*/
|
|
258
|
+
"no-proto": "error",
|
|
259
|
+
/**
|
|
260
|
+
* Disallow assignment in `return` statement.
|
|
261
|
+
*
|
|
262
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-return-assign
|
|
263
|
+
*/
|
|
264
|
+
"no-return-assign": "error",
|
|
265
|
+
/**
|
|
266
|
+
* Disallows unnecessary `return await`.
|
|
267
|
+
*
|
|
268
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-return-await
|
|
269
|
+
*/
|
|
270
|
+
"no-return-await": "error",
|
|
271
|
+
/**
|
|
272
|
+
* Disallow use of `javascript:` urls.
|
|
273
|
+
*
|
|
274
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-script-url
|
|
275
|
+
*/
|
|
276
|
+
"no-script-url": "error",
|
|
277
|
+
/**
|
|
278
|
+
* Disallow comparisons where both sides are exactly the same.
|
|
279
|
+
*
|
|
280
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-self-compare
|
|
281
|
+
*/
|
|
282
|
+
"no-self-compare": "error",
|
|
283
|
+
/**
|
|
284
|
+
* Disallow use of comma operator.
|
|
285
|
+
*
|
|
286
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-sequences
|
|
287
|
+
*/
|
|
288
|
+
"no-sequences": "error",
|
|
289
|
+
/**
|
|
290
|
+
* Disallow unnecessary `.call()` and `.apply()`.
|
|
291
|
+
*
|
|
292
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-useless-call
|
|
293
|
+
*/
|
|
294
|
+
"no-useless-call": "error",
|
|
295
|
+
/**
|
|
296
|
+
* Disallow unnecessary concatenation of strings.
|
|
297
|
+
*
|
|
298
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-useless-concat
|
|
299
|
+
*/
|
|
300
|
+
"no-useless-concat": "error",
|
|
301
|
+
/**
|
|
302
|
+
* Disallow redundant return statements.
|
|
303
|
+
*
|
|
304
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-useless-return
|
|
305
|
+
*/
|
|
306
|
+
"no-useless-return": "warn",
|
|
307
|
+
/**
|
|
308
|
+
* Require using named capture groups in regular expressions.
|
|
309
|
+
*
|
|
310
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-named-capture-group
|
|
311
|
+
*/
|
|
312
|
+
"prefer-named-capture-group": "error",
|
|
313
|
+
/**
|
|
314
|
+
* Require using Error objects as Promise rejection reasons.
|
|
315
|
+
*
|
|
316
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-promise-reject-errors
|
|
317
|
+
*/
|
|
318
|
+
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
|
|
319
|
+
/**
|
|
320
|
+
* Disallow use of the RegExp constructor in favor of regular expression
|
|
321
|
+
* literals.
|
|
322
|
+
*
|
|
323
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-regex-literals
|
|
324
|
+
*/
|
|
325
|
+
"prefer-regex-literals": "error",
|
|
326
|
+
/**
|
|
327
|
+
* Disallow "Yoda conditions", ensuring the comparison.
|
|
328
|
+
*
|
|
329
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/yoda
|
|
330
|
+
*/
|
|
331
|
+
yoda: "warn"
|
|
332
|
+
};
|
|
333
|
+
var storm_default = config2;
|
|
334
|
+
|
|
335
|
+
// packages/linting-tools/src/eslint/rules/unicorn.ts
|
|
336
|
+
var config3 = {
|
|
337
|
+
/**
|
|
338
|
+
* Require consistent filename case for all linted files.
|
|
339
|
+
*
|
|
340
|
+
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
|
341
|
+
*/
|
|
342
|
+
"unicorn/filename-case": [
|
|
343
|
+
"error",
|
|
344
|
+
{
|
|
345
|
+
case: "kebabCase"
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
/**
|
|
349
|
+
* Require using the `node:` protocol when importing Node.js built-in modules.
|
|
350
|
+
*
|
|
351
|
+
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
|
|
352
|
+
*/
|
|
353
|
+
"unicorn/prefer-node-protocol": "warn"
|
|
354
|
+
};
|
|
355
|
+
var unicorn_default = config3;
|
|
356
|
+
|
|
357
|
+
// packages/linting-tools/src/eslint/javascript/index.ts
|
|
358
|
+
var config4 = {
|
|
359
|
+
root: true,
|
|
360
|
+
overrides: [
|
|
361
|
+
{
|
|
362
|
+
files: ["*.js", "*.jsx"],
|
|
363
|
+
extends: ["plugin:@nx/javascript"],
|
|
364
|
+
plugins: ["unicorn", "import"],
|
|
365
|
+
rules: {
|
|
366
|
+
...import_default,
|
|
367
|
+
...unicorn_default,
|
|
368
|
+
...storm_default
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
]
|
|
372
|
+
};
|
|
373
|
+
var javascript_default = config4;
|
|
374
|
+
export {
|
|
375
|
+
javascript_default as default
|
|
376
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { fileURLToPath as _fileURLToPath } from 'url';
|
|
2
|
+
import _path from 'node:path';
|
|
3
|
+
import { createRequire as topLevelCreateRequire } from 'module';
|
|
4
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = _fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = _path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
// packages/linting-tools/src/eslint/jest/index.ts
|
|
9
|
+
var config = {
|
|
10
|
+
root: true,
|
|
11
|
+
overrides: [
|
|
12
|
+
{
|
|
13
|
+
files: ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
|
|
14
|
+
env: {
|
|
15
|
+
jest: true
|
|
16
|
+
},
|
|
17
|
+
rules: {}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
};
|
|
21
|
+
var jest_default = config;
|
|
22
|
+
export {
|
|
23
|
+
jest_default as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { fileURLToPath as _fileURLToPath } from 'url';
|
|
2
|
+
import _path from 'node:path';
|
|
3
|
+
import { createRequire as topLevelCreateRequire } from 'module';
|
|
4
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = _fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = _path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
// packages/linting-tools/src/eslint/constants.ts
|
|
9
|
+
var RESTRICTED_SYNTAX = [
|
|
10
|
+
{
|
|
11
|
+
// ❌ readFile(…, { encoding: … })
|
|
12
|
+
selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
|
|
13
|
+
message: `Specify encoding as last argument instead of object with encoding key`
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
// ❌ readFile(…, {})
|
|
17
|
+
selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]`,
|
|
18
|
+
message: "Specify encoding as last argument"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
// ❌ readFileSync(…).toString(…)
|
|
22
|
+
selector: `CallExpression[callee.name=readFileSync][parent.property.name=toString]`,
|
|
23
|
+
message: `toString is redundant, specify encoding as last argument`
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
// ❌ ….readFile(…, { encoding: … })
|
|
27
|
+
selector: `CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
|
|
28
|
+
message: `Specify encoding as last argument instead of object with encoding key`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
// ❌ ….readFile(…, {})
|
|
32
|
+
selector: `CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]`,
|
|
33
|
+
message: "Specify encoding as last argument"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
// ❌ Boolean(…)
|
|
37
|
+
selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
|
|
38
|
+
message: "Prefer `!!\u2026` over `Boolean(\u2026)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
// ❌ process.browser
|
|
42
|
+
selector: "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
|
|
43
|
+
message: "`process.browser` is deprecated, use `!!globalThis.window`"
|
|
44
|
+
}
|
|
45
|
+
// {
|
|
46
|
+
// // ❌ let { foo: { bar } } = baz
|
|
47
|
+
// // ✅ let { bar } = baz.foo
|
|
48
|
+
// // ✅ let { foo: { bar } } = await baz
|
|
49
|
+
// selector:
|
|
50
|
+
// 'VariableDeclarator[init.type!=AwaitExpression] > ObjectPattern[properties.length=1][properties.0.value.type=ObjectPattern]',
|
|
51
|
+
// message: 'Do not use nested destructuring.',
|
|
52
|
+
// },
|
|
53
|
+
];
|
|
54
|
+
var REACT_RESTRICTED_SYNTAX = [
|
|
55
|
+
...RESTRICTED_SYNTAX,
|
|
56
|
+
{
|
|
57
|
+
// ❌ useMemo(…, [])
|
|
58
|
+
selector: "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
|
|
59
|
+
message: "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
var CODE_BLOCK = "**/*.md{,x}/*";
|
|
63
|
+
|
|
64
|
+
// packages/linting-tools/src/eslint/json/index.ts
|
|
65
|
+
var JSONC_FILES = [
|
|
66
|
+
"tsconfig.json",
|
|
67
|
+
"tsconfig.base.json",
|
|
68
|
+
"nx.json",
|
|
69
|
+
".vscode/launch.json"
|
|
70
|
+
];
|
|
71
|
+
var config = {
|
|
72
|
+
root: true,
|
|
73
|
+
overrides: [
|
|
74
|
+
{
|
|
75
|
+
files: "*.json",
|
|
76
|
+
excludedFiles: JSONC_FILES,
|
|
77
|
+
extends: "plugin:jsonc/recommended-with-json"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
files: ["*.jsonc", ...JSONC_FILES],
|
|
81
|
+
extends: "plugin:jsonc/recommended-with-jsonc"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
files: "*.json5",
|
|
85
|
+
extends: "plugin:jsonc/recommended-with-json5"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
files: "*.json{,c,5}",
|
|
89
|
+
excludedFiles: CODE_BLOCK,
|
|
90
|
+
plugins: ["unicorn"],
|
|
91
|
+
rules: {
|
|
92
|
+
"unicorn/filename-case": "error"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
var json_default = config;
|
|
98
|
+
export {
|
|
99
|
+
json_default as default
|
|
100
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { fileURLToPath as _fileURLToPath } from 'url';
|
|
2
|
+
import _path from 'node:path';
|
|
3
|
+
import { createRequire as topLevelCreateRequire } from 'module';
|
|
4
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
5
|
+
const __filename = _fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = _path.dirname(__filename);
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined")
|
|
11
|
+
return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// packages/linting-tools/src/eslint/constants.ts
|
|
16
|
+
var RESTRICTED_SYNTAX = [
|
|
17
|
+
{
|
|
18
|
+
// ❌ readFile(…, { encoding: … })
|
|
19
|
+
selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
|
|
20
|
+
message: `Specify encoding as last argument instead of object with encoding key`
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
// ❌ readFile(…, {})
|
|
24
|
+
selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]`,
|
|
25
|
+
message: "Specify encoding as last argument"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
// ❌ readFileSync(…).toString(…)
|
|
29
|
+
selector: `CallExpression[callee.name=readFileSync][parent.property.name=toString]`,
|
|
30
|
+
message: `toString is redundant, specify encoding as last argument`
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
// ❌ ….readFile(…, { encoding: … })
|
|
34
|
+
selector: `CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
|
|
35
|
+
message: `Specify encoding as last argument instead of object with encoding key`
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
// ❌ ….readFile(…, {})
|
|
39
|
+
selector: `CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]`,
|
|
40
|
+
message: "Specify encoding as last argument"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
// ❌ Boolean(…)
|
|
44
|
+
selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
|
|
45
|
+
message: "Prefer `!!\u2026` over `Boolean(\u2026)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
// ❌ process.browser
|
|
49
|
+
selector: "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
|
|
50
|
+
message: "`process.browser` is deprecated, use `!!globalThis.window`"
|
|
51
|
+
}
|
|
52
|
+
// {
|
|
53
|
+
// // ❌ let { foo: { bar } } = baz
|
|
54
|
+
// // ✅ let { bar } = baz.foo
|
|
55
|
+
// // ✅ let { foo: { bar } } = await baz
|
|
56
|
+
// selector:
|
|
57
|
+
// 'VariableDeclarator[init.type!=AwaitExpression] > ObjectPattern[properties.length=1][properties.0.value.type=ObjectPattern]',
|
|
58
|
+
// message: 'Do not use nested destructuring.',
|
|
59
|
+
// },
|
|
60
|
+
];
|
|
61
|
+
var REACT_RESTRICTED_SYNTAX = [
|
|
62
|
+
...RESTRICTED_SYNTAX,
|
|
63
|
+
{
|
|
64
|
+
// ❌ useMemo(…, [])
|
|
65
|
+
selector: "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
|
|
66
|
+
message: "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
var JS_FILES = ["*.js?(x)", "*.mjs"];
|
|
70
|
+
|
|
71
|
+
// packages/linting-tools/src/eslint/next/index.ts
|
|
72
|
+
var babelOptions = {
|
|
73
|
+
presets: (() => {
|
|
74
|
+
try {
|
|
75
|
+
__require.resolve("next/babel");
|
|
76
|
+
return ["next/babel"];
|
|
77
|
+
} catch (e) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
})()
|
|
81
|
+
};
|
|
82
|
+
var config = {
|
|
83
|
+
root: true,
|
|
84
|
+
extends: ["plugin:@next/next/recommended"],
|
|
85
|
+
overrides: [
|
|
86
|
+
{
|
|
87
|
+
files: JS_FILES,
|
|
88
|
+
parserOptions: { babelOptions }
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
var next_default = config;
|
|
93
|
+
export {
|
|
94
|
+
next_default as default
|
|
95
|
+
};
|