@darksheep/eslint 5.3.0 → 5.3.1

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +3 -3
  3. package/src/configs/eslint-base.js +103 -103
  4. package/src/configs/eslint-complexity.js +24 -24
  5. package/src/configs/eslint-ignores.js +32 -32
  6. package/src/configs/eslint-recommended.js +4 -4
  7. package/src/configs/eslint-style.js +12 -12
  8. package/src/custom/index.js +5 -5
  9. package/src/custom/instance-of-array.js +44 -44
  10. package/src/custom/loose-types.js +128 -128
  11. package/src/custom/no-useless-expression.js +19 -19
  12. package/src/custom/sequence-expression.js +15 -15
  13. package/src/index.js +38 -38
  14. package/src/plugins/eslint-comments.js +19 -19
  15. package/src/plugins/jsdoc.js +57 -57
  16. package/src/plugins/json.js +43 -43
  17. package/src/plugins/node.js +108 -108
  18. package/src/plugins/package-json.js +25 -25
  19. package/src/plugins/perfectionist.js +200 -200
  20. package/src/plugins/promise.js +9 -9
  21. package/src/plugins/react.js +111 -111
  22. package/src/plugins/regexp.js +6 -6
  23. package/src/plugins/sca.js +32 -32
  24. package/src/plugins/security.js +14 -14
  25. package/src/plugins/sonarjs.js +11 -11
  26. package/src/plugins/style.js +236 -236
  27. package/src/plugins/typescript.js +65 -65
  28. package/src/plugins/unicorn.js +40 -40
  29. package/src/plugins/unused-imports.js +25 -25
  30. package/src/plugins/yml.js +32 -32
  31. package/src/types.d.ts +80 -80
  32. package/src/utilities/editorconfig.js +150 -150
  33. package/src/utilities/eslint-files.js +20 -20
  34. package/src/utilities/expand-glob.js +33 -33
  35. package/src/utilities/filesystem.js +30 -30
  36. package/src/utilities/make-compat.js +6 -6
  37. package/src/utilities/package.js +29 -29
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.3.1](https://github.com/DarkSheepSoftware/eslint/compare/v5.3.0...v5.3.1) (2024-08-08)
4
+
5
+
6
+ ### 📦 Dependencies
7
+
8
+ * **pkg:** update dependency @stylistic/eslint-plugin to v2.6.2 ([#564](https://github.com/DarkSheepSoftware/eslint/issues/564)) ([6d4296b](https://github.com/DarkSheepSoftware/eslint/commit/6d4296b5f5d24468bd29e640f4651842d959e899))
9
+ * **pkg:** update dependency eslint-plugin-unused-imports to v4.1.2 ([#563](https://github.com/DarkSheepSoftware/eslint/issues/563)) ([464a465](https://github.com/DarkSheepSoftware/eslint/commit/464a465b6293ae94d049f55d311e0ae4d09dd8d8))
10
+
3
11
  ## [5.3.0](https://github.com/DarkSheepSoftware/eslint/compare/v5.2.1...v5.3.0) (2024-08-08)
4
12
 
5
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksheep/eslint",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/DarkSheepSoftware/eslint"
@@ -24,7 +24,7 @@
24
24
  "@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
25
25
  "@eslint/eslintrc": "3.1.0",
26
26
  "@eslint/js": "9.8.0",
27
- "@stylistic/eslint-plugin": "2.6.1",
27
+ "@stylistic/eslint-plugin": "2.6.2",
28
28
  "@typescript-eslint/eslint-plugin": "8.0.1",
29
29
  "@typescript-eslint/parser": "8.0.1",
30
30
  "editorconfig": "2.0.0",
@@ -39,7 +39,7 @@
39
39
  "eslint-plugin-security": "3.0.1",
40
40
  "eslint-plugin-sonarjs": "1.0.4",
41
41
  "eslint-plugin-unicorn": "55.0.0",
42
- "eslint-plugin-unused-imports": "4.0.1",
42
+ "eslint-plugin-unused-imports": "4.1.2",
43
43
  "eslint-plugin-yml": "1.14.0",
44
44
  "jsonc-eslint-parser": "2.4.0",
45
45
  "yaml-eslint-parser": "1.2.3"
@@ -1,110 +1,110 @@
1
1
  /** @type {import('eslint').Linter.RulesRecord} */
2
2
  const rules = {
3
- 'no-else-return': 'error',
3
+ 'no-else-return': 'error',
4
4
 
5
- 'radix': 'error',
6
- 'prefer-exponentiation-operator': 'error',
5
+ 'radix': 'error',
6
+ 'prefer-exponentiation-operator': 'error',
7
7
 
8
- 'class-methods-use-this': 'off',
9
- 'no-eval': 'error',
10
- 'no-extend-native': 'error',
11
- 'no-implicit-coercion': 'error',
12
- 'no-implied-eval': 'error',
13
- 'no-invalid-this': 'error',
14
- 'no-new-func': 'error',
15
- 'no-proto': 'error',
16
- 'no-script-url': 'error',
17
- 'no-unexpected-multiline': 'error',
18
- 'no-void': 'error',
8
+ 'class-methods-use-this': 'off',
9
+ 'no-eval': 'error',
10
+ 'no-extend-native': 'error',
11
+ 'no-implicit-coercion': 'error',
12
+ 'no-implied-eval': 'error',
13
+ 'no-invalid-this': 'error',
14
+ 'no-new-func': 'error',
15
+ 'no-proto': 'error',
16
+ 'no-script-url': 'error',
17
+ 'no-unexpected-multiline': 'error',
18
+ 'no-void': 'error',
19
19
 
20
- 'no-caller': 'error',
21
- 'no-empty': [ 'error', { allowEmptyCatch: true } ],
22
- 'no-empty-function': [ 'error', { allow: [ 'arrowFunctions' ] } ],
23
- 'no-labels': 'error',
24
- 'no-lone-blocks': 'error',
25
- 'no-loop-func': 'error',
26
- 'no-misleading-character-class': 'error',
27
- 'no-new-wrappers': 'error',
28
- 'no-new': 'error',
29
- 'no-undef': [ 'error', { typeof: true } ],
30
- 'no-use-before-define': 'off',
20
+ 'no-caller': 'error',
21
+ 'no-empty': [ 'error', { allowEmptyCatch: true } ],
22
+ 'no-empty-function': [ 'error', { allow: [ 'arrowFunctions' ] } ],
23
+ 'no-labels': 'error',
24
+ 'no-lone-blocks': 'error',
25
+ 'no-loop-func': 'error',
26
+ 'no-misleading-character-class': 'error',
27
+ 'no-new-wrappers': 'error',
28
+ 'no-new': 'error',
29
+ 'no-undef': [ 'error', { typeof: true } ],
30
+ 'no-use-before-define': 'off',
31
31
 
32
- 'arrow-body-style': [ 'error', 'as-needed' ],
33
- 'constructor-super': 'error',
34
- 'no-class-assign': 'error',
35
- 'no-const-assign': 'error',
36
- 'no-dupe-class-members': 'error',
37
- 'no-duplicate-imports': 'error',
38
- 'no-new-native-nonconstructor': 'error',
39
- 'no-restricted-imports': 'error',
40
- 'no-this-before-super': 'error',
41
- 'no-useless-computed-key': 'error',
42
- 'no-useless-constructor': 'error',
43
- 'no-useless-rename': 'error',
44
- 'no-var': 'error',
45
- 'object-shorthand': [ 'error', 'consistent-as-needed' ],
46
- 'prefer-arrow-callback': [
47
- 'error',
48
- {
49
- allowNamedFunctions: false,
50
- allowUnboundThis: true,
51
- },
52
- ],
53
- 'prefer-const': 'error',
54
- 'prefer-destructuring': [
55
- 'error',
56
- { array: false, object: true },
57
- { enforceForRenamedProperties: false },
58
- ],
59
- 'prefer-numeric-literals': 'error',
60
- 'prefer-rest-params': 'error',
61
- 'prefer-spread': 'error',
62
- 'prefer-template': 'error',
63
- 'require-yield': 'error',
64
- 'sort-imports': 'off',
65
- 'symbol-description': 'error',
32
+ 'arrow-body-style': [ 'error', 'as-needed' ],
33
+ 'constructor-super': 'error',
34
+ 'no-class-assign': 'error',
35
+ 'no-const-assign': 'error',
36
+ 'no-dupe-class-members': 'error',
37
+ 'no-duplicate-imports': 'error',
38
+ 'no-new-native-nonconstructor': 'error',
39
+ 'no-restricted-imports': 'error',
40
+ 'no-this-before-super': 'error',
41
+ 'no-useless-computed-key': 'error',
42
+ 'no-useless-constructor': 'error',
43
+ 'no-useless-rename': 'error',
44
+ 'no-var': 'error',
45
+ 'object-shorthand': [ 'error', 'consistent-as-needed' ],
46
+ 'prefer-arrow-callback': [
47
+ 'error',
48
+ {
49
+ allowNamedFunctions: false,
50
+ allowUnboundThis: true,
51
+ },
52
+ ],
53
+ 'prefer-const': 'error',
54
+ 'prefer-destructuring': [
55
+ 'error',
56
+ { array: false, object: true },
57
+ { enforceForRenamedProperties: false },
58
+ ],
59
+ 'prefer-numeric-literals': 'error',
60
+ 'prefer-rest-params': 'error',
61
+ 'prefer-spread': 'error',
62
+ 'prefer-template': 'error',
63
+ 'require-yield': 'error',
64
+ 'sort-imports': 'off',
65
+ 'symbol-description': 'error',
66
66
 
67
- 'eqeqeq': [ 'error', 'always', { null: 'ignore' } ],
68
- 'no-extra-bind': 'error',
69
- 'no-loss-of-precision': 'error',
70
- 'no-useless-call': 'error',
71
- 'no-useless-catch': 'error',
72
- 'no-useless-concat': 'error',
73
- 'no-useless-escape': 'error',
74
- 'no-useless-return': 'error',
75
- 'no-multi-str': 'error',
76
- 'no-octal': 'error',
77
- 'no-octal-escape': 'error',
78
- 'no-return-assign': 'error',
79
- 'prefer-promise-reject-errors': 'error',
80
- 'require-await': 'off',
67
+ 'eqeqeq': [ 'error', 'always', { null: 'ignore' } ],
68
+ 'no-extra-bind': 'error',
69
+ 'no-loss-of-precision': 'error',
70
+ 'no-useless-call': 'error',
71
+ 'no-useless-catch': 'error',
72
+ 'no-useless-concat': 'error',
73
+ 'no-useless-escape': 'error',
74
+ 'no-useless-return': 'error',
75
+ 'no-multi-str': 'error',
76
+ 'no-octal': 'error',
77
+ 'no-octal-escape': 'error',
78
+ 'no-return-assign': 'error',
79
+ 'prefer-promise-reject-errors': 'error',
80
+ 'require-await': 'off',
81
81
 
82
- 'no-shadow-restricted-names': 'error',
83
- 'no-undefined': 'off',
82
+ 'no-shadow-restricted-names': 'error',
83
+ 'no-undefined': 'off',
84
84
 
85
- 'func-name-matching': [ 'error', 'never' ],
86
- 'func-style': [
87
- 'error',
88
- 'declaration',
89
- { allowArrowFunctions: true },
90
- ],
91
- 'consistent-this': [ 'error', 'that' ],
92
- 'no-array-constructor': 'error',
93
- 'no-lonely-if': 'error',
94
- 'no-negated-condition': 'error',
95
- 'no-object-constructor': 'error',
96
- 'no-nested-ternary': 'warn',
97
- 'no-unneeded-ternary': 'warn',
85
+ 'func-name-matching': [ 'error', 'never' ],
86
+ 'func-style': [
87
+ 'error',
88
+ 'declaration',
89
+ { allowArrowFunctions: true },
90
+ ],
91
+ 'consistent-this': [ 'error', 'that' ],
92
+ 'no-array-constructor': 'error',
93
+ 'no-lonely-if': 'error',
94
+ 'no-negated-condition': 'error',
95
+ 'no-object-constructor': 'error',
96
+ 'no-nested-ternary': 'warn',
97
+ 'no-unneeded-ternary': 'warn',
98
98
 
99
- 'one-var': [
100
- 'error',
101
- 'never',
102
- ],
103
- 'operator-assignment': [ 'error', 'always' ],
99
+ 'one-var': [
100
+ 'error',
101
+ 'never',
102
+ ],
103
+ 'operator-assignment': [ 'error', 'always' ],
104
104
 
105
- 'yoda': 'error',
105
+ 'yoda': 'error',
106
106
 
107
- 'prefer-object-spread': 'error',
107
+ 'prefer-object-spread': 'error',
108
108
  };
109
109
 
110
110
  /**
@@ -112,13 +112,13 @@ const rules = {
112
112
  * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
113
113
  */
114
114
  export async function createEslintBaseConfig() {
115
- return [ {
116
- name: 'darksheep/base',
117
- linterOptions: {
118
- noInlineConfig: false,
119
- reportUnusedDisableDirectives: true,
120
- },
115
+ return [ {
116
+ name: 'darksheep/base',
117
+ linterOptions: {
118
+ noInlineConfig: false,
119
+ reportUnusedDisableDirectives: true,
120
+ },
121
121
 
122
- rules: rules,
123
- } ];
122
+ rules: rules,
123
+ } ];
124
124
  }
@@ -3,29 +3,29 @@
3
3
  * @returns {import('eslint').Linter.FlatConfig[]}
4
4
  */
5
5
  export function createEslintComplexityConfig() {
6
- return [ {
7
- name: 'darksheep/complexity',
8
- rules: {
9
- 'max-depth': [ 'error', 4 ],
10
- 'complexity': 'off',
11
- 'max-lines': [
12
- 'warn',
13
- {
14
- max: 512,
15
- skipBlankLines: true,
16
- skipComments: true,
17
- },
18
- ],
19
- 'max-lines-per-function': [
20
- 'warn',
21
- {
22
- max: 120,
23
- skipBlankLines: true,
24
- skipComments: true,
25
- },
26
- ],
27
- 'max-nested-callbacks': [ 'warn', 3 ],
28
- 'max-params': [ 'error', 5 ],
6
+ return [ {
7
+ name: 'darksheep/complexity',
8
+ rules: {
9
+ 'max-depth': [ 'error', 4 ],
10
+ 'complexity': 'off',
11
+ 'max-lines': [
12
+ 'warn',
13
+ {
14
+ max: 512,
15
+ skipBlankLines: true,
16
+ skipComments: true,
29
17
  },
30
- } ];
18
+ ],
19
+ 'max-lines-per-function': [
20
+ 'warn',
21
+ {
22
+ max: 120,
23
+ skipBlankLines: true,
24
+ skipComments: true,
25
+ },
26
+ ],
27
+ 'max-nested-callbacks': [ 'warn', 3 ],
28
+ 'max-params': [ 'error', 5 ],
29
+ },
30
+ } ];
31
31
  }
@@ -9,23 +9,23 @@ import { findUp } from '../utilities/filesystem.js';
9
9
  * @returns {Promise<string[]>}
10
10
  */
11
11
  async function getGitignore(root) {
12
- const rootPath = fileURLToPath(root);
13
- const gitPath = await findUp(rootPath, '.git');
14
- const path = resolve(gitPath ?? rootPath, '..', '.gitignore');
15
-
16
- try {
17
- const raw = await fs.readFile(path, 'utf8');
18
-
19
- return raw
20
- .split(/\r?\n|\r/)
21
- .filter(Boolean);
22
- } catch (error) {
23
- if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
24
- return [];
25
- }
26
-
27
- throw error;
12
+ const rootPath = fileURLToPath(root);
13
+ const gitPath = await findUp(rootPath, '.git');
14
+ const path = resolve(gitPath ?? rootPath, '..', '.gitignore');
15
+
16
+ try {
17
+ const raw = await fs.readFile(path, 'utf8');
18
+
19
+ return raw
20
+ .split(/\r?\n|\r/)
21
+ .filter(Boolean);
22
+ } catch (error) {
23
+ if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
24
+ return [];
28
25
  }
26
+
27
+ throw error;
28
+ }
29
29
  }
30
30
 
31
31
  /**
@@ -34,20 +34,20 @@ async function getGitignore(root) {
34
34
  * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
35
35
  */
36
36
  export async function createEslintIgnoresConfig(root) {
37
- const ignores = await getGitignore(root);
38
-
39
- return [ {
40
- name: 'darksheep/git-ignores',
41
- ignores: [
42
- ...ignores,
43
-
44
- // Some things we always want to ignore
45
- '.yarn/',
46
- '.pnp.cjs',
47
- '.pnp.loader.mjs',
48
- '.git/',
49
- 'coverage/',
50
- 'node_modules/',
51
- ],
52
- } ];
37
+ const ignores = await getGitignore(root);
38
+
39
+ return [ {
40
+ name: 'darksheep/git-ignores',
41
+ ignores: [
42
+ ...ignores,
43
+
44
+ // Some things we always want to ignore
45
+ '.yarn/',
46
+ '.pnp.cjs',
47
+ '.pnp.loader.mjs',
48
+ '.git/',
49
+ 'coverage/',
50
+ 'node_modules/',
51
+ ],
52
+ } ];
53
53
  }
@@ -5,8 +5,8 @@ import js from '@eslint/js';
5
5
  * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
6
6
  */
7
7
  export async function createEslintRecommendsConfig() {
8
- return [ {
9
- name: 'eslint/recomended',
10
- ...js.configs.recommended,
11
- } ];
8
+ return [ {
9
+ name: 'eslint/recomended',
10
+ ...js.configs.recommended,
11
+ } ];
12
12
  }
@@ -2,12 +2,12 @@ import { createEditorOverrides } from '../utilities/editorconfig.js';
2
2
 
3
3
  /** @type {import('eslint').Linter.RulesRecord} */
4
4
  const rules = {
5
- 'dot-notation': 'error',
6
- 'curly': 'error',
7
- 'unicode-bom': [ 'error', 'never' ],
5
+ 'dot-notation': 'error',
6
+ 'curly': 'error',
7
+ 'unicode-bom': [ 'error', 'never' ],
8
8
 
9
- 'no-div-regex': 'error',
10
- 'no-control-regex': 'error',
9
+ 'no-div-regex': 'error',
10
+ 'no-control-regex': 'error',
11
11
  };
12
12
 
13
13
  /**
@@ -16,11 +16,11 @@ const rules = {
16
16
  * @returns {Promise<import('eslint').Linter.FlatConfig[]>}
17
17
  */
18
18
  export async function createStyleConfig(root) {
19
- return [
20
- {
21
- name: 'style/core',
22
- rules: rules,
23
- },
24
- ...await createEditorOverrides(root),
25
- ];
19
+ return [
20
+ {
21
+ name: 'style/core',
22
+ rules: rules,
23
+ },
24
+ ...await createEditorOverrides(root),
25
+ ];
26
26
  }
@@ -3,9 +3,9 @@ import noUselessExpression from './no-useless-expression.js';
3
3
  import sequenceExpression from './sequence-expression.js';
4
4
 
5
5
  export default {
6
- rules: {
7
- 'loose-types': looseTypes,
8
- 'no-useless-expression': noUselessExpression,
9
- 'sequence-expression': sequenceExpression,
10
- },
6
+ rules: {
7
+ 'loose-types': looseTypes,
8
+ 'no-useless-expression': noUselessExpression,
9
+ 'sequence-expression': sequenceExpression,
10
+ },
11
11
  };
@@ -3,23 +3,23 @@
3
3
  * @returns {import('eslint').Rule.RuleListener}
4
4
  */
5
5
  const preferInstance = (context) => ({
6
- /**
7
- * @param {import('estree').CallExpression} node The AST function node
8
- * @returns {void}
9
- */
10
- 'CallExpression[callee.object.name = "Array"][callee.property.name = "isArray"]': (node) => {
11
- const message = 'Use `instanceof Array` instead of `Array.isArray()`';
6
+ /**
7
+ * @param {import('estree').CallExpression} node The AST function node
8
+ * @returns {void}
9
+ */
10
+ 'CallExpression[callee.object.name = "Array"][callee.property.name = "isArray"]': (node) => {
11
+ const message = 'Use `instanceof Array` instead of `Array.isArray()`';
12
12
 
13
- if (node.arguments.length !== 1) {
14
- return context.report({ node, message });
15
- }
13
+ if (node.arguments.length !== 1) {
14
+ return context.report({ node, message });
15
+ }
16
16
 
17
- const left = context.sourceCode.getText(node.arguments[0]);
18
- /** @type {import('eslint').Rule.ReportFixer} */
19
- const fix = (fixer) => fixer.replaceText(node, `${left} instanceof Array`);
17
+ const left = context.sourceCode.getText(node.arguments[0]);
18
+ /** @type {import('eslint').Rule.ReportFixer} */
19
+ const fix = (fixer) => fixer.replaceText(node, `${left} instanceof Array`);
20
20
 
21
- context.report({ node, message, fix });
22
- },
21
+ context.report({ node, message, fix });
22
+ },
23
23
  });
24
24
 
25
25
  /**
@@ -27,46 +27,46 @@ const preferInstance = (context) => ({
27
27
  * @returns {import('eslint').Rule.RuleListener}
28
28
  */
29
29
  const preferIsArray = (context) => ({
30
- /**
31
- * @param {import('estree').BinaryExpression} node The AST function node
32
- * @returns {void}
33
- */
34
- 'BinaryExpression[operator="instanceof"][right.type="Identifier"][right.name="Array"]': (node) => {
35
- const message = 'Use `Array.isArray()` instead of `instanceof Array`';
30
+ /**
31
+ * @param {import('estree').BinaryExpression} node The AST function node
32
+ * @returns {void}
33
+ */
34
+ 'BinaryExpression[operator="instanceof"][right.type="Identifier"][right.name="Array"]': (node) => {
35
+ const message = 'Use `Array.isArray()` instead of `instanceof Array`';
36
36
 
37
- const argument = context.sourceCode.getText(node.left);
38
- /** @type {import('eslint').Rule.ReportFixer} */
39
- const fix = (fixer) => fixer.replaceText(node, `Array.isArray(${argument})`);
37
+ const argument = context.sourceCode.getText(node.left);
38
+ /** @type {import('eslint').Rule.ReportFixer} */
39
+ const fix = (fixer) => fixer.replaceText(node, `Array.isArray(${argument})`);
40
40
 
41
- context.report({ node, message, fix });
42
- },
41
+ context.report({ node, message, fix });
42
+ },
43
43
  });
44
44
 
45
45
  /** @type {import('eslint').Rule.RuleModule} */
46
46
  const rule = {
47
- meta: {
48
- type: 'suggestion',
49
- fixable: 'code',
50
- schema: [
51
- {
52
- type: 'string',
53
- enum: [
54
- 'instanceof',
55
- 'isarray',
56
- ],
57
- },
47
+ meta: {
48
+ type: 'suggestion',
49
+ fixable: 'code',
50
+ schema: [
51
+ {
52
+ type: 'string',
53
+ enum: [
54
+ 'instanceof',
55
+ 'isarray',
58
56
  ],
59
- },
57
+ },
58
+ ],
59
+ },
60
60
 
61
- create: function (context) {
62
- const [ option = 'instanceof' ] = context.options;
61
+ create: function (context) {
62
+ const [ option = 'instanceof' ] = context.options;
63
63
 
64
- if (option === 'instanceof') {
65
- return preferInstance(context);
66
- }
64
+ if (option === 'instanceof') {
65
+ return preferInstance(context);
66
+ }
67
67
 
68
- return preferIsArray(context);
69
- },
68
+ return preferIsArray(context);
69
+ },
70
70
  };
71
71
 
72
72
  export default rule;