|
| 1 | +import js from "@eslint/js"; |
| 2 | +import parserBabel from "@babel/eslint-parser"; |
| 3 | +import parserTs from "@typescript-eslint/parser"; |
| 4 | +import pluginReact from "eslint-plugin-react"; |
| 5 | +import pluginReactHooks from "eslint-plugin-react-hooks"; |
| 6 | +import pluginTs from "@typescript-eslint/eslint-plugin"; |
| 7 | +import pluginSimpleImportSort from "eslint-plugin-simple-import-sort"; |
| 8 | + |
| 9 | +/** @type {import("eslint").FlatConfig[]} */ |
| 10 | +export default [ |
| 11 | + js.configs.recommended, |
| 12 | + |
| 13 | + // TypeScript files |
| 14 | + { |
| 15 | + files: ["vis/**/*.{ts,tsx}"], |
| 16 | + languageOptions: { |
| 17 | + parser: parserTs, |
| 18 | + parserOptions: { |
| 19 | + ecmaVersion: 2022, |
| 20 | + sourceType: "module", |
| 21 | + ecmaFeatures: { jsx: true }, |
| 22 | + project: true, |
| 23 | + }, |
| 24 | + }, |
| 25 | + plugins: { |
| 26 | + "@typescript-eslint": pluginTs, |
| 27 | + "react": pluginReact, |
| 28 | + "react-hooks": pluginReactHooks, |
| 29 | + "simple-import-sort": pluginSimpleImportSort, |
| 30 | + }, |
| 31 | + rules: { |
| 32 | + ...pluginTs.configs.recommended.rules, |
| 33 | + "no-unused-vars": "off", |
| 34 | + "@typescript-eslint/no-unused-vars": ["error", { args: "none" }], |
| 35 | + "prefer-const": "warn", |
| 36 | + "simple-import-sort/imports": "warn", |
| 37 | + "simple-import-sort/exports": "warn", |
| 38 | + "react/prop-types": "off", |
| 39 | + "react/no-unescaped-entities": "off", |
| 40 | + "react-hooks/rules-of-hooks": "error", |
| 41 | + "react-hooks/exhaustive-deps": "warn", |
| 42 | + "array-callback-return": "error", |
| 43 | + "consistent-return": "off", |
| 44 | + "default-param-last": "error", |
| 45 | + "eqeqeq": ["error", "always"], |
| 46 | + "no-console": "warn", |
| 47 | + "no-else-return": ["error", { allowElseIf: false }], |
| 48 | + "no-param-reassign": ["error", { props: true }], |
| 49 | + "prefer-template": "error", |
| 50 | + "react/jsx-filename-extension": [ |
| 51 | + "warn", |
| 52 | + { extensions: [".jsx", ".tsx"] }, |
| 53 | + ], |
| 54 | + "react/jsx-props-no-spreading": "off", |
| 55 | + "react/react-in-jsx-scope": "off", |
| 56 | + "react/function-component-definition": [ |
| 57 | + "error", |
| 58 | + { |
| 59 | + namedComponents: "arrow-function", |
| 60 | + unnamedComponents: "arrow-function", |
| 61 | + }, |
| 62 | + ], |
| 63 | + }, |
| 64 | + settings: { |
| 65 | + react: { |
| 66 | + version: "detect", |
| 67 | + }, |
| 68 | + }, |
| 69 | + }, |
| 70 | + |
| 71 | + // JavaScript files |
| 72 | + { |
| 73 | + files: ["vis/**/*.{js,jsx}"], |
| 74 | + languageOptions: { |
| 75 | + parser: parserBabel, |
| 76 | + parserOptions: { |
| 77 | + requireConfigFile: false, |
| 78 | + babelOptions: { |
| 79 | + presets: ["@babel/preset-react"], |
| 80 | + }, |
| 81 | + ecmaFeatures: { |
| 82 | + jsx: true, |
| 83 | + }, |
| 84 | + }, |
| 85 | + }, |
| 86 | + plugins: { |
| 87 | + "react": pluginReact, |
| 88 | + "react-hooks": pluginReactHooks, |
| 89 | + "simple-import-sort": pluginSimpleImportSort, |
| 90 | + }, |
| 91 | + rules: { |
| 92 | + "no-unused-vars": ["error", { args: "none" }], |
| 93 | + "prefer-const": "warn", |
| 94 | + "simple-import-sort/imports": "warn", |
| 95 | + "simple-import-sort/exports": "warn", |
| 96 | + "react/prop-types": "off", |
| 97 | + "react/no-unescaped-entities": "off", |
| 98 | + "react-hooks/rules-of-hooks": "error", |
| 99 | + "react-hooks/exhaustive-deps": "warn", |
| 100 | + "array-callback-return": "error", |
| 101 | + "consistent-return": "off", |
| 102 | + "default-param-last": "error", |
| 103 | + "eqeqeq": ["error", "always"], |
| 104 | + "no-console": "warn", |
| 105 | + "no-else-return": ["error", { allowElseIf: false }], |
| 106 | + "no-param-reassign": ["error", { props: true }], |
| 107 | + "prefer-template": "error", |
| 108 | + "react/jsx-filename-extension": [ |
| 109 | + "warn", |
| 110 | + { extensions: [".jsx", ".tsx"] }, |
| 111 | + ], |
| 112 | + "react/jsx-props-no-spreading": "off", |
| 113 | + "react/react-in-jsx-scope": "off", |
| 114 | + "react/function-component-definition": [ |
| 115 | + "error", |
| 116 | + { |
| 117 | + namedComponents: "arrow-function", |
| 118 | + unnamedComponents: "arrow-function", |
| 119 | + }, |
| 120 | + ], |
| 121 | + }, |
| 122 | + settings: { |
| 123 | + react: { |
| 124 | + version: "detect", |
| 125 | + }, |
| 126 | + }, |
| 127 | + }, |
| 128 | +]; |
0 commit comments