Raw
1 import prettier from "eslint-plugin-prettier/recommended"
2 import globals from "globals"
3 import babelParser from "@babel/eslint-parser"
4 import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin"
5 import tsParser from "@typescript-eslint/parser"
6 import path from "node:path"
7 import { fileURLToPath } from "node:url"
8 import js from "@eslint/js"
9 import { FlatCompat } from "@eslint/eslintrc"
10
11 const __filename = fileURLToPath(import.meta.url)
12 const __dirname = path.dirname(__filename)
13 const compat = new FlatCompat({
14 baseDirectory: __dirname,
15 recommendedConfig: js.configs.recommended,
16 allConfig: js.configs.all,
17 })
18
19 export default [
20 prettier,
21 {
22 ignores: [
23 "**/eslint-config-docs",
24 "**/.eslintrc.js",
25 "**/dist",
26 "**/next.config.js",
27 "**/spec",
28 "**/node_modules",
29 "**/public",
30 "**/.eslintrc.js",
31 "generated",
32 ],
33 },
34 ...compat.extends(
35 "eslint:recommended",
36 "plugin:react/recommended",
37 "plugin:react/jsx-runtime",
38 "plugin:react-hooks/recommended",
39 "plugin:@next/next/recommended"
40 ),
41 {
42 languageOptions: {
43 globals: {
44 ...globals.node,
45 ...globals.jest,
46 ...globals.browser,
47 },
48
49 parser: babelParser,
50 ecmaVersion: 13,
51 sourceType: "module",
52
53 parserOptions: {
54 requireConfigFile: false,
55
56 ecmaFeatures: {
57 experimentalDecorators: true,
58 jsx: true,
59 modules: true,
60 },
61
62 project: true,
63 },
64 },
65
66 settings: {
67 react: {
68 version: "detect",
69 },
70 },
71
72 rules: {
73 curly: ["error", "all"],
74 "new-cap": "off",
75 "require-jsdoc": "off",
76 "no-unused-expressions": "off",
77 "no-unused-vars": "off",
78 camelcase: "off",
79 "no-invalid-this": "off",
80
81 "max-len": [
82 "error",
83 {
84 code: 80,
85 ignoreStrings: true,
86 ignoreRegExpLiterals: true,
87 ignoreComments: true,
88 ignoreTrailingComments: true,
89 ignoreUrls: true,
90 ignoreTemplateLiterals: true,
91 },
92 ],
93
94 semi: ["error", "never"],
95
96 quotes: [
97 "error",
98 "double",
99 {
100 allowTemplateLiterals: true,
101 },
102 ],
103
104 "comma-dangle": [
105 "error",
106 {
107 arrays: "always-multiline",
108 objects: "always-multiline",
109 imports: "always-multiline",
110 exports: "always-multiline",
111 functions: "never",
112 },
113 ],
114
115 "object-curly-spacing": ["error", "always"],
116 "arrow-parens": ["error", "always"],
117 "linebreak-style": 0,
118
119 "no-confusing-arrow": [
120 "error",
121 {
122 allowParens: false,
123 },
124 ],
125
126 "space-before-function-paren": [
127 "error",
128 {
129 anonymous: "always",
130 named: "never",
131 asyncArrow: "always",
132 },
133 ],
134
135 "space-infix-ops": "error",
136 "eol-last": ["error", "always"],
137
138 "no-console": [
139 "error",
140 {
141 allow: ["error", "warn"],
142 },
143 ],
144
145 "react/prop-types": [
146 2,
147 {
148 ignore: ["className"],
149 },
150 ],
151 },
152 },
153 ...compat
154 .extends(
155 "plugin:@typescript-eslint/recommended",
156 "plugin:react/recommended"
157 )
158 .map((config) => ({
159 ...config,
160 files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
161 })),
162 {
163 files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
164
165 plugins: {
166 "@typescript-eslint": typescriptEslintEslintPlugin,
167 },
168
169 languageOptions: {
170 parser: tsParser,
171 ecmaVersion: 13,
172 sourceType: "module",
173
174 parserOptions: {
175 project: "./tsconfig.json",
176 },
177 },
178
179 settings: {
180 next: {
181 rootDir: ".",
182 },
183 },
184
185 rules: {
186 "react/react-in-jsx-scope": "off",
187 "@typescript-eslint/prefer-ts-expect-error": "off",
188 "valid-jsdoc": "off",
189
190 "@typescript-eslint/no-non-null-assertion": "off",
191 "@typescript-eslint/no-floating-promises": "error",
192 "@typescript-eslint/await-thenable": "error",
193 "@typescript-eslint/promise-function-async": "error",
194 "@/keyword-spacing": "error",
195
196 "@/space-before-function-paren": [
197 "error",
198 {
199 anonymous: "always",
200 named: "never",
201 asyncArrow: "always",
202 },
203 ],
204
205 "@/space-infix-ops": "error",
206 "@typescript-eslint/no-explicit-any": "warn",
207 "@typescript-eslint/no-unused-vars": "warn",
208 },
209 },
210 ]