forked from google-gemini/generative-ai-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
239 lines (238 loc) · 6.01 KB
/
.eslintrc.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"@typescript-eslint/tslint",
"import",
"unused-imports",
],
parserOptions: {
ecmaVersion: 2015,
sourceType: "module",
project: "tsconfig.json",
},
overrides: [
{
files: ["**/*.test.ts", "**/{test,testing}/**/*.ts"],
rules: {
// TODO: Use https://www.npmjs.com/package/eslint-plugin-chai-friendly instead
"no-unused-expressions": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
],
ignorePatterns: ["dist/", ".eslintrc.js"],
rules: {
curly: ["error", "all"],
"guard-for-in": "error",
"no-extra-label": "error",
"no-unused-labels": "error",
"new-parens": "error",
"no-new-wrappers": "error",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-throw-literal": "error",
"no-return-await": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": [
"error",
{
allowShortCircuit: true,
},
],
"no-var": "error",
"object-shorthand": "error",
"prefer-arrow-callback": [
"error",
{
allowNamedFunctions: true,
},
],
"prefer-const": [
"error",
{
destructuring: "all",
},
],
radix: "error",
"unused-imports/no-unused-imports-ts": "error",
"default-case": "error",
eqeqeq: [
"error",
"always",
{
null: "ignore",
},
],
"no-caller": "error",
"no-cond-assign": ["error", "always"],
"use-isnan": "error",
"constructor-super": "error",
"no-restricted-properties": [
"error",
{
object: "it",
property: "skip",
},
{
object: "it",
property: "only",
},
{
object: "describe",
property: "skip",
},
{
object: "describe",
property: "only",
},
{
object: "xit",
},
],
"no-restricted-globals": [
"error",
{ name: "xit" },
{ name: "xdescribe" },
{ name: "parseInt", message: "tsstyle#type-coercion" },
{ name: "parseFloat", message: "tsstyle#type-coercion" },
],
"no-array-constructor": "error",
"sort-imports": [
"error",
{
ignoreCase: false,
ignoreDeclarationSort: true, // don't want to sort import lines, use eslint-plugin-import instead
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
allowSeparatedGroups: true,
},
],
"import/no-default-export": "error",
"import/no-duplicates": "error",
"import/no-extraneous-dependencies": [
"error",
{
packageDir: [__dirname],
peerDependencies: true,
},
],
"@typescript-eslint/array-type": [
"error",
{
default: "array-simple",
},
],
"@typescript-eslint/ban-types": [
"error",
{
types: {
Object: "Use {} or 'object' instead.",
String: "Use 'string' instead.",
Number: "Use 'number' instead.",
Boolean: "Use 'boolean' instead.",
Function: `Avoid the Function type, as it provides little safety for the following reasons:
It provides no type safety when calling the value, which means it's easy to provide the wrong arguments.
It accepts class declarations, which will fail when called, as they are called without the new keyword.`,
},
extendDefaults: false,
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: "class",
format: ["PascalCase"],
},
{
selector: "interface",
format: ["PascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
leadingUnderscore: "allow",
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
accessibility: "no-public",
overrides: {
parameterProperties: "off",
},
},
],
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "as",
},
],
"@typescript-eslint/no-explicit-any": ["error", { ignoreRestArgs: true }],
"@typescript-eslint/no-namespace": [
"error",
{
allowDeclarations: true,
},
],
"@typescript-eslint/triple-slash-reference": [
"error",
{
path: "never",
types: "never",
lib: "never",
},
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/semi": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
},
],
"@typescript-eslint/no-unused-vars": [
"error",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/tslint/config": [
"error",
{
rules: {
"jsdoc-format": true,
"arrow-return-shorthand": true,
},
},
],
},
};