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