-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
156 lines (146 loc) · 4.44 KB
/
.eslintrc.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
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
148
149
150
151
152
153
154
155
156
/** @type {import('@types/eslint').Linter.BaseConfig} */
module.exports = {
extends: [
// https://github.com/remix-run/remix/tree/main/packages/remix-eslint-config
// Using the following plugins:
// https://typescript-eslint.io/rules/
// https://github.com/jsx-eslint/eslint-plugin-react
// https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
// https://github.com/import-js/eslint-plugin-import
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y
// https://github.com/mysticatea/eslint-plugin-node
// https://github.com/jest-community/eslint-plugin-jest
// https://github.com/testing-library/eslint-plugin-jest-dom
// https://github.com/testing-library/eslint-plugin-testing-library
"@remix-run/eslint-config",
"@remix-run/eslint-config/node",
"@remix-run/eslint-config/jest-testing-library",
// https://github.com/sindresorhus/eslint-plugin-unicorn
"plugin:unicorn/all",
// https://mysticatea.github.io/eslint-plugin-eslint-comments/
"plugin:eslint-comments/recommended",
// https://github.com/francoismassart/eslint-plugin-tailwindcss/
"plugin:tailwindcss/recommended",
// https://github.com/cypress-io/eslint-plugin-cypress
"plugin:cypress/recommended",
// https://github.com/prettier/eslint-config-prettier
"prettier",
],
// We're using vitest which has a very similar API to jest
// (so the linting plugins work nicely), but we have to
// set the jest version explicitly.
settings: {
jest: {
version: 28,
},
},
rules: {
"unicorn/prefer-ternary": ["error", "only-single-line"],
"unicorn/prefer-switch": [
"error",
{ emptyDefaultCase: "do-nothing-comment" },
],
"unicorn/no-useless-undefined": ["error", { checkArguments: false }],
"unicorn/no-keyword-prefix": ["error", { checkProperties: false }],
// The no-magic-numbers rule from TS works also for JS files
"no-magic-numbers": ["off"],
"@typescript-eslint/no-magic-numbers": [
"warn",
{
ignore: [0, 1, -1],
ignoreArrayIndexes: true,
ignoreDefaultValues: true,
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreTypeIndexes: true,
},
],
"@typescript-eslint/consistent-type-imports": ["warn"],
// Allow unused vars starting with _
"@typescript-eslint/no-unused-vars": [
"warn",
{
vars: "all",
args: "after-used",
ignoreRestSiblings: false,
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
// Disable the prop-types rule as we're using TypeScript
"react/prop-types": ["off"],
"sort-imports": [
"warn",
{
ignoreCase: true,
ignoreDeclarationSort: true, // Use import/order instead for sorting
allowSeparatedGroups: true,
},
],
"import/consistent-type-specifier-style": ["warn", "prefer-top-level"],
"import/first": ["warn"],
"import/no-amd": ["error"],
"import/no-commonjs": ["error"],
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.{test,spec}.{js,jsx,ts,tsx}"],
peerDependencies: false,
packageDir: __dirname,
},
],
"import/no-deprecated": ["warn"],
"import/order": [
"warn",
{
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"import/newline-after-import": ["warn"],
// Getting false positives for React
"import/default": ["off"],
"eslint-comments/no-unused-disable": ["error"],
"eslint-comments/require-description": [
"error",
{ ignore: ["eslint-enable"] },
],
"unicorn/filename-case": ["off"],
"unicorn/no-null": ["off"],
"unicorn/prevent-abbreviations": [
"warn",
{
replacements: {
props: false,
ref: false,
params: false,
},
allowList: {
e2e: true,
},
},
],
},
overrides: [
{
files: ["**/package.json"],
plugins: ["json-files"],
rules: {
"json-files/require-unique-dependency-names": "error",
"json-files/sort-package-json": "warn",
},
},
// Global configs
{
files: "*.js",
rules: {
"import/no-commonjs": ["off"],
"unicorn/prefer-module": ["off"],
},
},
],
};