|
| 1 | +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; |
| 2 | +import react from "eslint-plugin-react"; |
| 3 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 4 | +import security from "eslint-plugin-security"; |
| 5 | +import _import from "eslint-plugin-import"; |
| 6 | +import globals from "globals"; |
| 7 | +import tsParser from "@typescript-eslint/parser"; |
| 8 | +import path from "node:path"; |
| 9 | +import { fileURLToPath } from "node:url"; |
| 10 | +import js from "@eslint/js"; |
| 11 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 12 | + |
| 13 | +const __filename = fileURLToPath(import.meta.url); |
| 14 | +const __dirname = path.dirname(__filename); |
| 15 | +const compat = new FlatCompat({ |
| 16 | + baseDirectory: __dirname, |
| 17 | + recommendedConfig: js.configs.recommended, |
| 18 | + allConfig: js.configs.all, |
| 19 | +}); |
| 20 | + |
| 21 | +export default [ |
| 22 | + { |
| 23 | + ignores: ["src/assets"], |
| 24 | + }, |
| 25 | + ...fixupConfigRules( |
| 26 | + compat.extends( |
| 27 | + "eslint:recommended", |
| 28 | + "plugin:react/recommended", |
| 29 | + "plugin:react-hooks/recommended", |
| 30 | + "plugin:import/recommended", |
| 31 | + "plugin:import/react", |
| 32 | + "plugin:@typescript-eslint/recommended", |
| 33 | + "plugin:prettier/recommended", |
| 34 | + "prettier" |
| 35 | + ) |
| 36 | + ), |
| 37 | + { |
| 38 | + plugins: { |
| 39 | + react: fixupPluginRules(react), |
| 40 | + "react-hooks": fixupPluginRules(reactHooks), |
| 41 | + security: fixupPluginRules(security), |
| 42 | + import: fixupPluginRules(_import), |
| 43 | + }, |
| 44 | + |
| 45 | + languageOptions: { |
| 46 | + globals: { |
| 47 | + ...globals.browser, |
| 48 | + ...globals.node, |
| 49 | + Atomics: "readonly", |
| 50 | + SharedArrayBuffer: "readonly", |
| 51 | + }, |
| 52 | + |
| 53 | + parser: tsParser, |
| 54 | + ecmaVersion: 2020, |
| 55 | + sourceType: "module", |
| 56 | + |
| 57 | + parserOptions: { |
| 58 | + ecmaFeatures: { |
| 59 | + jsx: true, |
| 60 | + }, |
| 61 | + }, |
| 62 | + }, |
| 63 | + |
| 64 | + settings: { |
| 65 | + react: { |
| 66 | + version: "^16.12.0", |
| 67 | + }, |
| 68 | + |
| 69 | + "import/resolver": { |
| 70 | + typescript: { |
| 71 | + project: "./tsconfig.json", |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + |
| 76 | + rules: { |
| 77 | + "max-len": [ |
| 78 | + "warn", |
| 79 | + { |
| 80 | + code: 120, |
| 81 | + }, |
| 82 | + ], |
| 83 | + |
| 84 | + "react/prop-types": 0, |
| 85 | + "no-unused-vars": "off", |
| 86 | + |
| 87 | + "@typescript-eslint/no-unused-vars": [ |
| 88 | + "error", |
| 89 | + { |
| 90 | + varsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)", |
| 91 | + argsIgnorePattern: "(^_+[0-9]*$)|([iI]gnored$)|(^ignored)", |
| 92 | + }, |
| 93 | + ], |
| 94 | + |
| 95 | + "no-console": [ |
| 96 | + "error", |
| 97 | + { |
| 98 | + allow: ["warn", "error", "info", "debug"], |
| 99 | + }, |
| 100 | + ], |
| 101 | + |
| 102 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 103 | + "@typescript-eslint/no-explicit-any": "off", |
| 104 | + "security/detect-object-injection": "off", |
| 105 | + "security/detect-non-literal-fs-filename": "off", |
| 106 | + |
| 107 | + "import/extensions": [ |
| 108 | + "error", |
| 109 | + "ignorePackages", |
| 110 | + { |
| 111 | + js: "never", |
| 112 | + jsx: "never", |
| 113 | + ts: "never", |
| 114 | + tsx: "never", |
| 115 | + }, |
| 116 | + ], |
| 117 | + |
| 118 | + "import/no-unresolved": "off", |
| 119 | + |
| 120 | + "import/order": [ |
| 121 | + "warn", |
| 122 | + { |
| 123 | + groups: ["builtin", "external", "internal", "parent", "sibling", "index"], |
| 124 | + |
| 125 | + pathGroups: [ |
| 126 | + { |
| 127 | + pattern: "{react,styled-components}", |
| 128 | + group: "external", |
| 129 | + position: "before", |
| 130 | + }, |
| 131 | + { |
| 132 | + pattern: "@kleros/**", |
| 133 | + group: "external", |
| 134 | + position: "after", |
| 135 | + }, |
| 136 | + { |
| 137 | + pattern: "{svgs/**,assets/**}", |
| 138 | + group: "internal", |
| 139 | + position: "after", |
| 140 | + }, |
| 141 | + { |
| 142 | + pattern: "{hooks/**,utils/**,consts/**,types/**,context/**,connectors/**,}", |
| 143 | + group: "internal", |
| 144 | + position: "after", |
| 145 | + }, |
| 146 | + { |
| 147 | + pattern: "{queries/**,}", |
| 148 | + group: "internal", |
| 149 | + position: "after", |
| 150 | + }, |
| 151 | + { |
| 152 | + pattern: "{src/**,}", |
| 153 | + group: "internal", |
| 154 | + position: "after", |
| 155 | + }, |
| 156 | + { |
| 157 | + pattern: "{styles/**,}", |
| 158 | + group: "internal", |
| 159 | + position: "after", |
| 160 | + }, |
| 161 | + { |
| 162 | + pattern: "{layout/**,pages/**,components/**,}", |
| 163 | + group: "internal", |
| 164 | + position: "after", |
| 165 | + }, |
| 166 | + ], |
| 167 | + |
| 168 | + pathGroupsExcludedImportTypes: ["builtin"], |
| 169 | + "newlines-between": "always", |
| 170 | + |
| 171 | + alphabetize: { |
| 172 | + order: "asc", |
| 173 | + caseInsensitive: true, |
| 174 | + }, |
| 175 | + }, |
| 176 | + ], |
| 177 | + }, |
| 178 | + }, |
| 179 | +]; |
0 commit comments