diff options
author | 2024-07-10 00:16:04 +0100 | |
---|---|---|
committer | 2024-07-10 01:51:05 +0100 | |
commit | e22afcc2e4a91ed5948820b39996e7099bc30bde (patch) | |
tree | cac543ee9b0ef34738ffa447364b2e87fc8bf84e | |
parent | Update code component to use @uiw/react-codemirror (diff) |
Add new linting config
-rw-r--r-- | .eslintrc.json | 58 | ||||
-rw-r--r-- | eslint.config.mjs | 71 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | yarn.lock | 12 |
4 files changed, 86 insertions, 59 deletions
diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 0a7b51b..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 12, - "sourceType": "module" - }, - "plugins": [ - "react", - "@typescript-eslint" - ], - "rules": { - "indent": [ - "error", - 4, - { - "SwitchCase": 1 - } - ], - "quotes": [ - "error", - "double" - ], - "semi": [ - "error", - "always" - ], - "no-trailing-spaces": "error", - "eol-last": "error", - "linebreak-style": "off" - }, - "settings": { - "react": { - "pragma": "jsx", - "version": "detect", - "flowVersion": "0.53" - } - }, - "overrides": [ - { - "files": "*.test.ts*", - "rules": { - "react/react-in-jsx-scope": "off" - } - } - ] -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..24ee02b --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,71 @@ +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; +import react from "eslint-plugin-react"; +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [...fixupConfigRules(compat.extends( + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended", +)), { + plugins: { + react: fixupPluginRules(react), + "@typescript-eslint": fixupPluginRules(typescriptEslint), + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: tsParser, + ecmaVersion: 12, + sourceType: "module", + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + }, + + settings: { + react: { + pragma: "jsx", + version: "detect", + flowVersion: "0.53", + }, + }, + + rules: { + indent: ["error", 4, { + SwitchCase: 1, + }], + + quotes: ["error", "double"], + semi: ["error", "always"], + "no-trailing-spaces": "error", + "eol-last": "error", + "linebreak-style": "off", + "react/no-unknown-property": ["error", { "ignore": ["css"] }] + }, +}, { + files: ["**/*.test.ts*"], + + rules: { + "react/react-in-jsx-scope": "off" + }, +}]; diff --git a/package.json b/package.json index 056dbe8..874e9cc 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,9 @@ ] }, "devDependencies": { + "@eslint/compat": "^1.1.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.6.0", "@swc/jest": "0.2.36", "@testing-library/jest-dom": "6.4.6", "@testing-library/react": "16.0.0", @@ -77,6 +80,7 @@ "dotenv": "16.4.5", "eslint": "9.6.0", "eslint-plugin-react": "7.34.3", + "globals": "^15.8.0", "husky": "9.0.11", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", @@ -2172,6 +2172,11 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.11.0.tgz#b0ffd0312b4a3fd2d6f77237e7248a5ad3a680ae" integrity sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A== +"@eslint/compat@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@eslint/compat/-/compat-1.1.0.tgz#fdc7d19a66820770bf58ced0342153769d8686f0" + integrity sha512-s9Wi/p25+KbzxKlDm3VshQdImhWk+cbdblhwGNnyCU5lpSwtWa4v7VQCxSki0FAUrGA3s8nCWgYzAH41mwQVKQ== + "@eslint/config-array@^0.17.0": version "0.17.0" resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.17.0.tgz#ff305e1ee618a00e6e5d0485454c8d92d94a860d" @@ -2196,7 +2201,7 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/[email protected]": +"@eslint/[email protected]", "@eslint/js@^9.6.0": version "9.6.0" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.6.0.tgz#5b0cb058cc13d9c92d4e561d3538807fa5127c95" integrity sha512-D9B0/3vNg44ZeWbYMpBoXqNP4j6eQD5vNwIlGAuFRRzK/WtT/jvDQW3Bi9kkf3PMDMlM7Yi+73VLUsn5bJcl8A== @@ -5890,6 +5895,11 @@ globals@^14.0.0: resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== +globals@^15.8.0: + version "15.8.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-15.8.0.tgz#e64bb47b619dd8cbf32b3c1a0a61714e33cbbb41" + integrity sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw== + globalthis@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.4.tgz#7430ed3a975d97bfb59bcce41f5cabbafa651236" |