-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
65 lines (63 loc) · 1.83 KB
/
eslint.config.js
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
import eslint from "@eslint/js";
import reactRecommended from "eslint-plugin-react/configs/recommended.js";
import hooksPlugin from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import path from "path";
import tseslint from "typescript-eslint";
import { fileURLToPath } from "url";
// Mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Preview: npx @eslint/config-inspector
export default tseslint.config(
{
// Global ignores
ignores: ["build/", "coverage/", "*.js"],
},
eslint.configs.recommended,
// Use TS config only for TS files: https://stackoverflow.com/a/64488474
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ["**/*.ts", "**/*.tsx"],
})),
reactRecommended,
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
globals: {
...globals.browser,
...globals.es2020,
...globals.node,
},
parserOptions: {
ecmaVersion: "latest",
project: ["./tsconfig.json", "./tsconfig.node.json"],
tsconfigRootDir: __dirname, // use import.meta.dirname in Node 20+
sourceType: "module",
},
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
plugins: {
"react-hooks": hooksPlugin,
"react-refresh": reactRefresh,
},
rules: {
// Suppress errors for missing 'import React' in files
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
...hooksPlugin.configs.recommended.rules,
},
settings: {
react: {
version: "detect",
},
},
}
);