-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
97 lines (83 loc) · 2.89 KB
/
eslint.config.mjs
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
import eslint from "@eslint/js";
import typescriptEslint from "typescript-eslint";
// @ts-expect-error There are no types
import next from "@next/eslint-plugin-next";
import importX from "eslint-plugin-import-x";
import jsxAlly from "eslint-plugin-jsx-a11y";
import react from "eslint-plugin-react";
import reactCompiler from "eslint-plugin-react-compiler";
import reactHooks from "eslint-plugin-react-hooks";
/** @type {import("typescript-eslint").ConfigWithExtends} */
const eslintConfig = {
name: eslint.meta.name,
...eslint.configs.recommended,
};
/** @type {import("typescript-eslint").ConfigWithExtends} */
const reactConfig = {
name: "eslint-plugin-react",
...react.configs.flat["jsx-runtime"],
};
/** @type {import("typescript-eslint").ConfigWithExtends} */
const reactCompilerConfig = {
name: reactCompiler.meta.name,
...reactCompiler.configs.recommended,
};
/** @type {import("typescript-eslint").ConfigWithExtends} */
const myConfig = {
name: "my-eslint-config",
files: ["**/*.{mjs,ts,tsx}"],
rules: {
// avoid shipping a bunch of console.logs leftover accidentally, use other type to indicate it's important to keep
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
// nobody actually wants those, and it's always a "forgot an import" type issue
"no-restricted-globals": ["error", "open", "close", "event"],
// require types to always be present
"@typescript-eslint/consistent-type-imports": [
"error",
{ fixStyle: "inline-type-imports" },
],
// allow unused vars for ignore or rest (that basically the only-non destructive way to remove a prop)
"@typescript-eslint/no-unused-vars": [
"error",
{
ignoreRestSiblings: true,
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// explicit > implicit
"no-extra-boolean-cast": "off",
// sometimes we alias
"@typescript-eslint/no-empty-object-type": [
"error",
{ allowInterfaces: "with-single-extends" },
],
// improve type-check performance
"import-x/no-cycle": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
// recommendations to disable rules by typescript-eslint
// https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
"import-x/named": "off",
"import-x/namespace": "off",
"import-x/default": "off",
"import-x/no-named-as-default-member": "off",
"import-x/no-unresolved": "off",
// my video elements are for video chat, those don't have captions
"jsx-a11y/media-has-caption": "off",
// raise to error
"react-hooks/exhaustive-deps": "error",
},
};
export default typescriptEslint.config([
eslintConfig,
typescriptEslint.configs.strict,
typescriptEslint.configs.stylistic,
reactConfig,
reactCompilerConfig,
reactHooks.configs["recommended-latest"],
jsxAlly.flatConfigs.recommended,
next.flatConfig.coreWebVitals,
importX.flatConfigs.recommended,
myConfig,
]);