-
Notifications
You must be signed in to change notification settings - Fork 711
/
eslint.config.mjs
164 lines (142 loc) · 5.91 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// @ts-check
import eslint from "@eslint/js";
import tslint from "typescript-eslint";
/** @type {import("typescript-eslint").ConfigWithExtends} */
const config = {
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
// We're fairly frequently on a later version of the TS compiler than
// is officially supported. So far this has never been a real problem.
warnOnUnsupportedTypeScriptVersion: false,
},
},
rules: {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/consistent-type-imports": [
"error",
{
fixStyle: "inline-type-imports",
prefer: "type-imports",
disallowTypeAnnotations: false,
},
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowBoolean: true,
allowNumber: true,
},
],
// This can probably be turned back on in 0.27, when the component hierarchy goes away
"@typescript-eslint/no-unsafe-function-type": "off",
// This one is just annoying since it complains at incomplete code
"no-empty": "off",
// Doesn't properly handle intersections of generics.
"@typescript-eslint/unified-signatures": "off",
// This rule is factually incorrect. Interfaces which extend some type alias can be used to introduce
// new type names. This is useful particularly when dealing with mixins.
"@typescript-eslint/no-empty-interface": "off",
// Conflicts with TS option to require dynamic access for records, which I find more useful.
"@typescript-eslint/no-dynamic-delete": "off",
// Conflicts with the `NeverIfInternal` type used to enforce a stricter API internally
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
// This is sometimes useful for clarity
"@typescript-eslint/no-unnecessary-type-arguments": "off",
// We still use `any` fairly frequently...
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-empty-object-type": "off",
// Needed for the locales today, don't want to make every contributor to those turn it off.
"@typescript-eslint/no-require-imports": [
"error",
{
allow: ["/[^/]+\\.cjs"],
},
],
// Really annoying, doesn't provide any value.
"@typescript-eslint/no-empty-function": "off",
// Declaration merging with a namespace is a necessary tool when working with enums.
"@typescript-eslint/no-namespace": "off",
// Reported by TypeScript
"@typescript-eslint/no-unused-vars": "off",
"no-console": "warn",
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/prefer-literal-enum-member": [
"error",
{ allowBitwiseExpressions: true },
],
// I'd like to have this turned on, but haven't figured out how to tell it about
// checks that are correctly linted as unnecessary for TypeDoc's usage, but not
// for plugin permitted usage.
"@typescript-eslint/no-unnecessary-condition": "off",
// Feel free to turn one of these back on and submit a PR!
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
// https://astexplorer.net/#/gist/82d22728cda8283bf38e956640420af4/4d5e6fbcbceed981f9897a859322ade5f1cb86ee
"no-restricted-syntax": [
"warn",
{
selector: "ImportDeclaration[source.value=/.*perf$/]",
message: "Benchmark calls must be removed before committing.",
},
{
selector:
"MemberExpression[object.name=type][property.name=symbol]",
message:
"Use type.getSymbol() instead, Type.symbol is not properly typed.",
},
{
selector:
"ImportDeclaration[source.value=typescript] ImportNamespaceSpecifier",
message: "TS before 5.7 does not have non-default exports.",
},
{
selector:
"ImportDeclaration[source.value=typescript] ImportDeclaration",
message: "TS before 5.7 does not have non-default exports.",
},
],
"no-fallthrough": ["error", { allowEmptyCase: true }],
},
};
export default tslint.config(
eslint.configs.recommended,
...tslint.configs.strictTypeChecked,
config,
{
ignores: [
"eslint.config.mjs",
"src/test/renderer/specs",
"site/typedoc-plugin-redirect.js",
"site/site-plugin.js",
"dist",
"docs",
"docs2",
"docs-site",
"tmp",
"coverage",
"static/main.js",
"src/lib/output/themes/default/assets",
"**/node_modules",
"example",
"src/test/converter",
"src/test/converter2",
"src/test/module",
"src/test/packages",
"src/test/renderer/",
"src/test/slow/entry-points",
"scripts",
"bin",
],
},
);