@jimmy.codes/eslint-config 5.5.0 → 5.7.0

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/dist/index.js CHANGED
@@ -108,7 +108,7 @@ var importsTypescriptConfig = () => {
108
108
  ];
109
109
  };
110
110
  var importsConfig = ({
111
- typescript = false
111
+ isTypescriptEnabled = false
112
112
  } = {}) => {
113
113
  return [
114
114
  {
@@ -119,7 +119,7 @@ var importsConfig = ({
119
119
  },
120
120
  rules: importsRules
121
121
  },
122
- ...typescript ? importsTypescriptConfig() : []
122
+ ...isTypescriptEnabled ? importsTypescriptConfig() : []
123
123
  ];
124
124
  };
125
125
 
@@ -577,20 +577,20 @@ var defineConfig = async ({
577
577
  eslintCommentsConfig(),
578
578
  regexpConfig(),
579
579
  jsdocConfig(),
580
- importsConfig({ typescript: isTypescriptEnabled }),
580
+ importsConfig({ isTypescriptEnabled }),
581
581
  stylisticConfig()
582
582
  ];
583
583
  const featureConfigs = await Promise.all([
584
584
  isTypescriptEnabled && unwrap(import("./typescript-IBCLQD7Q.js")),
585
- isReactEnabled && unwrap(import("./react-X5DWOH4Y.js")),
585
+ isReactEnabled && unwrap(import("./react-NYHAKXFD.js")),
586
586
  isTanstackQueryEnabled && unwrap(import("./tanstack-query-P4IBOLDK.js")),
587
587
  isAstroEnabled && unwrap(import("./astro-Z5RFF624.js")),
588
588
  isJestEnabled && unwrap(import("./jest-AHG2WRSU.js")),
589
589
  isVitestEnabled && unwrap(import("./vitest-YI6KNRZE.js")),
590
590
  isTestingLibraryEnabled && unwrap(import("./testing-library-7RTMAEOX.js")),
591
591
  isPlaywrightEnabled && unwrap(import("./playwright-U4PCWDYV.js")),
592
- isStorybookEnabled && unwrap(import("./storybook-4KS3DD3C.js")),
593
- isNextjsEnabled && unwrap(import("./nextjs-RCR4GYMK.js"))
592
+ isStorybookEnabled && unwrap(import("./storybook-IPSVKYYB.js")),
593
+ isNextjsEnabled && unwrap(import("./nextjs-7V464KOE.js"))
594
594
  ]);
595
595
  return [
596
596
  ...baseConfigs,
@@ -1,6 +1,6 @@
1
1
  import {
2
- warningAsErrors
3
- } from "./chunk-BJU7UEJ3.js";
2
+ upwarn
3
+ } from "./chunk-BDIXPIKB.js";
4
4
  import {
5
5
  interopDefault
6
6
  } from "./chunk-72FT76PY.js";
@@ -11,9 +11,7 @@ import {
11
11
  // src/rules/nextjs.ts
12
12
  var nextjsRules = async () => {
13
13
  const nextjsPlugin = await interopDefault(import("@next/eslint-plugin-next"));
14
- return warningAsErrors(
15
- nextjsPlugin.configs.recommended.rules
16
- );
14
+ return upwarn(nextjsPlugin.configs.recommended.rules);
17
15
  };
18
16
 
19
17
  // src/configs/nextjs.ts
@@ -0,0 +1,124 @@
1
+ import {
2
+ upwarn
3
+ } from "./chunk-BDIXPIKB.js";
4
+ import {
5
+ hasNext,
6
+ hasTypescript,
7
+ hasVite
8
+ } from "./chunk-OCS4JNPP.js";
9
+ import {
10
+ interopDefault
11
+ } from "./chunk-72FT76PY.js";
12
+ import {
13
+ GLOB_JSX,
14
+ GLOB_TSX
15
+ } from "./chunk-N5KZEOXT.js";
16
+
17
+ // src/configs/react.ts
18
+ import globals from "globals";
19
+
20
+ // src/rules/react.ts
21
+ var nextAllowedExportNames = [
22
+ "dynamic",
23
+ "dynamicParams",
24
+ "revalidate",
25
+ "fetchCache",
26
+ "runtime",
27
+ "preferredRegion",
28
+ "maxDuration",
29
+ "config",
30
+ "generateStaticParams",
31
+ "metadata",
32
+ "generateMetadata",
33
+ "viewport",
34
+ "generateViewport"
35
+ ];
36
+ var reactRules = async () => {
37
+ const [{ configs: reactConfigs }, jsxA11yPlugin] = await Promise.all([
38
+ interopDefault(import("@eslint-react/eslint-plugin")),
39
+ interopDefault(import("eslint-plugin-jsx-a11y"))
40
+ ]);
41
+ const isUsingNextjs = hasNext();
42
+ const isUsingVite = hasVite();
43
+ const isUsingTypesScript = hasTypescript();
44
+ const reactPluginRules = isUsingTypesScript ? reactConfigs["recommended-type-checked"].rules : reactConfigs.recommended.rules;
45
+ return {
46
+ ...jsxA11yPlugin.configs.recommended.rules,
47
+ ...upwarn(reactPluginRules),
48
+ "@eslint-react/avoid-shorthand-boolean": "off",
49
+ "@eslint-react/avoid-shorthand-fragment": "off",
50
+ "@eslint-react/hooks-extra/no-unnecessary-use-callback": "error",
51
+ "@eslint-react/hooks-extra/no-unnecessary-use-memo": "error",
52
+ "@eslint-react/hooks-extra/no-unnecessary-use-prefix": "error",
53
+ "@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "error",
54
+ "@eslint-react/no-children-prop": "error",
55
+ "@eslint-react/no-complex-conditional-rendering": "error",
56
+ "@eslint-react/prefer-react-namespace-import": "error",
57
+ "@eslint-react/prefer-shorthand-boolean": "error",
58
+ "@eslint-react/prefer-shorthand-fragment": "error",
59
+ "react-compiler/react-compiler": "error",
60
+ "react-hooks/exhaustive-deps": "error",
61
+ "react-hooks/rules-of-hooks": "error",
62
+ "react-refresh/only-export-components": [
63
+ "warn",
64
+ {
65
+ allowConstantExport: isUsingVite,
66
+ allowExportNames: isUsingNextjs ? nextAllowedExportNames : []
67
+ }
68
+ ]
69
+ };
70
+ };
71
+
72
+ // src/configs/react.ts
73
+ async function reactConfig() {
74
+ const [
75
+ reactPlugin,
76
+ jsxA11yPlugin,
77
+ reactHooksPlugin,
78
+ reactRefreshPlugin,
79
+ reactCompilerPlugin
80
+ ] = await Promise.all([
81
+ interopDefault(import("@eslint-react/eslint-plugin")),
82
+ interopDefault(import("eslint-plugin-jsx-a11y")),
83
+ import("eslint-plugin-react-hooks"),
84
+ interopDefault(import("eslint-plugin-react-refresh")),
85
+ import("eslint-plugin-react-compiler")
86
+ ]);
87
+ const reactPlugins = reactPlugin.configs.all.plugins;
88
+ return [
89
+ {
90
+ files: [GLOB_JSX, GLOB_TSX],
91
+ languageOptions: {
92
+ globals: {
93
+ ...globals.browser
94
+ },
95
+ parserOptions: {
96
+ ecmaFeatures: {
97
+ jsx: true
98
+ },
99
+ jsxPragma: null
100
+ }
101
+ },
102
+ name: "jimmy.codes/react",
103
+ plugins: {
104
+ "@eslint-react": reactPlugins["@eslint-react"],
105
+ "@eslint-react/dom": reactPlugins["@eslint-react/dom"],
106
+ "@eslint-react/hooks-extra": reactPlugins["@eslint-react/hooks-extra"],
107
+ "@eslint-react/web-api": reactPlugins["@eslint-react/web-api"],
108
+ "jsx-a11y": jsxA11yPlugin,
109
+ "react-compiler": reactCompilerPlugin,
110
+ "react-hooks": reactHooksPlugin,
111
+ "react-refresh": reactRefreshPlugin
112
+ },
113
+ rules: await reactRules(),
114
+ settings: {
115
+ react: {
116
+ version: "detect"
117
+ }
118
+ }
119
+ }
120
+ ];
121
+ }
122
+ export {
123
+ reactConfig as default
124
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
- warningAsErrors
3
- } from "./chunk-BJU7UEJ3.js";
2
+ upwarn
3
+ } from "./chunk-BDIXPIKB.js";
4
4
  import {
5
5
  interopDefault
6
6
  } from "./chunk-72FT76PY.js";
@@ -18,7 +18,7 @@ async function storybookConfig() {
18
18
  files: storiesConfig?.files,
19
19
  name: "jimmy.codes/storybook/stories-rules",
20
20
  rules: {
21
- ...warningAsErrors(storiesConfig?.rules),
21
+ ...upwarn(storiesConfig?.rules),
22
22
  "import-x/no-anonymous-default-export": "off",
23
23
  "unicorn/no-anonymous-default-export": "off"
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jimmy.codes/eslint-config",
3
- "version": "5.5.0",
3
+ "version": "5.7.0",
4
4
  "description": "A pragmatic and opinionated ESLint config for modern development.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -24,6 +24,8 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
27
+ "@eslint-react/eslint-plugin": "^1.37.3",
28
+ "@eslint-react/shared": "^1.37.3",
27
29
  "@eslint/js": "^9.22.0",
28
30
  "@next/eslint-plugin-next": "^15.2.3",
29
31
  "@stylistic/eslint-plugin": "^4.2.0",
@@ -44,7 +46,6 @@
44
46
  "eslint-plugin-n": "^17.16.2",
45
47
  "eslint-plugin-perfectionist": "^4.10.1",
46
48
  "eslint-plugin-playwright": "^2.2.0",
47
- "eslint-plugin-react": "^7.37.4",
48
49
  "eslint-plugin-react-compiler": "19.0.0-beta-3229e95-20250315",
49
50
  "eslint-plugin-react-hooks": "^5.2.0",
50
51
  "eslint-plugin-react-refresh": "0.4.19",
@@ -1,189 +0,0 @@
1
- import {
2
- hasNext,
3
- hasVite
4
- } from "./chunk-OCS4JNPP.js";
5
- import {
6
- interopDefault
7
- } from "./chunk-72FT76PY.js";
8
- import {
9
- GLOB_JSX,
10
- GLOB_TSX
11
- } from "./chunk-N5KZEOXT.js";
12
-
13
- // src/configs/react.ts
14
- import globals from "globals";
15
-
16
- // src/utils/normalize-rule-entries.ts
17
- var toStringSeverity = (option) => {
18
- return option === 2 ? "error" : option === 1 ? "warn" : "off";
19
- };
20
- var normalizeRuleEntries = (rules = {}) => {
21
- return Object.fromEntries(
22
- Object.entries(rules).map(([rule, option]) => {
23
- return [
24
- rule,
25
- typeof option === "number" ? toStringSeverity(option) : option
26
- ];
27
- })
28
- );
29
- };
30
-
31
- // src/rules/react.ts
32
- var nextAllowedExportNames = [
33
- "dynamic",
34
- "dynamicParams",
35
- "revalidate",
36
- "fetchCache",
37
- "runtime",
38
- "preferredRegion",
39
- "maxDuration",
40
- "config",
41
- "generateStaticParams",
42
- "metadata",
43
- "generateMetadata",
44
- "viewport",
45
- "generateViewport"
46
- ];
47
- var reactRules = async () => {
48
- const [reactPlugin, jsxA11yPlugin] = await Promise.all([
49
- interopDefault(import("eslint-plugin-react")),
50
- interopDefault(import("eslint-plugin-jsx-a11y"))
51
- ]);
52
- const isUsingNextjs = hasNext();
53
- const isUsingVite = hasVite();
54
- return {
55
- ...jsxA11yPlugin.configs.recommended.rules,
56
- ...normalizeRuleEntries(reactPlugin.configs.flat.recommended?.rules),
57
- ...normalizeRuleEntries(reactPlugin.configs.flat["jsx-runtime"]?.rules),
58
- "react-compiler/react-compiler": "error",
59
- "react-hooks/exhaustive-deps": "error",
60
- "react-hooks/rules-of-hooks": "error",
61
- "react-refresh/only-export-components": [
62
- "warn",
63
- {
64
- allowConstantExport: isUsingVite,
65
- allowExportNames: isUsingNextjs ? nextAllowedExportNames : []
66
- }
67
- ],
68
- "react/boolean-prop-naming": "off",
69
- // revisit
70
- "react/button-has-type": "error",
71
- "react/checked-requires-onchange-or-readonly": "error",
72
- "react/default-props-match-prop-types": "error",
73
- "react/destructuring-assignment": "off",
74
- // revisit
75
- "react/forbid-component-props": "off",
76
- "react/forbid-dom-props": "off",
77
- "react/forbid-elements": "off",
78
- "react/forbid-foreign-prop-types": "off",
79
- "react/forbid-prop-types": "off",
80
- "react/forward-ref-uses-ref": "error",
81
- "react/function-component-definition": "off",
82
- // revisit
83
- "react/hook-use-state": "error",
84
- "react/iframe-missing-sandbox": "error",
85
- "react/jsx-boolean-value": ["error", "never"],
86
- "react/jsx-curly-brace-presence": "error",
87
- "react/jsx-filename-extension": "off",
88
- "react/jsx-fragments": ["error", "syntax"],
89
- "react/jsx-handler-names": "off",
90
- "react/jsx-max-depth": "off",
91
- "react/jsx-no-bind": "off",
92
- // revisit
93
- "react/jsx-no-constructed-context-values": "error",
94
- "react/jsx-no-leaked-render": "error",
95
- "react/jsx-no-literals": "off",
96
- "react/jsx-no-script-url": "error",
97
- "react/jsx-no-useless-fragment": "error",
98
- "react/jsx-one-expression-per-line": "off",
99
- "react/jsx-pascal-case": ["error", { allowNamespace: true }],
100
- "react/jsx-props-no-spread-multi": "off",
101
- "react/jsx-props-no-spreading": "off",
102
- "react/jsx-sort-default-props": "off",
103
- "react/jsx-sort-props": "off",
104
- "react/no-access-state-in-setstate": "error",
105
- "react/no-adjacent-inline-elements": "off",
106
- "react/no-array-index-key": "off",
107
- "react/no-arrow-function-lifecycle": "error",
108
- "react/no-danger": "off",
109
- "react/no-did-mount-set-state": "error",
110
- "react/no-did-update-set-state": "error",
111
- "react/no-invalid-html-attribute": "error",
112
- "react/no-multi-comp": "off",
113
- "react/no-namespace": "error",
114
- "react/no-object-type-as-default-prop": "error",
115
- "react/no-redundant-should-component-update": "error",
116
- "react/no-set-state": "off",
117
- "react/no-this-in-sfc": "error",
118
- "react/no-typos": "error",
119
- "react/no-unstable-nested-components": "error",
120
- "react/no-unused-class-component-methods": "error",
121
- "react/no-unused-prop-types": "error",
122
- "react/no-unused-state": "error",
123
- "react/no-will-update-set-state": "error",
124
- "react/prefer-es6-class": "off",
125
- "react/prefer-exact-props": "off",
126
- "react/prefer-read-only-props": "off",
127
- "react/prefer-stateless-function": "off",
128
- "react/require-default-props": "off",
129
- "react/require-optimization": "off",
130
- "react/self-closing-comp": "error",
131
- "react/sort-comp": "off",
132
- "react/sort-default-props": "off",
133
- "react/sort-prop-types": "off",
134
- "react/state-in-constructor": "off",
135
- "react/static-property-placement": "off",
136
- "react/style-prop-object": "error",
137
- "react/void-dom-elements-no-children": "error"
138
- };
139
- };
140
-
141
- // src/configs/react.ts
142
- async function reactConfig() {
143
- const [
144
- reactPlugin,
145
- jsxA11yPlugin,
146
- reactHooksPlugin,
147
- reactRefreshPlugin,
148
- reactCompilerPlugin
149
- ] = await Promise.all([
150
- interopDefault(import("eslint-plugin-react")),
151
- interopDefault(import("eslint-plugin-jsx-a11y")),
152
- import("eslint-plugin-react-hooks"),
153
- interopDefault(import("eslint-plugin-react-refresh")),
154
- import("eslint-plugin-react-compiler")
155
- ]);
156
- return [
157
- {
158
- files: [GLOB_JSX, GLOB_TSX],
159
- languageOptions: {
160
- globals: {
161
- ...globals.browser
162
- },
163
- parserOptions: {
164
- ecmaFeatures: {
165
- jsx: true
166
- },
167
- jsxPragma: null
168
- }
169
- },
170
- name: "jimmy.codes/react",
171
- plugins: {
172
- "jsx-a11y": jsxA11yPlugin,
173
- "react": reactPlugin,
174
- "react-compiler": reactCompilerPlugin,
175
- "react-hooks": reactHooksPlugin,
176
- "react-refresh": reactRefreshPlugin
177
- },
178
- rules: await reactRules(),
179
- settings: {
180
- react: {
181
- version: "detect"
182
- }
183
- }
184
- }
185
- ];
186
- }
187
- export {
188
- reactConfig as default
189
- };