-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
135 lines (127 loc) · 4.69 KB
/
eslint.config.mjs
File metadata and controls
135 lines (127 loc) · 4.69 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
import js from "@eslint/js";
import typescript from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import prettier from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier"; // only turn off rules that conflict with prettier doesn't enforce them
import prettierOptions from "./.prettierrc.js"; // prettier config allows us to quick fix with --fix on top of prettier
import sonarjs from "eslint-plugin-sonarjs";
import globals from "globals";
export default [
// Base JavaScript recommended rules
js.configs.recommended,
// TypeScript configuration
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: typescriptParser,
ecmaVersion: 2024,
sourceType: "module",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: process.cwd(),
},
globals: {
...globals.node,
...globals.es2024,
fetch: "readonly",
File: "readonly",
Blob: "readonly",
FormData: "readonly",
console: "readonly",
process: "readonly",
Buffer: "readonly",
__dirname: "readonly",
__filename: "readonly",
global: "readonly",
module: "readonly",
require: "readonly",
exports: "readonly",
},
},
plugins: {
"@typescript-eslint": typescript,
prettier,
sonarjs,
},
rules: {
...typescript.configs.recommended.rules,
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-require-imports": "error",
// TypeScript Strict Enhancements
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{
ignoreConditionalTests: false,
ignoreTernaryTests: false,
ignoreMixedLogicalExpressions: false,
},
],
// Prettier enforcement
"prettier/prettier": ["error", prettierOptions],
"sonarjs/no-all-duplicated-branches": "warn",
"sonarjs/no-duplicate-string": "warn",
// General Code Style
"no-console": ["warn", { allow: ["warn", "error"] }], // for dev only, remove in productiona
"no-debugger": "error",
"no-alert": "error",
"no-undef": "off",
"no-unused-expressions": "error",
"prefer-const": "error",
"no-var": "error",
"no-useless-return": "error",
"no-else-return": "error",
"object-shorthand": ["error", "always"],
"prefer-template": "error",
"arrow-body-style": ["error", "as-needed"],
"prefer-destructuring": [
"error",
{
object: true,
array: false,
},
],
"no-multi-assign": "error",
"no-nested-ternary": "error",
},
},
// Prettier config override
prettierConfig,
// Ignore patterns
{
ignores: [
"dist/**",
"node_modules/**",
"coverage/**",
"prisma/migrations/**",
"*.js",
"*.mjs",
"*.cjs",
],
},
];