generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
121 lines (118 loc) · 3.04 KB
/
eslint.config.js
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
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import stylistic from "@stylistic/eslint-plugin";
export default tseslint.config(
{
// This block defines ignore patterns globally to all configurations below
// (therefore it can use slightly different patterns, see also the eslint "Flat Config" doc)
ignores: [
".husky/*",
".github/*",
".reuse/*",
"docs/*",
"rfcs/*",
"coverage/*",
// Exclude test files
"test/tmp/*",
"test/projects/*",
"test/fixtures/*",
// Exclude generated code
"lib/*",
],
},
// Base configs applying to JS and TS files
eslint.configs.recommended,
stylistic.configs.customize({
indent: "tab",
quotes: "double",
semi: true,
jsx: false,
arrowParens: true,
braceStyle: "1tbs",
blockSpacing: false,
}), {
// Lint all JS files using the eslint parser
files: ["**/*.js"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
},
}, {
// Lint all TS files using the typescript-eslint parser
// Also enable all recommended typescript-eslint rules
files: ["src/**/*.ts", "test/**/*.ts", "scripts/**/*.ts"],
extends: [
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
rules: {
// TypeScript specific overwrites
// We must disable the base rule as it can report incorrect errors
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error", {
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
},
}, {
// To be discussed: Type-aware checks might add quite some additional work when writing tests
// and could even require us to export types that we would otherwise not export
files: ["test/**/*.ts"],
rules: {
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-unary-minus": "off",
},
}, {
// Overwrite any rules from the configurations above for both, JS and TS files
rules: {
"linebreak-style": [
"error",
"unix",
],
"@stylistic/object-curly-spacing": [
"error",
"never",
],
"@stylistic/operator-linebreak": ["error", "after"],
"@stylistic/comma-dangle": ["error", {
functions: "never",
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
enums: "always-multiline",
generics: "always-multiline",
tuples: "always-multiline",
}],
"max-len": [
"error",
{
code: 120,
ignoreUrls: true,
ignoreRegExpLiterals: true,
},
],
"no-implicit-coercion": [
2,
{allow: ["!!"]},
],
"no-console": "error",
},
}
);