@prowise/eslint-config-linting-rules 2.0.1 → 2.0.3
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/backend.js +3 -2
- package/eslint.config.js +6 -1
- package/index.js +3 -0
- package/package.json +1 -1
- package/rules/baseSettings.js +8 -8
- package/rules/plugin-import-rules.js +2 -2
- package/rules/plugin-jest-rules.js +6 -0
- package/rules/plugin-jsx-a11y-rules.js +4 -4
- package/rules/plugin-node-rules.js +7 -0
- package/rules/plugin-stylistic-rules.js +2 -2
- package/rules/plugin-typescript-rules.js +51 -65
- package/rules/test-rules.js +0 -7
package/backend.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import base from "./base.js";
|
|
1
2
|
import node from "./rules/plugin-node-rules.js";
|
|
3
|
+
import typescript from "./rules/plugin-typescript-rules.js";
|
|
2
4
|
import vitest from "./rules/plugin-vitest-rules.js";
|
|
3
|
-
import typescript from "./typescript.js";
|
|
4
5
|
|
|
5
|
-
export default [node, typescript, vitest];
|
|
6
|
+
export default [base, node, typescript, vitest];
|
package/eslint.config.js
CHANGED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@prowise/eslint-config-linting-rules","version":"2.0.
|
|
1
|
+
{"name":"@prowise/eslint-config-linting-rules","version":"2.0.3","description":"Default Prowise linting rules for npm packages.","main":"index.js","type":"module","exports":{"./typescript":"./typescript.js","./backend":"./backend.js","./front-react":"./front-react.js","./front-solid":"./front-solid.js"},"scripts":{"lint":"eslint","inspect":"eslint --inspect-config"},"repository":{"type":"git","url":"git+ssh://git@bitbucket.org/prowise/npm-linting-rules.git"},"author":"Prowise B.V.","license":"UNLICENSED","homepage":"https://bitbucket.org/prowise/npm-linting-rules#readme","dependencies":{"@stylistic/eslint-plugin":"^2.8.0","confusing-browser-globals":"^1.0.11","eslint":"^9.11.1","eslint-import-resolver-typescript":"^3.6.3","eslint-plugin-import-x":"^4.3.0","eslint-plugin-jest":"^28.8.3","eslint-plugin-jsdoc":"^50.2.4","eslint-plugin-jsx-a11y":"^6.10.0","eslint-plugin-n":"^17.10.3","eslint-plugin-prefer-arrow":"^1.2.3","eslint-plugin-react":"^7.36.1","eslint-plugin-solid":"^0.14.3","eslint-plugin-vitest":"^0.5.4","globals":"^15.9.0","typescript-eslint":"^8.7.0"},"devDependencies":{"@eslint/config-inspector":"^0.5.4"}}
|
package/rules/baseSettings.js
CHANGED
|
@@ -327,7 +327,7 @@ export default {
|
|
|
327
327
|
* Disallow declaration of variables that are not used in the code ✅
|
|
328
328
|
* https://eslint.org/docs/latest/rules/no-unused-vars.
|
|
329
329
|
*/
|
|
330
|
-
"no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: true }],
|
|
330
|
+
"no-unused-vars": ["error", { vars: "all", args: "after-used", caughtErrors: "none", ignoreRestSiblings: true }],
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
333
|
* Disallow use of variables before they are defined
|
|
@@ -384,7 +384,7 @@ export default {
|
|
|
384
384
|
* Require camel case names
|
|
385
385
|
* https://eslint.org/docs/latest/rules/camelcase.
|
|
386
386
|
*/
|
|
387
|
-
camelcase: ["error", { properties: "never", ignoreDestructuring: false }],
|
|
387
|
+
"camelcase": ["error", { properties: "never", ignoreDestructuring: false }],
|
|
388
388
|
|
|
389
389
|
/**
|
|
390
390
|
* Enforce or disallow capitalization of the first letter of a comment 🔧
|
|
@@ -439,7 +439,7 @@ export default {
|
|
|
439
439
|
* Specify the maximum cyclomatic complexity allowed in a program
|
|
440
440
|
* https://eslint.org/docs/latest/rules/complexity.
|
|
441
441
|
*/
|
|
442
|
-
complexity: ["off", 20],
|
|
442
|
+
"complexity": ["off", 20],
|
|
443
443
|
|
|
444
444
|
/**
|
|
445
445
|
* Require return statements to either always or never specify values
|
|
@@ -457,7 +457,7 @@ export default {
|
|
|
457
457
|
* Specify curly brace conventions for all control statements 🔧
|
|
458
458
|
* https://eslint.org/docs/latest/rules/curly.
|
|
459
459
|
*/
|
|
460
|
-
curly: ["error", "multi-line", "consistent"],
|
|
460
|
+
"curly": ["error", "multi-line", "consistent"],
|
|
461
461
|
|
|
462
462
|
/**
|
|
463
463
|
* Require default case in switch statements
|
|
@@ -487,7 +487,7 @@ export default {
|
|
|
487
487
|
* Require the use of === and !== 🔧
|
|
488
488
|
* https://eslint.org/docs/latest/rules/eqeqeq.
|
|
489
489
|
*/
|
|
490
|
-
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
490
|
+
"eqeqeq": ["error", "always", { null: "ignore" }],
|
|
491
491
|
|
|
492
492
|
/**
|
|
493
493
|
* Requires function names to match the name of the variable or property to which they are assigned
|
|
@@ -1311,7 +1311,7 @@ export default {
|
|
|
1311
1311
|
* Require use of the second argument for parseInt()
|
|
1312
1312
|
* https://eslint.org/docs/latest/rules/radix.
|
|
1313
1313
|
*/
|
|
1314
|
-
radix: ["error", "as-needed"],
|
|
1314
|
+
"radix": ["error", "as-needed"],
|
|
1315
1315
|
|
|
1316
1316
|
/**
|
|
1317
1317
|
* Require `await` in `async function` (note: this is a horrible rule that should never be used)
|
|
@@ -1361,7 +1361,7 @@ export default {
|
|
|
1361
1361
|
* Require or disallow strict mode directives 🔧
|
|
1362
1362
|
* https://eslint.org/docs/latest/rules/strict.
|
|
1363
1363
|
*/
|
|
1364
|
-
strict: ["error", "never"],
|
|
1364
|
+
"strict": ["error", "never"],
|
|
1365
1365
|
|
|
1366
1366
|
/**
|
|
1367
1367
|
* Require a Symbol description
|
|
@@ -1385,6 +1385,6 @@ export default {
|
|
|
1385
1385
|
* Require or disallow Yoda conditions 🔧
|
|
1386
1386
|
* https://eslint.org/docs/latest/rules/yoda.
|
|
1387
1387
|
*/
|
|
1388
|
-
yoda: "error",
|
|
1388
|
+
"yoda": "error",
|
|
1389
1389
|
},
|
|
1390
1390
|
};
|
|
@@ -204,13 +204,13 @@ export default {
|
|
|
204
204
|
* Do not allow a default import name to match a named export
|
|
205
205
|
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default.md.
|
|
206
206
|
*/
|
|
207
|
-
|
|
207
|
+
"import/no-named-as-default": "error",
|
|
208
208
|
|
|
209
209
|
/**
|
|
210
210
|
* Warn on accessing default export property names that are also named exports
|
|
211
211
|
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-named-as-default-member.md.
|
|
212
212
|
*/
|
|
213
|
-
|
|
213
|
+
"import/no-named-as-default-member": "error",
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
216
|
* Prevent importing the default as if it were named
|
|
@@ -26,6 +26,12 @@ export default {
|
|
|
26
26
|
*/
|
|
27
27
|
"jest/no-deprecated-functions": "error",
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Disallow using a callback in asynchronous tests and hooks ✅
|
|
31
|
+
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-done-callback.md
|
|
32
|
+
*/
|
|
33
|
+
"jest/no-done-callback": "warn",
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
* Disallow using exports in files containing tests ✅
|
|
31
37
|
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-export.md
|
|
@@ -27,10 +27,10 @@ export default {
|
|
|
27
27
|
"jsx-a11y/alt-text": [
|
|
28
28
|
"error",
|
|
29
29
|
{
|
|
30
|
-
elements: ["img", "object", "area", "input[type='image']"],
|
|
31
|
-
img: [],
|
|
32
|
-
object: [],
|
|
33
|
-
area: [],
|
|
30
|
+
"elements": ["img", "object", "area", "input[type='image']"],
|
|
31
|
+
"img": [],
|
|
32
|
+
"object": [],
|
|
33
|
+
"area": [],
|
|
34
34
|
"input[type='image']": [],
|
|
35
35
|
},
|
|
36
36
|
],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import nodePlugin from "eslint-plugin-n";
|
|
2
|
+
import globals from "globals";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
/*
|
|
@@ -9,6 +10,12 @@ export default {
|
|
|
9
10
|
* 💭 requires type information
|
|
10
11
|
*/
|
|
11
12
|
|
|
13
|
+
languageOptions: {
|
|
14
|
+
globals: {
|
|
15
|
+
...globals.node,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
12
19
|
plugins: {
|
|
13
20
|
node: nodePlugin,
|
|
14
21
|
},
|
|
@@ -217,7 +217,7 @@ export default {
|
|
|
217
217
|
code: 120,
|
|
218
218
|
tabWidth: 4,
|
|
219
219
|
ignoreUrls: true,
|
|
220
|
-
ignoreComments:
|
|
220
|
+
ignoreComments: true,
|
|
221
221
|
ignoreRegExpLiterals: true,
|
|
222
222
|
ignoreStrings: true,
|
|
223
223
|
ignoreTemplateLiterals: true,
|
|
@@ -424,7 +424,7 @@ export default {
|
|
|
424
424
|
* Require quotes around object literal property names 🔧
|
|
425
425
|
* https://eslint.org/docs/latest/rules/quote-props.
|
|
426
426
|
*/
|
|
427
|
-
"style/quote-props": ["error", "as-needed", { keywords: false, unnecessary: true, numbers: false }],
|
|
427
|
+
"style/quote-props": ["error", "consistent-as-needed", { keywords: false, unnecessary: true, numbers: false }],
|
|
428
428
|
|
|
429
429
|
/**
|
|
430
430
|
* Enforce spacing between object rest-spread 🔧
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-unresolved
|
|
2
|
-
import typescriptPlugin from "
|
|
3
|
-
import
|
|
2
|
+
import typescriptPlugin from "typescript-eslint";
|
|
3
|
+
import baseRules from "./baseSettings.js";
|
|
4
|
+
import importRules from "./plugin-import-rules.js";
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
/*
|
|
@@ -11,12 +12,13 @@ export default {
|
|
|
11
12
|
* 💭 requires type information
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
16
|
+
|
|
17
|
+
plugins: { "@typescript-eslint": typescriptPlugin.plugin },
|
|
15
18
|
languageOptions: {
|
|
19
|
+
parser: typescriptPlugin.parser,
|
|
16
20
|
parserOptions: {
|
|
17
21
|
project: true,
|
|
18
|
-
projectService: true,
|
|
19
|
-
tsconfigRootDir: import.meta.dirname,
|
|
20
22
|
},
|
|
21
23
|
},
|
|
22
24
|
|
|
@@ -50,7 +52,7 @@ export default {
|
|
|
50
52
|
"ts-ignore": "allow-with-description",
|
|
51
53
|
"ts-nocheck": "allow-with-description",
|
|
52
54
|
"ts-check": "allow-with-description",
|
|
53
|
-
minimumDescriptionLength: 3,
|
|
55
|
+
"minimumDescriptionLength": 3,
|
|
54
56
|
},
|
|
55
57
|
],
|
|
56
58
|
|
|
@@ -175,7 +177,7 @@ export default {
|
|
|
175
177
|
* Enforce naming conventions for everything across a codebase 💭
|
|
176
178
|
* https://typescript-eslint.io/rules/naming-convention.
|
|
177
179
|
*/
|
|
178
|
-
camelcase: "off", // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
|
|
180
|
+
"camelcase": "off", // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
|
|
179
181
|
"@typescript-eslint/naming-convention": [
|
|
180
182
|
"error",
|
|
181
183
|
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
|
|
@@ -252,10 +254,13 @@ export default {
|
|
|
252
254
|
"@typescript-eslint/no-empty-function": baseRules.rules["no-empty-function"],
|
|
253
255
|
|
|
254
256
|
/**
|
|
255
|
-
* Disallow
|
|
256
|
-
* https://typescript-eslint.io/rules/no-empty-
|
|
257
|
+
* Disallow accidentally using the "empty object" type ✅ 🔧 💡
|
|
258
|
+
* https://typescript-eslint.io/rules/no-empty-object-type.
|
|
257
259
|
*/
|
|
258
|
-
"@typescript-eslint/no-empty-
|
|
260
|
+
"@typescript-eslint/no-empty-object-type": ["error", {
|
|
261
|
+
allowInterfaces: "always",
|
|
262
|
+
allowObjectTypes: "always",
|
|
263
|
+
}],
|
|
259
264
|
|
|
260
265
|
/**
|
|
261
266
|
* Disallow the any type ✅ 🔧 💡
|
|
@@ -322,13 +327,6 @@ export default {
|
|
|
322
327
|
"no-loop-func": "off",
|
|
323
328
|
"@typescript-eslint/no-loop-func": baseRules.rules["no-loop-func"],
|
|
324
329
|
|
|
325
|
-
/**
|
|
326
|
-
* Disallow literal numbers that lose precision. ✅
|
|
327
|
-
* https://typescript-eslint.io/rules/no-loss-of-precision.
|
|
328
|
-
*/
|
|
329
|
-
"no-loss-of-precision": "off",
|
|
330
|
-
"@typescript-eslint/no-loss-of-precision": baseRules.rules["no-loss-of-precision"],
|
|
331
|
-
|
|
332
330
|
/**
|
|
333
331
|
* Disallow magic numbers.
|
|
334
332
|
* Https://typescript-eslint.io/rules/no-magic-numbers.
|
|
@@ -392,16 +390,15 @@ export default {
|
|
|
392
390
|
"@typescript-eslint/no-redundant-type-constituents": "warn",
|
|
393
391
|
|
|
394
392
|
/**
|
|
395
|
-
* Disallow invocation of require()
|
|
393
|
+
* Disallow invocation of require() ✅
|
|
396
394
|
* https://typescript-eslint.io/rules/no-require-imports.
|
|
397
395
|
*/
|
|
398
|
-
"@typescript-eslint/no-require-imports": "
|
|
396
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
399
397
|
|
|
400
398
|
/**
|
|
401
399
|
* Disallow unnecessary return await
|
|
402
400
|
* https://typescript-eslint.io/rules/return-await.
|
|
403
401
|
*/
|
|
404
|
-
"no-return-await": "off",
|
|
405
402
|
"@typescript-eslint/return-await": "warn",
|
|
406
403
|
|
|
407
404
|
/**
|
|
@@ -424,12 +421,6 @@ export default {
|
|
|
424
421
|
*/
|
|
425
422
|
"@typescript-eslint/no-this-alias": "error",
|
|
426
423
|
|
|
427
|
-
/**
|
|
428
|
-
* Disallow type aliases
|
|
429
|
-
* https://typescript-eslint.io/rules/no-type-alias.
|
|
430
|
-
*/
|
|
431
|
-
"@typescript-eslint/no-type-alias": "off",
|
|
432
|
-
|
|
433
424
|
/**
|
|
434
425
|
* Disallow unnecessary equality comparisons against boolean literals 🔒 🔧 💭
|
|
435
426
|
* https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare.
|
|
@@ -533,12 +524,6 @@ export default {
|
|
|
533
524
|
*/
|
|
534
525
|
"@typescript-eslint/no-useless-empty-export": "warn",
|
|
535
526
|
|
|
536
|
-
/**
|
|
537
|
-
* Disallow require statements except in import statements ✅
|
|
538
|
-
* https://typescript-eslint.io/rules/no-var-requires.
|
|
539
|
-
*/
|
|
540
|
-
"@typescript-eslint/no-var-requires": "error",
|
|
541
|
-
|
|
542
527
|
/**
|
|
543
528
|
* Enforce non-null assertions over explicit type casts 🔒 🔧 💭
|
|
544
529
|
* https://typescript-eslint.io/rules/non-nullable-type-assertion-style.
|
|
@@ -648,12 +633,6 @@ export default {
|
|
|
648
633
|
*/
|
|
649
634
|
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
650
635
|
|
|
651
|
-
/**
|
|
652
|
-
* Enforce using @ts-expect-error over @ts-ignore 🔒 🔧
|
|
653
|
-
* https://typescript-eslint.io/rules/prefer-ts-expect-error.
|
|
654
|
-
*/
|
|
655
|
-
"@typescript-eslint/prefer-ts-expect-error": "warn",
|
|
656
|
-
|
|
657
636
|
/**
|
|
658
637
|
* Require any function or method that returns a Promise to be marked async 🔧 💭
|
|
659
638
|
* https://typescript-eslint.io/rules/promise-function-async.
|
|
@@ -736,32 +715,39 @@ export default {
|
|
|
736
715
|
*/
|
|
737
716
|
"@typescript-eslint/unified-signatures": "error",
|
|
738
717
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
718
|
+
/**
|
|
719
|
+
* See https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/named.md# why it is turned off
|
|
720
|
+
*/
|
|
721
|
+
"import/named": "off",
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Turned off because extension *.ts can not be resolved to the required *.js extension in node!
|
|
725
|
+
*/
|
|
726
|
+
"import/no-unresolved": "off",
|
|
727
|
+
|
|
728
|
+
"import/extensions": [
|
|
729
|
+
importRules.rules["import/extensions"][0],
|
|
730
|
+
importRules.rules["import/extensions"][1],
|
|
731
|
+
{
|
|
732
|
+
...importRules.rules["import/extensions"][2],
|
|
733
|
+
ts: "never",
|
|
734
|
+
tsx: "never",
|
|
735
|
+
},
|
|
736
|
+
],
|
|
737
|
+
|
|
738
|
+
"import/no-extraneous-dependencies": [
|
|
739
|
+
importRules.rules["import/no-extraneous-dependencies"][0],
|
|
740
|
+
{
|
|
741
|
+
...importRules.rules["import/no-extraneous-dependencies"][1],
|
|
742
|
+
devDependencies: importRules.rules["import/no-extraneous-dependencies"][1].devDependencies.reduce(
|
|
743
|
+
(result, devDep) => {
|
|
744
|
+
const toAppend = [devDep];
|
|
745
|
+
const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, "ts$1");
|
|
746
|
+
if (devDepWithTs !== devDep) toAppend.push(devDepWithTs);
|
|
747
|
+
return [...result, ...toAppend];
|
|
748
|
+
},
|
|
749
|
+
),
|
|
750
|
+
},
|
|
751
|
+
],
|
|
766
752
|
},
|
|
767
753
|
};
|
package/rules/test-rules.js
CHANGED
|
@@ -72,13 +72,6 @@ const rules = {
|
|
|
72
72
|
*/
|
|
73
73
|
"no-disabled-tests": "warn",
|
|
74
74
|
|
|
75
|
-
/**
|
|
76
|
-
* Disallow using a callback in asynchronous tests and hooks ✅
|
|
77
|
-
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-done-callback.md
|
|
78
|
-
* Vitest: https://github.com/veritem/eslint-plugin-vitest/blob/main/docs/rules/no-done-callback.md
|
|
79
|
-
*/
|
|
80
|
-
"no-done-callback": "warn",
|
|
81
|
-
|
|
82
75
|
/**
|
|
83
76
|
* Disallow duplicate setup and teardown hooks
|
|
84
77
|
* Jest: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-duplicate-hooks.md
|