Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
52 lines (50 loc) · 1.93 KB
/
Copy patheslint.config.js
File metadata and controls
52 lines (50 loc) · 1.93 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
import js from "@eslint/js";
import tseslint from "typescript-eslint";
export default tseslint.config(
{
ignores: ["node_modules", "dist", "coverage"],
},
js.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
// Enforce strict type checking for TypeScript
"@typescript-eslint/explicit-function-return-type": [
"warn",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
// General best practices
"no-console": ["warn", { allow: ["warn", "error"] }],
"no-debugger": "error",
"eqeqeq": ["error", "always"],
"curly": ["error", "all"],
},
},
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parserOptions: {
project: "./tsconfig.eslint.json",
},
},
},
// Type-aware rules on the shipped code only. The type information they need was already being computed for every file above (`parserOptions.project`), so the expensive part was paid for and none of it collected. `no-floating-promises` alone justifies this: it finds zero violations today, which is precisely when a rule is worth turning on -- it costs nothing now and catches the first unawaited write to the database. src/ only, not tests/: the `no-unsafe-*` family fires ~57 times in test fixtures that parse JSON into `any` and immediately assert on it, which is a legitimate shape for a fixture and a pointless thing to fight in a test.
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ["src/**/*.ts"],
})),
);