Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions examples/react-babel/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
import { defineConfig } from "eslint/config";
import js from '@eslint/js'
import { resolve } from "node:path";
import { cwd } from "node:process";
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import { defineConfig } from "eslint/config";
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import tsParser from "@typescript-eslint/parser";
import reactRefreshPlugin from 'eslint-plugin-react-refresh'
import reactHooksPlugin from 'eslint-plugin-react-hooks'

const PACKAGE_ROOT = resolve(cwd());

export default defineConfig(
{ ignores: ['dist'] },
eslint.configs.recommended,
...tseslint.configs.recommended,
reactHooksPlugin.configs.flat.recommended,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: PACKAGE_ROOT,
projectService: true,
},
},
},
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parser: tsParser,
parserOptions: {
project: ["tsconfig.json"],
tsconfigRootDir: cwd(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Use PACKAGE_ROOT consistently.

Line 20 uses PACKAGE_ROOT for tsconfigRootDir, but line 31 uses cwd() directly. For consistency and clarity, use PACKAGE_ROOT here as well since it's already defined at line 11.

Apply this diff:

       parserOptions: {
         project: ["tsconfig.json"],
-        tsconfigRootDir: cwd(),
+        tsconfigRootDir: PACKAGE_ROOT,
         projectService: true,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tsconfigRootDir: cwd(),
parserOptions: {
project: ["tsconfig.json"],
tsconfigRootDir: PACKAGE_ROOT,
projectService: true,
🤖 Prompt for AI Agents
In examples/react-babel/eslint.config.js around line 31, tsconfigRootDir is set
to cwd() while PACKAGE_ROOT (defined at line 11) should be used for consistency;
replace cwd() with PACKAGE_ROOT so tsconfigRootDir: PACKAGE_ROOT.

projectService: true,

ecmaVersion: "latest",
sourceType: "module",
globals: { ...globals.browser, ...globals.es2020 },
}
Comment on lines +29 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix incorrect property nesting in languageOptions.

Lines 34-36 (ecmaVersion, sourceType, globals) are incorrectly nested under parserOptions. These properties belong directly under languageOptions, not within parserOptions.

Apply this diff to fix the nesting:

     languageOptions: {
       parser: tsParser,
       parserOptions: {
         project: ["tsconfig.json"],
         tsconfigRootDir: cwd(),
         projectService: true,
-
-        ecmaVersion: "latest",
-        sourceType: "module",
-        globals: { ...globals.browser, ...globals.es2020 },
-      }
+      },
+      ecmaVersion: "latest",
+      sourceType: "module",
+      globals: { ...globals.browser, ...globals.es2020 },
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
parserOptions: {
project: ["tsconfig.json"],
tsconfigRootDir: cwd(),
projectService: true,
ecmaVersion: "latest",
sourceType: "module",
globals: { ...globals.browser, ...globals.es2020 },
}
languageOptions: {
parser: tsParser,
parserOptions: {
project: ["tsconfig.json"],
tsconfigRootDir: cwd(),
projectService: true,
},
ecmaVersion: "latest",
sourceType: "module",
globals: { ...globals.browser, ...globals.es2020 },
}
🤖 Prompt for AI Agents
In examples/react-babel/eslint.config.js around lines 29 to 37, parserOptions
currently contains ecmaVersion, sourceType and globals which are incorrectly
nested; move ecmaVersion, sourceType and globals out of parserOptions and place
them directly under languageOptions at the same level as parserOptions so
languageOptions directly includes parserOptions plus ecmaVersion, sourceType,
and globals.

},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'react-hooks': reactHooksPlugin,
'react-refresh': reactRefreshPlugin,
},
rules: {
...reactHooks.configs.recommended.rules,
...reactHooksPlugin.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
{
files: ["*.js", "*.cjs", "*.mjs"],
extends: [tseslint.configs.disableTypeChecked],
},
{
ignores: ["dist/**"],
},
)
1 change: 1 addition & 0 deletions examples/react-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@types/scheduler": "^0.26.0",
"@typescript-eslint/parser": "^8.46.2",
"@vitejs/plugin-react": "^5.0.4",
"eslint": "^9.38.0",
"eslint-plugin-react-hooks": "^7.0.0",
Expand Down
1 change: 1 addition & 0 deletions examples/react-swc/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default defineConfig(
"react-hooks": reactHooksPlugin,
},
rules: {
...reactHooksPlugin.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5816,6 +5816,7 @@ __metadata:
"@types/react": "npm:^19.2.2"
"@types/react-dom": "npm:^19.2.2"
"@types/scheduler": "npm:^0.26.0"
"@typescript-eslint/parser": "npm:^8.46.2"
"@vanilla-extract/css": "npm:^1.17.4"
"@vanilla-extract/css-utils": "npm:^0.1.6"
"@vanilla-extract/private": "npm:^1.0.9"
Expand Down
Loading