-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.eslintrc.js
212 lines (211 loc) · 7.41 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
const path = require("path");
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
ignorePatterns: [
"!.*",
"**/node_modules/.*",
"packages/server/dist",
"packages/web/.next",
"packages/web/src/graphql/generated.ts",
],
overrides: [
{
files: ["*.js", "*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
extends: [
"eslint:recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:react/jsx-runtime",
"plugin:@next/next/recommended",
"plugin:tailwindcss/recommended",
"plugin:storybook/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
],
plugins: ["unused-imports"],
env: {
browser: true,
es2022: true,
node: true,
},
rules: {
"prettier/prettier": "warn",
"spaced-comment": ["warn", "always", { markers: ["/"] }],
"multiline-comment-style": ["warn", "separate-lines"],
"import/no-useless-path-segments": [
"warn",
{
noUselessIndex: true,
commonjs: true,
},
],
"import/extensions": "warn",
// Whenever vscode users get the "import/no-unused-modules" rule error and they solve
// the error immediately, they have to reload their entire window/eslint server
// to make VS Code ESLint extension happy.
// Because the user dev experience would be quite bad, the rule is disabled in the workspace settings
// For reference: https://github.com/microsoft/vscode-eslint/issues/717
"import/no-unused-modules": [
"error",
{
unusedExports: true,
ignoreExports: [
path.join(__dirname, "packages/server/src/config/orm.ts"),
path.join(__dirname, "packages/server/src/migrations/*"),
path.join(__dirname, "packages/web/src/pages/**"),
path.join(__dirname, "packages/web/tests/playwright.config.ts"),
path.join(__dirname, "packages/web/.storybook/preview.js"),
path.join(
__dirname,
"packages/web/src/components/ui/**/*.stories.tsx"
),
],
},
],
"import/first": "warn",
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"unknown",
"object",
"type",
],
"newlines-between": "never",
alphabetize: {
order: "asc",
},
},
],
"import/newline-after-import": ["warn", { count: 1 }],
"sort-imports": [
"warn",
{
ignoreDeclarationSort: true,
},
],
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
},
],
"react/prop-types": "off",
"prefer-template": "warn",
"@next/next/no-html-link-for-pages": [
"error",
path.join(__dirname, "packages/web/src/pages"),
],
"tailwindcss/no-arbitrary-value": "warn",
},
settings: {
tailwindcss: {
config: path.join(__dirname, "packages/web/tailwind.config.js"),
},
react: {
version: "detect", // It will default to "detect" in the future
},
},
// If eslint takes to long to run, we could remove the below overrides section and uninstall
// eslint-plugin-type-graphql from root package.json or we could specify more specific paths to
// files containing typegraphql code or we could simply restrict lint-staged to only run eslint on
// changed files to speed things up
overrides: [
{
files: ["packages/server/src/**/*.ts"],
parserOptions: {
project: path.join(__dirname, "packages/server/tsconfig.json"),
},
extends: ["plugin:type-graphql/recommended"],
rules: {
"type-graphql/wrong-decorator-signature": [
"error",
{
customTypes: {
string: ["GraphQLEmailAddress", "GraphQLURL"],
},
},
],
},
},
],
},
{
files: ["*.graphql"],
parserOptions: {
operations: ["packages/web/src/graphql/**/*.graphql"],
schema: "packages/server/schema.graphql",
},
rules: {
"prettier/prettier": "warn",
"@graphql-eslint/alphabetize": [
"warn",
{
selections: ["OperationDefinition", "FragmentDefinition"],
variables: ["OperationDefinition"],
arguments: ["Field", "Directive"],
},
],
},
overrides: [
{
files: ["packages/web/src/graphql/**/*.graphql"],
extends: "plugin:@graphql-eslint/operations-recommended",
rules: {
"@graphql-eslint/unique-operation-name": "warn",
"@graphql-eslint/unique-fragment-name": "warn",
"@graphql-eslint/match-document-filename": [
"warn",
{
query: "matchDocumentStyle",
mutation: "matchDocumentStyle",
subscription: "matchDocumentStyle",
fragment: "matchDocumentStyle",
},
],
},
},
{
files: ["packages/server/schema.graphql"],
extends: "plugin:@graphql-eslint/schema-recommended",
rules: {
"@graphql-eslint/strict-id-in-types": "off",
"@graphql-eslint/require-description": "off",
"@graphql-eslint/input-name": [
"warn",
{ checkInputType: true, caseSensitiveInputType: false },
],
// Whenever vscode users get the "@graphql-eslint/no-unused-fields" rule error and they solve
// the error immediately, they have to reload their entire window/eslint server
// to make VS Code ESLint extension happy.
// Because the user dev experience would be quite bad, the rule is disabled in the workspace settings
// For reference: https://github.com/dotansimha/graphql-eslint/issues/593#issuecomment-982066342
// The same applies for these rules (there will probably be added more):
// "@graphql-eslint/fields-on-correct-type", "@graphql-eslint/known-type-names", "@graphql-eslint/unique-operation-name",
// "@graphql-eslint/unique-fragment-name", "@graphql-eslint/require-id-when-available", "@graphql-eslint/no-unreachable-types",
// "@graphql-eslint/provided-required-arguments" and "@graphql-eslint/known-argument-names".
"@graphql-eslint/no-unused-fields": "error",
},
},
],
},
],
};