-
-
Notifications
You must be signed in to change notification settings - Fork 1
Chore: update eslint config as consist #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(), | ||||||||||||||||||||||||||||||||||||||||||
| projectService: true, | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ecmaVersion: "latest", | ||||||||||||||||||||||||||||||||||||||||||
| sourceType: "module", | ||||||||||||||||||||||||||||||||||||||||||
| globals: { ...globals.browser, ...globals.es2020 }, | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect property nesting in languageOptions. Lines 34-36 ( 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| 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/**"], | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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_ROOTfortsconfigRootDir, but line 31 usescwd()directly. For consistency and clarity, usePACKAGE_ROOThere 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
🤖 Prompt for AI Agents