-
Notifications
You must be signed in to change notification settings - Fork 524
/
Copy patheslint.config.mjs
147 lines (139 loc) · 3.51 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import eslint from "@eslint/js";
import prettier from "eslint-plugin-prettier/recommended";
import pluginJest from "eslint-plugin-jest";
import pluginPromise from "eslint-plugin-promise";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import tseslint from "typescript-eslint";
import globals from "globals";
export default tseslint.config(
// enforce formatting
prettier,
// global ignores
{
ignores: [
"**/*.d.ts",
"**/.wireit/",
"**/.docusaurus/",
"**/artifacts/",
"**/coverage/",
"**/demo/rn/",
"**/dist/",
"**/build/",
"**/es/",
"**/lib/",
"**/lib-vendor/",
"**/public/",
"**/storybook-static/",
"**/tmp/",
"website/src/theme/",
"website/src/plugins/",
],
},
// Typescript and React Rules
{
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
react.configs.flat.recommended,
pluginPromise.configs["flat/recommended"],
],
plugins: {
react,
"react-hooks": reactHooks,
},
settings: {
react: {
version: "detect",
},
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
// eslint overrides
eqeqeq: "error",
"max-depth": ["error", 4],
"max-nested-callbacks": ["error", 3],
"max-params": ["error", 3],
"no-console": "error",
"no-magic-numbers": [
"error",
{ ignore: [-1, 0, 0.5, 1, 2, 90, 180, 270, 360] },
],
"no-nested-ternary": "error",
"no-prototype-builtins": "off",
"no-param-reassign": "error",
"no-restricted-imports": [
"error",
{
paths: [
{
name: "lodash",
message:
"Be sure to import specific lodash functions, not the entire library!",
},
],
patterns: [
{
group: ["victory*/src", "victory*/src/**"],
message:
"Be sure to import directly from Victory packages, not from /src folders!",
},
],
},
],
"no-shadow": "error",
"no-undef": "error",
"no-useless-escape": "off",
"prefer-arrow-callback": "error",
// react overrides
"react/display-name": "off",
"react/prop-types": "off",
"react/no-multi-comp": "error",
...reactHooks.configs.recommended.rules,
// @typescript-eslint overrides
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
},
},
// Overrides for JS files
{
files: ["**/*.js"],
rules: {
"@typescript-eslint/no-require-imports": "off",
},
},
// Overrides for Test files
{
files: ["**/*.test.*", "**/test/**/*", "**/jest-native-setup.tsx"],
plugins: { jest: pluginJest },
languageOptions: {
globals: pluginJest.environments.globals.globals,
},
rules: {
"react/sort-comp": "off",
"no-magic-numbers": "off",
"max-statements": "off",
"import/no-unresolved": "off",
"no-undef": "off",
"max-nested-callbacks": "off",
},
},
// Overrides for Storybook
{
files: ["**/stories/**/*.ts", "**/stories/**/*.stories.tsx"],
rules: {
"no-magic-numbers": "off",
},
},
);