@haltcase/style 7.0.0-canary.5 → 7.0.0-canary.6
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/eslint/configs/react.js +26 -8
- package/eslint/rules/react-x.js +67 -0
- package/eslint/rules/react.js +3 -105
- package/eslint/rules/stylistic-jsx.js +17 -0
- package/package.json +24 -22
package/eslint/configs/react.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import eslintPluginReact from "@eslint-react/eslint-plugin";
|
|
2
|
+
import eslintStylisticJsx from "@stylistic/eslint-plugin-jsx";
|
|
1
3
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
2
4
|
import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y";
|
|
3
|
-
import
|
|
5
|
+
import eslintPluginReactOriginal from "eslint-plugin-react";
|
|
4
6
|
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
|
|
5
7
|
import { config } from "typescript-eslint";
|
|
6
8
|
|
|
7
9
|
import { jsxA11yRules } from "../rules/jsx-a11y.js";
|
|
8
10
|
import { reactRules } from "../rules/react.js";
|
|
11
|
+
import { reactXRules } from "../rules/react-x.js";
|
|
12
|
+
import { stylisticJsxRules } from "../rules/stylistic-jsx.js";
|
|
9
13
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
10
14
|
|
|
11
15
|
/**
|
|
@@ -25,15 +29,29 @@ export const getEslintReactConfigInternal = (_options = {}) =>
|
|
|
25
29
|
name: "@haltcase/react",
|
|
26
30
|
|
|
27
31
|
extends: [
|
|
28
|
-
// @ts-ignore the modules types are incorrect
|
|
29
32
|
{
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
...eslintPluginReact.configs["recommended-type-checked"],
|
|
34
|
+
name: "@haltcase/react/recommended-type-checked"
|
|
32
35
|
},
|
|
33
|
-
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
name: "@haltcase/react/jsx-eslint/react",
|
|
39
|
+
plugins: {
|
|
40
|
+
react: eslintPluginReactOriginal
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
...reactRules
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
34
47
|
{
|
|
35
|
-
name: "@haltcase/react/
|
|
36
|
-
|
|
48
|
+
name: "@haltcase/react/stylistic",
|
|
49
|
+
plugins: {
|
|
50
|
+
"@stylistic/jsx": eslintStylisticJsx
|
|
51
|
+
},
|
|
52
|
+
rules: {
|
|
53
|
+
...stylisticJsxRules
|
|
54
|
+
}
|
|
37
55
|
},
|
|
38
56
|
|
|
39
57
|
{
|
|
@@ -62,7 +80,7 @@ export const getEslintReactConfigInternal = (_options = {}) =>
|
|
|
62
80
|
},
|
|
63
81
|
|
|
64
82
|
rules: {
|
|
65
|
-
...
|
|
83
|
+
...reactXRules,
|
|
66
84
|
...jsxA11yRules
|
|
67
85
|
}
|
|
68
86
|
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { Linter } from "eslint"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Additional rules to enable on top of the preset config from
|
|
7
|
+
* `@eslint-react/eslint-plugin`
|
|
8
|
+
*
|
|
9
|
+
* @type {Linter.RulesRecord}
|
|
10
|
+
*/
|
|
11
|
+
export const reactXRules = {
|
|
12
|
+
/**
|
|
13
|
+
* Prevents using useless `fragment` components or `<>` syntax.
|
|
14
|
+
*
|
|
15
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/no-useless-fragment
|
|
16
|
+
*/
|
|
17
|
+
"no-useless-fragment": "error",
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enforces using shorthand syntax for boolean attributes.
|
|
21
|
+
*
|
|
22
|
+
* 🔧 Fixable - https://eslint-react.xyz/docs/rules/prefer-shorthand-boolean
|
|
23
|
+
*/
|
|
24
|
+
"prefer-shorthand-boolean": "error",
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Enforces using shorthand syntax for fragments.
|
|
28
|
+
*
|
|
29
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/prefer-shorthand-fragment
|
|
30
|
+
*/
|
|
31
|
+
"prefer-shorthand-fragment": "error",
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Warns function calls made inside `useState` calls.
|
|
35
|
+
*
|
|
36
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization
|
|
37
|
+
*/
|
|
38
|
+
"hooks-extra/prefer-use-state-lazy-initialization": "error",
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Enforces naming conventions for components.
|
|
42
|
+
*
|
|
43
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-component-name
|
|
44
|
+
*/
|
|
45
|
+
"naming-convention/component-name": "warn",
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Enforces naming convention for JSX files.
|
|
49
|
+
*
|
|
50
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-filename
|
|
51
|
+
*/
|
|
52
|
+
"naming-convention/filename": "warn",
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Enforces consistent use of the JSX file extension.
|
|
56
|
+
*
|
|
57
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-filename-extension
|
|
58
|
+
*/
|
|
59
|
+
"naming-convention/filename-extension": "warn",
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Enforces destructuring and symmetric naming of useState hook value and setter variables.
|
|
63
|
+
*
|
|
64
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-use-state
|
|
65
|
+
*/
|
|
66
|
+
"naming-convention/use-state": "warn"
|
|
67
|
+
};
|
package/eslint/rules/react.js
CHANGED
|
@@ -3,118 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
8
|
*
|
|
9
9
|
* @type {Linter.RulesRecord}
|
|
10
10
|
*/
|
|
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
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @type {Linter.RulesRecord}
|
|
23
|
-
*/
|
|
24
11
|
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
12
|
/**
|
|
33
13
|
* Require consistent function type for function components.
|
|
34
14
|
*
|
|
35
15
|
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
|
|
36
16
|
*/
|
|
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
|
-
* Disabled because it can be annoying when enabled while not having a lot of upside.
|
|
98
|
-
*
|
|
99
|
-
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
100
|
-
*/
|
|
101
|
-
"react/jsx-sort-props": "off",
|
|
102
|
-
/**
|
|
103
|
-
* Disallow usage of Array index in keys.
|
|
104
|
-
*
|
|
105
|
-
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
106
|
-
*/
|
|
107
|
-
"react/no-array-index-key": "warn",
|
|
108
|
-
/**
|
|
109
|
-
* Disallow creating unstable components inside components.
|
|
110
|
-
*
|
|
111
|
-
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
112
|
-
*/
|
|
113
|
-
"react/no-unstable-nested-components": "error",
|
|
114
|
-
/**
|
|
115
|
-
* Disallow closing tags for components without children.
|
|
116
|
-
*
|
|
117
|
-
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
118
|
-
*/
|
|
119
|
-
"react/self-closing-comp": "warn"
|
|
17
|
+
"react/function-component-definition": "warn"
|
|
120
18
|
};
|
|
@@ -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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haltcase/style",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.6",
|
|
4
4
|
"description": "haltcase's web ecosystem style guide & configurations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -61,52 +61,54 @@
|
|
|
61
61
|
"@babel/core": "^7.26.0",
|
|
62
62
|
"@babel/eslint-parser": "^7.25.9",
|
|
63
63
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
64
|
-
"@
|
|
64
|
+
"@eslint-react/eslint-plugin": "^1.17.1",
|
|
65
|
+
"@next/eslint-plugin-next": "^15.0.3",
|
|
66
|
+
"@stylistic/eslint-plugin-jsx": "^2.11.0",
|
|
65
67
|
"eslint-config-prettier": "^9.1.0",
|
|
66
68
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
67
69
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
68
|
-
"eslint-plugin-import-x": "^4.4.
|
|
70
|
+
"eslint-plugin-import-x": "^4.4.3",
|
|
69
71
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
70
|
-
"eslint-plugin-playwright": "^2.
|
|
72
|
+
"eslint-plugin-playwright": "^2.1.0",
|
|
71
73
|
"eslint-plugin-react": "^7.37.2",
|
|
72
74
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
73
|
-
"eslint-plugin-regexp": "^2.
|
|
75
|
+
"eslint-plugin-regexp": "^2.7.0",
|
|
74
76
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
75
|
-
"eslint-plugin-testing-library": "^6.
|
|
76
|
-
"eslint-plugin-tsdoc": "^0.
|
|
77
|
-
"eslint-plugin-unicorn": "^56.0.
|
|
77
|
+
"eslint-plugin-testing-library": "^6.5.0",
|
|
78
|
+
"eslint-plugin-tsdoc": "^0.4.0",
|
|
79
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
78
80
|
"postcss-html": "^1.7.0",
|
|
79
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
80
|
-
"prettier-plugin-tailwindcss": "^0.6.
|
|
81
|
+
"prettier-plugin-packagejson": "^2.5.6",
|
|
82
|
+
"prettier-plugin-tailwindcss": "^0.6.9",
|
|
81
83
|
"stylelint-config-clean-order": "^6.1.0",
|
|
82
84
|
"stylelint-config-html": "^1.1.0",
|
|
83
85
|
"stylelint-config-standard": "^36.0.1",
|
|
84
86
|
"stylelint-define-config": "^1.7.0",
|
|
85
|
-
"typescript-eslint": "^8.
|
|
87
|
+
"typescript-eslint": "^8.16.0"
|
|
86
88
|
},
|
|
87
89
|
"devDependencies": {
|
|
88
90
|
"@actions/core": "^1.11.1",
|
|
89
91
|
"@actions/exec": "^1.1.1",
|
|
90
92
|
"@actions/github": "^6.0.0",
|
|
91
|
-
"@commitlint/cli": "^19.
|
|
92
|
-
"@commitlint/config-conventional": "^19.
|
|
93
|
-
"@eslint/eslintrc": "^3.
|
|
94
|
-
"@eslint/js": "^9.
|
|
95
|
-
"@octokit/types": "^13.6.
|
|
93
|
+
"@commitlint/cli": "^19.6.0",
|
|
94
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
95
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
96
|
+
"@eslint/js": "^9.15.0",
|
|
97
|
+
"@octokit/types": "^13.6.2",
|
|
96
98
|
"@semantic-release/git": "^10.0.1",
|
|
97
99
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
98
100
|
"@types/eslint__js": "^8.42.3",
|
|
99
101
|
"@types/node": "22",
|
|
100
|
-
"@typescript-eslint/types": "^8.
|
|
101
|
-
"eslint": "^9.
|
|
102
|
+
"@typescript-eslint/types": "^8.16.0",
|
|
103
|
+
"eslint": "^9.15.0",
|
|
102
104
|
"eslint-define-config": "^2.1.0",
|
|
103
|
-
"globals": "^15.
|
|
104
|
-
"husky": "^9.1.
|
|
105
|
+
"globals": "^15.12.0",
|
|
106
|
+
"husky": "^9.1.7",
|
|
105
107
|
"lint-staged": "^15.2.10",
|
|
106
|
-
"prettier": "^3.
|
|
108
|
+
"prettier": "^3.4.1",
|
|
107
109
|
"semantic-release": "^24.2.0",
|
|
108
110
|
"stylelint": "^16.10.0",
|
|
109
|
-
"typescript": "^5.
|
|
111
|
+
"typescript": "^5.7.2"
|
|
110
112
|
},
|
|
111
113
|
"peerDependencies": {
|
|
112
114
|
"eslint": ">=9",
|