-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy path.eslintrc.cjs
More file actions
147 lines (143 loc) · 4.35 KB
/
.eslintrc.cjs
File metadata and controls
147 lines (143 loc) · 4.35 KB
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
/* eslint-env node */
const CODE_EXT = "js,jsx,cjs,mjs,ts,tsx,cts,mts"
const MARKDOWN_EXT = "md,mdx"
module.exports = {
root: true,
plugins: [
"@graphql-eslint",
"mdx",
"@typescript-eslint",
"tailwindcss",
"react",
"@next/next",
"react-hooks",
],
overrides: [
{
files: [`**/*.{${CODE_EXT}}`],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:tailwindcss/recommended",
"prettier",
"plugin:@next/next/recommended",
"plugin:react-hooks/recommended-legacy",
"plugin:react/recommended",
],
rules: {
"react/react-in-jsx-scope": "off", // TS checks this
"react/prop-types": "off", // and this
"no-undef": "off", // and this too
// This is type checking for projects without `@types/react`. Disabled due to false positives.
"react/no-unknown-property": "off",
"react/no-unescaped-entities": [
"warn", // quotes and apostrophes are okay
{
forbid: [
{
char: "<",
alternatives: ["<"],
},
{
char: ">",
alternatives: [">"],
},
{
char: "{",
alternatives: ["{"],
},
{
char: "}",
alternatives: ["}"],
},
],
},
],
"@next/next/no-img-element": "off", // straight up upsell, small `img`s actually don't need optimization
"tailwindcss/classnames-order": "off",
"prefer-const": ["error", { destructuring: "all" }],
"prefer-rest-params": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-types": "off",
"no-restricted-syntax": [
"error",
{
selector:
"JSXElement[openingElement.name.name=/^(Image|NextImage)$/]:not(:has(JSXAttribute[name.name='placeholder']))",
message:
"Pass `placeholder: 'empty' | 'blur'` when calling <Image> or <NextImage>.",
},
],
},
settings: {
tailwindcss: {
whitelist: ["roboto-mono"],
},
react: {
version: "detect",
},
},
},
{
files: [`**/*.{${MARKDOWN_EXT}}`],
parser: "eslint-mdx",
extends: ["plugin:mdx/recommended"],
processor: "mdx/remark",
parserOptions: {
ecmaVersion: 13,
sourceType: "module",
},
settings: {
"mdx/code-blocks": true,
"mdx/language-mapper": {
js: "espree",
graphql: "@graphql-eslint/parser",
ts: "@typescript-eslint/parser",
typescript: "@typescript-eslint/parser",
},
},
rules: {
"mdx/remark": "error",
"no-unused-expressions": "off",
"react/jsx-no-undef": "off",
},
},
{
files: ["**/*.graphql"],
parser: "@graphql-eslint/parser",
rules: {
"@graphql-eslint/no-syntax-errors": "error",
"@graphql-eslint/unique-operation-name": "error",
"@graphql-eslint/unique-fragment-name": "error",
"@graphql-eslint/no-anonymous-operations": "warn",
"@graphql-eslint/lone-anonymous-operation": "error",
"@graphql-eslint/no-duplicate-fields": "error",
"@graphql-eslint/no-unused-fragments": "warn",
"@graphql-eslint/no-duplicate-fragment-names": "error",
"@graphql-eslint/no-undefined-variables": "error",
"@graphql-eslint/unique-variable-names": "error",
},
},
{
files: [`**/*.{${CODE_EXT}}`, `**/*.{${MARKDOWN_EXT}}`],
parserOptions: {
plugins: ["graphql"],
},
},
{
files: [
`src/pages/blog/**/*.{${MARKDOWN_EXT}}`,
`src/pages/graphql-js/running-an-express-graphql-server.mdx`,
`src/code/**/*.{${MARKDOWN_EXT}}`,
`src/app/conf/**/*.{${MARKDOWN_EXT}}`,
],
rules: {
// Disable `remark-lint-first-heading-level` since in blogs we don't want to enforce the first heading to be an `h1`
"mdx/remark": "off",
},
},
],
}