first commit
This commit is contained in:
21
node_modules/@typescript-eslint/eslint-plugin/LICENSE
generated
vendored
Normal file
21
node_modules/@typescript-eslint/eslint-plugin/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 TypeScript ESLint and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
241
node_modules/@typescript-eslint/eslint-plugin/README.md
generated
vendored
Normal file
241
node_modules/@typescript-eslint/eslint-plugin/README.md
generated
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
<h1 align="center">ESLint Plugin TypeScript</h1>
|
||||
|
||||
<p align="center">An ESLint plugin which provides lint rules for TypeScript codebases.</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/typescript-eslint/typescript-eslint/workflows/CI/badge.svg" alt="CI" />
|
||||
<a href="https://www.npmjs.com/package/@typescript-eslint/eslint-plugin"><img src="https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg?style=flat-square" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/package/@typescript-eslint/eslint-plugin"><img src="https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg?style=flat-square" alt="NPM Downloads" /></a>
|
||||
</p>
|
||||
|
||||
## Getting Started
|
||||
|
||||
- **[You can find our Getting Started docs here](https://typescript-eslint.io/docs/linting)**
|
||||
- **[You can find our FAQ / Troubleshooting docs here](https://typescript-eslint.io/docs/linting/troubleshooting)**
|
||||
|
||||
These docs walk you through setting up ESLint, this plugin, and our parser. If you know what you're doing and just want to quick start, read on...
|
||||
|
||||
## Quick-start
|
||||
|
||||
### Installation
|
||||
|
||||
Make sure you have TypeScript and [`@typescript-eslint/parser`](../parser) installed:
|
||||
|
||||
```bash
|
||||
$ yarn add -D typescript @typescript-eslint/parser
|
||||
$ npm i --save-dev typescript @typescript-eslint/parser
|
||||
```
|
||||
|
||||
Then install the plugin:
|
||||
|
||||
```bash
|
||||
$ yarn add -D @typescript-eslint/eslint-plugin
|
||||
$ npm i --save-dev @typescript-eslint/eslint-plugin
|
||||
```
|
||||
|
||||
It is important that you use the same version number for `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`.
|
||||
|
||||
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally.
|
||||
|
||||
### Usage
|
||||
|
||||
Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file, then configure the rules you want to use under the rules section.
|
||||
|
||||
```json
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"rules": {
|
||||
"@typescript-eslint/rule-name": "error"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can also enable all the recommended rules for our plugin. Add `plugin:@typescript-eslint/recommended` in extends:
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": ["plugin:@typescript-eslint/recommended"]
|
||||
}
|
||||
```
|
||||
|
||||
### Recommended Configs
|
||||
|
||||
You can also use [`eslint:recommended`](https://eslint.org/docs/rules/) (the set of rules which are recommended for all projects by the ESLint Team) with this plugin:
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"]
|
||||
}
|
||||
```
|
||||
|
||||
As of version 2 of this plugin, _by design_, none of the rules in the main `recommended` config require type-checking in order to run. This means that they are more lightweight and faster to run.
|
||||
|
||||
Some highly valuable rules require type-checking in order to be implemented correctly, however, so we provide an additional config you can extend from called `recommended-requiring-type-checking`. You would apply this _in addition_ to the recommended configs previously mentioned, e.g.:
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Pro Tip: For larger codebases you may want to consider splitting our linting into two separate stages: 1. fast feedback rules which operate purely based on syntax (no type-checking), 2. rules which are based on semantics (type-checking).
|
||||
|
||||
**[You can read more about linting with type information here](https://typescript-eslint.io/docs/linting/type-linting)**
|
||||
|
||||
## Supported Rules
|
||||
|
||||
<!-- begin base rule list -->
|
||||
|
||||
**Key**: :white_check_mark: = recommended, :lock: = strict, :wrench: = fixable, :thought_balloon: = requires type information
|
||||
|
||||
| Name | Description | :white_check_mark::lock: | :wrench: | :thought_balloon: |
|
||||
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------ | -------- | ----------------- |
|
||||
| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Require using either `T[]` or `Array<T>` for arrays | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md) | Disallow awaiting a value that is not a Thenable | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md) | Disallow `@ts-<directive>` comments or require descriptions after directive | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/ban-tslint-comment`](./docs/rules/ban-tslint-comment.md) | Disallow `// tslint:<rule-flag>` comments | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Disallow certain types | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/class-literal-property-style`](./docs/rules/class-literal-property-style.md) | Enforce that literals on classes are exposed in a consistent style | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/consistent-generic-constructors`](./docs/rules/consistent-generic-constructors.md) | Enforce specifying generic type arguments on type annotation or constructor name of a constructor call | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/consistent-indexed-object-style`](./docs/rules/consistent-indexed-object-style.md) | Require or disallow the `Record` type | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/consistent-type-assertions`](./docs/rules/consistent-type-assertions.md) | Enforce consistent usage of type assertions | :lock: | | |
|
||||
| [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Enforce type definitions to consistently use either `interface` or `type` | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/consistent-type-exports`](./docs/rules/consistent-type-exports.md) | Enforce consistent usage of type exports | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/consistent-type-imports`](./docs/rules/consistent-type-imports.md) | Enforce consistent usage of type imports | | :wrench: | |
|
||||
| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | |
|
||||
| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | |
|
||||
| [`@typescript-eslint/explicit-module-boundary-types`](./docs/rules/explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | |
|
||||
| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | |
|
||||
| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order | | | |
|
||||
| [`@typescript-eslint/method-signature-style`](./docs/rules/method-signature-style.md) | Enforce using a particular method signature syntax | | :wrench: | |
|
||||
| [`@typescript-eslint/naming-convention`](./docs/rules/naming-convention.md) | Enforce naming conventions for everything across a codebase | | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-base-to-string`](./docs/rules/no-base-to-string.md) | Require `.toString()` to only be called on objects which provide useful information when stringified | :lock: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-confusing-non-null-assertion`](./docs/rules/no-confusing-non-null-assertion.md) | Disallow non-null assertion in locations that may be confusing | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/no-confusing-void-expression`](./docs/rules/no-confusing-void-expression.md) | Require expressions of type void to appear in statement position | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-duplicate-enum-values`](./docs/rules/no-duplicate-enum-values.md) | Disallow duplicate enum member values | :lock: | | |
|
||||
| [`@typescript-eslint/no-dynamic-delete`](./docs/rules/no-dynamic-delete.md) | Disallow using the `delete` operator on computed key expressions | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow the `any` type | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/no-extra-non-null-assertion`](./docs/rules/no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Disallow classes used as namespaces | :lock: | | |
|
||||
| [`@typescript-eslint/no-floating-promises`](./docs/rules/no-floating-promises.md) | Require Promise-like statements to be handled appropriately | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/no-invalid-void-type`](./docs/rules/no-invalid-void-type.md) | Disallow `void` type outside of generic or return types | :lock: | | |
|
||||
| [`@typescript-eslint/no-meaningless-void-operator`](./docs/rules/no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-misused-promises`](./docs/rules/no-misused-promises.md) | Disallow Promises in places not designed to handle them | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow custom TypeScript modules and namespaces | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-non-null-asserted-nullish-coalescing`](./docs/rules/no-non-null-asserted-nullish-coalescing.md) | Disallow non-null assertions in the left operand of a nullish coalescing operator | :lock: | | |
|
||||
| [`@typescript-eslint/no-non-null-asserted-optional-chain`](./docs/rules/no-non-null-asserted-optional-chain.md) | Disallow non-null assertions after an optional chain expression | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallow non-null assertions using the `!` postfix operator | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-redundant-type-constituents`](./docs/rules/no-redundant-type-constituents.md) | Disallow members of unions and intersections that do nothing or override type information | | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallow invocation of `require()` | | | |
|
||||
| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow type aliases | | | |
|
||||
| [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./docs/rules/no-unnecessary-boolean-literal-compare.md) | Disallow unnecessary equality comparisons against boolean literals | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unnecessary-condition`](./docs/rules/no-unnecessary-condition.md) | Disallow conditionals where the type is always truthy or always falsy | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Disallow unnecessary namespace qualifiers | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unnecessary-type-arguments`](./docs/rules/no-unnecessary-type-arguments.md) | Disallow type arguments that are equal to the default | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Disallow type assertions that do not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unnecessary-type-constraint`](./docs/rules/no-unnecessary-type-constraint.md) | Disallow unnecessary constraints on generic types | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-unsafe-argument`](./docs/rules/no-unsafe-argument.md) | Disallow calling a function with a value with type `any` | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unsafe-assignment`](./docs/rules/no-unsafe-assignment.md) | Disallow assigning a value with type `any` to variables and properties | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unsafe-call`](./docs/rules/no-unsafe-call.md) | Disallow calling a value with type `any` | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unsafe-member-access`](./docs/rules/no-unsafe-member-access.md) | Disallow member access on a value with type `any` | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unsafe-return`](./docs/rules/no-unsafe-return.md) | Disallow returning a value with type `any` from a function | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-useless-empty-export`](./docs/rules/no-useless-empty-export.md) | Disallow empty exports that don't change anything in a module file | | :wrench: | |
|
||||
| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallow `require` statements except in import statements | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/non-nullable-type-assertion-style`](./docs/rules/non-nullable-type-assertion-style.md) | Enforce non-null assertions over explicit type casts | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/parameter-properties`](./docs/rules/parameter-properties.md) | Require or disallow parameter properties in class constructors | | | |
|
||||
| [`@typescript-eslint/prefer-as-const`](./docs/rules/prefer-as-const.md) | Enforce the use of `as const` over literal type | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/prefer-enum-initializers`](./docs/rules/prefer-enum-initializers.md) | Require each enum member value to be explicitly initialized | | | |
|
||||
| [`@typescript-eslint/prefer-for-of`](./docs/rules/prefer-for-of.md) | Enforce the use of `for-of` loop over the standard `for` loop where possible | :lock: | | |
|
||||
| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Enforce using function types instead of interfaces with call signatures | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/prefer-includes`](./docs/rules/prefer-includes.md) | Enforce `includes` method over `indexOf` method | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-literal-enum-member`](./docs/rules/prefer-literal-enum-member.md) | Require all enum members to be literal values | :lock: | | |
|
||||
| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/prefer-nullish-coalescing`](./docs/rules/prefer-nullish-coalescing.md) | Enforce using the nullish coalescing operator instead of logical chaining | :lock: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-optional-chain`](./docs/rules/prefer-optional-chain.md) | Enforce using concise optional chain expressions instead of chained logical ands | :lock: | | |
|
||||
| [`@typescript-eslint/prefer-readonly`](./docs/rules/prefer-readonly.md) | Require private members to be marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-readonly-parameter-types`](./docs/rules/prefer-readonly-parameter-types.md) | Require function parameters to be typed as `readonly` to prevent accidental mutation of inputs | | | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-reduce-type-parameter`](./docs/rules/prefer-reduce-type-parameter.md) | Enforce using type parameter when calling `Array#reduce` instead of casting | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce `RegExp#exec` over `String#match` if no global flag is provided | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-return-this-type`](./docs/rules/prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce using `String#startsWith` and `String#endsWith` over other equivalent methods of checking substrings | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Enforce using `@ts-expect-error` over `@ts-ignore` | :lock: | :wrench: | |
|
||||
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Require any function or method that returns a Promise to be marked async | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/require-array-sort-compare`](./docs/rules/require-array-sort-compare.md) | Require `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: |
|
||||
| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | Require both operands of addition to have type `number` or `string` | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/restrict-template-expressions`](./docs/rules/restrict-template-expressions.md) | Enforce template literal expressions to be of `string` type | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/sort-type-union-intersection-members`](./docs/rules/sort-type-union-intersection-members.md) | Enforce members of a type union/intersection to be sorted alphabetically | | :wrench: | |
|
||||
| [`@typescript-eslint/strict-boolean-expressions`](./docs/rules/strict-boolean-expressions.md) | Disallow certain types in boolean expressions | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/switch-exhaustiveness-check`](./docs/rules/switch-exhaustiveness-check.md) | Require switch-case statements to be exhaustive with union type | | | :thought_balloon: |
|
||||
| [`@typescript-eslint/triple-slash-reference`](./docs/rules/triple-slash-reference.md) | Disallow certain triple slash directives in favor of ES6-style import declarations | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | |
|
||||
| [`@typescript-eslint/typedef`](./docs/rules/typedef.md) | Require type annotations in certain places | | | |
|
||||
| [`@typescript-eslint/unbound-method`](./docs/rules/unbound-method.md) | Enforce unbound methods are called with their expected scope | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Disallow two overloads that could be unified into one with a union or an optional/rest parameter | :lock: | | |
|
||||
|
||||
<!-- end base rule list -->
|
||||
|
||||
### Extension Rules
|
||||
|
||||
In some cases, ESLint provides a rule itself, but it doesn't support TypeScript syntax; either it crashes, or it ignores the syntax, or it falsely reports against it.
|
||||
In these cases, we create what we call an extension rule; a rule within our plugin that has the same functionality, but also supports TypeScript.
|
||||
|
||||
<!-- begin extension rule list -->
|
||||
|
||||
**Key**: :white_check_mark: = recommended, :lock: = strict, :wrench: = fixable, :thought_balloon: = requires type information
|
||||
|
||||
| Name | Description | :white_check_mark::lock: | :wrench: | :thought_balloon: |
|
||||
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------ | -------- | ----------------- |
|
||||
| [`@typescript-eslint/brace-style`](./docs/rules/brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | |
|
||||
| [`@typescript-eslint/comma-dangle`](./docs/rules/comma-dangle.md) | Require or disallow trailing commas | | :wrench: | |
|
||||
| [`@typescript-eslint/comma-spacing`](./docs/rules/comma-spacing.md) | Enforce consistent spacing before and after commas | | :wrench: | |
|
||||
| [`@typescript-eslint/default-param-last`](./docs/rules/default-param-last.md) | Enforce default parameters to be last | | | |
|
||||
| [`@typescript-eslint/dot-notation`](./docs/rules/dot-notation.md) | Enforce dot notation whenever possible | :lock: | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/func-call-spacing`](./docs/rules/func-call-spacing.md) | Require or disallow spacing between function identifiers and their invocations | | :wrench: | |
|
||||
| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation | | :wrench: | |
|
||||
| [`@typescript-eslint/init-declarations`](./docs/rules/init-declarations.md) | Require or disallow initialization in variable declarations | | | |
|
||||
| [`@typescript-eslint/keyword-spacing`](./docs/rules/keyword-spacing.md) | Enforce consistent spacing before and after keywords | | :wrench: | |
|
||||
| [`@typescript-eslint/lines-between-class-members`](./docs/rules/lines-between-class-members.md) | Require or disallow an empty line between class members | | :wrench: | |
|
||||
| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/no-dupe-class-members`](./docs/rules/no-dupe-class-members.md) | Disallow duplicate class members | | | |
|
||||
| [`@typescript-eslint/no-empty-function`](./docs/rules/no-empty-function.md) | Disallow empty functions | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-extra-parens`](./docs/rules/no-extra-parens.md) | Disallow unnecessary parentheses | | :wrench: | |
|
||||
| [`@typescript-eslint/no-extra-semi`](./docs/rules/no-extra-semi.md) | Disallow unnecessary semicolons | :white_check_mark: | :wrench: | |
|
||||
| [`@typescript-eslint/no-implied-eval`](./docs/rules/no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-invalid-this`](./docs/rules/no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | |
|
||||
| [`@typescript-eslint/no-loop-func`](./docs/rules/no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | |
|
||||
| [`@typescript-eslint/no-loss-of-precision`](./docs/rules/no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-magic-numbers`](./docs/rules/no-magic-numbers.md) | Disallow magic numbers | | | |
|
||||
| [`@typescript-eslint/no-redeclare`](./docs/rules/no-redeclare.md) | Disallow variable redeclaration | | | |
|
||||
| [`@typescript-eslint/no-restricted-imports`](./docs/rules/no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | |
|
||||
| [`@typescript-eslint/no-shadow`](./docs/rules/no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | |
|
||||
| [`@typescript-eslint/no-throw-literal`](./docs/rules/no-throw-literal.md) | Disallow throwing literals as exceptions | :lock: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/no-unused-expressions`](./docs/rules/no-unused-expressions.md) | Disallow unused expressions | | | |
|
||||
| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables | :white_check_mark: | | |
|
||||
| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | | | |
|
||||
| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | :lock: | | |
|
||||
| [`@typescript-eslint/object-curly-spacing`](./docs/rules/object-curly-spacing.md) | Enforce consistent spacing inside braces | | :wrench: | |
|
||||
| [`@typescript-eslint/padding-line-between-statements`](./docs/rules/padding-line-between-statements.md) | Require or disallow padding lines between statements | | :wrench: | |
|
||||
| [`@typescript-eslint/quotes`](./docs/rules/quotes.md) | Enforce the consistent use of either backticks, double, or single quotes | | :wrench: | |
|
||||
| [`@typescript-eslint/require-await`](./docs/rules/require-await.md) | Disallow async functions which have no `await` expression | :white_check_mark: | | :thought_balloon: |
|
||||
| [`@typescript-eslint/return-await`](./docs/rules/return-await.md) | Enforce consistent returning of awaited values | | :wrench: | :thought_balloon: |
|
||||
| [`@typescript-eslint/semi`](./docs/rules/semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | |
|
||||
| [`@typescript-eslint/space-before-blocks`](./docs/rules/space-before-blocks.md) | Enforce consistent spacing before blocks | | :wrench: | |
|
||||
| [`@typescript-eslint/space-before-function-paren`](./docs/rules/space-before-function-paren.md) | Enforce consistent spacing before function parenthesis | | :wrench: | |
|
||||
| [`@typescript-eslint/space-infix-ops`](./docs/rules/space-infix-ops.md) | Require spacing around infix operators | | :wrench: | |
|
||||
|
||||
<!-- end extension rule list -->
|
||||
|
||||
## Contributing
|
||||
|
||||
[See the contributing guide here](../../CONTRIBUTING.md).
|
||||
172
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js
generated
vendored
Normal file
172
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||
'@typescript-eslint/array-type': 'error',
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
'@typescript-eslint/ban-tslint-comment': 'error',
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'brace-style': 'off',
|
||||
'@typescript-eslint/brace-style': 'error',
|
||||
'@typescript-eslint/class-literal-property-style': 'error',
|
||||
'comma-dangle': 'off',
|
||||
'@typescript-eslint/comma-dangle': 'error',
|
||||
'comma-spacing': 'off',
|
||||
'@typescript-eslint/comma-spacing': 'error',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'error',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'error',
|
||||
'@typescript-eslint/consistent-type-assertions': 'error',
|
||||
'@typescript-eslint/consistent-type-definitions': 'error',
|
||||
'@typescript-eslint/consistent-type-exports': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'default-param-last': 'off',
|
||||
'@typescript-eslint/default-param-last': 'error',
|
||||
'dot-notation': 'off',
|
||||
'@typescript-eslint/dot-notation': 'error',
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
'@typescript-eslint/explicit-member-accessibility': 'error',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
||||
'func-call-spacing': 'off',
|
||||
'@typescript-eslint/func-call-spacing': 'error',
|
||||
indent: 'off',
|
||||
'@typescript-eslint/indent': 'error',
|
||||
'init-declarations': 'off',
|
||||
'@typescript-eslint/init-declarations': 'error',
|
||||
'keyword-spacing': 'off',
|
||||
'@typescript-eslint/keyword-spacing': 'error',
|
||||
'lines-between-class-members': 'off',
|
||||
'@typescript-eslint/lines-between-class-members': 'error',
|
||||
'@typescript-eslint/member-delimiter-style': 'error',
|
||||
'@typescript-eslint/member-ordering': 'error',
|
||||
'@typescript-eslint/method-signature-style': 'error',
|
||||
'@typescript-eslint/naming-convention': 'error',
|
||||
'no-array-constructor': 'off',
|
||||
'@typescript-eslint/no-array-constructor': 'error',
|
||||
'@typescript-eslint/no-base-to-string': 'error',
|
||||
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
|
||||
'@typescript-eslint/no-confusing-void-expression': 'error',
|
||||
'no-dupe-class-members': 'off',
|
||||
'@typescript-eslint/no-dupe-class-members': 'error',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
||||
'no-duplicate-imports': 'off',
|
||||
'@typescript-eslint/no-dynamic-delete': 'error',
|
||||
'no-empty-function': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'error',
|
||||
'@typescript-eslint/no-empty-interface': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'error',
|
||||
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
||||
'no-extra-parens': 'off',
|
||||
'@typescript-eslint/no-extra-parens': 'error',
|
||||
'no-extra-semi': 'off',
|
||||
'@typescript-eslint/no-extra-semi': 'error',
|
||||
'@typescript-eslint/no-extraneous-class': 'error',
|
||||
'@typescript-eslint/no-floating-promises': 'error',
|
||||
'@typescript-eslint/no-for-in-array': 'error',
|
||||
'no-implied-eval': 'off',
|
||||
'@typescript-eslint/no-implied-eval': 'error',
|
||||
'@typescript-eslint/no-inferrable-types': 'error',
|
||||
'no-invalid-this': 'off',
|
||||
'@typescript-eslint/no-invalid-this': 'error',
|
||||
'@typescript-eslint/no-invalid-void-type': 'error',
|
||||
'no-loop-func': 'off',
|
||||
'@typescript-eslint/no-loop-func': 'error',
|
||||
'no-loss-of-precision': 'off',
|
||||
'@typescript-eslint/no-loss-of-precision': 'error',
|
||||
'no-magic-numbers': 'off',
|
||||
'@typescript-eslint/no-magic-numbers': 'error',
|
||||
'@typescript-eslint/no-meaningless-void-operator': 'error',
|
||||
'@typescript-eslint/no-misused-new': 'error',
|
||||
'@typescript-eslint/no-misused-promises': 'error',
|
||||
'@typescript-eslint/no-namespace': 'error',
|
||||
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||
'@typescript-eslint/parameter-properties': 'error',
|
||||
'no-redeclare': 'off',
|
||||
'@typescript-eslint/no-redeclare': 'error',
|
||||
'@typescript-eslint/no-redundant-type-constituents': 'error',
|
||||
'@typescript-eslint/no-require-imports': 'error',
|
||||
'no-restricted-imports': 'off',
|
||||
'@typescript-eslint/no-restricted-imports': 'error',
|
||||
'no-shadow': 'off',
|
||||
'@typescript-eslint/no-shadow': 'error',
|
||||
'@typescript-eslint/no-this-alias': 'error',
|
||||
'no-throw-literal': 'off',
|
||||
'@typescript-eslint/no-throw-literal': 'error',
|
||||
'@typescript-eslint/no-type-alias': 'error',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
||||
'@typescript-eslint/no-unnecessary-condition': 'error',
|
||||
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
||||
'@typescript-eslint/no-unsafe-argument': 'error',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'error',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'error',
|
||||
'@typescript-eslint/no-unsafe-return': 'error',
|
||||
'no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'error',
|
||||
'no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'error',
|
||||
'no-use-before-define': 'off',
|
||||
'@typescript-eslint/no-use-before-define': 'error',
|
||||
'no-useless-constructor': 'off',
|
||||
'@typescript-eslint/no-useless-constructor': 'error',
|
||||
'@typescript-eslint/no-useless-empty-export': 'error',
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
|
||||
'object-curly-spacing': 'off',
|
||||
'@typescript-eslint/object-curly-spacing': 'error',
|
||||
'padding-line-between-statements': 'off',
|
||||
'@typescript-eslint/padding-line-between-statements': 'error',
|
||||
'@typescript-eslint/prefer-as-const': 'error',
|
||||
'@typescript-eslint/prefer-enum-initializers': 'error',
|
||||
'@typescript-eslint/prefer-for-of': 'error',
|
||||
'@typescript-eslint/prefer-function-type': 'error',
|
||||
'@typescript-eslint/prefer-includes': 'error',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
||||
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
||||
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
||||
'@typescript-eslint/prefer-optional-chain': 'error',
|
||||
'@typescript-eslint/prefer-readonly': 'error',
|
||||
'@typescript-eslint/prefer-readonly-parameter-types': 'error',
|
||||
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
||||
'@typescript-eslint/prefer-regexp-exec': 'error',
|
||||
'@typescript-eslint/prefer-return-this-type': 'error',
|
||||
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
||||
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
||||
'@typescript-eslint/promise-function-async': 'error',
|
||||
quotes: 'off',
|
||||
'@typescript-eslint/quotes': 'error',
|
||||
'@typescript-eslint/require-array-sort-compare': 'error',
|
||||
'require-await': 'off',
|
||||
'@typescript-eslint/require-await': 'error',
|
||||
'@typescript-eslint/restrict-plus-operands': 'error',
|
||||
'@typescript-eslint/restrict-template-expressions': 'error',
|
||||
'no-return-await': 'off',
|
||||
'@typescript-eslint/return-await': 'error',
|
||||
semi: 'off',
|
||||
'@typescript-eslint/semi': 'error',
|
||||
'@typescript-eslint/sort-type-union-intersection-members': 'error',
|
||||
'space-before-blocks': 'off',
|
||||
'@typescript-eslint/space-before-blocks': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'@typescript-eslint/space-before-function-paren': 'error',
|
||||
'space-infix-ops': 'off',
|
||||
'@typescript-eslint/space-infix-ops': 'error',
|
||||
'@typescript-eslint/strict-boolean-expressions': 'error',
|
||||
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
||||
'@typescript-eslint/triple-slash-reference': 'error',
|
||||
'@typescript-eslint/type-annotation-spacing': 'error',
|
||||
'@typescript-eslint/typedef': 'error',
|
||||
'@typescript-eslint/unbound-method': 'error',
|
||||
'@typescript-eslint/unified-signatures': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=all.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/configs/all.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+BAA+B,EAAE,OAAO;QACxC,mCAAmC,EAAE,OAAO;QAC5C,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;QAChD,8BAA8B,EAAE,OAAO;QACvC,aAAa,EAAE,KAAK;QACpB,gCAAgC,EAAE,OAAO;QACzC,iDAAiD,EAAE,OAAO;QAC1D,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,oDAAoD,EAAE,OAAO;QAC7D,oDAAoD,EAAE,OAAO;QAC7D,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,oBAAoB,EAAE,KAAK;QAC3B,uCAAuC,EAAE,OAAO;QAChD,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,kDAAkD,EAAE,OAAO;QAC3D,kDAAkD,EAAE,OAAO;QAC3D,mDAAmD,EAAE,OAAO;QAC5D,mBAAmB,EAAE,KAAK;QAC1B,sCAAsC,EAAE,OAAO;QAC/C,MAAM,EAAE,KAAK;QACb,2BAA2B,EAAE,OAAO;QACpC,mBAAmB,EAAE,KAAK;QAC1B,sC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,OAAO;QAC3C,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,6CAA6C,EAAE,OAAO;QACtD,8CAA8C,EAAE,OAAO;QACvD,0CAA0C,EAAE,OAAO;QACnD,oCAAoC,EAAE,OAAO;QAC7C,oDAAoD,EAAE,OAAO;QAC7D,iDAAiD,EAAE,OAAO;QAC1D,uCAAuC,EAAE,OAAO;QAChD,4CAA4C,EAAE,OAAO;QACrD,mDAAmD,EAAE,OAAO;QAC5D,2CAA2C,EAAE,OAAO;QACpD,2CAA2C,EAAE,OAAO;QACpD,MAAM,EAAE,KAAK;QACb,2BAA2B,EAAE,OAAO;QACpC,+CAA+C,EAAE,OAAO;QACxD,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,iBAAiB,EAAE,KAAK;QACxB,iCAAiC,EAAE,OAAO;QAC1C,IAAI,EAAE,KAAK;QACX,yBAAyB,EAAE,OAAO;QAClC,yDAAyD,EAAE,OAAO;QAClE,qBAAqB,EAAE,KAAK;QAC5B,wCAAwC,EAAE,OAAO;QACjD,6BAA6B,EAAE,KAAK;QACpC,gDAAgD,EAAE,OAAO;QACzD,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,2CAA2C,EAAE,OAAO;QACpD,4CAA4C,EAAE,OAAO;QACrD,4BAA4B,EAAE,OAAO;QACrC,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;KACjD;CACF,CAAC"}
|
||||
10
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js
generated
vendored
Normal file
10
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: { sourceType: 'module' },
|
||||
plugins: ['@typescript-eslint'],
|
||||
};
|
||||
//# sourceMappingURL=base.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/configs/base.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE;IACvC,OAAO,EAAE,CAAC,oBAAoB,CAAC;CAChC,CAAC"}
|
||||
32
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js
generated
vendored
Normal file
32
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
|
||||
rules: {
|
||||
'constructor-super': 'off',
|
||||
'getter-return': 'off',
|
||||
'no-const-assign': 'off',
|
||||
'no-dupe-args': 'off',
|
||||
'no-dupe-class-members': 'off',
|
||||
'no-dupe-keys': 'off',
|
||||
'no-func-assign': 'off',
|
||||
'no-import-assign': 'off',
|
||||
'no-new-symbol': 'off',
|
||||
'no-obj-calls': 'off',
|
||||
'no-redeclare': 'off',
|
||||
'no-setter-return': 'off',
|
||||
'no-this-before-super': 'off',
|
||||
'no-undef': 'off',
|
||||
'no-unreachable': 'off',
|
||||
'no-unsafe-negation': 'off',
|
||||
'no-var': 'error',
|
||||
'prefer-const': 'error',
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'valid-typeof': 'off', // ts(2367)
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
//# sourceMappingURL=eslint-recommended.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"eslint-recommended.js","sourceRoot":"","sources":["../../src/configs/eslint-recommended.ts"],"names":[],"mappings":";AAKA,iBAAS;IACP,SAAS,EAAE;QACT;YACE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;YAC1C,KAAK,EAAE;gBACL,mBAAmB,EAAE,KAAK;gBAC1B,eAAe,EAAE,KAAK;gBACtB,iBAAiB,EAAE,KAAK;gBACxB,cAAc,EAAE,KAAK;gBACrB,uBAAuB,EAAE,KAAK;gBAC9B,cAAc,EAAE,KAAK;gBACrB,gBAAgB,EAAE,KAAK;gBACvB,kBAAkB,EAAE,KAAK;gBACzB,eAAe,EAAE,KAAK;gBACtB,cAAc,EAAE,KAAK;gBACrB,cAAc,EAAE,KAAK;gBACrB,kBAAkB,EAAE,KAAK;gBACzB,sBAAsB,EAAE,KAAK;gBAC7B,UAAU,EAAE,KAAK;gBACjB,gBAAgB,EAAE,KAAK;gBACvB,oBAAoB,EAAE,KAAK;gBAC3B,QAAQ,EAAE,OAAO;gBACjB,cAAc,EAAE,OAAO;gBACvB,oBAAoB,EAAE,OAAO;gBAC7B,eAAe,EAAE,OAAO;gBACxB,cAAc,EAAE,KAAK,EAAE,WAAW;aACnC;SACF;KACF;CACF,CAAC"}
|
||||
27
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-requiring-type-checking.js
generated
vendored
Normal file
27
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-requiring-type-checking.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/no-floating-promises': 'error',
|
||||
'@typescript-eslint/no-for-in-array': 'error',
|
||||
'no-implied-eval': 'off',
|
||||
'@typescript-eslint/no-implied-eval': 'error',
|
||||
'@typescript-eslint/no-misused-promises': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/no-unsafe-argument': 'error',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'error',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'error',
|
||||
'@typescript-eslint/no-unsafe-return': 'error',
|
||||
'require-await': 'off',
|
||||
'@typescript-eslint/require-await': 'error',
|
||||
'@typescript-eslint/restrict-plus-operands': 'error',
|
||||
'@typescript-eslint/restrict-template-expressions': 'error',
|
||||
'@typescript-eslint/unbound-method': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=recommended-requiring-type-checking.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-requiring-type-checking.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-requiring-type-checking.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"recommended-requiring-type-checking.js","sourceRoot":"","sources":["../../src/configs/recommended-requiring-type-checking.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,wCAAwC,EAAE,OAAO;QACjD,kDAAkD,EAAE,OAAO;QAC3D,uCAAuC,EAAE,OAAO;QAChD,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,mCAAmC,EAAE,OAAO;KAC7C;CACF,CAAC"}
|
||||
37
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js
generated
vendored
Normal file
37
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'no-array-constructor': 'off',
|
||||
'@typescript-eslint/no-array-constructor': 'error',
|
||||
'no-empty-function': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'error',
|
||||
'@typescript-eslint/no-empty-interface': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
||||
'no-extra-semi': 'off',
|
||||
'@typescript-eslint/no-extra-semi': 'error',
|
||||
'@typescript-eslint/no-inferrable-types': 'error',
|
||||
'no-loss-of-precision': 'off',
|
||||
'@typescript-eslint/no-loss-of-precision': 'error',
|
||||
'@typescript-eslint/no-misused-new': 'error',
|
||||
'@typescript-eslint/no-namespace': 'error',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
||||
'@typescript-eslint/no-non-null-assertion': 'warn',
|
||||
'@typescript-eslint/no-this-alias': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
||||
'no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'warn',
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
'@typescript-eslint/prefer-as-const': 'error',
|
||||
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
||||
'@typescript-eslint/triple-slash-reference': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=recommended.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,mCAAmC,EAAE,OAAO;QAC5C,8BAA8B,EAAE,OAAO;QACvC,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mBAAmB,EAAE,KAAK;QAC1B,sCAAsC,EAAE,OAAO;QAC/C,uCAAuC,EAAE,OAAO;QAChD,oCAAoC,EAAE,MAAM;QAC5C,gDAAgD,EAAE,OAAO;QACzD,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,wCAAwC,EAAE,OAAO;QACjD,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,iCAAiC,EAAE,OAAO;QAC1C,wDAAwD,EAAE,OAAO;QACjE,0CAA0C,EAAE,MAAM;QAClD,kCAAkC,EAAE,OAAO;QAC3C,mDAAmD,EAAE,OAAO;QAC5D,gBAAgB,EAAE,KAAK;QACvB,mCAAmC,EAAE,MAAM;QAC3C,oCAAoC,EAAE,OAAO;QAC7C,oCAAoC,EAAE,OAAO;QAC7C,6CAA6C,EAAE,OAAO;QACtD,2CAA2C,EAAE,OAAO;KACrD;CACF,CAAC"}
|
||||
46
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js
generated
vendored
Normal file
46
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/array-type': 'warn',
|
||||
'@typescript-eslint/ban-tslint-comment': 'warn',
|
||||
'@typescript-eslint/class-literal-property-style': 'warn',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'warn',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'warn',
|
||||
'@typescript-eslint/consistent-type-assertions': 'warn',
|
||||
'@typescript-eslint/consistent-type-definitions': 'warn',
|
||||
'dot-notation': 'off',
|
||||
'@typescript-eslint/dot-notation': 'warn',
|
||||
'@typescript-eslint/no-base-to-string': 'warn',
|
||||
'@typescript-eslint/no-confusing-non-null-assertion': 'warn',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'warn',
|
||||
'@typescript-eslint/no-dynamic-delete': 'warn',
|
||||
'@typescript-eslint/no-extraneous-class': 'warn',
|
||||
'@typescript-eslint/no-invalid-void-type': 'warn',
|
||||
'@typescript-eslint/no-meaningless-void-operator': 'warn',
|
||||
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'warn',
|
||||
'no-throw-literal': 'off',
|
||||
'@typescript-eslint/no-throw-literal': 'warn',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
|
||||
'@typescript-eslint/no-unnecessary-condition': 'warn',
|
||||
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
|
||||
'no-useless-constructor': 'off',
|
||||
'@typescript-eslint/no-useless-constructor': 'warn',
|
||||
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
|
||||
'@typescript-eslint/prefer-for-of': 'warn',
|
||||
'@typescript-eslint/prefer-function-type': 'warn',
|
||||
'@typescript-eslint/prefer-includes': 'warn',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'warn',
|
||||
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
||||
'@typescript-eslint/prefer-optional-chain': 'warn',
|
||||
'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
|
||||
'@typescript-eslint/prefer-return-this-type': 'warn',
|
||||
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
|
||||
'@typescript-eslint/prefer-ts-expect-error': 'warn',
|
||||
'@typescript-eslint/unified-signatures': 'warn',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=strict.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/configs/strict.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,+BAA+B,EAAE,MAAM;QACvC,uCAAuC,EAAE,MAAM;QAC/C,iDAAiD,EAAE,MAAM;QACzD,oDAAoD,EAAE,MAAM;QAC5D,oDAAoD,EAAE,MAAM;QAC5D,+CAA+C,EAAE,MAAM;QACvD,gDAAgD,EAAE,MAAM;QACxD,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,MAAM;QACzC,sCAAsC,EAAE,MAAM;QAC9C,oDAAoD,EAAE,MAAM;QAC5D,6CAA6C,EAAE,MAAM;QACrD,sCAAsC,EAAE,MAAM;QAC9C,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,iDAAiD,EAAE,MAAM;QACzD,4DAA4D,EAAE,MAAM;QACpE,kBAAkB,EAAE,KAAK;QACzB,qCAAqC,EAAE,MAAM;QAC7C,2DAA2D,EAAE,MAAM;QACnE,6CAA6C,EAAE,MAAM;QACrD,kDAAkD,EAAE,MAAM;QAC1D,wBAAwB,EAAE,KAAK;QAC/B,2CAA2C,EAAE,MAAM;QACnD,sDAAsD,EAAE,MAAM;QAC9D,kCAAkC,EAAE,MAAM;QAC1C,yCAAyC,EAAE,MAAM;QACjD,oCAAoC,EAAE,MAAM;QAC5C,+CAA+C,EAAE,MAAM;QACvD,8CAA8C,EAAE,MAAM;QACtD,0CAA0C,EAAE,MAAM;QAClD,iDAAiD,EAAE,MAAM;QACzD,4CAA4C,EAAE,MAAM;QACpD,mDAAmD,EAAE,MAAM;QAC3D,2CAA2C,EAAE,MAAM;QACnD,uCAAuC,EAAE,MAAM;KAChD;CACF,CAAC"}
|
||||
23
node_modules/@typescript-eslint/eslint-plugin/dist/index.js
generated
vendored
Normal file
23
node_modules/@typescript-eslint/eslint-plugin/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const rules_1 = __importDefault(require("./rules"));
|
||||
const all_1 = __importDefault(require("./configs/all"));
|
||||
const base_1 = __importDefault(require("./configs/base"));
|
||||
const eslint_recommended_1 = __importDefault(require("./configs/eslint-recommended"));
|
||||
const recommended_1 = __importDefault(require("./configs/recommended"));
|
||||
const recommended_requiring_type_checking_1 = __importDefault(require("./configs/recommended-requiring-type-checking"));
|
||||
const strict_1 = __importDefault(require("./configs/strict"));
|
||||
module.exports = {
|
||||
rules: rules_1.default,
|
||||
configs: {
|
||||
all: all_1.default,
|
||||
base: base_1.default,
|
||||
recommended: recommended_1.default,
|
||||
'eslint-recommended': eslint_recommended_1.default,
|
||||
'recommended-requiring-type-checking': recommended_requiring_type_checking_1.default,
|
||||
strict: strict_1.default,
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,oDAA4B;AAE5B,wDAAgC;AAChC,0DAAkC;AAClC,sFAA6D;AAC7D,wEAAgD;AAChD,wHAA6F;AAC7F,8DAAsC;AAEtC,iBAAS;IACP,KAAK,EAAL,eAAK;IACL,OAAO,EAAE;QACP,GAAG,EAAH,aAAG;QACH,IAAI,EAAJ,cAAI;QACJ,WAAW,EAAX,qBAAW;QACX,oBAAoB,EAAE,4BAAiB;QACvC,qCAAqC,EAAE,6CAAgC;QACvE,MAAM,EAAN,gBAAM;KACP;CACF,CAAC"}
|
||||
158
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
generated
vendored
Normal file
158
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'adjacent-overload-signatures',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require that member overloads be consecutive',
|
||||
recommended: 'error',
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
adjacentSignature: 'All {{name}} signatures should be adjacent.',
|
||||
},
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
/**
|
||||
* Gets the name and attribute of the member being processed.
|
||||
* @param member the member being processed.
|
||||
* @returns the name and attribute of the member or null if it's a member not relevant to the rule.
|
||||
*/
|
||||
function getMemberMethod(member) {
|
||||
var _a, _b;
|
||||
if (!member) {
|
||||
return null;
|
||||
}
|
||||
const isStatic = 'static' in member && !!member.static;
|
||||
switch (member.type) {
|
||||
case utils_1.AST_NODE_TYPES.ExportDefaultDeclaration:
|
||||
case utils_1.AST_NODE_TYPES.ExportNamedDeclaration: {
|
||||
// export statements (e.g. export { a };)
|
||||
// have no declarations, so ignore them
|
||||
if (!member.declaration) {
|
||||
return null;
|
||||
}
|
||||
return getMemberMethod(member.declaration);
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSDeclareFunction:
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration: {
|
||||
const name = (_b = (_a = member.id) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
|
||||
if (name === null) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
name,
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
type: util.MemberNameType.Normal,
|
||||
};
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
return Object.assign(Object.assign({}, util.getNameFromMember(member, sourceCode)), { static: isStatic, callSignature: false });
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return {
|
||||
name: 'call',
|
||||
static: isStatic,
|
||||
callSignature: true,
|
||||
type: util.MemberNameType.Normal,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return {
|
||||
name: 'new',
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
type: util.MemberNameType.Normal,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return Object.assign(Object.assign({}, util.getNameFromMember(member, sourceCode)), { static: isStatic, callSignature: false });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isSameMethod(method1, method2) {
|
||||
return (!!method2 &&
|
||||
method1.name === method2.name &&
|
||||
method1.static === method2.static &&
|
||||
method1.callSignature === method2.callSignature &&
|
||||
method1.type === method2.type);
|
||||
}
|
||||
function getMembers(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.ClassBody:
|
||||
case utils_1.AST_NODE_TYPES.Program:
|
||||
case utils_1.AST_NODE_TYPES.TSModuleBlock:
|
||||
case utils_1.AST_NODE_TYPES.TSInterfaceBody:
|
||||
return node.body;
|
||||
case utils_1.AST_NODE_TYPES.TSTypeLiteral:
|
||||
return node.members;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the body for overload methods.
|
||||
* @param {ASTNode} node the body to be inspected.
|
||||
*/
|
||||
function checkBodyForOverloadMethods(node) {
|
||||
const members = getMembers(node);
|
||||
if (members) {
|
||||
let lastMethod = null;
|
||||
const seenMethods = [];
|
||||
members.forEach(member => {
|
||||
const method = getMemberMethod(member);
|
||||
if (method === null) {
|
||||
lastMethod = null;
|
||||
return;
|
||||
}
|
||||
const index = seenMethods.findIndex(seenMethod => isSameMethod(method, seenMethod));
|
||||
if (index > -1 && !isSameMethod(method, lastMethod)) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'adjacentSignature',
|
||||
data: {
|
||||
name: `${method.static ? 'static ' : ''}${method.name}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
else if (index === -1) {
|
||||
seenMethods.push(method);
|
||||
}
|
||||
lastMethod = method;
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
ClassBody: checkBodyForOverloadMethods,
|
||||
Program: checkBodyForOverloadMethods,
|
||||
TSModuleBlock: checkBodyForOverloadMethods,
|
||||
TSTypeLiteral: checkBodyForOverloadMethods,
|
||||
TSInterfaceBody: checkBodyForOverloadMethods,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=adjacent-overload-signatures.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"adjacent-overload-signatures.js","sourceRoot":"","sources":["../../src/rules/adjacent-overload-signatures.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,8CAAgC;AAahC,kB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YACpC,aAAa,EAAE,2BAA2B;YAC1C,aAAa,EAAE,2BAA2B;YAC1C,eAAe,EAAE,2BAA2B;SAC7C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
236
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js
generated
vendored
Normal file
236
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
/**
|
||||
* Check whatever node can be considered as simple
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function isSimpleType(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSBooleanKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNeverKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNumberKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSBigIntKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSObjectKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSStringKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSSymbolKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSVoidKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNullKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSArrayType:
|
||||
case utils_1.AST_NODE_TYPES.TSUndefinedKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSThisType:
|
||||
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
||||
if (node.typeName &&
|
||||
node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
node.typeName.name === 'Array') {
|
||||
if (!node.typeParameters) {
|
||||
return true;
|
||||
}
|
||||
if (node.typeParameters.params.length === 1) {
|
||||
return isSimpleType(node.typeParameters.params[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (node.typeParameters) {
|
||||
return false;
|
||||
}
|
||||
return isSimpleType(node.typeName);
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if node needs parentheses
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function typeNeedsParentheses(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
||||
return typeNeedsParentheses(node.typeName);
|
||||
case utils_1.AST_NODE_TYPES.TSUnionType:
|
||||
case utils_1.AST_NODE_TYPES.TSFunctionType:
|
||||
case utils_1.AST_NODE_TYPES.TSIntersectionType:
|
||||
case utils_1.AST_NODE_TYPES.TSTypeOperator:
|
||||
case utils_1.AST_NODE_TYPES.TSInferType:
|
||||
case utils_1.AST_NODE_TYPES.TSConstructorType:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
return node.name === 'ReadonlyArray';
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const arrayOption = { enum: ['array', 'generic', 'array-simple'] };
|
||||
exports.default = util.createRule({
|
||||
name: 'array-type',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require using either `T[]` or `Array<T>` for arrays',
|
||||
recommended: 'strict',
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
errorStringGeneric: "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden. Use '{{className}}<{{type}}>' instead.",
|
||||
errorStringArray: "Array type using '{{className}}<{{type}}>' is forbidden. Use '{{readonlyPrefix}}{{type}}[]' instead.",
|
||||
errorStringArraySimple: "Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}[]' instead.",
|
||||
errorStringGenericSimple: "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead.",
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
default: arrayOption,
|
||||
readonly: arrayOption,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
default: 'array',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
var _a;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const defaultOption = options.default;
|
||||
const readonlyOption = (_a = options.readonly) !== null && _a !== void 0 ? _a : defaultOption;
|
||||
/**
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function getMessageType(node) {
|
||||
if (node && isSimpleType(node)) {
|
||||
return sourceCode.getText(node);
|
||||
}
|
||||
return 'T';
|
||||
}
|
||||
return {
|
||||
TSArrayType(node) {
|
||||
const isReadonly = node.parent &&
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.TSTypeOperator &&
|
||||
node.parent.operator === 'readonly';
|
||||
const currentOption = isReadonly ? readonlyOption : defaultOption;
|
||||
if (currentOption === 'array' ||
|
||||
(currentOption === 'array-simple' && isSimpleType(node.elementType))) {
|
||||
return;
|
||||
}
|
||||
const messageId = currentOption === 'generic'
|
||||
? 'errorStringGeneric'
|
||||
: 'errorStringGenericSimple';
|
||||
const errorNode = isReadonly ? node.parent : node;
|
||||
context.report({
|
||||
node: errorNode,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonly ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix: isReadonly ? 'readonly ' : '',
|
||||
type: getMessageType(node.elementType),
|
||||
},
|
||||
fix(fixer) {
|
||||
const typeNode = node.elementType;
|
||||
const arrayType = isReadonly ? 'ReadonlyArray' : 'Array';
|
||||
return [
|
||||
fixer.replaceTextRange([errorNode.range[0], typeNode.range[0]], `${arrayType}<`),
|
||||
fixer.replaceTextRange([typeNode.range[1], errorNode.range[1]], '>'),
|
||||
];
|
||||
},
|
||||
});
|
||||
},
|
||||
TSTypeReference(node) {
|
||||
var _a, _b;
|
||||
if (node.typeName.type !== utils_1.AST_NODE_TYPES.Identifier ||
|
||||
!(node.typeName.name === 'Array' ||
|
||||
node.typeName.name === 'ReadonlyArray')) {
|
||||
return;
|
||||
}
|
||||
const isReadonlyArrayType = node.typeName.name === 'ReadonlyArray';
|
||||
const currentOption = isReadonlyArrayType
|
||||
? readonlyOption
|
||||
: defaultOption;
|
||||
if (currentOption === 'generic') {
|
||||
return;
|
||||
}
|
||||
const readonlyPrefix = isReadonlyArrayType ? 'readonly ' : '';
|
||||
const typeParams = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params;
|
||||
const messageId = currentOption === 'array'
|
||||
? 'errorStringArray'
|
||||
: 'errorStringArraySimple';
|
||||
if (!typeParams || typeParams.length === 0) {
|
||||
// Create an 'any' array
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix,
|
||||
type: 'any',
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(node, `${readonlyPrefix}any[]`);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeParams.length !== 1 ||
|
||||
(currentOption === 'array-simple' && !isSimpleType(typeParams[0]))) {
|
||||
return;
|
||||
}
|
||||
const type = typeParams[0];
|
||||
const typeParens = !util.isParenthesized(type, sourceCode) && typeNeedsParentheses(type);
|
||||
const parentParens = readonlyPrefix &&
|
||||
((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.TSArrayType &&
|
||||
!util.isParenthesized(node.parent.elementType, sourceCode);
|
||||
const start = `${parentParens ? '(' : ''}${readonlyPrefix}${typeParens ? '(' : ''}`;
|
||||
const end = `${typeParens ? ')' : ''}[]${parentParens ? ')' : ''}`;
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix,
|
||||
type: getMessageType(type),
|
||||
},
|
||||
fix(fixer) {
|
||||
return [
|
||||
fixer.replaceTextRange([node.range[0], type.range[0]], start),
|
||||
fixer.replaceTextRange([type.range[1], node.range[1]], end),
|
||||
];
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=array-type.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
62
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js
generated
vendored
Normal file
62
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tsutils = __importStar(require("tsutils"));
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'await-thenable',
|
||||
meta: {
|
||||
docs: {
|
||||
description: 'Disallow awaiting a value that is not a Thenable',
|
||||
recommended: 'error',
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
messages: {
|
||||
await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
|
||||
},
|
||||
schema: [],
|
||||
type: 'problem',
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
const parserServices = util.getParserServices(context);
|
||||
const checker = parserServices.program.getTypeChecker();
|
||||
return {
|
||||
AwaitExpression(node) {
|
||||
const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
||||
const type = checker.getTypeAtLocation(originalNode.expression);
|
||||
if (!util.isTypeAnyType(type) &&
|
||||
!util.isTypeUnknownType(type) &&
|
||||
!tsutils.isThenableType(checker, originalNode.expression, type)) {
|
||||
context.report({
|
||||
messageId: 'await',
|
||||
node,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=await-thenable.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"await-thenable.js","sourceRoot":"","sources":["../../src/rules/await-thenable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,kDAAkD;YAC/D,WAAW,EAAE,OAAO;YACpB,oBAAoB,EAAE,IAAI;SAC3B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,6DAA6D;SACrE;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,cAAc,EAAE,EAAE;IAElB,MAAM,CAAC,OAAO;QACZ,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAExD,OAAO;YACL,eAAe,CAAC,IAAI;gBAClB,MAAM,YAAY,GAAG,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpE,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;gBAEhE,IACE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;oBACzB,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;oBAC7B,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,EAC/D;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,OAAO;wBAClB,IAAI;qBACL,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
151
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js
generated
vendored
Normal file
151
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultMinimumDescriptionLength = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const directiveConfigSchema = {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
enum: ['allow-with-description'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
descriptionFormat: { type: 'string' },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
exports.defaultMinimumDescriptionLength = 3;
|
||||
exports.default = util.createRule({
|
||||
name: 'ban-ts-comment',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Disallow `@ts-<directive>` comments or require descriptions after directive',
|
||||
recommended: 'error',
|
||||
},
|
||||
messages: {
|
||||
tsDirectiveComment: 'Do not use "@ts-{{directive}}" because it alters compilation errors.',
|
||||
tsDirectiveCommentRequiresDescription: 'Include a description after the "@ts-{{directive}}" directive to explain why the @ts-{{directive}} is necessary. The description must be {{minimumDescriptionLength}} characters or longer.',
|
||||
tsDirectiveCommentDescriptionNotMatchPattern: 'The description for the "@ts-{{directive}}" directive must match the {{format}} format.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
'ts-expect-error': directiveConfigSchema,
|
||||
'ts-ignore': directiveConfigSchema,
|
||||
'ts-nocheck': directiveConfigSchema,
|
||||
'ts-check': directiveConfigSchema,
|
||||
minimumDescriptionLength: {
|
||||
type: 'number',
|
||||
default: exports.defaultMinimumDescriptionLength,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
'ts-expect-error': 'allow-with-description',
|
||||
'ts-ignore': true,
|
||||
'ts-nocheck': true,
|
||||
'ts-check': false,
|
||||
minimumDescriptionLength: exports.defaultMinimumDescriptionLength,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
/*
|
||||
The regex used are taken from the ones used in the official TypeScript repo -
|
||||
https://github.com/microsoft/TypeScript/blob/408c760fae66080104bc85c449282c2d207dfe8e/src/compiler/scanner.ts#L288-L296
|
||||
*/
|
||||
const commentDirectiveRegExSingleLine = /^\/*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
|
||||
const commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const descriptionFormats = new Map();
|
||||
for (const directive of [
|
||||
'ts-expect-error',
|
||||
'ts-ignore',
|
||||
'ts-nocheck',
|
||||
'ts-check',
|
||||
]) {
|
||||
const option = options[directive];
|
||||
if (typeof option === 'object' && option.descriptionFormat) {
|
||||
descriptionFormats.set(directive, new RegExp(option.descriptionFormat));
|
||||
}
|
||||
}
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.forEach(comment => {
|
||||
const regExp = comment.type === utils_1.AST_TOKEN_TYPES.Line
|
||||
? commentDirectiveRegExSingleLine
|
||||
: commentDirectiveRegExMultiLine;
|
||||
const match = regExp.exec(comment.value);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
const { directive, description } = match.groups;
|
||||
const fullDirective = `ts-${directive}`;
|
||||
const option = options[fullDirective];
|
||||
if (option === true) {
|
||||
context.report({
|
||||
data: { directive },
|
||||
node: comment,
|
||||
messageId: 'tsDirectiveComment',
|
||||
});
|
||||
}
|
||||
if (option === 'allow-with-description' ||
|
||||
(typeof option === 'object' && option.descriptionFormat)) {
|
||||
const { minimumDescriptionLength = exports.defaultMinimumDescriptionLength, } = options;
|
||||
const format = descriptionFormats.get(fullDirective);
|
||||
if (description.trim().length < minimumDescriptionLength) {
|
||||
context.report({
|
||||
data: { directive, minimumDescriptionLength },
|
||||
node: comment,
|
||||
messageId: 'tsDirectiveCommentRequiresDescription',
|
||||
});
|
||||
}
|
||||
else if (format && !format.test(description)) {
|
||||
context.report({
|
||||
data: { directive, format: format.source },
|
||||
node: comment,
|
||||
messageId: 'tsDirectiveCommentDescriptionNotMatchPattern',
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-ts-comment.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ban-ts-comment.js","sourceRoot":"","sources":["../../src/rules/ban-ts-comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2D;AAC3D,8CAAgC;AAehC,MAAM,qBAAqB,GAAG;IAC5B,KAAK,EAAE;QACL;YACE,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD;YACE,IAAI,EAAE,CAAC,wBAAwB,CAAC;SACjC;QACD;YACE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aACtC;SACF;KACF;CACF,CAAC;AAEW,QAAA,+BAA+B,GAAG,CAAC,CAAC;AAOjD,kBAAe,IAAI,CAAC,UAAU,CAAwB;IACpD,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,6EAA6E;YAC/E,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,kBAAkB,EAChB,sEAAsE;YACxE,qCAAqC,EACnC,6LAA6L;YAC/L,4CAA4C,EAC1C,yFAAyF;SAC5F;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,iBAAiB,EAAE,qBAAqB;oBACxC,WAAW,EAAE,qBAAqB;oBAClC,YAAY,EAAE,qBAAqB;oBACnC,UAAU,EAAE,qBAAqB;oBACjC,w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/dist/rules/ban-tslint-comment.js
generated
vendored
Normal file
78
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
// tslint regex
|
||||
// https://github.com/palantir/tslint/blob/95d9d958833fd9dc0002d18cbe34db20d0fbf437/src/enableDisableRules.ts#L32
|
||||
const ENABLE_DISABLE_REGEX = /^\s*tslint:(enable|disable)(?:-(line|next-line))?(:|\s|$)/;
|
||||
const toText = (text, type) => type === utils_1.AST_TOKEN_TYPES.Line
|
||||
? ['//', text.trim()].join(' ')
|
||||
: ['/*', text.trim(), '*/'].join(' ');
|
||||
exports.default = util.createRule({
|
||||
name: 'ban-tslint-comment',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow `// tslint:<rule-flag>` comments',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
commentDetected: 'tslint comment detected: "{{ text }}"',
|
||||
},
|
||||
schema: [],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: [],
|
||||
create: context => {
|
||||
const sourceCode = context.getSourceCode();
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.forEach(c => {
|
||||
if (ENABLE_DISABLE_REGEX.test(c.value)) {
|
||||
context.report({
|
||||
data: { text: toText(c.value, c.type) },
|
||||
node: c,
|
||||
messageId: 'commentDetected',
|
||||
fix(fixer) {
|
||||
const rangeStart = sourceCode.getIndexFromLoc({
|
||||
column: c.loc.start.column > 0 ? c.loc.start.column - 1 : 0,
|
||||
line: c.loc.start.line,
|
||||
});
|
||||
const rangeEnd = sourceCode.getIndexFromLoc({
|
||||
column: c.loc.end.column,
|
||||
line: c.loc.end.line,
|
||||
});
|
||||
return fixer.removeRange([rangeStart, rangeEnd + 1]);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-tslint-comment.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ban-tslint-comment.js","sourceRoot":"","sources":["../../src/rules/ban-tslint-comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2D;AAC3D,8CAAgC;AAEhC,eAAe;AACf,iHAAiH;AACjH,MAAM,oBAAoB,GACxB,2DAA2D,CAAC;AAE9D,MAAM,MAAM,GAAG,CACb,IAAY,EACZ,IAAkD,EAC1C,EAAE,CACV,IAAI,KAAK,uBAAe,C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AAC,CAAC,CAAC,CAAC;oCAC3D,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI;iCACvB,CAAC,CAAC;gCACH,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC;oCAC1C,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;oCACxB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;iCACrB,CAAC,CAAC;gCACH,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;4BACvD,CAAC;yBACF,CAAC,CAAC;qBACJ;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
199
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js
generated
vendored
Normal file
199
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TYPE_KEYWORDS = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
function removeSpaces(str) {
|
||||
return str.replace(/\s/g, '');
|
||||
}
|
||||
function stringifyNode(node, sourceCode) {
|
||||
return removeSpaces(sourceCode.getText(node));
|
||||
}
|
||||
function getCustomMessage(bannedType) {
|
||||
if (bannedType === null) {
|
||||
return '';
|
||||
}
|
||||
if (typeof bannedType === 'string') {
|
||||
return ` ${bannedType}`;
|
||||
}
|
||||
if (bannedType.message) {
|
||||
return ` ${bannedType.message}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
const defaultTypes = {
|
||||
String: {
|
||||
message: 'Use string instead',
|
||||
fixWith: 'string',
|
||||
},
|
||||
Boolean: {
|
||||
message: 'Use boolean instead',
|
||||
fixWith: 'boolean',
|
||||
},
|
||||
Number: {
|
||||
message: 'Use number instead',
|
||||
fixWith: 'number',
|
||||
},
|
||||
Symbol: {
|
||||
message: 'Use symbol instead',
|
||||
fixWith: 'symbol',
|
||||
},
|
||||
BigInt: {
|
||||
message: 'Use bigint instead',
|
||||
fixWith: 'bigint',
|
||||
},
|
||||
Function: {
|
||||
message: [
|
||||
'The `Function` type accepts any function-like value.',
|
||||
'It provides no type safety when calling the function, which can be a common source of bugs.',
|
||||
'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.',
|
||||
'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
|
||||
].join('\n'),
|
||||
},
|
||||
// object typing
|
||||
Object: {
|
||||
message: [
|
||||
'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.',
|
||||
'- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.',
|
||||
'- If you want a type meaning "any value", you probably want `unknown` instead.',
|
||||
].join('\n'),
|
||||
},
|
||||
'{}': {
|
||||
message: [
|
||||
'`{}` actually means "any non-nullish value".',
|
||||
'- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.',
|
||||
'- If you want a type meaning "any value", you probably want `unknown` instead.',
|
||||
'- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.',
|
||||
].join('\n'),
|
||||
},
|
||||
};
|
||||
exports.TYPE_KEYWORDS = {
|
||||
bigint: utils_1.AST_NODE_TYPES.TSBigIntKeyword,
|
||||
boolean: utils_1.AST_NODE_TYPES.TSBooleanKeyword,
|
||||
never: utils_1.AST_NODE_TYPES.TSNeverKeyword,
|
||||
null: utils_1.AST_NODE_TYPES.TSNullKeyword,
|
||||
number: utils_1.AST_NODE_TYPES.TSNumberKeyword,
|
||||
object: utils_1.AST_NODE_TYPES.TSObjectKeyword,
|
||||
string: utils_1.AST_NODE_TYPES.TSStringKeyword,
|
||||
symbol: utils_1.AST_NODE_TYPES.TSSymbolKeyword,
|
||||
undefined: utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
|
||||
unknown: utils_1.AST_NODE_TYPES.TSUnknownKeyword,
|
||||
void: utils_1.AST_NODE_TYPES.TSVoidKeyword,
|
||||
};
|
||||
exports.default = util.createRule({
|
||||
name: 'ban-types',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow certain types',
|
||||
recommended: 'error',
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
bannedTypeMessage: "Don't use `{{name}}` as a type.{{customMessage}}",
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
types: {
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
oneOf: [
|
||||
{ type: 'null' },
|
||||
{ type: 'boolean' },
|
||||
{ type: 'string' },
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
message: { type: 'string' },
|
||||
fixWith: { type: 'string' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
extendDefaults: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [{}],
|
||||
create(context, [options]) {
|
||||
var _a, _b;
|
||||
const extendDefaults = (_a = options.extendDefaults) !== null && _a !== void 0 ? _a : true;
|
||||
const customTypes = (_b = options.types) !== null && _b !== void 0 ? _b : {};
|
||||
const types = Object.assign({}, extendDefaults ? defaultTypes : {}, customTypes);
|
||||
const bannedTypes = new Map(Object.entries(types).map(([type, data]) => [removeSpaces(type), data]));
|
||||
function checkBannedTypes(typeNode, name = stringifyNode(typeNode, context.getSourceCode())) {
|
||||
const bannedType = bannedTypes.get(name);
|
||||
if (bannedType === undefined || bannedType === false) {
|
||||
return;
|
||||
}
|
||||
const customMessage = getCustomMessage(bannedType);
|
||||
const fixWith = bannedType && typeof bannedType === 'object' && bannedType.fixWith;
|
||||
context.report({
|
||||
node: typeNode,
|
||||
messageId: 'bannedTypeMessage',
|
||||
data: {
|
||||
name,
|
||||
customMessage,
|
||||
},
|
||||
fix: fixWith
|
||||
? (fixer) => fixer.replaceText(typeNode, fixWith)
|
||||
: null,
|
||||
});
|
||||
}
|
||||
const keywordSelectors = util.objectReduceKey(exports.TYPE_KEYWORDS, (acc, keyword) => {
|
||||
if (bannedTypes.has(keyword)) {
|
||||
acc[exports.TYPE_KEYWORDS[keyword]] = (node) => checkBannedTypes(node, keyword);
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
return Object.assign(Object.assign({}, keywordSelectors), { TSTypeLiteral(node) {
|
||||
if (node.members.length) {
|
||||
return;
|
||||
}
|
||||
checkBannedTypes(node);
|
||||
},
|
||||
TSTupleType(node) {
|
||||
if (node.elementTypes.length === 0) {
|
||||
checkBannedTypes(node);
|
||||
}
|
||||
},
|
||||
TSTypeReference(node) {
|
||||
checkBannedTypes(node.typeName);
|
||||
if (node.typeParameters) {
|
||||
checkBannedTypes(node);
|
||||
}
|
||||
} });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-types.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ban-types.js","sourceRoot":"","sources":["../../src/rules/ban-types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA8E;AAC9E,8CAAgC;AAqBhC,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,aAAa,CACpB,IAAmB,EACnB,UAA+B;IAE/B,OAAO,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,gBAAgB,CACvB,UAAkE;IAElE,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,IAAI,UAAU,EAAE,CAAC;KACzB;IAED,IAAI,UAAU,CAAC,OAAO,EAAE;QACtB,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;KACjC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,YAAY,GAAU;IAC1B,MAAM,EAAE;QACN,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,QAAQ;KAClB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,SAAS;KACnB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,QAAQ;KAClB;IACD,MAAM,EAAE;QACN,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,QAAQ;KAClB;IACD,MAA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ACD,eAAe,CAAC,IAAI;gBAClB,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAEhC,IAAI,IAAI,CAAC,cAAc,EAAE;oBACvB,gBAAgB,CAAC,IAAI,CAAC,CAAC;iBACxB;YACH,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
92
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js
generated
vendored
Normal file
92
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const util_1 = require("../util");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('brace-style');
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'brace-style',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent brace style for blocks',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
messages: baseRule.meta.messages,
|
||||
fixable: baseRule.meta.fixable,
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
},
|
||||
defaultOptions: ['1tbs'],
|
||||
create(context) {
|
||||
const [style, { allowSingleLine } = { allowSingleLine: false }] = context.options;
|
||||
const isAllmanStyle = style === 'allman';
|
||||
const sourceCode = context.getSourceCode();
|
||||
const rules = baseRule.create(context);
|
||||
/**
|
||||
* Checks a pair of curly brackets based on the user's config
|
||||
*/
|
||||
function validateCurlyPair(openingCurlyToken, closingCurlyToken) {
|
||||
if (allowSingleLine &&
|
||||
(0, util_1.isTokenOnSameLine)(openingCurlyToken, closingCurlyToken)) {
|
||||
return;
|
||||
}
|
||||
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurlyToken);
|
||||
const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurlyToken);
|
||||
const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurlyToken);
|
||||
if (!isAllmanStyle &&
|
||||
!(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'nextLineOpen',
|
||||
fix: fixer => {
|
||||
const textRange = [
|
||||
tokenBeforeOpeningCurly.range[1],
|
||||
openingCurlyToken.range[0],
|
||||
];
|
||||
const textBetween = sourceCode.text.slice(textRange[0], textRange[1]);
|
||||
if (textBetween.trim()) {
|
||||
return null;
|
||||
}
|
||||
return fixer.replaceTextRange(textRange, ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
if (isAllmanStyle &&
|
||||
(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'sameLineOpen',
|
||||
fix: fixer => fixer.insertTextBefore(openingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
if ((0, util_1.isTokenOnSameLine)(openingCurlyToken, tokenAfterOpeningCurly) &&
|
||||
tokenAfterOpeningCurly !== closingCurlyToken) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'blockSameLine',
|
||||
fix: fixer => fixer.insertTextAfter(openingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
if ((0, util_1.isTokenOnSameLine)(tokenBeforeClosingCurly, closingCurlyToken) &&
|
||||
tokenBeforeClosingCurly !== openingCurlyToken) {
|
||||
context.report({
|
||||
node: closingCurlyToken,
|
||||
messageId: 'singleLineClose',
|
||||
fix: fixer => fixer.insertTextBefore(closingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, rules), { 'TSInterfaceBody, TSModuleBlock'(node) {
|
||||
const openingCurly = sourceCode.getFirstToken(node);
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
},
|
||||
TSEnumDeclaration(node) {
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
const openingCurly = sourceCode.getTokenBefore(node.members.length ? node.members[0] : closingCurly);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
} });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=brace-style.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"brace-style.js","sourceRoot":"","sources":["../../src/rules/brace-style.ts"],"names":[],"mappings":";;AACA,iEAA8D;AAC9D,kCAKiB;AAEjB,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,aAAa,CAAC,CAAC;AAKlD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;QAChC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;QAC9B,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;KAC7B;IACD,cAAc,EAAE,CAAC,MAAM,CAAC;IACxB,MAAM,CAAC,OAAO;QACZ,MAAM,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,GAC7D,OAAO,CAAC,OAAO,CAAC;QAElB,MAAM,aAAa,GAAG,KAAK,KAAK,QAAQ,CAAC;QACzC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAA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C,CAAC,CAAC,CAAC,YAAY,CACpD,CAAC;gBAEH,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
114
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js
generated
vendored
Normal file
114
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const printNodeModifiers = (node, final) => {
|
||||
var _a;
|
||||
return `${(_a = node.accessibility) !== null && _a !== void 0 ? _a : ''}${node.static ? ' static' : ''} ${final} `.trimLeft();
|
||||
};
|
||||
const isSupportedLiteral = (node) => {
|
||||
if (node.type === utils_1.AST_NODE_TYPES.Literal) {
|
||||
return true;
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression ||
|
||||
node.type === utils_1.AST_NODE_TYPES.TemplateLiteral) {
|
||||
return ('quasi' in node ? node.quasi.quasis : node.quasis).length === 1;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.default = util.createRule({
|
||||
name: 'class-literal-property-style',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Enforce that literals on classes are exposed in a consistent style',
|
||||
recommended: 'strict',
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
preferFieldStyle: 'Literals should be exposed using readonly fields.',
|
||||
preferGetterStyle: 'Literals should be exposed using getters.',
|
||||
},
|
||||
schema: [{ enum: ['fields', 'getters'] }],
|
||||
},
|
||||
defaultOptions: ['fields'],
|
||||
create(context, [style]) {
|
||||
return Object.assign(Object.assign({}, (style === 'fields' && {
|
||||
MethodDefinition(node) {
|
||||
if (node.kind !== 'get' ||
|
||||
!node.value.body ||
|
||||
!node.value.body.body.length) {
|
||||
return;
|
||||
}
|
||||
const [statement] = node.value.body.body;
|
||||
if (statement.type !== utils_1.AST_NODE_TYPES.ReturnStatement) {
|
||||
return;
|
||||
}
|
||||
const { argument } = statement;
|
||||
if (!argument || !isSupportedLiteral(argument)) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'preferFieldStyle',
|
||||
fix(fixer) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const name = sourceCode.getText(node.key);
|
||||
let text = '';
|
||||
text += printNodeModifiers(node, 'readonly');
|
||||
text += node.computed ? `[${name}]` : name;
|
||||
text += ` = ${sourceCode.getText(argument)};`;
|
||||
return fixer.replaceText(node, text);
|
||||
},
|
||||
});
|
||||
},
|
||||
})), (style === 'getters' && {
|
||||
PropertyDefinition(node) {
|
||||
if (!node.readonly || node.declare) {
|
||||
return;
|
||||
}
|
||||
const { value } = node;
|
||||
if (!value || !isSupportedLiteral(value)) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'preferGetterStyle',
|
||||
fix(fixer) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const name = sourceCode.getText(node.key);
|
||||
let text = '';
|
||||
text += printNodeModifiers(node, 'get');
|
||||
text += node.computed ? `[${name}]` : name;
|
||||
text += `() { return ${sourceCode.getText(value)}; }`;
|
||||
return fixer.replaceText(node, text);
|
||||
},
|
||||
});
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=class-literal-property-style.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"class-literal-property-style.js","sourceRoot":"","sources":["../../src/rules/class-literal-property-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,8CAAgC;AAUhC,MAAM,kBAAkB,GAAG,CACzB,IAAuB,EACvB,KAAyB,EACjB,EAAE;;IACV,OAAA,GAAG,MAAA,IAAI,CAAC,aAAa,mCAAI,EAAE,GACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC5B,IAAI,KAAK,GAAG,CAAC,QAAQ,EAAE,CAAA;CAAA,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CACzB,IAAmB,EACiB,EAAE;IACtC,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,OAAO,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IACE,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,wBAAwB;QACrD,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,eAAe,EAC5C;QACA,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAA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AK,CAAC,CAAC;wBACxC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;wBAC3C,IAAI,IAAI,eAAe,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;wBAEtD,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACvC,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,EACF;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
180
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js
generated
vendored
Normal file
180
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util = __importStar(require("../util"));
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('comma-dangle');
|
||||
const OPTION_VALUE_SCHEME = [
|
||||
'always-multiline',
|
||||
'always',
|
||||
'never',
|
||||
'only-multiline',
|
||||
];
|
||||
const DEFAULT_OPTION_VALUE = 'never';
|
||||
function normalizeOptions(options) {
|
||||
var _a, _b, _c;
|
||||
if (typeof options === 'string') {
|
||||
return {
|
||||
enums: options,
|
||||
generics: options,
|
||||
tuples: options,
|
||||
};
|
||||
}
|
||||
return {
|
||||
enums: (_a = options.enums) !== null && _a !== void 0 ? _a : DEFAULT_OPTION_VALUE,
|
||||
generics: (_b = options.generics) !== null && _b !== void 0 ? _b : DEFAULT_OPTION_VALUE,
|
||||
tuples: (_c = options.tuples) !== null && _c !== void 0 ? _c : DEFAULT_OPTION_VALUE,
|
||||
};
|
||||
}
|
||||
exports.default = util.createRule({
|
||||
name: 'comma-dangle',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require or disallow trailing commas',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
schema: {
|
||||
definitions: {
|
||||
value: {
|
||||
enum: OPTION_VALUE_SCHEME,
|
||||
},
|
||||
valueWithIgnore: {
|
||||
enum: [...OPTION_VALUE_SCHEME, 'ignore'],
|
||||
},
|
||||
},
|
||||
type: 'array',
|
||||
items: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
$ref: '#/definitions/value',
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
arrays: { $ref: '#/definitions/valueWithIgnore' },
|
||||
objects: { $ref: '#/definitions/valueWithIgnore' },
|
||||
imports: { $ref: '#/definitions/valueWithIgnore' },
|
||||
exports: { $ref: '#/definitions/valueWithIgnore' },
|
||||
functions: { $ref: '#/definitions/valueWithIgnore' },
|
||||
enums: { $ref: '#/definitions/valueWithIgnore' },
|
||||
generics: { $ref: '#/definitions/valueWithIgnore' },
|
||||
tuples: { $ref: '#/definitions/valueWithIgnore' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
additionalProperties: false,
|
||||
},
|
||||
fixable: 'code',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: ['never'],
|
||||
create(context, [options]) {
|
||||
const rules = baseRule.create(context);
|
||||
const sourceCode = context.getSourceCode();
|
||||
const normalizedOptions = normalizeOptions(options);
|
||||
const predicate = {
|
||||
always: forceComma,
|
||||
'always-multiline': forceCommaIfMultiline,
|
||||
'only-multiline': allowCommaIfMultiline,
|
||||
never: forbidComma,
|
||||
ignore: () => { },
|
||||
};
|
||||
function last(nodes) {
|
||||
var _a;
|
||||
return (_a = nodes[nodes.length - 1]) !== null && _a !== void 0 ? _a : null;
|
||||
}
|
||||
function getLastItem(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSEnumDeclaration:
|
||||
return last(node.members);
|
||||
case utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration:
|
||||
return last(node.params);
|
||||
case utils_1.AST_NODE_TYPES.TSTupleType:
|
||||
return last(node.elementTypes);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function getTrailingToken(node) {
|
||||
const last = getLastItem(node);
|
||||
const trailing = last && sourceCode.getTokenAfter(last);
|
||||
return trailing;
|
||||
}
|
||||
function isMultiline(node) {
|
||||
const last = getLastItem(node);
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
return (last === null || last === void 0 ? void 0 : last.loc.end.line) !== (lastToken === null || lastToken === void 0 ? void 0 : lastToken.loc.end.line);
|
||||
}
|
||||
function forbidComma(node) {
|
||||
const last = getLastItem(node);
|
||||
const trailing = getTrailingToken(node);
|
||||
if (last && trailing && util.isCommaToken(trailing)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unexpected',
|
||||
fix(fixer) {
|
||||
return fixer.remove(trailing);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
function forceComma(node) {
|
||||
const last = getLastItem(node);
|
||||
const trailing = getTrailingToken(node);
|
||||
if (last && trailing && !util.isCommaToken(trailing)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missing',
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(last, ',');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
function allowCommaIfMultiline(node) {
|
||||
if (!isMultiline(node)) {
|
||||
forbidComma(node);
|
||||
}
|
||||
}
|
||||
function forceCommaIfMultiline(node) {
|
||||
if (isMultiline(node)) {
|
||||
forceComma(node);
|
||||
}
|
||||
else {
|
||||
forbidComma(node);
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, rules), { TSEnumDeclaration: predicate[normalizedOptions.enums], TSTypeParameterDeclaration: predicate[normalizedOptions.generics], TSTupleType: predicate[normalizedOptions.tuples] });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=comma-dangle.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"comma-dangle.js","sourceRoot":"","sources":["../../src/rules/comma-dangle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,iEAA8D;AAC9D,oDAAoE;AAEpE,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC;AAUnD,MAAM,mBAAmB,GAAG;IAC1B,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,gBAAgB;CACjB,CAAC;AAEF,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAErC,SAAS,gBAAgB,CAAC,OAAe;;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CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,SAAS;oBACpB,GAAG,CAAC,KAAK;wBACP,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBAC1C,CAAC;iBACF,CAAC,CAAC;aACJ;QACH,CAAC;QAED,SAAS,qBAAqB,CAAC,IAAmB;YAChD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBACtB,WAAW,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC;QAED,SAAS,qBAAqB,CAAC,IAAmB;YAChD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;gBACrB,UAAU,CAAC,IAAI,CAAC,CAAC;aAClB;iBAAM;gBACL,WAAW,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC;QAED,uCACK,KAAK,KACR,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,EACrD,0BAA0B,EAAE,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EACjE,WAAW,EAAE,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAChD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
143
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js
generated
vendored
Normal file
143
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'comma-spacing',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce consistent spacing before and after commas',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
before: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
after: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
unexpected: `There should be no space {{loc}} ','.`,
|
||||
missing: `A space is required {{loc}} ','.`,
|
||||
},
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
before: false,
|
||||
after: true,
|
||||
},
|
||||
],
|
||||
create(context, [{ before: spaceBefore, after: spaceAfter }]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const tokensAndComments = sourceCode.tokensAndComments;
|
||||
const ignoredTokens = new Set();
|
||||
/**
|
||||
* Adds null elements of the ArrayExpression or ArrayPattern node to the ignore list
|
||||
* @param node node to evaluate
|
||||
*/
|
||||
function addNullElementsToIgnoreList(node) {
|
||||
let previousToken = sourceCode.getFirstToken(node);
|
||||
for (const element of node.elements) {
|
||||
let token;
|
||||
if (element === null) {
|
||||
token = sourceCode.getTokenAfter(previousToken);
|
||||
if (token && (0, util_1.isCommaToken)(token)) {
|
||||
ignoredTokens.add(token);
|
||||
}
|
||||
}
|
||||
else {
|
||||
token = sourceCode.getTokenAfter(element);
|
||||
}
|
||||
previousToken = token;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds type parameters trailing comma token to the ignore list
|
||||
* @param node node to evaluate
|
||||
*/
|
||||
function addTypeParametersTrailingCommaToIgnoreList(node) {
|
||||
const paramLength = node.params.length;
|
||||
if (paramLength) {
|
||||
const param = node.params[paramLength - 1];
|
||||
const afterToken = sourceCode.getTokenAfter(param);
|
||||
if (afterToken && (0, util_1.isCommaToken)(afterToken)) {
|
||||
ignoredTokens.add(afterToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates the spacing around a comma token.
|
||||
* @param commaToken The token representing the comma
|
||||
* @param prevToken The last token before the comma
|
||||
* @param nextToken The first token after the comma
|
||||
*/
|
||||
function validateCommaSpacing(commaToken, prevToken, nextToken) {
|
||||
if (prevToken &&
|
||||
(0, util_1.isTokenOnSameLine)(prevToken, commaToken) &&
|
||||
spaceBefore !== sourceCode.isSpaceBetweenTokens(prevToken, commaToken)) {
|
||||
context.report({
|
||||
node: commaToken,
|
||||
data: {
|
||||
loc: 'before',
|
||||
},
|
||||
messageId: spaceBefore ? 'missing' : 'unexpected',
|
||||
fix: fixer => spaceBefore
|
||||
? fixer.insertTextBefore(commaToken, ' ')
|
||||
: fixer.replaceTextRange([prevToken.range[1], commaToken.range[0]], ''),
|
||||
});
|
||||
}
|
||||
if (nextToken && (0, util_1.isClosingParenToken)(nextToken)) {
|
||||
return;
|
||||
}
|
||||
if (!spaceAfter && nextToken && nextToken.type === utils_1.AST_TOKEN_TYPES.Line) {
|
||||
return;
|
||||
}
|
||||
if (nextToken &&
|
||||
(0, util_1.isTokenOnSameLine)(commaToken, nextToken) &&
|
||||
spaceAfter !== sourceCode.isSpaceBetweenTokens(commaToken, nextToken)) {
|
||||
context.report({
|
||||
node: commaToken,
|
||||
data: {
|
||||
loc: 'after',
|
||||
},
|
||||
messageId: spaceAfter ? 'missing' : 'unexpected',
|
||||
fix: fixer => spaceAfter
|
||||
? fixer.insertTextAfter(commaToken, ' ')
|
||||
: fixer.replaceTextRange([commaToken.range[1], nextToken.range[0]], ''),
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
TSTypeParameterDeclaration: addTypeParametersTrailingCommaToIgnoreList,
|
||||
ArrayExpression: addNullElementsToIgnoreList,
|
||||
ArrayPattern: addNullElementsToIgnoreList,
|
||||
'Program:exit'() {
|
||||
tokensAndComments.forEach((token, i) => {
|
||||
if (!(0, util_1.isCommaToken)(token)) {
|
||||
return;
|
||||
}
|
||||
const prevToken = tokensAndComments[i - 1];
|
||||
const nextToken = tokensAndComments[i + 1];
|
||||
validateCommaSpacing(token, (0, util_1.isCommaToken)(prevToken) || ignoredTokens.has(token)
|
||||
? null
|
||||
: prevToken, (nextToken && (0, util_1.isCommaToken)(nextToken)) || ignoredTokens.has(token)
|
||||
? null
|
||||
: nextToken);
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=comma-spacing.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"comma-spacing.js","sourceRoot":"","sources":["../../src/rules/comma-spacing.ts"],"names":[],"mappings":";;AAAA,oDAAqE;AACrE,kCAKiB;AAUjB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,oDAAoD;YACjE,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,UAAU,EAAE,uCAAuC;YACnD,OAAO,EAAE,kCAAkC;SAC5C;KACF;IACD,cAAc,EAAE;QACd;YACE,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,IAAI;SACZ;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,MAAM,iBAAiB,GAAG,UAAU,CAAC,iBAAiB,CAAC;QACvD,M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CACH;iBACR,CAAC,CAAC;aACJ;QACH,CAAC;QAED,OAAO;YACL,0BAA0B,EAAE,0CAA0C;YACtE,eAAe,EAAE,2BAA2B;YAC5C,YAAY,EAAE,2BAA2B;YAEzC,cAAc;gBACZ,iBAAiB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;oBACrC,IAAI,CAAC,IAAA,mBAAY,EAAC,KAAK,CAAC,EAAE;wBACxB,OAAO;qBACR;oBAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3C,MAAM,SAAS,GAAG,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAE3C,oBAAoB,CAClB,KAAK,EACL,IAAA,mBAAY,EAAC,SAAS,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;wBACjD,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,SAAS,EACb,CAAC,SAAS,IAAI,IAAA,mBAAY,EAAC,SAAS,CAAC,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;wBAChE,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,SAAS,CACd,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
87
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js
generated
vendored
Normal file
87
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'consistent-generic-constructors',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce specifying generic type arguments on type annotation or constructor name of a constructor call',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
preferTypeAnnotation: 'The generic type arguments should be specified as part of the type annotation.',
|
||||
preferConstructor: 'The generic type arguments should be specified as part of the constructor type arguments.',
|
||||
},
|
||||
fixable: 'code',
|
||||
schema: [
|
||||
{
|
||||
enum: ['type-annotation', 'constructor'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['constructor'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
return {
|
||||
VariableDeclarator(node) {
|
||||
var _a, _b;
|
||||
const lhs = (_a = node.id.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation;
|
||||
const rhs = node.init;
|
||||
if (!rhs ||
|
||||
rhs.type !== utils_1.AST_NODE_TYPES.NewExpression ||
|
||||
rhs.callee.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return;
|
||||
}
|
||||
if (lhs &&
|
||||
(lhs.type !== utils_1.AST_NODE_TYPES.TSTypeReference ||
|
||||
lhs.typeName.type !== utils_1.AST_NODE_TYPES.Identifier ||
|
||||
lhs.typeName.name !== rhs.callee.name)) {
|
||||
return;
|
||||
}
|
||||
if (mode === 'type-annotation') {
|
||||
if (!lhs && rhs.typeParameters) {
|
||||
const { typeParameters, callee } = rhs;
|
||||
const typeAnnotation = sourceCode.getText(callee) + sourceCode.getText(typeParameters);
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'preferTypeAnnotation',
|
||||
fix(fixer) {
|
||||
return [
|
||||
fixer.remove(typeParameters),
|
||||
fixer.insertTextAfter(node.id, ': ' + typeAnnotation),
|
||||
];
|
||||
},
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mode === 'constructor') {
|
||||
if ((lhs === null || lhs === void 0 ? void 0 : lhs.typeParameters) && !rhs.typeParameters) {
|
||||
const hasParens = ((_b = sourceCode.getTokenAfter(rhs.callee)) === null || _b === void 0 ? void 0 : _b.value) === '(';
|
||||
const extraComments = new Set(sourceCode.getCommentsInside(lhs.parent));
|
||||
sourceCode
|
||||
.getCommentsInside(lhs.typeParameters)
|
||||
.forEach(c => extraComments.delete(c));
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'preferConstructor',
|
||||
*fix(fixer) {
|
||||
yield fixer.remove(lhs.parent);
|
||||
for (const comment of extraComments) {
|
||||
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(comment));
|
||||
}
|
||||
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(lhs.typeParameters));
|
||||
if (!hasParens) {
|
||||
yield fixer.insertTextAfter(rhs.callee, '()');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-generic-constructors.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-generic-constructors.js","sourceRoot":"","sources":["../../src/rules/consistent-generic-constructors.ts"],"names":[],"mappings":";;AAAA,oDAA0D;AAC1D,kCAAqC;AAKrC,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,wGAAwG;YAC1G,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,oBAAoB,EAClB,gFAAgF;YAClF,iBAAiB,EACf,2FAA2F;SAC9F;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC;aACzC;SACF;KACF;IACD,cAAc,EAAE,CAAC,aAAa,CAAC;IAC/B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,MAAM,UA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,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,cAAc,KAAI,CAAC,GAAG,CAAC,cAAc,EAAE;wBAC9C,MAAM,SAAS,GACb,CAAA,MAAA,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,0CAAE,KAAK,MAAK,GAAG,CAAC;wBACtD,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAO,CAAC,CAC1C,CAAC;wBACF,UAAU;6BACP,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC;6BACrC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBACzC,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,mBAAmB;4BAC9B,CAAC,GAAG,CAAC,KAAK;gCACR,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAO,CAAC,CAAC;gCAChC,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;oCACnC,MAAM,KAAK,CAAC,eAAe,CACzB,GAAG,CAAC,MAAM,EACV,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAC5B,CAAC;iCACH;gCACD,MAAM,KAAK,CAAC,eAAe,CACzB,GAAG,CAAC,MAAM,EACV,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CACvC,CAAC;gCACF,IAAI,CAAC,SAAS,EAAE;oCACd,MAAM,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;iCAC/C;4BACH,CAAC;yBACF,CAAC,CAAC;qBACJ;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
126
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js
generated
vendored
Normal file
126
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'consistent-indexed-object-style',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require or disallow the `Record` type',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
preferRecord: 'A record is preferred over an index signature.',
|
||||
preferIndexSignature: 'An index signature is preferred over a record.',
|
||||
},
|
||||
fixable: 'code',
|
||||
schema: [
|
||||
{
|
||||
enum: ['record', 'index-signature'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['record'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function checkMembers(members, node, parentId, prefix, postfix, safeFix = true) {
|
||||
if (members.length !== 1) {
|
||||
return;
|
||||
}
|
||||
const [member] = members;
|
||||
if (member.type !== utils_1.AST_NODE_TYPES.TSIndexSignature) {
|
||||
return;
|
||||
}
|
||||
const [parameter] = member.parameters;
|
||||
if (!parameter) {
|
||||
return;
|
||||
}
|
||||
if (parameter.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return;
|
||||
}
|
||||
const keyType = parameter.typeAnnotation;
|
||||
if (!keyType) {
|
||||
return;
|
||||
}
|
||||
const valueType = member.typeAnnotation;
|
||||
if (!valueType) {
|
||||
return;
|
||||
}
|
||||
if (parentId) {
|
||||
const scope = context.getScope();
|
||||
const superVar = scope.set.get(parentId.name);
|
||||
if (superVar) {
|
||||
const isCircular = superVar.references.some(item => item.isTypeReference &&
|
||||
node.range[0] <= item.identifier.range[0] &&
|
||||
node.range[1] >= item.identifier.range[1]);
|
||||
if (isCircular) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'preferRecord',
|
||||
fix: safeFix
|
||||
? (fixer) => {
|
||||
const key = sourceCode.getText(keyType.typeAnnotation);
|
||||
const value = sourceCode.getText(valueType.typeAnnotation);
|
||||
const record = member.readonly
|
||||
? `Readonly<Record<${key}, ${value}>>`
|
||||
: `Record<${key}, ${value}>`;
|
||||
return fixer.replaceText(node, `${prefix}${record}${postfix}`);
|
||||
}
|
||||
: null,
|
||||
});
|
||||
}
|
||||
return Object.assign(Object.assign({}, (mode === 'index-signature' && {
|
||||
TSTypeReference(node) {
|
||||
var _a;
|
||||
const typeName = node.typeName;
|
||||
if (typeName.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return;
|
||||
}
|
||||
if (typeName.name !== 'Record') {
|
||||
return;
|
||||
}
|
||||
const params = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params;
|
||||
if ((params === null || params === void 0 ? void 0 : params.length) !== 2) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'preferIndexSignature',
|
||||
fix(fixer) {
|
||||
const key = sourceCode.getText(params[0]);
|
||||
const type = sourceCode.getText(params[1]);
|
||||
return fixer.replaceText(node, `{ [key: ${key}]: ${type} }`);
|
||||
},
|
||||
});
|
||||
},
|
||||
})), (mode === 'record' && {
|
||||
TSTypeLiteral(node) {
|
||||
const parent = findParentDeclaration(node);
|
||||
checkMembers(node.members, node, parent === null || parent === void 0 ? void 0 : parent.id, '', '');
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
var _a, _b, _c, _d;
|
||||
let genericTypes = '';
|
||||
if (((_b = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : []).length > 0) {
|
||||
genericTypes = `<${(_c = node.typeParameters) === null || _c === void 0 ? void 0 : _c.params.map(p => p.name.name).join(', ')}>`;
|
||||
}
|
||||
checkMembers(node.body.body, node, node.id, `type ${node.id.name}${genericTypes} = `, ';', !((_d = node.extends) === null || _d === void 0 ? void 0 : _d.length));
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
function findParentDeclaration(node) {
|
||||
if (node.parent && node.parent.type !== utils_1.AST_NODE_TYPES.TSTypeAnnotation) {
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
||||
return node.parent;
|
||||
}
|
||||
return findParentDeclaration(node.parent);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
//# sourceMappingURL=consistent-indexed-object-style.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-indexed-object-style.js","sourceRoot":"","sources":["../../src/rules/consistent-indexed-object-style.ts"],"names":[],"mappings":";;AAAA,oDAA8E;AAC9E,kCAAqC;AAKrC,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,gDAAgD;YAC9D,oBAAoB,EAAE,gDAAgD;SACvE;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;aACpC;SACF;KACF;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE3C,SAAS,YAAY,CACnB,OAA+B,EAC/B,IAA8D,EAC9D,QAAyC,EACzC,MAAc,EACd,OAAe,EACf,OAAO,GAAG,IAAI;YAEd,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,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C9D,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;QACD,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC3C;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
||||
157
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js
generated
vendored
Normal file
157
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util = __importStar(require("../util"));
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-assertions',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce consistent usage of type assertions',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
as: "Use 'as {{cast}}' instead of '<{{cast}}>'.",
|
||||
'angle-bracket': "Use '<{{cast}}>' instead of 'as {{cast}}'.",
|
||||
never: 'Do not use any type assertions.',
|
||||
unexpectedObjectTypeAssertion: 'Always prefer const x: T = { ... }.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
assertionStyle: {
|
||||
enum: ['never'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['assertionStyle'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
assertionStyle: {
|
||||
enum: ['as', 'angle-bracket'],
|
||||
},
|
||||
objectLiteralTypeAssertions: {
|
||||
enum: ['allow', 'allow-as-parameter', 'never'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['assertionStyle'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
assertionStyle: 'as',
|
||||
objectLiteralTypeAssertions: 'allow',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function isConst(node) {
|
||||
if (node.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
|
||||
return false;
|
||||
}
|
||||
return (node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
node.typeName.name === 'const');
|
||||
}
|
||||
function reportIncorrectAssertionType(node) {
|
||||
const messageId = options.assertionStyle;
|
||||
// If this node is `as const`, then don't report an error.
|
||||
if (isConst(node.typeAnnotation) && messageId === 'never') {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: messageId !== 'never'
|
||||
? { cast: sourceCode.getText(node.typeAnnotation) }
|
||||
: {},
|
||||
});
|
||||
}
|
||||
function checkType(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
|
||||
return false;
|
||||
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
||||
return (
|
||||
// Ignore `as const` and `<const>`
|
||||
!isConst(node) ||
|
||||
// Allow qualified names which have dots between identifiers, `Foo.Bar`
|
||||
node.typeName.type === utils_1.AST_NODE_TYPES.TSQualifiedName);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function checkExpression(node) {
|
||||
if (options.assertionStyle === 'never' ||
|
||||
options.objectLiteralTypeAssertions === 'allow' ||
|
||||
node.expression.type !== utils_1.AST_NODE_TYPES.ObjectExpression) {
|
||||
return;
|
||||
}
|
||||
if (options.objectLiteralTypeAssertions === 'allow-as-parameter' &&
|
||||
node.parent &&
|
||||
(node.parent.type === utils_1.AST_NODE_TYPES.NewExpression ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.CallExpression ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.ThrowStatement ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer)) {
|
||||
return;
|
||||
}
|
||||
if (checkType(node.typeAnnotation) &&
|
||||
node.expression.type === utils_1.AST_NODE_TYPES.ObjectExpression) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unexpectedObjectTypeAssertion',
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
TSTypeAssertion(node) {
|
||||
if (options.assertionStyle !== 'angle-bracket') {
|
||||
reportIncorrectAssertionType(node);
|
||||
return;
|
||||
}
|
||||
checkExpression(node);
|
||||
},
|
||||
TSAsExpression(node) {
|
||||
if (options.assertionStyle !== 'as') {
|
||||
reportIncorrectAssertionType(node);
|
||||
return;
|
||||
}
|
||||
checkExpression(node);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-type-assertions.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-type-assertions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-assertions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,oDAAoE;AAkBpE,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,EAAE,EAAE,4CAA4C;YAChD,eAAe,EAAE,4CAA4C;YAC7D,KAAK,EAAE,iCAAiC;YACxC,6BAA6B,EAAE,qCAAqC;SACrE;QACD,MAAM,EAAE;YACN;gBACE,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,cAAc,EAAE;gCACd,IAAI,EAAE,CAAC,OAAO,CAAC;6BAChB;yBACF;wBACD,oBAAoB,EAAE,KAAK;wBAC3B,QAAQ,EAAE,CAAC,gBAAgB,CAAC;qBAC7B;oBACD;wBACE,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,cAAc,EAAE;gCACd,IAAI,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC;6BAC9B;4BACD,2BAA2B,EAAE;gCAC3B,IAAI,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,CAAC;6BAC/C;yBACF;wBACD,oBAAoB,EAAE,KAAK;wBAC3B,QAAQ,EAAE,CAAC,gBAAgB,CAAC;qBAC7B;iBACF;aACF;SACF;KACF;IACD,cAAc,EAAE;QACd;YACE,cAAc,EAAE,IAAI;YACpB,2BAA2B,EAAE,OAAO;SACrC;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAA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dist/rules/consistent-type-definitions.js
generated
vendored
Normal file
122
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-definitions',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce type definitions to consistently use either `interface` or `type`',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
interfaceOverType: 'Use an `interface` instead of a `type`.',
|
||||
typeOverInterface: 'Use a `type` instead of an `interface`.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
enum: ['interface', 'type'],
|
||||
},
|
||||
],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: ['interface'],
|
||||
create(context, [option]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
/**
|
||||
* Iterates from the highest parent to the currently traversed node
|
||||
* to determine whether any node in tree is globally declared module declaration
|
||||
*/
|
||||
function isCurrentlyTraversedNodeWithinModuleDeclaration() {
|
||||
return context
|
||||
.getAncestors()
|
||||
.some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
|
||||
node.declare &&
|
||||
node.global);
|
||||
}
|
||||
return Object.assign(Object.assign({}, (option === 'interface' && {
|
||||
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(node) {
|
||||
context.report({
|
||||
node: node.id,
|
||||
messageId: 'interfaceOverType',
|
||||
fix(fixer) {
|
||||
var _a;
|
||||
const typeNode = (_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.id;
|
||||
const fixes = [];
|
||||
const firstToken = sourceCode.getTokenBefore(node.id);
|
||||
if (firstToken) {
|
||||
fixes.push(fixer.replaceText(firstToken, 'interface'));
|
||||
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.typeAnnotation.range[0]], ' '));
|
||||
}
|
||||
const afterToken = sourceCode.getTokenAfter(node.typeAnnotation);
|
||||
if (afterToken &&
|
||||
afterToken.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
|
||||
afterToken.value === ';') {
|
||||
fixes.push(fixer.remove(afterToken));
|
||||
}
|
||||
return fixes;
|
||||
},
|
||||
});
|
||||
},
|
||||
})), (option === 'type' && {
|
||||
TSInterfaceDeclaration(node) {
|
||||
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration()
|
||||
? null
|
||||
: (fixer) => {
|
||||
var _a, _b;
|
||||
const typeNode = (_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.id;
|
||||
const fixes = [];
|
||||
const firstToken = sourceCode.getTokenBefore(node.id);
|
||||
if (firstToken) {
|
||||
fixes.push(fixer.replaceText(firstToken, 'type'));
|
||||
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.body.range[0]], ' = '));
|
||||
}
|
||||
if (node.extends) {
|
||||
node.extends.forEach(heritage => {
|
||||
const typeIdentifier = sourceCode.getText(heritage);
|
||||
fixes.push(fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`));
|
||||
});
|
||||
}
|
||||
if (((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
||||
fixes.push(fixer.removeRange([node.parent.range[0], node.range[0]]), fixer.insertTextAfter(node.body, `\nexport default ${node.id.name}`));
|
||||
}
|
||||
return fixes;
|
||||
};
|
||||
context.report({
|
||||
node: node.id,
|
||||
messageId: 'typeOverInterface',
|
||||
/**
|
||||
* remove automatically fix when the interface is within a declare global
|
||||
* @see {@link https://github.com/typescript-eslint/typescript-eslint/issues/2707}
|
||||
*/
|
||||
fix,
|
||||
});
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-type-definitions.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-type-definitions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-definitions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAKkC;AAClC,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,2EAA2E;YAC7E,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,yCAAyC;YAC5D,iBAAiB,EAAE,yCAAyC;SAC7D;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,WAAW,EAAE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yBACJ;wBAED,IACE,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,sBAAc,CAAC,wBAAwB,EAC7D;4BACA,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,CAAC,eAAe,CACnB,IAAI,CAAC,IAAI,EACT,oBAAoB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CACnC,CACF,CAAC;yBACH;wBAED,OAAO,KAAK,CAAC;oBACf,CAAC,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,IAAI,CAAC,EAAE;oBACb,SAAS,EAAE,mBAAmB;oBAC9B;;;uBAGG;oBACH,GAAG;iBACJ,CAAC,CAAC;YACL,CAAC;SACF,CAAC,EACF;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
266
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js
generated
vendored
Normal file
266
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const typescript_1 = require("typescript");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-exports',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce consistent usage of type exports',
|
||||
recommended: false,
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
messages: {
|
||||
typeOverValue: 'All exports in the declaration are only used as types. Use `export type`.',
|
||||
singleExportIsType: 'Type export {{exportNames}} is not a value and should be exported using `export type`.',
|
||||
multipleExportsAreTypes: 'Type exports {{exportNames}} are not values and should be exported using `export type`.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
fixMixedExportsWithInlineTypeSpecifier: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
fixMixedExportsWithInlineTypeSpecifier: false,
|
||||
},
|
||||
],
|
||||
create(context, [{ fixMixedExportsWithInlineTypeSpecifier }]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceExportsMap = {};
|
||||
const parserServices = util.getParserServices(context);
|
||||
return {
|
||||
ExportNamedDeclaration(node) {
|
||||
var _a;
|
||||
// Coerce the source into a string for use as a lookup entry.
|
||||
const source = (_a = getSourceFromExport(node)) !== null && _a !== void 0 ? _a : 'undefined';
|
||||
const sourceExports = (sourceExportsMap[source] || (sourceExportsMap[source] = {
|
||||
source,
|
||||
reportValueExports: [],
|
||||
typeOnlyNamedExport: null,
|
||||
valueOnlyNamedExport: null,
|
||||
}));
|
||||
// Cache the first encountered exports for the package. We will need to come
|
||||
// back to these later when fixing the problems.
|
||||
if (node.exportKind === 'type') {
|
||||
if (sourceExports.typeOnlyNamedExport == null) {
|
||||
// The export is a type export
|
||||
sourceExports.typeOnlyNamedExport = node;
|
||||
}
|
||||
}
|
||||
else if (sourceExports.valueOnlyNamedExport == null) {
|
||||
// The export is a value export
|
||||
sourceExports.valueOnlyNamedExport = node;
|
||||
}
|
||||
// Next for the current export, we will separate type/value specifiers.
|
||||
const typeBasedSpecifiers = [];
|
||||
const inlineTypeSpecifiers = [];
|
||||
const valueSpecifiers = [];
|
||||
// Note: it is valid to export values as types. We will avoid reporting errors
|
||||
// when this is encountered.
|
||||
if (node.exportKind !== 'type') {
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.exportKind === 'type') {
|
||||
inlineTypeSpecifiers.push(specifier);
|
||||
continue;
|
||||
}
|
||||
const isTypeBased = isSpecifierTypeBased(parserServices, specifier);
|
||||
if (isTypeBased === true) {
|
||||
typeBasedSpecifiers.push(specifier);
|
||||
}
|
||||
else if (isTypeBased === false) {
|
||||
// When isTypeBased is undefined, we should avoid reporting them.
|
||||
valueSpecifiers.push(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((node.exportKind === 'value' && typeBasedSpecifiers.length) ||
|
||||
(node.exportKind === 'type' && valueSpecifiers.length)) {
|
||||
sourceExports.reportValueExports.push({
|
||||
node,
|
||||
typeBasedSpecifiers,
|
||||
valueSpecifiers,
|
||||
inlineTypeSpecifiers,
|
||||
});
|
||||
}
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const sourceExports of Object.values(sourceExportsMap)) {
|
||||
// If this export has no issues, move on.
|
||||
if (sourceExports.reportValueExports.length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const report of sourceExports.reportValueExports) {
|
||||
if (report.valueSpecifiers.length === 0) {
|
||||
// Export is all type-only with no type specifiers; convert the entire export to `export type`.
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'typeOverValue',
|
||||
*fix(fixer) {
|
||||
yield* fixExportInsertType(fixer, sourceCode, report.node);
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
// We have both type and value violations.
|
||||
const allExportNames = report.typeBasedSpecifiers.map(specifier => `${specifier.local.name}`);
|
||||
if (allExportNames.length === 1) {
|
||||
const exportNames = allExportNames[0];
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'singleExportIsType',
|
||||
data: { exportNames },
|
||||
*fix(fixer) {
|
||||
if (fixMixedExportsWithInlineTypeSpecifier) {
|
||||
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
|
||||
}
|
||||
else {
|
||||
yield* fixSeparateNamedExports(fixer, sourceCode, report);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
const exportNames = util.formatWordList(allExportNames);
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'multipleExportsAreTypes',
|
||||
data: { exportNames },
|
||||
*fix(fixer) {
|
||||
if (fixMixedExportsWithInlineTypeSpecifier) {
|
||||
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
|
||||
}
|
||||
else {
|
||||
yield* fixSeparateNamedExports(fixer, sourceCode, report);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
/**
|
||||
* Helper for identifying if an export specifier resolves to a
|
||||
* JavaScript value or a TypeScript type.
|
||||
*
|
||||
* @returns True/false if is a type or not, or undefined if the specifier
|
||||
* can't be resolved.
|
||||
*/
|
||||
function isSpecifierTypeBased(parserServices, specifier) {
|
||||
const checker = parserServices.program.getTypeChecker();
|
||||
const node = parserServices.esTreeNodeToTSNodeMap.get(specifier.exported);
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
const aliasedSymbol = checker.getAliasedSymbol(symbol);
|
||||
if (!aliasedSymbol || aliasedSymbol.escapedName === 'unknown') {
|
||||
return undefined;
|
||||
}
|
||||
return !(aliasedSymbol.flags & typescript_1.SymbolFlags.Value);
|
||||
}
|
||||
/**
|
||||
* Inserts "type" into an export.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* export type { Foo } from 'foo';
|
||||
* ^^^^
|
||||
*/
|
||||
function* fixExportInsertType(fixer, sourceCode, node) {
|
||||
const exportToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('export', node.type));
|
||||
yield fixer.insertTextAfter(exportToken, ' type');
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.exportKind === 'type') {
|
||||
const kindToken = util.nullThrows(sourceCode.getFirstToken(specifier), util.NullThrowsReasons.MissingToken('export', specifier.type));
|
||||
const firstTokenAfter = util.nullThrows(sourceCode.getTokenAfter(kindToken, {
|
||||
includeComments: true,
|
||||
}), 'Missing token following the export kind.');
|
||||
yield fixer.removeRange([kindToken.range[0], firstTokenAfter.range[0]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Separates the exports which mismatch the kind of export the given
|
||||
* node represents. For example, a type export's named specifiers which
|
||||
* represent values will be inserted in a separate `export` statement.
|
||||
*/
|
||||
function* fixSeparateNamedExports(fixer, sourceCode, report) {
|
||||
const { node, typeBasedSpecifiers, inlineTypeSpecifiers, valueSpecifiers } = report;
|
||||
const typeSpecifiers = typeBasedSpecifiers.concat(inlineTypeSpecifiers);
|
||||
const source = getSourceFromExport(node);
|
||||
const specifierNames = typeSpecifiers.map(getSpecifierText).join(', ');
|
||||
const exportToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('export', node.type));
|
||||
// Filter the bad exports from the current line.
|
||||
const filteredSpecifierNames = valueSpecifiers
|
||||
.map(getSpecifierText)
|
||||
.join(', ');
|
||||
const openToken = util.nullThrows(sourceCode.getFirstToken(node, util.isOpeningBraceToken), util.NullThrowsReasons.MissingToken('{', node.type));
|
||||
const closeToken = util.nullThrows(sourceCode.getLastToken(node, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
|
||||
// Remove exports from the current line which we're going to re-insert.
|
||||
yield fixer.replaceTextRange([openToken.range[1], closeToken.range[0]], ` ${filteredSpecifierNames} `);
|
||||
// Insert the bad exports into a new export line above.
|
||||
yield fixer.insertTextBefore(exportToken, `export type { ${specifierNames} }${source ? ` from '${source}'` : ''};\n`);
|
||||
}
|
||||
function* fixAddTypeSpecifierToNamedExports(fixer, report) {
|
||||
if (report.node.exportKind === 'type') {
|
||||
return;
|
||||
}
|
||||
for (const specifier of report.typeBasedSpecifiers) {
|
||||
yield fixer.insertTextBefore(specifier, 'type ');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the source of the export, or undefined if the named export has no source.
|
||||
*/
|
||||
function getSourceFromExport(node) {
|
||||
var _a;
|
||||
if (((_a = node.source) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.Literal &&
|
||||
typeof node.source.value === 'string') {
|
||||
return node.source.value;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Returns the specifier text for the export. If it is aliased, we take care to return
|
||||
* the proper formatting.
|
||||
*/
|
||||
function getSpecifierText(specifier) {
|
||||
return `${specifier.local.name}${specifier.exported.name !== specifier.local.name
|
||||
? ` as ${specifier.exported.name}`
|
||||
: ''}`;
|
||||
}
|
||||
//# sourceMappingURL=consistent-type-exports.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
575
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js
generated
vendored
Normal file
575
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js
generated
vendored
Normal file
@@ -0,0 +1,575 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
function isImportToken(token) {
|
||||
return token.type === utils_1.AST_TOKEN_TYPES.Keyword && token.value === 'import';
|
||||
}
|
||||
function isTypeToken(token) {
|
||||
return token.type === utils_1.AST_TOKEN_TYPES.Identifier && token.value === 'type';
|
||||
}
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-imports',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce consistent usage of type imports',
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
typeOverValue: 'All imports in the declaration are only used as types. Use `import type`.',
|
||||
someImportsAreOnlyTypes: 'Imports {{typeImports}} are only used as types.',
|
||||
aImportIsOnlyTypes: 'Import {{typeImports}} is only used as types.',
|
||||
someImportsInDecoMeta: 'Type imports {{typeImports}} are used by decorator metadata.',
|
||||
aImportInDecoMeta: 'Type import {{typeImports}} is used by decorator metadata.',
|
||||
valueOverType: 'Use an `import` instead of an `import type`.',
|
||||
noImportTypeAnnotations: '`import()` type annotations are forbidden.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
prefer: {
|
||||
enum: ['type-imports', 'no-type-imports'],
|
||||
},
|
||||
disallowTypeAnnotations: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
prefer: 'type-imports',
|
||||
disallowTypeAnnotations: true,
|
||||
},
|
||||
],
|
||||
create(context, [option]) {
|
||||
var _a;
|
||||
const prefer = (_a = option.prefer) !== null && _a !== void 0 ? _a : 'type-imports';
|
||||
const disallowTypeAnnotations = option.disallowTypeAnnotations !== false;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceImportsMap = {};
|
||||
return Object.assign(Object.assign({}, (prefer === 'type-imports'
|
||||
? {
|
||||
// prefer type imports
|
||||
ImportDeclaration(node) {
|
||||
var _a;
|
||||
const source = node.source.value;
|
||||
const sourceImports = (_a = sourceImportsMap[source]) !== null && _a !== void 0 ? _a : (sourceImportsMap[source] = {
|
||||
source,
|
||||
reportValueImports: [],
|
||||
typeOnlyNamedImport: null,
|
||||
valueOnlyNamedImport: null,
|
||||
});
|
||||
if (node.importKind === 'type') {
|
||||
if (!sourceImports.typeOnlyNamedImport &&
|
||||
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier)) {
|
||||
sourceImports.typeOnlyNamedImport = node;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!sourceImports.valueOnlyNamedImport &&
|
||||
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier)) {
|
||||
sourceImports.valueOnlyNamedImport = node;
|
||||
}
|
||||
}
|
||||
const typeSpecifiers = [];
|
||||
const inlineTypeSpecifiers = [];
|
||||
const valueSpecifiers = [];
|
||||
const unusedSpecifiers = [];
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
|
||||
specifier.importKind === 'type') {
|
||||
inlineTypeSpecifiers.push(specifier);
|
||||
continue;
|
||||
}
|
||||
const [variable] = context.getDeclaredVariables(specifier);
|
||||
if (variable.references.length === 0) {
|
||||
unusedSpecifiers.push(specifier);
|
||||
}
|
||||
else {
|
||||
const onlyHasTypeReferences = variable.references.every(ref => {
|
||||
var _a, _b;
|
||||
/**
|
||||
* keep origin import kind when export
|
||||
* export { Type }
|
||||
* export default Type;
|
||||
*/
|
||||
if (((_a = ref.identifier.parent) === null || _a === void 0 ? void 0 : _a.type) ===
|
||||
utils_1.AST_NODE_TYPES.ExportSpecifier ||
|
||||
((_b = ref.identifier.parent) === null || _b === void 0 ? void 0 : _b.type) ===
|
||||
utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
||||
if (ref.isValueReference && ref.isTypeReference) {
|
||||
return node.importKind === 'type';
|
||||
}
|
||||
}
|
||||
if (ref.isValueReference) {
|
||||
let parent = ref.identifier.parent;
|
||||
let child = ref.identifier;
|
||||
while (parent) {
|
||||
switch (parent.type) {
|
||||
// CASE 1:
|
||||
// `type T = typeof foo` will create a value reference because "foo" must be a value type
|
||||
// however this value reference is safe to use with type-only imports
|
||||
case utils_1.AST_NODE_TYPES.TSTypeQuery:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
||||
// TSTypeQuery must have a TSESTree.EntityName as its child, so we can filter here and break early
|
||||
if (parent.left !== child) {
|
||||
return false;
|
||||
}
|
||||
child = parent;
|
||||
parent = parent.parent;
|
||||
continue;
|
||||
// END CASE 1
|
||||
//////////////
|
||||
// CASE 2:
|
||||
// `type T = { [foo]: string }` will create a value reference because "foo" must be a value type
|
||||
// however this value reference is safe to use with type-only imports.
|
||||
// Also this is represented as a non-type AST - hence it uses MemberExpression
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
return parent.key === child;
|
||||
case utils_1.AST_NODE_TYPES.MemberExpression:
|
||||
if (parent.object !== child) {
|
||||
return false;
|
||||
}
|
||||
child = parent;
|
||||
parent = parent.parent;
|
||||
continue;
|
||||
// END CASE 2
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ref.isTypeReference;
|
||||
});
|
||||
if (onlyHasTypeReferences) {
|
||||
typeSpecifiers.push(specifier);
|
||||
}
|
||||
else {
|
||||
valueSpecifiers.push(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((node.importKind === 'value' && typeSpecifiers.length) ||
|
||||
(node.importKind === 'type' && valueSpecifiers.length)) {
|
||||
sourceImports.reportValueImports.push({
|
||||
node,
|
||||
typeSpecifiers,
|
||||
valueSpecifiers,
|
||||
unusedSpecifiers,
|
||||
inlineTypeSpecifiers,
|
||||
});
|
||||
}
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const sourceImports of Object.values(sourceImportsMap)) {
|
||||
if (sourceImports.reportValueImports.length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const report of sourceImports.reportValueImports) {
|
||||
if (report.valueSpecifiers.length === 0 &&
|
||||
report.unusedSpecifiers.length === 0) {
|
||||
// import is all type-only, convert the entire import to `import type`
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'typeOverValue',
|
||||
*fix(fixer) {
|
||||
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
const isTypeImport = report.node.importKind === 'type';
|
||||
// we have a mixed type/value import, so we need to split them out into multiple exports
|
||||
const importNames = (isTypeImport
|
||||
? report.valueSpecifiers
|
||||
: report.typeSpecifiers).map(specifier => `"${specifier.local.name}"`);
|
||||
const message = (() => {
|
||||
const typeImports = util.formatWordList(importNames);
|
||||
if (importNames.length === 1) {
|
||||
if (isTypeImport) {
|
||||
return {
|
||||
messageId: 'aImportInDecoMeta',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
messageId: 'aImportIsOnlyTypes',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isTypeImport) {
|
||||
return {
|
||||
messageId: 'someImportsInDecoMeta',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
messageId: 'someImportsAreOnlyTypes',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
}
|
||||
})();
|
||||
context.report(Object.assign(Object.assign({ node: report.node }, message), { *fix(fixer) {
|
||||
if (isTypeImport) {
|
||||
yield* fixToValueImportDeclaration(fixer, report, sourceImports);
|
||||
}
|
||||
else {
|
||||
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
|
||||
}
|
||||
} }));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
: {
|
||||
// prefer no type imports
|
||||
'ImportDeclaration[importKind = "type"]'(node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'valueOverType',
|
||||
fix(fixer) {
|
||||
return fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
},
|
||||
});
|
||||
},
|
||||
'ImportSpecifier[importKind = "type"]'(node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'valueOverType',
|
||||
fix(fixer) {
|
||||
return fixRemoveTypeSpecifierFromImportSpecifier(fixer, node);
|
||||
},
|
||||
});
|
||||
},
|
||||
})), (disallowTypeAnnotations
|
||||
? {
|
||||
// disallow `import()` type
|
||||
TSImportType(node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'noImportTypeAnnotations',
|
||||
});
|
||||
},
|
||||
}
|
||||
: {}));
|
||||
function classifySpecifier(node) {
|
||||
var _a;
|
||||
const defaultSpecifier = node.specifiers[0].type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier
|
||||
? node.specifiers[0]
|
||||
: null;
|
||||
const namespaceSpecifier = (_a = node.specifiers.find((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier)) !== null && _a !== void 0 ? _a : null;
|
||||
const namedSpecifiers = node.specifiers.filter((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier);
|
||||
return {
|
||||
defaultSpecifier,
|
||||
namespaceSpecifier,
|
||||
namedSpecifiers,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns information for fixing named specifiers.
|
||||
*/
|
||||
function getFixesNamedSpecifiers(fixer, node, typeNamedSpecifiers, allNamedSpecifiers) {
|
||||
if (allNamedSpecifiers.length === 0) {
|
||||
return {
|
||||
typeNamedSpecifiersText: '',
|
||||
removeTypeNamedSpecifiers: [],
|
||||
};
|
||||
}
|
||||
const typeNamedSpecifiersTexts = [];
|
||||
const removeTypeNamedSpecifiers = [];
|
||||
if (typeNamedSpecifiers.length === allNamedSpecifiers.length) {
|
||||
// import Foo, {Type1, Type2} from 'foo'
|
||||
// import DefType, {Type1, Type2} from 'foo'
|
||||
const openingBraceToken = util.nullThrows(sourceCode.getTokenBefore(typeNamedSpecifiers[0], util.isOpeningBraceToken), util.NullThrowsReasons.MissingToken('{', node.type));
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenBefore(openingBraceToken, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
|
||||
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
|
||||
// import DefType, {...} from 'foo'
|
||||
// ^^^^^^^ remove
|
||||
removeTypeNamedSpecifiers.push(fixer.removeRange([commaToken.range[0], closingBraceToken.range[1]]));
|
||||
typeNamedSpecifiersTexts.push(sourceCode.text.slice(openingBraceToken.range[1], closingBraceToken.range[0]));
|
||||
}
|
||||
else {
|
||||
const typeNamedSpecifierGroups = [];
|
||||
let group = [];
|
||||
for (const namedSpecifier of allNamedSpecifiers) {
|
||||
if (typeNamedSpecifiers.includes(namedSpecifier)) {
|
||||
group.push(namedSpecifier);
|
||||
}
|
||||
else if (group.length) {
|
||||
typeNamedSpecifierGroups.push(group);
|
||||
group = [];
|
||||
}
|
||||
}
|
||||
if (group.length) {
|
||||
typeNamedSpecifierGroups.push(group);
|
||||
}
|
||||
for (const namedSpecifiers of typeNamedSpecifierGroups) {
|
||||
const { removeRange, textRange } = getNamedSpecifierRanges(namedSpecifiers, allNamedSpecifiers);
|
||||
removeTypeNamedSpecifiers.push(fixer.removeRange(removeRange));
|
||||
typeNamedSpecifiersTexts.push(sourceCode.text.slice(...textRange));
|
||||
}
|
||||
}
|
||||
return {
|
||||
typeNamedSpecifiersText: typeNamedSpecifiersTexts.join(','),
|
||||
removeTypeNamedSpecifiers,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns ranges for fixing named specifier.
|
||||
*/
|
||||
function getNamedSpecifierRanges(namedSpecifierGroup, allNamedSpecifiers) {
|
||||
const first = namedSpecifierGroup[0];
|
||||
const last = namedSpecifierGroup[namedSpecifierGroup.length - 1];
|
||||
const removeRange = [first.range[0], last.range[1]];
|
||||
const textRange = [...removeRange];
|
||||
const before = sourceCode.getTokenBefore(first);
|
||||
textRange[0] = before.range[1];
|
||||
if (util.isCommaToken(before)) {
|
||||
removeRange[0] = before.range[0];
|
||||
}
|
||||
else {
|
||||
removeRange[0] = before.range[1];
|
||||
}
|
||||
const isFirst = allNamedSpecifiers[0] === first;
|
||||
const isLast = allNamedSpecifiers[allNamedSpecifiers.length - 1] === last;
|
||||
const after = sourceCode.getTokenAfter(last);
|
||||
textRange[1] = after.range[0];
|
||||
if (isFirst || isLast) {
|
||||
if (util.isCommaToken(after)) {
|
||||
removeRange[1] = after.range[1];
|
||||
}
|
||||
}
|
||||
return {
|
||||
textRange,
|
||||
removeRange,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* insert specifiers to named import node.
|
||||
* e.g.
|
||||
* import type { Already, Type1, Type2 } from 'foo'
|
||||
* ^^^^^^^^^^^^^ insert
|
||||
*/
|
||||
function fixInsertNamedSpecifiersInNamedSpecifierList(fixer, target, insertText) {
|
||||
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(sourceCode.getFirstToken(target), target.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', target.type));
|
||||
const before = sourceCode.getTokenBefore(closingBraceToken);
|
||||
if (!util.isCommaToken(before) && !util.isOpeningBraceToken(before)) {
|
||||
insertText = `,${insertText}`;
|
||||
}
|
||||
return fixer.insertTextBefore(closingBraceToken, `${insertText}`);
|
||||
}
|
||||
function* fixToTypeImportDeclaration(fixer, report, sourceImports) {
|
||||
const { node } = report;
|
||||
const { defaultSpecifier, namespaceSpecifier, namedSpecifiers } = classifySpecifier(node);
|
||||
if (namespaceSpecifier && !defaultSpecifier) {
|
||||
// import * as types from 'foo'
|
||||
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false);
|
||||
return;
|
||||
}
|
||||
else if (defaultSpecifier) {
|
||||
if (report.typeSpecifiers.includes(defaultSpecifier) &&
|
||||
namedSpecifiers.length === 0 &&
|
||||
!namespaceSpecifier) {
|
||||
// import Type from 'foo'
|
||||
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (namedSpecifiers.every(specifier => report.typeSpecifiers.includes(specifier)) &&
|
||||
!namespaceSpecifier) {
|
||||
// import {Type1, Type2} from 'foo'
|
||||
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const typeNamedSpecifiers = namedSpecifiers.filter(specifier => report.typeSpecifiers.includes(specifier));
|
||||
const fixesNamedSpecifiers = getFixesNamedSpecifiers(fixer, node, typeNamedSpecifiers, namedSpecifiers);
|
||||
const afterFixes = [];
|
||||
if (typeNamedSpecifiers.length) {
|
||||
if (sourceImports.typeOnlyNamedImport) {
|
||||
const insertTypeNamedSpecifiers = fixInsertNamedSpecifiersInNamedSpecifierList(fixer, sourceImports.typeOnlyNamedImport, fixesNamedSpecifiers.typeNamedSpecifiersText);
|
||||
if (sourceImports.typeOnlyNamedImport.range[1] <= node.range[0]) {
|
||||
yield insertTypeNamedSpecifiers;
|
||||
}
|
||||
else {
|
||||
afterFixes.push(insertTypeNamedSpecifiers);
|
||||
}
|
||||
}
|
||||
else {
|
||||
yield fixer.insertTextBefore(node, `import type {${fixesNamedSpecifiers.typeNamedSpecifiersText}} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
}
|
||||
const fixesRemoveTypeNamespaceSpecifier = [];
|
||||
if (namespaceSpecifier &&
|
||||
report.typeSpecifiers.includes(namespaceSpecifier)) {
|
||||
// import Foo, * as Type from 'foo'
|
||||
// import DefType, * as Type from 'foo'
|
||||
// import DefType, * as Type from 'foo'
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenBefore(namespaceSpecifier, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
|
||||
// import Def, * as Ns from 'foo'
|
||||
// ^^^^^^^^^ remove
|
||||
fixesRemoveTypeNamespaceSpecifier.push(fixer.removeRange([commaToken.range[0], namespaceSpecifier.range[1]]));
|
||||
// import type * as Ns from 'foo'
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ insert
|
||||
yield fixer.insertTextBefore(node, `import type ${sourceCode.getText(namespaceSpecifier)} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
if (defaultSpecifier &&
|
||||
report.typeSpecifiers.includes(defaultSpecifier)) {
|
||||
if (report.typeSpecifiers.length === node.specifiers.length) {
|
||||
const importToken = util.nullThrows(sourceCode.getFirstToken(node, isImportToken), util.NullThrowsReasons.MissingToken('import', node.type));
|
||||
// import type Type from 'foo'
|
||||
// ^^^^ insert
|
||||
yield fixer.insertTextAfter(importToken, ' type');
|
||||
}
|
||||
else {
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenAfter(defaultSpecifier, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', defaultSpecifier.type));
|
||||
// import Type , {...} from 'foo'
|
||||
// ^^^^^ pick
|
||||
const defaultText = sourceCode.text
|
||||
.slice(defaultSpecifier.range[0], commaToken.range[0])
|
||||
.trim();
|
||||
yield fixer.insertTextBefore(node, `import type ${defaultText} from ${sourceCode.getText(node.source)};\n`);
|
||||
const afterToken = util.nullThrows(sourceCode.getTokenAfter(commaToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
|
||||
// import Type , {...} from 'foo'
|
||||
// ^^^^^^^ remove
|
||||
yield fixer.removeRange([
|
||||
defaultSpecifier.range[0],
|
||||
afterToken.range[0],
|
||||
]);
|
||||
}
|
||||
}
|
||||
yield* fixesNamedSpecifiers.removeTypeNamedSpecifiers;
|
||||
yield* fixesRemoveTypeNamespaceSpecifier;
|
||||
yield* afterFixes;
|
||||
}
|
||||
function* fixInsertTypeSpecifierForImportDeclaration(fixer, node, isDefaultImport) {
|
||||
// import type Foo from 'foo'
|
||||
// ^^^^^ insert
|
||||
const importToken = util.nullThrows(sourceCode.getFirstToken(node, isImportToken), util.NullThrowsReasons.MissingToken('import', node.type));
|
||||
yield fixer.insertTextAfter(importToken, ' type');
|
||||
if (isDefaultImport) {
|
||||
// Has default import
|
||||
const openingBraceToken = sourceCode.getFirstTokenBetween(importToken, node.source, util.isOpeningBraceToken);
|
||||
if (openingBraceToken) {
|
||||
// Only braces. e.g. import Foo, {} from 'foo'
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenBefore(openingBraceToken, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
|
||||
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
|
||||
// import type Foo, {} from 'foo'
|
||||
// ^^ remove
|
||||
yield fixer.removeRange([
|
||||
commaToken.range[0],
|
||||
closingBraceToken.range[1],
|
||||
]);
|
||||
const specifiersText = sourceCode.text.slice(commaToken.range[1], closingBraceToken.range[1]);
|
||||
if (node.specifiers.length > 1) {
|
||||
// import type Foo from 'foo'
|
||||
// import type {...} from 'foo' // <- insert
|
||||
yield fixer.insertTextAfter(node, `\nimport type${specifiersText} from ${sourceCode.getText(node.source)};`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// make sure we don't do anything like `import type {type T} from 'foo';`
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
|
||||
specifier.importKind === 'type') {
|
||||
yield* fixRemoveTypeSpecifierFromImportSpecifier(fixer, specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
function* fixToValueImportDeclaration(fixer, report, sourceImports) {
|
||||
const { node } = report;
|
||||
const { defaultSpecifier, namespaceSpecifier, namedSpecifiers } = classifySpecifier(node);
|
||||
if (namespaceSpecifier) {
|
||||
// import type * as types from 'foo'
|
||||
yield* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
return;
|
||||
}
|
||||
else if (defaultSpecifier) {
|
||||
if (report.valueSpecifiers.includes(defaultSpecifier) &&
|
||||
namedSpecifiers.length === 0) {
|
||||
// import type Type from 'foo'
|
||||
yield* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (namedSpecifiers.every(specifier => report.valueSpecifiers.includes(specifier))) {
|
||||
// import type {Type1, Type2} from 'foo'
|
||||
yield* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const valueNamedSpecifiers = namedSpecifiers.filter(specifier => report.valueSpecifiers.includes(specifier));
|
||||
const fixesNamedSpecifiers = getFixesNamedSpecifiers(fixer, node, valueNamedSpecifiers, namedSpecifiers);
|
||||
const afterFixes = [];
|
||||
if (valueNamedSpecifiers.length) {
|
||||
if (sourceImports.valueOnlyNamedImport) {
|
||||
const insertTypeNamedSpecifiers = fixInsertNamedSpecifiersInNamedSpecifierList(fixer, sourceImports.valueOnlyNamedImport, fixesNamedSpecifiers.typeNamedSpecifiersText);
|
||||
if (sourceImports.valueOnlyNamedImport.range[1] <= node.range[0]) {
|
||||
yield insertTypeNamedSpecifiers;
|
||||
}
|
||||
else {
|
||||
afterFixes.push(insertTypeNamedSpecifiers);
|
||||
}
|
||||
}
|
||||
else {
|
||||
yield fixer.insertTextBefore(node, `import {${fixesNamedSpecifiers.typeNamedSpecifiersText}} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
}
|
||||
yield* fixesNamedSpecifiers.removeTypeNamedSpecifiers;
|
||||
yield* afterFixes;
|
||||
}
|
||||
function* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node) {
|
||||
var _a, _b;
|
||||
// import type Foo from 'foo'
|
||||
// ^^^^ remove
|
||||
const importToken = util.nullThrows(sourceCode.getFirstToken(node, isImportToken), util.NullThrowsReasons.MissingToken('import', node.type));
|
||||
const typeToken = util.nullThrows(sourceCode.getFirstTokenBetween(importToken, (_b = (_a = node.specifiers[0]) === null || _a === void 0 ? void 0 : _a.local) !== null && _b !== void 0 ? _b : node.source, isTypeToken), util.NullThrowsReasons.MissingToken('type', node.type));
|
||||
const afterToken = util.nullThrows(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
|
||||
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);
|
||||
}
|
||||
function* fixRemoveTypeSpecifierFromImportSpecifier(fixer, node) {
|
||||
const typeToken = util.nullThrows(sourceCode.getFirstToken(node, isTypeToken), util.NullThrowsReasons.MissingToken('type', node.type));
|
||||
const afterToken = util.nullThrows(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
|
||||
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-type-imports.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
64
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js
generated
vendored
Normal file
64
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../util");
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'default-param-last',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce default parameters to be last',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
shouldBeLast: 'Default parameters should be last.',
|
||||
},
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
/**
|
||||
* checks if node is optional parameter
|
||||
* @param node the node to be evaluated
|
||||
* @private
|
||||
*/
|
||||
function isOptionalParam(node) {
|
||||
return 'optional' in node && node.optional === true;
|
||||
}
|
||||
/**
|
||||
* checks if node is plain parameter
|
||||
* @param node the node to be evaluated
|
||||
* @private
|
||||
*/
|
||||
function isPlainParam(node) {
|
||||
return !(node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
|
||||
node.type === utils_1.AST_NODE_TYPES.RestElement ||
|
||||
isOptionalParam(node));
|
||||
}
|
||||
function checkDefaultParamLast(node) {
|
||||
let hasSeenPlainParam = false;
|
||||
for (let i = node.params.length - 1; i >= 0; i--) {
|
||||
const current = node.params[i];
|
||||
const param = current.type === utils_1.AST_NODE_TYPES.TSParameterProperty
|
||||
? current.parameter
|
||||
: current;
|
||||
if (isPlainParam(param)) {
|
||||
hasSeenPlainParam = true;
|
||||
continue;
|
||||
}
|
||||
if (hasSeenPlainParam &&
|
||||
(isOptionalParam(param) ||
|
||||
param.type === utils_1.AST_NODE_TYPES.AssignmentPattern)) {
|
||||
context.report({ node: current, messageId: 'shouldBeLast' });
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: checkDefaultParamLast,
|
||||
FunctionDeclaration: checkDefaultParamLast,
|
||||
FunctionExpression: checkDefaultParamLast,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=default-param-last.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"default-param-last.js","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";;AAAA,kCAAqC;AACrC,oDAAoE;AAEpE,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,YAAY,EAAE,oCAAoC;SACnD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ;;;;WAIG;QACH,SAAS,eAAe,CAAC,IAAwB;YAC/C,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC;QACtD,CAAC;QAED;;;;WAIG;QACH,SAAS,YAAY,CAAC,IAAwB;YAC5C,OAAO,CAAC,CACN,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB;gBAC9C,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,WAAW;gBACxC,eAAe,CAAC,IAAI,CAAC,CACtB,CAAC;QACJ,CAAC;QAED,SAAS,qBAAqB,CAC5B,IAG+B;YAE/B,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAC9B,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;gBAChD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,KAAK,GACT,OAAO,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;oBACjD,CAAC,CAAC,OAAO,CAAC,SAAS;oBACnB,CAAC,CAAC,OAAO,CAAC;gBAEd,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;oBACvB,iBAAiB,GAAG,IAAI,CAAC;oBACzB,SAAS;iBACV;gBAED,IACE,iBAAiB;oBACjB,CAAC,eAAe,CAAC,KAAK,CAAC;wBACrB,KAAK,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB,CAAC,EAClD;oBACA,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;iBAC9D;aACF;QACH,CAAC;QAED,OAAO;YACL,uBAAuB,EAAE,qBAAqB;YAC9C,mBAAmB,EAAE,qBAAqB;YAC1C,kBAAkB,EAAE,qBAAqB;SAC1C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
125
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js
generated
vendored
Normal file
125
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ts = __importStar(require("typescript"));
|
||||
const tsutils = __importStar(require("tsutils"));
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const util_1 = require("../util");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('dot-notation');
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'dot-notation',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce dot notation whenever possible',
|
||||
recommended: 'strict',
|
||||
extendsBaseRule: true,
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowKeywords: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
allowPattern: {
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
allowPrivateClassPropertyAccess: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
allowProtectedClassPropertyAccess: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
allowIndexSignaturePropertyAccess: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: baseRule.meta.fixable,
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowPrivateClassPropertyAccess: false,
|
||||
allowProtectedClassPropertyAccess: false,
|
||||
allowIndexSignaturePropertyAccess: false,
|
||||
allowKeywords: true,
|
||||
allowPattern: '',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
var _a;
|
||||
const rules = baseRule.create(context);
|
||||
const { program, esTreeNodeToTSNodeMap } = (0, util_1.getParserServices)(context);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const allowPrivateClassPropertyAccess = options.allowPrivateClassPropertyAccess;
|
||||
const allowProtectedClassPropertyAccess = options.allowProtectedClassPropertyAccess;
|
||||
const allowIndexSignaturePropertyAccess = ((_a = options.allowIndexSignaturePropertyAccess) !== null && _a !== void 0 ? _a : false) ||
|
||||
tsutils.isCompilerOptionEnabled(program.getCompilerOptions(),
|
||||
// @ts-expect-error - TS is refining the type to never for some reason
|
||||
'noPropertyAccessFromIndexSignature');
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
var _a, _b, _c;
|
||||
if ((allowPrivateClassPropertyAccess ||
|
||||
allowProtectedClassPropertyAccess ||
|
||||
allowIndexSignaturePropertyAccess) &&
|
||||
node.computed) {
|
||||
// for perf reasons - only fetch symbols if we have to
|
||||
const propertySymbol = typeChecker.getSymbolAtLocation(esTreeNodeToTSNodeMap.get(node.property));
|
||||
const modifierKind = (_c = (_b = (_a = propertySymbol === null || propertySymbol === void 0 ? void 0 : propertySymbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.modifiers) === null || _c === void 0 ? void 0 : _c[0].kind;
|
||||
if ((allowPrivateClassPropertyAccess &&
|
||||
modifierKind == ts.SyntaxKind.PrivateKeyword) ||
|
||||
(allowProtectedClassPropertyAccess &&
|
||||
modifierKind == ts.SyntaxKind.ProtectedKeyword)) {
|
||||
return;
|
||||
}
|
||||
if (propertySymbol === undefined &&
|
||||
allowIndexSignaturePropertyAccess) {
|
||||
const objectType = typeChecker.getTypeAtLocation(esTreeNodeToTSNodeMap.get(node.object));
|
||||
const indexType = objectType
|
||||
.getNonNullableType()
|
||||
.getStringIndexType();
|
||||
if (indexType != undefined) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
rules.MemberExpression(node);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=dot-notation.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"dot-notation.js","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,iDAAmC;AACnC,iEAA8D;AAC9D,kCAKiB;AAEjB,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC;AAKnD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,wCAAwC;YACrD,WAAW,EAAE,QAAQ;YACrB,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;oBACD,YAAY,EAAE;wBACZ,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,EAAE;qBACZ;oBAC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AiC,CAAC;oBACpC,IAAI,CAAC,QAAQ,EACb;oBACA,sDAAsD;oBACtD,MAAM,cAAc,GAAG,WAAW,CAAC,mBAAmB,CACpD,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CACzC,CAAC;oBACF,MAAM,YAAY,GAChB,MAAA,MAAA,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,eAAe,EAAE,0CAAG,CAAC,CAAC,0CAAE,SAAS,0CAAG,CAAC,EAAE,IAAI,CAAC;oBAC9D,IACE,CAAC,+BAA+B;wBAC9B,YAAY,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC;wBAC/C,CAAC,iCAAiC;4BAChC,YAAY,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EACjD;wBACA,OAAO;qBACR;oBACD,IACE,cAAc,KAAK,SAAS;wBAC5B,iCAAiC,EACjC;wBACA,MAAM,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAC9C,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CACvC,CAAC;wBACF,MAAM,SAAS,GAAG,UAAU;6BACzB,kBAAkB,EAAE;6BACpB,kBAAkB,EAAE,CAAC;wBACxB,IAAI,SAAS,IAAI,SAAS,EAAE;4BAC1B,OAAO;yBACR;qBACF;iBACF;gBACD,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
164
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js
generated
vendored
Normal file
164
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
|
||||
exports.default = util.createRule({
|
||||
name: 'explicit-function-return-type',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Require explicit return types on functions and class methods',
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
missingReturnType: 'Missing return type on function.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowExpressions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowTypedFunctionExpressions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowHigherOrderFunctions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowDirectConstAssertionInArrowFunctions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowConciseArrowFunctionExpressionsStartingWithVoid: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowedNames: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowExpressions: false,
|
||||
allowTypedFunctionExpressions: true,
|
||||
allowHigherOrderFunctions: true,
|
||||
allowDirectConstAssertionInArrowFunctions: true,
|
||||
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
|
||||
allowedNames: [],
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function isAllowedName(node) {
|
||||
var _a;
|
||||
if (!options.allowedNames || !options.allowedNames.length) {
|
||||
return false;
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
|
||||
node.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
|
||||
const parent = node.parent;
|
||||
let funcName;
|
||||
if ((_a = node.id) === null || _a === void 0 ? void 0 : _a.name) {
|
||||
funcName = node.id.name;
|
||||
}
|
||||
else if (parent) {
|
||||
switch (parent.type) {
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclarator: {
|
||||
if (parent.id.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
funcName = parent.id.name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.Property: {
|
||||
if (parent.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
parent.computed === false) {
|
||||
funcName = parent.key.name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!!funcName && !!options.allowedNames.includes(funcName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration &&
|
||||
node.id &&
|
||||
node.id.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
!!options.allowedNames.includes(node.id.name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
'ArrowFunctionExpression, FunctionExpression'(node) {
|
||||
if (options.allowConciseArrowFunctionExpressionsStartingWithVoid &&
|
||||
node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
|
||||
node.expression &&
|
||||
node.body.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
||||
node.body.operator === 'void') {
|
||||
return;
|
||||
}
|
||||
if (isAllowedName(node)) {
|
||||
return;
|
||||
}
|
||||
if (options.allowTypedFunctionExpressions &&
|
||||
((0, explicitReturnTypeUtils_1.isValidFunctionExpressionReturnType)(node, options) ||
|
||||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node))) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
}));
|
||||
},
|
||||
FunctionDeclaration(node) {
|
||||
if (isAllowedName(node)) {
|
||||
return;
|
||||
}
|
||||
if (options.allowTypedFunctionExpressions && node.returnType) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
}));
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-function-return-type.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,8CAAgC;AAChC,6EAIyC;AAczC,kBAAe,IAAI,CAAC,UAAU,CA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AAC;QACf,CAAC;QACD,OAAO;YACL,6CAA6C,CAC3C,IAAoE;gBAEpE,IACE,OAAO,CAAC,oDAAoD;oBAC5D,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,uBAAuB;oBACpD,IAAI,CAAC,UAAU;oBACf,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,eAAe;oBACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,MAAM,EAC7B;oBACA,OAAO;iBACR;gBAED,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;oBACvB,OAAO;iBACR;gBAED,IACE,OAAO,CAAC,6BAA6B;oBACrC,CAAC,IAAA,6DAAmC,EAAC,IAAI,EAAE,OAAO,CAAC;wBACjD,IAAA,+CAAqB,EAAC,IAAI,CAAC,CAAC,EAC9B;oBACA,OAAO;iBACR;gBAED,IAAA,iDAAuB,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,CACvD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CACH,CAAC;YACJ,CAAC;YACD,mBAAmB,CAAC,IAAI;gBACtB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;oBACvB,OAAO;iBACR;gBACD,IAAI,OAAO,CAAC,6BAA6B,IAAI,IAAI,CAAC,UAAU,EAAE;oBAC5D,OAAO;iBACR;gBAED,IAAA,iDAAuB,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,CACvD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CACH,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
219
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js
generated
vendored
Normal file
219
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const accessibilityLevel = { enum: ['explicit', 'no-public', 'off'] };
|
||||
exports.default = util.createRule({
|
||||
name: 'explicit-member-accessibility',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Require explicit accessibility modifiers on class properties and methods',
|
||||
// too opinionated to be recommended
|
||||
recommended: false,
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
missingAccessibility: 'Missing accessibility modifier on {{type}} {{name}}.',
|
||||
unwantedPublicAccessibility: 'Public accessibility modifier on {{type}} {{name}}.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
accessibility: accessibilityLevel,
|
||||
overrides: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
accessors: accessibilityLevel,
|
||||
constructors: accessibilityLevel,
|
||||
methods: accessibilityLevel,
|
||||
properties: accessibilityLevel,
|
||||
parameterProperties: accessibilityLevel,
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
ignoredMethodNames: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [{ accessibility: 'explicit' }],
|
||||
create(context, [option]) {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const baseCheck = (_a = option.accessibility) !== null && _a !== void 0 ? _a : 'explicit';
|
||||
const overrides = (_b = option.overrides) !== null && _b !== void 0 ? _b : {};
|
||||
const ctorCheck = (_c = overrides.constructors) !== null && _c !== void 0 ? _c : baseCheck;
|
||||
const accessorCheck = (_d = overrides.accessors) !== null && _d !== void 0 ? _d : baseCheck;
|
||||
const methodCheck = (_e = overrides.methods) !== null && _e !== void 0 ? _e : baseCheck;
|
||||
const propCheck = (_f = overrides.properties) !== null && _f !== void 0 ? _f : baseCheck;
|
||||
const paramPropCheck = (_g = overrides.parameterProperties) !== null && _g !== void 0 ? _g : baseCheck;
|
||||
const ignoredMethodNames = new Set((_h = option.ignoredMethodNames) !== null && _h !== void 0 ? _h : []);
|
||||
/**
|
||||
* Generates the report for rule violations
|
||||
*/
|
||||
function reportIssue(messageId, nodeType, node, nodeName, fix = null) {
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
type: nodeType,
|
||||
name: nodeName,
|
||||
},
|
||||
fix,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Checks if a method declaration has an accessibility modifier.
|
||||
* @param methodDefinition The node representing a MethodDefinition.
|
||||
*/
|
||||
function checkMethodAccessibilityModifier(methodDefinition) {
|
||||
if (methodDefinition.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
let nodeType = 'method definition';
|
||||
let check = baseCheck;
|
||||
switch (methodDefinition.kind) {
|
||||
case 'method':
|
||||
check = methodCheck;
|
||||
break;
|
||||
case 'constructor':
|
||||
check = ctorCheck;
|
||||
break;
|
||||
case 'get':
|
||||
case 'set':
|
||||
check = accessorCheck;
|
||||
nodeType = `${methodDefinition.kind} property accessor`;
|
||||
break;
|
||||
}
|
||||
const { name: methodName } = util.getNameFromMember(methodDefinition, sourceCode);
|
||||
if (check === 'off' || ignoredMethodNames.has(methodName)) {
|
||||
return;
|
||||
}
|
||||
if (check === 'no-public' &&
|
||||
methodDefinition.accessibility === 'public') {
|
||||
reportIssue('unwantedPublicAccessibility', nodeType, methodDefinition, methodName, getUnwantedPublicAccessibilityFixer(methodDefinition));
|
||||
}
|
||||
else if (check === 'explicit' && !methodDefinition.accessibility) {
|
||||
reportIssue('missingAccessibility', nodeType, methodDefinition, methodName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a fixer that removes a "public" keyword with following spaces
|
||||
*/
|
||||
function getUnwantedPublicAccessibilityFixer(node) {
|
||||
return function (fixer) {
|
||||
const tokens = sourceCode.getTokens(node);
|
||||
let rangeToRemove;
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const token = tokens[i];
|
||||
if (token.type === utils_1.AST_TOKEN_TYPES.Keyword &&
|
||||
token.value === 'public') {
|
||||
const commensAfterPublicKeyword = sourceCode.getCommentsAfter(token);
|
||||
if (commensAfterPublicKeyword.length) {
|
||||
// public /* Hi there! */ static foo()
|
||||
// ^^^^^^^
|
||||
rangeToRemove = [
|
||||
token.range[0],
|
||||
commensAfterPublicKeyword[0].range[0],
|
||||
];
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// public static foo()
|
||||
// ^^^^^^^
|
||||
rangeToRemove = [token.range[0], tokens[i + 1].range[0]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fixer.removeRange(rangeToRemove);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Checks if property has an accessibility modifier.
|
||||
* @param propertyDefinition The node representing a PropertyDefinition.
|
||||
*/
|
||||
function checkPropertyAccessibilityModifier(propertyDefinition) {
|
||||
if (propertyDefinition.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
const nodeType = 'class property';
|
||||
const { name: propertyName } = util.getNameFromMember(propertyDefinition, sourceCode);
|
||||
if (propCheck === 'no-public' &&
|
||||
propertyDefinition.accessibility === 'public') {
|
||||
reportIssue('unwantedPublicAccessibility', nodeType, propertyDefinition, propertyName, getUnwantedPublicAccessibilityFixer(propertyDefinition));
|
||||
}
|
||||
else if (propCheck === 'explicit' &&
|
||||
!propertyDefinition.accessibility) {
|
||||
reportIssue('missingAccessibility', nodeType, propertyDefinition, propertyName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks that the parameter property has the desired accessibility modifiers set.
|
||||
* @param node The node representing a Parameter Property
|
||||
*/
|
||||
function checkParameterPropertyAccessibilityModifier(node) {
|
||||
const nodeType = 'parameter property';
|
||||
// HAS to be an identifier or assignment or TSC will throw
|
||||
if (node.parameter.type !== utils_1.AST_NODE_TYPES.Identifier &&
|
||||
node.parameter.type !== utils_1.AST_NODE_TYPES.AssignmentPattern) {
|
||||
return;
|
||||
}
|
||||
const nodeName = node.parameter.type === utils_1.AST_NODE_TYPES.Identifier
|
||||
? node.parameter.name
|
||||
: // has to be an Identifier or TSC will throw an error
|
||||
node.parameter.left.name;
|
||||
switch (paramPropCheck) {
|
||||
case 'explicit': {
|
||||
if (!node.accessibility) {
|
||||
reportIssue('missingAccessibility', nodeType, node, nodeName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'no-public': {
|
||||
if (node.accessibility === 'public' && node.readonly) {
|
||||
reportIssue('unwantedPublicAccessibility', nodeType, node, nodeName, getUnwantedPublicAccessibilityFixer(node));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
'MethodDefinition, TSAbstractMethodDefinition': checkMethodAccessibilityModifier,
|
||||
'PropertyDefinition, TSAbstractPropertyDefinition': checkPropertyAccessibilityModifier,
|
||||
TSParameterProperty: checkParameterPropertyAccessibilityModifier,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-member-accessibility.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
385
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js
generated
vendored
Normal file
385
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js
generated
vendored
Normal file
@@ -0,0 +1,385 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const scope_manager_1 = require("@typescript-eslint/scope-manager");
|
||||
const util = __importStar(require("../util"));
|
||||
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
|
||||
exports.default = util.createRule({
|
||||
name: 'explicit-module-boundary-types',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: "Require explicit return and argument types on exported functions' and classes' public class methods",
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
missingReturnType: 'Missing return type on function.',
|
||||
missingArgType: "Argument '{{name}}' should be typed.",
|
||||
missingArgTypeUnnamed: '{{type}} argument should be typed.',
|
||||
anyTypedArg: "Argument '{{name}}' should be typed with a non-any type.",
|
||||
anyTypedArgUnnamed: '{{type}} argument should be typed with a non-any type.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowArgumentsExplicitlyTypedAsAny: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowDirectConstAssertionInArrowFunctions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowedNames: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
allowHigherOrderFunctions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
allowTypedFunctionExpressions: {
|
||||
type: 'boolean',
|
||||
},
|
||||
// DEPRECATED - To be removed in next major
|
||||
shouldTrackReferences: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowArgumentsExplicitlyTypedAsAny: false,
|
||||
allowDirectConstAssertionInArrowFunctions: true,
|
||||
allowedNames: [],
|
||||
allowHigherOrderFunctions: true,
|
||||
allowTypedFunctionExpressions: true,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
// tracks all of the functions we've already checked
|
||||
const checkedFunctions = new Set();
|
||||
// tracks functions that were found whilst traversing
|
||||
const foundFunctions = [];
|
||||
// all nodes visited, avoids infinite recursion for cyclic references
|
||||
// (such as class member referring to itself)
|
||||
const alreadyVisited = new Set();
|
||||
/*
|
||||
# How the rule works:
|
||||
|
||||
As the rule traverses the AST, it immediately checks every single function that it finds is exported.
|
||||
"exported" means that it is either directly exported, or that its name is exported.
|
||||
|
||||
It also collects a list of every single function it finds on the way, but does not check them.
|
||||
After it's finished traversing the AST, it then iterates through the list of found functions, and checks to see if
|
||||
any of them are part of a higher-order function
|
||||
*/
|
||||
return {
|
||||
ExportDefaultDeclaration(node) {
|
||||
checkNode(node.declaration);
|
||||
},
|
||||
'ExportNamedDeclaration:not([source])'(node) {
|
||||
if (node.declaration) {
|
||||
checkNode(node.declaration);
|
||||
}
|
||||
else {
|
||||
for (const specifier of node.specifiers) {
|
||||
followReference(specifier.local);
|
||||
}
|
||||
}
|
||||
},
|
||||
TSExportAssignment(node) {
|
||||
checkNode(node.expression);
|
||||
},
|
||||
'ArrowFunctionExpression, FunctionDeclaration, FunctionExpression'(node) {
|
||||
foundFunctions.push(node);
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const func of foundFunctions) {
|
||||
if (isExportedHigherOrderFunction(func)) {
|
||||
checkNode(func);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
function checkParameters(node) {
|
||||
function checkParameter(param) {
|
||||
function report(namedMessageId, unnamedMessageId) {
|
||||
if (param.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: namedMessageId,
|
||||
data: { name: param.name },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Array pattern' },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Object pattern' },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.RestElement) {
|
||||
if (param.argument.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: namedMessageId,
|
||||
data: { name: param.argument.name },
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Rest' },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (param.type) {
|
||||
case utils_1.AST_NODE_TYPES.ArrayPattern:
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
case utils_1.AST_NODE_TYPES.ObjectPattern:
|
||||
case utils_1.AST_NODE_TYPES.RestElement:
|
||||
if (!param.typeAnnotation) {
|
||||
report('missingArgType', 'missingArgTypeUnnamed');
|
||||
}
|
||||
else if (options.allowArgumentsExplicitlyTypedAsAny !== true &&
|
||||
param.typeAnnotation.typeAnnotation.type ===
|
||||
utils_1.AST_NODE_TYPES.TSAnyKeyword) {
|
||||
report('anyTypedArg', 'anyTypedArgUnnamed');
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.TSParameterProperty:
|
||||
return checkParameter(param.parameter);
|
||||
case utils_1.AST_NODE_TYPES.AssignmentPattern: // ignored as it has a type via its assignment
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const arg of node.params) {
|
||||
checkParameter(arg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if a function name is allowed and should not be checked.
|
||||
*/
|
||||
function isAllowedName(node) {
|
||||
var _a;
|
||||
if (!node || !options.allowedNames || !options.allowedNames.length) {
|
||||
return false;
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.VariableDeclarator ||
|
||||
node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration) {
|
||||
return (((_a = node.id) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
options.allowedNames.includes(node.id.name));
|
||||
}
|
||||
else if (node.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
|
||||
node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
|
||||
(node.type === utils_1.AST_NODE_TYPES.Property && node.method) ||
|
||||
node.type === utils_1.AST_NODE_TYPES.PropertyDefinition) {
|
||||
if (node.key.type === utils_1.AST_NODE_TYPES.Literal &&
|
||||
typeof node.key.value === 'string') {
|
||||
return options.allowedNames.includes(node.key.value);
|
||||
}
|
||||
if (node.key.type === utils_1.AST_NODE_TYPES.TemplateLiteral &&
|
||||
node.key.expressions.length === 0) {
|
||||
return options.allowedNames.includes(node.key.quasis[0].value.raw);
|
||||
}
|
||||
if (!node.computed && node.key.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return options.allowedNames.includes(node.key.name);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isExportedHigherOrderFunction(node) {
|
||||
var _a;
|
||||
let current = node.parent;
|
||||
while (current) {
|
||||
if (current.type === utils_1.AST_NODE_TYPES.ReturnStatement) {
|
||||
// the parent of a return will always be a block statement, so we can skip over it
|
||||
current = (_a = current.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
||||
continue;
|
||||
}
|
||||
if (!util.isFunction(current) ||
|
||||
!(0, explicitReturnTypeUtils_1.doesImmediatelyReturnFunctionExpression)(current)) {
|
||||
return false;
|
||||
}
|
||||
if (checkedFunctions.has(current)) {
|
||||
return true;
|
||||
}
|
||||
current = current.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function followReference(node) {
|
||||
const scope = context.getScope();
|
||||
const variable = scope.set.get(node.name);
|
||||
/* istanbul ignore if */ if (!variable) {
|
||||
return;
|
||||
}
|
||||
// check all of the definitions
|
||||
for (const definition of variable.defs) {
|
||||
// cases we don't care about in this rule
|
||||
if ([
|
||||
scope_manager_1.DefinitionType.ImplicitGlobalVariable,
|
||||
scope_manager_1.DefinitionType.ImportBinding,
|
||||
scope_manager_1.DefinitionType.CatchClause,
|
||||
scope_manager_1.DefinitionType.Parameter,
|
||||
].includes(definition.type)) {
|
||||
continue;
|
||||
}
|
||||
checkNode(definition.node);
|
||||
}
|
||||
// follow references to find writes to the variable
|
||||
for (const reference of variable.references) {
|
||||
if (
|
||||
// we don't want to check the initialization ref, as this is handled by the declaration check
|
||||
!reference.init &&
|
||||
reference.writeExpr) {
|
||||
checkNode(reference.writeExpr);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkNode(node) {
|
||||
if (node == null || alreadyVisited.has(node)) {
|
||||
return;
|
||||
}
|
||||
alreadyVisited.add(node);
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
||||
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
||||
return checkFunctionExpression(node);
|
||||
case utils_1.AST_NODE_TYPES.ArrayExpression:
|
||||
for (const element of node.elements) {
|
||||
checkNode(element);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
if (node.accessibility === 'private' ||
|
||||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.ClassDeclaration:
|
||||
case utils_1.AST_NODE_TYPES.ClassExpression:
|
||||
for (const element of node.body.body) {
|
||||
checkNode(element);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration:
|
||||
return checkFunction(node);
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
if (node.accessibility === 'private' ||
|
||||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
return followReference(node);
|
||||
case utils_1.AST_NODE_TYPES.ObjectExpression:
|
||||
for (const property of node.properties) {
|
||||
checkNode(property);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.Property:
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression:
|
||||
return checkEmptyBodyFunctionExpression(node);
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclaration:
|
||||
for (const declaration of node.declarations) {
|
||||
checkNode(declaration);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclarator:
|
||||
return checkNode(node.init);
|
||||
}
|
||||
}
|
||||
function checkEmptyBodyFunctionExpression(node) {
|
||||
var _a, _b, _c;
|
||||
const isConstructor = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
||||
node.parent.kind === 'constructor';
|
||||
const isSetAccessor = (((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
|
||||
((_c = node.parent) === null || _c === void 0 ? void 0 : _c.type) === utils_1.AST_NODE_TYPES.MethodDefinition) &&
|
||||
node.parent.kind === 'set';
|
||||
if (!isConstructor && !isSetAccessor && !node.returnType) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
}
|
||||
checkParameters(node);
|
||||
}
|
||||
function checkFunctionExpression(node) {
|
||||
if (checkedFunctions.has(node)) {
|
||||
return;
|
||||
}
|
||||
checkedFunctions.add(node);
|
||||
if (isAllowedName(node.parent) ||
|
||||
(0, explicitReturnTypeUtils_1.isTypedFunctionExpression)(node, options) ||
|
||||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionExpressionReturnType)(node, options, sourceCode, loc => {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
});
|
||||
checkParameters(node);
|
||||
}
|
||||
function checkFunction(node) {
|
||||
if (checkedFunctions.has(node)) {
|
||||
return;
|
||||
}
|
||||
checkedFunctions.add(node);
|
||||
if (isAllowedName(node) || (0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
});
|
||||
checkParameters(node);
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-module-boundary-types.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
168
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js
generated
vendored
Normal file
168
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'func-call-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require or disallow spacing between function identifiers and their invocations',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'array',
|
||||
items: [
|
||||
{
|
||||
enum: ['never'],
|
||||
},
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 1,
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: [
|
||||
{
|
||||
enum: ['always'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowNewlines: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
messages: {
|
||||
unexpectedWhitespace: 'Unexpected whitespace between function name and paren.',
|
||||
unexpectedNewline: 'Unexpected newline between function name and paren.',
|
||||
missing: 'Missing space between function name and paren.',
|
||||
},
|
||||
},
|
||||
defaultOptions: ['never', {}],
|
||||
create(context, [option, config]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const text = sourceCode.getText();
|
||||
/**
|
||||
* Check if open space is present in a function name
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkSpacing(node) {
|
||||
var _a;
|
||||
const isOptionalCall = util.isOptionalCallExpression(node);
|
||||
const closingParenToken = sourceCode.getLastToken(node);
|
||||
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken((_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.callee);
|
||||
const openingParenToken = sourceCode.getFirstTokenBetween(lastCalleeTokenWithoutPossibleParens, closingParenToken, util.isOpeningParenToken);
|
||||
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {
|
||||
// new expression with no parens...
|
||||
return;
|
||||
}
|
||||
const lastCalleeToken = sourceCode.getTokenBefore(openingParenToken, util.isNotOptionalChainPunctuator);
|
||||
const textBetweenTokens = text
|
||||
.slice(lastCalleeToken.range[1], openingParenToken.range[0])
|
||||
.replace(/\/\*.*?\*\//gu, '');
|
||||
const hasWhitespace = /\s/u.test(textBetweenTokens);
|
||||
const hasNewline = hasWhitespace && util.LINEBREAK_MATCHER.test(textBetweenTokens);
|
||||
if (option === 'never') {
|
||||
if (hasWhitespace) {
|
||||
return context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'unexpectedWhitespace',
|
||||
fix(fixer) {
|
||||
/*
|
||||
* Only autofix if there is no newline
|
||||
* https://github.com/eslint/eslint/issues/7787
|
||||
*/
|
||||
if (!hasNewline &&
|
||||
// don't fix optional calls
|
||||
!isOptionalCall) {
|
||||
return fixer.removeRange([
|
||||
lastCalleeToken.range[1],
|
||||
openingParenToken.range[0],
|
||||
]);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (isOptionalCall) {
|
||||
// disallow:
|
||||
// foo?. ();
|
||||
// foo ?.();
|
||||
// foo ?. ();
|
||||
if (hasWhitespace || hasNewline) {
|
||||
context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'unexpectedWhitespace',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'missing',
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(openingParenToken, ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
else if (!config.allowNewlines && hasNewline) {
|
||||
context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'unexpectedNewline',
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange([lastCalleeToken.range[1], openingParenToken.range[0]], ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
CallExpression: checkSpacing,
|
||||
NewExpression: checkSpacing,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=func-call-spacing.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"func-call-spacing.js","sourceRoot":"","sources":["../../src/rules/func-call-spacing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAgC;AAahC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EACT,gFAAgF;YAClF,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE;YACN,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,CAAC,OAAO,CAAC;yBAChB;qBACF;oBACD,QAAQ,EAAE,CAAC;oBACX,QAAQ,EAAE,CAAC;iBACZ;gBACD;oBACE,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,CAAC,QAAQ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,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,SAAS;wBACpB,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;wBACxD,CAAC;qBACF,CAAC,CAAC;iBACJ;qBAAM,IAAI,CAAC,MAAO,CAAC,aAAa,IAAI,UAAU,EAAE;oBAC/C,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,mBAAmB;wBAC9B,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,gBAAgB,CAC3B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACtD,GAAG,CACJ,CAAC;wBACJ,CAAC;qBACF,CAAC,CAAC;iBACJ;aACF;QACH,CAAC;QAED,OAAO;YACL,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,YAAY;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
55
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/BinarySearchTree.js
generated
vendored
Normal file
55
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/BinarySearchTree.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
// The following code is adapted from the the code in eslint.
|
||||
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BinarySearchTree = void 0;
|
||||
const functional_red_black_tree_1 = __importDefault(require("functional-red-black-tree"));
|
||||
/**
|
||||
* A mutable balanced binary search tree that stores (key, value) pairs. The keys are numeric, and must be unique.
|
||||
* This is intended to be a generic wrapper around a balanced binary search tree library, so that the underlying implementation
|
||||
* can easily be swapped out.
|
||||
*/
|
||||
class BinarySearchTree {
|
||||
constructor() {
|
||||
this.rbTree = (0, functional_red_black_tree_1.default)();
|
||||
}
|
||||
/**
|
||||
* Inserts an entry into the tree.
|
||||
*/
|
||||
insert(key, value) {
|
||||
const iterator = this.rbTree.find(key);
|
||||
if (iterator.valid) {
|
||||
this.rbTree = iterator.update(value);
|
||||
}
|
||||
else {
|
||||
this.rbTree = this.rbTree.insert(key, value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Finds the entry with the largest key less than or equal to the provided key
|
||||
* @returns The found entry, or null if no such entry exists.
|
||||
*/
|
||||
findLe(key) {
|
||||
const iterator = this.rbTree.le(key);
|
||||
return { key: iterator.key, value: iterator.value };
|
||||
}
|
||||
/**
|
||||
* Deletes all of the keys in the interval [start, end)
|
||||
*/
|
||||
deleteRange(start, end) {
|
||||
// Exit without traversing the tree if the range has zero size.
|
||||
if (start === end) {
|
||||
return;
|
||||
}
|
||||
const iterator = this.rbTree.ge(start);
|
||||
while (iterator.valid && iterator.key < end) {
|
||||
this.rbTree = this.rbTree.remove(iterator.key);
|
||||
iterator.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.BinarySearchTree = BinarySearchTree;
|
||||
//# sourceMappingURL=BinarySearchTree.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/BinarySearchTree.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/BinarySearchTree.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BinarySearchTree.js","sourceRoot":"","sources":["../../../src/rules/indent-new-do-not-use/BinarySearchTree.ts"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,kGAAkG;;;;;;AAGlG,0FAAmD;AAQnD;;;;GAIG;AACH,MAAa,gBAAgB;IAA7B;QACU,WAAM,GAAG,IAAA,mCAAU,GAAa,CAAC;IAwC3C,CAAC;IAtCC;;OAEG;IACI,MAAM,CAAC,GAAW,EAAE,KAAgB;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEvC,IAAI,QAAQ,CAAC,KAAK,EAAE;YAClB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACtC;aAAM;YACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC9C;IACH,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,GAAW;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QAErC,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,WAAW,CAAC,KAAa,EAAE,GAAW;QAC3C,+DAA+D;QAC/D,IAAI,KAAK,KAAK,GAAG,EAAE;YACjB,OAAO;SACR;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAEvC,OAAO,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,GAAG,GAAG,GAAG,EAAE;YAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC/C,QAAQ,CAAC,IAAI,EAAE,CAAC;SACjB;IACH,CAAC;CACF;AAzCD,4CAyCC"}
|
||||
221
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/OffsetStorage.js
generated
vendored
Normal file
221
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/OffsetStorage.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
"use strict";
|
||||
// The following code is adapted from the the code in eslint.
|
||||
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OffsetStorage = void 0;
|
||||
const BinarySearchTree_1 = require("./BinarySearchTree");
|
||||
/**
|
||||
* A class to store information on desired offsets of tokens from each other
|
||||
*/
|
||||
class OffsetStorage {
|
||||
/**
|
||||
* @param tokenInfo a TokenInfo instance
|
||||
* @param indentSize The desired size of each indentation level
|
||||
* @param indentType The indentation character
|
||||
*/
|
||||
constructor(tokenInfo, indentSize, indentType) {
|
||||
this.tokenInfo = tokenInfo;
|
||||
this.indentSize = indentSize;
|
||||
this.indentType = indentType;
|
||||
this.tree = new BinarySearchTree_1.BinarySearchTree();
|
||||
this.tree.insert(0, { offset: 0, from: null, force: false });
|
||||
this.lockedFirstTokens = new WeakMap();
|
||||
this.desiredIndentCache = new WeakMap();
|
||||
this.ignoredTokens = new WeakSet();
|
||||
}
|
||||
getOffsetDescriptor(token) {
|
||||
return this.tree.findLe(token.range[0]).value;
|
||||
}
|
||||
/**
|
||||
* Sets the offset column of token B to match the offset column of token A.
|
||||
* **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
|
||||
* most cases, `setDesiredOffset` should be used instead.
|
||||
* @param baseToken The first token
|
||||
* @param offsetToken The second token, whose offset should be matched to the first token
|
||||
*/
|
||||
matchOffsetOf(baseToken, offsetToken) {
|
||||
/*
|
||||
* lockedFirstTokens is a map from a token whose indentation is controlled by the "first" option to
|
||||
* the token that it depends on. For example, with the `ArrayExpression: first` option, the first
|
||||
* token of each element in the array after the first will be mapped to the first token of the first
|
||||
* element. The desired indentation of each of these tokens is computed based on the desired indentation
|
||||
* of the "first" element, rather than through the normal offset mechanism.
|
||||
*/
|
||||
this.lockedFirstTokens.set(offsetToken, baseToken);
|
||||
}
|
||||
/**
|
||||
* Sets the desired offset of a token.
|
||||
*
|
||||
* This uses a line-based offset collapsing behavior to handle tokens on the same line.
|
||||
* For example, consider the following two cases:
|
||||
*
|
||||
* (
|
||||
* [
|
||||
* bar
|
||||
* ]
|
||||
* )
|
||||
*
|
||||
* ([
|
||||
* bar
|
||||
* ])
|
||||
*
|
||||
* Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from
|
||||
* the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is
|
||||
* the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces)
|
||||
* from the start of its line.
|
||||
*
|
||||
* However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level
|
||||
* between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the
|
||||
* `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented
|
||||
* by 1 indent level from the start of the line.
|
||||
*
|
||||
* This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node,
|
||||
* without needing to check which lines those tokens are on.
|
||||
*
|
||||
* Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive
|
||||
* behavior can occur. For example, consider the following cases:
|
||||
*
|
||||
* foo(
|
||||
* ).
|
||||
* bar(
|
||||
* baz
|
||||
* )
|
||||
*
|
||||
* foo(
|
||||
* ).bar(
|
||||
* baz
|
||||
* )
|
||||
*
|
||||
* Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz`
|
||||
* should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz`
|
||||
* being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no
|
||||
* collapsing would occur).
|
||||
*
|
||||
* Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and
|
||||
* offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed
|
||||
* in the second case.
|
||||
*
|
||||
* @param token The token
|
||||
* @param fromToken The token that `token` should be offset from
|
||||
* @param offset The desired indent level
|
||||
*/
|
||||
setDesiredOffset(token, fromToken, offset) {
|
||||
this.setDesiredOffsets(token.range, fromToken, offset);
|
||||
}
|
||||
/**
|
||||
* Sets the desired offset of all tokens in a range
|
||||
* It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens.
|
||||
* Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains
|
||||
* it). This means that the offset of each token is updated O(AST depth) times.
|
||||
* It would not be performant to store and update the offsets for each token independently, because the rule would end
|
||||
* up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files.
|
||||
*
|
||||
* Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following
|
||||
* list could represent the state of the offset tree at a given point:
|
||||
*
|
||||
* * Tokens starting in the interval [0, 15) are aligned with the beginning of the file
|
||||
* * Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
|
||||
* * Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
|
||||
* * Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
|
||||
* * Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
|
||||
*
|
||||
* The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
|
||||
* `setDesiredOffsets([30, 43], fooToken, 1);`
|
||||
*
|
||||
* @param range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied.
|
||||
* @param fromToken The token that this is offset from
|
||||
* @param offset The desired indent level
|
||||
* @param force `true` if this offset should not use the normal collapsing behavior. This should almost always be false.
|
||||
*/
|
||||
setDesiredOffsets(range, fromToken, offset = 0, force = false) {
|
||||
/*
|
||||
* Offset ranges are stored as a collection of nodes, where each node maps a numeric key to an offset
|
||||
* descriptor. The tree for the example above would have the following nodes:
|
||||
*
|
||||
* * key: 0, value: { offset: 0, from: null }
|
||||
* * key: 15, value: { offset: 1, from: barToken }
|
||||
* * key: 30, value: { offset: 1, from: fooToken }
|
||||
* * key: 43, value: { offset: 2, from: barToken }
|
||||
* * key: 820, value: { offset: 1, from: bazToken }
|
||||
*
|
||||
* To find the offset descriptor for any given token, one needs to find the node with the largest key
|
||||
* which is <= token.start. To make this operation fast, the nodes are stored in a balanced binary
|
||||
* search tree indexed by key.
|
||||
*/
|
||||
const descriptorToInsert = { offset, from: fromToken, force };
|
||||
const descriptorAfterRange = this.tree.findLe(range[1]).value;
|
||||
const fromTokenIsInRange = fromToken &&
|
||||
fromToken.range[0] >= range[0] &&
|
||||
fromToken.range[1] <= range[1];
|
||||
// this has to be before the delete + insert below or else you'll get into a cycle
|
||||
const fromTokenDescriptor = fromTokenIsInRange
|
||||
? this.getOffsetDescriptor(fromToken)
|
||||
: null;
|
||||
// First, remove any existing nodes in the range from the tree.
|
||||
this.tree.deleteRange(range[0] + 1, range[1]);
|
||||
// Insert a new node into the tree for this range
|
||||
this.tree.insert(range[0], descriptorToInsert);
|
||||
/*
|
||||
* To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
|
||||
* even if it's in the current range.
|
||||
*/
|
||||
if (fromTokenIsInRange) {
|
||||
this.tree.insert(fromToken.range[0], fromTokenDescriptor);
|
||||
this.tree.insert(fromToken.range[1], descriptorToInsert);
|
||||
}
|
||||
/*
|
||||
* To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
|
||||
* tokens the same as it was before.
|
||||
*/
|
||||
this.tree.insert(range[1], descriptorAfterRange);
|
||||
}
|
||||
/**
|
||||
* Gets the desired indent of a token
|
||||
* @returns The desired indent of the token
|
||||
*/
|
||||
getDesiredIndent(token) {
|
||||
if (!this.desiredIndentCache.has(token)) {
|
||||
if (this.ignoredTokens.has(token)) {
|
||||
/*
|
||||
* If the token is ignored, use the actual indent of the token as the desired indent.
|
||||
* This ensures that no errors are reported for this token.
|
||||
*/
|
||||
this.desiredIndentCache.set(token, this.tokenInfo.getTokenIndent(token));
|
||||
}
|
||||
else if (this.lockedFirstTokens.has(token)) {
|
||||
const firstToken = this.lockedFirstTokens.get(token);
|
||||
this.desiredIndentCache.set(token,
|
||||
// (indentation for the first element's line)
|
||||
this.getDesiredIndent(this.tokenInfo.getFirstTokenOfLine(firstToken)) +
|
||||
// (space between the start of the first element's line and the first element)
|
||||
this.indentType.repeat(firstToken.loc.start.column -
|
||||
this.tokenInfo.getFirstTokenOfLine(firstToken).loc.start.column));
|
||||
}
|
||||
else {
|
||||
const offsetInfo = this.getOffsetDescriptor(token);
|
||||
const offset = offsetInfo.from &&
|
||||
offsetInfo.from.loc.start.line === token.loc.start.line &&
|
||||
!/^\s*?\n/u.test(token.value) &&
|
||||
!offsetInfo.force
|
||||
? 0
|
||||
: offsetInfo.offset * this.indentSize;
|
||||
this.desiredIndentCache.set(token, (offsetInfo.from ? this.getDesiredIndent(offsetInfo.from) : '') +
|
||||
this.indentType.repeat(offset));
|
||||
}
|
||||
}
|
||||
return this.desiredIndentCache.get(token);
|
||||
}
|
||||
/**
|
||||
* Ignores a token, preventing it from being reported.
|
||||
*/
|
||||
ignoreToken(token) {
|
||||
if (this.tokenInfo.isFirstTokenOfLine(token)) {
|
||||
this.ignoredTokens.add(token);
|
||||
}
|
||||
}
|
||||
getFirstDependency(token) {
|
||||
return this.getOffsetDescriptor(token).from;
|
||||
}
|
||||
}
|
||||
exports.OffsetStorage = OffsetStorage;
|
||||
//# sourceMappingURL=OffsetStorage.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/OffsetStorage.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/OffsetStorage.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"OffsetStorage.js","sourceRoot":"","sources":["../../../src/rules/indent-new-do-not-use/OffsetStorage.ts"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,kGAAkG;;;AAGlG,yDAAiE;AAGjE;;GAEG;AACH,MAAa,aAAa;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AAG,CACzB,KAAK,EACL,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC7D,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CACjC,CAAC;aACH;SACF;QAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,KAAqB;QAC/B,IAAI,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;YAC5C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC/B;IACH,CAAC;IAUD,kBAAkB,CAAC,KAAqB;QACtC,OAAO,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;CACF;AA5QD,sCA4QC"}
|
||||
49
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/TokenInfo.js
generated
vendored
Normal file
49
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/TokenInfo.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
// The following code is adapted from the the code in eslint.
|
||||
// License: https://github.com/eslint/eslint/blob/48700fc8408f394887cdedd071b22b757700fdcb/LICENSE
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TokenInfo = void 0;
|
||||
/**
|
||||
* A helper class to get token-based info related to indentation
|
||||
*/
|
||||
class TokenInfo {
|
||||
constructor(sourceCode) {
|
||||
this.sourceCode = sourceCode;
|
||||
this.firstTokensByLineNumber = sourceCode.tokensAndComments.reduce((map, token) => {
|
||||
if (!map.has(token.loc.start.line)) {
|
||||
map.set(token.loc.start.line, token);
|
||||
}
|
||||
if (!map.has(token.loc.end.line) &&
|
||||
sourceCode.text
|
||||
.slice(token.range[1] - token.loc.end.column, token.range[1])
|
||||
.trim()) {
|
||||
map.set(token.loc.end.line, token);
|
||||
}
|
||||
return map;
|
||||
}, new Map());
|
||||
}
|
||||
/**
|
||||
* Gets the first token on a given token's line
|
||||
* @returns The first token on the given line
|
||||
*/
|
||||
getFirstTokenOfLine(token) {
|
||||
return this.firstTokensByLineNumber.get(token.loc.start.line);
|
||||
}
|
||||
/**
|
||||
* Determines whether a token is the first token in its line
|
||||
* @returns `true` if the token is the first on its line
|
||||
*/
|
||||
isFirstTokenOfLine(token) {
|
||||
return this.getFirstTokenOfLine(token) === token;
|
||||
}
|
||||
/**
|
||||
* Get the actual indent of a token
|
||||
* @param token Token to examine. This should be the first token on its line.
|
||||
* @returns The indentation characters that precede the token
|
||||
*/
|
||||
getTokenIndent(token) {
|
||||
return this.sourceCode.text.slice(token.range[0] - token.loc.start.column, token.range[0]);
|
||||
}
|
||||
}
|
||||
exports.TokenInfo = TokenInfo;
|
||||
//# sourceMappingURL=TokenInfo.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/TokenInfo.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/TokenInfo.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TokenInfo.js","sourceRoot":"","sources":["../../../src/rules/indent-new-do-not-use/TokenInfo.ts"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,kGAAkG;;;AAIlG;;GAEG;AACH,MAAa,SAAS;IAIpB,YAAY,UAA+B;QACzC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAChE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACb,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAClC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACtC;YACD,IACE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;gBAC5B,UAAU,CAAC,IAAI;qBACZ,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;qBAC5D,IAAI,EAAE,EACT;gBACA,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACpC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EACD,IAAI,GAAG,EAA0B,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,mBAAmB,CACxB,KAAqC;QAErC,OAAO,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC;IACjE,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,KAAqB;QAC7C,OAAO,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,KAAqB;QACzC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAC/B,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EACvC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CACf,CAAC;IACJ,CAAC;CACF;AAtDD,8BAsDC"}
|
||||
1140
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/index.js
generated
vendored
Normal file
1140
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/index.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent-new-do-not-use/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
410
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js
generated
vendored
Normal file
410
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js
generated
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Note this file is rather type-unsafe in its current state.
|
||||
* This is due to some really funky type conversions between different node types.
|
||||
* This is done intentionally based on the internal implementation of the base indent rule.
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const util = __importStar(require("../util"));
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('indent');
|
||||
const KNOWN_NODES = new Set([
|
||||
// Class properties aren't yet supported by eslint...
|
||||
utils_1.AST_NODE_TYPES.PropertyDefinition,
|
||||
// ts keywords
|
||||
utils_1.AST_NODE_TYPES.TSAbstractKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSAnyKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSBooleanKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSNeverKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSNumberKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSStringKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSSymbolKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSUnknownKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSVoidKeyword,
|
||||
utils_1.AST_NODE_TYPES.TSNullKeyword,
|
||||
// ts specific nodes we want to support
|
||||
utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition,
|
||||
utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition,
|
||||
utils_1.AST_NODE_TYPES.TSArrayType,
|
||||
utils_1.AST_NODE_TYPES.TSAsExpression,
|
||||
utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSConditionalType,
|
||||
utils_1.AST_NODE_TYPES.TSConstructorType,
|
||||
utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSDeclareFunction,
|
||||
utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
|
||||
utils_1.AST_NODE_TYPES.TSEnumDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSEnumMember,
|
||||
utils_1.AST_NODE_TYPES.TSExportAssignment,
|
||||
utils_1.AST_NODE_TYPES.TSExternalModuleReference,
|
||||
utils_1.AST_NODE_TYPES.TSFunctionType,
|
||||
utils_1.AST_NODE_TYPES.TSImportType,
|
||||
utils_1.AST_NODE_TYPES.TSIndexedAccessType,
|
||||
utils_1.AST_NODE_TYPES.TSIndexSignature,
|
||||
utils_1.AST_NODE_TYPES.TSInferType,
|
||||
utils_1.AST_NODE_TYPES.TSInterfaceBody,
|
||||
utils_1.AST_NODE_TYPES.TSInterfaceDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSInterfaceHeritage,
|
||||
utils_1.AST_NODE_TYPES.TSIntersectionType,
|
||||
utils_1.AST_NODE_TYPES.TSImportEqualsDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSLiteralType,
|
||||
utils_1.AST_NODE_TYPES.TSMappedType,
|
||||
utils_1.AST_NODE_TYPES.TSMethodSignature,
|
||||
'TSMinusToken',
|
||||
utils_1.AST_NODE_TYPES.TSModuleBlock,
|
||||
utils_1.AST_NODE_TYPES.TSModuleDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSNonNullExpression,
|
||||
utils_1.AST_NODE_TYPES.TSParameterProperty,
|
||||
'TSPlusToken',
|
||||
utils_1.AST_NODE_TYPES.TSPropertySignature,
|
||||
utils_1.AST_NODE_TYPES.TSQualifiedName,
|
||||
'TSQuestionToken',
|
||||
utils_1.AST_NODE_TYPES.TSRestType,
|
||||
utils_1.AST_NODE_TYPES.TSThisType,
|
||||
utils_1.AST_NODE_TYPES.TSTupleType,
|
||||
utils_1.AST_NODE_TYPES.TSTypeAnnotation,
|
||||
utils_1.AST_NODE_TYPES.TSTypeLiteral,
|
||||
utils_1.AST_NODE_TYPES.TSTypeOperator,
|
||||
utils_1.AST_NODE_TYPES.TSTypeParameter,
|
||||
utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration,
|
||||
utils_1.AST_NODE_TYPES.TSTypeParameterInstantiation,
|
||||
utils_1.AST_NODE_TYPES.TSTypeReference,
|
||||
utils_1.AST_NODE_TYPES.TSUnionType,
|
||||
utils_1.AST_NODE_TYPES.Decorator,
|
||||
]);
|
||||
exports.default = util.createRule({
|
||||
name: 'indent',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent indentation',
|
||||
// too opinionated to be recommended
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [
|
||||
// typescript docs and playground use 4 space indent
|
||||
4,
|
||||
{
|
||||
// typescript docs indent the case from the switch
|
||||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#example-4
|
||||
SwitchCase: 1,
|
||||
flatTernaryExpressions: false,
|
||||
ignoredNodes: [],
|
||||
},
|
||||
],
|
||||
create(context, optionsWithDefaults) {
|
||||
// because we extend the base rule, have to update opts on the context
|
||||
// the context defines options as readonly though...
|
||||
const contextWithDefaults = Object.create(context, {
|
||||
options: {
|
||||
writable: false,
|
||||
configurable: false,
|
||||
value: optionsWithDefaults,
|
||||
},
|
||||
});
|
||||
const rules = baseRule.create(contextWithDefaults);
|
||||
/**
|
||||
* Converts from a TSPropertySignature to a Property
|
||||
* @param node a TSPropertySignature node
|
||||
* @param [type] the type to give the new node
|
||||
* @returns a Property node
|
||||
*/
|
||||
function TSPropertySignatureToProperty(node, type = utils_1.AST_NODE_TYPES.Property) {
|
||||
const base = {
|
||||
// indent doesn't actually use these
|
||||
key: null,
|
||||
value: null,
|
||||
// Property flags
|
||||
computed: false,
|
||||
method: false,
|
||||
kind: 'init',
|
||||
// this will stop eslint from interrogating the type literal
|
||||
shorthand: true,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
};
|
||||
if (type === utils_1.AST_NODE_TYPES.Property) {
|
||||
return Object.assign({ type }, base);
|
||||
}
|
||||
else {
|
||||
return Object.assign({ type, static: false, readonly: false, declare: false }, base);
|
||||
}
|
||||
}
|
||||
return Object.assign({}, rules, {
|
||||
// overwrite the base rule here so we can use our KNOWN_NODES list instead
|
||||
'*:exit'(node) {
|
||||
// For nodes we care about, skip the default handling, because it just marks the node as ignored...
|
||||
if (!KNOWN_NODES.has(node.type)) {
|
||||
rules['*:exit'](node);
|
||||
}
|
||||
},
|
||||
VariableDeclaration(node) {
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/441
|
||||
if (node.declarations.length === 0) {
|
||||
return;
|
||||
}
|
||||
return rules.VariableDeclaration(node);
|
||||
},
|
||||
TSAsExpression(node) {
|
||||
// transform it to a BinaryExpression
|
||||
return rules['BinaryExpression, LogicalExpression']({
|
||||
type: utils_1.AST_NODE_TYPES.BinaryExpression,
|
||||
operator: 'as',
|
||||
left: node.expression,
|
||||
// the first typeAnnotation includes the as token
|
||||
right: node.typeAnnotation,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSConditionalType(node) {
|
||||
// transform it to a ConditionalExpression
|
||||
return rules.ConditionalExpression({
|
||||
type: utils_1.AST_NODE_TYPES.ConditionalExpression,
|
||||
test: {
|
||||
type: utils_1.AST_NODE_TYPES.BinaryExpression,
|
||||
operator: 'extends',
|
||||
left: node.checkType,
|
||||
right: node.extendsType,
|
||||
// location data
|
||||
range: [node.checkType.range[0], node.extendsType.range[1]],
|
||||
loc: {
|
||||
start: node.checkType.loc.start,
|
||||
end: node.extendsType.loc.end,
|
||||
},
|
||||
},
|
||||
consequent: node.trueType,
|
||||
alternate: node.falseType,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
'TSEnumDeclaration, TSTypeLiteral'(node) {
|
||||
// transform it to an ObjectExpression
|
||||
return rules['ObjectExpression, ObjectPattern']({
|
||||
type: utils_1.AST_NODE_TYPES.ObjectExpression,
|
||||
properties: node.members.map(member => TSPropertySignatureToProperty(member)),
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSImportEqualsDeclaration(node) {
|
||||
// transform it to an VariableDeclaration
|
||||
// use VariableDeclaration instead of ImportDeclaration because it's essentially the same thing
|
||||
const { id, moduleReference } = node;
|
||||
return rules.VariableDeclaration({
|
||||
type: utils_1.AST_NODE_TYPES.VariableDeclaration,
|
||||
kind: 'const',
|
||||
declarations: [
|
||||
{
|
||||
type: utils_1.AST_NODE_TYPES.VariableDeclarator,
|
||||
range: [id.range[0], moduleReference.range[1]],
|
||||
loc: {
|
||||
start: id.loc.start,
|
||||
end: moduleReference.loc.end,
|
||||
},
|
||||
id: id,
|
||||
init: {
|
||||
type: utils_1.AST_NODE_TYPES.CallExpression,
|
||||
callee: {
|
||||
type: utils_1.AST_NODE_TYPES.Identifier,
|
||||
name: 'require',
|
||||
range: [
|
||||
moduleReference.range[0],
|
||||
moduleReference.range[0] + 'require'.length,
|
||||
],
|
||||
loc: {
|
||||
start: moduleReference.loc.start,
|
||||
end: {
|
||||
line: moduleReference.loc.end.line,
|
||||
column: moduleReference.loc.start.line + 'require'.length,
|
||||
},
|
||||
},
|
||||
},
|
||||
arguments: 'expression' in moduleReference
|
||||
? [moduleReference.expression]
|
||||
: [],
|
||||
// location data
|
||||
range: moduleReference.range,
|
||||
loc: moduleReference.loc,
|
||||
},
|
||||
},
|
||||
],
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSIndexedAccessType(node) {
|
||||
// convert to a MemberExpression
|
||||
return rules['MemberExpression, JSXMemberExpression, MetaProperty']({
|
||||
type: utils_1.AST_NODE_TYPES.MemberExpression,
|
||||
object: node.objectType,
|
||||
property: node.indexType,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
optional: false,
|
||||
computed: true,
|
||||
});
|
||||
},
|
||||
TSInterfaceBody(node) {
|
||||
// transform it to an ClassBody
|
||||
return rules['BlockStatement, ClassBody']({
|
||||
type: utils_1.AST_NODE_TYPES.ClassBody,
|
||||
body: node.body.map(p => TSPropertySignatureToProperty(p, utils_1.AST_NODE_TYPES.PropertyDefinition)),
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
'TSInterfaceDeclaration[extends.length > 0]'(node) {
|
||||
// transform it to a ClassDeclaration
|
||||
return rules['ClassDeclaration[superClass], ClassExpression[superClass]']({
|
||||
type: utils_1.AST_NODE_TYPES.ClassDeclaration,
|
||||
body: node.body,
|
||||
id: null,
|
||||
// TODO: This is invalid, there can be more than one extends in interface
|
||||
superClass: node.extends[0].expression,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSMappedType(node) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const squareBracketStart = sourceCode.getTokenBefore(node.typeParameter);
|
||||
// transform it to an ObjectExpression
|
||||
return rules['ObjectExpression, ObjectPattern']({
|
||||
type: utils_1.AST_NODE_TYPES.ObjectExpression,
|
||||
properties: [
|
||||
{
|
||||
type: utils_1.AST_NODE_TYPES.Property,
|
||||
key: node.typeParameter,
|
||||
value: node.typeAnnotation,
|
||||
// location data
|
||||
range: [
|
||||
squareBracketStart.range[0],
|
||||
node.typeAnnotation
|
||||
? node.typeAnnotation.range[1]
|
||||
: squareBracketStart.range[0],
|
||||
],
|
||||
loc: {
|
||||
start: squareBracketStart.loc.start,
|
||||
end: node.typeAnnotation
|
||||
? node.typeAnnotation.loc.end
|
||||
: squareBracketStart.loc.end,
|
||||
},
|
||||
kind: 'init',
|
||||
computed: false,
|
||||
method: false,
|
||||
shorthand: false,
|
||||
},
|
||||
],
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSModuleBlock(node) {
|
||||
// transform it to a BlockStatement
|
||||
return rules['BlockStatement, ClassBody']({
|
||||
type: utils_1.AST_NODE_TYPES.BlockStatement,
|
||||
body: node.body,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSQualifiedName(node) {
|
||||
return rules['MemberExpression, JSXMemberExpression, MetaProperty']({
|
||||
type: utils_1.AST_NODE_TYPES.MemberExpression,
|
||||
object: node.left,
|
||||
property: node.right,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
optional: false,
|
||||
computed: false,
|
||||
});
|
||||
},
|
||||
TSTupleType(node) {
|
||||
// transform it to an ArrayExpression
|
||||
return rules['ArrayExpression, ArrayPattern']({
|
||||
type: utils_1.AST_NODE_TYPES.ArrayExpression,
|
||||
elements: node.elementTypes,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSTypeParameterDeclaration(node) {
|
||||
if (!node.params.length) {
|
||||
return;
|
||||
}
|
||||
const [name, ...attributes] = node.params;
|
||||
// JSX is about the closest we can get because the angle brackets
|
||||
// it's not perfect but it works!
|
||||
return rules.JSXOpeningElement({
|
||||
type: utils_1.AST_NODE_TYPES.JSXOpeningElement,
|
||||
selfClosing: false,
|
||||
name: name,
|
||||
attributes: attributes,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=indent.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
262
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
generated
vendored
Normal file
262
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
generated
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const adjacent_overload_signatures_1 = __importDefault(require("./adjacent-overload-signatures"));
|
||||
const array_type_1 = __importDefault(require("./array-type"));
|
||||
const await_thenable_1 = __importDefault(require("./await-thenable"));
|
||||
const ban_ts_comment_1 = __importDefault(require("./ban-ts-comment"));
|
||||
const ban_tslint_comment_1 = __importDefault(require("./ban-tslint-comment"));
|
||||
const ban_types_1 = __importDefault(require("./ban-types"));
|
||||
const brace_style_1 = __importDefault(require("./brace-style"));
|
||||
const class_literal_property_style_1 = __importDefault(require("./class-literal-property-style"));
|
||||
const comma_dangle_1 = __importDefault(require("./comma-dangle"));
|
||||
const comma_spacing_1 = __importDefault(require("./comma-spacing"));
|
||||
const consistent_generic_constructors_1 = __importDefault(require("./consistent-generic-constructors"));
|
||||
const consistent_indexed_object_style_1 = __importDefault(require("./consistent-indexed-object-style"));
|
||||
const consistent_type_assertions_1 = __importDefault(require("./consistent-type-assertions"));
|
||||
const consistent_type_definitions_1 = __importDefault(require("./consistent-type-definitions"));
|
||||
const consistent_type_exports_1 = __importDefault(require("./consistent-type-exports"));
|
||||
const consistent_type_imports_1 = __importDefault(require("./consistent-type-imports"));
|
||||
const default_param_last_1 = __importDefault(require("./default-param-last"));
|
||||
const dot_notation_1 = __importDefault(require("./dot-notation"));
|
||||
const explicit_function_return_type_1 = __importDefault(require("./explicit-function-return-type"));
|
||||
const explicit_member_accessibility_1 = __importDefault(require("./explicit-member-accessibility"));
|
||||
const explicit_module_boundary_types_1 = __importDefault(require("./explicit-module-boundary-types"));
|
||||
const func_call_spacing_1 = __importDefault(require("./func-call-spacing"));
|
||||
const indent_1 = __importDefault(require("./indent"));
|
||||
const init_declarations_1 = __importDefault(require("./init-declarations"));
|
||||
const keyword_spacing_1 = __importDefault(require("./keyword-spacing"));
|
||||
const lines_between_class_members_1 = __importDefault(require("./lines-between-class-members"));
|
||||
const member_delimiter_style_1 = __importDefault(require("./member-delimiter-style"));
|
||||
const member_ordering_1 = __importDefault(require("./member-ordering"));
|
||||
const method_signature_style_1 = __importDefault(require("./method-signature-style"));
|
||||
const naming_convention_1 = __importDefault(require("./naming-convention"));
|
||||
const no_array_constructor_1 = __importDefault(require("./no-array-constructor"));
|
||||
const no_base_to_string_1 = __importDefault(require("./no-base-to-string"));
|
||||
const no_confusing_non_null_assertion_1 = __importDefault(require("./no-confusing-non-null-assertion"));
|
||||
const no_confusing_void_expression_1 = __importDefault(require("./no-confusing-void-expression"));
|
||||
const no_dupe_class_members_1 = __importDefault(require("./no-dupe-class-members"));
|
||||
const no_duplicate_enum_values_1 = __importDefault(require("./no-duplicate-enum-values"));
|
||||
const no_duplicate_imports_1 = __importDefault(require("./no-duplicate-imports"));
|
||||
const no_dynamic_delete_1 = __importDefault(require("./no-dynamic-delete"));
|
||||
const no_empty_function_1 = __importDefault(require("./no-empty-function"));
|
||||
const no_empty_interface_1 = __importDefault(require("./no-empty-interface"));
|
||||
const no_explicit_any_1 = __importDefault(require("./no-explicit-any"));
|
||||
const no_extra_non_null_assertion_1 = __importDefault(require("./no-extra-non-null-assertion"));
|
||||
const no_extra_parens_1 = __importDefault(require("./no-extra-parens"));
|
||||
const no_extra_semi_1 = __importDefault(require("./no-extra-semi"));
|
||||
const no_extraneous_class_1 = __importDefault(require("./no-extraneous-class"));
|
||||
const no_floating_promises_1 = __importDefault(require("./no-floating-promises"));
|
||||
const no_for_in_array_1 = __importDefault(require("./no-for-in-array"));
|
||||
const no_implicit_any_catch_1 = __importDefault(require("./no-implicit-any-catch"));
|
||||
const no_implied_eval_1 = __importDefault(require("./no-implied-eval"));
|
||||
const no_inferrable_types_1 = __importDefault(require("./no-inferrable-types"));
|
||||
const no_invalid_this_1 = __importDefault(require("./no-invalid-this"));
|
||||
const no_invalid_void_type_1 = __importDefault(require("./no-invalid-void-type"));
|
||||
const no_loop_func_1 = __importDefault(require("./no-loop-func"));
|
||||
const no_loss_of_precision_1 = __importDefault(require("./no-loss-of-precision"));
|
||||
const no_magic_numbers_1 = __importDefault(require("./no-magic-numbers"));
|
||||
const no_meaningless_void_operator_1 = __importDefault(require("./no-meaningless-void-operator"));
|
||||
const no_misused_new_1 = __importDefault(require("./no-misused-new"));
|
||||
const no_misused_promises_1 = __importDefault(require("./no-misused-promises"));
|
||||
const no_namespace_1 = __importDefault(require("./no-namespace"));
|
||||
const no_non_null_asserted_nullish_coalescing_1 = __importDefault(require("./no-non-null-asserted-nullish-coalescing"));
|
||||
const no_non_null_asserted_optional_chain_1 = __importDefault(require("./no-non-null-asserted-optional-chain"));
|
||||
const no_non_null_assertion_1 = __importDefault(require("./no-non-null-assertion"));
|
||||
const no_parameter_properties_1 = __importDefault(require("./no-parameter-properties"));
|
||||
const no_redeclare_1 = __importDefault(require("./no-redeclare"));
|
||||
const no_redundant_type_constituents_1 = __importDefault(require("./no-redundant-type-constituents"));
|
||||
const no_require_imports_1 = __importDefault(require("./no-require-imports"));
|
||||
const no_restricted_imports_1 = __importDefault(require("./no-restricted-imports"));
|
||||
const no_shadow_1 = __importDefault(require("./no-shadow"));
|
||||
const no_this_alias_1 = __importDefault(require("./no-this-alias"));
|
||||
const no_throw_literal_1 = __importDefault(require("./no-throw-literal"));
|
||||
const no_type_alias_1 = __importDefault(require("./no-type-alias"));
|
||||
const no_unnecessary_boolean_literal_compare_1 = __importDefault(require("./no-unnecessary-boolean-literal-compare"));
|
||||
const no_unnecessary_condition_1 = __importDefault(require("./no-unnecessary-condition"));
|
||||
const no_unnecessary_qualifier_1 = __importDefault(require("./no-unnecessary-qualifier"));
|
||||
const no_unnecessary_type_arguments_1 = __importDefault(require("./no-unnecessary-type-arguments"));
|
||||
const no_unnecessary_type_assertion_1 = __importDefault(require("./no-unnecessary-type-assertion"));
|
||||
const no_unnecessary_type_constraint_1 = __importDefault(require("./no-unnecessary-type-constraint"));
|
||||
const no_unsafe_argument_1 = __importDefault(require("./no-unsafe-argument"));
|
||||
const no_unsafe_assignment_1 = __importDefault(require("./no-unsafe-assignment"));
|
||||
const no_unsafe_call_1 = __importDefault(require("./no-unsafe-call"));
|
||||
const no_unsafe_member_access_1 = __importDefault(require("./no-unsafe-member-access"));
|
||||
const no_unsafe_return_1 = __importDefault(require("./no-unsafe-return"));
|
||||
const no_unused_expressions_1 = __importDefault(require("./no-unused-expressions"));
|
||||
const no_unused_vars_1 = __importDefault(require("./no-unused-vars"));
|
||||
const no_use_before_define_1 = __importDefault(require("./no-use-before-define"));
|
||||
const no_useless_constructor_1 = __importDefault(require("./no-useless-constructor"));
|
||||
const no_useless_empty_export_1 = __importDefault(require("./no-useless-empty-export"));
|
||||
const no_var_requires_1 = __importDefault(require("./no-var-requires"));
|
||||
const non_nullable_type_assertion_style_1 = __importDefault(require("./non-nullable-type-assertion-style"));
|
||||
const object_curly_spacing_1 = __importDefault(require("./object-curly-spacing"));
|
||||
const padding_line_between_statements_1 = __importDefault(require("./padding-line-between-statements"));
|
||||
const parameter_properties_1 = __importDefault(require("./parameter-properties"));
|
||||
const prefer_as_const_1 = __importDefault(require("./prefer-as-const"));
|
||||
const prefer_enum_initializers_1 = __importDefault(require("./prefer-enum-initializers"));
|
||||
const prefer_for_of_1 = __importDefault(require("./prefer-for-of"));
|
||||
const prefer_function_type_1 = __importDefault(require("./prefer-function-type"));
|
||||
const prefer_includes_1 = __importDefault(require("./prefer-includes"));
|
||||
const prefer_literal_enum_member_1 = __importDefault(require("./prefer-literal-enum-member"));
|
||||
const prefer_namespace_keyword_1 = __importDefault(require("./prefer-namespace-keyword"));
|
||||
const prefer_nullish_coalescing_1 = __importDefault(require("./prefer-nullish-coalescing"));
|
||||
const prefer_optional_chain_1 = __importDefault(require("./prefer-optional-chain"));
|
||||
const prefer_readonly_1 = __importDefault(require("./prefer-readonly"));
|
||||
const prefer_readonly_parameter_types_1 = __importDefault(require("./prefer-readonly-parameter-types"));
|
||||
const prefer_reduce_type_parameter_1 = __importDefault(require("./prefer-reduce-type-parameter"));
|
||||
const prefer_regexp_exec_1 = __importDefault(require("./prefer-regexp-exec"));
|
||||
const prefer_return_this_type_1 = __importDefault(require("./prefer-return-this-type"));
|
||||
const prefer_string_starts_ends_with_1 = __importDefault(require("./prefer-string-starts-ends-with"));
|
||||
const prefer_ts_expect_error_1 = __importDefault(require("./prefer-ts-expect-error"));
|
||||
const promise_function_async_1 = __importDefault(require("./promise-function-async"));
|
||||
const quotes_1 = __importDefault(require("./quotes"));
|
||||
const require_array_sort_compare_1 = __importDefault(require("./require-array-sort-compare"));
|
||||
const require_await_1 = __importDefault(require("./require-await"));
|
||||
const restrict_plus_operands_1 = __importDefault(require("./restrict-plus-operands"));
|
||||
const restrict_template_expressions_1 = __importDefault(require("./restrict-template-expressions"));
|
||||
const return_await_1 = __importDefault(require("./return-await"));
|
||||
const semi_1 = __importDefault(require("./semi"));
|
||||
const sort_type_union_intersection_members_1 = __importDefault(require("./sort-type-union-intersection-members"));
|
||||
const space_before_blocks_1 = __importDefault(require("./space-before-blocks"));
|
||||
const space_before_function_paren_1 = __importDefault(require("./space-before-function-paren"));
|
||||
const space_infix_ops_1 = __importDefault(require("./space-infix-ops"));
|
||||
const strict_boolean_expressions_1 = __importDefault(require("./strict-boolean-expressions"));
|
||||
const switch_exhaustiveness_check_1 = __importDefault(require("./switch-exhaustiveness-check"));
|
||||
const triple_slash_reference_1 = __importDefault(require("./triple-slash-reference"));
|
||||
const type_annotation_spacing_1 = __importDefault(require("./type-annotation-spacing"));
|
||||
const typedef_1 = __importDefault(require("./typedef"));
|
||||
const unbound_method_1 = __importDefault(require("./unbound-method"));
|
||||
const unified_signatures_1 = __importDefault(require("./unified-signatures"));
|
||||
exports.default = {
|
||||
'adjacent-overload-signatures': adjacent_overload_signatures_1.default,
|
||||
'array-type': array_type_1.default,
|
||||
'await-thenable': await_thenable_1.default,
|
||||
'ban-ts-comment': ban_ts_comment_1.default,
|
||||
'ban-tslint-comment': ban_tslint_comment_1.default,
|
||||
'ban-types': ban_types_1.default,
|
||||
'brace-style': brace_style_1.default,
|
||||
'class-literal-property-style': class_literal_property_style_1.default,
|
||||
'comma-dangle': comma_dangle_1.default,
|
||||
'comma-spacing': comma_spacing_1.default,
|
||||
'consistent-generic-constructors': consistent_generic_constructors_1.default,
|
||||
'consistent-indexed-object-style': consistent_indexed_object_style_1.default,
|
||||
'consistent-type-assertions': consistent_type_assertions_1.default,
|
||||
'consistent-type-definitions': consistent_type_definitions_1.default,
|
||||
'consistent-type-exports': consistent_type_exports_1.default,
|
||||
'consistent-type-imports': consistent_type_imports_1.default,
|
||||
'default-param-last': default_param_last_1.default,
|
||||
'dot-notation': dot_notation_1.default,
|
||||
'explicit-function-return-type': explicit_function_return_type_1.default,
|
||||
'explicit-member-accessibility': explicit_member_accessibility_1.default,
|
||||
'explicit-module-boundary-types': explicit_module_boundary_types_1.default,
|
||||
'func-call-spacing': func_call_spacing_1.default,
|
||||
indent: indent_1.default,
|
||||
'init-declarations': init_declarations_1.default,
|
||||
'keyword-spacing': keyword_spacing_1.default,
|
||||
'lines-between-class-members': lines_between_class_members_1.default,
|
||||
'member-delimiter-style': member_delimiter_style_1.default,
|
||||
'member-ordering': member_ordering_1.default,
|
||||
'method-signature-style': method_signature_style_1.default,
|
||||
'naming-convention': naming_convention_1.default,
|
||||
'no-array-constructor': no_array_constructor_1.default,
|
||||
'no-base-to-string': no_base_to_string_1.default,
|
||||
'no-confusing-non-null-assertion': no_confusing_non_null_assertion_1.default,
|
||||
'no-confusing-void-expression': no_confusing_void_expression_1.default,
|
||||
'no-dupe-class-members': no_dupe_class_members_1.default,
|
||||
'no-duplicate-enum-values': no_duplicate_enum_values_1.default,
|
||||
'no-duplicate-imports': no_duplicate_imports_1.default,
|
||||
'no-dynamic-delete': no_dynamic_delete_1.default,
|
||||
'no-empty-function': no_empty_function_1.default,
|
||||
'no-empty-interface': no_empty_interface_1.default,
|
||||
'no-explicit-any': no_explicit_any_1.default,
|
||||
'no-extra-non-null-assertion': no_extra_non_null_assertion_1.default,
|
||||
'no-extra-parens': no_extra_parens_1.default,
|
||||
'no-extra-semi': no_extra_semi_1.default,
|
||||
'no-extraneous-class': no_extraneous_class_1.default,
|
||||
'no-floating-promises': no_floating_promises_1.default,
|
||||
'no-for-in-array': no_for_in_array_1.default,
|
||||
'no-implicit-any-catch': no_implicit_any_catch_1.default,
|
||||
'no-implied-eval': no_implied_eval_1.default,
|
||||
'no-inferrable-types': no_inferrable_types_1.default,
|
||||
'no-invalid-this': no_invalid_this_1.default,
|
||||
'no-invalid-void-type': no_invalid_void_type_1.default,
|
||||
'no-loop-func': no_loop_func_1.default,
|
||||
'no-loss-of-precision': no_loss_of_precision_1.default,
|
||||
'no-magic-numbers': no_magic_numbers_1.default,
|
||||
'no-meaningless-void-operator': no_meaningless_void_operator_1.default,
|
||||
'no-misused-new': no_misused_new_1.default,
|
||||
'no-misused-promises': no_misused_promises_1.default,
|
||||
'no-namespace': no_namespace_1.default,
|
||||
'no-non-null-asserted-nullish-coalescing': no_non_null_asserted_nullish_coalescing_1.default,
|
||||
'no-non-null-asserted-optional-chain': no_non_null_asserted_optional_chain_1.default,
|
||||
'no-non-null-assertion': no_non_null_assertion_1.default,
|
||||
'no-parameter-properties': no_parameter_properties_1.default,
|
||||
'no-redeclare': no_redeclare_1.default,
|
||||
'no-redundant-type-constituents': no_redundant_type_constituents_1.default,
|
||||
'no-require-imports': no_require_imports_1.default,
|
||||
'no-restricted-imports': no_restricted_imports_1.default,
|
||||
'no-shadow': no_shadow_1.default,
|
||||
'no-this-alias': no_this_alias_1.default,
|
||||
'no-throw-literal': no_throw_literal_1.default,
|
||||
'no-type-alias': no_type_alias_1.default,
|
||||
'no-unnecessary-boolean-literal-compare': no_unnecessary_boolean_literal_compare_1.default,
|
||||
'no-unnecessary-condition': no_unnecessary_condition_1.default,
|
||||
'no-unnecessary-qualifier': no_unnecessary_qualifier_1.default,
|
||||
'no-unnecessary-type-arguments': no_unnecessary_type_arguments_1.default,
|
||||
'no-unnecessary-type-assertion': no_unnecessary_type_assertion_1.default,
|
||||
'no-unnecessary-type-constraint': no_unnecessary_type_constraint_1.default,
|
||||
'no-unsafe-argument': no_unsafe_argument_1.default,
|
||||
'no-unsafe-assignment': no_unsafe_assignment_1.default,
|
||||
'no-unsafe-call': no_unsafe_call_1.default,
|
||||
'no-unsafe-member-access': no_unsafe_member_access_1.default,
|
||||
'no-unsafe-return': no_unsafe_return_1.default,
|
||||
'no-unused-expressions': no_unused_expressions_1.default,
|
||||
'no-unused-vars': no_unused_vars_1.default,
|
||||
'no-use-before-define': no_use_before_define_1.default,
|
||||
'no-useless-constructor': no_useless_constructor_1.default,
|
||||
'no-useless-empty-export': no_useless_empty_export_1.default,
|
||||
'no-var-requires': no_var_requires_1.default,
|
||||
'non-nullable-type-assertion-style': non_nullable_type_assertion_style_1.default,
|
||||
'object-curly-spacing': object_curly_spacing_1.default,
|
||||
'padding-line-between-statements': padding_line_between_statements_1.default,
|
||||
'parameter-properties': parameter_properties_1.default,
|
||||
'prefer-as-const': prefer_as_const_1.default,
|
||||
'prefer-enum-initializers': prefer_enum_initializers_1.default,
|
||||
'prefer-for-of': prefer_for_of_1.default,
|
||||
'prefer-function-type': prefer_function_type_1.default,
|
||||
'prefer-includes': prefer_includes_1.default,
|
||||
'prefer-literal-enum-member': prefer_literal_enum_member_1.default,
|
||||
'prefer-namespace-keyword': prefer_namespace_keyword_1.default,
|
||||
'prefer-nullish-coalescing': prefer_nullish_coalescing_1.default,
|
||||
'prefer-optional-chain': prefer_optional_chain_1.default,
|
||||
'prefer-readonly': prefer_readonly_1.default,
|
||||
'prefer-readonly-parameter-types': prefer_readonly_parameter_types_1.default,
|
||||
'prefer-reduce-type-parameter': prefer_reduce_type_parameter_1.default,
|
||||
'prefer-regexp-exec': prefer_regexp_exec_1.default,
|
||||
'prefer-return-this-type': prefer_return_this_type_1.default,
|
||||
'prefer-string-starts-ends-with': prefer_string_starts_ends_with_1.default,
|
||||
'prefer-ts-expect-error': prefer_ts_expect_error_1.default,
|
||||
'promise-function-async': promise_function_async_1.default,
|
||||
quotes: quotes_1.default,
|
||||
'require-array-sort-compare': require_array_sort_compare_1.default,
|
||||
'require-await': require_await_1.default,
|
||||
'restrict-plus-operands': restrict_plus_operands_1.default,
|
||||
'restrict-template-expressions': restrict_template_expressions_1.default,
|
||||
'return-await': return_await_1.default,
|
||||
semi: semi_1.default,
|
||||
'sort-type-union-intersection-members': sort_type_union_intersection_members_1.default,
|
||||
'space-before-blocks': space_before_blocks_1.default,
|
||||
'space-before-function-paren': space_before_function_paren_1.default,
|
||||
'space-infix-ops': space_infix_ops_1.default,
|
||||
'strict-boolean-expressions': strict_boolean_expressions_1.default,
|
||||
'switch-exhaustiveness-check': switch_exhaustiveness_check_1.default,
|
||||
'triple-slash-reference': triple_slash_reference_1.default,
|
||||
'type-annotation-spacing': type_annotation_spacing_1.default,
|
||||
typedef: typedef_1.default,
|
||||
'unbound-method': unbound_method_1.default,
|
||||
'unified-signatures': unified_signatures_1.default,
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;;;AAAA,kGAAwE;AACxE,8DAAqC;AACrC,sEAA6C;AAC7C,sEAA4C;AAC5C,8EAAoD;AACpD,4DAAmC;AACnC,gEAAuC;AACvC,kGAAuE;AACvE,kEAAyC;AACzC,oEAA2C;AAC3C,wGAA8E;AAC9E,wGAA6E;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,EAAE,uBAAY;IAC7B,wBAAwB,EAAE,gCAAoB;IAC9C,+BAA+B,EAAE,uCAA2B;IAC5D,cAAc,EAAE,sBAAW;IAC3B,IAAI,EAAE,cAAI;IACV,sCAAsC,EAAE,8CAAgC;IACxE,qBAAqB,EAAE,6BAAiB;IACxC,6BAA6B,EAAE,qCAAwB;IACvD,iBAAiB,EAAE,yBAAa;IAChC,4BAA4B,EAAE,oCAAwB;IACtD,6BAA6B,EAAE,qCAAyB;IACxD,wBAAwB,EAAE,gCAAoB;IAC9C,yBAAyB,EAAE,iCAAqB;IAChD,OAAO,EAAE,iBAAO;IAChB,gBAAgB,EAAE,wBAAa;IAC/B,oBAAoB,EAAE,4BAAiB;CACxC,CAAC"}
|
||||
49
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js
generated
vendored
Normal file
49
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const util_1 = require("../util");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('init-declarations');
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'init-declarations',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require or disallow initialization in variable declarations',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: ['always'],
|
||||
create(context, [mode]) {
|
||||
const rules = baseRule.create(context);
|
||||
return {
|
||||
'VariableDeclaration:exit'(node) {
|
||||
if (mode === 'always') {
|
||||
if (node.declare) {
|
||||
return;
|
||||
}
|
||||
if (isAncestorNamespaceDeclared(node)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
rules['VariableDeclaration:exit'](node);
|
||||
},
|
||||
};
|
||||
function isAncestorNamespaceDeclared(node) {
|
||||
let ancestor = node.parent;
|
||||
while (ancestor) {
|
||||
if (ancestor.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
|
||||
ancestor.declare) {
|
||||
return true;
|
||||
}
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=init-declarations.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"init-declarations.js","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":";;AAAA,oDAAoE;AACpE,iEAA8D;AAC9D,kCAIiB;AAEjB,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,mBAAmB,CAAC,CAAC;AAKxD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,6DAA6D;YAC/D,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO;YACL,0BAA0B,CAAC,IAAkC;gBAC3D,IAAI,IAAI,KAAK,QAAQ,EAAE;oBACrB,IAAI,IAAI,CAAC,OAAO,EAAE;wBAChB,OAAO;qBACR;oBACD,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE;wBACrC,OAAO;qBACR;iBACF;gBAED,KAAK,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC;QAEF,SAAS,2BAA2B,CAClC,IAAkC;YAElC,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;YAE3B,OAAO,QAAQ,EAAE;gBACf,IACE,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;oBACpD,QAAQ,CAAC,OAAO,EAChB;oBACA,OAAO,IAAI,CAAC;iBACb;gBAED,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;aAC5B;YAED,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
||||
63
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js
generated
vendored
Normal file
63
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const util = __importStar(require("../util"));
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('keyword-spacing');
|
||||
exports.default = util.createRule({
|
||||
name: 'keyword-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent spacing before and after keywords',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [{}],
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const baseRules = baseRule.create(context);
|
||||
return Object.assign(Object.assign({}, baseRules), { TSAsExpression(node) {
|
||||
const asToken = util.nullThrows(sourceCode.getTokenAfter(node.expression, token => token.value === 'as'), util.NullThrowsReasons.MissingToken('as', node.type));
|
||||
const oldTokenType = asToken.type;
|
||||
// as is a contextual keyword, so it's always reported as an Identifier
|
||||
// the rule looks for keyword tokens, so we temporarily override it
|
||||
// we mutate it at the token level because the rule calls sourceCode.getFirstToken,
|
||||
// so mutating a copy would not change the underlying copy returned by that method
|
||||
asToken.type = utils_1.AST_TOKEN_TYPES.Keyword;
|
||||
// use this selector just because it is just a call to `checkSpacingAroundFirstToken`
|
||||
baseRules.DebuggerStatement(asToken);
|
||||
// make sure to reset the type afterward so we don't permanently mutate the AST
|
||||
asToken.type = oldTokenType;
|
||||
} });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=keyword-spacing.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"keyword-spacing.js","sourceRoot":"","sources":["../../src/rules/keyword-spacing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2D;AAC3D,iEAA8D;AAC9D,8CAAgC;AAEhC,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,iBAAiB,CAAC,CAAC;AAKtD,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,sDAAsD;YACnE,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,EAAE,CAAC;IAEpB,MAAM,CAAC,OAAO;QACZ,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3C,uCACK,SAAS,KACZ,cAAc,CAAC,IAAI;gBACjB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAC7B,UAAU,CAAC,aAAa,CACtB,IAAI,CAAC,UAAU,EACf,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAC9B,EACD,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CACrD,CAAC;gBACF,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;gBAClC,uEAAuE;gBACvE,mEAAmE;gBACnE,mFAAmF;gBACnF,kFAAkF;gBAClF,OAAO,CAAC,IAAI,GAAG,uBAAe,CAAC,OAAO,CAAC;gBAEvC,qFAAqF;gBACrF,SAAS,CAAC,iBAAiB,CAAC,OAAgB,CAAC,CAAC;gBAE9C,+EAA+E;gBAC/E,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;YAC9B,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
77
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js
generated
vendored
Normal file
77
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const util = __importStar(require("../util"));
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('lines-between-class-members');
|
||||
const schema = util.deepMerge(Object.assign({}, baseRule.meta.schema), {
|
||||
1: {
|
||||
exceptAfterOverload: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
exports.default = util.createRule({
|
||||
name: 'lines-between-class-members',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require or disallow an empty line between class members',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [
|
||||
'always',
|
||||
{
|
||||
exceptAfterOverload: true,
|
||||
exceptAfterSingleLine: false,
|
||||
},
|
||||
],
|
||||
create(context, [firstOption, secondOption]) {
|
||||
const rules = baseRule.create(context);
|
||||
const exceptAfterOverload = (secondOption === null || secondOption === void 0 ? void 0 : secondOption.exceptAfterOverload) && firstOption === 'always';
|
||||
function isOverload(node) {
|
||||
return ((node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
|
||||
node.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
|
||||
node.value.type === utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression);
|
||||
}
|
||||
return {
|
||||
ClassBody(node) {
|
||||
const body = exceptAfterOverload
|
||||
? node.body.filter(node => !isOverload(node))
|
||||
: node.body;
|
||||
rules.ClassBody(Object.assign(Object.assign({}, node), { body }));
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=lines-between-class-members.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"lines-between-class-members.js","sourceRoot":"","sources":["../../src/rules/lines-between-class-members.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,iEAA8D;AAC9D,8CAAgC;AAEhC,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,6BAA6B,CAAC,CAAC;AAKlE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,mBACtB,QAAQ,CAAC,IAAI,CAAC,MAAM,GACzB;IACE,CAAC,EAAE;QACD,mBAAmB,EAAE;YACnB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;KACF;CACF,CACF,CAAC;AAEF,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,yDAAyD;YACtE,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM;QACN,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE;QACd,QAAQ;QACR;YACE,mBAAmB,EAAE,IAAI;YACzB,qBAAqB,EAAE,KAAK;SAC7B;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;QACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,mBAAmB,GACvB,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,mBAAmB,KAAI,WAAW,KAAK,QAAQ,CAAC;QAEhE,SAAS,UAAU,CAAC,IAAmB;YACrC,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,0BAA0B;gBACtD,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB,CAAC;gBAChD,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAc,CAAC,6BAA6B,CACjE,CAAC;QACJ,CAAC;QAED,OAAO;YACL,SAAS,CAAC,IAAI;gBACZ,MAAM,IAAI,GAAG,mBAAmB;oBAC9B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBAC7C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAEd,KAAK,CAAC,SAAS,iCAAM,IAAI,KAAE,IAAI,IAAG,CAAC;YACrC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
261
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js
generated
vendored
Normal file
261
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const definition = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
multiline: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
delimiter: { enum: ['none', 'semi', 'comma'] },
|
||||
requireLast: { type: 'boolean' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
singleline: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
// note can't have "none" for single line delimiter as it's invalid syntax
|
||||
delimiter: { enum: ['semi', 'comma'] },
|
||||
requireLast: { type: 'boolean' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
const isLastTokenEndOfLine = (token, line) => {
|
||||
const positionInLine = token.loc.start.column;
|
||||
return positionInLine === line.length - 1;
|
||||
};
|
||||
const isCommentsEndOfLine = (token, comments, line) => {
|
||||
if (!comments) {
|
||||
return false;
|
||||
}
|
||||
if (comments.loc.end.line > token.loc.end.line) {
|
||||
return true;
|
||||
}
|
||||
const positionInLine = comments.loc.end.column;
|
||||
return positionInLine === line.length;
|
||||
};
|
||||
const makeFixFunction = ({ optsNone, optsSemi, lastToken, commentsAfterLastToken, missingDelimiter, lastTokenLine, isSingleLine, }) => {
|
||||
// if removing is the action but last token is not the end of the line
|
||||
if (optsNone &&
|
||||
!isLastTokenEndOfLine(lastToken, lastTokenLine) &&
|
||||
!isCommentsEndOfLine(lastToken, commentsAfterLastToken, lastTokenLine) &&
|
||||
!isSingleLine) {
|
||||
return null;
|
||||
}
|
||||
return (fixer) => {
|
||||
if (optsNone) {
|
||||
// remove the unneeded token
|
||||
return fixer.remove(lastToken);
|
||||
}
|
||||
const token = optsSemi ? ';' : ',';
|
||||
if (missingDelimiter) {
|
||||
// add the missing delimiter
|
||||
return fixer.insertTextAfter(lastToken, token);
|
||||
}
|
||||
// correct the current delimiter
|
||||
return fixer.replaceText(lastToken, token);
|
||||
};
|
||||
};
|
||||
exports.default = util.createRule({
|
||||
name: 'member-delimiter-style',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require a specific member delimiter style for interfaces and type literals',
|
||||
recommended: false,
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
unexpectedComma: 'Unexpected separator (,).',
|
||||
unexpectedSemi: 'Unexpected separator (;).',
|
||||
expectedComma: 'Expected a comma.',
|
||||
expectedSemi: 'Expected a semicolon.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: Object.assign({}, definition.properties, {
|
||||
overrides: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
interface: definition,
|
||||
typeLiteral: definition,
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
multilineDetection: {
|
||||
enum: ['brackets', 'last-member'],
|
||||
},
|
||||
}),
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
multiline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: true,
|
||||
},
|
||||
singleline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: false,
|
||||
},
|
||||
multilineDetection: 'brackets',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
var _a;
|
||||
const sourceCode = context.getSourceCode();
|
||||
// use the base options as the defaults for the cases
|
||||
const baseOptions = options;
|
||||
const overrides = (_a = baseOptions.overrides) !== null && _a !== void 0 ? _a : {};
|
||||
const interfaceOptions = util.deepMerge(baseOptions, overrides.interface);
|
||||
const typeLiteralOptions = util.deepMerge(baseOptions, overrides.typeLiteral);
|
||||
/**
|
||||
* Check the last token in the given member.
|
||||
* @param member the member to be evaluated.
|
||||
* @param opts the options to be validated.
|
||||
* @param isLast a flag indicating `member` is the last in the interface or type literal.
|
||||
*/
|
||||
function checkLastToken(member, opts, isLast) {
|
||||
/**
|
||||
* Resolves the boolean value for the given setting enum value
|
||||
* @param type the option name
|
||||
*/
|
||||
function getOption(type) {
|
||||
if (isLast && !opts.requireLast) {
|
||||
// only turn the option on if its expecting no delimiter for the last member
|
||||
return type === 'none';
|
||||
}
|
||||
return opts.delimiter === type;
|
||||
}
|
||||
let messageId = null;
|
||||
let missingDelimiter = false;
|
||||
const lastToken = sourceCode.getLastToken(member, {
|
||||
includeComments: false,
|
||||
});
|
||||
if (!lastToken) {
|
||||
return;
|
||||
}
|
||||
const commentsAfterLastToken = sourceCode
|
||||
.getCommentsAfter(lastToken)
|
||||
.pop();
|
||||
const sourceCodeLines = sourceCode.getLines();
|
||||
const lastTokenLine = sourceCodeLines[(lastToken === null || lastToken === void 0 ? void 0 : lastToken.loc.start.line) - 1];
|
||||
const optsSemi = getOption('semi');
|
||||
const optsComma = getOption('comma');
|
||||
const optsNone = getOption('none');
|
||||
if (lastToken.value === ';') {
|
||||
if (optsComma) {
|
||||
messageId = 'expectedComma';
|
||||
}
|
||||
else if (optsNone) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'unexpectedSemi';
|
||||
}
|
||||
}
|
||||
else if (lastToken.value === ',') {
|
||||
if (optsSemi) {
|
||||
messageId = 'expectedSemi';
|
||||
}
|
||||
else if (optsNone) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'unexpectedComma';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (optsSemi) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'expectedSemi';
|
||||
}
|
||||
else if (optsComma) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'expectedComma';
|
||||
}
|
||||
}
|
||||
if (messageId) {
|
||||
context.report({
|
||||
node: lastToken,
|
||||
loc: {
|
||||
start: {
|
||||
line: lastToken.loc.end.line,
|
||||
column: lastToken.loc.end.column,
|
||||
},
|
||||
end: {
|
||||
line: lastToken.loc.end.line,
|
||||
column: lastToken.loc.end.column,
|
||||
},
|
||||
},
|
||||
messageId,
|
||||
fix: makeFixFunction({
|
||||
optsNone,
|
||||
optsSemi,
|
||||
lastToken,
|
||||
commentsAfterLastToken,
|
||||
missingDelimiter,
|
||||
lastTokenLine,
|
||||
isSingleLine: opts.type === 'single-line',
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the member separator being used matches the delimiter.
|
||||
* @param {ASTNode} node the node to be evaluated.
|
||||
*/
|
||||
function checkMemberSeparatorStyle(node) {
|
||||
const members = node.type === utils_1.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
||||
let isSingleLine = node.loc.start.line === node.loc.end.line;
|
||||
if (options.multilineDetection === 'last-member' &&
|
||||
!isSingleLine &&
|
||||
members.length > 0) {
|
||||
const lastMember = members[members.length - 1];
|
||||
if (lastMember.loc.end.line === node.loc.end.line) {
|
||||
isSingleLine = true;
|
||||
}
|
||||
}
|
||||
const typeOpts = node.type === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
||||
? interfaceOptions
|
||||
: typeLiteralOptions;
|
||||
const opts = isSingleLine
|
||||
? Object.assign(Object.assign({}, typeOpts.singleline), { type: 'single-line' }) : Object.assign(Object.assign({}, typeOpts.multiline), { type: 'multi-line' });
|
||||
members.forEach((member, index) => {
|
||||
checkLastToken(member, opts !== null && opts !== void 0 ? opts : {}, index === members.length - 1);
|
||||
});
|
||||
}
|
||||
return {
|
||||
TSInterfaceBody: checkMemberSeparatorStyle,
|
||||
TSTypeLiteral: checkMemberSeparatorStyle,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=member-delimiter-style.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
563
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js
generated
vendored
Normal file
563
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js
generated
vendored
Normal file
@@ -0,0 +1,563 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultOrder = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const neverConfig = {
|
||||
type: 'string',
|
||||
enum: ['never'],
|
||||
};
|
||||
const arrayConfig = (memberTypes) => ({
|
||||
type: 'array',
|
||||
items: {
|
||||
oneOf: [
|
||||
{
|
||||
enum: memberTypes,
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
enum: memberTypes,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const objectConfig = (memberTypes) => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
memberTypes: {
|
||||
oneOf: [arrayConfig(memberTypes), neverConfig],
|
||||
},
|
||||
order: {
|
||||
type: 'string',
|
||||
enum: ['alphabetically', 'alphabetically-case-insensitive', 'as-written'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
});
|
||||
exports.defaultOrder = [
|
||||
// Index signature
|
||||
'signature',
|
||||
'call-signature',
|
||||
// Fields
|
||||
'public-static-field',
|
||||
'protected-static-field',
|
||||
'private-static-field',
|
||||
'public-decorated-field',
|
||||
'protected-decorated-field',
|
||||
'private-decorated-field',
|
||||
'public-instance-field',
|
||||
'protected-instance-field',
|
||||
'private-instance-field',
|
||||
'public-abstract-field',
|
||||
'protected-abstract-field',
|
||||
'private-abstract-field',
|
||||
'public-field',
|
||||
'protected-field',
|
||||
'private-field',
|
||||
'static-field',
|
||||
'instance-field',
|
||||
'abstract-field',
|
||||
'decorated-field',
|
||||
'field',
|
||||
// Constructors
|
||||
'public-constructor',
|
||||
'protected-constructor',
|
||||
'private-constructor',
|
||||
'constructor',
|
||||
// Getters
|
||||
'public-static-get',
|
||||
'protected-static-get',
|
||||
'private-static-get',
|
||||
'public-decorated-get',
|
||||
'protected-decorated-get',
|
||||
'private-decorated-get',
|
||||
'public-instance-get',
|
||||
'protected-instance-get',
|
||||
'private-instance-get',
|
||||
'public-abstract-get',
|
||||
'protected-abstract-get',
|
||||
'private-abstract-get',
|
||||
'public-get',
|
||||
'protected-get',
|
||||
'private-get',
|
||||
'static-get',
|
||||
'instance-get',
|
||||
'abstract-get',
|
||||
'decorated-get',
|
||||
'get',
|
||||
// Setters
|
||||
'public-static-set',
|
||||
'protected-static-set',
|
||||
'private-static-set',
|
||||
'public-decorated-set',
|
||||
'protected-decorated-set',
|
||||
'private-decorated-set',
|
||||
'public-instance-set',
|
||||
'protected-instance-set',
|
||||
'private-instance-set',
|
||||
'public-abstract-set',
|
||||
'protected-abstract-set',
|
||||
'private-abstract-set',
|
||||
'public-set',
|
||||
'protected-set',
|
||||
'private-set',
|
||||
'static-set',
|
||||
'instance-set',
|
||||
'abstract-set',
|
||||
'decorated-set',
|
||||
'set',
|
||||
// Methods
|
||||
'public-static-method',
|
||||
'protected-static-method',
|
||||
'private-static-method',
|
||||
'public-decorated-method',
|
||||
'protected-decorated-method',
|
||||
'private-decorated-method',
|
||||
'public-instance-method',
|
||||
'protected-instance-method',
|
||||
'private-instance-method',
|
||||
'public-abstract-method',
|
||||
'protected-abstract-method',
|
||||
'private-abstract-method',
|
||||
'public-method',
|
||||
'protected-method',
|
||||
'private-method',
|
||||
'static-method',
|
||||
'instance-method',
|
||||
'abstract-method',
|
||||
'decorated-method',
|
||||
'method',
|
||||
];
|
||||
const allMemberTypes = Array.from([
|
||||
'signature',
|
||||
'field',
|
||||
'method',
|
||||
'call-signature',
|
||||
'constructor',
|
||||
'get',
|
||||
'set',
|
||||
].reduce((all, type) => {
|
||||
all.add(type);
|
||||
['public', 'protected', 'private'].forEach(accessibility => {
|
||||
if (type !== 'signature') {
|
||||
all.add(`${accessibility}-${type}`); // e.g. `public-field`
|
||||
}
|
||||
// Only class instance fields, methods, get and set can have decorators attached to them
|
||||
if (type === 'field' ||
|
||||
type === 'method' ||
|
||||
type === 'get' ||
|
||||
type === 'set') {
|
||||
all.add(`${accessibility}-decorated-${type}`);
|
||||
all.add(`decorated-${type}`);
|
||||
}
|
||||
if (type !== 'constructor' && type !== 'signature') {
|
||||
// There is no `static-constructor` or `instance-constructor` or `abstract-constructor`
|
||||
['static', 'instance', 'abstract'].forEach(scope => {
|
||||
all.add(`${scope}-${type}`);
|
||||
all.add(`${accessibility}-${scope}-${type}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
return all;
|
||||
}, new Set()));
|
||||
const functionExpressions = [
|
||||
utils_1.AST_NODE_TYPES.FunctionExpression,
|
||||
utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
|
||||
];
|
||||
/**
|
||||
* Gets the node type.
|
||||
*
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function getNodeType(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return node.kind;
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
return 'method';
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return 'call-signature';
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return 'constructor';
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
||||
return 'field';
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
return node.value && functionExpressions.includes(node.value.type)
|
||||
? 'method'
|
||||
: 'field';
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
return 'field';
|
||||
case utils_1.AST_NODE_TYPES.TSIndexSignature:
|
||||
return 'signature';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the raw string value of a member's name
|
||||
*/
|
||||
function getMemberRawName(member, sourceCode) {
|
||||
const { name, type } = util.getNameFromMember(member, sourceCode);
|
||||
if (type === util.MemberNameType.Quoted) {
|
||||
return name.slice(1, -1);
|
||||
}
|
||||
if (type === util.MemberNameType.Private) {
|
||||
return name.slice(1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Gets the member name based on the member type.
|
||||
*
|
||||
* @param node the node to be evaluated.
|
||||
* @param sourceCode
|
||||
*/
|
||||
function getMemberName(node, sourceCode) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
return getMemberRawName(node, sourceCode);
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return node.kind === 'constructor'
|
||||
? 'constructor'
|
||||
: getMemberRawName(node, sourceCode);
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return 'new';
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return 'call';
|
||||
case utils_1.AST_NODE_TYPES.TSIndexSignature:
|
||||
return util.getNameFromIndexSignature(node);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the calculated rank using the provided method definition.
|
||||
* The algorithm is as follows:
|
||||
* - Get the rank based on the accessibility-scope-type name, e.g. public-instance-field
|
||||
* - If there is no order for accessibility-scope-type, then strip out the accessibility.
|
||||
* - If there is no order for scope-type, then strip out the scope.
|
||||
* - If there is no order for type, then return -1
|
||||
* @param memberGroups the valid names to be validated.
|
||||
* @param orderConfig the current order to be validated.
|
||||
*
|
||||
* @return Index of the matching member type in the order configuration.
|
||||
*/
|
||||
function getRankOrder(memberGroups, orderConfig) {
|
||||
let rank = -1;
|
||||
const stack = memberGroups.slice(); // Get a copy of the member groups
|
||||
while (stack.length > 0 && rank === -1) {
|
||||
const memberGroup = stack.shift();
|
||||
rank = orderConfig.findIndex(memberType => Array.isArray(memberType)
|
||||
? memberType.includes(memberGroup)
|
||||
: memberType === memberGroup);
|
||||
}
|
||||
return rank;
|
||||
}
|
||||
/**
|
||||
* Gets the rank of the node given the order.
|
||||
* @param node the node to be evaluated.
|
||||
* @param orderConfig the current order to be validated.
|
||||
* @param supportsModifiers a flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*/
|
||||
function getRank(node, orderConfig, supportsModifiers) {
|
||||
const type = getNodeType(node);
|
||||
if (type === null) {
|
||||
// shouldn't happen but just in case, put it on the end
|
||||
return orderConfig.length - 1;
|
||||
}
|
||||
const abstract = node.type === utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition ||
|
||||
node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition;
|
||||
const scope = 'static' in node && node.static
|
||||
? 'static'
|
||||
: abstract
|
||||
? 'abstract'
|
||||
: 'instance';
|
||||
const accessibility = 'accessibility' in node && node.accessibility
|
||||
? node.accessibility
|
||||
: 'public';
|
||||
// Collect all existing member groups that apply to this node...
|
||||
// (e.g. 'public-instance-field', 'instance-field', 'public-field', 'constructor' etc.)
|
||||
const memberGroups = [];
|
||||
if (supportsModifiers) {
|
||||
const decorated = 'decorators' in node && node.decorators.length > 0;
|
||||
if (decorated &&
|
||||
(type === 'field' ||
|
||||
type === 'method' ||
|
||||
type === 'get' ||
|
||||
type === 'set')) {
|
||||
memberGroups.push(`${accessibility}-decorated-${type}`);
|
||||
memberGroups.push(`decorated-${type}`);
|
||||
}
|
||||
if (type !== 'signature') {
|
||||
if (type !== 'constructor') {
|
||||
// Constructors have no scope
|
||||
memberGroups.push(`${accessibility}-${scope}-${type}`);
|
||||
memberGroups.push(`${scope}-${type}`);
|
||||
}
|
||||
memberGroups.push(`${accessibility}-${type}`);
|
||||
}
|
||||
}
|
||||
memberGroups.push(type);
|
||||
// ...then get the rank order for those member groups based on the node
|
||||
return getRankOrder(memberGroups, orderConfig);
|
||||
}
|
||||
/**
|
||||
* Gets the lowest possible rank(s) higher than target.
|
||||
* e.g. given the following order:
|
||||
* ...
|
||||
* public-static-method
|
||||
* protected-static-method
|
||||
* private-static-method
|
||||
* public-instance-method
|
||||
* protected-instance-method
|
||||
* private-instance-method
|
||||
* ...
|
||||
* and considering that a public-instance-method has already been declared, so ranks contains
|
||||
* public-instance-method, then the lowest possible rank for public-static-method is
|
||||
* public-instance-method.
|
||||
* If a lowest possible rank is a member group, a comma separated list of ranks is returned.
|
||||
* @param ranks the existing ranks in the object.
|
||||
* @param target the target rank.
|
||||
* @param order the current order to be validated.
|
||||
* @returns the name(s) of the lowest possible rank without dashes (-).
|
||||
*/
|
||||
function getLowestRank(ranks, target, order) {
|
||||
let lowest = ranks[ranks.length - 1];
|
||||
ranks.forEach(rank => {
|
||||
if (rank > target) {
|
||||
lowest = Math.min(lowest, rank);
|
||||
}
|
||||
});
|
||||
const lowestRank = order[lowest];
|
||||
const lowestRanks = Array.isArray(lowestRank) ? lowestRank : [lowestRank];
|
||||
return lowestRanks.map(rank => rank.replace(/-/g, ' ')).join(', ');
|
||||
}
|
||||
exports.default = util.createRule({
|
||||
name: 'member-ordering',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require a consistent member declaration order',
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
incorrectOrder: 'Member {{member}} should be declared before member {{beforeMember}}.',
|
||||
incorrectGroupOrder: 'Member {{name}} should be declared before all {{rank}} definitions.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
default: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(allMemberTypes),
|
||||
objectConfig(allMemberTypes),
|
||||
],
|
||||
},
|
||||
classes: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(allMemberTypes),
|
||||
objectConfig(allMemberTypes),
|
||||
],
|
||||
},
|
||||
classExpressions: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(allMemberTypes),
|
||||
objectConfig(allMemberTypes),
|
||||
],
|
||||
},
|
||||
interfaces: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(['signature', 'field', 'method', 'constructor']),
|
||||
objectConfig(['signature', 'field', 'method', 'constructor']),
|
||||
],
|
||||
},
|
||||
typeLiterals: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(['signature', 'field', 'method', 'constructor']),
|
||||
objectConfig(['signature', 'field', 'method', 'constructor']),
|
||||
],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
default: exports.defaultOrder,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
/**
|
||||
* Checks if the member groups are correctly sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param groupOrder Group order to be validated.
|
||||
* @param supportsModifiers A flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*
|
||||
* @return Array of member groups or null if one of the groups is not correctly sorted.
|
||||
*/
|
||||
function checkGroupSort(members, groupOrder, supportsModifiers) {
|
||||
const previousRanks = [];
|
||||
const memberGroups = [];
|
||||
let isCorrectlySorted = true;
|
||||
// Find first member which isn't correctly sorted
|
||||
members.forEach(member => {
|
||||
const rank = getRank(member, groupOrder, supportsModifiers);
|
||||
const name = getMemberName(member, context.getSourceCode());
|
||||
const rankLastMember = previousRanks[previousRanks.length - 1];
|
||||
if (rank === -1) {
|
||||
return;
|
||||
}
|
||||
// Works for 1st item because x < undefined === false for any x (typeof string)
|
||||
if (rank < rankLastMember) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'incorrectGroupOrder',
|
||||
data: {
|
||||
name,
|
||||
rank: getLowestRank(previousRanks, rank, groupOrder),
|
||||
},
|
||||
});
|
||||
isCorrectlySorted = false;
|
||||
}
|
||||
else if (rank === rankLastMember) {
|
||||
// Same member group --> Push to existing member group array
|
||||
memberGroups[memberGroups.length - 1].push(member);
|
||||
}
|
||||
else {
|
||||
// New member group --> Create new member group array
|
||||
previousRanks.push(rank);
|
||||
memberGroups.push([member]);
|
||||
}
|
||||
});
|
||||
return isCorrectlySorted ? memberGroups : null;
|
||||
}
|
||||
/**
|
||||
* Checks if the members are alphabetically sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param caseSensitive indicates if the alpha ordering is case sensitive or not.
|
||||
*
|
||||
* @return True if all members are correctly sorted.
|
||||
*/
|
||||
function checkAlphaSort(members, caseSensitive) {
|
||||
let previousName = '';
|
||||
let isCorrectlySorted = true;
|
||||
// Find first member which isn't correctly sorted
|
||||
members.forEach(member => {
|
||||
const name = getMemberName(member, context.getSourceCode());
|
||||
// Note: Not all members have names
|
||||
if (name) {
|
||||
if (caseSensitive
|
||||
? name < previousName
|
||||
: name.toLowerCase() < previousName.toLowerCase()) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'incorrectOrder',
|
||||
data: {
|
||||
member: name,
|
||||
beforeMember: previousName,
|
||||
},
|
||||
});
|
||||
isCorrectlySorted = false;
|
||||
}
|
||||
previousName = name;
|
||||
}
|
||||
});
|
||||
return isCorrectlySorted;
|
||||
}
|
||||
/**
|
||||
* Validates if all members are correctly sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param orderConfig Order config to be validated.
|
||||
* @param supportsModifiers A flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*/
|
||||
function validateMembersOrder(members, orderConfig, supportsModifiers) {
|
||||
if (orderConfig === 'never') {
|
||||
return;
|
||||
}
|
||||
// Standardize config
|
||||
let order = null;
|
||||
let memberTypes;
|
||||
if (Array.isArray(orderConfig)) {
|
||||
memberTypes = orderConfig;
|
||||
}
|
||||
else {
|
||||
order = orderConfig.order;
|
||||
memberTypes = orderConfig.memberTypes;
|
||||
}
|
||||
const hasAlphaSort = order === null || order === void 0 ? void 0 : order.startsWith('alphabetically');
|
||||
const alphaSortIsCaseSensitive = order !== 'alphabetically-case-insensitive';
|
||||
// Check order
|
||||
if (Array.isArray(memberTypes)) {
|
||||
const grouped = checkGroupSort(members, memberTypes, supportsModifiers);
|
||||
if (grouped === null) {
|
||||
return;
|
||||
}
|
||||
if (hasAlphaSort) {
|
||||
grouped.some(groupMember => !checkAlphaSort(groupMember, alphaSortIsCaseSensitive));
|
||||
}
|
||||
}
|
||||
else if (hasAlphaSort) {
|
||||
checkAlphaSort(members, alphaSortIsCaseSensitive);
|
||||
}
|
||||
}
|
||||
return {
|
||||
ClassDeclaration(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.body.body, (_a = options.classes) !== null && _a !== void 0 ? _a : options.default, true);
|
||||
},
|
||||
ClassExpression(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.body.body, (_a = options.classExpressions) !== null && _a !== void 0 ? _a : options.default, true);
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.body.body, (_a = options.interfaces) !== null && _a !== void 0 ? _a : options.default, false);
|
||||
},
|
||||
TSTypeLiteral(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.members, (_a = options.typeLiterals) !== null && _a !== void 0 ? _a : options.default, false);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=member-ordering.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
201
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js
generated
vendored
Normal file
201
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'method-signature-style',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce using a particular method signature syntax',
|
||||
recommended: false,
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
errorMethod: 'Shorthand method signature is forbidden. Use a function property instead.',
|
||||
errorProperty: 'Function property signature is forbidden. Use a method shorthand instead.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
enum: ['property', 'method'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['property'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function getMethodKey(node) {
|
||||
let key = sourceCode.getText(node.key);
|
||||
if (node.computed) {
|
||||
key = `[${key}]`;
|
||||
}
|
||||
if (node.optional) {
|
||||
key = `${key}?`;
|
||||
}
|
||||
if (node.readonly) {
|
||||
key = `readonly ${key}`;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
function getMethodParams(node) {
|
||||
let params = '()';
|
||||
if (node.params.length > 0) {
|
||||
const openingParen = util.nullThrows(sourceCode.getTokenBefore(node.params[0], util.isOpeningParenToken), 'Missing opening paren before first parameter');
|
||||
const closingParen = util.nullThrows(sourceCode.getTokenAfter(node.params[node.params.length - 1], util.isClosingParenToken), 'Missing closing paren after last parameter');
|
||||
params = sourceCode.text.substring(openingParen.range[0], closingParen.range[1]);
|
||||
}
|
||||
if (node.typeParameters != null) {
|
||||
const typeParams = sourceCode.getText(node.typeParameters);
|
||||
params = `${typeParams}${params}`;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
function getMethodReturnType(node) {
|
||||
return node.returnType == null
|
||||
? // if the method has no return type, it implicitly has an `any` return type
|
||||
// we just make it explicit here so we can do the fix
|
||||
'any'
|
||||
: sourceCode.getText(node.returnType.typeAnnotation);
|
||||
}
|
||||
function getDelimiter(node) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (lastToken &&
|
||||
(util.isSemicolonToken(lastToken) || util.isCommaToken(lastToken))) {
|
||||
return lastToken.value;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function isNodeParentModuleDeclaration(node) {
|
||||
if (!node.parent) {
|
||||
return false;
|
||||
}
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration) {
|
||||
return true;
|
||||
}
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.Program) {
|
||||
return false;
|
||||
}
|
||||
return isNodeParentModuleDeclaration(node.parent);
|
||||
}
|
||||
return Object.assign(Object.assign({}, (mode === 'property' && {
|
||||
TSMethodSignature(methodNode) {
|
||||
if (methodNode.kind !== 'method') {
|
||||
return;
|
||||
}
|
||||
const parent = methodNode.parent;
|
||||
const members = (parent === null || parent === void 0 ? void 0 : parent.type) === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
||||
? parent.body
|
||||
: (parent === null || parent === void 0 ? void 0 : parent.type) === utils_1.AST_NODE_TYPES.TSTypeLiteral
|
||||
? parent.members
|
||||
: [];
|
||||
const duplicatedKeyMethodNodes = members.filter((element) => element.type === utils_1.AST_NODE_TYPES.TSMethodSignature &&
|
||||
element !== methodNode &&
|
||||
getMethodKey(element) === getMethodKey(methodNode));
|
||||
const isParentModule = isNodeParentModuleDeclaration(methodNode);
|
||||
if (duplicatedKeyMethodNodes.length > 0) {
|
||||
if (isParentModule) {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
*fix(fixer) {
|
||||
const methodNodes = [
|
||||
methodNode,
|
||||
...duplicatedKeyMethodNodes,
|
||||
].sort((a, b) => (a.range[0] < b.range[0] ? -1 : 1));
|
||||
const typeString = methodNodes
|
||||
.map(node => {
|
||||
const params = getMethodParams(node);
|
||||
const returnType = getMethodReturnType(node);
|
||||
return `(${params} => ${returnType})`;
|
||||
})
|
||||
.join(' & ');
|
||||
const key = getMethodKey(methodNode);
|
||||
const delimiter = getDelimiter(methodNode);
|
||||
yield fixer.replaceText(methodNode, `${key}: ${typeString}${delimiter}`);
|
||||
for (const node of duplicatedKeyMethodNodes) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (lastToken) {
|
||||
const nextToken = sourceCode.getTokenAfter(lastToken);
|
||||
if (nextToken) {
|
||||
yield fixer.remove(node);
|
||||
yield fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], '');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isParentModule) {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
fix: fixer => {
|
||||
const key = getMethodKey(methodNode);
|
||||
const params = getMethodParams(methodNode);
|
||||
const returnType = getMethodReturnType(methodNode);
|
||||
const delimiter = getDelimiter(methodNode);
|
||||
return fixer.replaceText(methodNode, `${key}: ${params} => ${returnType}${delimiter}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
})), (mode === 'method' && {
|
||||
TSPropertySignature(propertyNode) {
|
||||
var _a;
|
||||
const typeNode = (_a = propertyNode.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation;
|
||||
if ((typeNode === null || typeNode === void 0 ? void 0 : typeNode.type) !== utils_1.AST_NODE_TYPES.TSFunctionType) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: propertyNode,
|
||||
messageId: 'errorProperty',
|
||||
fix: fixer => {
|
||||
const key = getMethodKey(propertyNode);
|
||||
const params = getMethodParams(typeNode);
|
||||
const returnType = getMethodReturnType(typeNode);
|
||||
const delimiter = getDelimiter(propertyNode);
|
||||
return fixer.replaceText(propertyNode, `${key}${params}: ${returnType}${delimiter}`);
|
||||
},
|
||||
});
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=method-signature-style.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
94
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js
generated
vendored
Normal file
94
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UnderscoreOptions = exports.TypeModifiers = exports.Selectors = exports.PredefinedFormats = exports.Modifiers = exports.MetaSelectors = void 0;
|
||||
var PredefinedFormats;
|
||||
(function (PredefinedFormats) {
|
||||
PredefinedFormats[PredefinedFormats["camelCase"] = 1] = "camelCase";
|
||||
PredefinedFormats[PredefinedFormats["strictCamelCase"] = 2] = "strictCamelCase";
|
||||
PredefinedFormats[PredefinedFormats["PascalCase"] = 3] = "PascalCase";
|
||||
PredefinedFormats[PredefinedFormats["StrictPascalCase"] = 4] = "StrictPascalCase";
|
||||
PredefinedFormats[PredefinedFormats["snake_case"] = 5] = "snake_case";
|
||||
PredefinedFormats[PredefinedFormats["UPPER_CASE"] = 6] = "UPPER_CASE";
|
||||
})(PredefinedFormats || (PredefinedFormats = {}));
|
||||
exports.PredefinedFormats = PredefinedFormats;
|
||||
var UnderscoreOptions;
|
||||
(function (UnderscoreOptions) {
|
||||
UnderscoreOptions[UnderscoreOptions["forbid"] = 1] = "forbid";
|
||||
UnderscoreOptions[UnderscoreOptions["allow"] = 2] = "allow";
|
||||
UnderscoreOptions[UnderscoreOptions["require"] = 3] = "require";
|
||||
// special cases as it's common practice to use double underscore
|
||||
UnderscoreOptions[UnderscoreOptions["requireDouble"] = 4] = "requireDouble";
|
||||
UnderscoreOptions[UnderscoreOptions["allowDouble"] = 5] = "allowDouble";
|
||||
UnderscoreOptions[UnderscoreOptions["allowSingleOrDouble"] = 6] = "allowSingleOrDouble";
|
||||
})(UnderscoreOptions || (UnderscoreOptions = {}));
|
||||
exports.UnderscoreOptions = UnderscoreOptions;
|
||||
var Selectors;
|
||||
(function (Selectors) {
|
||||
// variableLike
|
||||
Selectors[Selectors["variable"] = 1] = "variable";
|
||||
Selectors[Selectors["function"] = 2] = "function";
|
||||
Selectors[Selectors["parameter"] = 4] = "parameter";
|
||||
// memberLike
|
||||
Selectors[Selectors["parameterProperty"] = 8] = "parameterProperty";
|
||||
Selectors[Selectors["accessor"] = 16] = "accessor";
|
||||
Selectors[Selectors["enumMember"] = 32] = "enumMember";
|
||||
Selectors[Selectors["classMethod"] = 64] = "classMethod";
|
||||
Selectors[Selectors["objectLiteralMethod"] = 128] = "objectLiteralMethod";
|
||||
Selectors[Selectors["typeMethod"] = 256] = "typeMethod";
|
||||
Selectors[Selectors["classProperty"] = 512] = "classProperty";
|
||||
Selectors[Selectors["objectLiteralProperty"] = 1024] = "objectLiteralProperty";
|
||||
Selectors[Selectors["typeProperty"] = 2048] = "typeProperty";
|
||||
// typeLike
|
||||
Selectors[Selectors["class"] = 4096] = "class";
|
||||
Selectors[Selectors["interface"] = 8192] = "interface";
|
||||
Selectors[Selectors["typeAlias"] = 16384] = "typeAlias";
|
||||
Selectors[Selectors["enum"] = 32768] = "enum";
|
||||
Selectors[Selectors["typeParameter"] = 131072] = "typeParameter";
|
||||
})(Selectors || (Selectors = {}));
|
||||
exports.Selectors = Selectors;
|
||||
var MetaSelectors;
|
||||
(function (MetaSelectors) {
|
||||
MetaSelectors[MetaSelectors["default"] = -1] = "default";
|
||||
MetaSelectors[MetaSelectors["variableLike"] = 7] = "variableLike";
|
||||
MetaSelectors[MetaSelectors["memberLike"] = 4088] = "memberLike";
|
||||
MetaSelectors[MetaSelectors["typeLike"] = 192512] = "typeLike";
|
||||
MetaSelectors[MetaSelectors["method"] = 448] = "method";
|
||||
MetaSelectors[MetaSelectors["property"] = 3584] = "property";
|
||||
})(MetaSelectors || (MetaSelectors = {}));
|
||||
exports.MetaSelectors = MetaSelectors;
|
||||
var Modifiers;
|
||||
(function (Modifiers) {
|
||||
// const variable
|
||||
Modifiers[Modifiers["const"] = 1] = "const";
|
||||
// readonly members
|
||||
Modifiers[Modifiers["readonly"] = 2] = "readonly";
|
||||
// static members
|
||||
Modifiers[Modifiers["static"] = 4] = "static";
|
||||
// member accessibility
|
||||
Modifiers[Modifiers["public"] = 8] = "public";
|
||||
Modifiers[Modifiers["protected"] = 16] = "protected";
|
||||
Modifiers[Modifiers["private"] = 32] = "private";
|
||||
Modifiers[Modifiers["abstract"] = 64] = "abstract";
|
||||
// destructured variable
|
||||
Modifiers[Modifiers["destructured"] = 128] = "destructured";
|
||||
// variables declared in the top-level scope
|
||||
Modifiers[Modifiers["global"] = 256] = "global";
|
||||
// things that are exported
|
||||
Modifiers[Modifiers["exported"] = 512] = "exported";
|
||||
// things that are unused
|
||||
Modifiers[Modifiers["unused"] = 1024] = "unused";
|
||||
// properties that require quoting
|
||||
Modifiers[Modifiers["requiresQuotes"] = 2048] = "requiresQuotes";
|
||||
// make sure TypeModifiers starts at Modifiers + 1 or else sorting won't work
|
||||
})(Modifiers || (Modifiers = {}));
|
||||
exports.Modifiers = Modifiers;
|
||||
var TypeModifiers;
|
||||
(function (TypeModifiers) {
|
||||
TypeModifiers[TypeModifiers["boolean"] = 4096] = "boolean";
|
||||
TypeModifiers[TypeModifiers["string"] = 8192] = "string";
|
||||
TypeModifiers[TypeModifiers["number"] = 16384] = "number";
|
||||
TypeModifiers[TypeModifiers["function"] = 32768] = "function";
|
||||
TypeModifiers[TypeModifiers["array"] = 65536] = "array";
|
||||
})(TypeModifiers || (TypeModifiers = {}));
|
||||
exports.TypeModifiers = TypeModifiers;
|
||||
//# sourceMappingURL=enums.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/enums.ts"],"names":[],"mappings":";;;AAAA,IAAK,iBAOJ;AAPD,WAAK,iBAAiB;IACpB,mEAAa,CAAA;IACb,+EAAe,CAAA;IACf,qEAAU,CAAA;IACV,iFAAgB,CAAA;IAChB,qEAAU,CAAA;IACV,qEAAU,CAAA;AACZ,CAAC,EAPI,iBAAiB,KAAjB,iBAAiB,QAOrB;AAqHC,8CAAiB;AAlHnB,IAAK,iBASJ;AATD,WAAK,iBAAiB;IACpB,6DAAU,CAAA;IACV,2DAAK,CAAA;IACL,+DAAO,CAAA;IAEP,iEAAiE;IACjE,2EAAa,CAAA;IACb,uEAAW,CAAA;IACX,uFAAmB,CAAA;AACrB,CAAC,EATI,iBAAiB,KAAjB,iBAAiB,QASrB;AA+GC,8CAAiB;AA5GnB,IAAK,SAuBJ;AAvBD,WAAK,SAAS;IACZ,eAAe;IACf,iDAAiB,CAAA;IACjB,iDAAiB,CAAA;IACjB,mDAAkB,CAAA;IAElB,aAAa;IACb,mEAA0B,CAAA;IAC1B,kDAAiB,CAAA;IACjB,sDAAmB,CAAA;IACnB,wDAAoB,CAAA;IACpB,yEAA4B,CAAA;IAC5B,uDAAmB,CAAA;IACnB,6DAAsB,CAAA;IACtB,8EAA+B,CAAA;IAC/B,4DAAsB,CAAA;IAEtB,WAAW;IACX,8CAAe,CAAA;IACf,sDAAmB,CAAA;IACnB,uDAAmB,CAAA;IACnB,6CAAc,CAAA;IACd,gEAAuB,CAAA;AACzB,CAAC,EAvBI,SAAS,KAAT,SAAS,QAuBb;AAiFC,8BAAS;AA9EX,IAAK,aA8BJ;AA9BD,WAAK,aAAa;IAChB,wDAAY,CAAA;IACZ,iEAGqB,CAAA;IACrB,gEASoB,CAAA;IACpB,8DAKyB,CAAA;IACzB,uDAGsB,CAAA;IACtB,4DAGwB,CAAA;AAC1B,CAAC,EA9BI,aAAa,KAAb,aAAa,QA8BjB;AA0CC,sCAAa;AAtCf,IAAK,SAwBJ;AAxBD,WAAK,SAAS;IACZ,iBAAiB;IACjB,2CAAc,CAAA;IACd,mBAAmB;IACnB,iDAAiB,CAAA;IACjB,iBAAiB;IACjB,6CAAe,CAAA;IACf,uBAAuB;IACvB,6CAAe,CAAA;IACf,oDAAkB,CAAA;IAClB,gDAAgB,CAAA;IAChB,kDAAiB,CAAA;IACjB,wBAAwB;IACxB,2DAAqB,CAAA;IACrB,4CAA4C;IAC5C,+CAAe,CAAA;IACf,2BAA2B;IAC3B,mDAAiB,CAAA;IACjB,yBAAyB;IACzB,gDAAgB,CAAA;IAChB,kCAAkC;IAClC,gEAAwB,CAAA;IAExB,6EAA6E;AAC/E,CAAC,EAxBI,SAAS,KAAT,SAAS,QAwBb;AAgBC,8BAAS;AAbX,IAAK,aAMJ;AAND,WAAK,aAAa;IAChB,0DAAiB,CAAA;IACjB,wDAAgB,CAAA;IAChB,yDAAgB,CAAA;IAChB,6DAAkB,CAAA;IAClB,uDAAe,CAAA;AACjB,CAAC,EANI,aAAa,KAAb,aAAa,QAMjB;AAaC,sCAAa"}
|
||||
91
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js
generated
vendored
Normal file
91
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PredefinedFormatToCheckFunction = void 0;
|
||||
const enums_1 = require("./enums");
|
||||
/*
|
||||
These format functions are taken from `tslint-consistent-codestyle/naming-convention`:
|
||||
https://github.com/ajafff/tslint-consistent-codestyle/blob/ab156cc8881bcc401236d999f4ce034b59039e81/rules/namingConventionRule.ts#L603-L645
|
||||
|
||||
The license for the code can be viewed here:
|
||||
https://github.com/ajafff/tslint-consistent-codestyle/blob/ab156cc8881bcc401236d999f4ce034b59039e81/LICENSE
|
||||
*/
|
||||
/*
|
||||
Why not regex here? Because it's actually really, really difficult to create a regex to handle
|
||||
all of the unicode cases, and we have many non-english users that use non-english characters.
|
||||
https://gist.github.com/mathiasbynens/6334847
|
||||
*/
|
||||
function isPascalCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toUpperCase() && !name.includes('_')));
|
||||
}
|
||||
function isStrictPascalCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toUpperCase() && hasStrictCamelHumps(name, true)));
|
||||
}
|
||||
function isCamelCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toLowerCase() && !name.includes('_')));
|
||||
}
|
||||
function isStrictCamelCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toLowerCase() && hasStrictCamelHumps(name, false)));
|
||||
}
|
||||
function hasStrictCamelHumps(name, isUpper) {
|
||||
function isUppercaseChar(char) {
|
||||
return char === char.toUpperCase() && char !== char.toLowerCase();
|
||||
}
|
||||
if (name.startsWith('_')) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 1; i < name.length; ++i) {
|
||||
if (name[i] === '_') {
|
||||
return false;
|
||||
}
|
||||
if (isUpper === isUppercaseChar(name[i])) {
|
||||
if (isUpper) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
isUpper = !isUpper;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isSnakeCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name === name.toLowerCase() && validateUnderscores(name)));
|
||||
}
|
||||
function isUpperCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name === name.toUpperCase() && validateUnderscores(name)));
|
||||
}
|
||||
/** Check for leading trailing and adjacent underscores */
|
||||
function validateUnderscores(name) {
|
||||
if (name.startsWith('_')) {
|
||||
return false;
|
||||
}
|
||||
let wasUnderscore = false;
|
||||
for (let i = 1; i < name.length; ++i) {
|
||||
if (name[i] === '_') {
|
||||
if (wasUnderscore) {
|
||||
return false;
|
||||
}
|
||||
wasUnderscore = true;
|
||||
}
|
||||
else {
|
||||
wasUnderscore = false;
|
||||
}
|
||||
}
|
||||
return !wasUnderscore;
|
||||
}
|
||||
const PredefinedFormatToCheckFunction = {
|
||||
[enums_1.PredefinedFormats.PascalCase]: isPascalCase,
|
||||
[enums_1.PredefinedFormats.StrictPascalCase]: isStrictPascalCase,
|
||||
[enums_1.PredefinedFormats.camelCase]: isCamelCase,
|
||||
[enums_1.PredefinedFormats.strictCamelCase]: isStrictCamelCase,
|
||||
[enums_1.PredefinedFormats.UPPER_CASE]: isUpperCase,
|
||||
[enums_1.PredefinedFormats.snake_case]: isSnakeCase,
|
||||
};
|
||||
exports.PredefinedFormatToCheckFunction = PredefinedFormatToCheckFunction;
|
||||
//# sourceMappingURL=format.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/format.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAE5C;;;;;;EAME;AAEF;;;;EAIE;AAEF,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CA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AS,CAAC,EAAE,WAAW;IAC1C,CAAC,yBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB;IACtD,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW;IAC3C,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW;CAC5C,CAAC;AAEO,0EAA+B"}
|
||||
12
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/index.js
generated
vendored
Normal file
12
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseOptions = exports.selectorTypeToMessageString = exports.SCHEMA = exports.Modifiers = void 0;
|
||||
var enums_1 = require("./enums");
|
||||
Object.defineProperty(exports, "Modifiers", { enumerable: true, get: function () { return enums_1.Modifiers; } });
|
||||
var schema_1 = require("./schema");
|
||||
Object.defineProperty(exports, "SCHEMA", { enumerable: true, get: function () { return schema_1.SCHEMA; } });
|
||||
var shared_1 = require("./shared");
|
||||
Object.defineProperty(exports, "selectorTypeToMessageString", { enumerable: true, get: function () { return shared_1.selectorTypeToMessageString; } });
|
||||
var parse_options_1 = require("./parse-options");
|
||||
Object.defineProperty(exports, "parseOptions", { enumerable: true, get: function () { return parse_options_1.parseOptions; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/index.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/index.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAGlB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mCAAuD;AAA9C,qHAAA,2BAA2B,OAAA;AACpC,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
|
||||
94
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/parse-options.js
generated
vendored
Normal file
94
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/parse-options.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseOptions = void 0;
|
||||
const util = __importStar(require("../../util"));
|
||||
const enums_1 = require("./enums");
|
||||
const shared_1 = require("./shared");
|
||||
const validator_1 = require("./validator");
|
||||
function normalizeOption(option) {
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
let weight = 0;
|
||||
(_a = option.modifiers) === null || _a === void 0 ? void 0 : _a.forEach(mod => {
|
||||
weight |= enums_1.Modifiers[mod];
|
||||
});
|
||||
(_b = option.types) === null || _b === void 0 ? void 0 : _b.forEach(mod => {
|
||||
weight |= enums_1.TypeModifiers[mod];
|
||||
});
|
||||
// give selectors with a filter the _highest_ priority
|
||||
if (option.filter) {
|
||||
weight |= 1 << 30;
|
||||
}
|
||||
const normalizedOption = {
|
||||
// format options
|
||||
format: option.format ? option.format.map(f => enums_1.PredefinedFormats[f]) : null,
|
||||
custom: option.custom
|
||||
? {
|
||||
regex: new RegExp(option.custom.regex, 'u'),
|
||||
match: option.custom.match,
|
||||
}
|
||||
: null,
|
||||
leadingUnderscore: option.leadingUnderscore !== undefined
|
||||
? enums_1.UnderscoreOptions[option.leadingUnderscore]
|
||||
: null,
|
||||
trailingUnderscore: option.trailingUnderscore !== undefined
|
||||
? enums_1.UnderscoreOptions[option.trailingUnderscore]
|
||||
: null,
|
||||
prefix: option.prefix && option.prefix.length > 0 ? option.prefix : null,
|
||||
suffix: option.suffix && option.suffix.length > 0 ? option.suffix : null,
|
||||
modifiers: (_d = (_c = option.modifiers) === null || _c === void 0 ? void 0 : _c.map(m => enums_1.Modifiers[m])) !== null && _d !== void 0 ? _d : null,
|
||||
types: (_f = (_e = option.types) === null || _e === void 0 ? void 0 : _e.map(m => enums_1.TypeModifiers[m])) !== null && _f !== void 0 ? _f : null,
|
||||
filter: option.filter !== undefined
|
||||
? typeof option.filter === 'string'
|
||||
? {
|
||||
regex: new RegExp(option.filter, 'u'),
|
||||
match: true,
|
||||
}
|
||||
: {
|
||||
regex: new RegExp(option.filter.regex, 'u'),
|
||||
match: option.filter.match,
|
||||
}
|
||||
: null,
|
||||
// calculated ordering weight based on modifiers
|
||||
modifierWeight: weight,
|
||||
};
|
||||
const selectors = Array.isArray(option.selector)
|
||||
? option.selector
|
||||
: [option.selector];
|
||||
return selectors.map(selector => (Object.assign({ selector: (0, shared_1.isMetaSelector)(selector)
|
||||
? enums_1.MetaSelectors[selector]
|
||||
: enums_1.Selectors[selector] }, normalizedOption)));
|
||||
}
|
||||
function parseOptions(context) {
|
||||
const normalizedOptions = context.options
|
||||
.map(opt => normalizeOption(opt))
|
||||
.reduce((acc, val) => acc.concat(val), []);
|
||||
return util.getEnumNames(enums_1.Selectors).reduce((acc, k) => {
|
||||
acc[k] = (0, validator_1.createValidator)(k, context, normalizedOptions);
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
exports.parseOptions = parseOptions;
|
||||
//# sourceMappingURL=parse-options.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/parse-options.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/parse-options.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-options.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/parse-options.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,mCAOiB;AACjB,qCAA0C;AAO1C,2CAA8C;AAE9C,SAAS,eAAe,CAAC,MAAgB;;IACvC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAA,MAAM,CAAC,SAAS,0CAAE,OAAO,CAAC,GAAG,CAAC,EAAE;QAC9B,MAAM,IAAI,iBAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,MAAA,MAAM,CAAC,KAAK,0CAAE,OAAO,CAAC,GAAG,CAAC,EAAE;QAC1B,MAAM,IAAI,qBAAa,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,sDAAsD;IACtD,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;KACnB;IAED,MAAM,gBAAgB,GAAG;QACvB,iBAAiB;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,yBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,I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;AAC1B,CAAC;AAEQ,oCAAY"}
|
||||
263
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/schema.js
generated
vendored
Normal file
263
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/schema.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SCHEMA = void 0;
|
||||
const enums_1 = require("./enums");
|
||||
const util = __importStar(require("../../util"));
|
||||
const UNDERSCORE_SCHEMA = {
|
||||
type: 'string',
|
||||
enum: util.getEnumNames(enums_1.UnderscoreOptions),
|
||||
};
|
||||
const PREFIX_SUFFIX_SCHEMA = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
additionalItems: false,
|
||||
};
|
||||
const MATCH_REGEX_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
match: { type: 'boolean' },
|
||||
regex: { type: 'string' },
|
||||
},
|
||||
required: ['match', 'regex'],
|
||||
};
|
||||
const FORMAT_OPTIONS_PROPERTIES = {
|
||||
format: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: util.getEnumNames(enums_1.PredefinedFormats),
|
||||
},
|
||||
additionalItems: false,
|
||||
},
|
||||
{
|
||||
type: 'null',
|
||||
},
|
||||
],
|
||||
},
|
||||
custom: MATCH_REGEX_SCHEMA,
|
||||
leadingUnderscore: UNDERSCORE_SCHEMA,
|
||||
trailingUnderscore: UNDERSCORE_SCHEMA,
|
||||
prefix: PREFIX_SUFFIX_SCHEMA,
|
||||
suffix: PREFIX_SUFFIX_SCHEMA,
|
||||
failureMessage: {
|
||||
type: 'string',
|
||||
},
|
||||
};
|
||||
function selectorSchema(selectorString, allowType, modifiers) {
|
||||
const selector = {
|
||||
filter: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
MATCH_REGEX_SCHEMA,
|
||||
],
|
||||
},
|
||||
selector: {
|
||||
type: 'string',
|
||||
enum: [selectorString],
|
||||
},
|
||||
};
|
||||
if (modifiers && modifiers.length > 0) {
|
||||
selector.modifiers = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: modifiers,
|
||||
},
|
||||
additionalItems: false,
|
||||
};
|
||||
}
|
||||
if (allowType) {
|
||||
selector.types = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: util.getEnumNames(enums_1.TypeModifiers),
|
||||
},
|
||||
additionalItems: false,
|
||||
};
|
||||
}
|
||||
return [
|
||||
{
|
||||
type: 'object',
|
||||
properties: Object.assign(Object.assign({}, FORMAT_OPTIONS_PROPERTIES), selector),
|
||||
required: ['selector', 'format'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
];
|
||||
}
|
||||
function selectorsSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
properties: Object.assign(Object.assign({}, FORMAT_OPTIONS_PROPERTIES), {
|
||||
filter: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string',
|
||||
minLength: 1,
|
||||
},
|
||||
MATCH_REGEX_SCHEMA,
|
||||
],
|
||||
},
|
||||
selector: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
...util.getEnumNames(enums_1.MetaSelectors),
|
||||
...util.getEnumNames(enums_1.Selectors),
|
||||
],
|
||||
},
|
||||
additionalItems: false,
|
||||
},
|
||||
modifiers: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: util.getEnumNames(enums_1.Modifiers),
|
||||
},
|
||||
additionalItems: false,
|
||||
},
|
||||
types: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: util.getEnumNames(enums_1.TypeModifiers),
|
||||
},
|
||||
additionalItems: false,
|
||||
},
|
||||
}),
|
||||
required: ['selector', 'format'],
|
||||
additionalProperties: false,
|
||||
};
|
||||
}
|
||||
const SCHEMA = {
|
||||
type: 'array',
|
||||
items: {
|
||||
oneOf: [
|
||||
selectorsSchema(),
|
||||
...selectorSchema('default', false, util.getEnumNames(enums_1.Modifiers)),
|
||||
...selectorSchema('variableLike', false, ['unused']),
|
||||
...selectorSchema('variable', true, [
|
||||
'const',
|
||||
'destructured',
|
||||
'exported',
|
||||
'global',
|
||||
'unused',
|
||||
]),
|
||||
...selectorSchema('function', false, ['exported', 'global', 'unused']),
|
||||
...selectorSchema('parameter', true, ['destructured', 'unused']),
|
||||
...selectorSchema('memberLike', false, [
|
||||
'abstract',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
'requiresQuotes',
|
||||
'static',
|
||||
]),
|
||||
...selectorSchema('classProperty', true, [
|
||||
'abstract',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
'requiresQuotes',
|
||||
'static',
|
||||
]),
|
||||
...selectorSchema('objectLiteralProperty', true, [
|
||||
'public',
|
||||
'requiresQuotes',
|
||||
]),
|
||||
...selectorSchema('typeProperty', true, [
|
||||
'public',
|
||||
'readonly',
|
||||
'requiresQuotes',
|
||||
]),
|
||||
...selectorSchema('parameterProperty', true, [
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
]),
|
||||
...selectorSchema('property', true, [
|
||||
'abstract',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'readonly',
|
||||
'requiresQuotes',
|
||||
'static',
|
||||
]),
|
||||
...selectorSchema('classMethod', false, [
|
||||
'abstract',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'requiresQuotes',
|
||||
'static',
|
||||
]),
|
||||
...selectorSchema('objectLiteralMethod', false, [
|
||||
'public',
|
||||
'requiresQuotes',
|
||||
]),
|
||||
...selectorSchema('typeMethod', false, ['public', 'requiresQuotes']),
|
||||
...selectorSchema('method', false, [
|
||||
'abstract',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'requiresQuotes',
|
||||
'static',
|
||||
]),
|
||||
...selectorSchema('accessor', true, [
|
||||
'abstract',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'requiresQuotes',
|
||||
'static',
|
||||
]),
|
||||
...selectorSchema('enumMember', false, ['requiresQuotes']),
|
||||
...selectorSchema('typeLike', false, ['abstract', 'exported', 'unused']),
|
||||
...selectorSchema('class', false, ['abstract', 'exported', 'unused']),
|
||||
...selectorSchema('interface', false, ['exported', 'unused']),
|
||||
...selectorSchema('typeAlias', false, ['exported', 'unused']),
|
||||
...selectorSchema('enum', false, ['exported', 'unused']),
|
||||
...selectorSchema('typeParameter', false, ['unused']),
|
||||
],
|
||||
},
|
||||
additionalItems: false,
|
||||
};
|
||||
exports.SCHEMA = SCHEMA;
|
||||
//# sourceMappingURL=schema.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/schema.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/schema.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mCASiB;AACjB,iDAAmC;AAEnC,MAAM,iBAAiB,GAA2B;IAChD,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,yBAAiB,CAAC;CAC3C,CAAC;AACF,MAAM,oBAAoB,GAA2B;IACnD,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,CAAC;KACb;IACD,eAAe,EAAE,KAAK;CACvB,CAAC;AACF,MAAM,kBAAkB,GAA2B;IACjD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC1B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1B;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,yBAAyB,GAAyB;IACtD,MAAM,EAAE;QACN,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,yBAAiB,CAAC;iBAC3C;gBACD,eAAe,EAAE,KAAK;aACvB;YACD;gBACE,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,kBAAkB;IAC1B,iBAAiB,EAAE,iBAAiB;IACpC,kBAAkB,EAAE,iBAAiB;IACrC,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,oBAAoB;IAC5B,cAAc,EAAE;QACd,IAAI,EAA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AI,EAAE;gBAClC,UAAU;gBACV,SAAS;gBACT,WAAW;gBACX,QAAQ;gBACR,gBAAgB;gBAChB,QAAQ;aACT,CAAC;YACF,GAAG,cAAc,CAAC,YAAY,EAAE,KAAK,EAAE,CAAC,gBAAgB,CAAC,CAAC;YAE1D,GAAG,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACxE,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YACrE,GAAG,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAC7D,GAAG,cAAc,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YAC7D,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACxD,GAAG,cAAc,CAAC,eAAe,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;SACtD;KACF;IACD,eAAe,EAAE,KAAK;CACvB,CAAC;AAEO,wBAAM"}
|
||||
18
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/shared.js
generated
vendored
Normal file
18
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/shared.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isMethodOrPropertySelector = exports.isMetaSelector = exports.selectorTypeToMessageString = void 0;
|
||||
const enums_1 = require("./enums");
|
||||
function selectorTypeToMessageString(selectorType) {
|
||||
const notCamelCase = selectorType.replace(/([A-Z])/g, ' $1');
|
||||
return notCamelCase.charAt(0).toUpperCase() + notCamelCase.slice(1);
|
||||
}
|
||||
exports.selectorTypeToMessageString = selectorTypeToMessageString;
|
||||
function isMetaSelector(selector) {
|
||||
return selector in enums_1.MetaSelectors;
|
||||
}
|
||||
exports.isMetaSelector = isMetaSelector;
|
||||
function isMethodOrPropertySelector(selector) {
|
||||
return (selector === enums_1.MetaSelectors.method || selector === enums_1.MetaSelectors.property);
|
||||
}
|
||||
exports.isMethodOrPropertySelector = isMethodOrPropertySelector;
|
||||
//# sourceMappingURL=shared.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/shared.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/shared.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/shared.ts"],"names":[],"mappings":";;;AAAA,mCAMiB;AAEjB,SAAS,2BAA2B,CAAC,YAA6B;IAChE,MAAM,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAiBC,kEAA2B;AAf7B,SAAS,cAAc,CACrB,QAAsE;IAEtE,OAAO,QAAQ,IAAI,qBAAa,CAAC;AACnC,CAAC;AAYC,wCAAc;AAVhB,SAAS,0BAA0B,CACjC,QAAsE;IAEtE,OAAO,CACL,QAAQ,KAAK,qBAAa,CAAC,MAAM,IAAI,QAAQ,KAAK,qBAAa,CAAC,QAAQ,CACzE,CAAC;AACJ,CAAC;AAKC,gEAA0B"}
|
||||
3
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/types.js
generated
vendored
Normal file
3
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/types.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/types.ts"],"names":[],"mappings":""}
|
||||
377
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/validator.js
generated
vendored
Normal file
377
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/validator.js
generated
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createValidator = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const enums_1 = require("./enums");
|
||||
const format_1 = require("./format");
|
||||
const shared_1 = require("./shared");
|
||||
const util = __importStar(require("../../util"));
|
||||
function createValidator(type, context, allConfigs) {
|
||||
// make sure the "highest priority" configs are checked first
|
||||
const selectorType = enums_1.Selectors[type];
|
||||
const configs = allConfigs
|
||||
// gather all of the applicable selectors
|
||||
.filter(c => (c.selector & selectorType) !== 0 ||
|
||||
c.selector === enums_1.MetaSelectors.default)
|
||||
.sort((a, b) => {
|
||||
if (a.selector === b.selector) {
|
||||
// in the event of the same selector, order by modifier weight
|
||||
// sort descending - the type modifiers are "more important"
|
||||
return b.modifierWeight - a.modifierWeight;
|
||||
}
|
||||
const aIsMeta = (0, shared_1.isMetaSelector)(a.selector);
|
||||
const bIsMeta = (0, shared_1.isMetaSelector)(b.selector);
|
||||
// non-meta selectors should go ahead of meta selectors
|
||||
if (aIsMeta && !bIsMeta) {
|
||||
return 1;
|
||||
}
|
||||
if (!aIsMeta && bIsMeta) {
|
||||
return -1;
|
||||
}
|
||||
const aIsMethodOrProperty = (0, shared_1.isMethodOrPropertySelector)(a.selector);
|
||||
const bIsMethodOrProperty = (0, shared_1.isMethodOrPropertySelector)(b.selector);
|
||||
// for backward compatibility, method and property have higher precedence than other meta selectors
|
||||
if (aIsMethodOrProperty && !bIsMethodOrProperty) {
|
||||
return -1;
|
||||
}
|
||||
if (!aIsMethodOrProperty && bIsMethodOrProperty) {
|
||||
return 1;
|
||||
}
|
||||
// both aren't meta selectors
|
||||
// sort descending - the meta selectors are "least important"
|
||||
return b.selector - a.selector;
|
||||
});
|
||||
return (node, modifiers = new Set()) => {
|
||||
var _a, _b, _c;
|
||||
const originalName = node.type === utils_1.AST_NODE_TYPES.Identifier ||
|
||||
node.type === utils_1.AST_NODE_TYPES.PrivateIdentifier
|
||||
? node.name
|
||||
: `${node.value}`;
|
||||
// return will break the loop and stop checking configs
|
||||
// it is only used when the name is known to have failed or succeeded a config.
|
||||
for (const config of configs) {
|
||||
if (((_a = config.filter) === null || _a === void 0 ? void 0 : _a.regex.test(originalName)) !== ((_b = config.filter) === null || _b === void 0 ? void 0 : _b.match)) {
|
||||
// name does not match the filter
|
||||
continue;
|
||||
}
|
||||
if ((_c = config.modifiers) === null || _c === void 0 ? void 0 : _c.some(modifier => !modifiers.has(modifier))) {
|
||||
// does not have the required modifiers
|
||||
continue;
|
||||
}
|
||||
if (!isCorrectType(node, config, context, selectorType)) {
|
||||
// is not the correct type
|
||||
continue;
|
||||
}
|
||||
let name = originalName;
|
||||
name = validateUnderscore('leading', config, name, node, originalName);
|
||||
if (name === null) {
|
||||
// fail
|
||||
return;
|
||||
}
|
||||
name = validateUnderscore('trailing', config, name, node, originalName);
|
||||
if (name === null) {
|
||||
// fail
|
||||
return;
|
||||
}
|
||||
name = validateAffix('prefix', config, name, node, originalName);
|
||||
if (name === null) {
|
||||
// fail
|
||||
return;
|
||||
}
|
||||
name = validateAffix('suffix', config, name, node, originalName);
|
||||
if (name === null) {
|
||||
// fail
|
||||
return;
|
||||
}
|
||||
if (!validateCustom(config, name, node, originalName)) {
|
||||
// fail
|
||||
return;
|
||||
}
|
||||
if (!validatePredefinedFormat(config, name, node, originalName, modifiers)) {
|
||||
// fail
|
||||
return;
|
||||
}
|
||||
// it's valid for this config, so we don't need to check any more configs
|
||||
return;
|
||||
}
|
||||
};
|
||||
// centralizes the logic for formatting the report data
|
||||
function formatReportData({ affixes, formats, originalName, processedName, position, custom, count, }) {
|
||||
var _a;
|
||||
return {
|
||||
type: (0, shared_1.selectorTypeToMessageString)(type),
|
||||
name: originalName,
|
||||
processedName,
|
||||
position,
|
||||
count,
|
||||
affixes: affixes === null || affixes === void 0 ? void 0 : affixes.join(', '),
|
||||
formats: formats === null || formats === void 0 ? void 0 : formats.map(f => enums_1.PredefinedFormats[f]).join(', '),
|
||||
regex: (_a = custom === null || custom === void 0 ? void 0 : custom.regex) === null || _a === void 0 ? void 0 : _a.toString(),
|
||||
regexMatch: (custom === null || custom === void 0 ? void 0 : custom.match) === true
|
||||
? 'match'
|
||||
: (custom === null || custom === void 0 ? void 0 : custom.match) === false
|
||||
? 'not match'
|
||||
: null,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @returns the name with the underscore removed, if it is valid according to the specified underscore option, null otherwise
|
||||
*/
|
||||
function validateUnderscore(position, config, name, node, originalName) {
|
||||
const option = position === 'leading'
|
||||
? config.leadingUnderscore
|
||||
: config.trailingUnderscore;
|
||||
if (!option) {
|
||||
return name;
|
||||
}
|
||||
const hasSingleUnderscore = position === 'leading'
|
||||
? () => name.startsWith('_')
|
||||
: () => name.endsWith('_');
|
||||
const trimSingleUnderscore = position === 'leading'
|
||||
? () => name.slice(1)
|
||||
: () => name.slice(0, -1);
|
||||
const hasDoubleUnderscore = position === 'leading'
|
||||
? () => name.startsWith('__')
|
||||
: () => name.endsWith('__');
|
||||
const trimDoubleUnderscore = position === 'leading'
|
||||
? () => name.slice(2)
|
||||
: () => name.slice(0, -2);
|
||||
switch (option) {
|
||||
// ALLOW - no conditions as the user doesn't care if it's there or not
|
||||
case enums_1.UnderscoreOptions.allow: {
|
||||
if (hasSingleUnderscore()) {
|
||||
return trimSingleUnderscore();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
case enums_1.UnderscoreOptions.allowDouble: {
|
||||
if (hasDoubleUnderscore()) {
|
||||
return trimDoubleUnderscore();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
case enums_1.UnderscoreOptions.allowSingleOrDouble: {
|
||||
if (hasDoubleUnderscore()) {
|
||||
return trimDoubleUnderscore();
|
||||
}
|
||||
if (hasSingleUnderscore()) {
|
||||
return trimSingleUnderscore();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
// FORBID
|
||||
case enums_1.UnderscoreOptions.forbid: {
|
||||
if (hasSingleUnderscore()) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unexpectedUnderscore',
|
||||
data: formatReportData({
|
||||
originalName,
|
||||
position,
|
||||
count: 'one',
|
||||
}),
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
// REQUIRE
|
||||
case enums_1.UnderscoreOptions.require: {
|
||||
if (!hasSingleUnderscore()) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missingUnderscore',
|
||||
data: formatReportData({
|
||||
originalName,
|
||||
position,
|
||||
count: 'one',
|
||||
}),
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return trimSingleUnderscore();
|
||||
}
|
||||
case enums_1.UnderscoreOptions.requireDouble: {
|
||||
if (!hasDoubleUnderscore()) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missingUnderscore',
|
||||
data: formatReportData({
|
||||
originalName,
|
||||
position,
|
||||
count: 'two',
|
||||
}),
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return trimDoubleUnderscore();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @returns the name with the affix removed, if it is valid according to the specified affix option, null otherwise
|
||||
*/
|
||||
function validateAffix(position, config, name, node, originalName) {
|
||||
const affixes = config[position];
|
||||
if (!affixes || affixes.length === 0) {
|
||||
return name;
|
||||
}
|
||||
for (const affix of affixes) {
|
||||
const hasAffix = position === 'prefix' ? name.startsWith(affix) : name.endsWith(affix);
|
||||
const trimAffix = position === 'prefix'
|
||||
? () => name.slice(affix.length)
|
||||
: () => name.slice(0, -affix.length);
|
||||
if (hasAffix) {
|
||||
// matches, so trim it and return
|
||||
return trimAffix();
|
||||
}
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missingAffix',
|
||||
data: formatReportData({
|
||||
originalName,
|
||||
position,
|
||||
affixes,
|
||||
}),
|
||||
});
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @returns true if the name is valid according to the `regex` option, false otherwise
|
||||
*/
|
||||
function validateCustom(config, name, node, originalName) {
|
||||
const custom = config.custom;
|
||||
if (!custom) {
|
||||
return true;
|
||||
}
|
||||
const result = custom.regex.test(name);
|
||||
if (custom.match && result) {
|
||||
return true;
|
||||
}
|
||||
if (!custom.match && !result) {
|
||||
return true;
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'satisfyCustom',
|
||||
data: formatReportData({
|
||||
originalName,
|
||||
custom,
|
||||
}),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @returns true if the name is valid according to the `format` option, false otherwise
|
||||
*/
|
||||
function validatePredefinedFormat(config, name, node, originalName, modifiers) {
|
||||
const formats = config.format;
|
||||
if (formats === null || formats.length === 0) {
|
||||
return true;
|
||||
}
|
||||
if (!modifiers.has(enums_1.Modifiers.requiresQuotes)) {
|
||||
for (const format of formats) {
|
||||
const checker = format_1.PredefinedFormatToCheckFunction[format];
|
||||
if (checker(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: originalName === name
|
||||
? 'doesNotMatchFormat'
|
||||
: 'doesNotMatchFormatTrimmed',
|
||||
data: formatReportData({
|
||||
originalName,
|
||||
processedName: name,
|
||||
formats,
|
||||
}),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.createValidator = createValidator;
|
||||
const SelectorsAllowedToHaveTypes = enums_1.Selectors.variable |
|
||||
enums_1.Selectors.parameter |
|
||||
enums_1.Selectors.classProperty |
|
||||
enums_1.Selectors.objectLiteralProperty |
|
||||
enums_1.Selectors.typeProperty |
|
||||
enums_1.Selectors.parameterProperty |
|
||||
enums_1.Selectors.accessor;
|
||||
function isCorrectType(node, config, context, selector) {
|
||||
if (config.types === null) {
|
||||
return true;
|
||||
}
|
||||
if ((SelectorsAllowedToHaveTypes & selector) === 0) {
|
||||
return true;
|
||||
}
|
||||
const { esTreeNodeToTSNodeMap, program } = util.getParserServices(context);
|
||||
const checker = program.getTypeChecker();
|
||||
const tsNode = esTreeNodeToTSNodeMap.get(node);
|
||||
const type = checker
|
||||
.getTypeAtLocation(tsNode)
|
||||
// remove null and undefined from the type, as we don't care about it here
|
||||
.getNonNullableType();
|
||||
for (const allowedType of config.types) {
|
||||
switch (allowedType) {
|
||||
case enums_1.TypeModifiers.array:
|
||||
if (isAllTypesMatch(type, t => checker.isArrayType(t) || checker.isTupleType(t))) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case enums_1.TypeModifiers.function:
|
||||
if (isAllTypesMatch(type, t => t.getCallSignatures().length > 0)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case enums_1.TypeModifiers.boolean:
|
||||
case enums_1.TypeModifiers.number:
|
||||
case enums_1.TypeModifiers.string: {
|
||||
const typeString = checker.typeToString(
|
||||
// this will resolve things like true => boolean, 'a' => string and 1 => number
|
||||
checker.getWidenedType(checker.getBaseTypeOfLiteralType(type)));
|
||||
const allowedTypeString = enums_1.TypeModifiers[allowedType];
|
||||
if (typeString === allowedTypeString) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @returns `true` if the type (or all union types) in the given type return true for the callback
|
||||
*/
|
||||
function isAllTypesMatch(type, cb) {
|
||||
if (type.isUnion()) {
|
||||
return type.types.every(t => cb(t));
|
||||
}
|
||||
return cb(type);
|
||||
}
|
||||
//# sourceMappingURL=validator.js.map
|
||||
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/validator.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/validator.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user