@haltcase/style 6.2.1 → 7.0.0-canary.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 (59) hide show
  1. package/eslint/configs/browser.js +19 -0
  2. package/eslint/configs/cjs.js +1 -0
  3. package/eslint/configs/internal/base.js +180 -0
  4. package/eslint/configs/internal/commonjs.js +22 -0
  5. package/eslint/{rules → configs/internal}/es2015.js +14 -16
  6. package/eslint/configs/internal/simple-import-sort.js +24 -0
  7. package/eslint/configs/internal/tsdoc.js +17 -0
  8. package/eslint/{rules → configs/internal}/unicorn.js +116 -121
  9. package/eslint/configs/next.js +36 -0
  10. package/eslint/configs/node.js +19 -0
  11. package/eslint/configs/playwright-test.js +17 -0
  12. package/eslint/configs/react.js +54 -0
  13. package/eslint/configs/typescript.js +84 -0
  14. package/eslint/constants.js +12 -28
  15. package/eslint/index.js +27 -0
  16. package/eslint/rules/best-practice.js +250 -245
  17. package/eslint/rules/imports.js +94 -0
  18. package/eslint/rules/jsx-a11y.js +11 -10
  19. package/eslint/rules/playwright-test.js +25 -26
  20. package/eslint/rules/possible-errors.js +38 -45
  21. package/eslint/rules/react.js +105 -104
  22. package/eslint/rules/stylistic.js +83 -84
  23. package/eslint/rules/typescript/extension.js +55 -39
  24. package/eslint/rules/typescript/import.js +16 -15
  25. package/eslint/rules/typescript/index.js +109 -121
  26. package/eslint/rules/typescript/naming-convention.js +71 -0
  27. package/eslint/rules/variables.js +34 -34
  28. package/eslint/withFiles.js +15 -0
  29. package/package.json +58 -56
  30. package/prettier/index.js +4 -11
  31. package/readme.md +181 -98
  32. package/stylelint/_base.js +2 -4
  33. package/stylelint/index.js +6 -7
  34. package/stylelint/modules.js +7 -8
  35. package/stylelint/standard.js +2 -5
  36. package/typescript/tsconfig.base.json +2 -1
  37. package/typescript/tsconfig.bundler.json +7 -3
  38. package/typescript/tsconfig.next.json +14 -6
  39. package/typescript/tsconfig.node.json +1 -1
  40. package/typescript/tsconfig.node18.json +4 -7
  41. package/typescript/tsconfig.node20.json +4 -7
  42. package/typescript/tsconfig.node22.json +10 -0
  43. package/typescript/tsconfig.web.json +1 -1
  44. package/eslint/_base.js +0 -82
  45. package/eslint/astro.js +0 -40
  46. package/eslint/browser.js +0 -8
  47. package/eslint/cjs.js +0 -12
  48. package/eslint/jest.js +0 -28
  49. package/eslint/next.js +0 -38
  50. package/eslint/node.js +0 -8
  51. package/eslint/playwright-test.js +0 -8
  52. package/eslint/react.js +0 -18
  53. package/eslint/rules/import.js +0 -92
  54. package/eslint/rules/jest.js +0 -28
  55. package/eslint/rules/simple-import-sort.js +0 -23
  56. package/eslint/rules/tsdoc.js +0 -17
  57. package/eslint/rules/typescript/strict.js +0 -18
  58. package/eslint/typescript.js +0 -26
  59. package/eslint/utils/require-package.js +0 -44
@@ -1,28 +1,27 @@
1
- "use strict";
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
2
4
 
3
- const {
4
- levels: { warn, error }
5
- } = require("../constants");
6
-
7
- module.exports = {
8
- rules: {
9
- /**
10
- * Require lowercase test names.
11
- *
12
- * 🔧 Fixable - https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
13
- */
14
- "playwright/prefer-lowercase-title": warn,
15
- /**
16
- * Require using `toHaveLength` over explicitly checking lengths.
17
- *
18
- * 🔧 Fixable - https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
19
- */
20
- "playwright/prefer-to-have-length": warn,
21
- /**
22
- * Require test cases and hooks to be inside a `test.describe` block.
23
- *
24
- * 🚫 Not fixable - https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
25
- */
26
- "playwright/require-top-level-describe": error
27
- }
5
+ /**
6
+ * @type {Linter.RulesRecord}
7
+ */
8
+ export const playwrightTestRules = {
9
+ /**
10
+ * Require lowercase test names.
11
+ *
12
+ * 🔧 Fixable - https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
13
+ */
14
+ "playwright/prefer-lowercase-title": "warn",
15
+ /**
16
+ * Require using `toHaveLength` over explicitly checking lengths.
17
+ *
18
+ * 🔧 Fixable - https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
19
+ */
20
+ "playwright/prefer-to-have-length": "warn",
21
+ /**
22
+ * Require test cases and hooks to be inside a `test.describe` block.
23
+ *
24
+ * 🚫 Not fixable - https://github.com/playwright-community/eslint-plugin-playwright/blob/main/docs/rules/prefer-lowercase-title.md
25
+ */
26
+ "playwright/require-top-level-describe": "error"
28
27
  };
@@ -1,47 +1,40 @@
1
- "use strict";
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
2
4
 
3
- const {
4
- levels: { error }
5
- } = require("../constants");
6
-
7
- module.exports = {
8
- rules: {
9
- /**
10
- * Disallow await inside of loops.
11
- *
12
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-await-in-loop
13
- */
14
- "no-await-in-loop": error,
15
- /**
16
- * Disallow the use of console.
17
- *
18
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-console
19
- */
20
- "no-console": error,
21
- /**
22
- * Disallow expressions where the operation doesn't affect the value.
23
- *
24
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-console
25
- */
26
- "no-constant-binary-expression": error,
27
- /**
28
- * Disallow returning values from Promise executor functions.
29
- *
30
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-promise-executor-return
31
- */
32
- "no-promise-executor-return": error,
33
- /**
34
- * Disallow template literal placeholder syntax in regular strings, as
35
- * these are likely errors.
36
- *
37
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-template-curly-in-string
38
- */
39
- "no-template-curly-in-string": error,
40
- /**
41
- * Disallow loops with a body that allows only one iteration.
42
- *
43
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-unreachable-loop
44
- */
45
- "no-unreachable-loop": error
46
- }
5
+ /**
6
+ * @type {Linter.RulesRecord}
7
+ */
8
+ export const possibleErrorsRules = {
9
+ /**
10
+ * Disallow the use of console.
11
+ *
12
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-console
13
+ */
14
+ "no-console": "error",
15
+ /**
16
+ * Disallow expressions where the operation doesn't affect the value.
17
+ *
18
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-console
19
+ */
20
+ "no-constant-binary-expression": "error",
21
+ /**
22
+ * Disallow returning values from Promise executor functions.
23
+ *
24
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-promise-executor-return
25
+ */
26
+ "no-promise-executor-return": "error",
27
+ /**
28
+ * Disallow template literal placeholder syntax in regular strings, as
29
+ * these are likely errors.
30
+ *
31
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-template-curly-in-string
32
+ */
33
+ "no-template-curly-in-string": "error",
34
+ /**
35
+ * Disallow loops with a body that allows only one iteration.
36
+ *
37
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-unreachable-loop
38
+ */
39
+ "no-unreachable-loop": "error"
47
40
  };
@@ -1,117 +1,118 @@
1
- "use strict";
2
-
3
- const {
4
- levels: { off, warn, error }
5
- } = require("../constants");
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
6
4
 
7
5
  /**
8
6
  * These are enabled by `react/recommended`, but we've made the decision to
9
7
  * disable them.
8
+ *
9
+ * @type {Linter.RulesRecord}
10
10
  */
11
11
  const disabledRules = {
12
12
  // This is better handled by TypeScript.
13
- "react/no-unknown-property": off,
13
+ "react/no-unknown-property": "off",
14
14
  // This is better handled by TypeScript, and `prop-types` also bloats
15
15
  // the project's build size.
16
- "react/prop-types": off,
16
+ "react/prop-types": "off",
17
17
  // Disable requiring React to be imported, as this is no longer required.
18
- "react/react-in-jsx-scope": off
18
+ "react/react-in-jsx-scope": "off"
19
19
  };
20
20
 
21
- module.exports = {
22
- rules: {
23
- ...disabledRules,
24
- /**
25
- * Require an explicit type when using button elements.
26
- *
27
- * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
28
- */
29
- "react/button-has-type": warn,
30
- /**
31
- * Require consistent function type for function components.
32
- *
33
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
34
- */
35
- "react/function-component-definition": warn,
36
- /**
37
- * Require destructuring and symmetric naming of `useState` hook value and setter variables.
38
- *
39
- * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
40
- */
41
- "react/hook-use-state": warn,
42
- /**
43
- * Require consistent boolean attributes notation in JSX.
44
- *
45
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
46
- */
47
- "react/jsx-boolean-value": warn,
48
- /**
49
- * Disallow unnecessary curly braces in JSX props and children.
50
- *
51
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
52
- */
53
- "react/jsx-curly-brace-presence": warn,
54
- /**
55
- * Require using shorthand form for React fragments, unless required.
56
- *
57
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
58
- */
59
- "react/jsx-fragments": warn,
60
- /**
61
- * Prevent problematic leaked values from being rendered.
62
- *
63
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
64
- */
65
- "react/jsx-no-leaked-render": warn,
66
- /**
67
- * Prevents usage of unsafe `target='_blank'`.
68
- *
69
- * This rule is a part of `react/recommended`, but we've modified it to
70
- * allow referrer.
71
- *
72
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
73
- */
74
- "react/jsx-no-target-blank": [
75
- error,
76
- {
77
- allowReferrer: true
78
- }
79
- ],
80
- /**
81
- * Disallow empty React fragments.
82
- *
83
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
84
- */
85
- "react/jsx-no-useless-fragment": [warn, { allowExpressions: true }],
86
- /**
87
- * Require the use of PascalCase for user-defined JSX components.
88
- *
89
- * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
90
- */
91
- "react/jsx-pascal-case": warn,
92
- /**
93
- * Require props to be sorted alphabetically.
94
- *
95
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
96
- */
97
- "react/jsx-sort-props": warn,
98
- /**
99
- * Disallow usage of Array index in keys.
100
- *
101
- * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
102
- */
103
- "react/no-array-index-key": warn,
104
- /**
105
- * Disallow creating unstable components inside components.
106
- *
107
- * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
108
- */
109
- "react/no-unstable-nested-components": error,
110
- /**
111
- * Disallow closing tags for components without children.
112
- *
113
- * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
114
- */
115
- "react/self-closing-comp": warn
116
- }
21
+ /**
22
+ * @type {Linter.RulesRecord}
23
+ */
24
+ export const reactRules = {
25
+ ...disabledRules,
26
+ /**
27
+ * Require an explicit type when using button elements.
28
+ *
29
+ * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
30
+ */
31
+ "react/button-has-type": "warn",
32
+ /**
33
+ * Require consistent function type for function components.
34
+ *
35
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
36
+ */
37
+ "react/function-component-definition": "warn",
38
+ /**
39
+ * Require destructuring and symmetric naming of `useState` hook value and setter variables.
40
+ *
41
+ * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
42
+ */
43
+ "react/hook-use-state": "warn",
44
+ /**
45
+ * Require consistent boolean attributes notation in JSX.
46
+ *
47
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
48
+ */
49
+ "react/jsx-boolean-value": "warn",
50
+ /**
51
+ * Disallow unnecessary curly braces in JSX props and children.
52
+ *
53
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
54
+ */
55
+ "react/jsx-curly-brace-presence": "warn",
56
+ /**
57
+ * Require using shorthand form for React fragments, unless required.
58
+ *
59
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
60
+ */
61
+ "react/jsx-fragments": "warn",
62
+ /**
63
+ * Prevent problematic leaked values from being rendered.
64
+ *
65
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
66
+ */
67
+ "react/jsx-no-leaked-render": "warn",
68
+ /**
69
+ * Prevents usage of unsafe `target='_blank'`.
70
+ *
71
+ * This rule is a part of `react/recommended`, but we've modified it to
72
+ * allow referrer.
73
+ *
74
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
75
+ */
76
+ "react/jsx-no-target-blank": [
77
+ "error",
78
+ {
79
+ allowReferrer: true
80
+ }
81
+ ],
82
+ /**
83
+ * Disallow empty React fragments.
84
+ *
85
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
86
+ */
87
+ "react/jsx-no-useless-fragment": ["warn", { allowExpressions: true }],
88
+ /**
89
+ * Require the use of PascalCase for user-defined JSX components.
90
+ *
91
+ * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
92
+ */
93
+ "react/jsx-pascal-case": "warn",
94
+ /**
95
+ * Require props to be sorted alphabetically.
96
+ *
97
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
98
+ */
99
+ "react/jsx-sort-props": "warn",
100
+ /**
101
+ * Disallow usage of Array index in keys.
102
+ *
103
+ * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
104
+ */
105
+ "react/no-array-index-key": "warn",
106
+ /**
107
+ * Disallow creating unstable components inside components.
108
+ *
109
+ * 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
110
+ */
111
+ "react/no-unstable-nested-components": "error",
112
+ /**
113
+ * Disallow closing tags for components without children.
114
+ *
115
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
116
+ */
117
+ "react/self-closing-comp": "warn"
117
118
  };
@@ -1,86 +1,85 @@
1
- "use strict";
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
2
4
 
3
- const {
4
- levels: { warn, error }
5
- } = require("../constants");
6
-
7
- module.exports = {
8
- rules: {
9
- /**
10
- * Require camel case names.
11
- *
12
- * 🚫 Not fixable - https://eslint.org/docs/rules/camelcase
13
- */
14
- camelcase: [
15
- error,
16
- { allow: ["^UNSAFE_"], ignoreDestructuring: false, properties: "never" }
17
- ],
18
- /**
19
- * Require function expressions to have a name.
20
- *
21
- * 🚫 Not fixable - https://eslint.org/docs/rules/func-names
22
- */
23
- "func-names": [error, "as-needed"],
24
- /**
25
- * Require a capital letter for constructors.
26
- *
27
- * 🚫 Not fixable - https://eslint.org/docs/rules/new-cap
28
- */
29
- "new-cap": [error, { capIsNew: false }],
30
- /**
31
- * Disallow the omission of parentheses when invoking a constructor with
32
- * no arguments.
33
- *
34
- * 🔧 Fixable - https://eslint.org/docs/rules/new-parens
35
- */
36
- "new-parens": warn,
37
- /**
38
- * Disallow use of the Array constructor.
39
- *
40
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-array-constructor
41
- */
42
- "no-array-constructor": error,
43
- /**
44
- * Disallow use of bitwise operators.
45
- *
46
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-bitwise
47
- */
48
- "no-bitwise": error,
49
- /**
50
- * Disallow if as the only statement in an else block.
51
- *
52
- * 🔧 Fixable - https://eslint.org/docs/rules/no-lonely-if
53
- */
54
- "no-lonely-if": warn,
55
- /**
56
- * Disallow use of chained assignment expressions.
57
- *
58
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-multi-assign
59
- */
60
- "no-multi-assign": [error],
61
- /**
62
- * Disallow nested ternary expressions.
63
- *
64
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-nested-ternary
65
- */
66
- "no-nested-ternary": error,
67
- /**
68
- * Disallow ternary operators when simpler alternatives exist.
69
- *
70
- * 🚫 Not fixable - https://eslint.org/docs/rules/no-unneeded-ternary
71
- */
72
- "no-unneeded-ternary": error,
73
- /**
74
- * Require using arrow functions for callbacks.
75
- *
76
- * 🔧 Fixable - https://eslint.org/docs/rules/prefer-arrow-callback
77
- */
78
- "prefer-arrow-callback": [error, { allowNamedFunctions: true }],
79
- /**
80
- * Require use of an object spread over Object.assign.
81
- *
82
- * 🔧 Fixable - https://eslint.org/docs/rules/prefer-object-spread
83
- */
84
- "prefer-object-spread": warn
85
- }
5
+ /**
6
+ * @type {Linter.RulesRecord}
7
+ */
8
+ export const stylisticRules = {
9
+ /**
10
+ * Require camel case names.
11
+ *
12
+ * 🚫 Not fixable - https://eslint.org/docs/rules/camelcase
13
+ */
14
+ camelcase: [
15
+ "error",
16
+ { allow: ["^UNSAFE_"], ignoreDestructuring: false, properties: "never" }
17
+ ],
18
+ /**
19
+ * Require function expressions to have a name.
20
+ *
21
+ * 🚫 Not fixable - https://eslint.org/docs/rules/func-names
22
+ */
23
+ "func-names": ["error", "as-needed"],
24
+ /**
25
+ * Require a capital letter for constructors.
26
+ *
27
+ * 🚫 Not fixable - https://eslint.org/docs/rules/new-cap
28
+ */
29
+ "new-cap": ["error", { capIsNew: false }],
30
+ /**
31
+ * Disallow the omission of parentheses when invoking a constructor with
32
+ * no arguments.
33
+ *
34
+ * 🔧 Fixable - https://eslint.org/docs/rules/new-parens
35
+ */
36
+ "new-parens": "warn",
37
+ /**
38
+ * Disallow use of the Array constructor.
39
+ *
40
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-array-constructor
41
+ */
42
+ "no-array-constructor": "error",
43
+ /**
44
+ * Disallow use of bitwise operators.
45
+ *
46
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-bitwise
47
+ */
48
+ "no-bitwise": "error",
49
+ /**
50
+ * Disallow if as the only statement in an else block.
51
+ *
52
+ * 🔧 Fixable - https://eslint.org/docs/rules/no-lonely-if
53
+ */
54
+ "no-lonely-if": "warn",
55
+ /**
56
+ * Disallow use of chained assignment expressions.
57
+ *
58
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-multi-assign
59
+ */
60
+ "no-multi-assign": ["error"],
61
+ /**
62
+ * Disallow nested ternary expressions.
63
+ *
64
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-nested-ternary
65
+ */
66
+ "no-nested-ternary": "error",
67
+ /**
68
+ * Disallow ternary operators when simpler alternatives exist.
69
+ *
70
+ * 🚫 Not fixable - https://eslint.org/docs/rules/no-unneeded-ternary
71
+ */
72
+ "no-unneeded-ternary": "error",
73
+ /**
74
+ * Require using arrow functions for callbacks.
75
+ *
76
+ * 🔧 Fixable - https://eslint.org/docs/rules/prefer-arrow-callback
77
+ */
78
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
79
+ /**
80
+ * Require use of an object spread over Object.assign.
81
+ *
82
+ * 🔧 Fixable - https://eslint.org/docs/rules/prefer-object-spread
83
+ */
84
+ "prefer-object-spread": "warn"
86
85
  };
@@ -1,45 +1,61 @@
1
- "use strict";
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
2
4
 
3
- const {
4
- levels: { error }
5
- } = require("../../constants");
5
+ import { variablesRules } from "../variables.js";
6
6
 
7
7
  // These share identical configuration options, so we want to keep them in sync.
8
8
  // eslint-disable-next-line unicorn/prevent-abbreviations
9
- const noUnusedVarsConfig = require("../variables").rules["no-unused-vars"];
9
+ const noUnusedVarsOptions = variablesRules["no-unused-vars"];
10
10
 
11
- module.exports = {
12
- rules: {
13
- /**
14
- * Require default parameters to be last.
15
- *
16
- * 🚫 Not fixable - https://typescript-eslint.io/rules/default-param-last/
17
- */
18
- "@typescript-eslint/default-param-last": error,
19
- /**
20
- * Disallow creation of functions within loops.
21
- *
22
- * 🚫 Not fixable - https://typescript-eslint.io/rules/no-loop-func/
23
- */
24
- "@typescript-eslint/no-loop-func": error,
25
- /**
26
- * Disallow variable declarations from shadowing variables declared in the
27
- * outer scope.
28
- *
29
- * 🚫 Not fixable - https://typescript-eslint.io/rules/no-shadow/
30
- */
31
- "@typescript-eslint/no-shadow": error,
32
- /**
33
- * Disallow unused variables.
34
- *
35
- * 🚫 Not fixable - https://typescript-eslint.io/rules/no-unused-vars/
36
- */
37
- "@typescript-eslint/no-unused-vars": noUnusedVarsConfig,
38
- /**
39
- * Disallow unnecessary constructors.
40
- *
41
- * 🚫 Not fixable - https://typescript-eslint.io/rules/no-useless-constructor/
42
- */
43
- "@typescript-eslint/no-useless-constructor": error
44
- }
11
+ /**
12
+ * @type {Linter.RulesRecord}
13
+ */
14
+ export const typescriptExtensionRules = {
15
+ /**
16
+ * Require default parameters to be last.
17
+ *
18
+ * 🚫 Not fixable - https://typescript-eslint.io/rules/default-param-last/
19
+ */
20
+ "@typescript-eslint/default-param-last": "error",
21
+ /**
22
+ * Disallow accidentally using the "empty object" type (`{}`).
23
+ *
24
+ * 🔧 Partially fixable - https://typescript-eslint.io/rules/no-empty-object-type/
25
+ */
26
+ "@typescript-eslint/no-empty-object-type": [
27
+ "error",
28
+ {
29
+ // allow "single-extends" interfaces as they are often useful for
30
+ // documentation purposes and future extensibility
31
+ allowInterfaces: "with-single-extends",
32
+ // allow React-like props types
33
+ allowWithName: "Props$"
34
+ }
35
+ ],
36
+ /**
37
+ * Disallow creation of functions within loops.
38
+ *
39
+ * 🚫 Not fixable - https://typescript-eslint.io/rules/no-loop-func/
40
+ */
41
+ "@typescript-eslint/no-loop-func": "error",
42
+ /**
43
+ * Disallow variable declarations from shadowing variables declared in the
44
+ * outer scope.
45
+ *
46
+ * 🚫 Not fixable - https://typescript-eslint.io/rules/no-shadow/
47
+ */
48
+ "@typescript-eslint/no-shadow": "error",
49
+ /**
50
+ * Disallow unused variables.
51
+ *
52
+ * 🚫 Not fixable - https://typescript-eslint.io/rules/no-unused-vars/
53
+ */
54
+ "@typescript-eslint/no-unused-vars": noUnusedVarsOptions,
55
+ /**
56
+ * Disallow unnecessary constructors.
57
+ *
58
+ * 🚫 Not fixable - https://typescript-eslint.io/rules/no-useless-constructor/
59
+ */
60
+ "@typescript-eslint/no-useless-constructor": "error"
45
61
  };