@enormora/eslint-config-base 0.0.36 → 0.0.38
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/constants.js +3 -2
- package/constants.js.map +1 -0
- package/package.json +11 -4
- package/presets/base/base-shared.js +49 -69
- package/presets/base/base-shared.js.map +1 -0
- package/presets/base/base.js +17 -28
- package/presets/base/base.js.map +1 -0
- package/presets/base/cspell-config.js +18 -1
- package/presets/base/cspell-config.js.map +1 -0
- package/presets/base/dprint-config.js +1 -5
- package/presets/base/dprint-config.js.map +1 -0
- package/presets/base/dprint-formatters.js +1 -3
- package/presets/base/dprint-formatters.js.map +1 -0
- package/presets/base/markdown-lint-rules.js +1 -4
- package/presets/base/markdown-lint-rules.js.map +1 -0
- package/presets/base/markdown.js +8 -13
- package/presets/base/markdown.js.map +1 -0
- package/presets/base/package-json.js +112 -0
- package/presets/base/package-json.js.map +1 -0
- package/readme.md +14 -0
- package/rule-sets/best-practices.js +113 -32
- package/rule-sets/best-practices.js.map +1 -0
- package/rule-sets/restricted-syntax.js +25 -22
- package/rule-sets/restricted-syntax.js.map +1 -0
- package/rule-sets/stylistic.js +33 -36
- package/rule-sets/stylistic.js.map +1 -0
- package/sbom.cdx.json +79 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../../../../configs/presets/base/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAExD,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElF,kGAAkG;AAClG,qGAAqG;AACrG,mGAAmG;AACnG,qGAAqG;AACrG,iGAAiG;AACjG,MAAM,0BAA0B,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC;AAC/D,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC;IAC3C,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;AAC1E,CAAC;AACD,MAAM,6BAA6B,GAAG;IAClC,KAAK,EAAE;QACH,QAAQ,EAAE;YACN,IAAI,EAAE,0BAA0B,CAAC,IAAI;YACrC,MAAM,CAAC,OAAyB;gBAC5B,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACzD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YACnC,CAAC;SACJ;KACJ;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,KAAK,EAAE,CAAE,SAAS,CAAE;IACpB,OAAO,EAAE;QACL,GAAG,mBAAmB;QACtB,iBAAiB,EAAE,6BAA6B;KACnD;IACD,8FAA8F;IAC9F,8EAA8E;IAC9E,6FAA6F;IAC7F,6FAA6F;IAC7F,gCAAgC;IAChC,QAAQ,EAAE,qBAAqB;IAC/B,QAAQ,EAAE,cAAc;IACxB,KAAK,EAAE;QACH,0BAA0B,EAAE;YACxB,OAAO;YACP;gBACI,MAAM,EAAE,oBAAoB;gBAC5B,WAAW,EAAE;oBACT,UAAU,EAAE,sBAAsB;oBAClC,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,gBAAgB;iBACzB;aACJ;SACJ;QAED,GAAG,iBAAiB;KACvB;CACwB,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import jsonSchemaValidatorPlugin from 'eslint-plugin-json-schema-validator';
|
|
2
|
+
import packageJsonPlugin from 'eslint-plugin-package-json';
|
|
3
|
+
import * as jsoncParser from 'jsonc-eslint-parser';
|
|
4
|
+
export const packageJsonConfig = {
|
|
5
|
+
files: ['**/package.json'],
|
|
6
|
+
languageOptions: { parser: jsoncParser },
|
|
7
|
+
plugins: {
|
|
8
|
+
'package-json': packageJsonPlugin,
|
|
9
|
+
'json-schema-validator': jsonSchemaValidatorPlugin
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'package-json/no-empty-fields': 'error',
|
|
13
|
+
'package-json/no-redundant-files': 'error',
|
|
14
|
+
'package-json/no-redundant-publishConfig': 'error',
|
|
15
|
+
'package-json/repository-shorthand': 'error',
|
|
16
|
+
'package-json/restrict-private-properties': 'error',
|
|
17
|
+
'package-json/scripts-name-casing': 'error',
|
|
18
|
+
'package-json/sort-collections': 'error',
|
|
19
|
+
'package-json/unique-dependencies': 'error',
|
|
20
|
+
'package-json/valid-author': 'error',
|
|
21
|
+
'package-json/valid-bin': 'error',
|
|
22
|
+
'package-json/valid-browser': 'error',
|
|
23
|
+
'package-json/valid-bugs': 'error',
|
|
24
|
+
'package-json/valid-bundleDependencies': 'error',
|
|
25
|
+
'package-json/valid-config': 'error',
|
|
26
|
+
'package-json/valid-contributors': 'error',
|
|
27
|
+
'package-json/valid-cpu': 'error',
|
|
28
|
+
'package-json/valid-dependencies': 'error',
|
|
29
|
+
'package-json/valid-description': 'error',
|
|
30
|
+
'package-json/valid-devDependencies': 'error',
|
|
31
|
+
'package-json/valid-devEngines': 'error',
|
|
32
|
+
'package-json/valid-directories': 'error',
|
|
33
|
+
'package-json/valid-engines': 'error',
|
|
34
|
+
'package-json/valid-exports': 'error',
|
|
35
|
+
'package-json/valid-files': 'error',
|
|
36
|
+
'package-json/valid-funding': 'error',
|
|
37
|
+
'package-json/valid-gypfile': 'error',
|
|
38
|
+
'package-json/valid-homepage': 'error',
|
|
39
|
+
'package-json/valid-keywords': 'error',
|
|
40
|
+
'package-json/valid-libc': 'error',
|
|
41
|
+
'package-json/valid-license': 'error',
|
|
42
|
+
'package-json/valid-main': 'error',
|
|
43
|
+
'package-json/valid-man': 'error',
|
|
44
|
+
'package-json/valid-module': 'error',
|
|
45
|
+
'package-json/valid-name': 'error',
|
|
46
|
+
'package-json/valid-optionalDependencies': 'error',
|
|
47
|
+
'package-json/valid-os': 'error',
|
|
48
|
+
'package-json/valid-packageManager': 'error',
|
|
49
|
+
'package-json/valid-peerDependencies': 'error',
|
|
50
|
+
'package-json/valid-peerDependenciesMeta': 'error',
|
|
51
|
+
'package-json/valid-peerDependenciesMeta-relationship': 'error',
|
|
52
|
+
'package-json/valid-private': 'error',
|
|
53
|
+
'package-json/valid-publishConfig': 'error',
|
|
54
|
+
'package-json/valid-repository': 'error',
|
|
55
|
+
'package-json/valid-repository-directory': 'error',
|
|
56
|
+
'package-json/valid-scripts': 'error',
|
|
57
|
+
'package-json/valid-sideEffects': 'error',
|
|
58
|
+
'package-json/valid-type': 'error',
|
|
59
|
+
'package-json/valid-version': 'error',
|
|
60
|
+
'package-json/valid-workspaces': 'error',
|
|
61
|
+
// Too opinionated for a base preset — consumers can opt in.
|
|
62
|
+
'package-json/bin-name-casing': 'off',
|
|
63
|
+
'package-json/exports-subpaths-style': 'off',
|
|
64
|
+
'package-json/no-local-dependencies': 'off',
|
|
65
|
+
'package-json/order-properties': 'off',
|
|
66
|
+
'package-json/require-attribution': 'off',
|
|
67
|
+
'package-json/require-author': 'off',
|
|
68
|
+
'package-json/require-bin': 'off',
|
|
69
|
+
'package-json/require-browser': 'off',
|
|
70
|
+
'package-json/require-bugs': 'off',
|
|
71
|
+
'package-json/require-bundleDependencies': 'off',
|
|
72
|
+
'package-json/require-config': 'off',
|
|
73
|
+
'package-json/require-contributors': 'off',
|
|
74
|
+
'package-json/require-cpu': 'off',
|
|
75
|
+
'package-json/require-dependencies': 'off',
|
|
76
|
+
'package-json/require-description': 'off',
|
|
77
|
+
'package-json/require-devDependencies': 'off',
|
|
78
|
+
'package-json/require-devEngines': 'off',
|
|
79
|
+
'package-json/require-directories': 'off',
|
|
80
|
+
'package-json/require-engines': 'off',
|
|
81
|
+
'package-json/require-exports': 'off',
|
|
82
|
+
'package-json/require-files': 'off',
|
|
83
|
+
'package-json/require-funding': 'off',
|
|
84
|
+
'package-json/require-gypfile': 'off',
|
|
85
|
+
'package-json/require-homepage': 'off',
|
|
86
|
+
'package-json/require-keywords': 'off',
|
|
87
|
+
'package-json/require-libc': 'off',
|
|
88
|
+
'package-json/require-license': 'off',
|
|
89
|
+
'package-json/require-main': 'off',
|
|
90
|
+
'package-json/require-man': 'off',
|
|
91
|
+
'package-json/require-module': 'off',
|
|
92
|
+
'package-json/require-name': 'off',
|
|
93
|
+
'package-json/require-optionalDependencies': 'off',
|
|
94
|
+
'package-json/require-os': 'off',
|
|
95
|
+
'package-json/require-packageManager': 'off',
|
|
96
|
+
'package-json/require-peerDependencies': 'off',
|
|
97
|
+
'package-json/require-peerDependenciesMeta': 'off',
|
|
98
|
+
'package-json/require-private': 'off',
|
|
99
|
+
'package-json/require-publishConfig': 'off',
|
|
100
|
+
'package-json/require-repository': 'off',
|
|
101
|
+
'package-json/require-scripts': 'off',
|
|
102
|
+
'package-json/require-sideEffects': 'off',
|
|
103
|
+
'package-json/require-type': 'off',
|
|
104
|
+
'package-json/require-types': 'off',
|
|
105
|
+
'package-json/require-version': 'off',
|
|
106
|
+
'package-json/restrict-dependency-ranges': 'off',
|
|
107
|
+
'package-json/restrict-top-level-properties': 'off',
|
|
108
|
+
'package-json/specify-peers-locally': 'off',
|
|
109
|
+
'json-schema-validator/no-invalid': 'error'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../../../configs/presets/base/package-json.ts"],"names":[],"mappings":"AACA,OAAO,yBAAyB,MAAM,qCAAqC,CAAC;AAC5E,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,KAAK,EAAE,C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EAAE,KAAK;QACrC,oCAAoC,EAAE,KAAK;QAC3C,iCAAiC,EAAE,KAAK;QACxC,8BAA8B,EAAE,KAAK;QACrC,kCAAkC,EAAE,KAAK;QACzC,2BAA2B,EAAE,KAAK;QAClC,4BAA4B,EAAE,KAAK;QACnC,8BAA8B,EAAE,KAAK;QACrC,yCAAyC,EAAE,KAAK;QAChD,4CAA4C,EAAE,KAAK;QACnD,oCAAoC,EAAE,KAAK;QAE3C,kCAAkC,EAAE,OAAO;KAC9C;CACwB,CAAC"}
|
package/readme.md
CHANGED
|
@@ -12,6 +12,19 @@ formatter step. The dprint configuration ships inline with this preset, so no `d
|
|
|
12
12
|
project root. If you'd rather use prettier, use [`@enormora/eslint-config-base-with-prettier`](../base-with-prettier/base-with-prettier.md)
|
|
13
13
|
instead — it is an alternative base preset and is not meant to be combined with this one.
|
|
14
14
|
|
|
15
|
+
`package.json` files get dedicated semantic linting through two plugins, parsed by
|
|
16
|
+
[`jsonc-eslint-parser`](https://github.com/ota-meshi/jsonc-eslint-parser):
|
|
17
|
+
|
|
18
|
+
- **[`eslint-plugin-package-json`](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json)** (`package-json/*`)
|
|
19
|
+
— validates the shape of every field that is present (author, repository, engines, exports, scripts, peers, etc.),
|
|
20
|
+
catches duplicate dependencies across `dependencies`/`devDependencies`/`peerDependencies`, sorts collections, and
|
|
21
|
+
enforces `repository` shorthand. The opinionated `require-*` rules (which would demand every package declare e.g.
|
|
22
|
+
`funding` or `cpu`) and `order-properties` are off; opt in by overriding individual rules in your own config.
|
|
23
|
+
- **[`eslint-plugin-json-schema-validator`](https://github.com/ota-meshi/eslint-plugin-json-schema-validator)**
|
|
24
|
+
(`json-schema-validator/no-invalid`) — validates the file against [schemastore.org](https://www.schemastore.org/)'s
|
|
25
|
+
`package.json` schema, catching invalid values that the field-shape rules above can't see (e.g. unknown
|
|
26
|
+
`engines.node` operators, malformed `exports` conditions).
|
|
27
|
+
|
|
15
28
|
Markdown files additionally get semantic linting through three language-aware plugins, all riding on
|
|
16
29
|
[`@eslint/markdown`](https://github.com/eslint/markdown)'s `language: "markdown/commonmark"`:
|
|
17
30
|
|
|
@@ -79,6 +92,7 @@ The remaining blocks each enable one formatter or linter scoped to a default fil
|
|
|
79
92
|
| :------------ | :----------------------------------------- | :------------------------------------------------------------------------------------- |
|
|
80
93
|
| JavaScript/TS | `**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue}` | `dprint/typescript` |
|
|
81
94
|
| JSON | `**/*.json` | `dprint/json` |
|
|
95
|
+
| package.json | `**/package.json` | `package-json/*`, `json-schema-validator/no-invalid` |
|
|
82
96
|
| Markdown | `**/*.md` | `dprint-markdown/markdown`, `markdown/*`, `markdown-links/*`, `markdown-preferences/*` |
|
|
83
97
|
| YAML | `**/*.{yml,yaml}` | `dprint/yaml` |
|
|
84
98
|
| TOML | `**/*.toml` | `dprint/toml` |
|
|
@@ -1,39 +1,33 @@
|
|
|
1
1
|
import arrayFunctionPlugin from 'eslint-plugin-array-func';
|
|
2
2
|
import noBarrelFiles from 'eslint-plugin-no-barrel-files';
|
|
3
3
|
import promisePlugin from 'eslint-plugin-promise';
|
|
4
|
+
import * as regexpPlugin from 'eslint-plugin-regexp';
|
|
4
5
|
import sonarjsPlugin from 'eslint-plugin-sonarjs';
|
|
5
6
|
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
6
|
-
|
|
7
7
|
const maxSwitchCases = 6;
|
|
8
|
-
|
|
9
8
|
function isSonarjsRuleDeprecated(sonarjsRule) {
|
|
10
|
-
return sonarjsRule.meta?.deprecated
|
|
9
|
+
return Boolean(sonarjsRule.meta?.deprecated);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const nonDeprecatedSonarjsRecommendedRules = Object.fromEntries(
|
|
25
|
-
Object.entries(sonarjsPlugin.configs.recommended.rules).filter(([ sonarjsRuleName ]) => {
|
|
26
|
-
return nonDeprecatedSonarjsRuleNames.has(sonarjsRuleName);
|
|
27
|
-
})
|
|
28
|
-
);
|
|
29
|
-
|
|
11
|
+
const nonDeprecatedSonarjsRuleNames = new Set(Object
|
|
12
|
+
.entries(sonarjsPlugin.rules)
|
|
13
|
+
.filter(function removeDeprecated([, sonarjsRule]) {
|
|
14
|
+
return !isSonarjsRuleDeprecated(sonarjsRule);
|
|
15
|
+
})
|
|
16
|
+
.map(function toQualifiedRuleName([sonarjsRuleName]) {
|
|
17
|
+
return `sonarjs/${sonarjsRuleName}`;
|
|
18
|
+
}));
|
|
19
|
+
const sonarjsRecommendedRules = sonarjsPlugin.configs.recommended.rules ?? {};
|
|
20
|
+
const nonDeprecatedSonarjsRecommendedRules = Object.fromEntries(Object.entries(sonarjsRecommendedRules).filter(function keepNonDeprecated([sonarjsRuleName]) {
|
|
21
|
+
return nonDeprecatedSonarjsRuleNames.has(sonarjsRuleName);
|
|
22
|
+
}));
|
|
30
23
|
export const bestPracticesRuleSet = {
|
|
31
24
|
plugins: {
|
|
32
25
|
unicorn: unicornPlugin,
|
|
33
26
|
promise: promisePlugin,
|
|
34
27
|
'array-func': arrayFunctionPlugin,
|
|
35
28
|
sonarjs: sonarjsPlugin,
|
|
36
|
-
'no-barrel-files': noBarrelFiles
|
|
29
|
+
'no-barrel-files': noBarrelFiles,
|
|
30
|
+
regexp: regexpPlugin
|
|
37
31
|
},
|
|
38
32
|
settings: {},
|
|
39
33
|
rules: {
|
|
@@ -48,7 +42,7 @@ export const bestPracticesRuleSet = {
|
|
|
48
42
|
'unicorn/no-null': 'off',
|
|
49
43
|
'unicorn/catch-error-name': 'error',
|
|
50
44
|
'unicorn/consistent-function-scoping': 'off',
|
|
51
|
-
'unicorn/custom-error-definition': '
|
|
45
|
+
'unicorn/custom-error-definition': 'error',
|
|
52
46
|
'unicorn/error-message': 'error',
|
|
53
47
|
'unicorn/escape-case': 'error',
|
|
54
48
|
'unicorn/expiring-todo-comments': 'error',
|
|
@@ -67,7 +61,7 @@ export const bestPracticesRuleSet = {
|
|
|
67
61
|
'unicorn/no-new-buffer': 'error',
|
|
68
62
|
'unicorn/no-process-exit': 'error',
|
|
69
63
|
'unicorn/no-unreadable-array-destructuring': 'error',
|
|
70
|
-
'unicorn/no-unused-properties': '
|
|
64
|
+
'unicorn/no-unused-properties': 'error',
|
|
71
65
|
'unicorn/no-zero-fractions': 'error',
|
|
72
66
|
'unicorn/number-literal-case': 'error',
|
|
73
67
|
'unicorn/prefer-add-event-listener': 'error',
|
|
@@ -183,19 +177,16 @@ export const bestPracticesRuleSet = {
|
|
|
183
177
|
'unicorn/prefer-response-static-json': 'error',
|
|
184
178
|
'unicorn/isolated-functions': 'off',
|
|
185
179
|
'unicorn/switch-case-break-position': 'error',
|
|
186
|
-
|
|
187
180
|
'array-func/from-map': 'error',
|
|
188
181
|
'array-func/no-unnecessary-this-arg': 'error',
|
|
189
182
|
'array-func/prefer-array-from': 'error',
|
|
190
183
|
'array-func/avoid-reverse': 'error',
|
|
191
184
|
'array-func/prefer-flat-map': 'error',
|
|
192
185
|
'array-func/prefer-flat': 'error',
|
|
193
|
-
|
|
194
186
|
...nonDeprecatedSonarjsRecommendedRules,
|
|
195
|
-
|
|
196
187
|
'sonarjs/cognitive-complexity': 'off',
|
|
197
188
|
'sonarjs/elseif-without-else': 'off',
|
|
198
|
-
'sonarjs/max-switch-cases': [
|
|
189
|
+
'sonarjs/max-switch-cases': ['error', maxSwitchCases],
|
|
199
190
|
'sonarjs/no-all-duplicated-branches': 'error',
|
|
200
191
|
'sonarjs/no-collapsible-if': 'error',
|
|
201
192
|
'sonarjs/no-collection-size-mischeck': 'error',
|
|
@@ -226,7 +217,9 @@ export const bestPracticesRuleSet = {
|
|
|
226
217
|
'sonarjs/prefer-object-literal': 'error',
|
|
227
218
|
'sonarjs/prefer-single-boolean-return': 'error',
|
|
228
219
|
'sonarjs/prefer-while': 'error',
|
|
229
|
-
|
|
220
|
+
// regexp/no-super-linear-backtracking subsumes this with a sound NFA-based analysis
|
|
221
|
+
// (sonarjs is heuristic); see the regexp/* block below.
|
|
222
|
+
'sonarjs/slow-regex': 'off',
|
|
230
223
|
'promise/avoid-new': 'off',
|
|
231
224
|
'promise/no-nesting': 'error',
|
|
232
225
|
'promise/no-promise-in-callback': 'error',
|
|
@@ -245,11 +238,99 @@ export const bestPracticesRuleSet = {
|
|
|
245
238
|
'promise/no-new-statics': 'error',
|
|
246
239
|
'promise/no-return-in-finally': 'error',
|
|
247
240
|
'promise/valid-params': 'error',
|
|
248
|
-
'promise/prefer-await-to-then': [
|
|
241
|
+
'promise/prefer-await-to-then': ['error', { strict: true }],
|
|
249
242
|
'promise/no-multiple-resolved': 'error',
|
|
250
243
|
'promise/spec-only': 'error',
|
|
251
244
|
'promise/prefer-catch': 'error',
|
|
252
|
-
|
|
253
|
-
|
|
245
|
+
'no-barrel-files/no-barrel-files': 'error',
|
|
246
|
+
// eslint-plugin-regexp — purely additive on top of core / unicorn / sonarjs regex coverage.
|
|
247
|
+
// Rules with a working equivalent already in core, unicorn, or sonarjs are turned off here so
|
|
248
|
+
// each diagnostic is reported by exactly one rule. The only swap is regexp/no-super-linear-backtracking
|
|
249
|
+
// taking over from the (off-above) sonarjs/slow-regex.
|
|
250
|
+
'regexp/confusing-quantifier': 'error',
|
|
251
|
+
'regexp/control-character-escape': 'error',
|
|
252
|
+
'regexp/match-any': 'error',
|
|
253
|
+
'regexp/negation': 'error',
|
|
254
|
+
'regexp/no-contradiction-with-assertion': 'error',
|
|
255
|
+
'regexp/no-dupe-disjunctions': 'error',
|
|
256
|
+
'regexp/no-empty-capturing-group': 'error',
|
|
257
|
+
'regexp/no-empty-group': 'error',
|
|
258
|
+
'regexp/no-empty-lookarounds-assertion': 'error',
|
|
259
|
+
'regexp/no-empty-string-literal': 'error',
|
|
260
|
+
'regexp/no-escape-backspace': 'error',
|
|
261
|
+
'regexp/no-extra-lookaround-assertions': 'error',
|
|
262
|
+
'regexp/no-invisible-character': 'error',
|
|
263
|
+
'regexp/no-lazy-ends': 'error',
|
|
264
|
+
'regexp/no-legacy-features': 'error',
|
|
265
|
+
'regexp/no-misleading-capturing-group': 'error',
|
|
266
|
+
'regexp/no-missing-g-flag': 'error',
|
|
267
|
+
'regexp/no-non-standard-flag': 'error',
|
|
268
|
+
'regexp/no-obscure-range': 'error',
|
|
269
|
+
'regexp/no-octal': 'error',
|
|
270
|
+
'regexp/no-optional-assertion': 'error',
|
|
271
|
+
'regexp/no-potentially-useless-backreference': 'error',
|
|
272
|
+
'regexp/no-standalone-backslash': 'error',
|
|
273
|
+
'regexp/no-super-linear-backtracking': 'error',
|
|
274
|
+
'regexp/no-super-linear-move': 'error',
|
|
275
|
+
'regexp/no-trivially-nested-assertion': 'error',
|
|
276
|
+
'regexp/no-trivially-nested-quantifier': 'error',
|
|
277
|
+
'regexp/no-unused-capturing-group': 'error',
|
|
278
|
+
'regexp/no-useless-assertions': 'error',
|
|
279
|
+
'regexp/no-useless-character-class': 'error',
|
|
280
|
+
'regexp/no-useless-dollar-replacements': 'error',
|
|
281
|
+
'regexp/no-useless-flag': 'error',
|
|
282
|
+
'regexp/no-useless-lazy': 'error',
|
|
283
|
+
'regexp/no-useless-non-capturing-group': 'error',
|
|
284
|
+
'regexp/no-useless-quantifier': 'error',
|
|
285
|
+
'regexp/no-useless-range': 'error',
|
|
286
|
+
'regexp/no-useless-set-operand': 'error',
|
|
287
|
+
'regexp/no-useless-string-literal': 'error',
|
|
288
|
+
'regexp/no-useless-two-nums-quantifier': 'error',
|
|
289
|
+
'regexp/no-zero-quantifier': 'error',
|
|
290
|
+
'regexp/optimal-lookaround-quantifier': 'error',
|
|
291
|
+
'regexp/optimal-quantifier-concatenation': 'error',
|
|
292
|
+
'regexp/prefer-escape-replacement-dollar-char': 'error',
|
|
293
|
+
'regexp/prefer-named-backreference': 'error',
|
|
294
|
+
'regexp/prefer-named-replacement': 'error',
|
|
295
|
+
'regexp/prefer-result-array-groups': 'error',
|
|
296
|
+
'regexp/prefer-set-operation': 'error',
|
|
297
|
+
'regexp/prefer-unicode-codepoint-escapes': 'error',
|
|
298
|
+
'regexp/simplify-set-operations': 'error',
|
|
299
|
+
// Overlap with existing rules — keep the existing rule as single source of truth.
|
|
300
|
+
'regexp/no-control-character': 'off', // core no-control-regex
|
|
301
|
+
'regexp/no-dupe-characters-character-class': 'off', // sonarjs/duplicates-in-character-class
|
|
302
|
+
'regexp/no-empty-alternative': 'off', // sonarjs/no-empty-alternatives
|
|
303
|
+
'regexp/no-empty-character-class': 'off', // core no-empty-character-class
|
|
304
|
+
'regexp/no-invalid-regexp': 'off', // core no-invalid-regexp
|
|
305
|
+
'regexp/no-misleading-unicode-character': 'off', // core no-misleading-character-class
|
|
306
|
+
'regexp/no-useless-backreference': 'off', // core no-useless-backreference
|
|
307
|
+
'regexp/no-useless-escape': 'off', // core no-useless-escape
|
|
308
|
+
'regexp/prefer-character-class': 'off', // unicorn/better-regex + sonarjs/concise-regex
|
|
309
|
+
'regexp/prefer-d': 'off', // unicorn/better-regex
|
|
310
|
+
'regexp/prefer-named-capture-group': 'off', // core prefer-named-capture-group
|
|
311
|
+
'regexp/prefer-plus-quantifier': 'off', // unicorn/better-regex
|
|
312
|
+
'regexp/prefer-question-quantifier': 'off', // unicorn/better-regex
|
|
313
|
+
'regexp/prefer-regexp-exec': 'off', // @typescript-eslint/prefer-regexp-exec
|
|
314
|
+
'regexp/prefer-regexp-test': 'off', // unicorn/prefer-regexp-test
|
|
315
|
+
'regexp/prefer-star-quantifier': 'off', // unicorn/better-regex
|
|
316
|
+
'regexp/prefer-w': 'off', // unicorn/better-regex
|
|
317
|
+
'regexp/require-unicode-regexp': 'off', // matches core require-unicode-regexp (off)
|
|
318
|
+
'regexp/strict': 'off', // unicorn/better-regex
|
|
319
|
+
// Pure style preferences outside the project's scope.
|
|
320
|
+
'regexp/grapheme-string-literal': 'off',
|
|
321
|
+
'regexp/hexadecimal-escape': 'off',
|
|
322
|
+
'regexp/letter-case': 'off',
|
|
323
|
+
'regexp/prefer-lookaround': 'off',
|
|
324
|
+
'regexp/prefer-predefined-assertion': 'off',
|
|
325
|
+
'regexp/prefer-quantifier': 'off',
|
|
326
|
+
'regexp/prefer-range': 'off',
|
|
327
|
+
'regexp/require-unicode-sets-regexp': 'off',
|
|
328
|
+
'regexp/sort-alternatives': 'off',
|
|
329
|
+
'regexp/sort-character-class-elements': 'off',
|
|
330
|
+
'regexp/sort-flags': 'off',
|
|
331
|
+
'regexp/unicode-escape': 'off',
|
|
332
|
+
'regexp/unicode-property': 'off',
|
|
333
|
+
'regexp/use-ignore-case': 'off'
|
|
254
334
|
}
|
|
255
335
|
};
|
|
336
|
+
//# sourceMappingURL=best-practices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"best-practices.js","sourceRoot":"","sources":["../../../../configs/rule-sets/best-practices.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AACrD,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAElD,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,SAAS,uBAAuB,CAAC,WAA4B;IACzD,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,6BAA6B,GAAG,IAAI,GAAG,CACzC,MAAM;KACD,OAAO,CAAC,aAAa,CAAC,KAAwC,CAAC;KAC/D,MAAM,CAAC,SAAS,gBAAgB,CAAC,CAAE,AAAD,EAAG,WAAW,CAAE;IAC/C,OAAO,CAAC,uBAAuB,CAAC,WAAW,CAAC,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AClC,oBAAoB,EAAE,KAAK;QAC3B,0BAA0B,EAAE,KAAK;QACjC,oCAAoC,EAAE,KAAK;QAC3C,0BAA0B,EAAE,KAAK;QACjC,qBAAqB,EAAE,KAAK;QAC5B,oCAAoC,EAAE,KAAK;QAC3C,0BAA0B,EAAE,KAAK;QACjC,sCAAsC,EAAE,KAAK;QAC7C,mBAAmB,EAAE,KAAK;QAC1B,uBAAuB,EAAE,KAAK;QAC9B,yBAAyB,EAAE,KAAK;QAChC,wBAAwB,EAAE,KAAK;KAClC;CACJ,CAAC"}
|
|
@@ -1,49 +1,52 @@
|
|
|
1
1
|
import { builtinRules } from 'eslint/use-at-your-own-risk';
|
|
2
|
-
|
|
3
2
|
const noRestrictedSyntaxRule = builtinRules.get('no-restricted-syntax');
|
|
4
|
-
|
|
5
3
|
export function createRestrictedSyntaxPlugin(ruleNames) {
|
|
6
4
|
return {
|
|
7
|
-
rules: Object.fromEntries(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})
|
|
11
|
-
)
|
|
5
|
+
rules: Object.fromEntries(ruleNames.map(function toRuleEntry(ruleName) {
|
|
6
|
+
return [ruleName, noRestrictedSyntaxRule];
|
|
7
|
+
}))
|
|
12
8
|
};
|
|
13
9
|
}
|
|
14
|
-
|
|
15
10
|
const defaultAllowedSuperClassNamePattern = '/Error$/';
|
|
16
11
|
const defaultClassDeclarationMessage = 'Class declarations are not allowed except for extending errors.';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const defaultNoClassDeclarationOptions = {
|
|
13
|
+
allowedSuperClassNamePattern: defaultAllowedSuperClassNamePattern,
|
|
14
|
+
message: defaultClassDeclarationMessage
|
|
15
|
+
};
|
|
16
|
+
export function createNoClassDeclarationRestriction(options = defaultNoClassDeclarationOptions) {
|
|
17
|
+
const { allowedSuperClassNamePattern, message } = options;
|
|
22
18
|
return {
|
|
23
19
|
selector: `ClassDeclaration[superClass.name!=${allowedSuperClassNamePattern}]`,
|
|
24
20
|
message
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
export const noClassDeclarationRestriction = createNoClassDeclarationRestriction();
|
|
29
|
-
|
|
30
24
|
export const noSwitchStatementRestriction = {
|
|
31
25
|
selector: 'SwitchStatement',
|
|
32
26
|
message: 'Use pattern matching instead.'
|
|
33
27
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
28
|
+
const emptyFunctionBodySelector = ['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression']
|
|
29
|
+
.map(function toEmptyBodySelector(kind) {
|
|
30
|
+
return `${kind} > BlockStatement[body.length=0]`;
|
|
31
|
+
})
|
|
39
32
|
.join(', ');
|
|
40
|
-
|
|
41
33
|
export const noEmptyFunctionBodyRestriction = {
|
|
42
34
|
selector: emptyFunctionBodySelector,
|
|
43
35
|
message: 'Empty function bodies are not allowed, even with a comment.'
|
|
44
36
|
};
|
|
45
|
-
|
|
46
37
|
export const noInOperatorRestriction = {
|
|
47
38
|
selector: 'BinaryExpression[operator="in"]',
|
|
48
39
|
message: 'The `in` operator is not allowed. Use `Object.hasOwn` instead.'
|
|
49
40
|
};
|
|
41
|
+
const lexicalBindingReferences = [
|
|
42
|
+
'ThisExpression',
|
|
43
|
+
'Super',
|
|
44
|
+
'MetaProperty[meta.name="new"]',
|
|
45
|
+
'Identifier[name="arguments"]'
|
|
46
|
+
]
|
|
47
|
+
.join(', ');
|
|
48
|
+
export const noUnnecessaryArrowFunctionRestriction = {
|
|
49
|
+
selector: `ArrowFunctionExpression:not(:has(${lexicalBindingReferences}))`,
|
|
50
|
+
message: 'Arrow functions are only allowed when they use lexical `this`, `super`, `new.target`, or `arguments`.'
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=restricted-syntax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restricted-syntax.js","sourceRoot":"","sources":["../../../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