@haltcase/style 7.0.0-canary.4 → 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.
@@ -1,17 +1,17 @@
1
- import { FlatCompat } from "@eslint/eslintrc";
1
+ import eslintPluginReact from "@eslint-react/eslint-plugin";
2
+ import eslintStylisticJsx from "@stylistic/eslint-plugin-jsx";
2
3
  import eslintPluginImportX from "eslint-plugin-import-x";
3
4
  import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y";
4
- import eslintPluginReact from "eslint-plugin-react";
5
- // @ts-ignore
5
+ import eslintPluginReactOriginal from "eslint-plugin-react";
6
6
  import eslintPluginReactHooks from "eslint-plugin-react-hooks";
7
7
  import { config } from "typescript-eslint";
8
8
 
9
9
  import { jsxA11yRules } from "../rules/jsx-a11y.js";
10
10
  import { reactRules } from "../rules/react.js";
11
+ import { reactXRules } from "../rules/react-x.js";
12
+ import { stylisticJsxRules } from "../rules/stylistic-jsx.js";
11
13
  import { getEslintBaseConfig } from "./internal/base.js";
12
14
 
13
- const compat = new FlatCompat();
14
-
15
15
  /**
16
16
  * @param {import("./internal/base.js").HaltcaseStyleOptions} [options]
17
17
  */
@@ -29,21 +29,39 @@ export const getEslintReactConfigInternal = (_options = {}) =>
29
29
  name: "@haltcase/react",
30
30
 
31
31
  extends: [
32
- // @ts-ignore the modules types are incorrect
33
32
  {
34
- name: "@haltcase/react/recommended",
35
- ...eslintPluginReact.configs.flat.recommended
33
+ ...eslintPluginReact.configs["recommended-type-checked"],
34
+ name: "@haltcase/react/recommended-type-checked"
36
35
  },
37
- // @ts-ignore the modules types are incorrect
36
+
37
+ {
38
+ name: "@haltcase/react/jsx-eslint/react",
39
+ plugins: {
40
+ react: eslintPluginReactOriginal
41
+ },
42
+ rules: {
43
+ ...reactRules
44
+ }
45
+ },
46
+
38
47
  {
39
- name: "@haltcase/react/jsx-runtime",
40
- ...eslintPluginReact.configs.flat["jsx-runtime"]
48
+ name: "@haltcase/react/stylistic",
49
+ plugins: {
50
+ "@stylistic/jsx": eslintStylisticJsx
51
+ },
52
+ rules: {
53
+ ...stylisticJsxRules
54
+ }
41
55
  },
42
56
 
43
57
  {
44
58
  name: "@haltcase/react/hooks",
45
- // @ts-ignore the modules types are incorrect
46
- ...compat.config(eslintPluginReactHooks.configs.recommended)
59
+ plugins: {
60
+ "react-hooks": eslintPluginReactHooks
61
+ },
62
+ rules: {
63
+ ...eslintPluginReactHooks.configs.recommended.rules
64
+ }
47
65
  },
48
66
 
49
67
  {
@@ -62,7 +80,7 @@ export const getEslintReactConfigInternal = (_options = {}) =>
62
80
  },
63
81
 
64
82
  rules: {
65
- ...reactRules,
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
+ };
@@ -3,116 +3,16 @@
3
3
  */
4
4
 
5
5
  /**
6
- * These are enabled by `react/recommended`, but we've made the decision to
7
- * disable them.
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
- * 🔧 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"
17
+ "react/function-component-definition": "warn"
118
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
+ };
@@ -57,5 +57,18 @@ export const typescriptExtensionRules = {
57
57
  *
58
58
  * 🚫 Not fixable - https://typescript-eslint.io/rules/no-useless-constructor/
59
59
  */
60
- "@typescript-eslint/no-useless-constructor": "error"
60
+ "@typescript-eslint/no-useless-constructor": "error",
61
+ /**
62
+ * Enforce template literal expressions to be of string type.
63
+ *
64
+ * 🚫 Not fixable - https://typescript-eslint.io/rules/restrict-template-expressions/
65
+ */
66
+ "@typescript-eslint/restrict-template-expressions": [
67
+ "error",
68
+ {
69
+ allow: [{ from: "lib", name: ["Error", "URL", "URLSearchParams"] }],
70
+ allowBoolean: true,
71
+ allowNumber: true
72
+ }
73
+ ]
61
74
  };
@@ -92,6 +92,7 @@ export const typescriptBaseRules = {
92
92
  "error",
93
93
  {
94
94
  ignorePrimitives: {
95
+ number: true,
95
96
  string: true
96
97
  }
97
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haltcase/style",
3
- "version": "7.0.0-canary.4",
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
- "@next/eslint-plugin-next": "^15.0.2",
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.0",
70
+ "eslint-plugin-import-x": "^4.4.3",
69
71
  "eslint-plugin-jsx-a11y": "^6.10.2",
70
- "eslint-plugin-playwright": "^2.0.0",
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.6.0",
75
+ "eslint-plugin-regexp": "^2.7.0",
74
76
  "eslint-plugin-simple-import-sort": "^12.1.1",
75
- "eslint-plugin-testing-library": "^6.4.0",
76
- "eslint-plugin-tsdoc": "^0.3.0",
77
- "eslint-plugin-unicorn": "^56.0.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.3",
80
- "prettier-plugin-tailwindcss": "^0.6.8",
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.12.2"
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.5.0",
92
- "@commitlint/config-conventional": "^19.5.0",
93
- "@eslint/eslintrc": "^3.1.0",
94
- "@eslint/js": "^9.14.0",
95
- "@octokit/types": "^13.6.1",
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.12.2",
101
- "eslint": "^9.14.0",
102
+ "@typescript-eslint/types": "^8.16.0",
103
+ "eslint": "^9.15.0",
102
104
  "eslint-define-config": "^2.1.0",
103
- "globals": "^15.11.0",
104
- "husky": "^9.1.6",
105
+ "globals": "^15.12.0",
106
+ "husky": "^9.1.7",
105
107
  "lint-staged": "^15.2.10",
106
- "prettier": "^3.3.3",
108
+ "prettier": "^3.4.1",
107
109
  "semantic-release": "^24.2.0",
108
110
  "stylelint": "^16.10.0",
109
- "typescript": "^5.6.3"
111
+ "typescript": "^5.7.2"
110
112
  },
111
113
  "peerDependencies": {
112
114
  "eslint": ">=9",