-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(lint): Update ESLint config to flat config
chore: Bump dependencies
- Loading branch information
1 parent
ac459ef
commit 7323b5f
Showing
6 changed files
with
17,132 additions
and
28,303 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
import js from "@eslint/js"; | ||
import stylisticJs from "@stylistic/eslint-plugin-js"; | ||
import tsParser from "@typescript-eslint/parser"; | ||
import pluginImport from "eslint-plugin-import"; | ||
import reactAccessibility from "eslint-plugin-jsx-a11y"; | ||
import nodePlugin from "eslint-plugin-n"; | ||
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; | ||
import hooksPlugin from "eslint-plugin-react-hooks"; | ||
import reactRefresh from "eslint-plugin-react-refresh"; | ||
import reactRecommended from "eslint-plugin-react/configs/recommended.js"; | ||
import pluginSecurity from "eslint-plugin-security"; | ||
import eslintPluginUnicorn from "eslint-plugin-unicorn"; | ||
import globals from "globals"; | ||
import tsEslint from "typescript-eslint"; | ||
|
||
const ecmaVersion = 2022; | ||
const reactFiles = ["**/*.{jsx,tsx}", "src/**"]; | ||
|
||
/** @type {import('eslint').Linter.FlatConfig[]} */ | ||
export default tsEslint.config( | ||
{ | ||
// Top-level ignores aka .eslintignore replacement for flat config | ||
ignores: [".vscode/**", "packages/*/dist/**", "build/**", "node_modules/**"] | ||
}, | ||
js.configs.recommended, | ||
...tsEslint.configs.recommended, | ||
{ | ||
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"], | ||
rules: { "@typescript-eslint/explicit-function-return-type": ["error"] } | ||
}, | ||
{ | ||
rules: { | ||
"no-console": ["error"], | ||
"no-restricted-syntax": [ | ||
"error", | ||
{ | ||
selector: "ExportDefaultDeclaration", | ||
message: "Prefer named exports" | ||
} | ||
], | ||
"no-else-return": ["error", { allowElseIf: false }] | ||
} | ||
}, | ||
pluginSecurity.configs.recommended, | ||
{ | ||
// @stylistic/eslint-plugin-js | ||
plugins: { | ||
"@stylistic/js": stylisticJs | ||
}, | ||
rules: { | ||
"@stylistic/js/semi": ["error", "always"] | ||
} | ||
}, | ||
eslintPluginPrettierRecommended, | ||
{ | ||
// Unicorn | ||
...eslintPluginUnicorn.configs["flat/recommended"], | ||
rules: { | ||
"unicorn/filename-case": ["error", { case: "camelCase" }], | ||
"unicorn/no-fn-reference-in-iterator": "off", | ||
"unicorn/no-reduce": "off", | ||
"unicorn/no-null": "off", | ||
"unicorn/switch-case-braces": "off", | ||
"unicorn/prefer-at": "off", | ||
"unicorn/no-array-reduce": "off", | ||
"unicorn/no-array-for-each": "off", | ||
"unicorn/no-array-callback-reference": "off", | ||
"unicorn/prefer-node-protocol": "off", | ||
"unicorn/prefer-object-from-entries": ["off"], | ||
"unicorn/no-useless-undefined": "off" | ||
} | ||
}, | ||
{ | ||
plugins: { | ||
import: pluginImport | ||
}, | ||
languageOptions: { | ||
sourceType: "module", | ||
ecmaVersion, | ||
parser: tsParser, | ||
parserOptions: { | ||
ecmaVersion | ||
} | ||
}, | ||
settings: { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [] | ||
} | ||
} | ||
}, | ||
{ | ||
files: ["**/*.cjs"], | ||
languageOptions: { | ||
globals: globals.node, | ||
sourceType: "commonjs" | ||
} | ||
}, | ||
{ | ||
files: ["**/*.d.ts"], | ||
rules: { | ||
"@typescript-eslint/triple-slash-reference": ["off"], | ||
"@typescript-eslint/no-namespace": ["off"], | ||
"unicorn/prevent-abbreviations": ["off"], | ||
"no-restricted-syntax": ["off"], | ||
"unicorn/filename-case": ["off"] | ||
} | ||
}, | ||
{ | ||
...nodePlugin.configs["flat/recommended"], | ||
files: ["eslint.config.js"], | ||
rules: { | ||
"no-restricted-syntax": ["off"], | ||
"n/no-unsupported-features/es-syntax": [ | ||
"error", | ||
{ | ||
ignores: ["modules"] | ||
} | ||
] | ||
}, | ||
languageOptions: { | ||
globals: globals.node | ||
} | ||
}, | ||
{ | ||
...reactRecommended, | ||
files: reactFiles, | ||
languageOptions: { | ||
...reactRecommended.languageOptions, | ||
globals: { | ||
...globals.browser | ||
} | ||
}, | ||
rules: { | ||
"react/jsx-uses-react": "off", | ||
"react/react-in-jsx-scope": "off", | ||
"react/prop-types": [2, { ignore: ["children"] }] | ||
}, | ||
settings: { | ||
react: { | ||
version: "detect" // React version. "detect" automatically picks the version you have installed. | ||
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value. | ||
// default to latest and warns if missing | ||
// It will default to "detect" in the future | ||
} | ||
} | ||
}, | ||
{ | ||
files: reactFiles, | ||
plugins: { | ||
"react-hooks": hooksPlugin | ||
}, | ||
rules: { | ||
...hooksPlugin.configs.recommended.rules, | ||
"react-hooks/rules-of-hooks": "error", | ||
"react-hooks/exhaustive-deps": "error" | ||
} | ||
}, | ||
{ | ||
files: reactFiles, | ||
plugins: { "jsx-a11y": reactAccessibility }, | ||
rules: { | ||
...reactAccessibility.configs.recommended.rules | ||
} | ||
}, | ||
{ | ||
files: reactFiles, | ||
plugins: { "react-refresh": reactRefresh }, | ||
rules: { | ||
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }] | ||
} | ||
} | ||
); |
Oops, something went wrong.