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