forked from biniyam69/flexile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
161 lines (159 loc) · 5.75 KB
/
eslint.config.js
File metadata and controls
161 lines (159 loc) · 5.75 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { fileURLToPath } from "node:url";
import { includeIgnoreFile } from "@eslint/compat";
import js from "@eslint/js";
import nextPlugin from "@next/eslint-plugin-next";
import prettierConfig from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import globals from "globals";
import tseslint from "typescript-eslint";
const nextIgnores = includeIgnoreFile(fileURLToPath(import.meta.resolve("./frontend/.gitignore")));
nextIgnores.ignores = nextIgnores.ignores.map((file) => `frontend/${file}`);
export default [
includeIgnoreFile(fileURLToPath(import.meta.resolve("./.gitignore"))),
nextIgnores,
{ ignores: ["frontend/utils/routes.*", "backend", ".github"] },
prettierRecommended,
js.configs.recommended,
{
plugins: { import: importPlugin },
linterOptions: {
reportUnusedDisableDirectives: process.env.DISABLE_TYPE_CHECKED ? "off" : "error",
},
rules: {
"arrow-body-style": "error",
eqeqeq: ["error", "smart"],
"logical-assignment-operators": "error",
"no-alert": "error",
"no-console": "error",
"no-else-return": "error",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-var": "error",
"no-unneeded-ternary": "error",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"object-shorthand": "error",
"operator-assignment": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-exponentiation-operator": "error",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-regex-literals": "error",
"prefer-spread": "error",
"prefer-template": "error",
radix: "error",
"require-await": "error",
"require-unicode-regexp": "error",
yoda: "error",
"import/no-duplicates": "error",
"import/order": [
"error",
{
"newlines-between": "never",
named: true,
alphabetize: { order: "asc", caseInsensitive: true },
pathGroups: [{ pattern: "@/**", group: "parent", position: "before" }],
},
],
},
settings: {
next: { rootDir: "frontend" },
},
},
nextPlugin.flatConfig.recommended,
...tseslint.config({
files: ["**/*.ts", "**/*.tsx"],
extends: [...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked],
languageOptions: {
parser: tseslint.parser,
parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
},
rules: {
"@typescript-eslint/no-unnecessary-condition": ["error", { allowConstantLoopConditions: true }],
"@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }],
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
reportUsedIgnorePattern: true,
},
],
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/require-array-sort-compare": ["error", { ignoreStringArrays: true }],
"@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }],
"@typescript-eslint/only-throw-error": "off", // to support `throw redirect`
},
}),
...tseslint.config({
files: ["**/*.tsx"],
extends: [reactPlugin.configs.flat.recommended],
rules: {
"@typescript-eslint/no-unnecessary-type-constraint": "off", // sometimes required in TSX lest it be parsed as a tag
"react/iframe-missing-sandbox": "error",
"react/jsx-no-leaked-render": "error",
"react/jsx-boolean-value": "error",
"react/jsx-curly-brace-presence": ["error", { props: "never", children: "never", propElementValues: "always" }],
"react/jsx-fragments": "error",
"react/jsx-no-constructed-context-values": "error",
"react/jsx-no-script-url": "error",
"react/jsx-no-useless-fragment": "error",
"react/no-unescaped-entities": "off",
"react/no-unstable-nested-components": ["error", { allowAsProps: true }],
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"react/no-unknown-property": "off",
},
settings: {
react: {
version: "detect",
},
},
}),
...tseslint.config({
files: [
".puppeteerrc.cjs",
"eslint.config.js",
"frontend/next.config.ts",
"frontend/drizzle.config.js",
"playwright.config.ts",
],
languageOptions: {
globals: globals.node,
},
extends: [tseslint.configs.base, tseslint.configs.disableTypeChecked],
}),
...tseslint.config({
files: ["e2e/**/*.ts"],
rules: {
"no-console": "off",
"no-debugger": "error",
"no-empty-pattern": "off",
"no-restricted-syntax": [
"error",
{
selector: "CallExpression[callee.property.name='pause']",
message: "page.pause() should not be committed to the codebase",
},
],
},
}),
prettierConfig,
process.env.DISABLE_TYPE_CHECKED ? tseslint.configs.disableTypeChecked : {},
];