xo 0.54.0 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/plugins.cjs +7 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js +26 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/enum-utils/shared.js +61 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/enum-utils/shared.js.map +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js +2 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unnecessary-condition.js +2 -2
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unnecessary-condition.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unsafe-enum-comparison.js +119 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unsafe-enum-comparison.js.map +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-regexp-exec.js +7 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-regexp-exec.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js +3 -3
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/unified-signatures.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/naming-convention.md +63 -63
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-enum-comparison.md +75 -0
- package/node_modules/@typescript-eslint/eslint-plugin/package.json +5 -5
- package/node_modules/@typescript-eslint/parser/dist/parser.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/parser/dist/parser.js +5 -1
- package/node_modules/@typescript-eslint/parser/dist/parser.js.map +1 -1
- package/node_modules/@typescript-eslint/parser/package.json +5 -5
- package/node_modules/@typescript-eslint/scope-manager/package.json +5 -5
- package/node_modules/@typescript-eslint/type-utils/_ts3.4/dist/typeFlagUtils.d.ts +8 -3
- package/node_modules/@typescript-eslint/type-utils/dist/typeFlagUtils.d.ts +8 -3
- package/node_modules/@typescript-eslint/type-utils/dist/typeFlagUtils.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/type-utils/dist/typeFlagUtils.js +10 -4
- package/node_modules/@typescript-eslint/type-utils/dist/typeFlagUtils.js.map +1 -1
- package/node_modules/@typescript-eslint/type-utils/package.json +5 -5
- package/node_modules/@typescript-eslint/types/package.json +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/package.json +4 -4
- package/node_modules/@typescript-eslint/utils/package.json +6 -6
- package/node_modules/@typescript-eslint/visitor-keys/package.json +3 -3
- package/node_modules/semver/README.md +67 -0
- package/node_modules/semver/bin/semver.js +16 -2
- package/node_modules/semver/classes/comparator.js +37 -33
- package/node_modules/semver/classes/range.js +6 -2
- package/node_modules/semver/classes/semver.js +27 -14
- package/node_modules/semver/functions/diff.js +48 -17
- package/node_modules/semver/functions/inc.js +3 -2
- package/node_modules/semver/functions/parse.js +5 -22
- package/node_modules/semver/index.js +1 -0
- package/node_modules/semver/internal/constants.js +15 -2
- package/node_modules/semver/internal/parse-options.js +14 -10
- package/node_modules/semver/package.json +7 -6
- package/node_modules/semver/ranges/intersects.js +1 -1
- package/node_modules/semver/ranges/subset.js +6 -3
- package/package.json +3 -3
|
@@ -104,10 +104,10 @@ For information about how each selector is applied, see ["How does the rule eval
|
|
|
104
104
|
The `format` option defines the allowed formats for the identifier. This option accepts an array of the following values, and the identifier can match any of them:
|
|
105
105
|
|
|
106
106
|
- `camelCase` - standard camelCase format - no underscores are allowed between characters, and consecutive capitals are allowed (i.e. both `myID` and `myId` are valid).
|
|
107
|
-
- `strictCamelCase` - same as `camelCase`, but consecutive capitals are not allowed (i.e. `myId` is valid, but `myID` is not).
|
|
108
107
|
- `PascalCase` - same as `camelCase`, except the first character must be upper-case.
|
|
109
|
-
- `StrictPascalCase` - same as `strictCamelCase`, except the first character must be upper-case.
|
|
110
108
|
- `snake_case` - standard snake_case format - all characters must be lower-case, and underscores are allowed.
|
|
109
|
+
- `strictCamelCase` - same as `camelCase`, but consecutive capitals are not allowed (i.e. `myId` is valid, but `myID` is not).
|
|
110
|
+
- `StrictPascalCase` - same as `strictCamelCase`, except the first character must be upper-case.
|
|
111
111
|
- `UPPER_CASE` - same as `snake_case`, except all characters must be upper-case.
|
|
112
112
|
|
|
113
113
|
Instead of an array, you may also pass `null`. This signifies "this selector shall not have its format checked".
|
|
@@ -118,8 +118,8 @@ This can be useful if you want to enforce no particular format for a specific se
|
|
|
118
118
|
The `custom` option defines a custom regex that the identifier must (or must not) match. This option allows you to have a bit more finer-grained control over identifiers, letting you ban (or force) certain patterns and substrings.
|
|
119
119
|
Accepts an object with the following properties:
|
|
120
120
|
|
|
121
|
-
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
122
121
|
- `match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`.
|
|
122
|
+
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
123
123
|
|
|
124
124
|
#### `filter`
|
|
125
125
|
|
|
@@ -129,8 +129,8 @@ You can use this to include or exclude specific identifiers from specific config
|
|
|
129
129
|
|
|
130
130
|
Accepts an object with the following properties:
|
|
131
131
|
|
|
132
|
-
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
133
132
|
- `match` - true if the identifier _must_ match the `regex`, false if the identifier _must not_ match the `regex`.
|
|
133
|
+
- `regex` - a string that is then passed into RegExp to create a new regular expression: `new RegExp(regex)`
|
|
134
134
|
|
|
135
135
|
Alternatively, `filter` accepts a regular expression (anything accepted into `new RegExp(filter)`). In this case, it's treated as if you had passed an object with the regex and `match: true`.
|
|
136
136
|
|
|
@@ -138,12 +138,12 @@ Alternatively, `filter` accepts a regular expression (anything accepted into `ne
|
|
|
138
138
|
|
|
139
139
|
The `leadingUnderscore` / `trailingUnderscore` options control whether leading/trailing underscores are considered valid. Accepts one of the following values:
|
|
140
140
|
|
|
141
|
-
- `forbid` - a leading/trailing underscore is not allowed at all.
|
|
142
|
-
- `require` - a single leading/trailing underscore must be included.
|
|
143
|
-
- `requireDouble` - two leading/trailing underscores must be included.
|
|
144
141
|
- `allow` - existence of a single leading/trailing underscore is not explicitly enforced.
|
|
145
142
|
- `allowDouble` - existence of a double leading/trailing underscore is not explicitly enforced.
|
|
146
143
|
- `allowSingleOrDouble` - existence of a single or a double leading/trailing underscore is not explicitly enforced.
|
|
144
|
+
- `forbid` - a leading/trailing underscore is not allowed at all.
|
|
145
|
+
- `require` - a single leading/trailing underscore must be included.
|
|
146
|
+
- `requireDouble` - two leading/trailing underscores must be included.
|
|
147
147
|
|
|
148
148
|
#### `prefix` / `suffix`
|
|
149
149
|
|
|
@@ -163,27 +163,27 @@ If these are provided, the identifier must start with one of the provided values
|
|
|
163
163
|
- The name must match _all_ of the modifiers.
|
|
164
164
|
- For example, if you provide `{ modifiers: ['private','readonly','static'] }`, then it will only match something that is `private static readonly`, and something that is just `private` will not match.
|
|
165
165
|
- The following `modifiers` are allowed:
|
|
166
|
+
- `abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier.
|
|
167
|
+
- `async` - matches any method, function, or function variable which is async via the `async` keyword (e.g. does not match functions that return promises without using `async` keyword)
|
|
166
168
|
- `const` - matches a variable declared as being `const` (`const x = 1`).
|
|
167
169
|
- `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
|
|
168
170
|
- Note that this does not match renamed destructured properties (`const {x: y, a: b = 2}`).
|
|
169
|
-
- `global` - matches a variable/function declared in the top-level scope.
|
|
170
171
|
- `exported` - matches anything that is exported from the module.
|
|
171
|
-
- `
|
|
172
|
-
- `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
|
|
173
|
-
- `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
|
|
174
|
-
- `abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier.
|
|
172
|
+
- `global` - matches a variable/function declared in the top-level scope.
|
|
175
173
|
- `#private` - matches any member with a private identifier (an identifier that starts with `#`)
|
|
176
|
-
- `
|
|
174
|
+
- `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public).
|
|
175
|
+
- `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it).
|
|
176
|
+
- `unused` - matches anything that is not used.
|
|
177
177
|
- `types` allows you to specify which types to match. This option supports simple, primitive types only (`array`,`boolean`,`function`,`number`,`string`).
|
|
178
178
|
- The name must match _one_ of the types.
|
|
179
179
|
- **_NOTE - Using this option will require that you lint with type information._**
|
|
180
180
|
- For example, this lets you do things like enforce that `boolean` variables are prefixed with a verb.
|
|
181
181
|
- The following `types` are allowed:
|
|
182
|
-
- `boolean` matches any type assignable to `boolean | null | undefined`
|
|
183
|
-
- `string` matches any type assignable to `string | null | undefined`
|
|
184
|
-
- `number` matches any type assignable to `number | null | undefined`
|
|
185
182
|
- `array` matches any type assignable to `Array<unknown> | null | undefined`
|
|
183
|
+
- `boolean` matches any type assignable to `boolean | null | undefined`
|
|
186
184
|
- `function` matches any type assignable to `Function | null | undefined`
|
|
185
|
+
- `number` matches any type assignable to `number | null | undefined`
|
|
186
|
+
- `string` matches any type assignable to `string | null | undefined`
|
|
187
187
|
|
|
188
188
|
The ordering of selectors does not matter. The implementation will automatically sort the selectors to ensure they match from most-specific to least specific. It will keep checking selectors in that order until it finds one that matches the name. See ["How does the rule automatically order selectors?"](#how-does-the-rule-automatically-order-selectors)
|
|
189
189
|
|
|
@@ -195,57 +195,57 @@ There are two types of selectors, individual selectors, and grouped selectors.
|
|
|
195
195
|
|
|
196
196
|
Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors.
|
|
197
197
|
|
|
198
|
-
- `
|
|
199
|
-
- Allowed `modifiers`: `
|
|
198
|
+
- `accessor` - matches any accessor.
|
|
199
|
+
- Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
|
|
200
200
|
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
201
|
-
- `
|
|
202
|
-
- Allowed `modifiers`: `
|
|
201
|
+
- `class` - matches any class declaration.
|
|
202
|
+
- Allowed `modifiers`: `abstract`, `exported`, `unused`.
|
|
203
203
|
- Allowed `types`: none.
|
|
204
|
-
- `parameter` - matches any function parameter. Does not match parameter properties.
|
|
205
|
-
- Allowed `modifiers`: `destructured`, `unused`.
|
|
206
|
-
- Allowed `types`: `boolean`, `string`, `number`, `function`, `array`.
|
|
207
|
-
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
|
|
208
|
-
- Allowed `modifiers`: `abstract`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
209
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
210
|
-
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
|
|
211
|
-
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
212
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
213
|
-
- `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
|
|
214
|
-
- Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`.
|
|
215
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
216
|
-
- `parameterProperty` - matches any parameter property.
|
|
217
|
-
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
|
|
218
|
-
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
219
204
|
- `classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
220
205
|
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
|
|
221
206
|
- Allowed `types`: none.
|
|
222
|
-
- `
|
|
223
|
-
- Allowed `modifiers`: `
|
|
224
|
-
- Allowed `types`: none.
|
|
225
|
-
- `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
226
|
-
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
227
|
-
- Allowed `types`: none.
|
|
228
|
-
- `accessor` - matches any accessor.
|
|
229
|
-
- Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`.
|
|
207
|
+
- `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values.
|
|
208
|
+
- Allowed `modifiers`: `abstract`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
230
209
|
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
210
|
+
- `enum` - matches any enum declaration.
|
|
211
|
+
- Allowed `modifiers`: `exported`, `unused`.
|
|
212
|
+
- Allowed `types`: none.
|
|
231
213
|
- `enumMember` - matches any enum member.
|
|
232
214
|
- Allowed `modifiers`: `requiresQuotes`.
|
|
233
215
|
- Allowed `types`: none.
|
|
234
|
-
- `
|
|
235
|
-
- Allowed `modifiers`: `
|
|
216
|
+
- `function` - matches any named function declaration or named function expression.
|
|
217
|
+
- Allowed `modifiers`: `async`, `exported`, `global`, `unused`.
|
|
236
218
|
- Allowed `types`: none.
|
|
237
219
|
- `interface` - matches any interface declaration.
|
|
238
220
|
- Allowed `modifiers`: `exported`, `unused`.
|
|
239
221
|
- Allowed `types`: none.
|
|
222
|
+
- `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
223
|
+
- Allowed `modifiers`: `async`, `public`, `requiresQuotes`.
|
|
224
|
+
- Allowed `types`: none.
|
|
225
|
+
- `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values.
|
|
226
|
+
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
227
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
228
|
+
- `parameter` - matches any function parameter. Does not match parameter properties.
|
|
229
|
+
- Allowed `modifiers`: `destructured`, `unused`.
|
|
230
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
231
|
+
- `parameterProperty` - matches any parameter property.
|
|
232
|
+
- Allowed `modifiers`: `private`, `protected`, `public`, `readonly`.
|
|
233
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
240
234
|
- `typeAlias` - matches any type alias declaration.
|
|
241
235
|
- Allowed `modifiers`: `exported`, `unused`.
|
|
242
236
|
- Allowed `types`: none.
|
|
243
|
-
- `
|
|
244
|
-
- Allowed `modifiers`: `
|
|
237
|
+
- `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors.
|
|
238
|
+
- Allowed `modifiers`: `public`, `requiresQuotes`.
|
|
245
239
|
- Allowed `types`: none.
|
|
246
240
|
- `typeParameter` - matches any generic type parameter declaration.
|
|
247
241
|
- Allowed `modifiers`: `unused`.
|
|
248
242
|
- Allowed `types`: none.
|
|
243
|
+
- `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values.
|
|
244
|
+
- Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`.
|
|
245
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
246
|
+
- `variable` - matches any `const` / `let` / `var` variable name.
|
|
247
|
+
- Allowed `modifiers`: `async`, `const`, `destructured`, `exported`, `global`, `unused`.
|
|
248
|
+
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
249
249
|
|
|
250
250
|
##### Group Selectors
|
|
251
251
|
|
|
@@ -254,20 +254,20 @@ Group Selectors are provided for convenience, and essentially bundle up sets of
|
|
|
254
254
|
- `default` - matches everything.
|
|
255
255
|
- Allowed `modifiers`: all modifiers.
|
|
256
256
|
- Allowed `types`: none.
|
|
257
|
-
- `variableLike` - matches the same as `function`, `parameter` and `variable`.
|
|
258
|
-
- Allowed `modifiers`: `async`, `unused`.
|
|
259
|
-
- Allowed `types`: none.
|
|
260
257
|
- `memberLike` - matches the same as `accessor`, `enumMember`, `method`, `parameterProperty`, `property`.
|
|
261
258
|
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
262
259
|
- Allowed `types`: none.
|
|
263
|
-
- `
|
|
264
|
-
- Allowed `modifiers`: `abstract`, `
|
|
260
|
+
- `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`.
|
|
261
|
+
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
265
262
|
- Allowed `types`: none.
|
|
266
263
|
- `property` - matches the same as `classProperty`, `objectLiteralProperty`, `typeProperty`.
|
|
267
264
|
- Allowed `modifiers`: `abstract`, `async`, `override`, `#private`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`.
|
|
268
265
|
- Allowed `types`: `array`, `boolean`, `function`, `number`, `string`.
|
|
269
|
-
- `
|
|
270
|
-
- Allowed `modifiers`: `abstract`, `
|
|
266
|
+
- `typeLike` - matches the same as `class`, `enum`, `interface`, `typeAlias`, `typeParameter`.
|
|
267
|
+
- Allowed `modifiers`: `abstract`, `unused`.
|
|
268
|
+
- Allowed `types`: none.
|
|
269
|
+
- `variableLike` - matches the same as `function`, `parameter` and `variable`.
|
|
270
|
+
- Allowed `modifiers`: `async`, `unused`.
|
|
271
271
|
- Allowed `types`: none.
|
|
272
272
|
|
|
273
273
|
## FAQ
|
|
@@ -278,18 +278,18 @@ This is a big rule, and there's a lot of docs. Here are a few clarifications tha
|
|
|
278
278
|
|
|
279
279
|
Each selector is checked in the following way:
|
|
280
280
|
|
|
281
|
-
1. check the `selector`
|
|
282
|
-
1. if `selector` is one individual selector → the name's type must be of that type.
|
|
283
|
-
1. if `selector` is a group selector → the name's type must be one of the grouped types.
|
|
284
|
-
1. if `selector` is an array of selectors → apply the above for each selector in the array.
|
|
285
281
|
1. check the `filter`
|
|
286
282
|
1. if `filter` is omitted → skip this step.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
283
|
+
2. if the name matches the `filter` → continue evaluating this selector.
|
|
284
|
+
3. if the name does not match the `filter` → skip this selector and continue to the next selector.
|
|
285
|
+
2. check the `selector`
|
|
286
|
+
1. if `selector` is one individual selector → the name's type must be of that type.
|
|
287
|
+
2. if `selector` is a group selector → the name's type must be one of the grouped types.
|
|
288
|
+
3. if `selector` is an array of selectors → apply the above for each selector in the array.
|
|
289
|
+
3. check the `types`
|
|
290
290
|
1. if `types` is omitted → skip this step.
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
2. if the name has a type in `types` → continue evaluating this selector.
|
|
292
|
+
3. if the name does not have a type in `types` → skip this selector and continue to the next selector.
|
|
293
293
|
|
|
294
294
|
A name is considered to pass the config if it:
|
|
295
295
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Disallow comparing an enum value with a non-enum value.'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
|
+
>
|
|
7
|
+
> See **https://typescript-eslint.io/rules/no-unsafe-enum-comparison** for documentation.
|
|
8
|
+
|
|
9
|
+
The TypeScript compiler can be surprisingly lenient when working with enums.
|
|
10
|
+
For example, it will allow you to compare enum values against numbers even though they might not have any type overlap:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
enum Fruit {
|
|
14
|
+
Apple,
|
|
15
|
+
Banana,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare let fruit: Fruit;
|
|
19
|
+
|
|
20
|
+
fruit === 999; // No error
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This rule flags when an enum typed value is compared to a non-enum `number`.
|
|
24
|
+
|
|
25
|
+
<!--tabs-->
|
|
26
|
+
|
|
27
|
+
### ❌ Incorrect
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
enum Fruit {
|
|
31
|
+
Apple,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare let fruit: Fruit;
|
|
35
|
+
|
|
36
|
+
fruit === 999;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
enum Vegetable {
|
|
41
|
+
Asparagus = 'asparagus',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare let vegetable: Vegetable;
|
|
45
|
+
|
|
46
|
+
vegetable === 'asparagus';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### ✅ Correct
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
enum Fruit {
|
|
53
|
+
Apple,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare let fruit: Fruit;
|
|
57
|
+
|
|
58
|
+
fruit === Fruit.Banana;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
enum Vegetable {
|
|
63
|
+
Asparagus = 'asparagus',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare let vegetable: Vegetable;
|
|
67
|
+
|
|
68
|
+
vegetable === Vegetable.Asparagus;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
<!--/tabs-->
|
|
72
|
+
|
|
73
|
+
## When Not to Use It
|
|
74
|
+
|
|
75
|
+
If you don't mind number and/or literal string constants being compared against enums, you likely don't need this rule.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@eslint-community/regexpp": "^4.4.0",
|
|
48
|
-
"@typescript-eslint/scope-manager": "5.
|
|
49
|
-
"@typescript-eslint/type-utils": "5.
|
|
50
|
-
"@typescript-eslint/utils": "5.
|
|
48
|
+
"@typescript-eslint/scope-manager": "5.59.1",
|
|
49
|
+
"@typescript-eslint/type-utils": "5.59.1",
|
|
50
|
+
"@typescript-eslint/utils": "5.59.1",
|
|
51
51
|
"debug": "^4.3.4",
|
|
52
52
|
"grapheme-splitter": "^1.0.4",
|
|
53
53
|
"ignore": "^5.2.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"type": "opencollective",
|
|
85
85
|
"url": "https://opencollective.com/typescript-eslint"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACb,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAO,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEL,WAAW,EACZ,MAAM,sCAAsC,CAAC;AAO9C,UAAU,oBAAoB;IAC5B,GAAG,EAAE,QAAQ,CAAC,OAAO,GAA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AAE,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -28,10 +28,14 @@ function getLib(compilerOptions) {
|
|
|
28
28
|
}, []);
|
|
29
29
|
}
|
|
30
30
|
const target = (_a = compilerOptions.target) !== null && _a !== void 0 ? _a : typescript_1.ScriptTarget.ES5;
|
|
31
|
-
// https://github.com/
|
|
31
|
+
// https://github.com/microsoft/TypeScript/blob/ae582a22ee1bb052e19b7c1bc4cac60509b574e0/src/compiler/utilitiesPublic.ts#L13-L36
|
|
32
32
|
switch (target) {
|
|
33
33
|
case typescript_1.ScriptTarget.ESNext:
|
|
34
34
|
return ['esnext.full'];
|
|
35
|
+
case typescript_1.ScriptTarget.ES2022:
|
|
36
|
+
return ['es2022.full'];
|
|
37
|
+
case typescript_1.ScriptTarget.ES2021:
|
|
38
|
+
return ['es2021.full'];
|
|
35
39
|
case typescript_1.ScriptTarget.ES2020:
|
|
36
40
|
return ['es2020.full'];
|
|
37
41
|
case typescript_1.ScriptTarget.ES2019:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";;;;;;AAIA,oEAA2D;AAO3D,4EAG8C;AAC9C,kDAA0B;AAE1B,2CAA0C;AAE1C,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,iCAAiC,CAAC,CAAC;AAarD,SAAS,eAAe,CACtB,KAA0B,EAC1B,QAAQ,GAAG,KAAK;IAEhB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC9B,OAAO,QAAQ,CAAC;KACjB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AACpD,SAAS,MAAM,CAAC,eAAgC;;IAC9C,IAAI,eAAe,CAAC,GAAG,EAAE;QACvB,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC7C,MAAM,KAA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C,GAAG,CAAC,qCAAqC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;SACtE;QACD,IACE,cAAc,CAAC,eAAe,KAAK,SAAS;YAC5C,eAAe,CAAC,kBAAkB,IAAI,IAAI,EAC1C;YACA,kEAAkE;YAClE,MAAM,WAAW,GAAG,eAAe,CAAC,kBAAkB;iBACnD,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBACb,IAAI,EAAE,CAAC;YACV,cAAc,CAAC,eAAe,GAAG,WAAW,CAAC;YAC7C,GAAG,CACD,2CAA2C,EAC3C,cAAc,CAAC,eAAe,CAC/B,CAAC;SACH;QACD,IAAI,eAAe,CAAC,qBAAqB,KAAK,IAAI,EAAE;YAClD,qBAAqB,GAAG,IAAI,CAAC;SAC9B;KACF;IAED,IAAI,qBAAqB,EAAE;QACzB,cAAc,CAAC,qBAAqB,GAAG,IAAI,CAAC;KAC7C;IAED,MAAM,YAAY,GAAG,IAAA,uBAAO,EAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAElD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAX,+BAAW,EAAE,CAAC;AACtD,CAAC;AAEe,wCAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/parser",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "An ESLint custom parser which leverages TypeScript ESTree",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@typescript-eslint/scope-manager": "5.
|
|
49
|
-
"@typescript-eslint/types": "5.
|
|
50
|
-
"@typescript-eslint/typescript-estree": "5.
|
|
48
|
+
"@typescript-eslint/scope-manager": "5.59.1",
|
|
49
|
+
"@typescript-eslint/types": "5.59.1",
|
|
50
|
+
"@typescript-eslint/typescript-estree": "5.59.1",
|
|
51
51
|
"debug": "^4.3.4"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
]
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
75
75
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/scope-manager",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "TypeScript scope analyser for ESLint",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"typecheck": "nx typecheck"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/types": "5.
|
|
42
|
-
"@typescript-eslint/visitor-keys": "5.
|
|
41
|
+
"@typescript-eslint/types": "5.59.1",
|
|
42
|
+
"@typescript-eslint/visitor-keys": "5.59.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/glob": "*",
|
|
46
|
-
"@typescript-eslint/typescript-estree": "5.
|
|
46
|
+
"@typescript-eslint/typescript-estree": "5.59.1",
|
|
47
47
|
"glob": "*",
|
|
48
48
|
"jest-specific-snapshot": "*",
|
|
49
49
|
"make-dir": "*",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
]
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
67
67
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
/**
|
|
3
|
-
* Gets all of the type flags in a type, iterating through unions automatically
|
|
3
|
+
* Gets all of the type flags in a type, iterating through unions automatically.
|
|
4
4
|
*/
|
|
5
5
|
export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param isReceiver
|
|
7
|
+
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
|
|
8
|
+
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
|
|
9
|
+
* called function's parameter).
|
|
10
|
+
* @remarks
|
|
11
|
+
* Note that if the type is a union, this function will decompose it into the
|
|
12
|
+
* parts and get the flags of every union constituent. If this is not desired,
|
|
13
|
+
* use the `isTypeFlag` function from tsutils.
|
|
9
14
|
*/
|
|
10
15
|
export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
|
|
11
16
|
//# sourceMappingURL=typeFlagUtils.d.ts.map
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
2
|
/**
|
|
3
|
-
* Gets all of the type flags in a type, iterating through unions automatically
|
|
3
|
+
* Gets all of the type flags in a type, iterating through unions automatically.
|
|
4
4
|
*/
|
|
5
5
|
export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param isReceiver
|
|
7
|
+
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
|
|
8
|
+
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
|
|
9
|
+
* called function's parameter).
|
|
10
|
+
* @remarks
|
|
11
|
+
* Note that if the type is a union, this function will decompose it into the
|
|
12
|
+
* parts and get the flags of every union constituent. If this is not desired,
|
|
13
|
+
* use the `isTypeFlag` function from tsutils.
|
|
9
14
|
*/
|
|
10
15
|
export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
|
|
11
16
|
//# sourceMappingURL=typeFlagUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeFlagUtils.d.ts","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"typeFlagUtils.d.ts","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAOxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,EAAE,EAAE,CAAC,SAAS,EAC1B,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAQT"}
|
|
@@ -26,8 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.isTypeFlagSet = exports.getTypeFlags = void 0;
|
|
27
27
|
const tsutils_1 = require("tsutils");
|
|
28
28
|
const ts = __importStar(require("typescript"));
|
|
29
|
+
const ANY_OR_UNKNOWN = ts.TypeFlags.Any | ts.TypeFlags.Unknown;
|
|
29
30
|
/**
|
|
30
|
-
* Gets all of the type flags in a type, iterating through unions automatically
|
|
31
|
+
* Gets all of the type flags in a type, iterating through unions automatically.
|
|
31
32
|
*/
|
|
32
33
|
function getTypeFlags(type) {
|
|
33
34
|
// @ts-expect-error Since typescript 5.0, this is invalid, but uses 0 as the default value of TypeFlags.
|
|
@@ -39,12 +40,17 @@ function getTypeFlags(type) {
|
|
|
39
40
|
}
|
|
40
41
|
exports.getTypeFlags = getTypeFlags;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param isReceiver
|
|
43
|
+
* @param flagsToCheck The composition of one or more `ts.TypeFlags`.
|
|
44
|
+
* @param isReceiver Whether the type is a receiving type (e.g. the type of a
|
|
45
|
+
* called function's parameter).
|
|
46
|
+
* @remarks
|
|
47
|
+
* Note that if the type is a union, this function will decompose it into the
|
|
48
|
+
* parts and get the flags of every union constituent. If this is not desired,
|
|
49
|
+
* use the `isTypeFlag` function from tsutils.
|
|
44
50
|
*/
|
|
45
51
|
function isTypeFlagSet(type, flagsToCheck, isReceiver) {
|
|
46
52
|
const flags = getTypeFlags(type);
|
|
47
|
-
if (isReceiver && flags &
|
|
53
|
+
if (isReceiver && flags & ANY_OR_UNKNOWN) {
|
|
48
54
|
return true;
|
|
49
55
|
}
|
|
50
56
|
return (flags & flagsToCheck) !== 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeFlagUtils.js","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,+CAAiC;AAEjC;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,wGAAwG;IACxG,IAAI,KAAK,GAAiB,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,IAAA,wBAAc,EAAC,IAAI,CAAC,EAAE;QACpC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,oCAOC;AAED
|
|
1
|
+
{"version":3,"file":"typeFlagUtils.js","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,+CAAiC;AAEjC,MAAM,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;AAE/D;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,wGAAwG;IACxG,IAAI,KAAK,GAAiB,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,IAAA,wBAAc,EAAC,IAAI,CAAC,EAAE;QACpC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,oCAOC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAC3B,IAAa,EACb,YAA0B,EAC1B,UAAoB;IAEpB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjC,IAAI,UAAU,IAAI,KAAK,GAAG,cAAc,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAZD,sCAYC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/type-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "Type utilities for working with TypeScript + ESLint together",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@typescript-eslint/typescript-estree": "5.
|
|
43
|
-
"@typescript-eslint/utils": "5.
|
|
42
|
+
"@typescript-eslint/typescript-estree": "5.59.1",
|
|
43
|
+
"@typescript-eslint/utils": "5.59.1",
|
|
44
44
|
"debug": "^4.3.4",
|
|
45
45
|
"tsutils": "^3.21.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@typescript-eslint/parser": "5.
|
|
48
|
+
"@typescript-eslint/parser": "5.59.1",
|
|
49
49
|
"typescript": "*"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
]
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
71
71
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/types",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "Types for the TypeScript-ESTree AST spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"typescript": "*"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
84
84
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/typescript-estree",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@typescript-eslint/types": "5.
|
|
46
|
-
"@typescript-eslint/visitor-keys": "5.
|
|
45
|
+
"@typescript-eslint/types": "5.59.1",
|
|
46
|
+
"@typescript-eslint/visitor-keys": "5.59.1",
|
|
47
47
|
"debug": "^4.3.4",
|
|
48
48
|
"globby": "^11.1.0",
|
|
49
49
|
"is-glob": "^4.0.3",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
]
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
85
85
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.1",
|
|
4
4
|
"description": "Utilities for working with TypeScript + ESLint together",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@eslint-community/eslint-utils": "^4.2.0",
|
|
43
43
|
"@types/json-schema": "^7.0.9",
|
|
44
44
|
"@types/semver": "^7.3.12",
|
|
45
|
-
"@typescript-eslint/scope-manager": "5.
|
|
46
|
-
"@typescript-eslint/types": "5.
|
|
47
|
-
"@typescript-eslint/typescript-estree": "5.
|
|
45
|
+
"@typescript-eslint/scope-manager": "5.59.1",
|
|
46
|
+
"@typescript-eslint/types": "5.59.1",
|
|
47
|
+
"@typescript-eslint/typescript-estree": "5.59.1",
|
|
48
48
|
"eslint-scope": "^5.1.1",
|
|
49
49
|
"semver": "^7.3.7"
|
|
50
50
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@typescript-eslint/parser": "5.
|
|
55
|
+
"@typescript-eslint/parser": "5.59.1",
|
|
56
56
|
"typescript": "*"
|
|
57
57
|
},
|
|
58
58
|
"funding": {
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
]
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "2f32472787f01545e58d74a1d1cd6248a17a8a9c"
|
|
70
70
|
}
|