eslint-plugin-constructors 1.4.1 → 1.4.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/README.md +16 -2
- package/package.json +6 -8
- package/src/index.js +3 -9
- package/src/rules/no-explicit-return.js +1 -1
- package/src/rules/require-error-subclass-name.js +1 -1
- package/src/rules/require-new.js +1 -1
- package/src/utils.js +6 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<img alt="[Latest Build]" src="https://img.shields.io/npm/v/eslint-plugin-constructors?logo=icinga&style=for-the-badge&label=Latest%20Build&color=32fcee"></a>
|
|
7
7
|
<a href="#license">
|
|
8
8
|
<img alt="[License: MIT]" src="https://img.shields.io/badge/License-MIT-f1f20a.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
9
|
-
<a>
|
|
9
|
+
<a target="_blank" href="https://getnpmstats.com/?package=eslint-plugin-constructors&range=last-year&interval=monthly">
|
|
10
10
|
<img src="https://img.shields.io/npm/dm/eslint-plugin-constructors?style=for-the-badge&logo=npm&color=black"></a>
|
|
11
11
|
<a target="_blank" href="https://eslint.org/">
|
|
12
12
|
<img alt="[Requires ESLint >=9.0.0]" src="https://img.shields.io/badge/Requires-ESLint_%3E%3D9.0.0-4B32C3?style=for-the-badge&logo=eslint"></a>
|
|
@@ -52,7 +52,7 @@ export default [
|
|
|
52
52
|
]
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
Available bundles: `recommended`, `problem`
|
|
55
|
+
Available bundles: `recommended`, `problem` (deterministic bugs only)
|
|
56
56
|
|
|
57
57
|
**Note:** Rule config is either a severity string (`'off'`, `'warn'`, `'error'`) or an array `[severity, options]` when the rule accepts options.
|
|
58
58
|
|
|
@@ -270,6 +270,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
270
270
|
|
|
271
271
|
## <img height=30 width=29 align="top" src="https://api.iconify.design/bxs/package.svg?color=%232b2b2a"> Related
|
|
272
272
|
|
|
273
|
+
<!-- eslint-plugin-chrome-extensions -->
|
|
274
|
+
|
|
275
|
+
### <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-chrome-extensions/#readme"><img height=15 width=auto src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/e9128375d4/assets/images/icons/eslint/purple/icon16.png"> eslint-plugin-chrome-extensions</a>
|
|
276
|
+
|
|
277
|
+
<details>
|
|
278
|
+
|
|
279
|
+
<summary>ESLint rules for Chrome extensions.</summary><br>
|
|
280
|
+
|
|
281
|
+
> <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-chrome-extensions/#readme"><img width=555 src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-chrome-extensions/0b5e3e49/assets/images/screenshots/vs-code/squiggles.png"></a>
|
|
282
|
+
|
|
283
|
+
> <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-chrome-extensions/#installation"><b>Install</b></a> / <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-chrome-extensions/#readme">Readme</a> / <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-chrome-extensions/#supported-rules">Supported rules</a>
|
|
284
|
+
|
|
285
|
+
</details>
|
|
286
|
+
|
|
273
287
|
<!-- eslint-plugin-greasemonkey -->
|
|
274
288
|
|
|
275
289
|
### <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-greasemonkey/#readme"><img height=15 width=auto src="https://cdn.staticdelivr.com/gl/adamlui/eslint-plugin-greasemonkey/e9128375d4/assets/images/icons/eslint/purple/icon16.png"> eslint-plugin-greasemonkey</a>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-constructors",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "ESLint rules for constructor usage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "src/index.d.ts",
|
|
36
36
|
"scripts": {
|
|
37
|
-
"prepare": "husky",
|
|
38
37
|
"lint": "eslint . --cache && yamllint .",
|
|
39
38
|
"lint:all": "eslint . && yamllint .",
|
|
40
39
|
"lint:fix": "eslint . --fix --cache && yamllint .",
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"security"
|
|
61
60
|
],
|
|
62
61
|
"dependencies": {
|
|
63
|
-
"globals": "^17.
|
|
62
|
+
"globals": "^17.13.0"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
65
|
"eslint": ">=9.0.0"
|
|
@@ -68,19 +67,18 @@
|
|
|
68
67
|
"devDependencies": {
|
|
69
68
|
"@e18e/eslint-plugin": "^0.8.1",
|
|
70
69
|
"@eslint/js": "^10.0.1",
|
|
71
|
-
"@eslint/json": "^2.1.
|
|
72
|
-
"@eslint/markdown": "^
|
|
70
|
+
"@eslint/json": "^2.1.1",
|
|
71
|
+
"@eslint/markdown": "^7.5.1",
|
|
73
72
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
74
|
-
"eslint": "^10.
|
|
73
|
+
"eslint": "^10.12.0",
|
|
75
74
|
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
76
75
|
"eslint-plugin-import-x": "^4.17.1",
|
|
77
|
-
"eslint-plugin-n": "^18.4.
|
|
76
|
+
"eslint-plugin-n": "^18.4.1",
|
|
78
77
|
"eslint-plugin-no-secrets": "^2.3.3",
|
|
79
78
|
"eslint-plugin-no-unsanitized": "^4.1.5",
|
|
80
79
|
"eslint-plugin-promise": "^7.3.0",
|
|
81
80
|
"eslint-plugin-regexp": "^3.3.1",
|
|
82
81
|
"eslint-plugin-security": "^4.2.0",
|
|
83
|
-
"husky": "^9.1.7",
|
|
84
82
|
"yamllint-js": "^0.2.4"
|
|
85
83
|
}
|
|
86
84
|
}
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import noExplicitReturn from './rules/no-explicit-return.js'
|
|
|
4
4
|
import requireErrorSubclassName from './rules/require-error-subclass-name.js'
|
|
5
5
|
import requireNew from './rules/require-new.js'
|
|
6
6
|
|
|
7
|
-
import { initDeprecatedAlias } from './utils.js'
|
|
7
|
+
import { bundleRules, initDeprecatedAlias } from './utils.js'
|
|
8
8
|
|
|
9
9
|
const plugin = {
|
|
10
10
|
rules: {
|
|
@@ -23,17 +23,11 @@ for (const entry of Object.entries(oldRules))
|
|
|
23
23
|
plugin.configs = {
|
|
24
24
|
recommended: {
|
|
25
25
|
plugins: { constructors: plugin },
|
|
26
|
-
rules:
|
|
27
|
-
'constructors/no-explicit-return': 'error',
|
|
28
|
-
'constructors/require-error-subclass-name': 'error',
|
|
29
|
-
'constructors/require-new': 'error'
|
|
30
|
-
}
|
|
26
|
+
rules: bundleRules(plugin.rules, rule => rule.meta.docs.recommended, 'constructors')
|
|
31
27
|
},
|
|
32
28
|
problem: {
|
|
33
29
|
plugins: { constructors: plugin },
|
|
34
|
-
rules:
|
|
35
|
-
.filter(([, rule]) => rule.meta.type == 'problem')
|
|
36
|
-
.map(([id]) => [`constructors/${id}`, 'error']))
|
|
30
|
+
rules: bundleRules(plugin.rules, rule => rule.meta.type == 'problem', 'constructors')
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
33
|
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
recommended: true
|
|
8
8
|
},
|
|
9
9
|
schema: [],
|
|
10
|
-
messages: { endWithError: 'Class extending Error must have a name ending in "Error"' }
|
|
10
|
+
messages: { endWithError: 'Class extending Error must have a name ending in "Error".' }
|
|
11
11
|
},
|
|
12
12
|
|
|
13
13
|
create(context) {
|
package/src/rules/require-new.js
CHANGED
|
@@ -31,7 +31,7 @@ export default {
|
|
|
31
31
|
additionalProperties: false
|
|
32
32
|
}],
|
|
33
33
|
defaultOptions: [{ mode: 'throwing' }],
|
|
34
|
-
messages: { requireNew: 'Use `new {{name}}()` instead of `{{name}}()
|
|
34
|
+
messages: { requireNew: 'Use `new {{name}}()` instead of `{{name}}()`.' }
|
|
35
35
|
},
|
|
36
36
|
|
|
37
37
|
create(context) {
|
package/src/utils.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export function bundleRules(rules, predicate, pluginName) {
|
|
2
|
+
return Object.fromEntries(Object.entries(rules)
|
|
3
|
+
.filter(([, rule]) => predicate(rule))
|
|
4
|
+
.map(([ruleId]) => [`${pluginName}/${ruleId}`, 'error']))
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export function initDeprecatedAlias(plugin, [oldName, alias]) { /* eslint-disable security/detect-object-injection */
|
|
2
8
|
const routes = typeof alias == 'string' ? { [alias]: null } // 'old-rule': 'new-rule'
|
|
3
9
|
: Array.isArray(alias) ? Object.fromEntries(alias.map(entry =>
|