Regenerating node_modules

This commit is contained in:
Chris Raynor 2020-09-14 10:42:37 +01:00
parent 09b4a82c83
commit c96f84308a
No known key found for this signature in database
GPG key ID: 579A1FBC36FDA261
5488 changed files with 487362 additions and 60779 deletions

File diff suppressed because it is too large Load diff

21
node_modules/@typescript-eslint/eslint-plugin/LICENSE generated vendored Normal file
View 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.

224
node_modules/@typescript-eslint/eslint-plugin/README.md generated vendored Normal file
View file

@ -0,0 +1,224 @@
<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](../../docs/getting-started/linting/README.md)**
- **[You can find our FAQ / Troubleshooting docs here](../../docs/getting-started/linting/FAQ.md)**
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"]
}
```
**Note: Make sure to use `eslint --ext .js,.ts` since by [default](https://eslint.org/docs/user-guide/command-line-interface#--ext) `eslint` will only search for `.js` files.**
### 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 simply 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](../../docs/getting-started/linting/TYPED_LINTING.md)**
## Supported Rules
<!-- begin base rule list -->
**Key**: :heavy_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information
| Name | Description | :heavy_check_mark: | :wrench: | :thought_balloon: |
| --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | ----------------- |
| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive | :heavy_check_mark: | | |
| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array<T>` for arrays | | :wrench: | |
| [`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md) | Disallows awaiting a value that is not a Thenable | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/ban-ts-comment`](./docs/rules/ban-ts-comment.md) | Bans `// @ts-<directive>` comments from being used or requires descriptions after directive | :heavy_check_mark: | | |
| [`@typescript-eslint/ban-tslint-comment`](./docs/rules/ban-tslint-comment.md) | Bans `// tslint:<rule-flag>` comments from being used | | :wrench: | |
| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Bans specific types from being used | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/class-literal-property-style`](./docs/rules/class-literal-property-style.md) | Ensures that literals on classes are exposed in a consistent style | | :wrench: | |
| [`@typescript-eslint/consistent-type-assertions`](./docs/rules/consistent-type-assertions.md) | Enforces consistent usage of type assertions | | | |
| [`@typescript-eslint/consistent-type-definitions`](./docs/rules/consistent-type-definitions.md) | Consistent with type definition either `interface` or `type` | | :wrench: | |
| [`@typescript-eslint/consistent-type-imports`](./docs/rules/consistent-type-imports.md) | Enforces 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 | :heavy_check_mark: | | |
| [`@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) | Enforces using a particular method signature syntax. | | :wrench: | |
| [`@typescript-eslint/naming-convention`](./docs/rules/naming-convention.md) | Enforces naming conventions for everything across a codebase | | | :thought_balloon: |
| [`@typescript-eslint/no-base-to-string`](./docs/rules/no-base-to-string.md) | Requires that `.toString()` is only called on objects which provide useful information when stringified | | | :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 | | :wrench: | |
| [`@typescript-eslint/no-dynamic-delete`](./docs/rules/no-dynamic-delete.md) | Disallow the delete operator with computed key expressions | | :wrench: | |
| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/no-extra-non-null-assertion`](./docs/rules/no-extra-non-null-assertion.md) | Disallow extra non-null assertion | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces | | | |
| [`@typescript-eslint/no-floating-promises`](./docs/rules/no-floating-promises.md) | Requires Promise-like values to be handled appropriately | :heavy_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 | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-implicit-any-catch`](./docs/rules/no-implicit-any-catch.md) | Disallow usage of the implicit `any` type in catch clauses | | :wrench: | |
| [`@typescript-eslint/no-implied-eval`](./docs/rules/no-implied-eval.md) | Disallow the use of `eval()`-like methods | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/no-invalid-void-type`](./docs/rules/no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | | | |
| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor` | :heavy_check_mark: | | |
| [`@typescript-eslint/no-misused-promises`](./docs/rules/no-misused-promises.md) | Avoid using promises in places not designed to handle them | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces | :heavy_check_mark: | | |
| [`@typescript-eslint/no-non-null-asserted-optional-chain`](./docs/rules/no-non-null-asserted-optional-chain.md) | Disallows using a non-null assertion after an optional chain expression | :heavy_check_mark: | | |
| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator | :heavy_check_mark: | | |
| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors | | | |
| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` | | | |
| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` | :heavy_check_mark: | | |
| [`@typescript-eslint/no-throw-literal`](./docs/rules/no-throw-literal.md) | Disallow throwing literals as exceptions | | | :thought_balloon: |
| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases | | | |
| [`@typescript-eslint/no-unnecessary-boolean-literal-compare`](./docs/rules/no-unnecessary-boolean-literal-compare.md) | Flags unnecessary equality comparisons against boolean literals | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/no-unnecessary-condition`](./docs/rules/no-unnecessary-condition.md) | Prevents conditionals where the type is always truthy or always falsy | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/no-unnecessary-type-arguments`](./docs/rules/no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :heavy_check_mark: | :wrench: | :thought_balloon: |
| [`@typescript-eslint/no-unsafe-assignment`](./docs/rules/no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-unsafe-call`](./docs/rules/no-unsafe-call.md) | Disallows calling an any type value | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-unsafe-member-access`](./docs/rules/no-unsafe-member-access.md) | Disallows member access on any typed variables | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-unsafe-return`](./docs/rules/no-unsafe-return.md) | Disallows returning any from a function | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements | :heavy_check_mark: | | |
| [`@typescript-eslint/prefer-as-const`](./docs/rules/prefer-as-const.md) | Prefer usage of `as const` over literal type | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/prefer-enum-initializers`](./docs/rules/prefer-enum-initializers.md) | Prefer initializing each enums member value | | | |
| [`@typescript-eslint/prefer-for-of`](./docs/rules/prefer-for-of.md) | Prefer a for-of loop over a standard for loop if the index is only used to access the array being iterated | | | |
| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures | | :wrench: | |
| [`@typescript-eslint/prefer-includes`](./docs/rules/prefer-includes.md) | Enforce `includes` method over `indexOf` method | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-literal-enum-member`](./docs/rules/prefer-literal-enum-member.md) | Require that all enum members be literal values to prevent unintended enum member name shadow issues | | | |
| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules | :heavy_check_mark: | :wrench: | |
| [`@typescript-eslint/prefer-nullish-coalescing`](./docs/rules/prefer-nullish-coalescing.md) | Enforce the usage of the nullish coalescing operator instead of logical chaining | | | :thought_balloon: |
| [`@typescript-eslint/prefer-optional-chain`](./docs/rules/prefer-optional-chain.md) | Prefer using concise optional chain expressions instead of chained logical ands | | | |
| [`@typescript-eslint/prefer-readonly`](./docs/rules/prefer-readonly.md) | Requires that private members are 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) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: |
| [`@typescript-eslint/prefer-reduce-type-parameter`](./docs/rules/prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | | :wrench: | :thought_balloon: |
| [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Recommends using `// @ts-expect-error` over `// @ts-ignore` | | :wrench: | |
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async | | | :thought_balloon: |
| [`@typescript-eslint/require-array-sort-compare`](./docs/rules/require-array-sort-compare.md) | Requires `Array#sort` calls to always provide a `compareFunction` | | | :thought_balloon: |
| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/restrict-template-expressions`](./docs/rules/restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/strict-boolean-expressions`](./docs/rules/strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | | :thought_balloon: |
| [`@typescript-eslint/switch-exhaustiveness-check`](./docs/rules/switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: |
| [`@typescript-eslint/triple-slash-reference`](./docs/rules/triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :heavy_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) | Requires type annotations to exist | | | |
| [`@typescript-eslint/unbound-method`](./docs/rules/unbound-method.md) | Enforces unbound methods are called with their expected scope | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter | | | |
<!-- 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**: :heavy_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information
| Name | Description | :heavy_check_mark: | :wrench: | :thought_balloon: |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------ | -------- | ----------------- |
| [`@typescript-eslint/brace-style`](./docs/rules/brace-style.md) | Enforce consistent brace style for blocks | | :wrench: | |
| [`@typescript-eslint/comma-spacing`](./docs/rules/comma-spacing.md) | Enforces 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 | | :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 | :heavy_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 | :heavy_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 | :heavy_check_mark: | :wrench: | |
| [`@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 | | | |
| [`@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-shadow`](./docs/rules/no-shadow.md) | Disallow variable declarations from shadowing variables declared in the outer scope | | | |
| [`@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 | :heavy_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 | | | |
| [`@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 | :heavy_check_mark: | | :thought_balloon: |
| [`@typescript-eslint/return-await`](./docs/rules/return-await.md) | Enforces 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-function-paren`](./docs/rules/space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | |
<!-- end extension rule list -->
## Contributing
[See the contributing guide here](../../CONTRIBUTING.md).

View file

@ -0,0 +1,144 @@
"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-spacing': 'off',
'@typescript-eslint/comma-spacing': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': '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',
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'error',
'@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',
'@typescript-eslint/no-implicit-any-catch': 'error',
'@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-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-parameter-properties': 'error',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-require-imports': 'error',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@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-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-var-requires': '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-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',
'space-before-function-paren': 'off',
'@typescript-eslint/space-before-function-paren': '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

View file

@ -0,0 +1 @@
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/configs/all.ts"],"names":[],"mappings":";AAAA,wCA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AE,OAAO;KACjD;CACF,CAAC"}

View 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

View 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"}

View file

@ -0,0 +1,32 @@
"use strict";
module.exports = {
overrides: [
{
files: ['*.ts', '*.tsx'],
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',
},
},
],
};
//# sourceMappingURL=eslint-recommended.js.map

View 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,CAAC;YACxB,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;aACtB;SACF;KACF;CACF,CAAC"}

View file

@ -0,0 +1,26 @@
"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',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': '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',
'@typescript-eslint/prefer-regexp-exec': '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

View 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,oCAAoC,EAAE,OAAO;QAC7C,wCAAwC,EAAE,OAAO;QACjD,kDAAkD,EAAE,OAAO;QAC3D,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,uCAAuC,EAAE,OAAO;QAChD,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,mCAAmC,EAAE,OAAO;KAC7C;CACF,CAAC"}

View file

@ -0,0 +1,35 @@
"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',
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'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',
'@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',
'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

View 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,mDAAmD,EAAE,MAAM;QAC3D,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,mCAAmC,EAAE,OAAO;QAC5C,iCAAiC,EAAE,OAAO;QAC1C,wDAAwD,EAAE,OAAO;QACjE,0CAA0C,EAAE,MAAM;QAClD,kCAAkC,EAAE,OAAO;QAC3C,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"}

View file

@ -0,0 +1,21 @@
"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 recommended_1 = __importDefault(require("./configs/recommended"));
const recommended_requiring_type_checking_1 = __importDefault(require("./configs/recommended-requiring-type-checking"));
const eslint_recommended_1 = __importDefault(require("./configs/eslint-recommended"));
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,
},
};
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,oDAA4B;AAE5B,wDAAgC;AAChC,0DAAkC;AAClC,wEAAgD;AAChD,wHAA6F;AAC7F,sFAA6D;AAE7D,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;KACxE;CACF,CAAC"}

View file

@ -0,0 +1,159 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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',
category: 'Best Practices',
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 experimental_utils_1.AST_NODE_TYPES.ExportDefaultDeclaration:
case experimental_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 experimental_utils_1.AST_NODE_TYPES.TSDeclareFunction:
case experimental_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,
};
}
case experimental_utils_1.AST_NODE_TYPES.TSMethodSignature:
return {
name: util.getNameFromMember(member, sourceCode),
static: isStatic,
callSignature: false,
};
case experimental_utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
return {
name: 'call',
static: isStatic,
callSignature: true,
};
case experimental_utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
return {
name: 'new',
static: isStatic,
callSignature: false,
};
case experimental_utils_1.AST_NODE_TYPES.MethodDefinition:
return {
name: 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);
}
function getMembers(node) {
switch (node.type) {
case experimental_utils_1.AST_NODE_TYPES.ClassBody:
case experimental_utils_1.AST_NODE_TYPES.Program:
case experimental_utils_1.AST_NODE_TYPES.TSModuleBlock:
case experimental_utils_1.AST_NODE_TYPES.TSInterfaceBody:
return node.body;
case experimental_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

View file

@ -0,0 +1 @@
{"version":3,"file":"adjacent-overload-signatures.js","sourceRoot":"","sources":["../../src/rules/adjacent-overload-signatures.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,8CAAgC;AAahC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,8CAA8C;YAC3D,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,OAAO;SACrB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,iBAAiB,EAAE,+CAA+C;SACnE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAA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I,EAAE;wBACnB,UAAU,GAAG,IAAI,CAAC;wBAClB,OAAO;qBACR;oBAED,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAC/C,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CACjC,CAAC;oBACF,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;wBACnD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,MAAM;4BACZ,SAAS,EAAE,mBAAmB;4BAC9B,IAAI,EAAE;gCACJ,IAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI;6BACrD;yBACF,CAAC,CAAC;qBACJ;yBAAM,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;wBACvB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;qBAC1B;oBAED,UAAU,GAAG,MAAM,CAAC;gBACtB,CAAC,CAAC,CAAC;aACJ;QACH,CAAC;QAED,OAAO;YACL,SAAS,EAAE,2BAA2B;YACtC,OAAO,EAAE,2BAA2B;YACpC,aAAa,EAAE,2BAA2B;YAC1C,aAAa,EAAE,2BAA2B;YAC1C,eAAe,EAAE,2BAA2B;SAC7C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,275 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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 experimental_utils_1.AST_NODE_TYPES.Identifier:
case experimental_utils_1.AST_NODE_TYPES.TSAnyKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSBooleanKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSNeverKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSNumberKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSObjectKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSStringKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSSymbolKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSUnknownKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSVoidKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSNullKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSArrayType:
case experimental_utils_1.AST_NODE_TYPES.TSUndefinedKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSThisType:
case experimental_utils_1.AST_NODE_TYPES.TSQualifiedName:
return true;
case experimental_utils_1.AST_NODE_TYPES.TSTypeReference:
if (node.typeName &&
node.typeName.type === experimental_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 experimental_utils_1.AST_NODE_TYPES.TSTypeReference:
return typeNeedsParentheses(node.typeName);
case experimental_utils_1.AST_NODE_TYPES.TSUnionType:
case experimental_utils_1.AST_NODE_TYPES.TSFunctionType:
case experimental_utils_1.AST_NODE_TYPES.TSIntersectionType:
case experimental_utils_1.AST_NODE_TYPES.TSTypeOperator:
case experimental_utils_1.AST_NODE_TYPES.TSInferType:
return true;
case experimental_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: 'Requires using either `T[]` or `Array<T>` for arrays',
category: 'Stylistic Issues',
// too opinionated to be recommended
recommended: false,
},
fixable: 'code',
messages: {
errorStringGeneric: "Array type using '{{type}}[]' is forbidden. Use 'Array<{{type}}>' instead.",
errorStringGenericSimple: "Array type using '{{type}}[]' is forbidden for non-simple types. Use 'Array<{{type}}>' instead.",
errorStringArray: "Array type using 'Array<{{type}}>' is forbidden. Use '{{type}}[]' instead.",
errorStringArraySimple: "Array type using 'Array<{{type}}>' is forbidden for simple types. Use '{{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;
const isArraySimpleOption = defaultOption === 'array-simple' && readonlyOption === 'array-simple';
const isArrayOption = defaultOption === 'array' && readonlyOption === 'array';
const isGenericOption = defaultOption === 'generic' && readonlyOption === 'generic';
/**
* Check if whitespace is needed before this node
* @param node the node to be evaluated.
*/
function requireWhitespaceBefore(node) {
const prevToken = sourceCode.getTokenBefore(node);
if (!prevToken) {
return false;
}
const nextToken = sourceCode.getTokenAfter(prevToken);
if (nextToken && sourceCode.isSpaceBetweenTokens(prevToken, nextToken)) {
return false;
}
return prevToken.type === experimental_utils_1.AST_TOKEN_TYPES.Identifier;
}
/**
* @param node the node to be evaluated.
*/
function getMessageType(node) {
if (node) {
if (node.type === experimental_utils_1.AST_NODE_TYPES.TSParenthesizedType) {
return getMessageType(node.typeAnnotation);
}
if (isSimpleType(node)) {
return sourceCode.getText(node);
}
}
return 'T';
}
/**
* @param node the node to be evaluated
*/
function getTypeOpNodeRange(node) {
if (!node) {
return undefined;
}
const firstToken = sourceCode.getFirstToken(node);
const nextToken = sourceCode.getTokenAfter(firstToken);
return [firstToken.range[0], nextToken.range[0]];
}
return {
TSArrayType(node) {
if (isArrayOption ||
(isArraySimpleOption && isSimpleType(node.elementType))) {
return;
}
const isReadonly = node.parent &&
node.parent.type === experimental_utils_1.AST_NODE_TYPES.TSTypeOperator &&
node.parent.operator === 'readonly';
const isReadonlyGeneric = readonlyOption === 'generic' && defaultOption !== 'generic';
const isReadonlyArray = readonlyOption !== 'generic' && defaultOption === 'generic';
if ((isReadonlyGeneric && !isReadonly) ||
(isReadonlyArray && isReadonly)) {
return;
}
const messageId = defaultOption === 'generic'
? 'errorStringGeneric'
: 'errorStringGenericSimple';
const typeOpNode = isReadonly ? node.parent : null;
context.report({
node: isReadonly ? node.parent : node,
messageId,
data: {
type: getMessageType(node.elementType),
},
fix(fixer) {
const toFix = [
fixer.replaceTextRange([node.range[1] - 2, node.range[1]], '>'),
];
const startText = requireWhitespaceBefore(node);
const typeOpNodeRange = getTypeOpNodeRange(typeOpNode);
if (typeOpNodeRange) {
toFix.unshift(fixer.removeRange(typeOpNodeRange));
}
else {
toFix.push(fixer.insertTextBefore(node, `${startText ? ' ' : ''}`));
}
toFix.push(fixer.insertTextBefore(node, `${isReadonly ? 'Readonly' : ''}Array<`));
if (node.elementType.type === experimental_utils_1.AST_NODE_TYPES.TSParenthesizedType) {
const first = sourceCode.getFirstToken(node.elementType);
const last = sourceCode.getLastToken(node.elementType);
if (!first || !last) {
return null;
}
toFix.push(fixer.remove(first));
toFix.push(fixer.remove(last));
}
return toFix;
},
});
},
TSTypeReference(node) {
var _a;
if (isGenericOption ||
node.typeName.type !== experimental_utils_1.AST_NODE_TYPES.Identifier) {
return;
}
const isReadonlyArrayType = node.typeName.name === 'ReadonlyArray';
const isArrayType = node.typeName.name === 'Array';
if (!(isArrayType || isReadonlyArrayType) ||
(readonlyOption === 'generic' && isReadonlyArrayType) ||
(defaultOption === 'generic' && !isReadonlyArrayType)) {
return;
}
const readonlyPrefix = isReadonlyArrayType ? 'readonly ' : '';
const typeParams = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params;
const messageId = defaultOption === 'array'
? 'errorStringArray'
: 'errorStringArraySimple';
if (!typeParams || typeParams.length === 0) {
// Create an 'any' array
context.report({
node,
messageId,
data: {
type: 'any',
},
fix(fixer) {
return fixer.replaceText(node, `${readonlyPrefix}any[]`);
},
});
return;
}
if (typeParams.length !== 1 ||
(defaultOption === 'array-simple' && !isSimpleType(typeParams[0]))) {
return;
}
const type = typeParams[0];
const parens = typeNeedsParentheses(type);
context.report({
node,
messageId,
data: {
type: getMessageType(type),
},
fix(fixer) {
return [
fixer.replaceTextRange([node.range[0], type.range[0]], `${readonlyPrefix}${parens ? '(' : ''}`),
fixer.replaceTextRange([type.range[1], node.range[1]], parens ? ')[]' : '[]'),
];
},
});
},
};
},
});
//# sourceMappingURL=array-type.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,59 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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: 'Disallows awaiting a value that is not a Thenable',
category: 'Best Practices',
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

View 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,mDAAmD;YAChE,QAAQ,EAAE,gBAAgB;YAC1B,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"}

View file

@ -0,0 +1,141 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.defaultMinimumDescriptionLength = 3;
exports.default = util.createRule({
name: 'ban-ts-comment',
meta: {
type: 'problem',
docs: {
description: 'Bans `// @ts-<directive>` comments from being used or requires descriptions after directive',
category: 'Best Practices',
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.',
},
schema: [
{
type: 'object',
properties: {
'ts-expect-error': {
oneOf: [
{
type: 'boolean',
default: true,
},
{
enum: ['allow-with-description'],
},
],
},
'ts-ignore': {
oneOf: [
{
type: 'boolean',
default: true,
},
{
enum: ['allow-with-description'],
},
],
},
'ts-nocheck': {
oneOf: [
{
type: 'boolean',
default: true,
},
{
enum: ['allow-with-description'],
},
],
},
'ts-check': {
oneOf: [
{
type: 'boolean',
default: true,
},
{
enum: ['allow-with-description'],
},
],
},
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]) {
const tsCommentRegExp = /^\/*\s*@ts-(expect-error|ignore|check|nocheck)(.*)/;
const sourceCode = context.getSourceCode();
return {
Program() {
const comments = sourceCode.getAllComments();
comments.forEach(comment => {
var _a;
if (comment.type !== experimental_utils_1.AST_TOKEN_TYPES.Line) {
return;
}
const [, directive, description] = (_a = tsCommentRegExp.exec(comment.value)) !== null && _a !== void 0 ? _a : [];
const fullDirective = `ts-${directive}`;
const option = options[fullDirective];
if (option === true) {
context.report({
data: { directive },
node: comment,
messageId: 'tsDirectiveComment',
});
}
if (option === 'allow-with-description') {
const { minimumDescriptionLength = exports.defaultMinimumDescriptionLength, } = options;
if (description.trim().length < minimumDescriptionLength) {
context.report({
data: { directive, minimumDescriptionLength },
node: comment,
messageId: 'tsDirectiveCommentRequiresDescription',
});
}
}
});
},
};
},
});
//# sourceMappingURL=ban-ts-comment.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"ban-ts-comment.js","sourceRoot":"","sources":["../../src/rules/ban-ts-comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,8EAAwE;AACxE,8CAAgC;AAUnB,QAAA,+BAA+B,GAAG,CAAC,CAAC;AAMjD,kBAAe,IAAI,CAAC,UAAU,CAAwB;IACpD,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,6FAA6F;YAC/F,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,kBAAkB,EAChB,yEAAyE;YAC3E,qCAAqC,EACnC,gMAAgM;SACnM;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,iBAAiB,EAAE;wBACjB,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,OAAO,EAAE,IAAI;6BACd;4BACD;gCACE,IAAI,EAAE,CAAC,wBAAwB,CAAC;6BACjC;yBACF;qBACF;oBACD,WAAW,EAAE;wBACX,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,OAAO,EAAE,IAAI;6BACd;4BACD;gCACE,IAAI,EAAE,CAAC,wBAAwB,CAAC;6BACjC;yBACF;qBACF;oBACD,YAAY,EAAE;wBACZ,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,OAAO,EAAE,IAAI;6BACd;4BACD;gCACE,IAAI,EAAE,CAAC,wBAAwB,CAAC;6BACjC;yBACF;qBACF;oBACD,UAAU,EAAE;wBACV,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,OAAO,EAAE,IAAI;6BACd;4BACD;gCACE,IAAI,EAAE,CAAC,wBAAwB,CAAC;6BACjC;yBACF;qBACF;oBACD,wBAAwB,EAAE;wBACxB,IAAI,EA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;gCACb,IAAI,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE;gCAC7C,IAAI,EAAE,OAAO;gCACb,SAAS,EAAE,uCAAuC;6BACnD,CAAC,CAAC;yBACJ;qBACF;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,75 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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 === experimental_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: 'Bans `// tslint:<rule-flag>` comments from being used',
category: 'Stylistic Issues',
recommended: false,
},
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

View file

@ -0,0 +1 @@
{"version":3,"file":"ban-tslint-comment.js","sourceRoot":"","sources":["../../src/rules/ban-tslint-comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAAwE;AACxE,8CAAgC;AAEhC,eAAe;AACf,iHAAiH;AACjH,MAAM,oBAAoB,GAAG,2DAA2D,CAAC;AAEzF,MAAM,MAAM,GAAG,CACb,IAAY,EACZ,IAAkD,EAC1C,EAAE,CACV,IAAI,KAAK,oCAAe,CAAC,IAAI;IAC3B,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IAC/B,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1C,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,eAAe,EAAE,uCAAuC;SACzD;QACD,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,EAAE;IACl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Binding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
function removeSpaces(str) {
return str.replace(/ /g, '');
}
function stringifyTypeName(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',
},
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.',
].join('\n'),
},
object: {
message: [
'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).',
'Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys.',
].join('\n'),
},
};
exports.TYPE_KEYWORDS = {
bigint: experimental_utils_1.AST_NODE_TYPES.TSBigIntKeyword,
boolean: experimental_utils_1.AST_NODE_TYPES.TSBooleanKeyword,
never: experimental_utils_1.AST_NODE_TYPES.TSNeverKeyword,
null: experimental_utils_1.AST_NODE_TYPES.TSNullKeyword,
number: experimental_utils_1.AST_NODE_TYPES.TSNumberKeyword,
object: experimental_utils_1.AST_NODE_TYPES.TSObjectKeyword,
string: experimental_utils_1.AST_NODE_TYPES.TSStringKeyword,
symbol: experimental_utils_1.AST_NODE_TYPES.TSSymbolKeyword,
undefined: experimental_utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
unknown: experimental_utils_1.AST_NODE_TYPES.TSUnknownKeyword,
void: experimental_utils_1.AST_NODE_TYPES.TSVoidKeyword,
};
exports.default = util.createRule({
name: 'ban-types',
meta: {
type: 'suggestion',
docs: {
description: 'Bans specific types from being used',
category: 'Best Practices',
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 = stringifyTypeName(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);
},
TSTypeReference({ typeName }) {
checkBannedTypes(typeName);
} });
},
});
//# sourceMappingURL=ban-types.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"ban-types.js","sourceRoot":"","sources":["../../src/rules/ban-types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,8EAI+C;AAC/C,8CAAgC;AAqBhC,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,iBAAiB,CACxB,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,OA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AAC,CAAC,GAAG,CAAC,IAAmB,EAAQ,EAAE,CAC1D,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;aACnC;YAED,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,CACH,CAAC;QAEF,uCACK,gBAAgB,KAEnB,aAAa,CAAC,IAAI;gBAChB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;oBACvB,OAAO;iBACR;gBAED,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YACD,eAAe,CAAC,EAAE,QAAQ,EAAE;gBAC1B,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,94 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const brace_style_1 = __importDefault(require("eslint/lib/rules/brace-style"));
const util_1 = require("../util");
exports.default = util_1.createRule({
name: 'brace-style',
meta: {
type: 'layout',
docs: {
description: 'Enforce consistent brace style for blocks',
category: 'Stylistic Issues',
recommended: false,
extendsBaseRule: true,
},
messages: brace_style_1.default.meta.messages,
fixable: brace_style_1.default.meta.fixable,
schema: brace_style_1.default.meta.schema,
},
defaultOptions: ['1tbs'],
create(context) {
const [style, { allowSingleLine } = { allowSingleLine: false },] = context.options;
const isAllmanStyle = style === 'allman';
const sourceCode = context.getSourceCode();
const rules = brace_style_1.default.create(context);
/**
* Checks a pair of curly brackets based on the user's config
*/
function validateCurlyPair(openingCurlyToken, closingCurlyToken) {
if (allowSingleLine &&
util_1.isTokenOnSameLine(openingCurlyToken, closingCurlyToken)) {
return;
}
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurlyToken);
const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurlyToken);
const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurlyToken);
if (!isAllmanStyle &&
!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 &&
util_1.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurlyToken)) {
context.report({
node: openingCurlyToken,
messageId: 'sameLineOpen',
fix: fixer => fixer.insertTextBefore(openingCurlyToken, '\n'),
});
}
if (util_1.isTokenOnSameLine(openingCurlyToken, tokenAfterOpeningCurly) &&
tokenAfterOpeningCurly !== closingCurlyToken) {
context.report({
node: openingCurlyToken,
messageId: 'blockSameLine',
fix: fixer => fixer.insertTextAfter(openingCurlyToken, '\n'),
});
}
if (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

View file

@ -0,0 +1 @@
{"version":3,"file":"brace-style.js","sourceRoot":"","sources":["../../src/rules/brace-style.ts"],"names":[],"mappings":";;;;;AACA,+EAAoD;AACpD,kCAKiB;AAKjB,kBAAe,iBAAU,CAAsB;IAC7C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE;QACJ,IAAI,E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gB,CAAC,iBAAiB,EAAE,IAAI,CAAC;iBAC9D,CAAC,CAAC;aACJ;QACH,CAAC;QAED,uCACK,KAAK,KACR,gCAAgC,CAC9B,IAAuD;gBAEvD,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAE,CAAC;gBACrD,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAE,CAAC;gBAEpD,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;YACD,iBAAiB,CAAC,IAAI;gBACpB,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAE,CAAC;gBACpD,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CACpD,CAAC;gBAEH,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,114 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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 === experimental_utils_1.AST_NODE_TYPES.Literal) {
return true;
}
if (node.type === experimental_utils_1.AST_NODE_TYPES.TaggedTemplateExpression ||
node.type === experimental_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: 'Ensures that literals on classes are exposed in a consistent style',
category: 'Best Practices',
recommended: false,
},
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]) {
if (style === 'fields') {
return {
MethodDefinition(node) {
if (node.kind !== 'get' ||
!node.value.body ||
!node.value.body.body.length) {
return;
}
const [statement] = node.value.body.body;
if (statement.type !== experimental_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);
},
});
},
};
}
return {
ClassProperty(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

View file

@ -0,0 +1 @@
{"version":3,"file":"class-literal-property-style.js","sourceRoot":"","sources":["../../src/rules/class-literal-property-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,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,mCAAc,CAAC,OAAO,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IACE,IAAI,CAAC,IAAI,KAAK,mCAAc,CAAC,wBAAwB;QACrD,IAAI,CAAC,IAAI,KAAK,mCAAc,CAAC,eAAe,EAC5C;QACA,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;KACzE;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,oEAAoE;YACtE,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,gBAAgB,EAAE,mDAAmD;YACrE,iBAAiB,EAAE,2CAA2C;SAC/D;QACD,MAAM,EAAE,CAAC,EA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AAQ,CAAC,GAAG,CAAC;4BAE9C,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBACvC,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;SACH;QAED,OAAO;YACL,aAAa,CAAC,IAA4B;gBACxC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE;oBAClC,OAAO;iBACR;gBAED,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;gBAEvB,IAAI,CAAC,KAAK,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;oBACxC,OAAO;iBACR;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,IAAI,CAAC,GAAG;oBACd,SAAS,EAAE,mBAAmB;oBAC9B,GAAG,CAAC,KAAK;wBACP,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;wBAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;wBAE1C,IAAI,IAAI,GAAG,EAAE,CAAC;wBAEd,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,KAAK,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;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,141 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util_1 = require("../util");
exports.default = util_1.createRule({
name: 'comma-spacing',
meta: {
type: 'suggestion',
docs: {
description: 'Enforces consistent spacing before and after commas',
category: 'Stylistic Issues',
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 && 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 param = node.params[node.params.length - 1];
const afterToken = sourceCode.getTokenAfter(param);
if (afterToken && 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 &&
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 && util_1.isClosingParenToken(nextToken)) {
return;
}
if (!spaceAfter && nextToken && nextToken.type === experimental_utils_1.AST_TOKEN_TYPES.Line) {
return;
}
if (nextToken &&
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 (!util_1.isCommaToken(token)) {
return;
}
const prevToken = tokensAndComments[i - 1];
const nextToken = tokensAndComments[i + 1];
validateCommaSpacing(token, util_1.isCommaToken(prevToken) || ignoredTokens.has(token)
? null
: prevToken, util_1.isCommaToken(nextToken) || ignoredTokens.has(token)
? null
: nextToken);
});
},
};
},
});
//# sourceMappingURL=comma-spacing.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"comma-spacing.js","sourceRoot":"","sources":["../../src/rules/comma-spacing.ts"],"names":[],"mappings":";;AAAA,8EAG+C;AAC/C,kCAKiB;AAUjB,kBAAe,iBAAU,CAAsB;IAC7C,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,qDAAqD;YAClE,QAAQ,EAAE,kBAAkB;YAC5B,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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,OAAO;qBACb;oBACD,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY;oBAChD,GAAG,EAAE,KAAK,CAAC,EAAE,CACX,UAAU;wBACR,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,EAAE,GAAG,CAAC;wBACxC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CACpB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACzC,EAAE,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,mBAAY,CAAC,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,mBAAY,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;wBACjD,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,SAAS,EACb,mBAAY,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;wBACjD,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,SAAS,CACd,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,153 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
exports.default = util.createRule({
name: 'consistent-type-assertions',
meta: {
type: 'suggestion',
docs: {
category: 'Best Practices',
description: 'Enforces consistent usage of type assertions',
recommended: false,
},
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 !== experimental_utils_1.AST_NODE_TYPES.TSTypeReference) {
return false;
}
return (node.typeName.type === experimental_utils_1.AST_NODE_TYPES.Identifier &&
node.typeName.name === 'const');
}
function reportIncorrectAssertionType(node) {
// If this node is `as const`, then don't report an error.
if (isConst(node.typeAnnotation)) {
return;
}
const messageId = options.assertionStyle;
context.report({
node,
messageId,
data: messageId !== 'never'
? { cast: sourceCode.getText(node.typeAnnotation) }
: {},
});
}
function checkType(node) {
switch (node.type) {
case experimental_utils_1.AST_NODE_TYPES.TSAnyKeyword:
case experimental_utils_1.AST_NODE_TYPES.TSUnknownKeyword:
return false;
case experimental_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 === experimental_utils_1.AST_NODE_TYPES.TSQualifiedName);
default:
return true;
}
}
function checkExpression(node) {
if (options.assertionStyle === 'never' ||
options.objectLiteralTypeAssertions === 'allow' ||
node.expression.type !== experimental_utils_1.AST_NODE_TYPES.ObjectExpression) {
return;
}
if (options.objectLiteralTypeAssertions === 'allow-as-parameter' &&
node.parent &&
(node.parent.type === experimental_utils_1.AST_NODE_TYPES.NewExpression ||
node.parent.type === experimental_utils_1.AST_NODE_TYPES.CallExpression ||
node.parent.type === experimental_utils_1.AST_NODE_TYPES.ThrowStatement ||
node.parent.type === experimental_utils_1.AST_NODE_TYPES.AssignmentPattern)) {
return;
}
if (checkType(node.typeAnnotation) &&
node.expression.type === experimental_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

View file

@ -0,0 +1 @@
{"version":3,"file":"consistent-type-assertions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-assertions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,8EAG+C;AAkB/C,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAA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M,CAAC,IAAI,KAAK,mCAAc,CAAC,cAAc;oBAClD,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,mCAAc,CAAC,cAAc;oBAClD,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,mCAAc,CAAC,iBAAiB,CAAC,EACxD;gBACA,OAAO;aACR;YAED,IACE,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC;gBAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,mCAAc,CAAC,gBAAgB,EACxD;gBACA,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,+BAA+B;iBAC3C,CAAC,CAAC;aACJ;QACH,CAAC;QAED,OAAO;YACL,eAAe,CAAC,IAAI;gBAClB,IAAI,OAAO,CAAC,cAAc,KAAK,eAAe,EAAE;oBAC9C,4BAA4B,CAAC,IAAI,CAAC,CAAC;oBACnC,OAAO;iBACR;gBAED,eAAe,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;YACD,cAAc,CAAC,IAAI;gBACjB,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,EAAE;oBACnC,4BAA4B,CAAC,IAAI,CAAC,CAAC;oBACnC,OAAO;iBACR;gBAED,eAAe,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,102 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'consistent-type-definitions',
meta: {
type: 'suggestion',
docs: {
description: 'Consistent with type definition either `interface` or `type`',
category: 'Stylistic Issues',
// too opinionated to be recommended
recommended: false,
},
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();
return {
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(node) {
if (option === 'interface') {
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.getFirstToken(node);
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 === experimental_utils_1.AST_TOKEN_TYPES.Punctuator &&
afterToken.value === ';') {
fixes.push(fixer.remove(afterToken));
}
return fixes;
},
});
}
},
TSInterfaceDeclaration(node) {
if (option === 'type') {
context.report({
node: node.id,
messageId: 'typeOverInterface',
fix(fixer) {
var _a;
const typeNode = (_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.id;
const fixes = [];
const firstToken = sourceCode.getFirstToken(node);
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}`));
});
}
return fixes;
},
});
}
},
};
},
});
//# sourceMappingURL=consistent-type-definitions.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"consistent-type-definitions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-definitions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAI+C;AAC/C,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,8DAA8D;YAChE,QAAQ,EAAE,kBAAkB;YAC5B,oCAAoC;YACpC,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,yCAAyC;YAC5D,iBAAiB,EAAE,yCAAyC;SAC7D;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;aAC5B;SACF;QACD,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,CAAC,WAAW,CAAC;IAC7B,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;QACtB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE3C,OAAO;YACL,6DAA6D,CAC3D,IAAqC;gBAErC,IAAI,MAAM,KAAK,WAAW,EAAE;oBAC1B,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,EAAE;wBACb,SAAS,EAAE,mBAAmB;wBAC9B,GAAG,CAAC,KAAK;;4BACP,MAAM,QAAQ,SAAG,IAAI,CAAC,cAAc,mCAAI,IAAI,CAAC,EAAE,CAAC;4BAChD,MAAM,KAAK,GAAuB,EAAE,CAAC;4BAErC,MAAM,UAAU,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;4BAClD,IAAI,UAAU,EAAE;gCACd,KAAK,CAAC,IAAI,CAAC,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AAC,CAAC,EACvC,KAAK,CACN,CACF,CAAC;6BACH;4BAED,IAAI,IAAI,CAAC,OAAO,EAAE;gCAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oCAC9B,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;oCACpD,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,cAAc,EAAE,CAAC,CACzD,CAAC;gCACJ,CAAC,CAAC,CAAC;6BACJ;4BAED,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,392 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
function isImportToken(token) {
return token.type === experimental_utils_1.AST_TOKEN_TYPES.Keyword && token.value === 'import';
}
function isTypeToken(token) {
return token.type === experimental_utils_1.AST_TOKEN_TYPES.Identifier && token.value === 'type';
}
exports.default = util.createRule({
name: 'consistent-type-imports',
meta: {
type: 'suggestion',
docs: {
description: 'Enforces consistent usage of type imports',
category: 'Stylistic Issues',
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',
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,
});
if (node.importKind === 'type') {
if (!sourceImports.typeOnlyNamedImport &&
node.specifiers.every(specifier => specifier.type === experimental_utils_1.AST_NODE_TYPES.ImportSpecifier)) {
sourceImports.typeOnlyNamedImport = node;
}
return;
}
// if importKind === 'value'
const typeSpecifiers = [];
const valueSpecifiers = [];
const unusedSpecifiers = [];
for (const specifier of node.specifiers) {
const [variable] = context.getDeclaredVariables(specifier);
if (variable.references.length === 0) {
unusedSpecifiers.push(specifier);
}
else {
const onlyHasTypeReferences = variable.references.every(ref => {
if (ref.isValueReference) {
// `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
let parent = ref.identifier.parent;
while (parent) {
if (parent.type === experimental_utils_1.AST_NODE_TYPES.TSTypeQuery) {
return true;
}
// TSTypeQuery must have a TSESTree.EntityName as its child, so we can filter here and break early
if (parent.type !== experimental_utils_1.AST_NODE_TYPES.TSQualifiedName) {
break;
}
parent = parent.parent;
}
return false;
}
return ref.isTypeReference;
});
if (onlyHasTypeReferences) {
typeSpecifiers.push(specifier);
}
else {
valueSpecifiers.push(specifier);
}
}
}
if (typeSpecifiers.length) {
sourceImports.reportValueImports.push({
node,
typeSpecifiers,
valueSpecifiers,
unusedSpecifiers,
});
}
},
'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* fixToTypeImport(fixer, report, sourceImports);
},
});
}
else {
// we have a mixed type/value import, so we need to split them out into multiple exports
const typeImportNames = report.typeSpecifiers.map(specifier => `"${specifier.local.name}"`);
context.report({
node: report.node,
messageId: typeImportNames.length === 1
? 'aImportIsOnlyTypes'
: 'someImportsAreOnlyTypes',
data: {
typeImports: typeImportNames.length === 1
? typeImportNames[0]
: [
typeImportNames.slice(0, -1).join(', '),
typeImportNames.slice(-1)[0],
].join(' and '),
},
*fix(fixer) {
yield* fixToTypeImport(fixer, report, sourceImports);
},
});
}
}
}
},
}
: {
// prefer no type imports
'ImportDeclaration[importKind = "type"]'(node) {
context.report({
node,
messageId: 'valueOverType',
fix(fixer) {
return fixToValueImport(fixer, node);
},
});
},
})), (disallowTypeAnnotations
? {
// disallow `import()` type
TSImportType(node) {
context.report({
node,
messageId: 'noImportTypeAnnotations',
});
},
}
: {}));
function* fixToTypeImport(fixer, report, sourceImports) {
const { node } = report;
const defaultSpecifier = node.specifiers[0].type === experimental_utils_1.AST_NODE_TYPES.ImportDefaultSpecifier
? node.specifiers[0]
: null;
const namespaceSpecifier = node.specifiers[0].type === experimental_utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier
? node.specifiers[0]
: null;
const namedSpecifiers = node.specifiers.filter((specifier) => specifier.type === experimental_utils_1.AST_NODE_TYPES.ImportSpecifier);
if (namespaceSpecifier) {
// e.g.
// import * as types from 'foo'
yield* fixToTypeImportByInsertType(fixer, node, false);
return;
}
else if (defaultSpecifier) {
if (report.typeSpecifiers.includes(defaultSpecifier) &&
namedSpecifiers.length === 0) {
// e.g.
// import Type from 'foo'
yield* fixToTypeImportByInsertType(fixer, node, true);
return;
}
}
else {
if (namedSpecifiers.every(specifier => report.typeSpecifiers.includes(specifier))) {
// e.g.
// import {Type1, Type2} from 'foo'
yield* fixToTypeImportByInsertType(fixer, node, false);
return;
}
}
const typeNamedSpecifiers = namedSpecifiers.filter(specifier => report.typeSpecifiers.includes(specifier));
const fixesNamedSpecifiers = getFixesNamedSpecifiers(typeNamedSpecifiers, namedSpecifiers);
const afterFixes = [];
if (typeNamedSpecifiers.length) {
if (sourceImports.typeOnlyNamedImport) {
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(sourceCode.getFirstToken(sourceImports.typeOnlyNamedImport), sourceImports.typeOnlyNamedImport.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', sourceImports.typeOnlyNamedImport.type));
let insertText = fixesNamedSpecifiers.typeNamedSpecifiersText;
const before = sourceCode.getTokenBefore(closingBraceToken);
if (!util.isCommaToken(before) && !util.isOpeningBraceToken(before)) {
insertText = ',' + insertText;
}
// import type { Already, Type1, Type2 } from 'foo'
// ^^^^^^^^^^^^^ insert
const insertTypeNamedSpecifiers = fixer.insertTextBefore(closingBraceToken, insertText);
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`);
}
}
if (defaultSpecifier &&
report.typeSpecifiers.includes(defaultSpecifier)) {
if (typeNamedSpecifiers.length === namedSpecifiers.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 {
yield fixer.insertTextBefore(node, `import type ${sourceCode.getText(defaultSpecifier)} from ${sourceCode.getText(node.source)};\n`);
// import Type , {...} from 'foo'
// ^^^^^^ remove
yield fixer.remove(defaultSpecifier);
yield fixer.remove(sourceCode.getTokenAfter(defaultSpecifier));
}
}
yield* fixesNamedSpecifiers.removeTypeNamedSpecifiers;
yield* afterFixes;
/**
* Returns information for fixing named specifiers.
*/
function getFixesNamedSpecifiers(typeNamedSpecifiers, allNamedSpecifiers) {
const typeNamedSpecifiersTexts = [];
const removeTypeNamedSpecifiers = [];
if (typeNamedSpecifiers.length === allNamedSpecifiers.length) {
// e.g.
// 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,
};
}
}
function* fixToTypeImportByInsertType(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)};`);
}
}
}
}
function fixToValueImport(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));
return fixer.remove(typeToken);
}
},
});
//# sourceMappingURL=consistent-type-imports.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
exports.default = util_1.createRule({
name: 'default-param-last',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce default parameters to be last',
category: 'Best Practices',
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 === experimental_utils_1.AST_NODE_TYPES.AssignmentPattern ||
node.type === experimental_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 === experimental_utils_1.AST_NODE_TYPES.TSParameterProperty
? current.parameter
: current;
if (isPlainParam(param)) {
hasSeenPlainParam = true;
continue;
}
if (hasSeenPlainParam &&
(isOptionalParam(param) ||
param.type === experimental_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

View file

@ -0,0 +1 @@
{"version":3,"file":"default-param-last.js","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";;AAAA,kCAAqC;AACrC,8EAG+C;AAE/C,kBAAe,iBAAU,CAAC;IACxB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,gBAAgB;YAC1B,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,mCAAc,CAAC,iBAAiB;gBAC9C,IAAI,CAAC,IAAI,KAAK,mCAAc,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,mCAAc,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,mCAAc,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"}

View file

@ -0,0 +1,90 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ts = __importStar(require("typescript"));
const dot_notation_1 = __importDefault(require("eslint/lib/rules/dot-notation"));
const util_1 = require("../util");
exports.default = util_1.createRule({
name: 'dot-notation',
meta: {
type: 'suggestion',
docs: {
description: 'enforce dot notation whenever possible',
category: 'Best Practices',
recommended: false,
extendsBaseRule: true,
requiresTypeChecking: true,
},
schema: [
{
type: 'object',
properties: {
allowKeywords: {
type: 'boolean',
default: true,
},
allowPattern: {
type: 'string',
default: '',
},
allowPrivateClassPropertyAccess: {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
],
fixable: dot_notation_1.default.meta.fixable,
messages: dot_notation_1.default.meta.messages,
},
defaultOptions: [
{
allowPrivateClassPropertyAccess: false,
allowKeywords: true,
allowPattern: '',
},
],
create(context, [options]) {
const rules = dot_notation_1.default.create(context);
const allowPrivateClassPropertyAccess = options.allowPrivateClassPropertyAccess;
const parserServices = util_1.getParserServices(context);
const typeChecker = parserServices.program.getTypeChecker();
return {
MemberExpression(node) {
var _a, _b, _c;
if (allowPrivateClassPropertyAccess && node.computed) {
// for perf reasons - only fetch the symbol if we have to
const objectSymbol = typeChecker.getSymbolAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node.property));
if (((_c = (_b = (_a = objectSymbol === null || objectSymbol === void 0 ? void 0 : objectSymbol.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) ===
ts.SyntaxKind.PrivateKeyword) {
return;
}
}
rules.MemberExpression(node);
},
};
},
});
//# sourceMappingURL=dot-notation.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"dot-notation.js","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,iFAAqD;AACrD,kCAKiB;AAKjB,kBAAe,iBAAU,CAAsB;IAC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AC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CACxD,CAAC;oBACF,IACE,mBAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,eAAe,4CAAK,CAAC,2CAAG,SAAS,0CAAG,CAAC,EAAE,IAAI;wBACzD,EAAE,CAAC,UAAU,CAAC,cAAc,EAC5B;wBACA,OAAO;qBACR;iBACF;gBACD,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,97 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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',
category: 'Stylistic Issues',
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',
},
},
additionalProperties: false,
},
],
},
defaultOptions: [
{
allowExpressions: false,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: true,
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
},
],
create(context, [options]) {
const sourceCode = context.getSourceCode();
return {
'ArrowFunctionExpression, FunctionExpression'(node) {
if (options.allowConciseArrowFunctionExpressionsStartingWithVoid &&
node.type === experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
node.expression &&
node.body.type === experimental_utils_1.AST_NODE_TYPES.UnaryExpression &&
node.body.operator === 'void') {
return;
}
explicitReturnTypeUtils_1.checkFunctionExpressionReturnType(node, options, sourceCode, loc => context.report({
node,
loc,
messageId: 'missingReturnType',
}));
},
FunctionDeclaration(node) {
explicitReturnTypeUtils_1.checkFunctionReturnType(node, options, sourceCode, loc => context.report({
node,
loc,
messageId: 'missingReturnType',
}));
},
};
},
});
//# sourceMappingURL=explicit-function-return-type.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,8CAAgC;AAChC,6EAGyC;AAazC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8DAA8D;YAChE,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,kCAAkC;SACtD;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,gBAAgB,EAAE;wBAChB,IAAI,EAAE,SAAS;qBAChB;oBACD,6BAA6B,EAAE;wBAC7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CACF,CAAC,CAAC"}

View file

@ -0,0 +1,209 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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',
category: 'Stylistic Issues',
// 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: node,
messageId: messageId,
data: {
type: nodeType,
name: nodeName,
},
fix: fix,
});
}
/**
* Checks if a method declaration has an accessibility modifier.
* @param methodDefinition The node representing a MethodDefinition.
*/
function checkMethodAccessibilityModifier(methodDefinition) {
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 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 === experimental_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 classProperty The node representing a ClassProperty.
*/
function checkPropertyAccessibilityModifier(classProperty) {
const nodeType = 'class property';
const propertyName = util.getNameFromMember(classProperty, sourceCode);
if (propCheck === 'no-public' &&
classProperty.accessibility === 'public') {
reportIssue('unwantedPublicAccessibility', nodeType, classProperty, propertyName, getUnwantedPublicAccessibilityFixer(classProperty));
}
else if (propCheck === 'explicit' && !classProperty.accessibility) {
reportIssue('missingAccessibility', nodeType, classProperty, 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 !== experimental_utils_1.AST_NODE_TYPES.Identifier &&
node.parameter.type !== experimental_utils_1.AST_NODE_TYPES.AssignmentPattern) {
return;
}
const nodeName = node.parameter.type === experimental_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 {
TSParameterProperty: checkParameterPropertyAccessibilityModifier,
ClassProperty: checkPropertyAccessibilityModifier,
MethodDefinition: checkMethodAccessibilityModifier,
};
},
});
//# sourceMappingURL=explicit-member-accessibility.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"explicit-member-accessibility.js","sourceRoot":"","sources":["../../src/rules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AS,CAAC,IAA4B,CAAC,IAAI,CAAC;YAExD,QAAQ,cAAc,EAAE;gBACtB,KAAK,UAAU,CAAC,CAAC;oBACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;wBACvB,WAAW,CAAC,sBAAsB,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;qBAC/D;oBACD,MAAM;iBACP;gBACD,KAAK,WAAW,CAAC,CAAC;oBAChB,IAAI,IAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE;wBACpD,WAAW,CACT,6BAA6B,EAC7B,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,mCAAmC,CAAC,IAAI,CAAC,CAC1C,CAAC;qBACH;oBACD,MAAM;iBACP;aACF;QACH,CAAC;QAED,OAAO;YACL,mBAAmB,EAAE,2CAA2C;YAChE,aAAa,EAAE,kCAAkC;YACjD,gBAAgB,EAAE,gCAAgC;SACnD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,412 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
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",
category: 'Stylistic Issues',
recommended: 'warn',
},
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 === experimental_utils_1.AST_NODE_TYPES.Identifier) {
context.report({
node: param,
messageId: namedMessageId,
data: { name: param.name },
});
}
else if (param.type === experimental_utils_1.AST_NODE_TYPES.ArrayPattern) {
context.report({
node: param,
messageId: unnamedMessageId,
data: { type: 'Array pattern' },
});
}
else if (param.type === experimental_utils_1.AST_NODE_TYPES.ObjectPattern) {
context.report({
node: param,
messageId: unnamedMessageId,
data: { type: 'Object pattern' },
});
}
else if (param.type === experimental_utils_1.AST_NODE_TYPES.RestElement) {
if (param.argument.type === experimental_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 experimental_utils_1.AST_NODE_TYPES.ArrayPattern:
case experimental_utils_1.AST_NODE_TYPES.Identifier:
case experimental_utils_1.AST_NODE_TYPES.ObjectPattern:
case experimental_utils_1.AST_NODE_TYPES.RestElement:
if (!param.typeAnnotation) {
report('missingArgType', 'missingArgTypeUnnamed');
}
else if (options.allowArgumentsExplicitlyTypedAsAny !== true &&
param.typeAnnotation.typeAnnotation.type ===
experimental_utils_1.AST_NODE_TYPES.TSAnyKeyword) {
report('anyTypedArg', 'anyTypedArgUnnamed');
}
return;
case experimental_utils_1.AST_NODE_TYPES.TSParameterProperty:
return checkParameter(param.parameter);
case experimental_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) {
if (!node || !options.allowedNames || !options.allowedNames.length) {
return false;
}
if (node.type === experimental_utils_1.AST_NODE_TYPES.VariableDeclarator) {
return (node.id.type === experimental_utils_1.AST_NODE_TYPES.Identifier &&
options.allowedNames.includes(node.id.name));
}
else if (node.type === experimental_utils_1.AST_NODE_TYPES.MethodDefinition ||
node.type === experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition) {
if (node.key.type === experimental_utils_1.AST_NODE_TYPES.Literal &&
typeof node.key.value === 'string') {
return options.allowedNames.includes(node.key.value);
}
if (node.key.type === experimental_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 === experimental_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 === experimental_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) ||
!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 (definition.type === 'ImplicitGlobalVariable' ||
definition.type === 'ImportBinding' ||
// eslint-disable-next-line @typescript-eslint/internal/prefer-ast-types-enum
definition.type === 'CatchClause' ||
definition.type === 'Parameter') {
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 experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
case experimental_utils_1.AST_NODE_TYPES.FunctionExpression:
return checkFunctionExpression(node);
case experimental_utils_1.AST_NODE_TYPES.ArrayExpression:
for (const element of node.elements) {
checkNode(element);
}
return;
case experimental_utils_1.AST_NODE_TYPES.ClassProperty:
case experimental_utils_1.AST_NODE_TYPES.TSAbstractClassProperty:
if (node.accessibility === 'private') {
return;
}
return checkNode(node.value);
case experimental_utils_1.AST_NODE_TYPES.ClassDeclaration:
case experimental_utils_1.AST_NODE_TYPES.ClassExpression:
for (const element of node.body.body) {
checkNode(element);
}
return;
case experimental_utils_1.AST_NODE_TYPES.FunctionDeclaration:
return checkFunction(node);
case experimental_utils_1.AST_NODE_TYPES.MethodDefinition:
case experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
if (node.accessibility === 'private') {
return;
}
return checkNode(node.value);
case experimental_utils_1.AST_NODE_TYPES.Identifier:
return followReference(node);
case experimental_utils_1.AST_NODE_TYPES.ObjectExpression:
for (const property of node.properties) {
checkNode(property);
}
return;
case experimental_utils_1.AST_NODE_TYPES.Property:
return checkNode(node.value);
case experimental_utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression:
return checkEmptyBodyFunctionExpression(node);
case experimental_utils_1.AST_NODE_TYPES.VariableDeclaration:
for (const declaration of node.declarations) {
checkNode(declaration);
}
return;
case experimental_utils_1.AST_NODE_TYPES.VariableDeclarator:
return checkNode(node.init);
}
}
/**
* Check whether any ancestor of the provided function has a valid return type.
* This function assumes that the function either:
* - belongs to an exported function chain validated by isExportedHigherOrderFunction
* - is directly exported itself
*/
function ancestorHasReturnType(node) {
let ancestor = node.parent;
// if the ancestor is not a return, then this function was not returned at all, so we can exit early
const isReturnStatement = (ancestor === null || ancestor === void 0 ? void 0 : ancestor.type) === experimental_utils_1.AST_NODE_TYPES.ReturnStatement;
const isBodylessArrow = (ancestor === null || ancestor === void 0 ? void 0 : ancestor.type) === experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
ancestor.body.type !== experimental_utils_1.AST_NODE_TYPES.BlockStatement;
if (!isReturnStatement && !isBodylessArrow) {
return false;
}
while (ancestor) {
switch (ancestor.type) {
case experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
case experimental_utils_1.AST_NODE_TYPES.FunctionExpression:
case experimental_utils_1.AST_NODE_TYPES.FunctionDeclaration:
if (ancestor.returnType) {
return true;
}
// assume
break;
// const x: Foo = () => {};
// Assume that a typed variable types the function expression
case experimental_utils_1.AST_NODE_TYPES.VariableDeclarator:
if (ancestor.id.typeAnnotation) {
return true;
}
break;
}
ancestor = ancestor.parent;
}
return false;
}
function checkEmptyBodyFunctionExpression(node) {
var _a, _b, _c;
const isConstructor = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === experimental_utils_1.AST_NODE_TYPES.MethodDefinition &&
node.parent.kind === 'constructor';
const isSetAccessor = (((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
((_c = node.parent) === null || _c === void 0 ? void 0 : _c.type) === experimental_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) ||
explicitReturnTypeUtils_1.isTypedFunctionExpression(node, options) ||
ancestorHasReturnType(node)) {
return;
}
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.parent) || ancestorHasReturnType(node)) {
return;
}
explicitReturnTypeUtils_1.checkFunctionReturnType(node, options, sourceCode, loc => {
context.report({
node,
loc,
messageId: 'missingReturnType',
});
});
checkParameters(node);
}
},
});
//# sourceMappingURL=explicit-module-boundary-types.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,165 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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',
category: 'Stylistic Issues',
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

View file

@ -0,0 +1 @@
{"version":3,"file":"func-call-spacing.js","sourceRoot":"","sources":["../../src/rules/func-call-spacing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,8CAA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

View 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 = 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

View 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;AASnD;;;;GAIG;AACH,MAAa,gBAAgB;IAA7B;QACU,WAAM,GAAG,mCAAU,EAAa,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"}

View 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

View 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,yDAI4B;AAG5B;;GAEG;AACH,MAAa,aAAa;IAQxB;;;;OAIG;IACH,YAAY,SAAoB,EAAE,UAAkB,EAAE,UAAkB;QACtE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,IAAI,GAAG,IAAI,mCAAgB,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAE7D,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,OAAO,EAAE,C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AAK,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;CACF;AA5QD,sCA4QC"}

View 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

View 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;;;AAKlG;;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,EAAE,CACV,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"}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,412 @@
"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 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const indent_1 = __importDefault(require("eslint/lib/rules/indent"));
const util = __importStar(require("../util"));
const KNOWN_NODES = new Set([
// Class properties aren't yet supported by eslint...
experimental_utils_1.AST_NODE_TYPES.ClassProperty,
// ts keywords
experimental_utils_1.AST_NODE_TYPES.TSAbstractKeyword,
experimental_utils_1.AST_NODE_TYPES.TSAnyKeyword,
experimental_utils_1.AST_NODE_TYPES.TSBooleanKeyword,
experimental_utils_1.AST_NODE_TYPES.TSNeverKeyword,
experimental_utils_1.AST_NODE_TYPES.TSNumberKeyword,
experimental_utils_1.AST_NODE_TYPES.TSStringKeyword,
experimental_utils_1.AST_NODE_TYPES.TSSymbolKeyword,
experimental_utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
experimental_utils_1.AST_NODE_TYPES.TSUnknownKeyword,
experimental_utils_1.AST_NODE_TYPES.TSVoidKeyword,
experimental_utils_1.AST_NODE_TYPES.TSNullKeyword,
// ts specific nodes we want to support
experimental_utils_1.AST_NODE_TYPES.TSAbstractClassProperty,
experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition,
experimental_utils_1.AST_NODE_TYPES.TSArrayType,
experimental_utils_1.AST_NODE_TYPES.TSAsExpression,
experimental_utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSConditionalType,
experimental_utils_1.AST_NODE_TYPES.TSConstructorType,
experimental_utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSDeclareFunction,
experimental_utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
experimental_utils_1.AST_NODE_TYPES.TSEnumDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSEnumMember,
experimental_utils_1.AST_NODE_TYPES.TSExportAssignment,
experimental_utils_1.AST_NODE_TYPES.TSExternalModuleReference,
experimental_utils_1.AST_NODE_TYPES.TSFunctionType,
experimental_utils_1.AST_NODE_TYPES.TSImportType,
experimental_utils_1.AST_NODE_TYPES.TSIndexedAccessType,
experimental_utils_1.AST_NODE_TYPES.TSIndexSignature,
experimental_utils_1.AST_NODE_TYPES.TSInferType,
experimental_utils_1.AST_NODE_TYPES.TSInterfaceBody,
experimental_utils_1.AST_NODE_TYPES.TSInterfaceDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSInterfaceHeritage,
experimental_utils_1.AST_NODE_TYPES.TSIntersectionType,
experimental_utils_1.AST_NODE_TYPES.TSImportEqualsDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSLiteralType,
experimental_utils_1.AST_NODE_TYPES.TSMappedType,
experimental_utils_1.AST_NODE_TYPES.TSMethodSignature,
'TSMinusToken',
experimental_utils_1.AST_NODE_TYPES.TSModuleBlock,
experimental_utils_1.AST_NODE_TYPES.TSModuleDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSNonNullExpression,
experimental_utils_1.AST_NODE_TYPES.TSParameterProperty,
experimental_utils_1.AST_NODE_TYPES.TSParenthesizedType,
'TSPlusToken',
experimental_utils_1.AST_NODE_TYPES.TSPropertySignature,
experimental_utils_1.AST_NODE_TYPES.TSQualifiedName,
'TSQuestionToken',
experimental_utils_1.AST_NODE_TYPES.TSRestType,
experimental_utils_1.AST_NODE_TYPES.TSThisType,
experimental_utils_1.AST_NODE_TYPES.TSTupleType,
experimental_utils_1.AST_NODE_TYPES.TSTypeAnnotation,
experimental_utils_1.AST_NODE_TYPES.TSTypeLiteral,
experimental_utils_1.AST_NODE_TYPES.TSTypeOperator,
experimental_utils_1.AST_NODE_TYPES.TSTypeParameter,
experimental_utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSTypeParameterInstantiation,
experimental_utils_1.AST_NODE_TYPES.TSTypeReference,
experimental_utils_1.AST_NODE_TYPES.TSUnionType,
experimental_utils_1.AST_NODE_TYPES.Decorator,
]);
exports.default = util.createRule({
name: 'indent',
meta: {
type: 'layout',
docs: {
description: 'Enforce consistent indentation',
category: 'Stylistic Issues',
// too opinionated to be recommended
recommended: false,
extendsBaseRule: true,
},
fixable: 'whitespace',
schema: indent_1.default.meta.schema,
messages: (_a = indent_1.default.meta.messages) !== null && _a !== void 0 ? _a : {
wrongIndentation: 'Expected indentation of {{expected}} but found {{actual}}.',
},
},
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 = indent_1.default.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 = experimental_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 === experimental_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: experimental_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: experimental_utils_1.AST_NODE_TYPES.ConditionalExpression,
test: {
type: experimental_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: experimental_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: experimental_utils_1.AST_NODE_TYPES.VariableDeclaration,
kind: 'const',
declarations: [
{
type: experimental_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: experimental_utils_1.AST_NODE_TYPES.CallExpression,
callee: {
type: experimental_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: experimental_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: experimental_utils_1.AST_NODE_TYPES.ClassBody,
body: node.body.map(p => TSPropertySignatureToProperty(p, experimental_utils_1.AST_NODE_TYPES.ClassProperty)),
// 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: experimental_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: experimental_utils_1.AST_NODE_TYPES.ObjectExpression,
properties: [
{
type: experimental_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: experimental_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: experimental_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: experimental_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: experimental_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

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,220 @@
"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_spacing_1 = __importDefault(require("./comma-spacing"));
const no_confusing_non_null_assertion_1 = __importDefault(require("./no-confusing-non-null-assertion"));
const consistent_type_assertions_1 = __importDefault(require("./consistent-type-assertions"));
const consistent_type_definitions_1 = __importDefault(require("./consistent-type-definitions"));
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_dupe_class_members_1 = __importDefault(require("./no-dupe-class-members"));
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_implicit_any_catch_1 = __importDefault(require("./no-implicit-any-catch"));
const no_extraneous_class_1 = __importDefault(require("./no-extraneous-class"));
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_floating_promises_1 = __importDefault(require("./no-floating-promises"));
const no_for_in_array_1 = __importDefault(require("./no-for-in-array"));
const prefer_literal_enum_member_1 = __importDefault(require("./prefer-literal-enum-member"));
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_loss_of_precision_1 = __importDefault(require("./no-loss-of-precision"));
const no_loop_func_1 = __importDefault(require("./no-loop-func"));
const no_magic_numbers_1 = __importDefault(require("./no-magic-numbers"));
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_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_require_imports_1 = __importDefault(require("./no-require-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_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_unused_vars_experimental_1 = __importDefault(require("./no-unused-vars-experimental"));
const no_use_before_define_1 = __importDefault(require("./no-use-before-define"));
const no_useless_constructor_1 = __importDefault(require("./no-useless-constructor"));
const no_var_requires_1 = __importDefault(require("./no-var-requires"));
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_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_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 space_before_function_paren_1 = __importDefault(require("./space-before-function-paren"));
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-spacing': comma_spacing_1.default,
'consistent-type-assertions': consistent_type_assertions_1.default,
'consistent-type-definitions': consistent_type_definitions_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,
'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-dupe-class-members': no_dupe_class_members_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-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-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-require-imports': no_require_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-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-experimental': no_unused_vars_experimental_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-var-requires': no_var_requires_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-parameter-types': prefer_readonly_parameter_types_1.default,
'prefer-readonly': prefer_readonly_1.default,
'prefer-reduce-type-parameter': prefer_reduce_type_parameter_1.default,
'prefer-regexp-exec': prefer_regexp_exec_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,
'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,
'space-before-function-paren': space_before_function_paren_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,
'unbound-method': unbound_method_1.default,
'unified-signatures': unified_signatures_1.default,
indent: indent_1.default,
quotes: quotes_1.default,
semi: semi_1.default,
typedef: typedef_1.default,
};
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"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;IAC9C,iBAAiB,EAAE,yBAAa;IAChC,iBAAiB,EAAE,yBAAa;IAChC,0BAA0B,EAAE,kCAAsB;IAClD,eAAe,EAAE,uBAAW;IAC5B,sBAAsB,EAAE,8BAAkB;IAC1C,iBAAiB,EAAE,yBAAc;IACjC,4BAA4B,EAAE,oCAAuB;IACrD,0BAA0B,EAAE,kCAAsB;IAClD,2BAA2B,EAAE,mCAAuB;IACpD,uBAAuB,EAAE,+BAAmB;IAC5C,iCAAiC,EAAE,yCAA4B;IAC/D,iBAAiB,EAAE,yBAAc;IACjC,8BAA8B,EAAE,sCAAyB;IACzD,oBAAoB,EAAE,4BAAgB;IACtC,gCAAgC,EAAE,wCAA0B;IAC5D,wBAAwB,EAAE,gCAAmB;IAC7C,wBAAwB,EAAE,gCAAoB;IAC9C,4BAA4B,EAAE,oCAAuB;IACrD,eAAe,EAAE,uBAAY;IAC7B,wBAAwB,EAAE,gCAAoB;IAC9C,+BAA+B,EAAE,uCAA2B;IAC5D,cAAc,EAAE,sBAAW;IAC3B,6BAA6B,EAAE,qCAAwB;IACvD,4BAA4B,EAAE,oCAAwB;IACtD,6BAA6B,EAAE,qCAAyB;IACxD,wBAAwB,EAAE,gCAAoB;IAC9C,yBAAyB,EAAE,iCAAqB;IAChD,gBAAgB,EAAE,wBAAa;IAC/B,oBAAoB,EAAE,4BAAiB;IACvC,MAAM,EAAE,gBAAM;IACd,MAAM,EAAE,gBAAM;IACd,IAAI,EAAE,cAAI;IACV,OAAO,EAAE,iBAAO;CACjB,CAAC"}

View file

@ -0,0 +1,47 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const init_declarations_1 = __importDefault(require("eslint/lib/rules/init-declarations"));
const util_1 = require("../util");
exports.default = util_1.createRule({
name: 'init-declarations',
meta: {
type: 'suggestion',
docs: {
description: 'require or disallow initialization in variable declarations',
category: 'Variables',
recommended: false,
extendsBaseRule: true,
},
schema: init_declarations_1.default.meta.schema,
messages: (_a = init_declarations_1.default.meta.messages) !== null && _a !== void 0 ? _a : {
initialized: "Variable '{{idName}}' should be initialized on declaration.",
notInitialized: "Variable '{{idName}}' should not be initialized on declaration.",
},
},
defaultOptions: ['always'],
create(context) {
const rules = init_declarations_1.default.create(context);
const mode = context.options[0] || 'always';
return {
'VariableDeclaration:exit'(node) {
var _a, _b, _c;
if (mode === 'always') {
if (node.declare) {
return;
}
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === experimental_utils_1.AST_NODE_TYPES.TSModuleBlock &&
((_b = node.parent.parent) === null || _b === void 0 ? void 0 : _b.type) === experimental_utils_1.AST_NODE_TYPES.TSModuleDeclaration && ((_c = node.parent.parent) === null || _c === void 0 ? void 0 : _c.declare)) {
return;
}
}
rules['VariableDeclaration:exit'](node);
},
};
},
});
//# sourceMappingURL=init-declarations.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"init-declarations.js","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":";;;;;;AAAA,8EAG+C;AAC/C,2FAA0D;AAC1D,kCAIiB;AAKjB,kBAAe,iBAAU,CAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,6DAA6D;YAC/D,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE,2BAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,QAAE,2BAAQ,CAAC,IAAI,CAAC,QAAQ,mCAAI;YAClC,WAAW,EACT,6DAA6D;YAC/D,cAAc,EACZ,iEAAiE;SACpE;KACF;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,2BAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC;QAE5C,OAAO;YACL,0BAA0B,CAAC,IAAkC;;gBAC3D,IAAI,IAAI,KAAK,QAAQ,EAAE;oBACrB,IAAI,IAAI,CAAC,OAAO,EAAE;wBAChB,OAAO;qBACR;oBACD,IACE,OAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,mCAAc,CAAC,aAAa;wBAClD,OAAA,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,IAAI,MAAK,mCAAc,CAAC,mBAAmB,WAC/D,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,OAAO,CAAA,EAC3B;wBACA,OAAO;qBACR;iBACF;gBAED,KAAK,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,67 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const keyword_spacing_1 = __importDefault(require("eslint/lib/rules/keyword-spacing"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'keyword-spacing',
meta: {
type: 'layout',
docs: {
description: 'Enforce consistent spacing before and after keywords',
category: 'Stylistic Issues',
recommended: false,
extendsBaseRule: true,
},
fixable: 'whitespace',
schema: keyword_spacing_1.default.meta.schema,
messages: (_a = keyword_spacing_1.default.meta.messages) !== null && _a !== void 0 ? _a : {
expectedBefore: 'Expected space(s) before "{{value}}".',
expectedAfter: 'Expected space(s) after "{{value}}".',
unexpectedBefore: 'Unexpected space(s) before "{{value}}".',
unexpectedAfter: 'Unexpected space(s) after "{{value}}".',
},
},
defaultOptions: [{}],
create(context) {
const sourceCode = context.getSourceCode();
const baseRules = keyword_spacing_1.default.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 = experimental_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

View file

@ -0,0 +1 @@
{"version":3,"file":"keyword-spacing.js","sourceRoot":"","sources":["../../src/rules/keyword-spacing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8EAAwE;AACxE,uFAAwD;AACxD,8CAAgC;AAKhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,E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object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const lines_between_class_members_1 = __importDefault(require("eslint/lib/rules/lines-between-class-members"));
const util = __importStar(require("../util"));
const schema = util.deepMerge(Object.assign({}, lines_between_class_members_1.default.meta.schema), {
1: {
exceptAfterOverload: {
type: 'booleean',
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',
category: 'Stylistic Issues',
recommended: false,
extendsBaseRule: true,
},
fixable: 'whitespace',
schema,
messages: (_a = lines_between_class_members_1.default.meta.messages) !== null && _a !== void 0 ? _a : {
never: 'Unexpected blank line between class members.',
always: 'Expected blank line between class members.',
},
},
defaultOptions: [
'always',
{
exceptAfterOverload: true,
exceptAfterSingleLine: false,
},
],
create(context, options) {
var _a;
const rules = lines_between_class_members_1.default.create(context);
const exceptAfterOverload = ((_a = options[1]) === null || _a === void 0 ? void 0 : _a.exceptAfterOverload) && options[0] === 'always';
function isOverload(node) {
return (node.type === experimental_utils_1.AST_NODE_TYPES.MethodDefinition &&
node.value.type === experimental_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

View file

@ -0,0 +1 @@
{"version":3,"file":"lines-between-class-members.js","sourceRoot":"","sources":["../../src/rules/lines-between-class-members.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,+GAAoE;AACpE,8CAAgC;AAKhC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,mBACtB,qCAAQ,CAAC,IAAI,CAAC,MAAM,GACzB;IACE,CAAC,EAAE;QACD,mBAAmB,EAAE;YACnB,IAAI,EAAE,UAAU;YAChB,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,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,MAAM;QACN,QAAQ,QAAE,qCAAQ,CAAC,IAAI,CAAC,QAAQ,mCAAI;YAClC,KAAK,EAAE,8CAA8C;YACrD,MAAM,EAAE,4CAA4C;SACrD;KACF;IACD,cAAc,EAAE;QACd,QAAQ;QACR;YACE,mBAAmB,EAAE,IAAI;YACzB,qBAAqB,EAAE,KAAK;SAC7B;KACF;IACD,MAAM,CAAC,OAAO,EAAE,OAAO;;QACrB,MAAM,KAAK,GAAG,qCAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,mBAAmB,GACvB,OAAA,OAAO,CAAC,CAAC,CAAC,0CAAE,mBAAmB,KAAI,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;QAE7D,SAAS,UAAU,CAAC,IAAmB;YACrC,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,mCAAc,CAAC,gBAAgB;gBAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,mCAAc,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"}

View file

@ -0,0 +1,208 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-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,
};
exports.default = util.createRule({
name: 'member-delimiter-style',
meta: {
type: 'suggestion',
docs: {
description: 'Require a specific member delimiter style for interfaces and type literals',
category: 'Stylistic Issues',
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,
},
}),
additionalProperties: false,
},
],
},
defaultOptions: [
{
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
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 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(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);
},
});
}
}
/**
* Check the member separator being used matches the delimiter.
* @param {ASTNode} node the node to be evaluated.
*/
function checkMemberSeparatorStyle(node) {
const isSingleLine = node.loc.start.line === node.loc.end.line;
const members = node.type === experimental_utils_1.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
const typeOpts = node.type === experimental_utils_1.AST_NODE_TYPES.TSInterfaceBody
? interfaceOptions
: typeLiteralOptions;
const opts = isSingleLine ? typeOpts.singleline : typeOpts.multiline;
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

View file

@ -0,0 +1 @@
{"version":3,"file":"member-delimiter-style.js","sourceRoot":"","sources":["../../src/rules/member-delimiter-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,8CAAgC;AA2BhC,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAA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CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;yBAChD;wBAED,gCAAgC;wBAChC,OAAO,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;oBAC7C,CAAC;iBACF,CAAC,CAAC;aACJ;QACH,CAAC;QAED;;;WAGG;QACH,SAAS,yBAAyB,CAChC,IAAuD;YAEvD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;YAE/D,MAAM,OAAO,GACX,IAAI,CAAC,IAAI,KAAK,mCAAc,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YAE1E,MAAM,QAAQ,GACZ,IAAI,CAAC,IAAI,KAAK,mCAAc,CAAC,eAAe;gBAC1C,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,kBAAkB,CAAC;YACzB,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;YAErE,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBAChC,cAAc,CAAC,MAAM,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,eAAe,EAAE,yBAAyB;YAC1C,aAAa,EAAE,yBAAyB;SACzC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,468 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
const neverConfig = {
type: 'string',
enum: ['never'],
};
const arrayConfig = (memberTypes) => ({
type: 'array',
items: {
enum: memberTypes,
},
});
const objectConfig = (memberTypes) => ({
type: 'object',
properties: {
memberTypes: {
oneOf: [arrayConfig(memberTypes), neverConfig],
},
order: {
type: 'string',
enum: ['alphabetically', 'as-written'],
},
},
additionalProperties: false,
});
exports.defaultOrder = [
// Index signature
'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',
// 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 = ['signature', 'field', 'method', 'constructor'].reduce((all, type) => {
all.push(type);
['public', 'protected', 'private'].forEach(accessibility => {
if (type !== 'signature') {
all.push(`${accessibility}-${type}`); // e.g. `public-field`
}
// Only class instance fields and methods can have decorators attached to them
if (type === 'field' || type === 'method') {
const decoratedMemberType = `${accessibility}-decorated-${type}`;
const decoratedMemberTypeNoAccessibility = `decorated-${type}`;
if (!all.includes(decoratedMemberType)) {
all.push(decoratedMemberType);
}
if (!all.includes(decoratedMemberTypeNoAccessibility)) {
all.push(decoratedMemberTypeNoAccessibility);
}
}
if (type !== 'constructor' && type !== 'signature') {
// There is no `static-constructor` or `instance-constructor` or `abstract-constructor`
['static', 'instance', 'abstract'].forEach(scope => {
if (!all.includes(`${scope}-${type}`)) {
all.push(`${scope}-${type}`);
}
all.push(`${accessibility}-${scope}-${type}`);
});
}
});
return all;
}, []);
const functionExpressions = [
experimental_utils_1.AST_NODE_TYPES.FunctionExpression,
experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
];
/**
* Gets the node type.
*
* @param node the node to be evaluated.
*/
function getNodeType(node) {
// TODO: add missing TSCallSignatureDeclaration
switch (node.type) {
case experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
case experimental_utils_1.AST_NODE_TYPES.MethodDefinition:
return node.kind;
case experimental_utils_1.AST_NODE_TYPES.TSMethodSignature:
return 'method';
case experimental_utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
return 'constructor';
case experimental_utils_1.AST_NODE_TYPES.TSAbstractClassProperty:
case experimental_utils_1.AST_NODE_TYPES.ClassProperty:
return node.value && functionExpressions.includes(node.value.type)
? 'method'
: 'field';
case experimental_utils_1.AST_NODE_TYPES.TSPropertySignature:
return 'field';
case experimental_utils_1.AST_NODE_TYPES.TSIndexSignature:
return 'signature';
default:
return null;
}
}
/**
* 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 experimental_utils_1.AST_NODE_TYPES.TSPropertySignature:
case experimental_utils_1.AST_NODE_TYPES.TSMethodSignature:
case experimental_utils_1.AST_NODE_TYPES.TSAbstractClassProperty:
case experimental_utils_1.AST_NODE_TYPES.ClassProperty:
return util.getNameFromMember(node, sourceCode);
case experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
case experimental_utils_1.AST_NODE_TYPES.MethodDefinition:
return node.kind === 'constructor'
? 'constructor'
: util.getNameFromMember(node, sourceCode);
case experimental_utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
return 'new';
case experimental_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) {
rank = orderConfig.indexOf(stack.shift());
}
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 === experimental_utils_1.AST_NODE_TYPES.TSAbstractClassProperty ||
node.type === experimental_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 (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')) {
memberGroups.push(`${accessibility}-decorated-${type}`);
memberGroups.push(`decorated-${type}`);
}
if (type !== 'constructor') {
// Constructors have no scope
memberGroups.push(`${accessibility}-${scope}-${type}`);
memberGroups.push(`${scope}-${type}`);
}
memberGroups.push(`${accessibility}-${type}`);
}
memberGroups.push(type);
return getRankOrder(memberGroups, orderConfig);
}
/**
* Gets the lowest possible rank 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.
* @param ranks the existing ranks in the object.
* @param target the target rank.
* @param order the current order to be validated.
* @returns the name 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);
}
});
return order[lowest].replace(/-/g, ' ');
}
exports.default = util.createRule({
name: 'member-ordering',
meta: {
type: 'suggestion',
docs: {
description: 'Require a consistent member declaration order',
category: 'Stylistic Issues',
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.
*
* @return True if all members are correctly sorted.
*/
function checkAlphaSort(members) {
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 (name < previousName) {
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;
}
// Check order
if (Array.isArray(memberTypes)) {
const grouped = checkGroupSort(members, memberTypes, supportsModifiers);
if (grouped === null) {
return;
}
if (order === 'alphabetically') {
grouped.some(groupMember => !checkAlphaSort(groupMember));
}
}
else if (order === 'alphabetically') {
checkAlphaSort(members);
}
}
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

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,162 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'method-signature-style',
meta: {
type: 'suggestion',
docs: {
description: 'Enforces using a particular method signature syntax.',
category: 'Best Practices',
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 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 '';
}
return {
TSMethodSignature(methodNode) {
var _a;
if (mode === 'method') {
return;
}
const duplicatedKeyMethodNodes = ((_a = methodNode.parent) === null || _a === void 0 ? void 0 : _a.type) === experimental_utils_1.AST_NODE_TYPES.TSInterfaceBody
? methodNode.parent.body.filter((element) => element.type === experimental_utils_1.AST_NODE_TYPES.TSMethodSignature &&
element !== methodNode &&
getMethodKey(element) === getMethodKey(methodNode))
: [];
if (duplicatedKeyMethodNodes.length > 0) {
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.reduce((str, node, idx, nodes) => {
const params = getMethodParams(node);
const returnType = getMethodReturnType(node);
return `${str}(${params} => ${returnType})${idx !== nodes.length - 1 ? ' & ' : ''}`;
}, '');
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;
}
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}`);
},
});
},
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) !== experimental_utils_1.AST_NODE_TYPES.TSFunctionType) {
return;
}
if (mode === 'property') {
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

View file

@ -0,0 +1 @@
{"version":3,"file":"method-signature-style.js","sourceRoot":"","sources":["../../src/rules/method-signature-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,8CAAgC;AAKhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,E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BACb,IAAI,EAAE,YAAY;oBAClB,SAAS,EAAE,eAAe;oBAC1B,GAAG,EAAE,KAAK,CAAC,EAAE;wBACX,MAAM,GAAG,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;wBACvC,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;wBACzC,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;wBACjD,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;wBAC7C,OAAO,KAAK,CAAC,WAAW,CACtB,YAAY,EACZ,GAAG,GAAG,GAAG,MAAM,KAAK,UAAU,GAAG,SAAS,EAAE,CAC7C,CAAC;oBACJ,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,999 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.selectorTypeToMessageString = void 0;
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
// #region Options Type Config
var PredefinedFormats;
(function (PredefinedFormats) {
PredefinedFormats[PredefinedFormats["camelCase"] = 1] = "camelCase";
PredefinedFormats[PredefinedFormats["strictCamelCase"] = 2] = "strictCamelCase";
PredefinedFormats[PredefinedFormats["PascalCase"] = 4] = "PascalCase";
PredefinedFormats[PredefinedFormats["StrictPascalCase"] = 8] = "StrictPascalCase";
PredefinedFormats[PredefinedFormats["snake_case"] = 16] = "snake_case";
PredefinedFormats[PredefinedFormats["UPPER_CASE"] = 32] = "UPPER_CASE";
})(PredefinedFormats || (PredefinedFormats = {}));
var UnderscoreOptions;
(function (UnderscoreOptions) {
UnderscoreOptions[UnderscoreOptions["forbid"] = 1] = "forbid";
UnderscoreOptions[UnderscoreOptions["allow"] = 2] = "allow";
UnderscoreOptions[UnderscoreOptions["require"] = 4] = "require";
})(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["property"] = 8] = "property";
Selectors[Selectors["parameterProperty"] = 16] = "parameterProperty";
Selectors[Selectors["method"] = 32] = "method";
Selectors[Selectors["accessor"] = 64] = "accessor";
Selectors[Selectors["enumMember"] = 128] = "enumMember";
// typeLike
Selectors[Selectors["class"] = 256] = "class";
Selectors[Selectors["interface"] = 512] = "interface";
Selectors[Selectors["typeAlias"] = 1024] = "typeAlias";
Selectors[Selectors["enum"] = 2048] = "enum";
Selectors[Selectors["typeParameter"] = 4096] = "typeParameter";
})(Selectors || (Selectors = {}));
const SELECTOR_COUNT = util.getEnumNames(Selectors).length;
var MetaSelectors;
(function (MetaSelectors) {
MetaSelectors[MetaSelectors["default"] = -1] = "default";
MetaSelectors[MetaSelectors["variableLike"] = 7] = "variableLike";
MetaSelectors[MetaSelectors["memberLike"] = 248] = "memberLike";
MetaSelectors[MetaSelectors["typeLike"] = 7936] = "typeLike";
})(MetaSelectors || (MetaSelectors = {}));
var Modifiers;
(function (Modifiers) {
Modifiers[Modifiers["const"] = 1] = "const";
Modifiers[Modifiers["readonly"] = 2] = "readonly";
Modifiers[Modifiers["static"] = 4] = "static";
Modifiers[Modifiers["public"] = 8] = "public";
Modifiers[Modifiers["protected"] = 16] = "protected";
Modifiers[Modifiers["private"] = 32] = "private";
Modifiers[Modifiers["abstract"] = 64] = "abstract";
})(Modifiers || (Modifiers = {}));
var TypeModifiers;
(function (TypeModifiers) {
TypeModifiers[TypeModifiers["boolean"] = 1024] = "boolean";
TypeModifiers[TypeModifiers["string"] = 2048] = "string";
TypeModifiers[TypeModifiers["number"] = 4096] = "number";
TypeModifiers[TypeModifiers["function"] = 8192] = "function";
TypeModifiers[TypeModifiers["array"] = 16384] = "array";
})(TypeModifiers || (TypeModifiers = {}));
// #endregion Options Type Config
// #region Schema Config
const UNDERSCORE_SCHEMA = {
type: 'string',
enum: util.getEnumNames(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(PredefinedFormats),
},
additionalItems: false,
},
{
type: 'null',
},
],
},
custom: MATCH_REGEX_SCHEMA,
leadingUnderscore: UNDERSCORE_SCHEMA,
trailingUnderscore: UNDERSCORE_SCHEMA,
prefix: PREFIX_SUFFIX_SCHEMA,
suffix: PREFIX_SUFFIX_SCHEMA,
};
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(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(MetaSelectors),
...util.getEnumNames(Selectors),
],
},
additionalItems: false,
},
}),
modifiers: {
type: 'array',
items: {
type: 'string',
enum: util.getEnumNames(Modifiers),
},
additionalItems: false,
},
types: {
type: 'array',
items: {
type: 'string',
enum: util.getEnumNames(TypeModifiers),
},
additionalItems: false,
},
required: ['selector', 'format'],
additionalProperties: false,
};
}
const SCHEMA = {
type: 'array',
items: {
oneOf: [
selectorsSchema(),
...selectorSchema('default', false, util.getEnumNames(Modifiers)),
...selectorSchema('variableLike', false),
...selectorSchema('variable', true, ['const']),
...selectorSchema('function', false),
...selectorSchema('parameter', true),
...selectorSchema('memberLike', false, [
'private',
'protected',
'public',
'static',
'readonly',
'abstract',
]),
...selectorSchema('property', true, [
'private',
'protected',
'public',
'static',
'readonly',
'abstract',
]),
...selectorSchema('parameterProperty', true, [
'private',
'protected',
'public',
'readonly',
]),
...selectorSchema('method', false, [
'private',
'protected',
'public',
'static',
'abstract',
]),
...selectorSchema('accessor', true, [
'private',
'protected',
'public',
'static',
'abstract',
]),
...selectorSchema('enumMember', false),
...selectorSchema('typeLike', false, ['abstract']),
...selectorSchema('class', false, ['abstract']),
...selectorSchema('interface', false),
...selectorSchema('typeAlias', false),
...selectorSchema('enum', false),
...selectorSchema('typeParameter', false),
],
},
additionalItems: false,
};
// #endregion Schema Config
// This essentially mirrors ESLint's `camelcase` rule
// note that that rule ignores leading and trailing underscores and only checks those in the middle of a variable name
const defaultCamelCaseAllTheThingsConfig = [
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
];
exports.default = util.createRule({
name: 'naming-convention',
meta: {
docs: {
category: 'Variables',
description: 'Enforces naming conventions for everything across a codebase',
recommended: false,
// technically only requires type checking if the user uses "type" modifiers
requiresTypeChecking: true,
},
type: 'suggestion',
messages: {
unexpectedUnderscore: '{{type}} name `{{name}}` must not have a {{position}} underscore.',
missingUnderscore: '{{type}} name `{{name}}` must have a {{position}} underscore.',
missingAffix: '{{type}} name `{{name}}` must have one of the following {{position}}es: {{affixes}}',
satisfyCustom: '{{type}} name `{{name}}` must {{regexMatch}} the RegExp: {{regex}}',
doesNotMatchFormat: '{{type}} name `{{name}}` must match one of the following formats: {{formats}}',
doesNotMatchFormatTrimmed: '{{type}} name `{{name}}` trimmed as `{{processedName}}` must match one of the following formats: {{formats}}',
},
schema: SCHEMA,
},
defaultOptions: defaultCamelCaseAllTheThingsConfig,
create(contextWithoutDefaults) {
const context = contextWithoutDefaults.options &&
contextWithoutDefaults.options.length > 0
? contextWithoutDefaults
: // only apply the defaults when the user provides no config
Object.setPrototypeOf({
options: defaultCamelCaseAllTheThingsConfig,
}, contextWithoutDefaults);
const validators = parseOptions(context);
function handleMember(validator, node, modifiers) {
if (!validator) {
return;
}
const key = node.key;
validator(key, modifiers);
}
function getMemberModifiers(node) {
const modifiers = new Set();
if (node.accessibility) {
modifiers.add(Modifiers[node.accessibility]);
}
else {
modifiers.add(Modifiers.public);
}
if (node.static) {
modifiers.add(Modifiers.static);
}
if ('readonly' in node && node.readonly) {
modifiers.add(Modifiers.readonly);
}
if (node.type === experimental_utils_1.AST_NODE_TYPES.TSAbstractClassProperty ||
node.type === experimental_utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition) {
modifiers.add(Modifiers.abstract);
}
return modifiers;
}
return {
// #region variable
VariableDeclarator(node) {
const validator = validators.variable;
if (!validator) {
return;
}
const identifiers = [];
getIdentifiersFromPattern(node.id, identifiers);
const modifiers = new Set();
const parent = node.parent;
if (parent &&
parent.type === experimental_utils_1.AST_NODE_TYPES.VariableDeclaration &&
parent.kind === 'const') {
modifiers.add(Modifiers.const);
}
identifiers.forEach(i => {
validator(i, modifiers);
});
},
// #endregion
// #region function
'FunctionDeclaration, TSDeclareFunction, FunctionExpression'(node) {
const validator = validators.function;
if (!validator || node.id === null) {
return;
}
validator(node.id);
},
// #endregion function
// #region parameter
'FunctionDeclaration, TSDeclareFunction, FunctionExpression, ArrowFunctionExpression'(node) {
const validator = validators.parameter;
if (!validator) {
return;
}
node.params.forEach(param => {
if (param.type === experimental_utils_1.AST_NODE_TYPES.TSParameterProperty) {
return;
}
const identifiers = [];
getIdentifiersFromPattern(param, identifiers);
identifiers.forEach(i => {
validator(i);
});
});
},
// #endregion parameter
// #region parameterProperty
TSParameterProperty(node) {
const validator = validators.parameterProperty;
if (!validator) {
return;
}
const modifiers = getMemberModifiers(node);
const identifiers = [];
getIdentifiersFromPattern(node.parameter, identifiers);
identifiers.forEach(i => {
validator(i, modifiers);
});
},
// #endregion parameterProperty
// #region property
'Property[computed = false][kind = "init"][value.type != "ArrowFunctionExpression"][value.type != "FunctionExpression"][value.type != "TSEmptyBodyFunctionExpression"]'(node) {
const modifiers = new Set([Modifiers.public]);
handleMember(validators.property, node, modifiers);
},
':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type != "ArrowFunctionExpression"][value.type != "FunctionExpression"][value.type != "TSEmptyBodyFunctionExpression"]'(node) {
const modifiers = getMemberModifiers(node);
handleMember(validators.property, node, modifiers);
},
'TSPropertySignature[computed = false]'(node) {
const modifiers = new Set([Modifiers.public]);
if (node.readonly) {
modifiers.add(Modifiers.readonly);
}
handleMember(validators.property, node, modifiers);
},
// #endregion property
// #region method
[[
'Property[computed = false][kind = "init"][value.type = "ArrowFunctionExpression"]',
'Property[computed = false][kind = "init"][value.type = "FunctionExpression"]',
'Property[computed = false][kind = "init"][value.type = "TSEmptyBodyFunctionExpression"]',
'TSMethodSignature[computed = false]',
].join(', ')](node) {
const modifiers = new Set([Modifiers.public]);
handleMember(validators.method, node, modifiers);
},
[[
':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type = "ArrowFunctionExpression"]',
':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type = "FunctionExpression"]',
':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type = "TSEmptyBodyFunctionExpression"]',
':matches(MethodDefinition, TSAbstractMethodDefinition)[computed = false][kind = "method"]',
].join(', ')](node) {
const modifiers = getMemberModifiers(node);
handleMember(validators.method, node, modifiers);
},
// #endregion method
// #region accessor
'Property[computed = false]:matches([kind = "get"], [kind = "set"])'(node) {
const modifiers = new Set([Modifiers.public]);
handleMember(validators.accessor, node, modifiers);
},
'MethodDefinition[computed = false]:matches([kind = "get"], [kind = "set"])'(node) {
const modifiers = getMemberModifiers(node);
handleMember(validators.accessor, node, modifiers);
},
// #endregion accessor
// #region enumMember
// computed is optional, so can't do [computed = false]
'TSEnumMember[computed != true]'(node) {
const validator = validators.enumMember;
if (!validator) {
return;
}
const id = node.id;
validator(id);
},
// #endregion enumMember
// #region class
'ClassDeclaration, ClassExpression'(node) {
const validator = validators.class;
if (!validator) {
return;
}
const id = node.id;
if (id === null) {
return;
}
const modifiers = new Set();
if (node.abstract) {
modifiers.add(Modifiers.abstract);
}
validator(id, modifiers);
},
// #endregion class
// #region interface
TSInterfaceDeclaration(node) {
const validator = validators.interface;
if (!validator) {
return;
}
validator(node.id);
},
// #endregion interface
// #region typeAlias
TSTypeAliasDeclaration(node) {
const validator = validators.typeAlias;
if (!validator) {
return;
}
validator(node.id);
},
// #endregion typeAlias
// #region enum
TSEnumDeclaration(node) {
const validator = validators.enum;
if (!validator) {
return;
}
validator(node.id);
},
// #endregion enum
// #region typeParameter
'TSTypeParameterDeclaration > TSTypeParameter'(node) {
const validator = validators.typeParameter;
if (!validator) {
return;
}
validator(node.name);
},
};
},
});
function getIdentifiersFromPattern(pattern, identifiers) {
switch (pattern.type) {
case experimental_utils_1.AST_NODE_TYPES.Identifier:
identifiers.push(pattern);
break;
case experimental_utils_1.AST_NODE_TYPES.ArrayPattern:
pattern.elements.forEach(element => {
if (element !== null) {
getIdentifiersFromPattern(element, identifiers);
}
});
break;
case experimental_utils_1.AST_NODE_TYPES.ObjectPattern:
pattern.properties.forEach(property => {
if (property.type === experimental_utils_1.AST_NODE_TYPES.RestElement) {
getIdentifiersFromPattern(property, identifiers);
}
else {
// this is a bit weird, but it's because ESTree doesn't have a new node type
// for object destructuring properties - it just reuses Property...
// https://github.com/estree/estree/blob/9ae284b71130d53226e7153b42f01bf819e6e657/es2015.md#L206-L211
// However, the parser guarantees this is safe (and there is error handling)
getIdentifiersFromPattern(property.value, identifiers);
}
});
break;
case experimental_utils_1.AST_NODE_TYPES.RestElement:
getIdentifiersFromPattern(pattern.argument, identifiers);
break;
case experimental_utils_1.AST_NODE_TYPES.AssignmentPattern:
getIdentifiersFromPattern(pattern.left, identifiers);
break;
case experimental_utils_1.AST_NODE_TYPES.MemberExpression:
// ignore member expressions, as the everything must already be defined
break;
default:
// https://github.com/typescript-eslint/typescript-eslint/issues/1282
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
throw new Error(`Unexpected pattern type ${pattern.type}`);
}
}
function parseOptions(context) {
const normalizedOptions = context.options.map(opt => normalizeOption(opt));
return util.getEnumNames(Selectors).reduce((acc, k) => {
acc[k] = createValidator(k, context, normalizedOptions);
return acc;
}, {});
}
function createValidator(type, context, allConfigs) {
// make sure the "highest priority" configs are checked first
const selectorType = Selectors[type];
const configs = allConfigs
// gather all of the applicable selectors
.filter(c => (c.selector & selectorType) !== 0 ||
c.selector === 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;
}
/*
meta selectors will always be larger numbers than the normal selectors they contain, as they are the sum of all
of the selectors that they contain.
to give normal selectors a higher priority, shift them all SELECTOR_COUNT bits to the left before comparison, so
they are instead always guaranteed to be larger than the meta selectors.
*/
const aSelector = isMetaSelector(a.selector)
? a.selector
: a.selector << SELECTOR_COUNT;
const bSelector = isMetaSelector(b.selector)
? b.selector
: b.selector << SELECTOR_COUNT;
// sort descending - the meta selectors are "least important"
return bSelector - aSelector;
});
return (node, modifiers = new Set()) => {
var _a, _b, _c;
const originalName = node.type === experimental_utils_1.AST_NODE_TYPES.Identifier ? 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)) {
// 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)) {
// 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, }) {
var _a;
return {
type: selectorTypeToMessageString(type),
name: originalName,
processedName,
position,
affixes: affixes === null || affixes === void 0 ? void 0 : affixes.join(', '),
formats: formats === null || formats === void 0 ? void 0 : formats.map(f => 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 hasUnderscore = position === 'leading' ? name.startsWith('_') : name.endsWith('_');
const trimUnderscore = position === 'leading'
? () => name.slice(1)
: () => name.slice(0, -1);
switch (option) {
case UnderscoreOptions.allow:
// no check - the user doesn't care if it's there or not
break;
case UnderscoreOptions.forbid:
if (hasUnderscore) {
context.report({
node,
messageId: 'unexpectedUnderscore',
data: formatReportData({
originalName,
position,
}),
});
return null;
}
break;
case UnderscoreOptions.require:
if (!hasUnderscore) {
context.report({
node,
messageId: 'missingUnderscore',
data: formatReportData({
originalName,
position,
}),
});
return null;
}
}
return hasUnderscore ? trimUnderscore() : name;
}
/**
* @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) {
const formats = config.format;
if (formats === null || formats.length === 0) {
return true;
}
for (const format of formats) {
const checker = PredefinedFormatToCheckFunction[format];
if (checker(name)) {
return true;
}
}
context.report({
node,
messageId: originalName === name
? 'doesNotMatchFormat'
: 'doesNotMatchFormatTrimmed',
data: formatReportData({
originalName,
processedName: name,
formats,
}),
});
return false;
}
}
// #region Predefined Format Functions
/*
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 licence 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 = {
[PredefinedFormats.PascalCase]: isPascalCase,
[PredefinedFormats.StrictPascalCase]: isStrictPascalCase,
[PredefinedFormats.camelCase]: isCamelCase,
[PredefinedFormats.strictCamelCase]: isStrictCamelCase,
[PredefinedFormats.UPPER_CASE]: isUpperCase,
[PredefinedFormats.snake_case]: isSnakeCase,
};
// #endregion Predefined Format Functions
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 MetaSelectors;
}
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 |= Modifiers[mod];
});
(_b = option.types) === null || _b === void 0 ? void 0 : _b.forEach(mod => {
weight |= 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 => PredefinedFormats[f]) : null,
custom: option.custom
? {
regex: new RegExp(option.custom.regex, 'u'),
match: option.custom.match,
}
: null,
leadingUnderscore: option.leadingUnderscore !== undefined
? UnderscoreOptions[option.leadingUnderscore]
: null,
trailingUnderscore: option.trailingUnderscore !== undefined
? 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 => Modifiers[m])) !== null && _d !== void 0 ? _d : null,
types: (_f = (_e = option.types) === null || _e === void 0 ? void 0 : _e.map(m => 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 Object.assign({ selector: selectors
.map(selector => isMetaSelector(selector)
? MetaSelectors[selector]
: Selectors[selector])
.reduce((accumulator, selector) => accumulator | selector) }, normalizedOption);
}
function isCorrectType(node, config, context) {
if (config.types === null) {
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 TypeModifiers.array:
if (isAllTypesMatch(type, t => checker.isArrayType(t) || checker.isTupleType(t))) {
return true;
}
break;
case TypeModifiers.function:
if (isAllTypesMatch(type, t => t.getCallSignatures().length > 0)) {
return true;
}
break;
case TypeModifiers.boolean:
case TypeModifiers.number:
case 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 = 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=naming-convention.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,72 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-array-constructor',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow generic `Array` constructors',
category: 'Stylistic Issues',
recommended: 'error',
extendsBaseRule: true,
},
fixable: 'code',
messages: {
useLiteral: 'The array literal notation [] is preferable.',
},
schema: [],
},
defaultOptions: [],
create(context) {
/**
* Disallow construction of dense arrays using the Array constructor
* @param node node to evaluate
*/
function check(node) {
if (node.arguments.length !== 1 &&
node.callee.type === experimental_utils_1.AST_NODE_TYPES.Identifier &&
node.callee.name === 'Array' &&
!node.typeParameters &&
!util.isOptionalCallExpression(node)) {
context.report({
node,
messageId: 'useLiteral',
fix(fixer) {
if (node.arguments.length === 0) {
return fixer.replaceText(node, '[]');
}
const fullText = context.getSourceCode().getText(node);
const preambleLength = node.callee.range[1] - node.range[0];
return fixer.replaceText(node, `[${fullText.slice(preambleLength + 1, -1)}]`);
},
});
}
}
return {
CallExpression: check,
NewExpression: check,
};
},
});
//# sourceMappingURL=no-array-constructor.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-array-constructor.js","sourceRoot":"","sources":["../../src/rules/no-array-constructor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QACl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AK;YACrB,aAAa,EAAE,KAAK;SACrB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,161 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
var Usefulness;
(function (Usefulness) {
Usefulness[Usefulness["Always"] = 0] = "Always";
Usefulness["Never"] = "will";
Usefulness["Sometimes"] = "may";
})(Usefulness || (Usefulness = {}));
exports.default = util.createRule({
name: 'no-base-to-string',
meta: {
docs: {
description: 'Requires that `.toString()` is only called on objects which provide useful information when stringified',
category: 'Best Practices',
recommended: false,
requiresTypeChecking: true,
},
messages: {
baseToString: "'{{name}} {{certainty}} evaluate to '[object Object]' when stringified.",
},
schema: [
{
type: 'object',
properties: {
ignoredTypeNames: {
type: 'array',
items: {
type: 'string',
},
},
},
additionalProperties: false,
},
],
type: 'suggestion',
},
defaultOptions: [
{
ignoredTypeNames: ['RegExp'],
},
],
create(context, [option]) {
var _a;
const parserServices = util.getParserServices(context);
const typeChecker = parserServices.program.getTypeChecker();
const ignoredTypeNames = (_a = option.ignoredTypeNames) !== null && _a !== void 0 ? _a : [];
function checkExpression(node, type) {
if (node.type === experimental_utils_1.AST_NODE_TYPES.Literal) {
return;
}
const certainty = collectToStringCertainty(type !== null && type !== void 0 ? type : typeChecker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node)));
if (certainty === Usefulness.Always) {
return;
}
context.report({
data: {
certainty,
name: context.getSourceCode().getText(node),
},
messageId: 'baseToString',
node,
});
}
function collectToStringCertainty(type) {
const toString = typeChecker.getPropertyOfType(type, 'toString');
const declarations = toString === null || toString === void 0 ? void 0 : toString.getDeclarations();
if (!toString || !declarations || declarations.length === 0) {
return Usefulness.Always;
}
// Patch for old version TypeScript, the Boolean type definition missing toString()
if (type.flags & ts.TypeFlags.Boolean ||
type.flags & ts.TypeFlags.BooleanLiteral) {
return Usefulness.Always;
}
if (ignoredTypeNames.includes(util.getTypeName(typeChecker, type))) {
return Usefulness.Always;
}
if (declarations.every(({ parent }) => !ts.isInterfaceDeclaration(parent) || parent.name.text !== 'Object')) {
return Usefulness.Always;
}
if (type.isIntersection()) {
for (const subType of type.types) {
const subtypeUsefulness = collectToStringCertainty(subType);
if (subtypeUsefulness === Usefulness.Always) {
return Usefulness.Always;
}
}
return Usefulness.Never;
}
if (!type.isUnion()) {
return Usefulness.Never;
}
let allSubtypesUseful = true;
let someSubtypeUseful = false;
for (const subType of type.types) {
const subtypeUsefulness = collectToStringCertainty(subType);
if (subtypeUsefulness !== Usefulness.Always && allSubtypesUseful) {
allSubtypesUseful = false;
}
if (subtypeUsefulness !== Usefulness.Never && !someSubtypeUseful) {
someSubtypeUseful = true;
}
}
if (allSubtypesUseful && someSubtypeUseful) {
return Usefulness.Always;
}
if (someSubtypeUseful) {
return Usefulness.Sometimes;
}
return Usefulness.Never;
}
return {
'AssignmentExpression[operator = "+="], BinaryExpression[operator = "+"]'(node) {
const leftType = typeChecker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node.left));
const rightType = typeChecker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node.right));
if (util.getTypeName(typeChecker, leftType) === 'string') {
checkExpression(node.right, rightType);
}
else if (util.getTypeName(typeChecker, rightType) === 'string') {
checkExpression(node.left, leftType);
}
},
'CallExpression > MemberExpression.callee > Identifier[name = "toString"].property'(node) {
const memberExpr = node.parent;
checkExpression(memberExpr.object);
},
TemplateLiteral(node) {
if (node.parent &&
node.parent.type === experimental_utils_1.AST_NODE_TYPES.TaggedTemplateExpression) {
return;
}
for (const expression of node.expressions) {
checkExpression(expression);
}
},
};
},
});
//# sourceMappingURL=no-base-to-string.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-base-to-string.js","sourceRoot":"","sources":["../../src/rules/no-base-to-string.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,+CAAiC;AAEjC,8CAAgC;AAEhC,IAAK,UAIJ;AAJD,WAAK,UAAU;IACb,+CAAM,CAAA;IACN,4BAAc,CAAA;IACd,+BAAiB,CAAA;AACnB,CAAC,EAJI,UAAU,KAAV,UAAU,QAId;AASD,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EACT,yGAAyG;YAC3G,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,KAAK;YAClB,oBAAoB,EAAE,IAAI;SAC3B;QACD,QAAQ,EAAE;YACR,YAAY,EACV,yEAAyE;SAC5E;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,gBAAgB,EAAE;wBAChB,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,IAAI,EAAE,YAAY;KACnB;IACD,cAAc,EAAE;QACd;YACE,gBAAgB,EAAE,CAAC,QAAQ,CAAC;SAC7B;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;;QACtB,MAAM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AC"}

View file

@ -0,0 +1,97 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-confusing-non-null-assertion',
meta: {
type: 'problem',
docs: {
description: 'Disallow non-null assertion in locations that may be confusing',
category: 'Stylistic Issues',
recommended: false,
},
fixable: 'code',
messages: {
confusingEqual: 'Confusing combinations of non-null assertion and equal test like "a! == b", which looks very similar to not equal "a !== b"',
confusingAssign: 'Confusing combinations of non-null assertion and equal test like "a! = b", which looks very similar to not equal "a != b"',
notNeedInEqualTest: 'Unnecessary non-null assertion (!) in equal test',
notNeedInAssign: 'Unnecessary non-null assertion (!) in assignment left hand',
wrapUpLeft: 'Wrap up left hand to avoid putting non-null assertion "!" and "=" together',
},
schema: [],
},
defaultOptions: [],
create(context) {
const sourceCode = context.getSourceCode();
return {
'BinaryExpression, AssignmentExpression'(node) {
function isLeftHandPrimaryExpression(node) {
return node.type === experimental_utils_1.AST_NODE_TYPES.TSNonNullExpression;
}
if (node.operator === '==' ||
node.operator === '===' ||
node.operator === '=') {
const isAssign = node.operator === '=';
const leftHandFinalToken = sourceCode.getLastToken(node.left);
const tokenAfterLeft = sourceCode.getTokenAfter(node.left);
if ((leftHandFinalToken === null || leftHandFinalToken === void 0 ? void 0 : leftHandFinalToken.type) === experimental_utils_1.AST_TOKEN_TYPES.Punctuator &&
(leftHandFinalToken === null || leftHandFinalToken === void 0 ? void 0 : leftHandFinalToken.value) === '!' &&
(tokenAfterLeft === null || tokenAfterLeft === void 0 ? void 0 : tokenAfterLeft.value) !== ')') {
if (isLeftHandPrimaryExpression(node.left)) {
context.report({
node,
messageId: isAssign ? 'confusingAssign' : 'confusingEqual',
suggest: [
{
messageId: isAssign
? 'notNeedInAssign'
: 'notNeedInEqualTest',
fix: (fixer) => [
fixer.remove(leftHandFinalToken),
],
},
],
});
}
else {
context.report({
node,
messageId: isAssign ? 'confusingAssign' : 'confusingEqual',
suggest: [
{
messageId: 'wrapUpLeft',
fix: (fixer) => [
fixer.insertTextBefore(node.left, '('),
fixer.insertTextAfter(node.left, ')'),
],
},
],
});
}
}
}
},
};
},
});
//# sourceMappingURL=no-confusing-non-null-assertion.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-confusing-non-null-assertion.js","sourceRoot":"","sources":["../../src/rules/no-confusing-non-null-assertion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAK+C;AAC/C,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,gEAAgE;YAClE,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,cAAc,EACZ,6HAA6H;YAC/H,eAAe,EACb,2HAA2H;YAC7H,kBAAkB,EAAE,kDAAkD;YACtE,eAAe,EACb,4DAA4D;YAC9D,UAAU,EACR,4EAA4E;SAC/E;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,M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;6BAAM;4BACL,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI;gCACJ,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB;gCAC1D,OAAO,EAAE;oCACP;wCACE,SAAS,EAAE,YAAY;wCACvB,GAAG,EAAE,CAAC,KAAK,EAAsB,EAAE,CAAC;4CAClC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;4CACtC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;yCACtC;qCACF;iCACF;6BACF,CAAC,CAAC;yBACJ;qBACF;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,55 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const no_dupe_class_members_1 = __importDefault(require("eslint/lib/rules/no-dupe-class-members"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-dupe-class-members',
meta: {
type: 'problem',
docs: {
description: 'Disallow duplicate class members',
category: 'Possible Errors',
recommended: false,
extendsBaseRule: true,
},
schema: no_dupe_class_members_1.default.meta.schema,
messages: no_dupe_class_members_1.default.meta.messages,
},
defaultOptions: [],
create(context) {
const rules = no_dupe_class_members_1.default.create(context);
return Object.assign(Object.assign({}, rules), { MethodDefinition(node) {
if (node.computed) {
return;
}
if (node.value.type === experimental_utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression) {
return;
}
return rules.MethodDefinition(node);
} });
},
});
//# sourceMappingURL=no-dupe-class-members.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-dupe-class-members.js","sourceRoot":"","sources":["../../src/rules/no-dupe-class-members.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8EAAuE;AACvE,mGAA8D;AAC9D,8CAAgC;AAKhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE,+BAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,+BAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,+BAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,uCACK,KAAK,KACR,gBAAgB,CAAC,IAAI;gBACnB,IAAI,IAAI,CAAC,QAAQ,EAAE;oBACjB,OAAO;iBACR;gBAED,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,mCAAc,CAAC,6BAA6B,EAAE;oBACpE,OAAO;iBACR;gBAED,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,91 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const tsutils = __importStar(require("tsutils"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-dynamic-delete',
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow the delete operator with computed key expressions',
recommended: false,
},
fixable: 'code',
messages: {
dynamicDelete: 'Do not delete dynamically computed property keys.',
},
schema: [],
type: 'suggestion',
},
defaultOptions: [],
create(context) {
function createFixer(member) {
if (member.property.type === experimental_utils_1.AST_NODE_TYPES.Literal &&
typeof member.property.value === 'string') {
return createPropertyReplacement(member.property, `.${member.property.value}`);
}
return undefined;
}
return {
'UnaryExpression[operator=delete]'(node) {
if (node.argument.type !== experimental_utils_1.AST_NODE_TYPES.MemberExpression ||
!node.argument.computed ||
isNecessaryDynamicAccess(diveIntoWrapperExpressions(node.argument.property))) {
return;
}
context.report({
fix: createFixer(node.argument),
messageId: 'dynamicDelete',
node: node.argument.property,
});
},
};
function createPropertyReplacement(property, replacement) {
return (fixer) => fixer.replaceTextRange(getTokenRange(property), replacement);
}
function getTokenRange(property) {
const sourceCode = context.getSourceCode();
return [
sourceCode.getTokenBefore(property).range[0],
sourceCode.getTokenAfter(property).range[1],
];
}
},
});
function diveIntoWrapperExpressions(node) {
if (node.type === experimental_utils_1.AST_NODE_TYPES.UnaryExpression) {
return diveIntoWrapperExpressions(node.argument);
}
return node;
}
function isNecessaryDynamicAccess(property) {
if (property.type !== experimental_utils_1.AST_NODE_TYPES.Literal) {
return false;
}
if (typeof property.value === 'number') {
return true;
}
return (typeof property.value === 'string' &&
!tsutils.isValidPropertyAccess(property.value));
}
//# sourceMappingURL=no-dynamic-delete.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-dynamic-delete.js","sourceRoot":"","sources":["../../src/rules/no-dynamic-delete.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAI+C;AAC/C,iDAAmC;AACnC,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,4DAA4D;YACzE,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,aAAa,EAAE,mDAAmD;SACnE;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,YAAY;KACnB;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,SAAS,WAAW,CAClB,MAAiC;YAEjC,IACE,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,mCAAc,CAAC,OAAO;gBAC/C,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,EACzC;gBACA,OAAO,yBAAyB,CAC9B,MAAM,CAAC,QAAQ,EACf,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAC5B,CAAC;aACH;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO;YACL,kCAAkC,CAAC,IAA8B;gBAC/D,IACE,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,mCAAc,C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OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ;QAClC,CAAC,OAAO,CAAC,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC/C,CAAC;AACJ,CAAC"}

View file

@ -0,0 +1,146 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const no_empty_function_1 = __importDefault(require("eslint/lib/rules/no-empty-function"));
const util = __importStar(require("../util"));
const schema = util.deepMerge(Array.isArray(no_empty_function_1.default.meta.schema)
? no_empty_function_1.default.meta.schema[0]
: no_empty_function_1.default.meta.schema, {
properties: {
allow: {
items: {
enum: [
'functions',
'arrowFunctions',
'generatorFunctions',
'methods',
'generatorMethods',
'getters',
'setters',
'constructors',
'private-constructors',
'protected-constructors',
'asyncFunctions',
'asyncMethods',
'decoratedFunctions',
],
},
},
},
});
exports.default = util.createRule({
name: 'no-empty-function',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow empty functions',
category: 'Best Practices',
recommended: 'error',
extendsBaseRule: true,
},
schema: [schema],
messages: no_empty_function_1.default.meta.messages,
},
defaultOptions: [
{
allow: [],
},
],
create(context, [{ allow = [] }]) {
const rules = no_empty_function_1.default.create(context);
const isAllowedProtectedConstructors = allow.includes('protected-constructors');
const isAllowedPrivateConstructors = allow.includes('private-constructors');
const isAllowedDecoratedFunctions = allow.includes('decoratedFunctions');
/**
* Check if the method body is empty
* @param node the node to be validated
* @returns true if the body is empty
* @private
*/
function isBodyEmpty(node) {
return !node.body || node.body.body.length === 0;
}
/**
* Check if method has parameter properties
* @param node the node to be validated
* @returns true if the body has parameter properties
* @private
*/
function hasParameterProperties(node) {
var _a;
return (_a = node.params) === null || _a === void 0 ? void 0 : _a.some(param => param.type === experimental_utils_1.AST_NODE_TYPES.TSParameterProperty);
}
/**
* @param node the node to be validated
* @returns true if the constructor is allowed to be empty
* @private
*/
function isAllowedEmptyConstructor(node) {
const parent = node.parent;
if (isBodyEmpty(node) &&
(parent === null || parent === void 0 ? void 0 : parent.type) === experimental_utils_1.AST_NODE_TYPES.MethodDefinition &&
parent.kind === 'constructor') {
const { accessibility } = parent;
return (
// allow protected constructors
(accessibility === 'protected' && isAllowedProtectedConstructors) ||
// allow private constructors
(accessibility === 'private' && isAllowedPrivateConstructors) ||
// allow constructors which have parameter properties
hasParameterProperties(node));
}
return false;
}
/**
* @param node the node to be validated
* @returns true if a function has decorators
* @private
*/
function isAllowedEmptyDecoratedFunctions(node) {
var _a;
if (isAllowedDecoratedFunctions && isBodyEmpty(node)) {
const decorators = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === experimental_utils_1.AST_NODE_TYPES.MethodDefinition
? node.parent.decorators
: undefined;
return !!decorators && !!decorators.length;
}
return false;
}
return Object.assign(Object.assign({}, rules), { FunctionExpression(node) {
if (isAllowedEmptyConstructor(node) ||
isAllowedEmptyDecoratedFunctions(node)) {
return;
}
rules.FunctionExpression(node);
},
FunctionDeclaration(node) {
if (isAllowedEmptyDecoratedFunctions(node)) {
return;
}
rules.FunctionDeclaration(node);
} });
},
});
//# sourceMappingURL=no-empty-function.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-empty-function.js","sourceRoot":"","sources":["../../src/rules/no-empty-function.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,2FAA0D;AAC1D,8CAAgC;AAKhC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAC3B,KAAK,CAAC,OAAO,CAAC,2BAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC,2BAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC,2BAAQ,CAAC,IAAI,CAAC,MAAM,EACxB;IACE,UAAU,EAAE;QACV,KAAK,EAAE;YACL,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,WAAW;oBACX,gBAAgB;oBAChB,oBAAoB;oBACpB,SAAS;oBACT,kBAAkB;oBAClB,SAAS;oBACT,SAAS;oBACT,cAAc;oBACd,sBAAsB;oBACtB,wBAAwB;oBACxB,gBAAgB;oBAChB,cAAc;oBACd,oBAAoB;iBACrB;aACF;SACF;KACF;CACF,CACF,CAAC;AAEF,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,OAAO;YACpB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE,CAAC,MAAM,CAAC;QAChB,QAAQ,EAAE,2BAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE;QACd;YACE,KAAK,EAAE,EAAE;SACV;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,2BAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,MAAM,8BA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AM,UAAU,GACd,OAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,mCAAc,CAAC,gBAAgB;oBACnD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU;oBACxB,CAAC,CAAC,SAAS,CAAC;gBAChB,OAAO,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;aAC5C;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAED,uCACK,KAAK,KACR,kBAAkB,CAAC,IAAI;gBACrB,IACE,yBAAyB,CAAC,IAAI,CAAC;oBAC/B,gCAAgC,CAAC,IAAI,CAAC,EACtC;oBACA,OAAO;iBACR;gBAED,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;YACD,mBAAmB,CAAC,IAAI;gBACtB,IAAI,gCAAgC,CAAC,IAAI,CAAC,EAAE;oBAC1C,OAAO;iBACR;gBAED,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,105 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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: 'no-empty-interface',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow the declaration of empty interfaces',
category: 'Best Practices',
recommended: 'error',
suggestion: true,
},
fixable: 'code',
messages: {
noEmpty: 'An empty interface is equivalent to `{}`.',
noEmptyWithSuper: 'An interface declaring no members is equivalent to its supertype.',
},
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
allowSingleExtends: {
type: 'boolean',
},
},
},
],
},
defaultOptions: [
{
allowSingleExtends: false,
},
],
create(context, [{ allowSingleExtends }]) {
return {
TSInterfaceDeclaration(node) {
const sourceCode = context.getSourceCode();
const filename = context.getFilename();
if (node.body.body.length !== 0) {
// interface contains members --> Nothing to report
return;
}
const extend = node.extends;
if (!extend || extend.length === 0) {
context.report({
node: node.id,
messageId: 'noEmpty',
});
}
else if (extend.length === 1) {
// interface extends exactly 1 interface --> Report depending on rule setting
if (!allowSingleExtends) {
const fix = (fixer) => {
let typeParam = '';
if (node.typeParameters) {
typeParam = sourceCode.getText(node.typeParameters);
}
return fixer.replaceText(node, `type ${sourceCode.getText(node.id)}${typeParam} = ${sourceCode.getText(extend[0])}`);
};
// Check if interface is within ambient declaration
let useAutoFix = true;
if (util.isDefinitionFile(filename)) {
const scope = context.getScope();
if (scope.type === 'tsModule' && scope.block.declare) {
useAutoFix = false;
}
}
context.report(Object.assign({ node: node.id, messageId: 'noEmptyWithSuper' }, (useAutoFix
? { fix }
: {
suggest: [
{
messageId: 'noEmptyWithSuper',
fix,
},
],
})));
}
}
},
};
},
});
//# sourceMappingURL=no-empty-interface.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-empty-interface.js","sourceRoot":"","sources":["../../src/rules/no-empty-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAUhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,8CAA8C;YAC3D,QAAQ,EAAE,gBAAgB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AC,CAAC;6BACrD;4BACD,OAAO,KAAK,CAAC,WAAW,CACtB,IAAI,EACJ,QAAQ,UAAU,CAAC,OAAO,CACxB,IAAI,CAAC,EAAE,CACR,GAAG,SAAS,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CACnD,CAAC;wBACJ,CAAC,CAAC;wBAEF,mDAAmD;wBACnD,IAAI,UAAU,GAAG,IAAI,CAAC;wBACtB,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE;4BACnC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;4BACjC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;gCACpD,UAAU,GAAG,KAAK,CAAC;6BACpB;yBACF;wBAED,OAAO,CAAC,MAAM,iBACZ,IAAI,EAAE,IAAI,CAAC,EAAE,EACb,SAAS,EAAE,kBAAkB,IAC1B,CAAC,UAAU;4BACZ,CAAC,CAAC,EAAE,GAAG,EAAE;4BACT,CAAC,CAAC;gCACE,OAAO,EAAE;oCACP;wCACE,SAAS,EAAE,kBAAkB;wCAC7B,GAAG;qCACJ;iCACF;6BACF,CAAC,EACN,CAAC;qBACJ;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,188 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-explicit-any',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow usage of the `any` type',
category: 'Best Practices',
recommended: 'warn',
suggestion: true,
},
fixable: 'code',
messages: {
unexpectedAny: 'Unexpected any. Specify a different type.',
suggestUnknown: 'Use `unknown` instead, this will force you to explicitly, and safely assert the type is correct.',
suggestNever: "Use `never` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.",
},
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
fixToUnknown: {
type: 'boolean',
},
ignoreRestArgs: {
type: 'boolean',
},
},
},
],
},
defaultOptions: [
{
fixToUnknown: false,
ignoreRestArgs: false,
},
],
create(context, [{ ignoreRestArgs, fixToUnknown }]) {
/**
* Checks if the node is an arrow function, function/constructor declaration or function expression
* @param node the node to be validated.
* @returns true if the node is any kind of function declaration or expression
* @private
*/
function isNodeValidFunction(node) {
return [
experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
experimental_utils_1.AST_NODE_TYPES.FunctionDeclaration,
experimental_utils_1.AST_NODE_TYPES.FunctionExpression,
experimental_utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
experimental_utils_1.AST_NODE_TYPES.TSFunctionType,
experimental_utils_1.AST_NODE_TYPES.TSConstructorType,
experimental_utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
experimental_utils_1.AST_NODE_TYPES.TSMethodSignature,
experimental_utils_1.AST_NODE_TYPES.TSDeclareFunction,
].includes(node.type);
}
/**
* Checks if the node is a rest element child node of a function
* @param node the node to be validated.
* @returns true if the node is a rest element child node of a function
* @private
*/
function isNodeRestElementInFunction(node) {
return (node.type === experimental_utils_1.AST_NODE_TYPES.RestElement &&
typeof node.parent !== 'undefined' &&
isNodeValidFunction(node.parent));
}
/**
* Checks if the node is a TSTypeOperator node with a readonly operator
* @param node the node to be validated.
* @returns true if the node is a TSTypeOperator node with a readonly operator
* @private
*/
function isNodeReadonlyTSTypeOperator(node) {
return (node.type === experimental_utils_1.AST_NODE_TYPES.TSTypeOperator &&
node.operator === 'readonly');
}
/**
* Checks if the node is a TSTypeReference node with an Array identifier
* @param node the node to be validated.
* @returns true if the node is a TSTypeReference node with an Array identifier
* @private
*/
function isNodeValidArrayTSTypeReference(node) {
return (node.type === experimental_utils_1.AST_NODE_TYPES.TSTypeReference &&
typeof node.typeName !== 'undefined' &&
node.typeName.type === experimental_utils_1.AST_NODE_TYPES.Identifier &&
['Array', 'ReadonlyArray'].includes(node.typeName.name));
}
/**
* Checks if the node is a valid TSTypeOperator or TSTypeReference node
* @param node the node to be validated.
* @returns true if the node is a valid TSTypeOperator or TSTypeReference node
* @private
*/
function isNodeValidTSType(node) {
return (isNodeReadonlyTSTypeOperator(node) ||
isNodeValidArrayTSTypeReference(node));
}
/**
* Checks if the great grand-parent node is a RestElement node in a function
* @param node the node to be validated.
* @returns true if the great grand-parent node is a RestElement node in a function
* @private
*/
function isGreatGrandparentRestElement(node) {
var _a, _b;
return (((_b = (_a = node === null || node === void 0 ? void 0 : node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) != null &&
isNodeRestElementInFunction(node.parent.parent.parent));
}
/**
* Checks if the great great grand-parent node is a valid RestElement node in a function
* @param node the node to be validated.
* @returns true if the great great grand-parent node is a valid RestElement node in a function
* @private
*/
function isGreatGreatGrandparentRestElement(node) {
var _a, _b, _c;
return (((_c = (_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.parent) != null &&
isNodeValidTSType(node.parent.parent) &&
isNodeRestElementInFunction(node.parent.parent.parent.parent));
}
/**
* Checks if the great grand-parent or the great great grand-parent node is a RestElement node
* @param node the node to be validated.
* @returns true if the great grand-parent or the great great grand-parent node is a RestElement node
* @private
*/
function isNodeDescendantOfRestElementInFunction(node) {
return (isGreatGrandparentRestElement(node) ||
isGreatGreatGrandparentRestElement(node));
}
return {
TSAnyKeyword(node) {
if (ignoreRestArgs && isNodeDescendantOfRestElementInFunction(node)) {
return;
}
const fixOrSuggest = {
fix: null,
suggest: [
{
messageId: 'suggestUnknown',
fix(fixer) {
return fixer.replaceText(node, 'unknown');
},
},
{
messageId: 'suggestNever',
fix(fixer) {
return fixer.replaceText(node, 'never');
},
},
],
};
if (fixToUnknown) {
fixOrSuggest.fix = (fixer => fixer.replaceText(node, 'unknown'));
}
context.report(Object.assign({ node, messageId: 'unexpectedAny' }, fixOrSuggest));
},
};
},
});
//# sourceMappingURL=no-explicit-any.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-explicit-any.js","sourceRoot":"","sources":["../../src/rules/no-explicit-any.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,8EAG+C;AAC/C,8CAAgC;AAWhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,aAAa,EAAE,2CAA2C;YAC1D,cAAc,EACZ,kGAAkG;YACpG,YAAY,EACV,yHAAyH;SAC5H;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,YAAY,EAAE;wBACZ,IAAI,EAAE,SAAS;qBAChB;oBACD,cAAc,EAAE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AAK,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;4BAC5C,CAAC;yBACF;wBACD;4BACE,SAAS,EAAE,cAAc;4BACzB,GAAG,CAAC,KAAK;gCACP,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;4BAC1C,CAAC;yBACF;qBACF;iBACF,CAAC;gBAEF,IAAI,YAAY,EAAE;oBAChB,YAAY,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAC1B,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAA+B,CAAC;iBACrE;gBAED,OAAO,CAAC,MAAM,iBACZ,IAAI,EACJ,SAAS,EAAE,eAAe,IACvB,YAAY,EACf,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,56 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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: 'no-extra-non-null-assertion',
meta: {
type: 'problem',
docs: {
description: 'Disallow extra non-null assertion',
category: 'Stylistic Issues',
recommended: 'error',
},
fixable: 'code',
schema: [],
messages: {
noExtraNonNullAssertion: 'Forbidden extra non-null assertion.',
},
},
defaultOptions: [],
create(context) {
function checkExtraNonNullAssertion(node) {
context.report({
node,
messageId: 'noExtraNonNullAssertion',
fix(fixer) {
return fixer.removeRange([node.range[1] - 1, node.range[1]]);
},
});
}
return {
'TSNonNullExpression > TSNonNullExpression': checkExtraNonNullAssertion,
'MemberExpression[optional = true] > TSNonNullExpression': checkExtraNonNullAssertion,
'CallExpression[optional = true] > TSNonNullExpression.callee': checkExtraNonNullAssertion,
};
},
});
//# sourceMappingURL=no-extra-non-null-assertion.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-extra-non-null-assertion.js","sourceRoot":"","sources":["../../src/rules/no-extra-non-null-assertion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,mCAAmC;YAChD,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,OAAO;SACrB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,uBAAuB,EAAE,qCAAqC;SAC/D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,SAAS,0BAA0B,CACjC,IAAkC;YAElC,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI;gBACJ,SAAS,EAAE,yBAAyB;gBACpC,GAAG,CAAC,KAAK;oBACP,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC/D,CAAC;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,2CAA2C,EAAE,0BAA0B;YACvE,yDAAyD,EAAE,0BAA0B;YACrF,8DAA8D,EAAE,0BAA0B;SAC3F,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,182 @@
"use strict";
// any is required to work around manipulating the AST in weird ways
/* eslint-disable @typescript-eslint/no-explicit-any */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const no_extra_parens_1 = __importDefault(require("eslint/lib/rules/no-extra-parens"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-extra-parens',
meta: {
type: 'layout',
docs: {
description: 'Disallow unnecessary parentheses',
category: 'Possible Errors',
recommended: false,
extendsBaseRule: true,
},
fixable: 'code',
schema: no_extra_parens_1.default.meta.schema,
messages: no_extra_parens_1.default.meta.messages,
},
defaultOptions: ['all'],
create(context) {
const rules = no_extra_parens_1.default.create(context);
function binaryExp(node) {
const rule = rules.BinaryExpression;
// makes the rule think it should skip the left or right
const isLeftTypeAssertion = util.isTypeAssertion(node.left);
const isRightTypeAssertion = util.isTypeAssertion(node.right);
if (isLeftTypeAssertion && isRightTypeAssertion) {
return; // ignore
}
if (isLeftTypeAssertion) {
return rule(Object.assign(Object.assign({}, node), { left: Object.assign(Object.assign({}, node.left), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
if (isRightTypeAssertion) {
return rule(Object.assign(Object.assign({}, node), { right: Object.assign(Object.assign({}, node.right), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
return rule(node);
}
function callExp(node) {
var _a;
const rule = rules.CallExpression;
if (util.isTypeAssertion(node.callee)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped
return rule(Object.assign(Object.assign({}, node), { callee: Object.assign(Object.assign({}, node.callee), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
if (node.arguments.length === 1 && ((_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params.some(param => param.type === experimental_utils_1.AST_NODE_TYPES.TSParenthesizedType ||
param.type === experimental_utils_1.AST_NODE_TYPES.TSImportType))) {
return rule(Object.assign(Object.assign({}, node), { arguments: [
Object.assign(Object.assign({}, node.arguments[0]), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }),
] }));
}
return rule(node);
}
function unaryUpdateExpression(node) {
const rule = rules.UnaryExpression;
if (util.isTypeAssertion(node.argument)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped
return rule(Object.assign(Object.assign({}, node), { argument: Object.assign(Object.assign({}, node.argument), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
return rule(node);
}
const overrides = {
// ArrayExpression
ArrowFunctionExpression(node) {
if (!util.isTypeAssertion(node.body)) {
return rules.ArrowFunctionExpression(node);
}
},
// AssignmentExpression
// AwaitExpression
BinaryExpression: binaryExp,
CallExpression: callExp,
// ClassDeclaration
// ClassExpression
ConditionalExpression(node) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped
if (util.isTypeAssertion(node.test)) {
return rules.ConditionalExpression(Object.assign(Object.assign({}, node), { test: Object.assign(Object.assign({}, node.test), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
if (util.isTypeAssertion(node.consequent)) {
return rules.ConditionalExpression(Object.assign(Object.assign({}, node), { consequent: Object.assign(Object.assign({}, node.consequent), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
if (util.isTypeAssertion(node.alternate)) {
// reduces the precedence of the node so the rule thinks it needs to be rapped
return rules.ConditionalExpression(Object.assign(Object.assign({}, node), { alternate: Object.assign(Object.assign({}, node.alternate), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
return rules.ConditionalExpression(node);
},
// DoWhileStatement
'ForInStatement, ForOfStatement'(node) {
if (util.isTypeAssertion(node.right)) {
// makes the rule skip checking of the right
return rules['ForInStatement, ForOfStatement'](Object.assign(Object.assign({}, node), { type: experimental_utils_1.AST_NODE_TYPES.ForOfStatement, right: Object.assign(Object.assign({}, node.right), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
return rules['ForInStatement, ForOfStatement'](node);
},
ForStatement(node) {
// make the rule skip the piece by removing it entirely
if (node.init && util.isTypeAssertion(node.init)) {
return rules.ForStatement(Object.assign(Object.assign({}, node), { init: null }));
}
if (node.test && util.isTypeAssertion(node.test)) {
return rules.ForStatement(Object.assign(Object.assign({}, node), { test: null }));
}
if (node.update && util.isTypeAssertion(node.update)) {
return rules.ForStatement(Object.assign(Object.assign({}, node), { update: null }));
}
return rules.ForStatement(node);
},
'ForStatement > *.init:exit'(node) {
if (!util.isTypeAssertion(node)) {
return rules['ForStatement > *.init:exit'](node);
}
},
// IfStatement
LogicalExpression: binaryExp,
MemberExpression(node) {
if (util.isTypeAssertion(node.object)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped
return rules.MemberExpression(Object.assign(Object.assign({}, node), { object: Object.assign(Object.assign({}, node.object), { type: experimental_utils_1.AST_NODE_TYPES.SequenceExpression }) }));
}
return rules.MemberExpression(node);
},
NewExpression: callExp,
// ObjectExpression
// ReturnStatement
// SequenceExpression
SpreadElement(node) {
if (!util.isTypeAssertion(node.argument)) {
return rules.SpreadElement(node);
}
},
SwitchCase(node) {
if (node.test && !util.isTypeAssertion(node.test)) {
return rules.SwitchCase(node);
}
},
// SwitchStatement
ThrowStatement(node) {
if (node.argument && !util.isTypeAssertion(node.argument)) {
return rules.ThrowStatement(node);
}
},
UnaryExpression: unaryUpdateExpression,
UpdateExpression: unaryUpdateExpression,
// VariableDeclarator
// WhileStatement
// WithStatement - i'm not going to even bother implementing this terrible and never used feature
YieldExpression(node) {
if (node.argument && !util.isTypeAssertion(node.argument)) {
return rules.YieldExpression(node);
}
},
};
return Object.assign({}, rules, overrides);
},
});
//# sourceMappingURL=no-extra-parens.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,49 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const no_extra_semi_1 = __importDefault(require("eslint/lib/rules/no-extra-semi"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-extra-semi',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow unnecessary semicolons',
category: 'Possible Errors',
recommended: 'error',
extendsBaseRule: true,
},
fixable: 'code',
schema: no_extra_semi_1.default.meta.schema,
messages: no_extra_semi_1.default.meta.messages,
},
defaultOptions: [],
create(context) {
const rules = no_extra_semi_1.default.create(context);
return Object.assign(Object.assign({}, rules), { ClassProperty(node) {
rules.MethodDefinition(node);
} });
},
});
//# sourceMappingURL=no-extra-semi.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"no-extra-semi.js","sourceRoot":"","sources":["../../src/rules/no-extra-semi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mFAAsD;AACtD,8CAAgC;AAKhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,OAAO;YACpB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,uBAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,uBAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,uBAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,uCACK,KAAK,KACR,aAAa,CAAC,IAAI;gBAChB,KAAK,CAAC,gBAAgB,CAAC,IAAa,CAAC,CAAC;YACxC,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -0,0 +1,129 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
name: 'no-extraneous-class',
meta: {
type: 'suggestion',
docs: {
description: 'Forbids the use of classes as namespaces',
category: 'Best Practices',
recommended: false,
},
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
allowConstructorOnly: {
type: 'boolean',
},
allowEmpty: {
type: 'boolean',
},
allowStaticOnly: {
type: 'boolean',
},
allowWithDecorator: {
type: 'boolean',
},
},
},
],
messages: {
empty: 'Unexpected empty class.',
onlyStatic: 'Unexpected class with only static properties.',
onlyConstructor: 'Unexpected class with only a constructor.',
},
},
defaultOptions: [
{
allowConstructorOnly: false,
allowEmpty: false,
allowStaticOnly: false,
allowWithDecorator: false,
},
],
create(context, [{ allowConstructorOnly, allowEmpty, allowStaticOnly, allowWithDecorator }]) {
const isAllowWithDecorator = (node) => {
return !!(allowWithDecorator &&
node &&
node.decorators &&
node.decorators.length);
};
return {
ClassBody(node) {
const parent = node.parent;
if (!parent || parent.superClass) {
return;
}
const reportNode = 'id' in parent && parent.id ? parent.id : parent;
if (node.body.length === 0) {
if (allowEmpty || isAllowWithDecorator(parent)) {
return;
}
context.report({
node: reportNode,
messageId: 'empty',
});
return;
}
let onlyStatic = true;
let onlyConstructor = true;
for (const prop of node.body) {
if ('kind' in prop && prop.kind === 'constructor') {
if (prop.value.params.some(param => param.type === experimental_utils_1.AST_NODE_TYPES.TSParameterProperty)) {
onlyConstructor = false;
onlyStatic = false;
}
}
else {
onlyConstructor = false;
if ('static' in prop && !prop.static) {
onlyStatic = false;
}
}
if (!(onlyStatic || onlyConstructor)) {
break;
}
}
if (onlyConstructor) {
if (!allowConstructorOnly) {
context.report({
node: reportNode,
messageId: 'onlyConstructor',
});
}
return;
}
if (onlyStatic && !allowStaticOnly) {
context.report({
node: reportNode,
messageId: 'onlyStatic',
});
}
},
};
},
});
//# sourceMappingURL=no-extraneous-class.js.map

Some files were not shown because too many files have changed in this diff Show more