eslint-plugin-constructors 1.4.0 → 1.4.2

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 CHANGED
@@ -6,6 +6,8 @@
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>
10
+ <img src="https://img.shields.io/npm/dm/eslint-plugin-constructors?style=for-the-badge&logo=npm&color=black"></a>
9
11
  <a target="_blank" href="https://eslint.org/">
10
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>
11
13
  <br><br>
@@ -50,7 +52,7 @@ export default [
50
52
  ]
51
53
  ```
52
54
 
53
- Available bundles: `recommended`, `problem`
55
+ Available bundles: `recommended`, `problem` (deterministic bugs only)
54
56
 
55
57
  **Note:** Rule config is either a severity string (`'off'`, `'warn'`, `'error'`) or an array `[severity, options]` when the rule accepts options.
56
58
 
@@ -226,7 +228,7 @@ If you prefer calling built-ins w/o `new` (which the runtime allows for some of
226
228
 
227
229
  ---
228
230
 
229
- ## <img height=30 align="top" src="https://api.iconify.design/boxicons/code-alt-filled.svg?color=%232b2b2a"> Shield embed
231
+ ## <img width=30 align="top" src="https://api.iconify.design/boxicons/code-alt-filled.svg?color=%232b2b2a"> Shield embed
230
232
 
231
233
  <a target="_blank" href="https://codeberg.org/adamlui/eslint-plugin-constructors/#readme">
232
234
  <img height=32 alt="[Linted by eslint-plugin-constructors]" src="https://img.shields.io/badge/Linted_by-eslint--plugin--constructors-black?logo=eslint&logoColor=white&labelColor=464646&style=for-the-badge"></a>
@@ -268,6 +270,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
268
270
 
269
271
  ## <img height=30 width=29 align="top" src="https://api.iconify.design/bxs/package.svg?color=%232b2b2a"> Related
270
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
+
271
287
  <!-- eslint-plugin-greasemonkey -->
272
288
 
273
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.0",
3
+ "version": "1.4.2",
4
4
  "description": "ESLint rules for constructor usage",
5
5
  "type": "module",
6
6
  "engines": {
@@ -71,10 +71,10 @@
71
71
  "@eslint/json": "^2.1.0",
72
72
  "@eslint/markdown": "^8.0.3",
73
73
  "@stylistic/eslint-plugin": "^5.10.0",
74
- "eslint": "^10.11.0",
74
+ "eslint": "^10.12.0",
75
75
  "eslint-plugin-eslint-plugin": "^7.6.2",
76
76
  "eslint-plugin-import-x": "^4.17.1",
77
- "eslint-plugin-n": "^18.4.0",
77
+ "eslint-plugin-n": "^18.4.1",
78
78
  "eslint-plugin-no-secrets": "^2.3.3",
79
79
  "eslint-plugin-no-unsanitized": "^4.1.5",
80
80
  "eslint-plugin-promise": "^7.3.0",
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: Object.fromEntries(Object.entries(plugin.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
 
@@ -23,7 +23,7 @@ export default {
23
23
  recommended: true
24
24
  },
25
25
  schema: [],
26
- messages: { unexpectedReturn: 'Unexpected return statement in constructor' }
26
+ messages: { unexpectedReturn: 'Unexpected return statement in constructor.' }
27
27
  },
28
28
 
29
29
  create(context) {
@@ -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) {
@@ -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 =>