-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
126 lines (105 loc) · 3.9 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
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
// @ts-check
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
import tseslint from "typescript-eslint";
// Restricted imports enforced in every package.
const noRestrictedImportsPaths = [
{
name: "console",
importNames: ["assert"],
message: "Always import assert from 'shared/helpers'.",
},
];
export default tseslint.config(
// NOTE: These configurations appear to extend one another in a top-down fashion.
// Global ignores. This must come first before any other configs.
{
ignores: [
"**/node_modules/",
"**/coverage/",
"**/dist/",
"**/*.js",
"**/*.mjs",
"**/*.cjs",
"**/*.config.ts",
"**/*.config.mts",
],
},
// Sets up TS parser and whatnot.
tseslint.configs.base,
{
name: "1-800-call-it-in/base",
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
// TypeScript ESLint setup.
languageOptions: {
parserOptions: {
// Keep up, typescript-eslint, keep up.
warnOnUnsupportedTypeScriptVersion: false,
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
"no-relative-import-paths": noRelativeImportPaths,
},
rules: {
"no-compare-neg-zero": "error",
"no-cond-assign": ["error", "always"],
"no-constant-condition": ["error", { checkLoops: true }],
"no-control-regex": "error",
"no-debugger": "error",
"no-dupe-else-if": "error",
"no-duplicate-case": "error",
"no-empty-character-class": "error",
"no-empty-pattern": "error",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-misleading-character-class": "error",
"no-sparse-arrays": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-useless-backreference": "error",
"use-isnan": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-loss-of-precision": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
// `() => Promise<void>` should be assignable to `() => void`.
checksVoidReturn: false,
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/only-throw-error": ["error"],
// Ban certain imports.
"no-restricted-imports": [
"error",
{
paths: noRestrictedImportsPaths,
},
],
"no-restricted-properties": ["error"],
"no-restricted-syntax": [
"error",
"WithStatement",
// NOTE: if you add to these here, also add them to `packages/client/.eslintrc.json`.
{
selector: "Identifier[name='fit']",
message: "Please do not commit focused tests",
},
{
selector: "Identifier[name='fdescribe']",
message: "Please do not commit focused tests",
},
],
eqeqeq: "error",
"no-unused-expressions": ["error", { enforceForJSX: true }],
"no-console": ["error", { allow: ["warn", "error", "info"] }],
"no-relative-import-paths/no-relative-import-paths": [
"error",
{ allowSameFolder: true },
],
},
},
);