@haltcase/style 6.2.1 → 7.0.0-canary.10

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 (61) hide show
  1. package/eslint/configs/browser.js +27 -0
  2. package/eslint/configs/cjs.js +13 -0
  3. package/eslint/configs/internal/base.js +178 -0
  4. package/eslint/configs/internal/commonjs.js +22 -0
  5. package/eslint/{rules → configs/internal}/es2015.js +17 -16
  6. package/eslint/configs/internal/simple-import-sort.js +27 -0
  7. package/eslint/configs/internal/tsdoc.js +20 -0
  8. package/eslint/{rules → configs/internal}/unicorn.js +118 -126
  9. package/eslint/configs/next.js +50 -0
  10. package/eslint/configs/node.js +27 -0
  11. package/eslint/configs/playwright-test.js +21 -0
  12. package/eslint/configs/react.js +109 -0
  13. package/eslint/configs/typescript.js +106 -0
  14. package/eslint/constants.js +23 -28
  15. package/eslint/index.js +33 -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-x.js +78 -0
  22. package/eslint/rules/react.js +20 -113
  23. package/eslint/rules/stylistic-jsx.js +17 -0
  24. package/eslint/rules/stylistic.js +83 -84
  25. package/eslint/rules/typescript/extension.js +68 -39
  26. package/eslint/rules/typescript/import.js +16 -15
  27. package/eslint/rules/typescript/index.js +110 -121
  28. package/eslint/rules/typescript/naming-convention.js +121 -0
  29. package/eslint/rules/variables.js +34 -34
  30. package/eslint/withFiles.js +15 -0
  31. package/package.json +53 -59
  32. package/prettier/index.js +4 -11
  33. package/readme.md +183 -98
  34. package/stylelint/_base.js +2 -4
  35. package/stylelint/index.js +6 -7
  36. package/stylelint/modules.js +7 -8
  37. package/stylelint/standard.js +2 -5
  38. package/typescript/tsconfig.base.json +2 -1
  39. package/typescript/tsconfig.bundler.json +7 -3
  40. package/typescript/tsconfig.next.json +14 -6
  41. package/typescript/tsconfig.node.json +1 -1
  42. package/typescript/tsconfig.node18.json +4 -7
  43. package/typescript/tsconfig.node20.json +4 -7
  44. package/typescript/tsconfig.node22.json +10 -0
  45. package/typescript/tsconfig.web.json +1 -1
  46. package/eslint/_base.js +0 -82
  47. package/eslint/astro.js +0 -40
  48. package/eslint/browser.js +0 -8
  49. package/eslint/cjs.js +0 -12
  50. package/eslint/jest.js +0 -28
  51. package/eslint/next.js +0 -38
  52. package/eslint/node.js +0 -8
  53. package/eslint/playwright-test.js +0 -8
  54. package/eslint/react.js +0 -18
  55. package/eslint/rules/import.js +0 -92
  56. package/eslint/rules/jest.js +0 -28
  57. package/eslint/rules/simple-import-sort.js +0 -23
  58. package/eslint/rules/tsdoc.js +0 -17
  59. package/eslint/rules/typescript/strict.js +0 -18
  60. package/eslint/typescript.js +0 -26
  61. 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
  };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
4
+
5
+ /**
6
+ * Rules we've decided to disable from the preset config.
7
+ *
8
+ * @type {Linter.RulesRecord}
9
+ */
10
+ const disabledRules = {
11
+ /**
12
+ * Enforces that function components props are read-only.
13
+ *
14
+ * We have other checks that already disallow changing function parameters.
15
+ *
16
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/prefer-read-only-props
17
+ */
18
+ "@eslint-react/prefer-read-only-props": "off"
19
+ };
20
+
21
+ /**
22
+ * Additional rules to enable on top of the preset config from
23
+ * `@eslint-react/eslint-plugin`
24
+ *
25
+ * @type {Linter.RulesRecord}
26
+ */
27
+ export const reactXRules = {
28
+ ...disabledRules,
29
+
30
+ /**
31
+ * Prevents using useless `fragment` components or `<>` syntax.
32
+ *
33
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/no-useless-fragment
34
+ */
35
+ "@eslint-react/no-useless-fragment": "error",
36
+
37
+ /**
38
+ * Enforces using shorthand syntax for boolean attributes.
39
+ *
40
+ * 🔧 Fixable - https://eslint-react.xyz/docs/rules/prefer-shorthand-boolean
41
+ */
42
+ "@eslint-react/prefer-shorthand-boolean": "error",
43
+
44
+ /**
45
+ * Enforces using shorthand syntax for fragments.
46
+ *
47
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/prefer-shorthand-fragment
48
+ */
49
+ "@eslint-react/prefer-shorthand-fragment": "error",
50
+
51
+ /**
52
+ * Warns function calls made inside `useState` calls.
53
+ *
54
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization
55
+ */
56
+ "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "error",
57
+
58
+ /**
59
+ * Enforces naming conventions for components.
60
+ *
61
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-component-name
62
+ */
63
+ "@eslint-react/naming-convention/component-name": "warn",
64
+
65
+ /**
66
+ * Enforces consistent use of the JSX file extension.
67
+ *
68
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-filename-extension
69
+ */
70
+ "@eslint-react/naming-convention/filename-extension": "warn",
71
+
72
+ /**
73
+ * Enforces destructuring and symmetric naming of useState hook value and setter variables.
74
+ *
75
+ * 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-use-state
76
+ */
77
+ "@eslint-react/naming-convention/use-state": "warn"
78
+ };
@@ -1,117 +1,24 @@
1
- "use strict";
2
-
3
- const {
4
- levels: { off, warn, error }
5
- } = require("../constants");
6
-
7
1
  /**
8
- * These are enabled by `react/recommended`, but we've made the decision to
9
- * disable them.
2
+ * @import { Linter } from "eslint"
10
3
  */
11
- const disabledRules = {
12
- // This is better handled by TypeScript.
13
- "react/no-unknown-property": off,
14
- // This is better handled by TypeScript, and `prop-types` also bloats
15
- // the project's build size.
16
- "react/prop-types": off,
17
- // Disable requiring React to be imported, as this is no longer required.
18
- "react/react-in-jsx-scope": off
19
- };
20
4
 
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
- }
5
+ /**
6
+ * We primarily use `@eslint-react/eslint-plugin`, but it's not quite complete
7
+ * compared to the official plugin. We enable missing rules selectively here.
8
+ *
9
+ * @type {Linter.RulesRecord}
10
+ */
11
+ export const reactRules = {
12
+ /**
13
+ * Require consistent function type for function components.
14
+ *
15
+ * 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
16
+ */
17
+ "react/function-component-definition": [
18
+ "error",
19
+ {
20
+ namedComponents: "arrow-function",
21
+ unnamedComponents: "arrow-function"
22
+ }
23
+ ]
117
24
  };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @import { Linter } from "eslint"
3
+ */
4
+
5
+ /**
6
+ * @type {Linter.RulesRecord}
7
+ */
8
+ export const stylisticJsxRules = {
9
+ /**
10
+ * Disallow extra closing tags for components without children.
11
+ *
12
+ * Components without children can be self-closed to avoid unnecessary extra closing tag.
13
+ *
14
+ * 🔧 Fixable - https://eslint.style/rules/jsx/jsx-self-closing-comp
15
+ */
16
+ "@stylistic/jsx/jsx-self-closing-comp": "error"
17
+ };
@@ -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
  };