-
Notifications
You must be signed in to change notification settings - Fork 39
/
.eslintrc.cjs
180 lines (176 loc) · 4.23 KB
/
.eslintrc.cjs
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/** @type {import("@types/eslint").Linter.Config} */
module.exports = {
env: {
es2022: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:n/recommended",
"plugin:perfectionist/recommended-natural",
"plugin:regexp/recommended",
"plugin:vitest/recommended",
],
ignorePatterns: [
"!.*",
"coverage",
"lib",
"node_modules",
"test/cases",
"pnpm-lock.yaml",
],
overrides: [
{
extends: ["plugin:markdown/recommended-legacy"],
files: ["**/*.md"],
processor: "markdown/markdown",
},
{
extends: [
"plugin:jsdoc/recommended-typescript-error",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/stylistic",
],
files: ["**/*.ts"],
parser: "@typescript-eslint/parser",
rules: {
// These off-by-default rules work well for this repo and we like them on.
"jsdoc/informative-docs": "error",
"logical-assignment-operators": [
"error",
"always",
{ enforceForIfStatements: true },
],
"operator-assignment": "error",
// These on-by-default rules don't work well for this repo and we like them off.
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-property": "off",
"jsdoc/require-returns": "off",
"no-undef": "error",
},
},
{
files: "**/*.md/*.ts",
rules: {
"n/no-missing-import": ["error", { allowModules: ["TypeStat"] }],
},
},
{
excludedFiles: ["**/*.md/*.ts"],
extends: [
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
],
files: ["**/*.ts"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.eslint.json",
},
rules: {
// These off-by-default rules work well for this repo and we like them on.
"deprecation/deprecation": "error",
// These too-strict-by-default rules work well for this repo, once configured.
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
},
],
},
},
{
excludedFiles: ["package.json"],
extends: ["plugin:jsonc/recommended-with-json"],
files: ["*.json", "*.jsonc"],
parser: "jsonc-eslint-parser",
rules: {
"jsonc/comma-dangle": "off",
"jsonc/sort-keys": "error",
},
},
{
files: ["*.jsonc"],
rules: {
"jsonc/no-comments": "off",
},
},
{
extends: ["plugin:package-json/recommended"],
files: ["package.json"],
parser: "jsonc-eslint-parser",
plugins: ["package-json"],
},
{
files: "**/*.test.ts",
rules: {
// These on-by-default rules aren't useful in test files.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
},
},
{
extends: ["plugin:yml/standard", "plugin:yml/prettier"],
files: ["**/*.{yml,yaml}"],
parser: "yaml-eslint-parser",
rules: {
"yml/file-extension": ["error", { extension: "yml" }],
"yml/sort-keys": [
"error",
{
order: { type: "asc" },
pathPattern: "^.*$",
},
],
"yml/sort-sequence-values": [
"error",
{
order: { type: "asc" },
pathPattern: "^.*$",
},
],
},
},
],
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"deprecation",
"jsdoc",
"perfectionist",
"regexp",
"vitest",
],
reportUnusedDisableDirectives: true,
root: true,
rules: {
// These off/less-strict-by-default rules work well for this repo and we like them on.
"@typescript-eslint/no-unused-vars": [
"error",
{ args: "all", caughtErrors: "all" },
],
"no-undef": "off",
// These on-by-default rules don't work well for this repo and we like them off.
"no-case-declarations": "off",
"no-constant-condition": "off",
"no-inner-declarations": "off",
"no-mixed-spaces-and-tabs": "off",
// Stylistic concerns that don't interfere with Prettier
"@typescript-eslint/padding-line-between-statements": [
"error",
{ blankLine: "always", next: "*", prev: "block-like" },
],
"no-useless-rename": "error",
"object-shorthand": "error",
"perfectionist/sort-objects": [
"error",
{
order: "asc",
"partition-by-comment": true,
type: "natural",
},
],
"vitest/consistent-test-it": "error",
},
};