-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.cjs
82 lines (81 loc) · 2.14 KB
/
.eslintrc.cjs
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
const useExpensiveChecks = Boolean(process.env.USE_EXPENSIVE_LINT_RULES);
const projectGlobs = "./packages/*/tsconfig{.test.json,.json}";
module.exports = {
extends: ["eslint:recommended"],
overrides: [
// Node commonjs files
{
files: ["**/*.cjs"],
env: { node: true },
},
// TS files
{
extends: [
"plugin:@typescript-eslint/recommended",
useExpensiveChecks && "plugin:@typescript-eslint/recommended-requiring-type-checking",
].filter(Boolean),
files: ["**/*.{ts,tsx}"],
parserOptions: {
project: useExpensiveChecks ? projectGlobs : undefined,
},
rules: {
"no-undef": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-misused-promises": [
useExpensiveChecks ? "error" : "off",
{ checksVoidReturn: false },
],
},
},
// Example files
{
files: ["**/*.example.{ts,tsx}"],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
},
},
// Test files
{
files: ["**/*.test.{ts,tsx}"],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
},
},
],
plugins: ["@typescript-eslint", "import"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
impliedStrict: true,
jsx: true,
},
},
rules: {
"no-mixed-spaces-and-tabs": "off",
"no-console": "error",
eqeqeq: "error",
"prefer-const": "error",
"import/no-useless-path-segments": "error",
"import/order": [
"error",
{
alphabetize: { order: "asc" },
groups: [["builtin", "external"], "internal"],
"newlines-between": "always",
pathGroups: [{ pattern: "@docs/**", group: "internal" }],
pathGroupsExcludedImportTypes: [],
},
],
"sort-imports": ["error", { allowSeparatedGroups: true, ignoreDeclarationSort: true }],
},
settings: {
"import/resolver": {
typescript: {
project: projectGlobs,
},
},
},
};