-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy patheslint.config.mjs
74 lines (72 loc) · 2.18 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import path from "path";
import { fileURLToPath } from "url";
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import pluginJest from "eslint-plugin-jest";
import jestDom from "eslint-plugin-jest-dom";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import testingLibrary from "eslint-plugin-testing-library";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
/** @type {import('eslint').Linter.Config[]} */
export default [
pluginJs.configs.recommended,
pluginReact.configs.flat.recommended,
pluginReact.configs.flat["jsx-runtime"],
...tseslint.configs.recommended,
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
globals: { ...globals.browser, ...globals.node },
},
},
{
settings: {
react: {
version: "detect",
},
"import/resolver": {
"eslint-import-resolver-lerna": {
packages: path.resolve(__dirname, "packages"),
},
typescript: {
project: [
"./tsconfig.json",
"./packages/backend/tsconfig.json",
"./packages/web/tsconfig.json",
],
},
},
},
plugins: { "react-hooks": reactHooks },
rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
},
},
{
// Rules and plugins for tests only
files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
plugins: {
jest: pluginJest,
...jestDom.configs["flat/dom"],
...testingLibrary.configs["flat/recommended"],
...testingLibrary.configs["flat/react"],
},
languageOptions: {
globals: pluginJest.environments.globals.globals,
},
rules: {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
},
},
// this prettier plugin adjusts other parts of this config,
// so keep it as the last item
eslintPluginPrettierRecommended,
];