Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2024-09-16 17:29:58 +00:00
parent 1afca056e3
commit 6989ba7bd2
3942 changed files with 55190 additions and 132206 deletions

View file

@ -1,21 +0,0 @@
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.

View file

@ -1,12 +0,0 @@
# `@typescript-eslint/eslint-plugin`
An ESLint plugin which provides lint rules for TypeScript codebases.
[![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
[![NPM Downloads](https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
👉 See **https://typescript-eslint.io/getting-started** for our Getting Started docs.
> See https://typescript-eslint.io for general documentation on typescript-eslint, the tooling that allows you to run ESLint and Prettier on TypeScript code.
<!-- Local path for docs: docs/packages/ESLint_Plugin.mdx -->

View file

@ -1,162 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// 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',
'@typescript-eslint/class-literal-property-style': 'error',
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': 'error',
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'consistent-return': 'off',
'@typescript-eslint/consistent-return': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
'dot-notation': 'off',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'init-declarations': 'off',
'@typescript-eslint/init-declarations': 'error',
'max-params': 'off',
'@typescript-eslint/max-params': '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-array-delete': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': '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-empty-object-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'no-loop-func': 'off',
'@typescript-eslint/no-loop-func': 'error',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': 'error',
'no-magic-numbers': 'off',
'@typescript-eslint/no-magic-numbers': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-mixed-enums': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-require-imports': 'error',
'no-restricted-imports': 'off',
'@typescript-eslint/no-restricted-imports': 'error',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/no-unsafe-unary-minus': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'prefer-destructuring': 'off',
'@typescript-eslint/prefer-destructuring': 'error',
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-find': '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',
'prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-readonly-parameter-types': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': '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',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/typedef': 'error',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',
},
};
//# sourceMappingURL=all.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/configs/all.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+BAA+B,EAAE,OAAO;QACxC,mCAAmC,EAAE,OAAO;QAC5C,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;QAChD,8BAA8B,EAAE,OAAO;QACvC,iDAAiD,EAAE,OAAO;QAC1D,wBAAwB,EAAE,KAAK;QAC/B,2CAA2C,EAAE,OAAO;QACpD,oDAAoD,EAAE,OAAO;QAC7D,oDAAoD,EAAE,OAAO;QAC7D,mBAAmB,EAAE,KAAK;QAC1B,sCAAsC,EAAE,OAAO;QAC/C,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,4CAA4C,E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ACpD,4CAA4C,EAAE,OAAO;QACrD,oCAAoC,EAAE,OAAO;QAC7C,4CAA4C,EAAE,OAAO;QACrD,sDAAsD,EAAE,OAAO;QAC/D,kBAAkB,EAAE,KAAK;QACzB,qCAAqC,EAAE,OAAO;QAC9C,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,6CAA6C,EAAE,OAAO;QACtD,gCAAgC,EAAE,OAAO;QACzC,kCAAkC,EAAE,OAAO;QAC3C,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,6CAA6C,EAAE,OAAO;QACtD,8CAA8C,EAAE,OAAO;QACvD,0CAA0C,EAAE,OAAO;QACnD,8BAA8B,EAAE,KAAK;QACrC,iDAAiD,EAAE,OAAO;QAC1D,oCAAoC,EAAE,OAAO;QAC7C,oDAAoD,EAAE,OAAO;QAC7D,iDAAiD,EAAE,OAAO;QAC1D,uCAAuC,EAAE,OAAO;QAChD,4CAA4C,EAAE,OAAO;QACrD,mDAAmD,EAAE,OAAO;QAC5D,2CAA2C,EAAE,OAAO;QACpD,+CAA+C,EAAE,OAAO;QACxD,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,iBAAiB,EAAE,KAAK;QACxB,iCAAiC,EAAE,OAAO;QAC1C,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,2CAA2C,EAAE,OAAO;QACpD,4BAA4B,EAAE,OAAO;QACrC,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;QAChD,2DAA2D,EAAE,OAAO;KACrE;CAC6B,CAAC"}

View file

@ -1,7 +0,0 @@
"use strict";
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: { sourceType: 'module' },
plugins: ['@typescript-eslint'],
};
//# sourceMappingURL=base.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/configs/base.ts"],"names":[],"mappings":";AAEA,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE;IACvC,OAAO,EAAE,CAAC,oBAAoB,CAAC;CACD,CAAC"}

View file

@ -1,73 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `yarn generate:configs`
module.exports = {
parserOptions: {
project: false,
program: null,
EXPERIMENTAL_useProjectService: false,
},
rules: {
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/consistent-return': 'off',
'@typescript-eslint/consistent-type-exports': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-array-delete': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-for-in-array': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-meaningless-void-operator': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-mixed-enums': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-qualifier': 'off',
'@typescript-eslint/no-unnecessary-template-expression': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-destructuring': 'off',
'@typescript-eslint/prefer-find': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-readonly': 'off',
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/prefer-return-this-type': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/require-array-sort-compare': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
},
};
//# sourceMappingURL=disable-type-checked.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"disable-type-checked.js","sourceRoot":"","sources":["../../src/configs/disable-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,aAAa,EAAE;QACb,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,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EAAE,KAAK;QAC9C,4CAA4C,EAAE,KAAK;QACnD,mDAAmD,EAAE,KAAK;QAC1D,2CAA2C,EAAE,KAAK;QAClD,+CAA+C,EAAE,KAAK;QACtD,kCAAkC,EAAE,KAAK;QACzC,2CAA2C,EAAE,KAAK;QAClD,kDAAkD,EAAE,KAAK;QACzD,iCAAiC,EAAE,KAAK;QACxC,+CAA+C,EAAE,KAAK;QACtD,gDAAgD,EAAE,KAAK;QACvD,mCAAmC,EAAE,KAAK;QAC1C,2DAA2D,EAAE,KAAK;KACnE;CAC6B,CAAC"}

View file

@ -1,42 +0,0 @@
"use strict";
// NOTE: this file is isolated to be shared across legacy and flat configs
// it is exported via `./use-at-your-own-risk/eslint-recommended-raw`
// and it has types manually defined in `./eslint-recommended-raw.d.ts`
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This is a compatibility ruleset that:
* - disables rules from eslint:recommended which are already handled by TypeScript.
* - enables rules that make sense due to TS's typechecking / transpilation.
*/
exports.default = (style) => ({
files: style === 'glob'
? // classic configs use glob syntax
['*.ts', '*.tsx', '*.mts', '*.cts']
: // flat configs use minimatch syntax
['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
rules: {
'constructor-super': 'off', // ts(2335) & ts(2377)
'getter-return': 'off', // ts(2378)
'no-const-assign': 'off', // ts(2588)
'no-dupe-args': 'off', // ts(2300)
'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
'no-dupe-keys': 'off', // ts(1117)
'no-func-assign': 'off', // ts(2630)
'no-import-assign': 'off', // ts(2632) & ts(2540)
// TODO - remove this once we no longer support ESLint v8
'no-new-symbol': 'off', // ts(7009)
'no-new-native-nonconstructor': 'off', // ts(7009)
'no-obj-calls': 'off', // ts(2349)
'no-redeclare': 'off', // ts(2451)
'no-setter-return': 'off', // ts(2408)
'no-this-before-super': 'off', // ts(2376) & ts(17009)
'no-undef': 'off', // ts(2304) & ts(2552)
'no-unreachable': 'off', // ts(7027)
'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
'prefer-const': 'error', // ts provides better types with const
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
},
});
//# sourceMappingURL=eslint-recommended-raw.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"eslint-recommended-raw.js","sourceRoot":"","sources":["../../src/configs/eslint-recommended-raw.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,qEAAqE;AACrE,uEAAuE;;AAEvE;;;;GAIG;AACH,kBAAe,CACb,KAA2B,EAI3B,EAAE,CAAC,CAAC;IACJ,KAAK,EACH,KAAK,KAAK,MAAM;QACd,CAAC,CAAC,kCAAkC;YAClC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;QACrC,CAAC,CAAC,oCAAoC;YACpC,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC;IACrD,KAAK,EAAE;QACL,mBAAmB,EAAE,KAAK,EAAE,sBAAsB;QAClD,eAAe,EAAE,KAAK,EAAE,WAAW;QACnC,iBAAiB,EAAE,KAAK,EAAE,WAAW;QACrC,cAAc,EAAE,KAAK,EAAE,WAAW;QAClC,uBAAuB,EAAE,KAAK,EAAE,sBAAsB;QACtD,cAAc,EAAE,KAAK,EAAE,WAAW;QAClC,gBAAgB,EAAE,KAAK,EAAE,WAAW;QACpC,kBAAkB,EAAE,KAAK,EAAE,sBAAsB;QACjD,yDAAyD;QACzD,eAAe,EAAE,KAAK,EAAE,WAAW;QACnC,8BAA8B,EAAE,KAAK,EAAE,WAAW;QAClD,cAAc,EAAE,KAAK,EAAE,WAAW;QAClC,cAAc,EAAE,KAAK,EAAE,WAAW;QAClC,kBAAkB,EAAE,KAAK,EAAE,WAAW;QACtC,sBAAsB,EAAE,KAAK,EAAE,uBAAuB;QACtD,UAAU,EAAE,KAAK,EAAE,sBAAsB;QACzC,gBAAgB,EAAE,KAAK,EAAE,WAAW;QACpC,oBAAoB,EAAE,KAAK,EAAE,iCAAiC;QAC9D,QAAQ,EAAE,OAAO,EAAE,+DAA+D;QAClF,cAAc,EAAE,OAAO,EAAE,sCAAsC;QAC/D,oBAAoB,EAAE,OAAO,EAAE,yDAAyD;QACxF,eAAe,EAAE,OAAO,EAAE,6DAA6D;KACxF;CACF,CAAC,CAAC"}

View file

@ -1,14 +0,0 @@
"use strict";
/**
* This is a compatibility ruleset that:
* - disables rules from eslint:recommended which are already handled by TypeScript.
* - enables rules that make sense due to TS's typechecking / transpilation.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const eslint_recommended_raw_1 = __importDefault(require("./eslint-recommended-raw"));
module.exports = {
overrides: [(0, eslint_recommended_raw_1.default)('glob')],
};
//# sourceMappingURL=eslint-recommended.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"eslint-recommended.js","sourceRoot":"","sources":["../../src/configs/eslint-recommended.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAIH,sFAA6D;AAE7D,iBAAS;IACP,SAAS,EAAE,CAAC,IAAA,gCAAqB,EAAC,MAAM,CAAC,CAAC;CACZ,CAAC"}

View file

@ -1,34 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// 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-base-to-string': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/unbound-method': 'error',
},
};
//# sourceMappingURL=recommended-type-checked-only.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"recommended-type-checked-only.js","sourceRoot":"","sources":["../../src/configs/recommended-type-checked-only.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,sCAAsC,EAAE,OAAO;QAC/C,mDAAmD,EAAE,OAAO;QAC5D,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,wCAAwC,EAAE,OAAO;QACjD,mDAAmD,EAAE,OAAO;QAC5D,kDAAkD,EAAE,OAAO;QAC3D,uCAAuC,EAAE,OAAO;QAChD,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,8CAA8C,EAAE,OAAO;QACvD,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,mCAAmC,EAAE,OAAO;KAC7C;CAC6B,CAAC"}

View file

@ -1,54 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `yarn generate:configs`
module.exports = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/ban-types': 'error',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': '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-redundant-type-constituents': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/unbound-method': 'error',
},
};
//# sourceMappingURL=recommended-type-checked.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"recommended-type-checked.js","sourceRoot":"","sources":["../../src/configs/recommended-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,mCAAmC,EAAE,OAAO;QAC5C,8BAA8B,EAAE,OAAO;QACvC,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,sCAAsC,EAAE,OAAO;QAC/C,6CAA6C,EAAE,OAAO;QACtD,mDAAmD,EAAE,OAAO;QAC5D,oCAAoC,EAAE,OAAO;QAC7C,gDAAgD,EAAE,OAAO;QACzD,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,wCAAwC,EAAE,OAAO;QACjD,iCAAiC,EAAE,OAAO;QAC1C,wDAAwD,EAAE,OAAO;QACjE,mDAAmD,EAAE,OAAO;QAC5D,kCAAkC,EAAE,OAAO;QAC3C,kDAAkD,EAAE,OAAO;QAC3D,mDAAmD,EAAE,OAAO;QAC5D,uCAAuC,EAAE,OAAO;QAChD,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,kDAAkD,EAAE,OAAO;QAC3D,8CAA8C,EAAE,OAAO;QACvD,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,gBAAgB,EAAE,KAAK;QACvB,mCAAmC,EAAE,OAAO;QAC5C,oCAAoC,EAAE,OAAO;QAC7C,oCAAoC,EAAE,OAAO;QAC7C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,2CAA2C,EAAE,OAAO;QACpD,mCAAmC,EAAE,OAAO;KAC7C;CAC6B,CAAC"}

View file

@ -1,33 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `yarn generate:configs`
module.exports = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/ban-types': 'error',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
},
};
//# sourceMappingURL=recommended.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,8BAA8B,EAAE,OAAO;QACvC,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,6CAA6C,EAAE,OAAO;QACtD,oCAAoC,EAAE,OAAO;QAC7C,gDAAgD,EAAE,OAAO;QACzD,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,iCAAiC,EAAE,OAAO;QAC1C,wDAAwD,EAAE,OAAO;QACjE,kCAAkC,EAAE,OAAO;QAC3C,mDAAmD,EAAE,OAAO;QAC5D,kDAAkD,EAAE,OAAO;QAC3D,gBAAgB,EAAE,KAAK;QACvB,mCAAmC,EAAE,OAAO;QAC5C,oCAAoC,EAAE,OAAO;QAC7C,oCAAoC,EAAE,OAAO;QAC7C,2CAA2C,EAAE,OAAO;KACrD;CAC6B,CAAC"}

View file

@ -1,69 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// 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-array-delete': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-mixed-enums': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-includes': 'error',
'prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumberAndString: false,
allowRegExp: false,
},
],
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumber: false,
allowRegExp: false,
allowNever: false,
},
],
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',
},
};
//# sourceMappingURL=strict-type-checked-only.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"strict-type-checked-only.js","sourceRoot":"","sources":["../../src/configs/strict-type-checked-only.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,oCAAoC,EAAE,O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,EAAE,OAAO;QAC5C,2DAA2D,EAAE,OAAO;KACrE;CAC6B,CAAC"}

View file

@ -1,101 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `yarn generate:configs`
module.exports = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': [
'error',
{ minimumDescriptionLength: 10 },
],
'@typescript-eslint/ban-types': 'error',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-array-delete': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-mixed-enums': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
'prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-plus-operands': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumberAndString: false,
allowRegExp: false,
},
],
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumber: false,
allowRegExp: false,
allowNever: false,
},
],
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',
},
};
//# sourceMappingURL=strict-type-checked.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"strict-type-checked.js","sourceRoot":"","sources":["../../src/configs/strict-type-checked.ts"],"names":[],"mappings":";AAAA,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,OAAO;QAChD,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,kDAAkD,EAAE,OAAO;QAC3D,8CAA8C,EAAE,OAAO;QACvD,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,gBAAgB,EAAE,KAAK;QACvB,mCAAmC,EAAE,OAAO;QAC5C,wBAAwB,EAAE,KAAK;QAC/B,2CAA2C,EAAE,OAAO;QACpD,oCAAoC,EAAE,OAAO;QAC7C,kBAAkB,EAAE,KAAK;QACzB,qCAAqC,EAAE,OAAO;QAC9C,oCAAoC,EAAE,OAAO;QAC7C,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,8BAA8B,EAAE,KAAK;QACrC,iDAAiD,EAAE,OAAO;QAC1D,iDAAiD,EAAE,OAAO;QAC1D,4CAA4C,EAAE,OAAO;QACrD,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE;YAC3C,OAAO;YACP;gBACE,QAAQ,EAAE,KAAK;gBACf,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,KAAK;gBACnB,oBAAoB,EAAE,KAAK;gBAC3B,WAAW,EAAE,KAAK;aACnB;SACF;QACD,kDAAkD,EAAE;YAClD,OAAO;YACP;gBACE,QAAQ,EAAE,KAAK;gBACf,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,KAAK;gBAClB,UAAU,EAAE,KAAK;aAClB;SACF;QACD,2CAA2C,EAAE,OAAO;QACpD,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;QAChD,2DAA2D,EAAE,OAAO;KACrE;CAC6B,CAAC"}

View file

@ -1,45 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `yarn generate:configs`
module.exports = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
'@typescript-eslint/ban-ts-comment': [
'error',
{ minimumDescriptionLength: 10 },
],
'@typescript-eslint/ban-types': 'error',
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': '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-literal-enum-member': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/unified-signatures': 'error',
},
};
//# sourceMappingURL=strict.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/configs/strict.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE;YACnC,OAAO;YACP,EAAE,wBAAwB,EAAE,EAAE,EAAE;SACjC;QACD,8BAA8B,EAAE,OAAO;QACvC,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,6CAA6C,EAAE,OAAO;QACtD,sCAAsC,EAAE,OAAO;QAC/C,oCAAoC,EAAE,OAAO;QAC7C,gDAAgD,EAAE,OAAO;QACzD,wCAAwC,EAAE,OAAO;QACjD,yCAAyC,EAAE,OAAO;QAClD,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,iCAAiC,EAAE,OAAO;QAC1C,4DAA4D,EAAE,OAAO;QACrE,wDAAwD,EAAE,OAAO;QACjE,0CAA0C,EAAE,OAAO;QACnD,kCAAkC,EAAE,OAAO;QAC3C,mDAAmD,EAAE,OAAO;QAC5D,kDAAkD,EAAE,OAAO;QAC3D,gBAAgB,EAAE,KAAK;QACvB,mCAAmC,EAAE,OAAO;QAC5C,wBAAwB,EAAE,KAAK;QAC/B,2CAA2C,EAAE,OAAO;QACpD,oCAAoC,EAAE,OAAO;QAC7C,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,2CAA2C,EAAE,OAAO;QACpD,uCAAuC,EAAE,OAAO;KACjD;CAC6B,CAAC"}

View file

@ -1,19 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// You can regenerate it using `yarn generate:configs`
module.exports = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
'dot-notation': 'off',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
},
};
//# sourceMappingURL=stylistic-type-checked-only.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"stylistic-type-checked-only.js","sourceRoot":"","sources":["../../src/configs/stylistic-type-checked-only.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,sDAAsD,EAAE,OAAO;QAC/D,8CAA8C,EAAE,OAAO;QACvD,0CAA0C,EAAE,OAAO;QACnD,mDAAmD,EAAE,OAAO;KAC7D;CAC6B,CAAC"}

View file

@ -1,35 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// 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/ban-tslint-comment': 'error',
'@typescript-eslint/class-literal-property-style': 'error',
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'dot-notation': 'off',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
},
};
//# sourceMappingURL=stylistic-type-checked.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"stylistic-type-checked.js","sourceRoot":"","sources":["../../src/configs/stylistic-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+BAA+B,EAAE,OAAO;QACxC,uCAAuC,EAAE,OAAO;QAChD,iDAAiD,EAAE,OAAO;QAC1D,oDAAoD,EAAE,OAAO;QAC7D,oDAAoD,EAAE,OAAO;QAC7D,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,oDAAoD,EAAE,OAAO;QAC7D,mBAAmB,EAAE,KAAK;QAC1B,sCAAsC,EAAE,OAAO;QAC/C,uCAAuC,EAAE,OAAO;QAChD,wCAAwC,EAAE,OAAO;QACjD,sDAAsD,EAAE,OAAO;QAC/D,kCAAkC,EAAE,OAAO;QAC3C,yCAAyC,EAAE,OAAO;QAClD,6CAA6C,EAAE,OAAO;QACtD,8CAA8C,EAAE,OAAO;QACvD,0CAA0C,EAAE,OAAO;QACnD,mDAAmD,EAAE,OAAO;KAC7D;CAC6B,CAAC"}

View file

@ -1,29 +0,0 @@
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// SEE https://typescript-eslint.io/users/configs
//
// For developers working in the typescript-eslint monorepo:
// 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/ban-tslint-comment': 'error',
'@typescript-eslint/class-literal-property-style': 'error',
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
},
};
//# sourceMappingURL=stylistic.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"stylistic.js","sourceRoot":"","sources":["../../src/configs/stylistic.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,iDAAiD;AACjD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAItD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+BAA+B,EAAE,OAAO;QACxC,uCAAuC,EAAE,OAAO;QAChD,iDAAiD,EAAE,OAAO;QAC1D,oDAAoD,EAAE,OAAO;QAC7D,oDAAoD,EAAE,OAAO;QAC7D,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,oDAAoD,EAAE,OAAO;QAC7D,mBAAmB,EAAE,KAAK;QAC1B,sCAAsC,EAAE,OAAO;QAC/C,uCAAuC,EAAE,OAAO;QAChD,wCAAwC,EAAE,OAAO;QACjD,kCAAkC,EAAE,OAAO;QAC3C,yCAAyC,EAAE,OAAO;QAClD,6CAA6C,EAAE,OAAO;KACvD;CAC6B,CAAC"}

View file

@ -1,45 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const all_1 = __importDefault(require("./configs/all"));
const base_1 = __importDefault(require("./configs/base"));
const disable_type_checked_1 = __importDefault(require("./configs/disable-type-checked"));
const eslint_recommended_1 = __importDefault(require("./configs/eslint-recommended"));
const recommended_1 = __importDefault(require("./configs/recommended"));
const recommended_type_checked_1 = __importDefault(require("./configs/recommended-type-checked"));
const recommended_type_checked_only_1 = __importDefault(require("./configs/recommended-type-checked-only"));
const strict_1 = __importDefault(require("./configs/strict"));
const strict_type_checked_1 = __importDefault(require("./configs/strict-type-checked"));
const strict_type_checked_only_1 = __importDefault(require("./configs/strict-type-checked-only"));
const stylistic_1 = __importDefault(require("./configs/stylistic"));
const stylistic_type_checked_1 = __importDefault(require("./configs/stylistic-type-checked"));
const stylistic_type_checked_only_1 = __importDefault(require("./configs/stylistic-type-checked-only"));
const rules_1 = __importDefault(require("./rules"));
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
const { name, version } = require('../package.json');
module.exports = {
configs: {
all: all_1.default,
base: base_1.default,
'disable-type-checked': disable_type_checked_1.default,
'eslint-recommended': eslint_recommended_1.default,
recommended: recommended_1.default,
/** @deprecated - please use "recommended-type-checked" instead. */
'recommended-requiring-type-checking': recommended_type_checked_1.default,
'recommended-type-checked': recommended_type_checked_1.default,
'recommended-type-checked-only': recommended_type_checked_only_1.default,
strict: strict_1.default,
'strict-type-checked': strict_type_checked_1.default,
'strict-type-checked-only': strict_type_checked_only_1.default,
stylistic: stylistic_1.default,
'stylistic-type-checked': stylistic_type_checked_1.default,
'stylistic-type-checked-only': stylistic_type_checked_only_1.default,
},
meta: {
name,
version,
},
rules: rules_1.default,
};
//# sourceMappingURL=index.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAEA,wDAAgC;AAChC,0DAAkC;AAClC,0FAAgE;AAChE,sFAA6D;AAC7D,wEAAgD;AAChD,kGAAwE;AACxE,4GAAiF;AACjF,8DAAsC;AACtC,wFAA8D;AAC9D,kGAAuE;AACvE,oEAA4C;AAC5C,8FAAoE;AACpE,wGAA6E;AAC7E,oDAA4B;AAE5B,sHAAsH;AACtH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAGlD,CAAC;AAEF,iBAAS;IACP,OAAO,EAAE;QACP,GAAG,EAAH,aAAG;QACH,IAAI,EAAJ,cAAI;QACJ,sBAAsB,EAAE,8BAAkB;QAC1C,oBAAoB,EAAE,4BAAiB;QACvC,WAAW,EAAX,qBAAW;QACX,mEAAmE;QACnE,qCAAqC,EAAE,kCAAsB;QAC7D,0BAA0B,EAAE,kCAAsB;QAClD,+BAA+B,EAAE,uCAA0B;QAC3D,MAAM,EAAN,gBAAM;QACN,qBAAqB,EAAE,6BAAiB;QACxC,0BAA0B,EAAE,kCAAqB;QACjD,SAAS,EAAT,mBAAS;QACT,wBAAwB,EAAE,gCAAoB;QAC9C,6BAA6B,EAAE,qCAAwB;KACxD;IACD,IAAI,EAAE;QACJ,IAAI;QACJ,OAAO;KACR;IACD,KAAK,EAAL,eAAK;CACkB,CAAC"}

View file

@ -1,130 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'adjacent-overload-signatures',
meta: {
type: 'suggestion',
docs: {
description: 'Require that function overload signatures be consecutive',
recommended: 'stylistic',
},
schema: [],
messages: {
adjacentSignature: 'All {{name}} signatures should be adjacent.',
},
},
defaultOptions: [],
create(context) {
/**
* 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) {
switch (member.type) {
case utils_1.AST_NODE_TYPES.ExportDefaultDeclaration:
case utils_1.AST_NODE_TYPES.ExportNamedDeclaration: {
// export statements (e.g. export { a };)
// have no declarations, so ignore them
if (!member.declaration) {
return null;
}
return getMemberMethod(member.declaration);
}
case utils_1.AST_NODE_TYPES.TSDeclareFunction:
case utils_1.AST_NODE_TYPES.FunctionDeclaration: {
const name = member.id?.name ?? null;
if (name == null) {
return null;
}
return {
name,
callSignature: false,
type: util_1.MemberNameType.Normal,
};
}
case utils_1.AST_NODE_TYPES.TSMethodSignature:
return {
...(0, util_1.getNameFromMember)(member, context.sourceCode),
static: !!member.static,
callSignature: false,
};
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
return {
name: 'call',
callSignature: true,
type: util_1.MemberNameType.Normal,
};
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
return {
name: 'new',
callSignature: false,
type: util_1.MemberNameType.Normal,
};
case utils_1.AST_NODE_TYPES.MethodDefinition:
return {
...(0, util_1.getNameFromMember)(member, context.sourceCode),
static: !!member.static,
callSignature: false,
};
}
return null;
}
function isSameMethod(method1, method2) {
return (!!method2 &&
method1.name === method2.name &&
method1.static === method2.static &&
method1.callSignature === method2.callSignature &&
method1.type === method2.type);
}
function getMembers(node) {
switch (node.type) {
case utils_1.AST_NODE_TYPES.ClassBody:
case utils_1.AST_NODE_TYPES.Program:
case utils_1.AST_NODE_TYPES.TSModuleBlock:
case utils_1.AST_NODE_TYPES.TSInterfaceBody:
case utils_1.AST_NODE_TYPES.BlockStatement:
return node.body;
case utils_1.AST_NODE_TYPES.TSTypeLiteral:
return node.members;
}
}
function checkBodyForOverloadMethods(node) {
const members = getMembers(node);
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,
BlockStatement: checkBodyForOverloadMethods,
};
},
});
//# sourceMappingURL=adjacent-overload-signatures.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"adjacent-overload-signatures.js","sourceRoot":"","sources":["../../src/rules/adjacent-overload-signatures.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAwE;AAmBxE,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,0DAA0D;YACvE,WAAW,EAAE,WAAW;SACzB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,iBAAiB,EAAE,6CAA6C;SACjE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QAQZ;;;;WAIG;QACH,SAAS,eAAe,CACtB,MAAkC;YAElC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAK,sBAAc,CAAC,wBAAwB,CAAC;gBAC7C,KAAK,sBAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC;oBAC3C,yCAAyC;oBACzC,uCAAuC;oBACvC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;wBACxB,OAAO,IAAI,CAAC;oBACd,CAAC;oBAED,OAAO,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBAC7C,CAAC;gBACD,KAAK,sBAAc,CAAC,iBAAiB,CAAC;gBACtC,KAAK,sBAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC;oBACxC,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,IAAI,IAAI,IAAI,CAAC;oBACrC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;wBACjB,OAAO,IAAI,CAAC;oBACd,CAAC;oBACD,OAAO;wBACL,IAA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AC,MAAM,CAAC,CAAC;gBAC3B,CAAC;gBAED,UAAU,GAAG,MAAM,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,SAAS,EAAE,2BAA2B;YACtC,OAAO,EAAE,2BAA2B;YACpC,aAAa,EAAE,2BAA2B;YAC1C,aAAa,EAAE,2BAA2B;YAC1C,eAAe,EAAE,2BAA2B;YAC5C,cAAc,EAAE,2BAA2B;SAC5C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,229 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
/**
* Check whatever node can be considered as simple
* @param node the node to be evaluated.
*/
function isSimpleType(node) {
switch (node.type) {
case utils_1.AST_NODE_TYPES.Identifier:
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
case utils_1.AST_NODE_TYPES.TSBooleanKeyword:
case utils_1.AST_NODE_TYPES.TSNeverKeyword:
case utils_1.AST_NODE_TYPES.TSNumberKeyword:
case utils_1.AST_NODE_TYPES.TSBigIntKeyword:
case utils_1.AST_NODE_TYPES.TSObjectKeyword:
case utils_1.AST_NODE_TYPES.TSStringKeyword:
case utils_1.AST_NODE_TYPES.TSSymbolKeyword:
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
case utils_1.AST_NODE_TYPES.TSVoidKeyword:
case utils_1.AST_NODE_TYPES.TSNullKeyword:
case utils_1.AST_NODE_TYPES.TSArrayType:
case utils_1.AST_NODE_TYPES.TSUndefinedKeyword:
case utils_1.AST_NODE_TYPES.TSThisType:
case utils_1.AST_NODE_TYPES.TSQualifiedName:
return true;
case utils_1.AST_NODE_TYPES.TSTypeReference:
if (node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
node.typeName.name === 'Array') {
if (!node.typeArguments) {
return true;
}
if (node.typeArguments.params.length === 1) {
return isSimpleType(node.typeArguments.params[0]);
}
}
else {
if (node.typeArguments) {
return false;
}
return isSimpleType(node.typeName);
}
return false;
default:
return false;
}
}
/**
* Check if node needs parentheses
* @param node the node to be evaluated.
*/
function typeNeedsParentheses(node) {
switch (node.type) {
case utils_1.AST_NODE_TYPES.TSTypeReference:
return typeNeedsParentheses(node.typeName);
case utils_1.AST_NODE_TYPES.TSUnionType:
case utils_1.AST_NODE_TYPES.TSFunctionType:
case utils_1.AST_NODE_TYPES.TSIntersectionType:
case utils_1.AST_NODE_TYPES.TSTypeOperator:
case utils_1.AST_NODE_TYPES.TSInferType:
case utils_1.AST_NODE_TYPES.TSConstructorType:
return true;
case utils_1.AST_NODE_TYPES.Identifier:
return node.name === 'ReadonlyArray';
default:
return false;
}
}
exports.default = (0, util_1.createRule)({
name: 'array-type',
meta: {
type: 'suggestion',
docs: {
description: 'Require consistently using either `T[]` or `Array<T>` for arrays',
recommended: 'stylistic',
},
fixable: 'code',
messages: {
errorStringGeneric: "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden. Use '{{className}}<{{type}}>' instead.",
errorStringArray: "Array type using '{{className}}<{{type}}>' is forbidden. Use '{{readonlyPrefix}}{{type}}[]' instead.",
errorStringArrayReadonly: "Array type using '{{className}}<{{type}}>' is forbidden. Use '{{readonlyPrefix}}{{type}}' instead.",
errorStringArraySimple: "Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}[]' instead.",
errorStringGenericSimple: "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead.",
},
schema: [
{
$defs: {
arrayOption: {
type: 'string',
enum: ['array', 'generic', 'array-simple'],
},
},
additionalProperties: false,
properties: {
default: {
$ref: '#/items/0/$defs/arrayOption',
description: 'The array type expected for mutable cases.',
},
readonly: {
$ref: '#/items/0/$defs/arrayOption',
description: 'The array type expected for readonly cases. If omitted, the value for `default` will be used.',
},
},
type: 'object',
},
],
},
defaultOptions: [
{
default: 'array',
},
],
create(context, [options]) {
const defaultOption = options.default;
const readonlyOption = options.readonly ?? defaultOption;
/**
* @param node the node to be evaluated.
*/
function getMessageType(node) {
if (isSimpleType(node)) {
return context.sourceCode.getText(node);
}
return 'T';
}
return {
TSArrayType(node) {
const isReadonly = node.parent.type === utils_1.AST_NODE_TYPES.TSTypeOperator &&
node.parent.operator === 'readonly';
const currentOption = isReadonly ? readonlyOption : defaultOption;
if (currentOption === 'array' ||
(currentOption === 'array-simple' && isSimpleType(node.elementType))) {
return;
}
const messageId = currentOption === 'generic'
? 'errorStringGeneric'
: 'errorStringGenericSimple';
const errorNode = isReadonly ? node.parent : node;
context.report({
node: errorNode,
messageId,
data: {
className: isReadonly ? 'ReadonlyArray' : 'Array',
readonlyPrefix: isReadonly ? 'readonly ' : '',
type: getMessageType(node.elementType),
},
fix(fixer) {
const typeNode = node.elementType;
const arrayType = isReadonly ? 'ReadonlyArray' : 'Array';
return [
fixer.replaceTextRange([errorNode.range[0], typeNode.range[0]], `${arrayType}<`),
fixer.replaceTextRange([typeNode.range[1], errorNode.range[1]], '>'),
];
},
});
},
TSTypeReference(node) {
if (node.typeName.type !== utils_1.AST_NODE_TYPES.Identifier ||
!(node.typeName.name === 'Array' ||
node.typeName.name === 'ReadonlyArray' ||
node.typeName.name === 'Readonly') ||
(node.typeName.name === 'Readonly' &&
node.typeArguments?.params[0].type !== utils_1.AST_NODE_TYPES.TSArrayType)) {
return;
}
const isReadonlyWithGenericArrayType = node.typeName.name === 'Readonly' &&
node.typeArguments?.params[0].type === utils_1.AST_NODE_TYPES.TSArrayType;
const isReadonlyArrayType = node.typeName.name === 'ReadonlyArray' ||
isReadonlyWithGenericArrayType;
const currentOption = isReadonlyArrayType
? readonlyOption
: defaultOption;
if (currentOption === 'generic') {
return;
}
const readonlyPrefix = isReadonlyArrayType ? 'readonly ' : '';
const typeParams = node.typeArguments?.params;
const messageId = currentOption === 'array'
? isReadonlyWithGenericArrayType
? 'errorStringArrayReadonly'
: 'errorStringArray'
: 'errorStringArraySimple';
if (!typeParams || typeParams.length === 0) {
// Create an 'any' array
context.report({
node,
messageId,
data: {
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
readonlyPrefix,
type: 'any',
},
fix(fixer) {
return fixer.replaceText(node, `${readonlyPrefix}any[]`);
},
});
return;
}
if (typeParams.length !== 1 ||
(currentOption === 'array-simple' && !isSimpleType(typeParams[0]))) {
return;
}
const type = typeParams[0];
const typeParens = typeNeedsParentheses(type);
const parentParens = readonlyPrefix &&
node.parent.type === utils_1.AST_NODE_TYPES.TSArrayType &&
!(0, util_1.isParenthesized)(node.parent.elementType, context.sourceCode);
const start = `${parentParens ? '(' : ''}${readonlyPrefix}${typeParens ? '(' : ''}`;
const end = `${typeParens ? ')' : ''}${isReadonlyWithGenericArrayType ? '' : `[]`}${parentParens ? ')' : ''}`;
context.report({
node,
messageId,
data: {
className: isReadonlyArrayType ? node.typeName.name : 'Array',
readonlyPrefix,
type: getMessageType(type),
},
fix(fixer) {
return [
fixer.replaceTextRange([node.range[0], type.range[0]], start),
fixer.replaceTextRange([type.range[1], node.range[1]], end),
];
},
});
},
};
},
});
//# sourceMappingURL=array-type.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,74 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const tsutils = __importStar(require("ts-api-utils"));
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'await-thenable',
meta: {
docs: {
description: 'Disallow awaiting a value that is not a Thenable',
recommended: 'recommended',
requiresTypeChecking: true,
},
hasSuggestions: true,
messages: {
await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
removeAwait: 'Remove unnecessary `await`.',
},
schema: [],
type: 'problem',
},
defaultOptions: [],
create(context) {
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
return {
AwaitExpression(node) {
const type = services.getTypeAtLocation(node.argument);
if ((0, util_1.isTypeAnyType)(type) || (0, util_1.isTypeUnknownType)(type)) {
return;
}
const originalNode = services.esTreeNodeToTSNodeMap.get(node);
if (!tsutils.isThenableType(checker, originalNode.expression, type)) {
context.report({
messageId: 'await',
node,
suggest: [
{
messageId: 'removeAwait',
fix(fixer) {
const awaitKeyword = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isAwaitKeyword), util_1.NullThrowsReasons.MissingToken('await', 'await expression'));
return fixer.remove(awaitKeyword);
},
},
],
});
}
},
};
},
});
//# sourceMappingURL=await-thenable.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"await-thenable.js","sourceRoot":"","sources":["../../src/rules/await-thenable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AAExC,kCAQiB;AAEjB,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,kDAAkD;YAC/D,WAAW,EAAE,aAAa;YAC1B,oBAAoB,EAAE,IAAI;SAC3B;QACD,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,KAAK,EAAE,6DAA6D;YACpE,WAAW,EAAE,6BAA6B;SAC3C;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,cAAc,EAAE,EAAE;IAElB,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAG,IAAA,wBAAiB,EAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAElD,OAAO;YACL,eAAe,CAAC,IAAI;gBAClB,MAAM,IAAI,GAAG,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACvD,IAAI,IAAA,oBAAa,EAAC,IAAI,CAAC,IAAI,IAAA,wBAAiB,EAAC,IAAI,CAAC,EAAE,CAAC;oBACnD,OAAO;gBACT,CAAC;gBAED,MAAM,YAAY,GAAG,QAAQ,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAE9D,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;oBACpE,OAAO,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,OAAO;wBAClB,IAAI;wBACJ,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,aAAa;gCACxB,GAAG,CAAC,KAAK;oCACP,MAAM,YAAY,GAAG,IAAA,iBAAU,EAC7B,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,EAAE,qBAAc,CAAC,EACtD,wBAAiB,CAAC,YAAY,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAC5D,CAAC;oCAEF,OAAO,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gCACpC,CAAC;6BACF;yBACF;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,178 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const defaultMinimumDescriptionLength = 3;
exports.default = (0, util_1.createRule)({
name: 'ban-ts-comment',
meta: {
type: 'problem',
docs: {
description: 'Disallow `@ts-<directive>` comments or require descriptions after directives',
recommended: {
recommended: true,
strict: [{ minimumDescriptionLength: 10 }],
},
},
messages: {
tsDirectiveComment: 'Do not use "@ts-{{directive}}" because it alters compilation errors.',
tsIgnoreInsteadOfExpectError: 'Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free.',
tsDirectiveCommentRequiresDescription: 'Include a description after the "@ts-{{directive}}" directive to explain why the @ts-{{directive}} is necessary. The description must be {{minimumDescriptionLength}} characters or longer.',
tsDirectiveCommentDescriptionNotMatchPattern: 'The description for the "@ts-{{directive}}" directive must match the {{format}} format.',
replaceTsIgnoreWithTsExpectError: 'Replace "@ts-ignore" with "@ts-expect-error".',
},
hasSuggestions: true,
schema: [
{
$defs: {
directiveConfigSchema: {
oneOf: [
{
type: 'boolean',
default: true,
},
{
type: 'string',
enum: ['allow-with-description'],
},
{
type: 'object',
additionalProperties: false,
properties: {
descriptionFormat: { type: 'string' },
},
},
],
},
},
properties: {
'ts-expect-error': { $ref: '#/items/0/$defs/directiveConfigSchema' },
'ts-ignore': { $ref: '#/items/0/$defs/directiveConfigSchema' },
'ts-nocheck': { $ref: '#/items/0/$defs/directiveConfigSchema' },
'ts-check': { $ref: '#/items/0/$defs/directiveConfigSchema' },
minimumDescriptionLength: {
type: 'number',
default: defaultMinimumDescriptionLength,
},
},
type: 'object',
additionalProperties: false,
},
],
},
defaultOptions: [
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
'ts-nocheck': true,
'ts-check': false,
minimumDescriptionLength: defaultMinimumDescriptionLength,
},
],
create(context, [options]) {
// https://github.com/microsoft/TypeScript/blob/6f1ad5ad8bec5671f7e951a3524b62d82ec4be68/src/compiler/parser.ts#L10591
const singleLinePragmaRegEx = /^\/\/\/?\s*@ts-(?<directive>check|nocheck)(?<description>.*)$/;
/*
The regex used are taken from the ones used in the official TypeScript repo -
https://github.com/microsoft/TypeScript/blob/6f1ad5ad8bec5671f7e951a3524b62d82ec4be68/src/compiler/scanner.ts#L340-L348
*/
const commentDirectiveRegExSingleLine = /^\/*\s*@ts-(?<directive>expect-error|ignore)(?<description>.*)/;
const commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@ts-(?<directive>expect-error|ignore)(?<description>.*)/;
const descriptionFormats = new Map();
for (const directive of [
'ts-expect-error',
'ts-ignore',
'ts-nocheck',
'ts-check',
]) {
const option = options[directive];
if (typeof option === 'object' && option.descriptionFormat) {
descriptionFormats.set(directive, new RegExp(option.descriptionFormat));
}
}
function execDirectiveRegEx(regex, str) {
const match = regex.exec(str);
if (!match) {
return null;
}
const { directive, description } = (0, util_1.nullThrows)(match.groups, 'RegExp should contain groups');
return {
directive: (0, util_1.nullThrows)(directive, 'RegExp should contain "directive" group'),
description: (0, util_1.nullThrows)(description, 'RegExp should contain "description" group'),
};
}
function findDirectiveInComment(comment) {
if (comment.type === utils_1.AST_TOKEN_TYPES.Line) {
const matchedPragma = execDirectiveRegEx(singleLinePragmaRegEx, `//${comment.value}`);
if (matchedPragma) {
return matchedPragma;
}
return execDirectiveRegEx(commentDirectiveRegExSingleLine, comment.value);
}
const commentLines = comment.value.split('\n');
return execDirectiveRegEx(commentDirectiveRegExMultiLine, commentLines[commentLines.length - 1]);
}
return {
Program() {
const comments = context.sourceCode.getAllComments();
comments.forEach(comment => {
const match = findDirectiveInComment(comment);
if (!match) {
return;
}
const { directive, description } = match;
const fullDirective = `ts-${directive}`;
const option = options[fullDirective];
if (option === true) {
if (directive === 'ignore') {
// Special case to suggest @ts-expect-error instead of @ts-ignore
context.report({
node: comment,
messageId: 'tsIgnoreInsteadOfExpectError',
suggest: [
{
messageId: 'replaceTsIgnoreWithTsExpectError',
fix(fixer) {
const commentText = comment.value.replace(/@ts-ignore/, '@ts-expect-error');
return fixer.replaceText(comment, comment.type === utils_1.AST_TOKEN_TYPES.Line
? `//${commentText}`
: `/*${commentText}*/`);
},
},
],
});
}
else {
context.report({
data: { directive },
node: comment,
messageId: 'tsDirectiveComment',
});
}
}
if (option === 'allow-with-description' ||
(typeof option === 'object' && option.descriptionFormat)) {
const { minimumDescriptionLength } = options;
const format = descriptionFormats.get(fullDirective);
if ((0, util_1.getStringLength)(description.trim()) <
(0, util_1.nullThrows)(minimumDescriptionLength, 'Expected minimumDescriptionLength to be set')) {
context.report({
data: { directive, minimumDescriptionLength },
node: comment,
messageId: 'tsDirectiveCommentRequiresDescription',
});
}
else if (format && !format.test(description)) {
context.report({
data: { directive, format: format.source },
node: comment,
messageId: 'tsDirectiveCommentDescriptionNotMatchPattern',
});
}
}
});
},
};
},
});
//# sourceMappingURL=ban-ts-comment.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"ban-ts-comment.js","sourceRoot":"","sources":["../../src/rules/ban-ts-comment.ts"],"names":[],"mappings":";;AACA,oDAA2D;AAE3D,kCAAkE;AAelE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAc1C,kBAAe,IAAA,iBAAU,EAAwB;IAC/C,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8EAA8E;YAChF,WAAW,EAAE;gBACX,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,CAAC,EAAE,wBAAwB,EAAE,EAAE,EAAE,CAAC;aAC3C;SACF;QACD,QAAQ,EAAE;YACR,kBAAkB,EAChB,sEAAsE;YACxE,4BAA4B,EAC1B,sHAAsH;YACxH,qCAAqC,EACnC,6LAA6L;YAC/L,4CAA4C,EAC1C,yFAAyF;YAC3F,gCAAgC,EAC9B,+CAA+C;SAClD;QACD,cAAc,EAAE,IAAI;QACpB,MAAM,EAAE;YACN;gBACE,KAAK,EAAE;oBACL,qBAAqB,EAAE;wBACrB,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,OAAO,EAAE,IAAI;6BACd;4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BACD,MAAM,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC;wBAC7C,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;wBACrD,IACE,IAAA,sBAAe,EAAC,WAAW,CAAC,IAAI,EAAE,CAAC;4BACnC,IAAA,iBAAU,EACR,wBAAwB,EACxB,6CAA6C,CAC9C,EACD,CAAC;4BACD,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE;gCAC7C,IAAI,EAAE,OAAO;gCACb,SAAS,EAAE,uCAAuC;6BACnD,CAAC,CAAC;wBACL,CAAC;6BAAM,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;4BAC/C,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;gCAC1C,IAAI,EAAE,OAAO;gCACb,SAAS,EAAE,8CAA8C;6BAC1D,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,54 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
// tslint regex
// https://github.com/palantir/tslint/blob/95d9d958833fd9dc0002d18cbe34db20d0fbf437/src/enableDisableRules.ts#L32
const ENABLE_DISABLE_REGEX = /^\s*tslint:(enable|disable)(?:-(line|next-line))?(:|\s|$)/;
const toText = (text, type) => type === utils_1.AST_TOKEN_TYPES.Line
? ['//', text.trim()].join(' ')
: ['/*', text.trim(), '*/'].join(' ');
exports.default = (0, util_1.createRule)({
name: 'ban-tslint-comment',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow `// tslint:<rule-flag>` comments',
recommended: 'stylistic',
},
messages: {
commentDetected: 'tslint comment detected: "{{ text }}"',
},
schema: [],
fixable: 'code',
},
defaultOptions: [],
create: context => {
return {
Program() {
const comments = context.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 = context.sourceCode.getIndexFromLoc({
column: c.loc.start.column > 0 ? c.loc.start.column - 1 : 0,
line: c.loc.start.line,
});
const rangeEnd = context.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

@ -1 +0,0 @@
{"version":3,"file":"ban-tslint-comment.js","sourceRoot":"","sources":["../../src/rules/ban-tslint-comment.ts"],"names":[],"mappings":";;AAAA,oDAA2D;AAE3D,kCAAqC;AAErC,eAAe;AACf,iHAAiH;AACjH,MAAM,oBAAoB,GACxB,2DAA2D,CAAC;AAE9D,MAAM,MAAM,GAAG,CACb,IAAY,EACZ,IAAkD,EAC1C,EAAE,CACV,IAAI,KAAK,uBAAe,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,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,WAAW,EAAE,WAAW;SACzB;QACD,QAAQ,EAAE;YACR,eAAe,EAAE,uCAAuC;SACzD;QACD,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,MAAM;KAChB;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@@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TYPE_KEYWORDS = void 0;
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
function removeSpaces(str) {
return str.replace(/\s/g, '');
}
function stringifyNode(node, sourceCode) {
return removeSpaces(sourceCode.getText(node));
}
function getCustomMessage(bannedType) {
if (bannedType == null || bannedType === true) {
return '';
}
if (typeof bannedType === 'string') {
return ` ${bannedType}`;
}
if (bannedType.message) {
return ` ${bannedType.message}`;
}
return '';
}
const defaultTypes = {
String: {
message: 'Use string instead',
fixWith: 'string',
},
Boolean: {
message: 'Use boolean instead',
fixWith: 'boolean',
},
Number: {
message: 'Use number instead',
fixWith: 'number',
},
Symbol: {
message: 'Use symbol instead',
fixWith: 'symbol',
},
BigInt: {
message: 'Use bigint instead',
fixWith: 'bigint',
},
Function: {
message: [
'The `Function` type accepts any function-like value.',
'It provides no type safety when calling the function, which can be a common source of bugs.',
'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.',
'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
].join('\n'),
},
// object typing
Object: {
message: [
'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.',
'- If you want a type meaning "any object", you probably want `object` instead.',
'- If you want a type meaning "any value", you probably want `unknown` instead.',
'- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.',
].join('\n'),
suggest: ['object', 'unknown', 'NonNullable<unknown>'],
},
'{}': {
message: [
'`{}` actually means "any non-nullish value".',
'- If you want a type meaning "any object", you probably want `object` instead.',
'- If you want a type meaning "any value", you probably want `unknown` instead.',
'- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.',
'- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.',
].join('\n'),
suggest: [
'object',
'unknown',
'Record<string, never>',
'NonNullable<unknown>',
],
},
};
exports.TYPE_KEYWORDS = {
bigint: utils_1.AST_NODE_TYPES.TSBigIntKeyword,
boolean: utils_1.AST_NODE_TYPES.TSBooleanKeyword,
never: utils_1.AST_NODE_TYPES.TSNeverKeyword,
null: utils_1.AST_NODE_TYPES.TSNullKeyword,
number: utils_1.AST_NODE_TYPES.TSNumberKeyword,
object: utils_1.AST_NODE_TYPES.TSObjectKeyword,
string: utils_1.AST_NODE_TYPES.TSStringKeyword,
symbol: utils_1.AST_NODE_TYPES.TSSymbolKeyword,
undefined: utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
unknown: utils_1.AST_NODE_TYPES.TSUnknownKeyword,
void: utils_1.AST_NODE_TYPES.TSVoidKeyword,
};
exports.default = (0, util_1.createRule)({
name: 'ban-types',
meta: {
type: 'suggestion',
docs: {
description: 'Disallow certain types',
recommended: 'recommended',
},
fixable: 'code',
hasSuggestions: true,
messages: {
bannedTypeMessage: "Don't use `{{name}}` as a type.{{customMessage}}",
bannedTypeReplacement: 'Replace `{{name}}` with `{{replacement}}`.',
},
schema: [
{
$defs: {
banConfig: {
oneOf: [
{
type: 'null',
description: 'Bans the type with the default message',
},
{
type: 'boolean',
enum: [false],
description: 'Un-bans the type (useful when paired with `extendDefaults`)',
},
{
type: 'boolean',
enum: [true],
description: 'Bans the type with the default message',
},
{
type: 'string',
description: 'Bans the type with a custom message',
},
{
type: 'object',
description: 'Bans a type',
properties: {
message: {
type: 'string',
description: 'Custom error message',
},
fixWith: {
type: 'string',
description: 'Type to autofix replace with. Note that autofixers can be applied automatically - so you need to be careful with this option.',
},
suggest: {
type: 'array',
items: { type: 'string' },
description: 'Types to suggest replacing with.',
additionalItems: false,
},
},
additionalProperties: false,
},
],
},
},
type: 'object',
properties: {
types: {
type: 'object',
additionalProperties: {
$ref: '#/items/0/$defs/banConfig',
},
},
extendDefaults: {
type: 'boolean',
},
},
additionalProperties: false,
},
],
},
defaultOptions: [{}],
create(context, [options]) {
const extendDefaults = options.extendDefaults ?? true;
const customTypes = options.types ?? {};
const types = {
...(extendDefaults && defaultTypes),
...customTypes,
};
const bannedTypes = new Map(Object.entries(types).map(([type, data]) => [removeSpaces(type), data]));
function checkBannedTypes(typeNode, name = stringifyNode(typeNode, context.sourceCode)) {
const bannedType = bannedTypes.get(name);
if (bannedType === undefined || bannedType === false) {
return;
}
const customMessage = getCustomMessage(bannedType);
const fixWith = bannedType && typeof bannedType === 'object' && bannedType.fixWith;
const suggest = bannedType && typeof bannedType === 'object'
? bannedType.suggest
: undefined;
context.report({
node: typeNode,
messageId: 'bannedTypeMessage',
data: {
name,
customMessage,
},
fix: fixWith
? (fixer) => fixer.replaceText(typeNode, fixWith)
: null,
suggest: suggest?.map(replacement => ({
messageId: 'bannedTypeReplacement',
data: {
name,
replacement,
},
fix: (fixer) => fixer.replaceText(typeNode, replacement),
})),
});
}
const keywordSelectors = (0, util_1.objectReduceKey)(exports.TYPE_KEYWORDS, (acc, keyword) => {
if (bannedTypes.has(keyword)) {
acc[exports.TYPE_KEYWORDS[keyword]] = (node) => checkBannedTypes(node, keyword);
}
return acc;
}, {});
return {
...keywordSelectors,
TSTypeLiteral(node) {
if (node.members.length) {
return;
}
checkBannedTypes(node);
},
TSTupleType(node) {
if (node.elementTypes.length === 0) {
checkBannedTypes(node);
}
},
TSTypeReference(node) {
checkBannedTypes(node.typeName);
if (node.typeArguments) {
checkBannedTypes(node);
}
},
TSInterfaceHeritage(node) {
checkBannedTypes(node);
},
TSClassImplements(node) {
checkBannedTypes(node);
},
};
},
});
//# sourceMappingURL=ban-types.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,138 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('block-spacing');
exports.default = (0, util_1.createRule)({
name: 'block-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/block-spacing'],
type: 'layout',
docs: {
description: 'Disallow or enforce spaces inside of blocks after opening block and before closing block',
extendsBaseRule: true,
},
fixable: 'whitespace',
hasSuggestions: baseRule.meta.hasSuggestions,
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
},
defaultOptions: ['always'],
create(context, [whenToApplyOption]) {
const baseRules = baseRule.create(context);
const always = whenToApplyOption !== 'never';
const messageId = always ? 'missing' : 'extra';
/**
* Gets the open brace token from a given node.
* @returns The token of the open brace.
*/
function getOpenBrace(node) {
// guaranteed for enums
// This is the only change made here from the base rule
return context.sourceCode.getFirstToken(node, {
filter: token => token.type === utils_1.AST_TOKEN_TYPES.Punctuator && token.value === '{',
});
}
/**
* Checks whether or not:
* - given tokens are on same line.
* - there is/isn't a space between given tokens.
* @param left A token to check.
* @param right The token which is next to `left`.
* @returns
* When the option is `"always"`, `true` if there are one or more spaces between given tokens.
* When the option is `"never"`, `true` if there are not any spaces between given tokens.
* If given tokens are not on same line, it's always `true`.
*/
function isValid(left, right) {
return (!(0, util_1.isTokenOnSameLine)(left, right) ||
context.sourceCode.isSpaceBetween(left, right) === always);
}
/**
* Checks and reports invalid spacing style inside braces.
*/
function checkSpacingInsideBraces(node) {
// Gets braces and the first/last token of content.
const openBrace = getOpenBrace(node);
const closeBrace = context.sourceCode.getLastToken(node);
const firstToken = context.sourceCode.getTokenAfter(openBrace, {
includeComments: true,
});
const lastToken = context.sourceCode.getTokenBefore(closeBrace, {
includeComments: true,
});
// Skip if the node is invalid or empty.
if (openBrace.value !== '{' ||
closeBrace.type !== utils_1.AST_TOKEN_TYPES.Punctuator ||
closeBrace.value !== '}' ||
firstToken === closeBrace) {
return;
}
// Skip line comments for option never
if (!always && firstToken.type === utils_1.AST_TOKEN_TYPES.Line) {
return;
}
if (!isValid(openBrace, firstToken)) {
let loc = openBrace.loc;
if (messageId === 'extra') {
loc = {
start: openBrace.loc.end,
end: firstToken.loc.start,
};
}
context.report({
node,
loc,
messageId,
data: {
location: 'after',
token: openBrace.value,
},
fix(fixer) {
if (always) {
return fixer.insertTextBefore(firstToken, ' ');
}
return fixer.removeRange([openBrace.range[1], firstToken.range[0]]);
},
});
}
if (!isValid(lastToken, closeBrace)) {
let loc = closeBrace.loc;
if (messageId === 'extra') {
loc = {
start: lastToken.loc.end,
end: closeBrace.loc.start,
};
}
context.report({
node,
loc,
messageId,
data: {
location: 'before',
token: closeBrace.value,
},
fix(fixer) {
if (always) {
return fixer.insertTextAfter(lastToken, ' ');
}
return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]);
},
});
}
}
return {
...baseRules,
// This code worked "out of the box" for interface and type literal
// Enums were very close to match as well, the only reason they are not is that was that enums don't have a body node in the parser
// So the opening brace punctuator starts in the middle of the node - `getFirstToken` in
// the base rule did not filter for the first opening brace punctuator
TSInterfaceBody: baseRules.BlockStatement,
TSTypeLiteral: baseRules.BlockStatement,
TSEnumDeclaration: checkSpacingInsideBraces,
};
},
});
//# sourceMappingURL=block-spacing.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"block-spacing.js","sourceRoot":"","sources":["../../src/rules/block-spacing.ts"],"names":[],"mappings":";;AAEA,oDAA2D;AAM3D,kCAAwD;AACxD,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,eAAe,CAAC,CAAC;AAKpD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,6BAA6B,CAAC;QAC3C,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EACT,0FAA0F;YAC5F,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAE1B,MAAM,CAAC,OAAO,EAAE,CAAC,iBAAiB,CAAC;QAC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AS,CAAC,GAAG,CAAC,GAAG;wBACxB,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,KAAK;qBAC1B,CAAC;gBACJ,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS;oBACT,IAAI,EAAE;wBACJ,QAAQ,EAAE,QAAQ;wBAClB,KAAK,EAAE,UAAU,CAAC,KAAK;qBACxB;oBACD,GAAG,CAAC,KAAK;wBACP,IAAI,MAAM,EAAE,CAAC;4BACX,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;wBAC/C,CAAC;wBAED,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACtE,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO;YACL,GAAG,SAAS;YAEZ,mEAAmE;YACnE,mIAAmI;YACnI,wFAAwF;YACxF,sEAAsE;YACtE,eAAe,EAAE,SAAS,CAAC,cAAuB;YAClD,aAAa,EAAE,SAAS,CAAC,cAAuB;YAChD,iBAAiB,EAAE,wBAAwB;SAC5C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,97 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('brace-style');
exports.default = (0, util_1.createRule)({
name: 'brace-style',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/brace-style'],
type: 'layout',
docs: {
description: 'Enforce consistent brace style for blocks',
extendsBaseRule: true,
},
messages: baseRule.meta.messages,
fixable: baseRule.meta.fixable,
hasSuggestions: baseRule.meta.hasSuggestions,
schema: baseRule.meta.schema,
},
defaultOptions: ['1tbs'],
create(context) {
const [style, { allowSingleLine } = { allowSingleLine: false }] =
// eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules.
context.options;
const isAllmanStyle = style === 'allman';
const rules = baseRule.create(context);
/**
* Checks a pair of curly brackets based on the user's config
*/
function validateCurlyPair(openingCurlyToken, closingCurlyToken) {
if (allowSingleLine &&
(0, util_1.isTokenOnSameLine)(openingCurlyToken, closingCurlyToken)) {
return;
}
const tokenBeforeOpeningCurly = context.sourceCode.getTokenBefore(openingCurlyToken);
const tokenBeforeClosingCurly = context.sourceCode.getTokenBefore(closingCurlyToken);
const tokenAfterOpeningCurly = context.sourceCode.getTokenAfter(openingCurlyToken);
if (!isAllmanStyle &&
!(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
context.report({
node: openingCurlyToken,
messageId: 'nextLineOpen',
fix: fixer => {
const textRange = [
tokenBeforeOpeningCurly.range[1],
openingCurlyToken.range[0],
];
const textBetween = context.sourceCode.text.slice(textRange[0], textRange[1]);
if (textBetween.trim()) {
return null;
}
return fixer.replaceTextRange(textRange, ' ');
},
});
}
if (isAllmanStyle &&
(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
context.report({
node: openingCurlyToken,
messageId: 'sameLineOpen',
fix: fixer => fixer.insertTextBefore(openingCurlyToken, '\n'),
});
}
if ((0, util_1.isTokenOnSameLine)(openingCurlyToken, tokenAfterOpeningCurly) &&
tokenAfterOpeningCurly !== closingCurlyToken) {
context.report({
node: openingCurlyToken,
messageId: 'blockSameLine',
fix: fixer => fixer.insertTextAfter(openingCurlyToken, '\n'),
});
}
if ((0, util_1.isTokenOnSameLine)(tokenBeforeClosingCurly, closingCurlyToken) &&
tokenBeforeClosingCurly !== openingCurlyToken) {
context.report({
node: closingCurlyToken,
messageId: 'singleLineClose',
fix: fixer => fixer.insertTextBefore(closingCurlyToken, '\n'),
});
}
}
return {
...rules,
'TSInterfaceBody, TSModuleBlock'(node) {
const openingCurly = context.sourceCode.getFirstToken(node);
const closingCurly = context.sourceCode.getLastToken(node);
validateCurlyPair(openingCurly, closingCurly);
},
TSEnumDeclaration(node) {
const closingCurly = context.sourceCode.getLastToken(node);
const openingCurly = context.sourceCode.getTokenBefore(node.members.length ? node.members[0] : closingCurly);
validateCurlyPair(openingCurly, closingCurly);
},
};
},
});
//# sourceMappingURL=brace-style.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"brace-style.js","sourceRoot":"","sources":["../../src/rules/brace-style.ts"],"names":[],"mappings":";;AAOA,kCAAwD;AACxD,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,aAAa,CAAC,CAAC;AAKlD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,2BAA2B,CAAC;QACzC,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,eAAe,EAAE,IAAI;SACtB;QACD,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;QAChC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;QAC9B,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;KAC7B;IACD,cAAc,EAAE,CAAC,MAAM,CAAC;IACxB,MAAM,CAAC,OAAO;QACZ,MAAM,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAC7D,uFAAuF;QACvF,OAAO,CAAC,OAAO,CAAC;QAElB,MAAM,aAAa,GAAG,KAAK,KAAK,QAAQ,CAAC;QAEzC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC;;WAEG;QACH,SAAS,iBAAiB,CACxB,iBAAiC,EACjC,iBAAiC;Y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C,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CACpD,CAAC;gBAEH,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,164 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const printNodeModifiers = (node, final) => `${node.accessibility ?? ''}${node.static ? ' static' : ''} ${final} `.trimStart();
const isSupportedLiteral = (node) => {
switch (node.type) {
case utils_1.AST_NODE_TYPES.Literal:
return true;
case utils_1.AST_NODE_TYPES.TaggedTemplateExpression:
return node.quasi.quasis.length === 1;
case utils_1.AST_NODE_TYPES.TemplateLiteral:
return node.quasis.length === 1;
default:
return false;
}
};
exports.default = (0, util_1.createRule)({
name: 'class-literal-property-style',
meta: {
type: 'problem',
docs: {
description: 'Enforce that literals on classes are exposed in a consistent style',
recommended: 'stylistic',
},
hasSuggestions: true,
messages: {
preferFieldStyle: 'Literals should be exposed using readonly fields.',
preferFieldStyleSuggestion: 'Replace the literals with readonly fields.',
preferGetterStyle: 'Literals should be exposed using getters.',
preferGetterStyleSuggestion: 'Replace the literals with getters.',
},
schema: [
{
type: 'string',
enum: ['fields', 'getters'],
},
],
},
defaultOptions: ['fields'],
create(context, [style]) {
const propertiesInfoStack = [];
function getStringValue(node) {
return (0, util_1.getStaticStringValue)(node) ?? context.sourceCode.getText(node);
}
function enterClassBody() {
propertiesInfoStack.push({
properties: [],
excludeSet: new Set(),
});
}
function exitClassBody() {
const { properties, excludeSet } = (0, util_1.nullThrows)(propertiesInfoStack.pop(), 'Stack should exist on class exit');
properties.forEach(node => {
const { value } = node;
if (!value || !isSupportedLiteral(value)) {
return;
}
const name = getStringValue(node.key);
if (excludeSet.has(name)) {
return;
}
context.report({
node: node.key,
messageId: 'preferGetterStyle',
suggest: [
{
messageId: 'preferGetterStyleSuggestion',
fix(fixer) {
const name = context.sourceCode.getText(node.key);
let text = '';
text += printNodeModifiers(node, 'get');
text += node.computed ? `[${name}]` : name;
text += `() { return ${context.sourceCode.getText(value)}; }`;
return fixer.replaceText(node, text);
},
},
],
});
});
}
function excludeAssignedProperty(node) {
if ((0, util_1.isAssignee)(node)) {
const { excludeSet } = propertiesInfoStack[propertiesInfoStack.length - 1];
const name = (0, util_1.getStaticStringValue)(node.property) ??
context.sourceCode.getText(node.property);
if (name) {
excludeSet.add(name);
}
}
}
return {
...(style === 'fields' && {
MethodDefinition(node) {
if (node.kind !== 'get' ||
!node.value.body ||
node.value.body.body.length === 0) {
return;
}
const [statement] = node.value.body.body;
if (statement.type !== utils_1.AST_NODE_TYPES.ReturnStatement) {
return;
}
const { argument } = statement;
if (!argument || !isSupportedLiteral(argument)) {
return;
}
const name = getStringValue(node.key);
if (node.parent.type === utils_1.AST_NODE_TYPES.ClassBody) {
const hasDuplicateKeySetter = node.parent.body.some(element => {
return (element.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
element.kind === 'set' &&
getStringValue(element.key) === name);
});
if (hasDuplicateKeySetter) {
return;
}
}
context.report({
node: node.key,
messageId: 'preferFieldStyle',
suggest: [
{
messageId: 'preferFieldStyleSuggestion',
fix(fixer) {
const name = context.sourceCode.getText(node.key);
let text = '';
text += printNodeModifiers(node, 'readonly');
text += node.computed ? `[${name}]` : name;
text += ` = ${context.sourceCode.getText(argument)};`;
return fixer.replaceText(node, text);
},
},
],
});
},
}),
...(style === 'getters' && {
ClassBody: enterClassBody,
'ClassBody:exit': exitClassBody,
'MethodDefinition[kind="constructor"] ThisExpression'(node) {
if (node.parent.type === utils_1.AST_NODE_TYPES.MemberExpression) {
let parent = node.parent;
while (!(0, util_1.isFunction)(parent)) {
parent = parent.parent;
}
if (parent.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
parent.parent.kind === 'constructor') {
excludeAssignedProperty(node.parent);
}
}
},
PropertyDefinition(node) {
if (!node.readonly || node.declare) {
return;
}
const { properties } = propertiesInfoStack[propertiesInfoStack.length - 1];
properties.push(node);
},
}),
};
},
});
//# sourceMappingURL=class-literal-property-style.js.map

View file

@ -1,209 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'class-methods-use-this',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce that class methods utilize `this`',
extendsBaseRule: true,
requiresTypeChecking: false,
},
schema: [
{
type: 'object',
properties: {
exceptMethods: {
type: 'array',
description: 'Allows specified method names to be ignored with this rule',
items: {
type: 'string',
},
},
enforceForClassFields: {
type: 'boolean',
description: 'Enforces that functions used as instance field initializers utilize `this`',
default: true,
},
ignoreOverrideMethods: {
type: 'boolean',
description: 'Ignore members marked with the `override` modifier',
},
ignoreClassesThatImplementAnInterface: {
oneOf: [
{
type: 'boolean',
description: 'Ignore all classes that implement an interface',
},
{
type: 'string',
enum: ['public-fields'],
description: 'Ignore only the public fields of classes that implement an interface',
},
],
description: 'Ignore classes that specifically implement some interface',
},
},
additionalProperties: false,
},
],
messages: {
missingThis: "Expected 'this' to be used by class {{name}}.",
},
},
defaultOptions: [
{
enforceForClassFields: true,
exceptMethods: [],
ignoreClassesThatImplementAnInterface: false,
ignoreOverrideMethods: false,
},
],
create(context, [{ enforceForClassFields, exceptMethods: exceptMethodsRaw, ignoreClassesThatImplementAnInterface, ignoreOverrideMethods, },]) {
const exceptMethods = new Set(exceptMethodsRaw);
let stack;
function pushContext(member) {
if (member?.parent.type === utils_1.AST_NODE_TYPES.ClassBody) {
stack = {
member,
class: member.parent.parent,
usesThis: false,
parent: stack,
};
}
else {
stack = {
member: null,
class: null,
usesThis: false,
parent: stack,
};
}
}
function enterFunction(node) {
if (node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
node.parent.type === utils_1.AST_NODE_TYPES.PropertyDefinition) {
pushContext(node.parent);
}
else {
pushContext();
}
}
/**
* Pop `this` used flag from the stack.
*/
function popContext() {
const oldStack = stack;
stack = stack?.parent;
return oldStack;
}
function isPublicField(accessibility) {
if (!accessibility || accessibility === 'public') {
return true;
}
return false;
}
/**
* Check if the node is an instance method not excluded by config
*/
function isIncludedInstanceMethod(node) {
if (node.static ||
(node.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
node.kind === 'constructor') ||
(node.type === utils_1.AST_NODE_TYPES.PropertyDefinition &&
!enforceForClassFields)) {
return false;
}
if (node.computed || exceptMethods.size === 0) {
return true;
}
const hashIfNeeded = node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier ? '#' : '';
const name = node.key.type === utils_1.AST_NODE_TYPES.Literal
? (0, util_1.getStaticStringValue)(node.key)
: node.key.name || '';
return !exceptMethods.has(hashIfNeeded + (name ?? ''));
}
/**
* Checks if we are leaving a function that is a method, and reports if 'this' has not been used.
* Static methods and the constructor are exempt.
* Then pops the context off the stack.
*/
function exitFunction(node) {
const stackContext = popContext();
if (stackContext?.member == null ||
stackContext.usesThis ||
(ignoreOverrideMethods && stackContext.member.override) ||
(ignoreClassesThatImplementAnInterface === true &&
stackContext.class.implements.length > 0) ||
(ignoreClassesThatImplementAnInterface === 'public-fields' &&
stackContext.class.implements.length > 0 &&
isPublicField(stackContext.member.accessibility))) {
return;
}
if (isIncludedInstanceMethod(stackContext.member)) {
context.report({
node,
loc: (0, util_1.getFunctionHeadLoc)(node, context.sourceCode),
messageId: 'missingThis',
data: {
name: (0, util_1.getFunctionNameWithKind)(node),
},
});
}
}
return {
// function declarations have their own `this` context
FunctionDeclaration() {
pushContext();
},
'FunctionDeclaration:exit'() {
popContext();
},
FunctionExpression(node) {
enterFunction(node);
},
'FunctionExpression:exit'(node) {
exitFunction(node);
},
...(enforceForClassFields
? {
'PropertyDefinition > ArrowFunctionExpression.value'(node) {
enterFunction(node);
},
'PropertyDefinition > ArrowFunctionExpression.value:exit'(node) {
exitFunction(node);
},
}
: {}),
/*
* Class field value are implicit functions.
*/
'PropertyDefinition > *.key:exit'() {
pushContext();
},
'PropertyDefinition:exit'() {
popContext();
},
/*
* Class static blocks are implicit functions. They aren't required to use `this`,
* but we have to push context so that it captures any use of `this` in the static block
* separately from enclosing contexts, because static blocks have their own `this` and it
* shouldn't count as used `this` in enclosing contexts.
*/
StaticBlock() {
pushContext();
},
'StaticBlock:exit'() {
popContext();
},
'ThisExpression, Super'() {
if (stack) {
stack.usesThis = true;
}
},
};
},
});
//# sourceMappingURL=class-methods-use-this.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"class-methods-use-this.js","sourceRoot":"","sources":["../../src/rules/class-methods-use-this.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAKiB;AAYjB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,KAAK;SAC5B;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,OAAO;wBACb,WAAW,EACT,4DAA4D;wBAC9D,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,qBAAqB,EAAE;wBACrB,IAAI,EAAE,SAAS;wBACf,WAAW,EACT,4EAA4E;wBAC9E,OAAO,EAAE,IAAI;qBACd;oBACD,qBAAqB,EAAE;wBACrB,IAAI,EAAE,SAAS;wBACf,WAAW,EAAE,oDAAoD;qBAClE;oBACD,qCAAqC,EAAE;wBACrC,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,WAAW,EAAE,gDAAgD;6BAC9D;4BACD;gCACE,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,eAAe,CAAC;gCACvB,WAAW,EACT,sEAAsE;6BAC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CAAC,CAAC;oBACrB,CAAC;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YAEP;;eAEG;YACH,iCAAiC;gBAC/B,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,yBAAyB;gBACvB,UAAU,EAAE,CAAC;YACf,CAAC;YAED;;;;;eAKG;YACH,WAAW;gBACT,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,kBAAkB;gBAChB,UAAU,EAAE,CAAC;YACf,CAAC;YAED,uBAAuB;gBACrB,IAAI,KAAK,EAAE,CAAC;oBACV,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACxB,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,164 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('comma-dangle');
const OPTION_VALUE_SCHEME = [
'always-multiline',
'always',
'never',
'only-multiline',
];
const DEFAULT_OPTION_VALUE = 'never';
function normalizeOptions(options) {
if (typeof options === 'string') {
return {
enums: options,
generics: options,
tuples: options,
};
}
return {
enums: options.enums ?? DEFAULT_OPTION_VALUE,
generics: options.generics ?? DEFAULT_OPTION_VALUE,
tuples: options.tuples ?? DEFAULT_OPTION_VALUE,
};
}
exports.default = (0, util_1.createRule)({
name: 'comma-dangle',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/comma-dangle'],
type: 'layout',
docs: {
description: 'Require or disallow trailing commas',
extendsBaseRule: true,
},
schema: {
$defs: {
value: {
type: 'string',
enum: OPTION_VALUE_SCHEME,
},
valueWithIgnore: {
type: 'string',
enum: [...OPTION_VALUE_SCHEME, 'ignore'],
},
},
type: 'array',
items: [
{
oneOf: [
{
$ref: '#/$defs/value',
},
{
type: 'object',
properties: {
arrays: { $ref: '#/$defs/valueWithIgnore' },
objects: { $ref: '#/$defs/valueWithIgnore' },
imports: { $ref: '#/$defs/valueWithIgnore' },
exports: { $ref: '#/$defs/valueWithIgnore' },
functions: { $ref: '#/$defs/valueWithIgnore' },
enums: { $ref: '#/$defs/valueWithIgnore' },
generics: { $ref: '#/$defs/valueWithIgnore' },
tuples: { $ref: '#/$defs/valueWithIgnore' },
},
additionalProperties: false,
},
],
},
],
additionalItems: false,
},
fixable: 'code',
hasSuggestions: baseRule.meta.hasSuggestions,
messages: baseRule.meta.messages,
},
defaultOptions: ['never'],
create(context, [options]) {
const rules = baseRule.create(context);
const normalizedOptions = normalizeOptions(options);
const predicate = {
always: forceComma,
'always-multiline': forceCommaIfMultiline,
'only-multiline': allowCommaIfMultiline,
never: forbidComma,
// https://github.com/typescript-eslint/typescript-eslint/issues/7220
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-empty-function
ignore: () => { },
};
function last(nodes) {
return nodes[nodes.length - 1] ?? null;
}
function getLastItem(node) {
switch (node.type) {
case utils_1.AST_NODE_TYPES.TSEnumDeclaration:
return last(node.members);
case utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration:
return last(node.params);
case utils_1.AST_NODE_TYPES.TSTupleType:
return last(node.elementTypes);
default:
return null;
}
}
function getTrailingToken(node) {
const last = getLastItem(node);
const trailing = last && context.sourceCode.getTokenAfter(last);
return trailing;
}
function isMultiline(node) {
const last = getLastItem(node);
const lastToken = context.sourceCode.getLastToken(node);
return last?.loc.end.line !== lastToken?.loc.end.line;
}
function forbidComma(node) {
const last = getLastItem(node);
const trailing = getTrailingToken(node);
if (last && trailing && (0, util_1.isCommaToken)(trailing)) {
context.report({
node,
messageId: 'unexpected',
fix(fixer) {
return fixer.remove(trailing);
},
});
}
}
function forceComma(node) {
const last = getLastItem(node);
const trailing = getTrailingToken(node);
if (last && trailing && !(0, util_1.isCommaToken)(trailing)) {
context.report({
node,
messageId: 'missing',
fix(fixer) {
return fixer.insertTextAfter(last, ',');
},
});
}
}
function allowCommaIfMultiline(node) {
if (!isMultiline(node)) {
forbidComma(node);
}
}
function forceCommaIfMultiline(node) {
if (isMultiline(node)) {
forceComma(node);
}
else {
forbidComma(node);
}
}
return {
...rules,
TSEnumDeclaration: predicate[normalizedOptions.enums],
TSTypeParameterDeclaration: predicate[normalizedOptions.generics],
TSTupleType: predicate[normalizedOptions.tuples],
};
},
});
//# sourceMappingURL=comma-dangle.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"comma-dangle.js","sourceRoot":"","sources":["../../src/rules/comma-dangle.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAM1D,kCAAmD;AACnD,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC;AAUnD,MAAM,mBAAmB,GAAG;IAC1B,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,gBAAgB;CACjB,CAAC;AAEF,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAErC,SAAS,gBAAgB,CAAC,OAAe;IACvC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO;YACL,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,OAAO;SAChB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,oBAAoB;QAC5C,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,oBAAoB;QAClD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,oBAAoB;KAC/C,CAAC;AACJ,CAAC;AAED,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,4BAA4B,CAAC;QAC1C,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,qCAAqC;YAClD,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,KA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iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC;YACrD,0BAA0B,EAAE,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YACjE,WAAW,EAAE,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC;SACjD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,149 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'comma-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/comma-spacing'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing before and after commas',
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 tokensAndComments = context.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 = context.sourceCode.getFirstToken(node);
for (const element of node.elements) {
let token;
if (element == null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
token = context.sourceCode.getTokenAfter(previousToken);
if (token && (0, util_1.isCommaToken)(token)) {
ignoredTokens.add(token);
}
}
else {
token = context.sourceCode.getTokenAfter(element);
}
previousToken = token;
}
}
/**
* Adds type parameters trailing comma token to the ignore list
* @param node node to evaluate
*/
function addTypeParametersTrailingCommaToIgnoreList(node) {
const paramLength = node.params.length;
if (paramLength) {
const param = node.params[paramLength - 1];
const afterToken = context.sourceCode.getTokenAfter(param);
if (afterToken && (0, util_1.isCommaToken)(afterToken)) {
ignoredTokens.add(afterToken);
}
}
}
/**
* Validates the spacing around a comma token.
* @param commaToken The token representing the comma
* @param prevToken The last token before the comma
* @param nextToken The first token after the comma
*/
function validateCommaSpacing(commaToken, prevToken, nextToken) {
if (prevToken &&
(0, util_1.isTokenOnSameLine)(prevToken, commaToken) &&
spaceBefore !== context.sourceCode.isSpaceBetween(prevToken, commaToken)) {
context.report({
node: commaToken,
data: {
loc: 'before',
},
messageId: spaceBefore ? 'missing' : 'unexpected',
fix: fixer => spaceBefore
? fixer.insertTextBefore(commaToken, ' ')
: fixer.replaceTextRange([prevToken.range[1], commaToken.range[0]], ''),
});
}
if (nextToken && (0, util_1.isClosingParenToken)(nextToken)) {
return;
}
if (spaceAfter &&
nextToken &&
((0, util_1.isClosingBraceToken)(nextToken) || (0, util_1.isClosingBracketToken)(nextToken))) {
return;
}
if (!spaceAfter && nextToken && nextToken.type === utils_1.AST_TOKEN_TYPES.Line) {
return;
}
if (nextToken &&
(0, util_1.isTokenOnSameLine)(commaToken, nextToken) &&
spaceAfter !== context.sourceCode.isSpaceBetween(commaToken, nextToken)) {
context.report({
node: commaToken,
data: {
loc: 'after',
},
messageId: spaceAfter ? 'missing' : 'unexpected',
fix: fixer => spaceAfter
? fixer.insertTextAfter(commaToken, ' ')
: fixer.replaceTextRange([commaToken.range[1], nextToken.range[0]], ''),
});
}
}
return {
TSTypeParameterDeclaration: addTypeParametersTrailingCommaToIgnoreList,
ArrayExpression: addNullElementsToIgnoreList,
ArrayPattern: addNullElementsToIgnoreList,
'Program:exit'() {
tokensAndComments.forEach((token, i) => {
if (!(0, util_1.isCommaToken)(token)) {
return;
}
const prevToken = tokensAndComments[i - 1];
const nextToken = tokensAndComments.at(i + 1);
validateCommaSpacing(token, (0, util_1.isCommaToken)(prevToken) || ignoredTokens.has(token)
? null
: prevToken, (nextToken && (0, util_1.isCommaToken)(nextToken)) || ignoredTokens.has(token)
? null
: nextToken ?? null);
});
},
};
},
});
//# sourceMappingURL=comma-spacing.js.map

View file

@ -1 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AAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACzC,EAAE,CACH;iBACR,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,0BAA0B,EAAE,0CAA0C;YACtE,eAAe,EAAE,2BAA2B;YAC5C,YAAY,EAAE,2BAA2B;YAEzC,cAAc;gBACZ,iBAAiB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;oBACrC,IAAI,CAAC,IAAA,mBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;wBACzB,OAAO;oBACT,CAAC;oBAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC3C,MAAM,SAAS,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBAE9C,oBAAoB,CAClB,KAAK,EACL,IAAA,mBAAY,EAAC,SAAS,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;wBACjD,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,SAAS,EACb,CAAC,SAAS,IAAI,IAAA,mBAAY,EAAC,SAAS,CAAC,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;wBAChE,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,SAAS,IAAI,IAAI,CACtB,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,108 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-generic-constructors',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce specifying generic type arguments on type annotation or constructor name of a constructor call',
recommended: 'stylistic',
},
messages: {
preferTypeAnnotation: 'The generic type arguments should be specified as part of the type annotation.',
preferConstructor: 'The generic type arguments should be specified as part of the constructor type arguments.',
},
fixable: 'code',
schema: [
{
type: 'string',
enum: ['type-annotation', 'constructor'],
},
],
},
defaultOptions: ['constructor'],
create(context, [mode]) {
return {
'VariableDeclarator,PropertyDefinition,:matches(FunctionDeclaration,FunctionExpression) > AssignmentPattern'(node) {
function getLHSRHS() {
switch (node.type) {
case utils_1.AST_NODE_TYPES.VariableDeclarator:
return [node.id, node.init];
case utils_1.AST_NODE_TYPES.PropertyDefinition:
return [node, node.value];
case utils_1.AST_NODE_TYPES.AssignmentPattern:
return [node.left, node.right];
default:
throw new Error(`Unhandled node type: ${node.type}`);
}
}
const [lhsName, rhs] = getLHSRHS();
const lhs = lhsName.typeAnnotation?.typeAnnotation;
if (!rhs ||
rhs.type !== utils_1.AST_NODE_TYPES.NewExpression ||
rhs.callee.type !== utils_1.AST_NODE_TYPES.Identifier) {
return;
}
if (lhs &&
(lhs.type !== utils_1.AST_NODE_TYPES.TSTypeReference ||
lhs.typeName.type !== utils_1.AST_NODE_TYPES.Identifier ||
lhs.typeName.name !== rhs.callee.name)) {
return;
}
if (mode === 'type-annotation') {
if (!lhs && rhs.typeArguments) {
const { typeArguments, callee } = rhs;
const typeAnnotation = context.sourceCode.getText(callee) +
context.sourceCode.getText(typeArguments);
context.report({
node,
messageId: 'preferTypeAnnotation',
fix(fixer) {
function getIDToAttachAnnotation() {
if (node.type !== utils_1.AST_NODE_TYPES.PropertyDefinition) {
return lhsName;
}
if (!node.computed) {
return node.key;
}
// If the property's computed, we have to attach the
// annotation after the square bracket, not the enclosed expression
return (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(node.key), util_1.NullThrowsReasons.MissingToken(']', 'key'));
}
return [
fixer.remove(typeArguments),
fixer.insertTextAfter(getIDToAttachAnnotation(), ': ' + typeAnnotation),
];
},
});
}
return;
}
if (lhs?.typeArguments && !rhs.typeArguments) {
const hasParens = context.sourceCode.getTokenAfter(rhs.callee)?.value === '(';
const extraComments = new Set(context.sourceCode.getCommentsInside(lhs.parent));
context.sourceCode
.getCommentsInside(lhs.typeArguments)
.forEach(c => extraComments.delete(c));
context.report({
node,
messageId: 'preferConstructor',
*fix(fixer) {
yield fixer.remove(lhs.parent);
for (const comment of extraComments) {
yield fixer.insertTextAfter(rhs.callee, context.sourceCode.getText(comment));
}
yield fixer.insertTextAfter(rhs.callee, context.sourceCode.getText(lhs.typeArguments));
if (!hasParens) {
yield fixer.insertTextAfter(rhs.callee, '()');
}
},
});
}
},
};
},
});
//# sourceMappingURL=consistent-generic-constructors.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"consistent-generic-constructors.js","sourceRoot":"","sources":["../../src/rules/consistent-generic-constructors.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAoE;AAKpE,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,wGAAwG;YAC1G,WAAW,EAAE,WAAW;SACzB;QACD,QAAQ,EAAE;YACR,oBAAoB,EAClB,gFAAgF;YAClF,iBAAiB,EACf,2FAA2F;SAC9F;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC;aACzC;SACF;KACF;IACD,cAAc,EAAE,CAAC,aAAa,CAAC;IAC/B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,OAAO;YACL,4GAA4G,CAC1G,IAG+B;gBAE/B,SAAS,SAAS;oBAIhB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;wBAClB,KAAK,sBAAc,CAAC,kBAAkB;4BACpC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC9B,KAAK,sBAAc,CAAC,kBAAkB;4BACpC,OAAO,CAAC,IAAI,EAAE,IAAI,CA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,MAAM,CAAC,CAAC;4BAC/B,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;gCACpC,MAAM,KAAK,CAAC,eAAe,CACzB,GAAG,CAAC,MAAM,EACV,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CACpC,CAAC;4BACJ,CAAC;4BACD,MAAM,KAAK,CAAC,eAAe,CACzB,GAAG,CAAC,MAAM,EACV,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAC9C,CAAC;4BACF,IAAI,CAAC,SAAS,EAAE,CAAC;gCACf,MAAM,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;4BAChD,CAAC;wBACH,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,126 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-indexed-object-style',
meta: {
type: 'suggestion',
docs: {
description: 'Require or disallow the `Record` type',
recommended: 'stylistic',
},
messages: {
preferRecord: 'A record is preferred over an index signature.',
preferIndexSignature: 'An index signature is preferred over a record.',
},
fixable: 'code',
schema: [
{
type: 'string',
enum: ['record', 'index-signature'],
},
],
},
defaultOptions: ['record'],
create(context, [mode]) {
function checkMembers(members, node, parentId, prefix, postfix, safeFix = true) {
if (members.length !== 1) {
return;
}
const [member] = members;
if (member.type !== utils_1.AST_NODE_TYPES.TSIndexSignature) {
return;
}
const parameter = member.parameters.at(0);
if (parameter?.type !== utils_1.AST_NODE_TYPES.Identifier) {
return;
}
const keyType = parameter.typeAnnotation;
if (!keyType) {
return;
}
const valueType = member.typeAnnotation;
if (!valueType) {
return;
}
if (parentId) {
const scope = context.sourceCode.getScope(parentId);
const superVar = utils_1.ASTUtils.findVariable(scope, parentId.name);
if (superVar) {
const isCircular = superVar.references.some(item => item.isTypeReference &&
node.range[0] <= item.identifier.range[0] &&
node.range[1] >= item.identifier.range[1]);
if (isCircular) {
return;
}
}
}
context.report({
node,
messageId: 'preferRecord',
fix: safeFix
? (fixer) => {
const key = context.sourceCode.getText(keyType.typeAnnotation);
const value = context.sourceCode.getText(valueType.typeAnnotation);
const record = member.readonly
? `Readonly<Record<${key}, ${value}>>`
: `Record<${key}, ${value}>`;
return fixer.replaceText(node, `${prefix}${record}${postfix}`);
}
: null,
});
}
return {
...(mode === 'index-signature' && {
TSTypeReference(node) {
const typeName = node.typeName;
if (typeName.type !== utils_1.AST_NODE_TYPES.Identifier) {
return;
}
if (typeName.name !== 'Record') {
return;
}
const params = node.typeArguments?.params;
if (params?.length !== 2) {
return;
}
context.report({
node,
messageId: 'preferIndexSignature',
fix(fixer) {
const key = context.sourceCode.getText(params[0]);
const type = context.sourceCode.getText(params[1]);
return fixer.replaceText(node, `{ [key: ${key}]: ${type} }`);
},
});
},
}),
...(mode === 'record' && {
TSTypeLiteral(node) {
const parent = findParentDeclaration(node);
checkMembers(node.members, node, parent?.id, '', '');
},
TSInterfaceDeclaration(node) {
let genericTypes = '';
if (node.typeParameters?.params.length) {
genericTypes = `<${node.typeParameters.params
.map(p => context.sourceCode.getText(p))
.join(', ')}>`;
}
checkMembers(node.body.body, node, node.id, `type ${node.id.name}${genericTypes} = `, ';', !node.extends.length);
},
}),
};
},
});
function findParentDeclaration(node) {
if (node.parent && node.parent.type !== utils_1.AST_NODE_TYPES.TSTypeAnnotation) {
if (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
return node.parent;
}
return findParentDeclaration(node.parent);
}
return undefined;
}
//# sourceMappingURL=consistent-indexed-object-style.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"consistent-indexed-object-style.js","sourceRoot":"","sources":["../../src/rules/consistent-indexed-object-style.ts"],"names":[],"mappings":";;AACA,oDAAoE;AAEpE,kCAAq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AE,MAAM,CAAC,MAAM,EAAE,CAAC;wBACvC,YAAY,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM;6BAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;6BACvC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;oBACnB,CAAC;oBAED,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,IAAI,EACd,IAAI,EACJ,IAAI,CAAC,EAAE,EACP,QAAQ,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,YAAY,KAAK,EACxC,GAAG,EACH,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CACrB,CAAC;gBACJ,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAC5B,IAAmB;IAEnB,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB,EAAE,CAAC;QACxE,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,sBAAsB,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;QACD,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}

View file

@ -1,124 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('consistent-return');
exports.default = (0, util_1.createRule)({
name: 'consistent-return',
meta: {
type: 'suggestion',
docs: {
description: 'Require `return` statements to either always or never specify values',
extendsBaseRule: true,
requiresTypeChecking: true,
},
hasSuggestions: baseRule.meta.hasSuggestions,
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
},
defaultOptions: [{ treatUndefinedAsUnspecified: false }],
create(context, [options]) {
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const rules = baseRule.create(context);
const functions = [];
const treatUndefinedAsUnspecified = options?.treatUndefinedAsUnspecified === true;
function enterFunction(node) {
functions.push(node);
}
function exitFunction() {
functions.pop();
}
function getCurrentFunction() {
return functions[functions.length - 1] ?? null;
}
function isPromiseVoid(node, type) {
if (tsutils.isThenableType(checker, node, type) &&
tsutils.isTypeReference(type)) {
const awaitedType = type.typeArguments?.[0];
if (awaitedType) {
if ((0, util_1.isTypeFlagSet)(awaitedType, ts.TypeFlags.Void)) {
return true;
}
return isPromiseVoid(node, awaitedType);
}
}
return false;
}
function isReturnVoidOrThenableVoid(node) {
const functionType = services.getTypeAtLocation(node);
const tsNode = services.esTreeNodeToTSNodeMap.get(node);
const callSignatures = functionType.getCallSignatures();
return callSignatures.some(signature => {
const returnType = signature.getReturnType();
if (node.async) {
return isPromiseVoid(tsNode, returnType);
}
return (0, util_1.isTypeFlagSet)(returnType, ts.TypeFlags.Void);
});
}
return {
...rules,
FunctionDeclaration: enterFunction,
'FunctionDeclaration:exit'(node) {
exitFunction();
rules['FunctionDeclaration:exit'](node);
},
FunctionExpression: enterFunction,
'FunctionExpression:exit'(node) {
exitFunction();
rules['FunctionExpression:exit'](node);
},
ArrowFunctionExpression: enterFunction,
'ArrowFunctionExpression:exit'(node) {
exitFunction();
rules['ArrowFunctionExpression:exit'](node);
},
ReturnStatement(node) {
const functionNode = getCurrentFunction();
if (!node.argument &&
functionNode &&
isReturnVoidOrThenableVoid(functionNode)) {
return;
}
if (treatUndefinedAsUnspecified && node.argument) {
const returnValueType = services.getTypeAtLocation(node.argument);
if (returnValueType.flags === ts.TypeFlags.Undefined) {
rules.ReturnStatement({
...node,
argument: null,
});
return;
}
}
rules.ReturnStatement(node);
},
};
},
});
//# sourceMappingURL=consistent-return.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"consistent-return.js","sourceRoot":"","sources":["../../src/rules/consistent-return.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AACxC,+CAAiC;AAMjC,kCAAuE;AACvE,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,mBAAmB,CAAC,CAAC;AAUxD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,sEAAsE;YACxE,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,IAAI;SAC3B;QACD,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,EAAE,2BAA2B,EAAE,KAAK,EAAE,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,CAA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C,QAAQ,CAAC,CAAC;oBAClE,IAAI,eAAe,CAAC,KAAK,KAAK,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;wBACrD,KAAK,CAAC,eAAe,CAAC;4BACpB,GAAG,IAAI;4BACP,QAAQ,EAAE,IAAI;yBACf,CAAC,CAAC;wBACH,OAAO;oBACT,CAAC;gBACH,CAAC;gBAED,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,209 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const ts = __importStar(require("typescript"));
const util_1 = require("../util");
const getWrappedCode_1 = require("../util/getWrappedCode");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-assertions',
meta: {
type: 'suggestion',
fixable: 'code',
hasSuggestions: true,
docs: {
description: 'Enforce consistent usage of type assertions',
recommended: 'stylistic',
},
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 = { ... }.',
replaceObjectTypeAssertionWithAnnotation: 'Use const x: {{cast}} = { ... } instead.',
replaceObjectTypeAssertionWithSatisfies: 'Use const x = { ... } satisfies {{cast}} instead.',
},
schema: [
{
oneOf: [
{
type: 'object',
properties: {
assertionStyle: {
type: 'string',
enum: ['never'],
},
},
additionalProperties: false,
required: ['assertionStyle'],
},
{
type: 'object',
properties: {
assertionStyle: {
type: 'string',
enum: ['as', 'angle-bracket'],
},
objectLiteralTypeAssertions: {
type: 'string',
enum: ['allow', 'allow-as-parameter', 'never'],
},
},
additionalProperties: false,
required: ['assertionStyle'],
},
],
},
],
},
defaultOptions: [
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow',
},
],
create(context, [options]) {
const parserServices = (0, util_1.getParserServices)(context, true);
function isConst(node) {
if (node.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
return false;
}
return (node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
node.typeName.name === 'const');
}
function reportIncorrectAssertionType(node) {
const messageId = options.assertionStyle;
// If this node is `as const`, then don't report an error.
if (isConst(node.typeAnnotation) && messageId === 'never') {
return;
}
context.report({
node,
messageId,
data: messageId !== 'never'
? { cast: context.sourceCode.getText(node.typeAnnotation) }
: {},
fix: messageId === 'as'
? (fixer) => {
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
const expressionCode = context.sourceCode.getText(node.expression);
const typeAnnotationCode = context.sourceCode.getText(node.typeAnnotation);
const asPrecedence = (0, util_1.getOperatorPrecedence)(ts.SyntaxKind.AsExpression, ts.SyntaxKind.Unknown);
const parentPrecedence = (0, util_1.getOperatorPrecedence)(tsNode.parent.kind, ts.isBinaryExpression(tsNode.parent)
? tsNode.parent.operatorToken.kind
: ts.SyntaxKind.Unknown, ts.isNewExpression(tsNode.parent)
? tsNode.parent.arguments != null &&
tsNode.parent.arguments.length > 0
: undefined);
const expressionPrecedence = (0, util_1.getOperatorPrecedenceForNode)(node.expression);
const expressionCodeWrapped = (0, getWrappedCode_1.getWrappedCode)(expressionCode, expressionPrecedence, asPrecedence);
const text = `${expressionCodeWrapped} as ${typeAnnotationCode}`;
return fixer.replaceText(node, (0, util_1.isParenthesized)(node, context.sourceCode)
? text
: (0, getWrappedCode_1.getWrappedCode)(text, asPrecedence, parentPrecedence));
}
: undefined,
});
}
function checkType(node) {
switch (node.type) {
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
return false;
case utils_1.AST_NODE_TYPES.TSTypeReference:
return (
// Ignore `as const` and `<const>`
!isConst(node) ||
// Allow qualified names which have dots between identifiers, `Foo.Bar`
node.typeName.type === utils_1.AST_NODE_TYPES.TSQualifiedName);
default:
return true;
}
}
function checkExpression(node) {
if (options.assertionStyle === 'never' ||
options.objectLiteralTypeAssertions === 'allow' ||
node.expression.type !== utils_1.AST_NODE_TYPES.ObjectExpression) {
return;
}
if (options.objectLiteralTypeAssertions === 'allow-as-parameter' &&
(node.parent.type === utils_1.AST_NODE_TYPES.NewExpression ||
node.parent.type === utils_1.AST_NODE_TYPES.CallExpression ||
node.parent.type === utils_1.AST_NODE_TYPES.ThrowStatement ||
node.parent.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
node.parent.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer ||
(node.parent.type === utils_1.AST_NODE_TYPES.TemplateLiteral &&
node.parent.parent.type ===
utils_1.AST_NODE_TYPES.TaggedTemplateExpression))) {
return;
}
if (checkType(node.typeAnnotation)) {
const suggest = [];
if (node.parent.type === utils_1.AST_NODE_TYPES.VariableDeclarator &&
!node.parent.id.typeAnnotation) {
const { parent } = node;
suggest.push({
messageId: 'replaceObjectTypeAssertionWithAnnotation',
data: { cast: context.sourceCode.getText(node.typeAnnotation) },
fix: fixer => [
fixer.insertTextAfter(parent.id, `: ${context.sourceCode.getText(node.typeAnnotation)}`),
fixer.replaceText(node, (0, util_1.getTextWithParentheses)(context.sourceCode, node.expression)),
],
});
}
suggest.push({
messageId: 'replaceObjectTypeAssertionWithSatisfies',
data: { cast: context.sourceCode.getText(node.typeAnnotation) },
fix: fixer => [
fixer.replaceText(node, (0, util_1.getTextWithParentheses)(context.sourceCode, node.expression)),
fixer.insertTextAfter(node, ` satisfies ${context.sourceCode.getText(node.typeAnnotation)}`),
],
});
context.report({
node,
messageId: 'unexpectedObjectTypeAssertion',
suggest,
});
}
}
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

@ -1,98 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-definitions',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce type definitions to consistently use either `interface` or `type`',
recommended: 'stylistic',
},
messages: {
interfaceOverType: 'Use an `interface` instead of a `type`.',
typeOverInterface: 'Use a `type` instead of an `interface`.',
},
schema: [
{
type: 'string',
enum: ['interface', 'type'],
},
],
fixable: 'code',
},
defaultOptions: ['interface'],
create(context, [option]) {
/**
* Iterates from the highest parent to the currently traversed node
* to determine whether any node in tree is globally declared module declaration
*/
function isCurrentlyTraversedNodeWithinModuleDeclaration(node) {
return context.sourceCode
.getAncestors(node)
.some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
node.declare &&
node.kind === 'global');
}
return {
...(option === 'interface' && {
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(node) {
context.report({
node: node.id,
messageId: 'interfaceOverType',
fix(fixer) {
const typeNode = node.typeParameters ?? node.id;
const fixes = [];
const firstToken = context.sourceCode.getTokenBefore(node.id);
if (firstToken) {
fixes.push(fixer.replaceText(firstToken, 'interface'));
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.typeAnnotation.range[0]], ' '));
}
const afterToken = context.sourceCode.getTokenAfter(node.typeAnnotation);
if (afterToken &&
afterToken.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
afterToken.value === ';') {
fixes.push(fixer.remove(afterToken));
}
return fixes;
},
});
},
}),
...(option === 'type' && {
TSInterfaceDeclaration(node) {
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration(node)
? null
: (fixer) => {
const typeNode = node.typeParameters ?? node.id;
const fixes = [];
const firstToken = context.sourceCode.getTokenBefore(node.id);
if (firstToken) {
fixes.push(fixer.replaceText(firstToken, 'type'));
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.body.range[0]], ' = '));
}
node.extends.forEach(heritage => {
const typeIdentifier = context.sourceCode.getText(heritage);
fixes.push(fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`));
});
if (node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
fixes.push(fixer.removeRange([node.parent.range[0], node.range[0]]), fixer.insertTextAfter(node.body, `\nexport default ${node.id.name}`));
}
return fixes;
};
context.report({
node: node.id,
messageId: 'typeOverInterface',
/**
* remove automatically fix when the interface is within a declare global
* @see {@link https://github.com/typescript-eslint/typescript-eslint/issues/2707}
*/
fix,
});
},
}),
};
},
});
//# sourceMappingURL=consistent-type-definitions.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"consistent-type-definitions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-definitions.ts"],"names":[],"mappings":";;AACA,oDAA2E;AAE3E,kCAAqC;AAErC,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,2EAA2E;YAC7E,WAAW,EAAE,WAAW;SACzB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,yCAAyC;YAC5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AU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gCAC5D,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,cAAc,EAAE,CAAC,CACzD,CAAC;4BACJ,CAAC,CAAC,CAAC;4BAEH,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,wBAAwB,EAC5D,CAAC;gCACD,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EACxD,KAAK,CAAC,eAAe,CACnB,IAAI,CAAC,IAAI,EACT,oBAAoB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CACnC,CACF,CAAC;4BACJ,CAAC;4BAED,OAAO,KAAK,CAAC;wBACf,CAAC,CAAC;oBACN,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,EAAE;wBACb,SAAS,EAAE,mBAAmB;wBAC9B;;;2BAGG;wBACH,GAAG;qBACJ,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,243 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const typescript_1 = require("typescript");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-exports',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce consistent usage of type exports',
requiresTypeChecking: true,
},
messages: {
typeOverValue: 'All exports in the declaration are only used as types. Use `export type`.',
singleExportIsType: 'Type export {{exportNames}} is not a value and should be exported using `export type`.',
multipleExportsAreTypes: 'Type exports {{exportNames}} are not values and should be exported using `export type`.',
},
schema: [
{
type: 'object',
properties: {
fixMixedExportsWithInlineTypeSpecifier: {
type: 'boolean',
},
},
additionalProperties: false,
},
],
fixable: 'code',
},
defaultOptions: [
{
fixMixedExportsWithInlineTypeSpecifier: false,
},
],
create(context, [{ fixMixedExportsWithInlineTypeSpecifier }]) {
const sourceExportsMap = {};
const services = (0, util_1.getParserServices)(context);
/**
* Helper for identifying if an export specifier resolves to a
* JavaScript value or a TypeScript type.
*
* @returns True/false if is a type or not, or undefined if the specifier
* can't be resolved.
*/
function isSpecifierTypeBased(specifier) {
const checker = services.program.getTypeChecker();
const symbol = services.getSymbolAtLocation(specifier.exported);
if (!symbol) {
return undefined;
}
const aliasedSymbol = checker.getAliasedSymbol(symbol);
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (aliasedSymbol.escapedName === 'unknown') {
return undefined;
}
return !(aliasedSymbol.flags & typescript_1.SymbolFlags.Value);
}
return {
ExportNamedDeclaration(node) {
// Coerce the source into a string for use as a lookup entry.
const source = getSourceFromExport(node) ?? 'undefined';
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const sourceExports = (sourceExportsMap[source] ||= {
source,
reportValueExports: [],
typeOnlyNamedExport: null,
valueOnlyNamedExport: null,
});
// Cache the first encountered exports for the package. We will need to come
// back to these later when fixing the problems.
if (node.exportKind === 'type') {
if (sourceExports.typeOnlyNamedExport == null) {
// The export is a type export
sourceExports.typeOnlyNamedExport = node;
}
}
else if (sourceExports.valueOnlyNamedExport == null) {
// The export is a value export
sourceExports.valueOnlyNamedExport = node;
}
// Next for the current export, we will separate type/value specifiers.
const typeBasedSpecifiers = [];
const inlineTypeSpecifiers = [];
const valueSpecifiers = [];
// Note: it is valid to export values as types. We will avoid reporting errors
// when this is encountered.
if (node.exportKind !== 'type') {
for (const specifier of node.specifiers) {
if (specifier.exportKind === 'type') {
inlineTypeSpecifiers.push(specifier);
continue;
}
const isTypeBased = isSpecifierTypeBased(specifier);
if (isTypeBased === true) {
typeBasedSpecifiers.push(specifier);
}
else if (isTypeBased === false) {
// When isTypeBased is undefined, we should avoid reporting them.
valueSpecifiers.push(specifier);
}
}
}
if ((node.exportKind === 'value' && typeBasedSpecifiers.length) ||
(node.exportKind === 'type' && valueSpecifiers.length)) {
sourceExports.reportValueExports.push({
node,
typeBasedSpecifiers,
valueSpecifiers,
inlineTypeSpecifiers,
});
}
},
'Program:exit'() {
for (const sourceExports of Object.values(sourceExportsMap)) {
// If this export has no issues, move on.
if (sourceExports.reportValueExports.length === 0) {
continue;
}
for (const report of sourceExports.reportValueExports) {
if (report.valueSpecifiers.length === 0) {
// Export is all type-only with no type specifiers; convert the entire export to `export type`.
context.report({
node: report.node,
messageId: 'typeOverValue',
*fix(fixer) {
yield* fixExportInsertType(fixer, context.sourceCode, report.node);
},
});
continue;
}
// We have both type and value violations.
const allExportNames = report.typeBasedSpecifiers.map(specifier => specifier.local.name);
if (allExportNames.length === 1) {
const exportNames = allExportNames[0];
context.report({
node: report.node,
messageId: 'singleExportIsType',
data: { exportNames },
*fix(fixer) {
if (fixMixedExportsWithInlineTypeSpecifier) {
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
}
else {
yield* fixSeparateNamedExports(fixer, context.sourceCode, report);
}
},
});
}
else {
const exportNames = (0, util_1.formatWordList)(allExportNames);
context.report({
node: report.node,
messageId: 'multipleExportsAreTypes',
data: { exportNames },
*fix(fixer) {
if (fixMixedExportsWithInlineTypeSpecifier) {
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
}
else {
yield* fixSeparateNamedExports(fixer, context.sourceCode, report);
}
},
});
}
}
}
},
};
},
});
/**
* Inserts "type" into an export.
*
* Example:
*
* export type { Foo } from 'foo';
* ^^^^
*/
function* fixExportInsertType(fixer, sourceCode, node) {
const exportToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node), util_1.NullThrowsReasons.MissingToken('export', node.type));
yield fixer.insertTextAfter(exportToken, ' type');
for (const specifier of node.specifiers) {
if (specifier.exportKind === 'type') {
const kindToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(specifier), util_1.NullThrowsReasons.MissingToken('export', specifier.type));
const firstTokenAfter = (0, util_1.nullThrows)(sourceCode.getTokenAfter(kindToken, {
includeComments: true,
}), 'Missing token following the export kind.');
yield fixer.removeRange([kindToken.range[0], firstTokenAfter.range[0]]);
}
}
}
/**
* Separates the exports which mismatch the kind of export the given
* node represents. For example, a type export's named specifiers which
* represent values will be inserted in a separate `export` statement.
*/
function* fixSeparateNamedExports(fixer, sourceCode, report) {
const { node, typeBasedSpecifiers, inlineTypeSpecifiers, valueSpecifiers } = report;
const typeSpecifiers = typeBasedSpecifiers.concat(inlineTypeSpecifiers);
const source = getSourceFromExport(node);
const specifierNames = typeSpecifiers.map(getSpecifierText).join(', ');
const exportToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node), util_1.NullThrowsReasons.MissingToken('export', node.type));
// Filter the bad exports from the current line.
const filteredSpecifierNames = valueSpecifiers
.map(getSpecifierText)
.join(', ');
const openToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isOpeningBraceToken), util_1.NullThrowsReasons.MissingToken('{', node.type));
const closeToken = (0, util_1.nullThrows)(sourceCode.getLastToken(node, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', node.type));
// Remove exports from the current line which we're going to re-insert.
yield fixer.replaceTextRange([openToken.range[1], closeToken.range[0]], ` ${filteredSpecifierNames} `);
// Insert the bad exports into a new export line above.
yield fixer.insertTextBefore(exportToken, `export type { ${specifierNames} }${source ? ` from '${source}'` : ''};\n`);
}
function* fixAddTypeSpecifierToNamedExports(fixer, report) {
if (report.node.exportKind === 'type') {
return;
}
for (const specifier of report.typeBasedSpecifiers) {
yield fixer.insertTextBefore(specifier, 'type ');
}
}
/**
* Returns the source of the export, or undefined if the named export has no source.
*/
function getSourceFromExport(node) {
if (node.source?.type === utils_1.AST_NODE_TYPES.Literal &&
typeof node.source.value === 'string') {
return node.source.value;
}
return undefined;
}
/**
* Returns the specifier text for the export. If it is aliased, we take care to return
* the proper formatting.
*/
function getSpecifierText(specifier) {
return `${specifier.local.name}${specifier.exported.name !== specifier.local.name
? ` as ${specifier.exported.name}`
: ''}`;
}
//# sourceMappingURL=consistent-type-exports.js.map

View file

@ -1,606 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-imports',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce consistent usage of type imports',
},
messages: {
typeOverValue: 'All imports in the declaration are only used as types. Use `import type`.',
someImportsAreOnlyTypes: 'Imports {{typeImports}} are only used as type.',
avoidImportType: 'Use an `import` instead of an `import type`.',
noImportTypeAnnotations: '`import()` type annotations are forbidden.',
},
schema: [
{
type: 'object',
properties: {
disallowTypeAnnotations: {
type: 'boolean',
},
fixStyle: {
type: 'string',
enum: ['separate-type-imports', 'inline-type-imports'],
},
prefer: {
type: 'string',
enum: ['type-imports', 'no-type-imports'],
},
},
additionalProperties: false,
},
],
fixable: 'code',
},
defaultOptions: [
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
fixStyle: 'separate-type-imports',
},
],
create(context, [option]) {
const prefer = option.prefer ?? 'type-imports';
const disallowTypeAnnotations = option.disallowTypeAnnotations !== false;
const selectors = {};
if (disallowTypeAnnotations) {
selectors.TSImportType = (node) => {
context.report({
node,
messageId: 'noImportTypeAnnotations',
});
};
}
if (prefer === 'no-type-imports') {
return {
...selectors,
'ImportDeclaration[importKind = "type"]'(node) {
context.report({
node,
messageId: 'avoidImportType',
fix(fixer) {
return fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
},
});
},
'ImportSpecifier[importKind = "type"]'(node) {
context.report({
node,
messageId: 'avoidImportType',
fix(fixer) {
return fixRemoveTypeSpecifierFromImportSpecifier(fixer, node);
},
});
},
};
}
// prefer type imports
const fixStyle = option.fixStyle ?? 'separate-type-imports';
let hasDecoratorMetadata = false;
const sourceImportsMap = {};
const emitDecoratorMetadata = (0, util_1.getParserServices)(context, true).emitDecoratorMetadata ?? false;
const experimentalDecorators = (0, util_1.getParserServices)(context, true).experimentalDecorators ?? false;
if (experimentalDecorators && emitDecoratorMetadata) {
selectors.Decorator = () => {
hasDecoratorMetadata = true;
};
}
return {
...selectors,
ImportDeclaration(node) {
const source = node.source.value;
// sourceImports is the object containing all the specifics for a particular import source, type or value
sourceImportsMap[source] ??= {
source,
reportValueImports: [], // if there is a mismatch where type importKind but value specifiers
typeOnlyNamedImport: null, // if only type imports
valueOnlyNamedImport: null, // if only value imports with named specifiers
valueImport: null, // if only value imports
};
const sourceImports = sourceImportsMap[source];
if (node.importKind === 'type') {
if (!sourceImports.typeOnlyNamedImport &&
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier)) {
// definitely import type { TypeX }
sourceImports.typeOnlyNamedImport = node;
}
}
else if (!sourceImports.valueOnlyNamedImport &&
node.specifiers.length &&
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier)) {
sourceImports.valueOnlyNamedImport = node;
sourceImports.valueImport = node;
}
else if (!sourceImports.valueImport &&
node.specifiers.some(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier)) {
sourceImports.valueImport = node;
}
const typeSpecifiers = [];
const inlineTypeSpecifiers = [];
const valueSpecifiers = [];
const unusedSpecifiers = [];
for (const specifier of node.specifiers) {
if (specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
specifier.importKind === 'type') {
inlineTypeSpecifiers.push(specifier);
continue;
}
const [variable] = context.sourceCode.getDeclaredVariables(specifier);
if (variable.references.length === 0) {
unusedSpecifiers.push(specifier);
}
else {
const onlyHasTypeReferences = variable.references.every(ref => {
/**
* keep origin import kind when export
* export { Type }
* export default Type;
* export = Type;
*/
if (ref.identifier.parent.type === utils_1.AST_NODE_TYPES.ExportSpecifier ||
ref.identifier.parent.type ===
utils_1.AST_NODE_TYPES.ExportDefaultDeclaration ||
ref.identifier.parent.type === utils_1.AST_NODE_TYPES.TSExportAssignment) {
if (ref.isValueReference && ref.isTypeReference) {
return node.importKind === 'type';
}
}
if (ref.isValueReference) {
let parent = ref.identifier.parent;
let child = ref.identifier;
while (parent) {
switch (parent.type) {
// CASE 1:
// `type T = typeof foo` will create a value reference because "foo" must be a value type
// however this value reference is safe to use with type-only imports
case utils_1.AST_NODE_TYPES.TSTypeQuery:
return true;
case utils_1.AST_NODE_TYPES.TSQualifiedName:
// TSTypeQuery must have a TSESTree.EntityName as its child, so we can filter here and break early
if (parent.left !== child) {
return false;
}
child = parent;
parent = parent.parent;
continue;
// END CASE 1
//////////////
// CASE 2:
// `type T = { [foo]: string }` will create a value reference because "foo" must be a value type
// however this value reference is safe to use with type-only imports.
// Also this is represented as a non-type AST - hence it uses MemberExpression
case utils_1.AST_NODE_TYPES.TSPropertySignature:
return parent.key === child;
case utils_1.AST_NODE_TYPES.MemberExpression:
if (parent.object !== child) {
return false;
}
child = parent;
parent = parent.parent;
continue;
// END CASE 2
default:
return false;
}
}
}
return ref.isTypeReference;
});
if (onlyHasTypeReferences) {
typeSpecifiers.push(specifier);
}
else {
valueSpecifiers.push(specifier);
}
}
}
if (node.importKind === 'value' && typeSpecifiers.length) {
sourceImports.reportValueImports.push({
node,
typeSpecifiers,
valueSpecifiers,
unusedSpecifiers,
inlineTypeSpecifiers,
});
}
},
'Program:exit'() {
if (hasDecoratorMetadata) {
// Experimental decorator metadata is bowl of poop that cannot be
// supported based on pure syntactic analysis.
//
// So we can do one of two things:
// 1) add type-information to the rule in a breaking change and
// prevent users from using it so that we can fully support this
// case.
// 2) make the rule ignore all imports that are used in a file that
// might have decorator metadata.
//
// (1) is has huge impact and prevents the rule from being used by 99%
// of users Frankly - it's a straight-up bad option. So instead we
// choose with option (2) and just avoid reporting on any imports in a
// file with both emitDecoratorMetadata AND decorators
//
// For more context see the discussion in this issue and its linked
// issues:
// https://github.com/typescript-eslint/typescript-eslint/issues/5468
//
//
// NOTE - in TS 5.0 `experimentalDecorators` became the legacy option,
// replaced with un-flagged, stable decorators and thus the type-aware
// emitDecoratorMetadata implementation also became legacy. in TS 5.2
// support for the new, stable decorator metadata proposal was added -
// however this proposal does not include type information
//
//
// PHEW. So TL;DR what does all this mean?
// - if you use experimentalDecorators:true,
// emitDecoratorMetadata:true, and have a decorator in the file -
// the rule will do nothing in the file out of an abundance of
// caution.
// - else the rule will work as normal.
return;
}
for (const sourceImports of Object.values(sourceImportsMap)) {
if (sourceImports.reportValueImports.length === 0) {
// nothing to fix. value specifiers and type specifiers are correctly written
continue;
}
for (const report of sourceImports.reportValueImports) {
if (report.valueSpecifiers.length === 0 &&
report.unusedSpecifiers.length === 0 &&
report.node.importKind !== 'type') {
/**
* checks if import has type assertions
* @example
* ```ts
* import * as type from 'mod' assert \{ type: 'json' \};
* ```
* https://github.com/typescript-eslint/typescript-eslint/issues/7527
*/
if (report.node.attributes.length === 0) {
context.report({
node: report.node,
messageId: 'typeOverValue',
*fix(fixer) {
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
},
});
}
}
else {
// we have a mixed type/value import or just value imports, so we need to split them out into multiple imports if separate-type-imports is configured
const importNames = report.typeSpecifiers.map(specifier => `"${specifier.local.name}"`);
const message = (() => {
const typeImports = (0, util_1.formatWordList)(importNames);
if (importNames.length === 1) {
return {
messageId: 'someImportsAreOnlyTypes',
data: {
typeImports,
},
};
}
return {
messageId: 'someImportsAreOnlyTypes',
data: {
typeImports,
},
};
})();
context.report({
node: report.node,
...message,
*fix(fixer) {
// take all the typeSpecifiers and put them on a new line
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
},
});
}
}
}
},
};
function classifySpecifier(node) {
const defaultSpecifier = node.specifiers[0].type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier
? node.specifiers[0]
: null;
const namespaceSpecifier = node.specifiers.find((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier) ?? null;
const namedSpecifiers = node.specifiers.filter((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier);
return {
defaultSpecifier,
namespaceSpecifier,
namedSpecifiers,
};
}
/**
* Returns information for fixing named specifiers, type or value
*/
function getFixesNamedSpecifiers(fixer, node, subsetNamedSpecifiers, allNamedSpecifiers) {
if (allNamedSpecifiers.length === 0) {
return {
typeNamedSpecifiersText: '',
removeTypeNamedSpecifiers: [],
};
}
const typeNamedSpecifiersTexts = [];
const removeTypeNamedSpecifiers = [];
if (subsetNamedSpecifiers.length === allNamedSpecifiers.length) {
// import Foo, {Type1, Type2} from 'foo'
// import DefType, {Type1, Type2} from 'foo'
const openingBraceToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(subsetNamedSpecifiers[0], util_1.isOpeningBraceToken), util_1.NullThrowsReasons.MissingToken('{', node.type));
const commaToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(openingBraceToken, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
const closingBraceToken = (0, util_1.nullThrows)(context.sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', node.type));
// import DefType, {...} from 'foo'
// ^^^^^^^ remove
removeTypeNamedSpecifiers.push(fixer.removeRange([commaToken.range[0], closingBraceToken.range[1]]));
typeNamedSpecifiersTexts.push(context.sourceCode.text.slice(openingBraceToken.range[1], closingBraceToken.range[0]));
}
else {
const namedSpecifierGroups = [];
let group = [];
for (const namedSpecifier of allNamedSpecifiers) {
if (subsetNamedSpecifiers.includes(namedSpecifier)) {
group.push(namedSpecifier);
}
else if (group.length) {
namedSpecifierGroups.push(group);
group = [];
}
}
if (group.length) {
namedSpecifierGroups.push(group);
}
for (const namedSpecifiers of namedSpecifierGroups) {
const { removeRange, textRange } = getNamedSpecifierRanges(namedSpecifiers, allNamedSpecifiers);
removeTypeNamedSpecifiers.push(fixer.removeRange(removeRange));
typeNamedSpecifiersTexts.push(context.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 = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(first), util_1.NullThrowsReasons.MissingToken('token', 'first specifier'));
textRange[0] = before.range[1];
if ((0, util_1.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 = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(last), util_1.NullThrowsReasons.MissingToken('token', 'last specifier'));
textRange[1] = after.range[0];
if (isFirst || isLast) {
if ((0, util_1.isCommaToken)(after)) {
removeRange[1] = after.range[1];
}
}
return {
textRange,
removeRange,
};
}
/**
* insert specifiers to named import node.
* e.g.
* import type { Already, Type1, Type2 } from 'foo'
* ^^^^^^^^^^^^^ insert
*/
function fixInsertNamedSpecifiersInNamedSpecifierList(fixer, target, insertText) {
const closingBraceToken = (0, util_1.nullThrows)(context.sourceCode.getFirstTokenBetween((0, util_1.nullThrows)(context.sourceCode.getFirstToken(target), util_1.NullThrowsReasons.MissingToken('token before', 'import')), target.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', target.type));
const before = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(closingBraceToken), util_1.NullThrowsReasons.MissingToken('token before', 'closing brace'));
if (!(0, util_1.isCommaToken)(before) && !(0, util_1.isOpeningBraceToken)(before)) {
insertText = `,${insertText}`;
}
return fixer.insertTextBefore(closingBraceToken, insertText);
}
/**
* insert type keyword to named import node.
* e.g.
* import ADefault, { Already, type Type1, type Type2 } from 'foo'
* ^^^^ insert
*/
function* fixInsertTypeKeywordInNamedSpecifierList(fixer, typeSpecifiers) {
for (const spec of typeSpecifiers) {
const insertText = context.sourceCode.text.slice(...spec.range);
yield fixer.replaceTextRange(spec.range, `type ${insertText}`);
}
}
function* fixInlineTypeImportDeclaration(fixer, report, sourceImports) {
const { node } = report;
// For a value import, will only add an inline type to named specifiers
const { namedSpecifiers } = classifySpecifier(node);
const typeNamedSpecifiers = namedSpecifiers.filter(specifier => report.typeSpecifiers.includes(specifier));
if (sourceImports.valueImport) {
// add import named type specifiers to its value import
// import ValueA, { type A }
// ^^^^ insert
const { namedSpecifiers: valueImportNamedSpecifiers } = classifySpecifier(sourceImports.valueImport);
if (sourceImports.valueOnlyNamedImport ||
valueImportNamedSpecifiers.length) {
yield* fixInsertTypeKeywordInNamedSpecifierList(fixer, typeNamedSpecifiers);
}
}
}
function* fixToTypeImportDeclaration(fixer, report, sourceImports) {
const { node } = report;
const { defaultSpecifier, namespaceSpecifier, namedSpecifiers } = classifySpecifier(node);
if (namespaceSpecifier && !defaultSpecifier) {
// import * as types from 'foo'
// checks for presence of import assertions
if (node.attributes.length === 0) {
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false);
}
return;
}
else if (defaultSpecifier) {
if (report.typeSpecifiers.includes(defaultSpecifier) &&
namedSpecifiers.length === 0 &&
!namespaceSpecifier) {
// import Type from 'foo'
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, true);
return;
}
else if (fixStyle === 'inline-type-imports' &&
!report.typeSpecifiers.includes(defaultSpecifier) &&
namedSpecifiers.length > 0 &&
!namespaceSpecifier) {
// if there is a default specifier but it isn't a type specifier, then just add the inline type modifier to the named specifiers
// import AValue, {BValue, Type1, Type2} from 'foo'
yield* fixInlineTypeImportDeclaration(fixer, report, sourceImports);
return;
}
}
else if (!namespaceSpecifier) {
if (fixStyle === 'inline-type-imports' &&
namedSpecifiers.some(specifier => report.typeSpecifiers.includes(specifier))) {
// import {AValue, Type1, Type2} from 'foo'
yield* fixInlineTypeImportDeclaration(fixer, report, sourceImports);
return;
}
else if (namedSpecifiers.every(specifier => report.typeSpecifiers.includes(specifier))) {
// import {Type1, Type2} from 'foo'
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false);
return;
}
}
const typeNamedSpecifiers = namedSpecifiers.filter(specifier => report.typeSpecifiers.includes(specifier));
const fixesNamedSpecifiers = getFixesNamedSpecifiers(fixer, node, typeNamedSpecifiers, namedSpecifiers);
const afterFixes = [];
if (typeNamedSpecifiers.length) {
if (sourceImports.typeOnlyNamedImport) {
const insertTypeNamedSpecifiers = fixInsertNamedSpecifiersInNamedSpecifierList(fixer, sourceImports.typeOnlyNamedImport, fixesNamedSpecifiers.typeNamedSpecifiersText);
if (sourceImports.typeOnlyNamedImport.range[1] <= node.range[0]) {
yield insertTypeNamedSpecifiers;
}
else {
afterFixes.push(insertTypeNamedSpecifiers);
}
}
else {
// The import is both default and named. Insert named on new line because can't mix default type import and named type imports
// eslint-disable-next-line no-lonely-if
if (fixStyle === 'inline-type-imports') {
yield fixer.insertTextBefore(node, `import {${typeNamedSpecifiers
.map(spec => {
const insertText = context.sourceCode.text.slice(...spec.range);
return `type ${insertText}`;
})
.join(', ')}} from ${context.sourceCode.getText(node.source)};\n`);
}
else {
yield fixer.insertTextBefore(node, `import type {${fixesNamedSpecifiers.typeNamedSpecifiersText}} from ${context.sourceCode.getText(node.source)};\n`);
}
}
}
const fixesRemoveTypeNamespaceSpecifier = [];
if (namespaceSpecifier &&
report.typeSpecifiers.includes(namespaceSpecifier)) {
// import Foo, * as Type from 'foo'
// import DefType, * as Type from 'foo'
// import DefType, * as Type from 'foo'
const commaToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(namespaceSpecifier, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
// import Def, * as Ns from 'foo'
// ^^^^^^^^^ remove
fixesRemoveTypeNamespaceSpecifier.push(fixer.removeRange([commaToken.range[0], namespaceSpecifier.range[1]]));
// import type * as Ns from 'foo'
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ insert
yield fixer.insertTextBefore(node, `import type ${context.sourceCode.getText(namespaceSpecifier)} from ${context.sourceCode.getText(node.source)};\n`);
}
if (defaultSpecifier &&
report.typeSpecifiers.includes(defaultSpecifier)) {
if (report.typeSpecifiers.length === node.specifiers.length) {
const importToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
// import type Type from 'foo'
// ^^^^ insert
yield fixer.insertTextAfter(importToken, ' type');
}
else {
const commaToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(defaultSpecifier, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', defaultSpecifier.type));
// import Type , {...} from 'foo'
// ^^^^^ pick
const defaultText = context.sourceCode.text
.slice(defaultSpecifier.range[0], commaToken.range[0])
.trim();
yield fixer.insertTextBefore(node, `import type ${defaultText} from ${context.sourceCode.getText(node.source)};\n`);
const afterToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(commaToken, {
includeComments: true,
}), util_1.NullThrowsReasons.MissingToken('any token', node.type));
// import Type , {...} from 'foo'
// ^^^^^^^ remove
yield fixer.removeRange([
defaultSpecifier.range[0],
afterToken.range[0],
]);
}
}
yield* fixesNamedSpecifiers.removeTypeNamedSpecifiers;
yield* fixesRemoveTypeNamespaceSpecifier;
yield* afterFixes;
}
function* fixInsertTypeSpecifierForImportDeclaration(fixer, node, isDefaultImport) {
// import type Foo from 'foo'
// ^^^^^ insert
const importToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
yield fixer.insertTextAfter(importToken, ' type');
if (isDefaultImport) {
// Has default import
const openingBraceToken = context.sourceCode.getFirstTokenBetween(importToken, node.source, util_1.isOpeningBraceToken);
if (openingBraceToken) {
// Only braces. e.g. import Foo, {} from 'foo'
const commaToken = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(openingBraceToken, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
const closingBraceToken = (0, util_1.nullThrows)(context.sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', node.type));
// import type Foo, {} from 'foo'
// ^^ remove
yield fixer.removeRange([
commaToken.range[0],
closingBraceToken.range[1],
]);
const specifiersText = context.sourceCode.text.slice(commaToken.range[1], closingBraceToken.range[1]);
if (node.specifiers.length > 1) {
yield fixer.insertTextAfter(node, `\nimport type${specifiersText} from ${context.sourceCode.getText(node.source)};`);
}
}
}
// make sure we don't do anything like `import type {type T} from 'foo';`
for (const specifier of node.specifiers) {
if (specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
specifier.importKind === 'type') {
yield* fixRemoveTypeSpecifierFromImportSpecifier(fixer, specifier);
}
}
}
function* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node) {
// import type Foo from 'foo'
// ^^^^ remove
const importToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
const typeToken = (0, util_1.nullThrows)(context.sourceCode.getFirstTokenBetween(importToken, node.specifiers[0]?.local ?? node.source, util_1.isTypeKeyword), util_1.NullThrowsReasons.MissingToken('type', node.type));
const afterToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(typeToken, { includeComments: true }), util_1.NullThrowsReasons.MissingToken('any token', node.type));
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);
}
function* fixRemoveTypeSpecifierFromImportSpecifier(fixer, node) {
// import { type Foo } from 'foo'
// ^^^^ remove
const typeToken = (0, util_1.nullThrows)(context.sourceCode.getFirstToken(node, util_1.isTypeKeyword), util_1.NullThrowsReasons.MissingToken('type', node.type));
const afterToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(typeToken, { includeComments: true }), util_1.NullThrowsReasons.MissingToken('any token', node.type));
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);
}
},
});
//# sourceMappingURL=consistent-type-imports.js.map

View file

@ -1,68 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'default-param-last',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce default parameters to be last',
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 ((node.type === utils_1.AST_NODE_TYPES.ArrayPattern ||
node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
node.type === utils_1.AST_NODE_TYPES.Identifier ||
node.type === utils_1.AST_NODE_TYPES.ObjectPattern ||
node.type === utils_1.AST_NODE_TYPES.RestElement) &&
node.optional);
}
/**
* checks if node is plain parameter
* @param node the node to be evaluated
* @private
*/
function isPlainParam(node) {
return !(node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
node.type === utils_1.AST_NODE_TYPES.RestElement ||
isOptionalParam(node));
}
function checkDefaultParamLast(node) {
let hasSeenPlainParam = false;
for (let i = node.params.length - 1; i >= 0; i--) {
const current = node.params[i];
const param = current.type === utils_1.AST_NODE_TYPES.TSParameterProperty
? current.parameter
: current;
if (isPlainParam(param)) {
hasSeenPlainParam = true;
continue;
}
if (hasSeenPlainParam &&
(isOptionalParam(param) ||
param.type === utils_1.AST_NODE_TYPES.AssignmentPattern)) {
context.report({ node: current, messageId: 'shouldBeLast' });
}
}
}
return {
ArrowFunctionExpression: checkDefaultParamLast,
FunctionDeclaration: checkDefaultParamLast,
FunctionExpression: checkDefaultParamLast,
};
},
});
//# sourceMappingURL=default-param-last.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"default-param-last.js","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAqC;AAErC,kBAAe,IAA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C,CAAC,OAAO,CAAC,SAAS;oBACnB,CAAC,CAAC,OAAO,CAAC;gBAEd,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;oBACxB,iBAAiB,GAAG,IAAI,CAAC;oBACzB,SAAS;gBACX,CAAC;gBAED,IACE,iBAAiB;oBACjB,CAAC,eAAe,CAAC,KAAK,CAAC;wBACrB,KAAK,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB,CAAC,EAClD,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;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

@ -1,127 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('dot-notation');
exports.default = (0, util_1.createRule)({
name: 'dot-notation',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce dot notation whenever possible',
recommended: 'stylistic',
extendsBaseRule: true,
requiresTypeChecking: true,
},
schema: [
{
type: 'object',
properties: {
allowKeywords: {
type: 'boolean',
default: true,
},
allowPattern: {
type: 'string',
default: '',
},
allowPrivateClassPropertyAccess: {
type: 'boolean',
default: false,
},
allowProtectedClassPropertyAccess: {
type: 'boolean',
default: false,
},
allowIndexSignaturePropertyAccess: {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
],
fixable: baseRule.meta.fixable,
hasSuggestions: baseRule.meta.hasSuggestions,
messages: baseRule.meta.messages,
},
defaultOptions: [
{
allowPrivateClassPropertyAccess: false,
allowProtectedClassPropertyAccess: false,
allowIndexSignaturePropertyAccess: false,
allowKeywords: true,
allowPattern: '',
},
],
create(context, [options]) {
const rules = baseRule.create(context);
const services = (0, util_1.getParserServices)(context);
const allowPrivateClassPropertyAccess = options.allowPrivateClassPropertyAccess;
const allowProtectedClassPropertyAccess = options.allowProtectedClassPropertyAccess;
const allowIndexSignaturePropertyAccess = (options.allowIndexSignaturePropertyAccess ?? false) ||
tsutils.isCompilerOptionEnabled(services.program.getCompilerOptions(), 'noPropertyAccessFromIndexSignature');
return {
MemberExpression(node) {
if ((allowPrivateClassPropertyAccess ||
allowProtectedClassPropertyAccess ||
allowIndexSignaturePropertyAccess) &&
node.computed) {
// for perf reasons - only fetch symbols if we have to
const propertySymbol = services.getSymbolAtLocation(node.property) ??
services
.getTypeAtLocation(node.object)
.getNonNullableType()
.getProperties()
.find(propertySymbol => node.property.type === utils_1.AST_NODE_TYPES.Literal &&
propertySymbol.escapedName === node.property.value);
const modifierKind = (0, util_1.getModifiers)(propertySymbol?.getDeclarations()?.[0])?.[0].kind;
if ((allowPrivateClassPropertyAccess &&
modifierKind === ts.SyntaxKind.PrivateKeyword) ||
(allowProtectedClassPropertyAccess &&
modifierKind === ts.SyntaxKind.ProtectedKeyword)) {
return;
}
if (propertySymbol === undefined &&
allowIndexSignaturePropertyAccess) {
const objectType = services.getTypeAtLocation(node.object);
const indexType = objectType
.getNonNullableType()
.getStringIndexType();
if (indexType !== undefined) {
return;
}
}
}
rules.MemberExpression(node);
},
};
},
});
//# sourceMappingURL=dot-notation.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"dot-notation.js","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAC1D,sDAAwC;AACxC,+CAAiC;AAMjC,kCAAsE;AACtE,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC;AAKnD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,wCAAwC;YACrD,WAAW,EAAE,WAAW;YACxB,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;oBACD,YAAY,EAAE;wBACZ,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,EAAE;qBACZ;oBACD,+BAA+B,EAAE;wBAC/B,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,iCAAiC,EAAE;wBACjC,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,iCAAiC,EAAE;wBACjC,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;iBACF;gBACD,oBAAoB,EAAE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C7C,cAAc,CAAC,WAAW,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,CACrD,CAAC;oBACN,MAAM,YAAY,GAAG,IAAA,mBAAY,EAC/B,cAAc,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,CACvC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;oBACZ,IACE,CAAC,+BAA+B;wBAC9B,YAAY,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC;wBAChD,CAAC,iCAAiC;4BAChC,YAAY,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAClD,CAAC;wBACD,OAAO;oBACT,CAAC;oBACD,IACE,cAAc,KAAK,SAAS;wBAC5B,iCAAiC,EACjC,CAAC;wBACD,MAAM,UAAU,GAAG,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBAC3D,MAAM,SAAS,GAAG,UAAU;6BACzB,kBAAkB,EAAE;6BACpB,kBAAkB,EAAE,CAAC;wBACxB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;4BAC5B,OAAO;wBACT,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,112 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnumLiterals = getEnumLiterals;
exports.getEnumTypes = getEnumTypes;
exports.getEnumKeyForLiteral = getEnumKeyForLiteral;
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util_1 = require("../../util");
/*
* If passed an enum member, returns the type of the parent. Otherwise,
* returns itself.
*
* For example:
* - `Fruit` --> `Fruit`
* - `Fruit.Apple` --> `Fruit`
*/
function getBaseEnumType(typeChecker, type) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const symbol = type.getSymbol();
if (!tsutils.isSymbolFlagSet(symbol, ts.SymbolFlags.EnumMember)) {
return type;
}
return typeChecker.getTypeAtLocation(symbol.valueDeclaration.parent);
}
/**
* Retrieve only the Enum literals from a type. for example:
* - 123 --> []
* - {} --> []
* - Fruit.Apple --> [Fruit.Apple]
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit.Apple, Vegetable.Lettuce]
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit.Apple, Vegetable.Lettuce]
* - T extends Fruit --> [Fruit]
*/
function getEnumLiterals(type) {
return tsutils
.unionTypeParts(type)
.filter((subType) => (0, util_1.isTypeFlagSet)(subType, ts.TypeFlags.EnumLiteral));
}
/**
* A type can have 0 or more enum types. For example:
* - 123 --> []
* - {} --> []
* - Fruit.Apple --> [Fruit]
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit, Vegetable]
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit, Vegetable]
* - T extends Fruit --> [Fruit]
*/
function getEnumTypes(typeChecker, type) {
return getEnumLiterals(type).map(type => getBaseEnumType(typeChecker, type));
}
/**
* Returns the enum key that matches the given literal node, or null if none
* match. For example:
* ```ts
* enum Fruit {
* Apple = 'apple',
* Banana = 'banana',
* }
*
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'apple') --> 'Fruit.Apple'
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'banana') --> 'Fruit.Banana'
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'cherry') --> null
* ```
*/
function getEnumKeyForLiteral(enumLiterals, literal) {
for (const enumLiteral of enumLiterals) {
if (enumLiteral.value === literal) {
const { symbol } = enumLiteral;
const memberDeclaration = symbol.valueDeclaration;
const enumDeclaration = memberDeclaration.parent;
const memberNameIdentifier = memberDeclaration.name;
const enumName = enumDeclaration.name.text;
switch (memberNameIdentifier.kind) {
case ts.SyntaxKind.Identifier:
return `${enumName}.${memberNameIdentifier.text}`;
case ts.SyntaxKind.StringLiteral: {
const memberName = memberNameIdentifier.text.replace(/'/g, "\\'");
return `${enumName}['${memberName}']`;
}
case ts.SyntaxKind.ComputedPropertyName:
return `${enumName}[${memberNameIdentifier.expression.getText()}]`;
default:
break;
}
}
}
return null;
}
//# sourceMappingURL=shared.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/rules/enum-utils/shared.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,0CAMC;AAWD,oCAKC;AAgBD,oDAkCC;AA1GD,sDAAwC;AACxC,+CAAiC;AAEjC,qCAA2C;AAE3C;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,WAA2B,EAAE,IAAa;IACjE,oEAAoE;IACpE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAG,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,WAAW,CAAC,iBAAiB,CACjC,MAAM,CAAC,gBAAkC,CAAC,MAAM,CAClD,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GAAG,QAAQ,KAAK,UAAU,IAAI,CAAC;gBACxC,CAAC;gBAED,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB;oBACrC,OAAO,GAAG,QAAQ,IAAI,oBAAoB,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;gBAErE;oBACE,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}

View file

@ -1,180 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
exports.default = (0, util_1.createRule)({
name: 'explicit-function-return-type',
meta: {
type: 'problem',
docs: {
description: 'Require explicit return types on functions and class methods',
},
messages: {
missingReturnType: 'Missing return type on function.',
},
schema: [
{
type: 'object',
properties: {
allowConciseArrowFunctionExpressionsStartingWithVoid: {
description: 'Whether to allow arrow functions that start with the `void` keyword.',
type: 'boolean',
},
allowExpressions: {
description: 'Whether to ignore function expressions (functions which are not part of a declaration).',
type: 'boolean',
},
allowHigherOrderFunctions: {
description: 'Whether to ignore functions immediately returning another function expression.',
type: 'boolean',
},
allowTypedFunctionExpressions: {
description: 'Whether to ignore type annotations on the variable of function expressions.',
type: 'boolean',
},
allowDirectConstAssertionInArrowFunctions: {
description: 'Whether to ignore arrow functions immediately returning a `as const` value.',
type: 'boolean',
},
allowFunctionsWithoutTypeParameters: {
description: "Whether to ignore functions that don't have generic type parameters.",
type: 'boolean',
},
allowedNames: {
description: 'An array of function/method names that will not have their arguments or return values checked.',
items: {
type: 'string',
},
type: 'array',
},
allowIIFEs: {
description: 'Whether to ignore immediately invoked function expressions (IIFEs).',
type: 'boolean',
},
},
additionalProperties: false,
},
],
},
defaultOptions: [
{
allowExpressions: false,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: true,
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
allowFunctionsWithoutTypeParameters: false,
allowedNames: [],
allowIIFEs: false,
},
],
create(context, [options]) {
const functionInfoStack = [];
function enterFunction(node) {
functionInfoStack.push({
node,
returns: [],
});
}
function popFunctionInfo(exitNodeType) {
return (0, util_1.nullThrows)(functionInfoStack.pop(), `Stack should exist on ${exitNodeType} exit`);
}
function isAllowedFunction(node) {
if (options.allowFunctionsWithoutTypeParameters && !node.typeParameters) {
return true;
}
if (options.allowIIFEs && isIIFE(node)) {
return true;
}
if (!options.allowedNames?.length) {
return false;
}
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
node.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
const parent = node.parent;
let funcName;
if (node.id?.name) {
funcName = node.id.name;
}
else {
switch (parent.type) {
case utils_1.AST_NODE_TYPES.VariableDeclarator: {
if (parent.id.type === utils_1.AST_NODE_TYPES.Identifier) {
funcName = parent.id.name;
}
break;
}
case utils_1.AST_NODE_TYPES.MethodDefinition:
case utils_1.AST_NODE_TYPES.PropertyDefinition:
case utils_1.AST_NODE_TYPES.Property: {
if (parent.key.type === utils_1.AST_NODE_TYPES.Identifier &&
!parent.computed) {
funcName = parent.key.name;
}
break;
}
}
}
if (!!funcName && !!options.allowedNames.includes(funcName)) {
return true;
}
}
if (node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration &&
node.id &&
!!options.allowedNames.includes(node.id.name)) {
return true;
}
return false;
}
function isIIFE(node) {
return node.parent.type === utils_1.AST_NODE_TYPES.CallExpression;
}
function exitFunctionExpression(node) {
const info = popFunctionInfo('function expression');
if (options.allowConciseArrowFunctionExpressionsStartingWithVoid &&
node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
node.expression &&
node.body.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
node.body.operator === 'void') {
return;
}
if (isAllowedFunction(node)) {
return;
}
if (options.allowTypedFunctionExpressions &&
((0, explicitReturnTypeUtils_1.isValidFunctionExpressionReturnType)(node, options) ||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node))) {
return;
}
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(info, options, context.sourceCode, loc => context.report({
node,
loc,
messageId: 'missingReturnType',
}));
}
return {
'ArrowFunctionExpression, FunctionExpression, FunctionDeclaration': enterFunction,
'ArrowFunctionExpression:exit': exitFunctionExpression,
'FunctionExpression:exit': exitFunctionExpression,
'FunctionDeclaration:exit'(node) {
const info = popFunctionInfo('function declaration');
if (isAllowedFunction(node)) {
return;
}
if (options.allowTypedFunctionExpressions && node.returnType) {
return;
}
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(info, options, context.sourceCode, loc => context.report({
node,
loc,
messageId: 'missingReturnType',
}));
},
ReturnStatement(node) {
functionInfoStack.at(-1)?.returns.push(node);
},
};
},
});
//# sourceMappingURL=explicit-function-return-type.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAiD;AAEjD,6EAIyC;AAqBzC,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8DAA8D;SACjE;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,kCAAkC;SACtD;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,oDAAoD,EAAE;wBACpD,WAAW,EACT,sEAAsE;wBACxE,IAAI,EAAE,SAAS;qBAChB;oBACD,gBAAgB,EAAE;wBAChB,WAAW,EACT,yFAAyF;wBAC3F,IAAI,EAAE,SAAS;qBAChB;oBACD,yBAAyB,EAAE;wBACzB,WAAW,EACT,gFAAgF;wBAClF,IAAI,EAAE,SAAS;qBAChB;oBACD,6BAA6B,EAAE;wBAC7B,WAAW,EACT,6EAA6E;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CAAC;QAED,OAAO;YACL,kEAAkE,EAChE,aAAa;YACf,8BAA8B,EAAE,sBAAsB;YACtD,yBAAyB,EAAE,sBAAsB;YACjD,0BAA0B,CAAC,IAAI;gBAC7B,MAAM,IAAI,GAAG,eAAe,CAAC,sBAAsB,CAAC,CAAC;gBACrD,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC5B,OAAO;gBACT,CAAC;gBACD,IAAI,OAAO,CAAC,6BAA6B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBAC7D,OAAO;gBACT,CAAC;gBAED,IAAA,iDAAuB,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAC/D,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CACH,CAAC;YACJ,CAAC;YACD,eAAe,CAAC,IAAI;gBAClB,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,293 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getMemberHeadLoc_1 = require("../util/getMemberHeadLoc");
exports.default = (0, util_1.createRule)({
name: 'explicit-member-accessibility',
meta: {
hasSuggestions: true,
type: 'problem',
docs: {
description: 'Require explicit accessibility modifiers on class properties and methods',
// too opinionated to be recommended
},
fixable: 'code',
messages: {
missingAccessibility: 'Missing accessibility modifier on {{type}} {{name}}.',
unwantedPublicAccessibility: 'Public accessibility modifier on {{type}} {{name}}.',
addExplicitAccessibility: "Add '{{ type }}' accessibility modifier",
},
schema: [
{
$defs: {
accessibilityLevel: {
oneOf: [
{
type: 'string',
enum: ['explicit'],
description: 'Always require an accessor.',
},
{
type: 'string',
enum: ['no-public'],
description: 'Require an accessor except when public.',
},
{
type: 'string',
enum: ['off'],
description: 'Never check whether there is an accessor.',
},
],
},
},
type: 'object',
properties: {
accessibility: { $ref: '#/items/0/$defs/accessibilityLevel' },
overrides: {
type: 'object',
properties: {
accessors: { $ref: '#/items/0/$defs/accessibilityLevel' },
constructors: { $ref: '#/items/0/$defs/accessibilityLevel' },
methods: { $ref: '#/items/0/$defs/accessibilityLevel' },
properties: { $ref: '#/items/0/$defs/accessibilityLevel' },
parameterProperties: {
$ref: '#/items/0/$defs/accessibilityLevel',
},
},
additionalProperties: false,
},
ignoredMethodNames: {
type: 'array',
items: {
type: 'string',
},
},
},
additionalProperties: false,
},
],
},
defaultOptions: [{ accessibility: 'explicit' }],
create(context, [option]) {
const baseCheck = option.accessibility ?? 'explicit';
const overrides = option.overrides ?? {};
const ctorCheck = overrides.constructors ?? baseCheck;
const accessorCheck = overrides.accessors ?? baseCheck;
const methodCheck = overrides.methods ?? baseCheck;
const propCheck = overrides.properties ?? baseCheck;
const paramPropCheck = overrides.parameterProperties ?? baseCheck;
const ignoredMethodNames = new Set(option.ignoredMethodNames ?? []);
/**
* Checks if a method declaration has an accessibility modifier.
* @param methodDefinition The node representing a MethodDefinition.
*/
function checkMethodAccessibilityModifier(methodDefinition) {
if (methodDefinition.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
return;
}
let nodeType = 'method definition';
let check = baseCheck;
switch (methodDefinition.kind) {
case 'method':
check = methodCheck;
break;
case 'constructor':
check = ctorCheck;
break;
case 'get':
case 'set':
check = accessorCheck;
nodeType = `${methodDefinition.kind} property accessor`;
break;
}
const { name: methodName } = (0, util_1.getNameFromMember)(methodDefinition, context.sourceCode);
if (check === 'off' || ignoredMethodNames.has(methodName)) {
return;
}
if (check === 'no-public' &&
methodDefinition.accessibility === 'public') {
const publicKeyword = findPublicKeyword(methodDefinition);
context.report({
loc: rangeToLoc(context.sourceCode, publicKeyword.range),
messageId: 'unwantedPublicAccessibility',
data: {
type: nodeType,
name: methodName,
},
fix: fixer => fixer.removeRange(publicKeyword.rangeToRemove),
});
}
else if (check === 'explicit' && !methodDefinition.accessibility) {
context.report({
loc: (0, getMemberHeadLoc_1.getMemberHeadLoc)(context.sourceCode, methodDefinition),
messageId: 'missingAccessibility',
data: {
type: nodeType,
name: methodName,
},
suggest: getMissingAccessibilitySuggestions(methodDefinition),
});
}
}
/**
* Returns an object containing a range that corresponds to the "public"
* keyword for a node, and the range that would need to be removed to
* remove the "public" keyword (including associated whitespace).
*/
function findPublicKeyword(node) {
const tokens = context.sourceCode.getTokens(node);
let rangeToRemove;
let keywordRange;
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.type === utils_1.AST_TOKEN_TYPES.Keyword &&
token.value === 'public') {
keywordRange = structuredClone(token.range);
const commensAfterPublicKeyword = context.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 { range: keywordRange, rangeToRemove };
}
/**
* Creates a fixer that adds an accessibility modifier keyword
*/
function getMissingAccessibilitySuggestions(node) {
function fix(accessibility, fixer) {
if (node.decorators.length) {
const lastDecorator = node.decorators[node.decorators.length - 1];
const nextToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(lastDecorator), util_1.NullThrowsReasons.MissingToken('token', 'last decorator'));
return fixer.insertTextBefore(nextToken, `${accessibility} `);
}
return fixer.insertTextBefore(node, `${accessibility} `);
}
return [
{
messageId: 'addExplicitAccessibility',
data: { type: 'public' },
fix: fixer => fix('public', fixer),
},
{
messageId: 'addExplicitAccessibility',
data: { type: 'private' },
fix: fixer => fix('private', fixer),
},
{
messageId: 'addExplicitAccessibility',
data: { type: 'protected' },
fix: fixer => fix('protected', fixer),
},
];
}
/**
* Checks if property has an accessibility modifier.
* @param propertyDefinition The node representing a PropertyDefinition.
*/
function checkPropertyAccessibilityModifier(propertyDefinition) {
if (propertyDefinition.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
return;
}
const nodeType = 'class property';
const { name: propertyName } = (0, util_1.getNameFromMember)(propertyDefinition, context.sourceCode);
if (propCheck === 'no-public' &&
propertyDefinition.accessibility === 'public') {
const publicKeywordRange = findPublicKeyword(propertyDefinition);
context.report({
loc: rangeToLoc(context.sourceCode, publicKeywordRange.range),
messageId: 'unwantedPublicAccessibility',
data: {
type: nodeType,
name: propertyName,
},
fix: fixer => fixer.removeRange(publicKeywordRange.rangeToRemove),
});
}
else if (propCheck === 'explicit' &&
!propertyDefinition.accessibility) {
context.report({
loc: (0, getMemberHeadLoc_1.getMemberHeadLoc)(context.sourceCode, propertyDefinition),
messageId: 'missingAccessibility',
data: {
type: nodeType,
name: propertyName,
},
suggest: getMissingAccessibilitySuggestions(propertyDefinition),
});
}
}
/**
* Checks that the parameter property has the desired accessibility modifiers set.
* @param node The node representing a Parameter Property
*/
function checkParameterPropertyAccessibilityModifier(node) {
const nodeType = 'parameter property';
// HAS to be an identifier or assignment or TSC will throw
if (node.parameter.type !== utils_1.AST_NODE_TYPES.Identifier &&
node.parameter.type !== utils_1.AST_NODE_TYPES.AssignmentPattern) {
return;
}
const nodeName = node.parameter.type === utils_1.AST_NODE_TYPES.Identifier
? node.parameter.name
: // has to be an Identifier or TSC will throw an error
node.parameter.left.name;
switch (paramPropCheck) {
case 'explicit': {
if (!node.accessibility) {
context.report({
loc: (0, getMemberHeadLoc_1.getParameterPropertyHeadLoc)(context.sourceCode, node, nodeName),
messageId: 'missingAccessibility',
data: {
type: nodeType,
name: nodeName,
},
suggest: getMissingAccessibilitySuggestions(node),
});
}
break;
}
case 'no-public': {
if (node.accessibility === 'public' && node.readonly) {
const publicKeyword = findPublicKeyword(node);
context.report({
loc: rangeToLoc(context.sourceCode, publicKeyword.range),
messageId: 'unwantedPublicAccessibility',
data: {
type: nodeType,
name: nodeName,
},
fix: fixer => fixer.removeRange(publicKeyword.rangeToRemove),
});
}
break;
}
}
}
return {
'MethodDefinition, TSAbstractMethodDefinition': checkMethodAccessibilityModifier,
'PropertyDefinition, TSAbstractPropertyDefinition': checkPropertyAccessibilityModifier,
TSParameterProperty: checkParameterPropertyAccessibilityModifier,
};
},
});
function rangeToLoc(sourceCode, range) {
return {
start: sourceCode.getLocFromIndex(range[0]),
end: sourceCode.getLocFromIndex(range[1]),
};
}
//# sourceMappingURL=explicit-member-accessibility.js.map

View file

@ -1,386 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
exports.default = (0, util_1.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",
},
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: {
description: 'Whether to ignore arguments that are explicitly typed as `any`.',
type: 'boolean',
},
allowDirectConstAssertionInArrowFunctions: {
description: [
'Whether to ignore return type annotations on body-less arrow functions that return an `as const` type assertion.',
'You must still type the parameters of the function.',
].join('\n'),
type: 'boolean',
},
allowedNames: {
description: 'An array of function/method names that will not have their arguments or return values checked.',
items: {
type: 'string',
},
type: 'array',
},
allowHigherOrderFunctions: {
description: [
'Whether to ignore return type annotations on functions immediately returning another function expression.',
'You must still type the parameters of the function.',
].join('\n'),
type: 'boolean',
},
allowTypedFunctionExpressions: {
description: 'Whether to ignore type annotations on the variable of a function expression.',
type: 'boolean',
},
},
additionalProperties: false,
},
],
},
defaultOptions: [
{
allowArgumentsExplicitlyTypedAsAny: false,
allowDirectConstAssertionInArrowFunctions: true,
allowedNames: [],
allowHigherOrderFunctions: true,
allowTypedFunctionExpressions: true,
},
],
create(context, [options]) {
// tracks all of the functions we've already checked
const checkedFunctions = new Set();
const functionStack = [];
const functionReturnsMap = new Map();
// all nodes visited, avoids infinite recursion for cyclic references
// (such as class member referring to itself)
const alreadyVisited = new Set();
function getReturnsInFunction(node) {
return functionReturnsMap.get(node) ?? [];
}
function enterFunction(node) {
functionStack.push(node);
functionReturnsMap.set(node, []);
}
function exitFunction() {
functionStack.pop();
}
/*
# 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:exit'(node) {
checkNode(node.declaration);
},
'ExportNamedDeclaration:not([source]):exit'(node) {
if (node.declaration) {
checkNode(node.declaration);
}
else {
for (const specifier of node.specifiers) {
followReference(specifier.local);
}
}
},
'TSExportAssignment:exit'(node) {
checkNode(node.expression);
},
'ArrowFunctionExpression, FunctionDeclaration, FunctionExpression': enterFunction,
'ArrowFunctionExpression:exit': exitFunction,
'FunctionDeclaration:exit': exitFunction,
'FunctionExpression:exit': exitFunction,
'Program:exit'() {
for (const [node, returns] of functionReturnsMap) {
if (isExportedHigherOrderFunction({ node, returns })) {
checkNode(node);
}
}
},
ReturnStatement(node) {
const current = functionStack[functionStack.length - 1];
functionReturnsMap.get(current)?.push(node);
},
};
function checkParameters(node) {
function checkParameter(param) {
function report(namedMessageId, unnamedMessageId) {
if (param.type === utils_1.AST_NODE_TYPES.Identifier) {
context.report({
node: param,
messageId: namedMessageId,
data: { name: param.name },
});
}
else if (param.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
context.report({
node: param,
messageId: unnamedMessageId,
data: { type: 'Array pattern' },
});
}
else if (param.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
context.report({
node: param,
messageId: unnamedMessageId,
data: { type: 'Object pattern' },
});
}
else if (param.type === utils_1.AST_NODE_TYPES.RestElement) {
if (param.argument.type === utils_1.AST_NODE_TYPES.Identifier) {
context.report({
node: param,
messageId: namedMessageId,
data: { name: param.argument.name },
});
}
else {
context.report({
node: param,
messageId: unnamedMessageId,
data: { type: 'Rest' },
});
}
}
}
switch (param.type) {
case utils_1.AST_NODE_TYPES.ArrayPattern:
case utils_1.AST_NODE_TYPES.Identifier:
case utils_1.AST_NODE_TYPES.ObjectPattern:
case utils_1.AST_NODE_TYPES.RestElement:
if (!param.typeAnnotation) {
report('missingArgType', 'missingArgTypeUnnamed');
}
else if (options.allowArgumentsExplicitlyTypedAsAny !== true &&
param.typeAnnotation.typeAnnotation.type ===
utils_1.AST_NODE_TYPES.TSAnyKeyword) {
report('anyTypedArg', 'anyTypedArgUnnamed');
}
return;
case utils_1.AST_NODE_TYPES.TSParameterProperty:
return checkParameter(param.parameter);
case utils_1.AST_NODE_TYPES.AssignmentPattern: // ignored as it has a type via its assignment
return;
}
}
for (const arg of node.params) {
checkParameter(arg);
}
}
/**
* Checks if a function name is allowed and should not be checked.
*/
function isAllowedName(node) {
if (!node || !options.allowedNames || options.allowedNames.length === 0) {
return false;
}
if (node.type === utils_1.AST_NODE_TYPES.VariableDeclarator ||
node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration) {
return (node.id?.type === utils_1.AST_NODE_TYPES.Identifier &&
options.allowedNames.includes(node.id.name));
}
else if (node.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
(node.type === utils_1.AST_NODE_TYPES.Property && node.method) ||
node.type === utils_1.AST_NODE_TYPES.PropertyDefinition) {
if (node.key.type === utils_1.AST_NODE_TYPES.Literal &&
typeof node.key.value === 'string') {
return options.allowedNames.includes(node.key.value);
}
if (node.key.type === utils_1.AST_NODE_TYPES.TemplateLiteral &&
node.key.expressions.length === 0) {
return options.allowedNames.includes(node.key.quasis[0].value.raw);
}
if (!node.computed && node.key.type === utils_1.AST_NODE_TYPES.Identifier) {
return options.allowedNames.includes(node.key.name);
}
}
return false;
}
function isExportedHigherOrderFunction({ node, }) {
let current = node.parent;
while (current) {
if (current.type === utils_1.AST_NODE_TYPES.ReturnStatement) {
// the parent of a return will always be a block statement, so we can skip over it
current = current.parent.parent;
continue;
}
if (!(0, util_1.isFunction)(current)) {
return false;
}
const returns = getReturnsInFunction(current);
if (!(0, explicitReturnTypeUtils_1.doesImmediatelyReturnFunctionExpression)({ node: current, returns })) {
return false;
}
if (checkedFunctions.has(current)) {
return true;
}
current = current.parent;
}
return false;
}
function followReference(node) {
const scope = context.sourceCode.getScope(node);
const variable = scope.set.get(node.name);
/* istanbul ignore if */ if (!variable) {
return;
}
// check all of the definitions
for (const definition of variable.defs) {
// cases we don't care about in this rule
if ([
scope_manager_1.DefinitionType.ImplicitGlobalVariable,
scope_manager_1.DefinitionType.ImportBinding,
scope_manager_1.DefinitionType.CatchClause,
scope_manager_1.DefinitionType.Parameter,
].includes(definition.type)) {
continue;
}
checkNode(definition.node);
}
// follow references to find writes to the variable
for (const reference of variable.references) {
if (
// we don't want to check the initialization ref, as this is handled by the declaration check
!reference.init &&
reference.writeExpr) {
checkNode(reference.writeExpr);
}
}
}
function checkNode(node) {
if (node == null || alreadyVisited.has(node)) {
return;
}
alreadyVisited.add(node);
switch (node.type) {
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
case utils_1.AST_NODE_TYPES.FunctionExpression: {
const returns = getReturnsInFunction(node);
return checkFunctionExpression({ node, returns });
}
case utils_1.AST_NODE_TYPES.ArrayExpression:
for (const element of node.elements) {
checkNode(element);
}
return;
case utils_1.AST_NODE_TYPES.PropertyDefinition:
if (node.accessibility === 'private' ||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
return;
}
return checkNode(node.value);
case utils_1.AST_NODE_TYPES.ClassDeclaration:
case utils_1.AST_NODE_TYPES.ClassExpression:
for (const element of node.body.body) {
checkNode(element);
}
return;
case utils_1.AST_NODE_TYPES.FunctionDeclaration: {
const returns = getReturnsInFunction(node);
return checkFunction({ node, returns });
}
case utils_1.AST_NODE_TYPES.MethodDefinition:
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
if (node.accessibility === 'private' ||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
return;
}
return checkNode(node.value);
case utils_1.AST_NODE_TYPES.Identifier:
return followReference(node);
case utils_1.AST_NODE_TYPES.ObjectExpression:
for (const property of node.properties) {
checkNode(property);
}
return;
case utils_1.AST_NODE_TYPES.Property:
return checkNode(node.value);
case utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression:
return checkEmptyBodyFunctionExpression(node);
case utils_1.AST_NODE_TYPES.VariableDeclaration:
for (const declaration of node.declarations) {
checkNode(declaration);
}
return;
case utils_1.AST_NODE_TYPES.VariableDeclarator:
return checkNode(node.init);
}
}
function checkEmptyBodyFunctionExpression(node) {
const isConstructor = node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
node.parent.kind === 'constructor';
const isSetAccessor = (node.parent.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
node.parent.kind === 'set';
if (!isConstructor && !isSetAccessor && !node.returnType) {
context.report({
node,
messageId: 'missingReturnType',
});
}
checkParameters(node);
}
function checkFunctionExpression({ node, returns, }) {
if (checkedFunctions.has(node)) {
return;
}
checkedFunctions.add(node);
if (isAllowedName(node.parent) ||
(0, explicitReturnTypeUtils_1.isTypedFunctionExpression)(node, options) ||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
return;
}
(0, explicitReturnTypeUtils_1.checkFunctionExpressionReturnType)({ node, returns }, options, context.sourceCode, loc => {
context.report({
node,
loc,
messageId: 'missingReturnType',
});
});
checkParameters(node);
}
function checkFunction({ node, returns, }) {
if (checkedFunctions.has(node)) {
return;
}
checkedFunctions.add(node);
if (isAllowedName(node) || (0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
return;
}
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)({ node, returns }, options, context.sourceCode, loc => {
context.report({
node,
loc,
messageId: 'missingReturnType',
});
});
checkParameters(node);
}
},
});
//# sourceMappingURL=explicit-module-boundary-types.js.map

View file

@ -1,143 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'func-call-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/func-call-spacing'],
type: 'layout',
docs: {
description: 'Require or disallow spacing between function identifiers and their invocations',
extendsBaseRule: true,
},
fixable: 'whitespace',
schema: {
anyOf: [
{
type: 'array',
items: [
{
type: 'string',
enum: ['never'],
},
],
minItems: 0,
maxItems: 1,
},
{
type: 'array',
items: [
{
type: 'string',
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 text = context.sourceCode.getText();
/**
* Check if open space is present in a function name
* @param node node to evaluate
* @private
*/
function checkSpacing(node) {
const isOptionalCall = (0, util_1.isOptionalCallExpression)(node);
const closingParenToken = context.sourceCode.getLastToken(node);
const lastCalleeTokenWithoutPossibleParens = context.sourceCode.getLastToken(node.typeArguments ?? node.callee);
const openingParenToken = context.sourceCode.getFirstTokenBetween(lastCalleeTokenWithoutPossibleParens, closingParenToken, util_1.isOpeningParenToken);
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {
// new expression with no parens...
return;
}
const lastCalleeToken = context.sourceCode.getTokenBefore(openingParenToken, util_1.isNotOptionalChainPunctuator);
const textBetweenTokens = text
.slice(lastCalleeToken.range[1], openingParenToken.range[0])
.replace(/\/\*.*?\*\//gu, '');
const hasWhitespace = /\s/u.test(textBetweenTokens);
const hasNewline = hasWhitespace && util_1.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

@ -1 +0,0 @@
{"version":3,"file":"func-call-spacing.js","sourceRoot":"","sources":["../../src/rules/func-call-spacing.ts"],"names":[],"mappings":";;AAGA,kCAMiB;AAajB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,iCAAiC,CAAC;QAC/C,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EACT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,CAAC;YACH,CAAC;iBAAM,IAAI,cAAc,EAAE,CAAC;gBAC1B,YAAY;gBACZ,YAAY;gBACZ,YAAY;gBACZ,aAAa;gBACb,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;oBAChC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,sBAAsB;qBAClC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,aAAa,EAAE,CAAC;gBAC1B,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;oBAC9B,SAAS,EAAE,SAAS;oBACpB,GAAG,CAAC,KAAK;wBACP,OAAO,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;oBACxD,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,CAAC,MAAO,CAAC,aAAa,IAAI,UAAU,EAAE,CAAC;gBAChD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;oBAC9B,SAAS,EAAE,mBAAmB;oBAC9B,GAAG,CAAC,KAAK;wBACP,OAAO,KAAK,CAAC,gBAAgB,CAC3B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACtD,GAAG,CACJ,CAAC;oBACJ,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,YAAY;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,415 +0,0 @@
"use strict";
/**
* Note this file is rather type-unsafe in its current state.
* This is due to some really funky type conversions between different node types.
* This is done intentionally based on the internal implementation of the base indent rule.
*/
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, eslint-plugin/no-property-in-node */
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('indent');
const KNOWN_NODES = new Set([
// Class properties aren't yet supported by eslint...
utils_1.AST_NODE_TYPES.PropertyDefinition,
// ts keywords
utils_1.AST_NODE_TYPES.TSAbstractKeyword,
utils_1.AST_NODE_TYPES.TSAnyKeyword,
utils_1.AST_NODE_TYPES.TSBooleanKeyword,
utils_1.AST_NODE_TYPES.TSNeverKeyword,
utils_1.AST_NODE_TYPES.TSNumberKeyword,
utils_1.AST_NODE_TYPES.TSStringKeyword,
utils_1.AST_NODE_TYPES.TSSymbolKeyword,
utils_1.AST_NODE_TYPES.TSUndefinedKeyword,
utils_1.AST_NODE_TYPES.TSUnknownKeyword,
utils_1.AST_NODE_TYPES.TSVoidKeyword,
utils_1.AST_NODE_TYPES.TSNullKeyword,
// ts specific nodes we want to support
utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition,
utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition,
utils_1.AST_NODE_TYPES.TSArrayType,
utils_1.AST_NODE_TYPES.TSAsExpression,
utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
utils_1.AST_NODE_TYPES.TSConditionalType,
utils_1.AST_NODE_TYPES.TSConstructorType,
utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
utils_1.AST_NODE_TYPES.TSDeclareFunction,
utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
utils_1.AST_NODE_TYPES.TSEnumDeclaration,
utils_1.AST_NODE_TYPES.TSEnumMember,
utils_1.AST_NODE_TYPES.TSExportAssignment,
utils_1.AST_NODE_TYPES.TSExternalModuleReference,
utils_1.AST_NODE_TYPES.TSFunctionType,
utils_1.AST_NODE_TYPES.TSImportType,
utils_1.AST_NODE_TYPES.TSIndexedAccessType,
utils_1.AST_NODE_TYPES.TSIndexSignature,
utils_1.AST_NODE_TYPES.TSInferType,
utils_1.AST_NODE_TYPES.TSInterfaceBody,
utils_1.AST_NODE_TYPES.TSInterfaceDeclaration,
utils_1.AST_NODE_TYPES.TSInterfaceHeritage,
utils_1.AST_NODE_TYPES.TSIntersectionType,
utils_1.AST_NODE_TYPES.TSImportEqualsDeclaration,
utils_1.AST_NODE_TYPES.TSLiteralType,
utils_1.AST_NODE_TYPES.TSMappedType,
utils_1.AST_NODE_TYPES.TSMethodSignature,
'TSMinusToken',
utils_1.AST_NODE_TYPES.TSModuleBlock,
utils_1.AST_NODE_TYPES.TSModuleDeclaration,
utils_1.AST_NODE_TYPES.TSNonNullExpression,
utils_1.AST_NODE_TYPES.TSParameterProperty,
'TSPlusToken',
utils_1.AST_NODE_TYPES.TSPropertySignature,
utils_1.AST_NODE_TYPES.TSQualifiedName,
'TSQuestionToken',
utils_1.AST_NODE_TYPES.TSRestType,
utils_1.AST_NODE_TYPES.TSThisType,
utils_1.AST_NODE_TYPES.TSTupleType,
utils_1.AST_NODE_TYPES.TSTypeAnnotation,
utils_1.AST_NODE_TYPES.TSTypeLiteral,
utils_1.AST_NODE_TYPES.TSTypeOperator,
utils_1.AST_NODE_TYPES.TSTypeParameter,
utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration,
utils_1.AST_NODE_TYPES.TSTypeParameterInstantiation,
utils_1.AST_NODE_TYPES.TSTypeReference,
utils_1.AST_NODE_TYPES.TSUnionType,
utils_1.AST_NODE_TYPES.Decorator,
]);
exports.default = (0, util_1.createRule)({
name: 'indent',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/indent'],
type: 'layout',
docs: {
description: 'Enforce consistent indentation',
// too opinionated to be recommended
extendsBaseRule: true,
},
fixable: 'whitespace',
hasSuggestions: baseRule.meta.hasSuggestions,
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
},
defaultOptions: [
// typescript docs and playground use 4 space indent
4,
{
// typescript docs indent the case from the switch
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#example-4
SwitchCase: 1,
flatTernaryExpressions: false,
ignoredNodes: [],
},
],
create(context, optionsWithDefaults) {
// because we extend the base rule, have to update opts on the context
// the context defines options as readonly though...
const contextWithDefaults = Object.create(context, {
options: {
writable: false,
configurable: false,
value: optionsWithDefaults,
},
});
const rules = baseRule.create(contextWithDefaults);
/**
* Converts from a TSPropertySignature to a Property
* @param node a TSPropertySignature node
* @param [type] the type to give the new node
* @returns a Property node
*/
function TSPropertySignatureToProperty(node, type = utils_1.AST_NODE_TYPES.Property) {
const base = {
// indent doesn't actually use these
key: null,
value: null,
// Property flags
computed: false,
method: false,
kind: 'init',
// this will stop eslint from interrogating the type literal
shorthand: true,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
};
if (type === utils_1.AST_NODE_TYPES.Property) {
return {
type,
...base,
};
}
return {
type,
accessibility: undefined,
declare: false,
decorators: [],
definite: false,
optional: false,
override: false,
readonly: false,
static: false,
typeAnnotation: undefined,
...base,
};
}
return {
...rules,
// overwrite the base rule here so we can use our KNOWN_NODES list instead
'*:exit'(node) {
// For nodes we care about, skip the default handling, because it just marks the node as ignored...
if (!KNOWN_NODES.has(node.type)) {
rules['*:exit'](node);
}
},
VariableDeclaration(node) {
// https://github.com/typescript-eslint/typescript-eslint/issues/441
if (node.declarations.length === 0) {
return;
}
return rules.VariableDeclaration(node);
},
TSAsExpression(node) {
// transform it to a BinaryExpression
return rules['BinaryExpression, LogicalExpression']({
type: utils_1.AST_NODE_TYPES.BinaryExpression,
operator: 'as',
left: node.expression,
// the first typeAnnotation includes the as token
right: node.typeAnnotation,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSConditionalType(node) {
// transform it to a ConditionalExpression
return rules.ConditionalExpression({
type: utils_1.AST_NODE_TYPES.ConditionalExpression,
test: {
parent: node,
type: utils_1.AST_NODE_TYPES.BinaryExpression,
operator: 'extends',
left: node.checkType,
right: node.extendsType,
// location data
range: [node.checkType.range[0], node.extendsType.range[1]],
loc: {
start: node.checkType.loc.start,
end: node.extendsType.loc.end,
},
},
consequent: node.trueType,
alternate: node.falseType,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
'TSEnumDeclaration, TSTypeLiteral'(node) {
// transform it to an ObjectExpression
return rules['ObjectExpression, ObjectPattern']({
type: utils_1.AST_NODE_TYPES.ObjectExpression,
properties: node.members.map(member => TSPropertySignatureToProperty(member)),
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSImportEqualsDeclaration(node) {
// transform it to an VariableDeclaration
// use VariableDeclaration instead of ImportDeclaration because it's essentially the same thing
const { id, moduleReference } = node;
return rules.VariableDeclaration({
type: utils_1.AST_NODE_TYPES.VariableDeclaration,
kind: 'const',
declarations: [
{
type: utils_1.AST_NODE_TYPES.VariableDeclarator,
range: [id.range[0], moduleReference.range[1]],
loc: {
start: id.loc.start,
end: moduleReference.loc.end,
},
id: id,
init: {
type: utils_1.AST_NODE_TYPES.CallExpression,
callee: {
type: utils_1.AST_NODE_TYPES.Identifier,
name: 'require',
range: [
moduleReference.range[0],
moduleReference.range[0] + 'require'.length,
],
loc: {
start: moduleReference.loc.start,
end: {
line: moduleReference.loc.end.line,
column: moduleReference.loc.start.line + 'require'.length,
},
},
},
arguments: 'expression' in moduleReference
? [moduleReference.expression]
: [],
// location data
range: moduleReference.range,
loc: moduleReference.loc,
},
},
],
declare: false,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSIndexedAccessType(node) {
// convert to a MemberExpression
return rules['MemberExpression, JSXMemberExpression, MetaProperty']({
type: utils_1.AST_NODE_TYPES.MemberExpression,
object: node.objectType,
property: node.indexType,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
optional: false,
computed: true,
});
},
TSInterfaceBody(node) {
// transform it to an ClassBody
return rules['BlockStatement, ClassBody']({
type: utils_1.AST_NODE_TYPES.ClassBody,
body: node.body.map(p => TSPropertySignatureToProperty(p, utils_1.AST_NODE_TYPES.PropertyDefinition)),
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
'TSInterfaceDeclaration[extends.length > 0]'(node) {
// transform it to a ClassDeclaration
return rules['ClassDeclaration[superClass], ClassExpression[superClass]']({
type: utils_1.AST_NODE_TYPES.ClassDeclaration,
body: node.body,
id: null,
// TODO: This is invalid, there can be more than one extends in interface
superClass: node.extends[0].expression,
abstract: false,
declare: false,
decorators: [],
implements: [],
superTypeArguments: undefined,
superTypeParameters: undefined,
typeParameters: undefined,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSMappedType(node) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const squareBracketStart = context.sourceCode.getTokenBefore(node.typeParameter);
// transform it to an ObjectExpression
return rules['ObjectExpression, ObjectPattern']({
type: utils_1.AST_NODE_TYPES.ObjectExpression,
properties: [
{
parent: node,
type: utils_1.AST_NODE_TYPES.Property,
key: node.typeParameter,
value: node.typeAnnotation,
// location data
range: [
squareBracketStart.range[0],
node.typeAnnotation
? node.typeAnnotation.range[1]
: squareBracketStart.range[0],
],
loc: {
start: squareBracketStart.loc.start,
end: node.typeAnnotation
? node.typeAnnotation.loc.end
: squareBracketStart.loc.end,
},
kind: 'init',
computed: false,
method: false,
optional: false,
shorthand: false,
},
],
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSModuleBlock(node) {
// transform it to a BlockStatement
return rules['BlockStatement, ClassBody']({
type: utils_1.AST_NODE_TYPES.BlockStatement,
body: node.body,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSQualifiedName(node) {
return rules['MemberExpression, JSXMemberExpression, MetaProperty']({
type: utils_1.AST_NODE_TYPES.MemberExpression,
object: node.left,
property: node.right,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
optional: false,
computed: false,
});
},
TSTupleType(node) {
// transform it to an ArrayExpression
return rules['ArrayExpression, ArrayPattern']({
type: utils_1.AST_NODE_TYPES.ArrayExpression,
elements: node.elementTypes,
// location data
parent: node.parent,
range: node.range,
loc: node.loc,
});
},
TSTypeParameterDeclaration(node) {
if (!node.params.length) {
return;
}
const [name, ...attributes] = node.params;
// JSX is about the closest we can get because the angle brackets
// it's not perfect but it works!
return rules.JSXOpeningElement({
type: utils_1.AST_NODE_TYPES.JSXOpeningElement,
selfClosing: false,
name: name,
attributes: attributes,
typeArguments: undefined,
typeParameters: undefined,
// 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

@ -1,306 +0,0 @@
"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 block_spacing_1 = __importDefault(require("./block-spacing"));
const brace_style_1 = __importDefault(require("./brace-style"));
const class_literal_property_style_1 = __importDefault(require("./class-literal-property-style"));
const class_methods_use_this_1 = __importDefault(require("./class-methods-use-this"));
const comma_dangle_1 = __importDefault(require("./comma-dangle"));
const comma_spacing_1 = __importDefault(require("./comma-spacing"));
const consistent_generic_constructors_1 = __importDefault(require("./consistent-generic-constructors"));
const consistent_indexed_object_style_1 = __importDefault(require("./consistent-indexed-object-style"));
const consistent_return_1 = __importDefault(require("./consistent-return"));
const consistent_type_assertions_1 = __importDefault(require("./consistent-type-assertions"));
const consistent_type_definitions_1 = __importDefault(require("./consistent-type-definitions"));
const consistent_type_exports_1 = __importDefault(require("./consistent-type-exports"));
const consistent_type_imports_1 = __importDefault(require("./consistent-type-imports"));
const default_param_last_1 = __importDefault(require("./default-param-last"));
const dot_notation_1 = __importDefault(require("./dot-notation"));
const explicit_function_return_type_1 = __importDefault(require("./explicit-function-return-type"));
const explicit_member_accessibility_1 = __importDefault(require("./explicit-member-accessibility"));
const explicit_module_boundary_types_1 = __importDefault(require("./explicit-module-boundary-types"));
const func_call_spacing_1 = __importDefault(require("./func-call-spacing"));
const indent_1 = __importDefault(require("./indent"));
const init_declarations_1 = __importDefault(require("./init-declarations"));
const key_spacing_1 = __importDefault(require("./key-spacing"));
const keyword_spacing_1 = __importDefault(require("./keyword-spacing"));
const lines_around_comment_1 = __importDefault(require("./lines-around-comment"));
const lines_between_class_members_1 = __importDefault(require("./lines-between-class-members"));
const max_params_1 = __importDefault(require("./max-params"));
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_array_delete_1 = __importDefault(require("./no-array-delete"));
const no_base_to_string_1 = __importDefault(require("./no-base-to-string"));
const no_confusing_non_null_assertion_1 = __importDefault(require("./no-confusing-non-null-assertion"));
const no_confusing_void_expression_1 = __importDefault(require("./no-confusing-void-expression"));
const no_dupe_class_members_1 = __importDefault(require("./no-dupe-class-members"));
const no_duplicate_enum_values_1 = __importDefault(require("./no-duplicate-enum-values"));
const no_duplicate_type_constituents_1 = __importDefault(require("./no-duplicate-type-constituents"));
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_empty_object_type_1 = __importDefault(require("./no-empty-object-type"));
const no_explicit_any_1 = __importDefault(require("./no-explicit-any"));
const no_extra_non_null_assertion_1 = __importDefault(require("./no-extra-non-null-assertion"));
const no_extra_parens_1 = __importDefault(require("./no-extra-parens"));
const no_extra_semi_1 = __importDefault(require("./no-extra-semi"));
const no_extraneous_class_1 = __importDefault(require("./no-extraneous-class"));
const no_floating_promises_1 = __importDefault(require("./no-floating-promises"));
const no_for_in_array_1 = __importDefault(require("./no-for-in-array"));
const no_implied_eval_1 = __importDefault(require("./no-implied-eval"));
const no_import_type_side_effects_1 = __importDefault(require("./no-import-type-side-effects"));
const no_inferrable_types_1 = __importDefault(require("./no-inferrable-types"));
const no_invalid_this_1 = __importDefault(require("./no-invalid-this"));
const no_invalid_void_type_1 = __importDefault(require("./no-invalid-void-type"));
const no_loop_func_1 = __importDefault(require("./no-loop-func"));
const no_loss_of_precision_1 = __importDefault(require("./no-loss-of-precision"));
const no_magic_numbers_1 = __importDefault(require("./no-magic-numbers"));
const no_meaningless_void_operator_1 = __importDefault(require("./no-meaningless-void-operator"));
const no_misused_new_1 = __importDefault(require("./no-misused-new"));
const no_misused_promises_1 = __importDefault(require("./no-misused-promises"));
const no_mixed_enums_1 = __importDefault(require("./no-mixed-enums"));
const no_namespace_1 = __importDefault(require("./no-namespace"));
const no_non_null_asserted_nullish_coalescing_1 = __importDefault(require("./no-non-null-asserted-nullish-coalescing"));
const no_non_null_asserted_optional_chain_1 = __importDefault(require("./no-non-null-asserted-optional-chain"));
const no_non_null_assertion_1 = __importDefault(require("./no-non-null-assertion"));
const no_redeclare_1 = __importDefault(require("./no-redeclare"));
const no_redundant_type_constituents_1 = __importDefault(require("./no-redundant-type-constituents"));
const no_require_imports_1 = __importDefault(require("./no-require-imports"));
const no_restricted_imports_1 = __importDefault(require("./no-restricted-imports"));
const no_shadow_1 = __importDefault(require("./no-shadow"));
const no_this_alias_1 = __importDefault(require("./no-this-alias"));
const no_throw_literal_1 = __importDefault(require("./no-throw-literal"));
const no_type_alias_1 = __importDefault(require("./no-type-alias"));
const no_unnecessary_boolean_literal_compare_1 = __importDefault(require("./no-unnecessary-boolean-literal-compare"));
const no_unnecessary_condition_1 = __importDefault(require("./no-unnecessary-condition"));
const no_unnecessary_parameter_property_assignment_1 = __importDefault(require("./no-unnecessary-parameter-property-assignment"));
const no_unnecessary_qualifier_1 = __importDefault(require("./no-unnecessary-qualifier"));
const no_unnecessary_template_expression_1 = __importDefault(require("./no-unnecessary-template-expression"));
const no_unnecessary_type_arguments_1 = __importDefault(require("./no-unnecessary-type-arguments"));
const no_unnecessary_type_assertion_1 = __importDefault(require("./no-unnecessary-type-assertion"));
const no_unnecessary_type_constraint_1 = __importDefault(require("./no-unnecessary-type-constraint"));
const no_unnecessary_type_parameters_1 = __importDefault(require("./no-unnecessary-type-parameters"));
const no_unsafe_argument_1 = __importDefault(require("./no-unsafe-argument"));
const no_unsafe_assignment_1 = __importDefault(require("./no-unsafe-assignment"));
const no_unsafe_call_1 = __importDefault(require("./no-unsafe-call"));
const no_unsafe_declaration_merging_1 = __importDefault(require("./no-unsafe-declaration-merging"));
const no_unsafe_enum_comparison_1 = __importDefault(require("./no-unsafe-enum-comparison"));
const no_unsafe_function_type_1 = __importDefault(require("./no-unsafe-function-type"));
const no_unsafe_member_access_1 = __importDefault(require("./no-unsafe-member-access"));
const no_unsafe_return_1 = __importDefault(require("./no-unsafe-return"));
const no_unsafe_unary_minus_1 = __importDefault(require("./no-unsafe-unary-minus"));
const no_unused_expressions_1 = __importDefault(require("./no-unused-expressions"));
const no_unused_vars_1 = __importDefault(require("./no-unused-vars"));
const no_use_before_define_1 = __importDefault(require("./no-use-before-define"));
const no_useless_constructor_1 = __importDefault(require("./no-useless-constructor"));
const no_useless_empty_export_1 = __importDefault(require("./no-useless-empty-export"));
const no_useless_template_literals_1 = __importDefault(require("./no-useless-template-literals"));
const no_var_requires_1 = __importDefault(require("./no-var-requires"));
const no_wrapper_object_types_1 = __importDefault(require("./no-wrapper-object-types"));
const non_nullable_type_assertion_style_1 = __importDefault(require("./non-nullable-type-assertion-style"));
const object_curly_spacing_1 = __importDefault(require("./object-curly-spacing"));
const only_throw_error_1 = __importDefault(require("./only-throw-error"));
const padding_line_between_statements_1 = __importDefault(require("./padding-line-between-statements"));
const parameter_properties_1 = __importDefault(require("./parameter-properties"));
const prefer_as_const_1 = __importDefault(require("./prefer-as-const"));
const prefer_destructuring_1 = __importDefault(require("./prefer-destructuring"));
const prefer_enum_initializers_1 = __importDefault(require("./prefer-enum-initializers"));
const prefer_find_1 = __importDefault(require("./prefer-find"));
const prefer_for_of_1 = __importDefault(require("./prefer-for-of"));
const prefer_function_type_1 = __importDefault(require("./prefer-function-type"));
const prefer_includes_1 = __importDefault(require("./prefer-includes"));
const prefer_literal_enum_member_1 = __importDefault(require("./prefer-literal-enum-member"));
const prefer_namespace_keyword_1 = __importDefault(require("./prefer-namespace-keyword"));
const prefer_nullish_coalescing_1 = __importDefault(require("./prefer-nullish-coalescing"));
const prefer_optional_chain_1 = __importDefault(require("./prefer-optional-chain"));
const prefer_promise_reject_errors_1 = __importDefault(require("./prefer-promise-reject-errors"));
const prefer_readonly_1 = __importDefault(require("./prefer-readonly"));
const prefer_readonly_parameter_types_1 = __importDefault(require("./prefer-readonly-parameter-types"));
const prefer_reduce_type_parameter_1 = __importDefault(require("./prefer-reduce-type-parameter"));
const prefer_regexp_exec_1 = __importDefault(require("./prefer-regexp-exec"));
const prefer_return_this_type_1 = __importDefault(require("./prefer-return-this-type"));
const prefer_string_starts_ends_with_1 = __importDefault(require("./prefer-string-starts-ends-with"));
const prefer_ts_expect_error_1 = __importDefault(require("./prefer-ts-expect-error"));
const promise_function_async_1 = __importDefault(require("./promise-function-async"));
const quotes_1 = __importDefault(require("./quotes"));
const require_array_sort_compare_1 = __importDefault(require("./require-array-sort-compare"));
const require_await_1 = __importDefault(require("./require-await"));
const restrict_plus_operands_1 = __importDefault(require("./restrict-plus-operands"));
const restrict_template_expressions_1 = __importDefault(require("./restrict-template-expressions"));
const return_await_1 = __importDefault(require("./return-await"));
const semi_1 = __importDefault(require("./semi"));
const sort_type_constituents_1 = __importDefault(require("./sort-type-constituents"));
const space_before_blocks_1 = __importDefault(require("./space-before-blocks"));
const space_before_function_paren_1 = __importDefault(require("./space-before-function-paren"));
const space_infix_ops_1 = __importDefault(require("./space-infix-ops"));
const strict_boolean_expressions_1 = __importDefault(require("./strict-boolean-expressions"));
const switch_exhaustiveness_check_1 = __importDefault(require("./switch-exhaustiveness-check"));
const triple_slash_reference_1 = __importDefault(require("./triple-slash-reference"));
const type_annotation_spacing_1 = __importDefault(require("./type-annotation-spacing"));
const typedef_1 = __importDefault(require("./typedef"));
const unbound_method_1 = __importDefault(require("./unbound-method"));
const unified_signatures_1 = __importDefault(require("./unified-signatures"));
const use_unknown_in_catch_callback_variable_1 = __importDefault(require("./use-unknown-in-catch-callback-variable"));
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,
'block-spacing': block_spacing_1.default,
'brace-style': brace_style_1.default,
'class-literal-property-style': class_literal_property_style_1.default,
'class-methods-use-this': class_methods_use_this_1.default,
'comma-dangle': comma_dangle_1.default,
'comma-spacing': comma_spacing_1.default,
'consistent-generic-constructors': consistent_generic_constructors_1.default,
'consistent-indexed-object-style': consistent_indexed_object_style_1.default,
'consistent-return': consistent_return_1.default,
'consistent-type-assertions': consistent_type_assertions_1.default,
'consistent-type-definitions': consistent_type_definitions_1.default,
'consistent-type-exports': consistent_type_exports_1.default,
'consistent-type-imports': consistent_type_imports_1.default,
'default-param-last': default_param_last_1.default,
'dot-notation': dot_notation_1.default,
'explicit-function-return-type': explicit_function_return_type_1.default,
'explicit-member-accessibility': explicit_member_accessibility_1.default,
'explicit-module-boundary-types': explicit_module_boundary_types_1.default,
'func-call-spacing': func_call_spacing_1.default,
indent: indent_1.default,
'init-declarations': init_declarations_1.default,
'key-spacing': key_spacing_1.default,
'keyword-spacing': keyword_spacing_1.default,
'lines-around-comment': lines_around_comment_1.default,
'lines-between-class-members': lines_between_class_members_1.default,
'max-params': max_params_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-array-delete': no_array_delete_1.default,
'no-base-to-string': no_base_to_string_1.default,
'no-confusing-non-null-assertion': no_confusing_non_null_assertion_1.default,
'no-confusing-void-expression': no_confusing_void_expression_1.default,
'no-dupe-class-members': no_dupe_class_members_1.default,
'no-duplicate-enum-values': no_duplicate_enum_values_1.default,
'no-duplicate-type-constituents': no_duplicate_type_constituents_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-empty-object-type': no_empty_object_type_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-implied-eval': no_implied_eval_1.default,
'no-import-type-side-effects': no_import_type_side_effects_1.default,
'no-inferrable-types': no_inferrable_types_1.default,
'no-invalid-this': no_invalid_this_1.default,
'no-invalid-void-type': no_invalid_void_type_1.default,
'no-loop-func': no_loop_func_1.default,
'no-loss-of-precision': no_loss_of_precision_1.default,
'no-magic-numbers': no_magic_numbers_1.default,
'no-meaningless-void-operator': no_meaningless_void_operator_1.default,
'no-misused-new': no_misused_new_1.default,
'no-misused-promises': no_misused_promises_1.default,
'no-mixed-enums': no_mixed_enums_1.default,
'no-namespace': no_namespace_1.default,
'no-non-null-asserted-nullish-coalescing': no_non_null_asserted_nullish_coalescing_1.default,
'no-non-null-asserted-optional-chain': no_non_null_asserted_optional_chain_1.default,
'no-non-null-assertion': no_non_null_assertion_1.default,
'no-redeclare': no_redeclare_1.default,
'no-redundant-type-constituents': no_redundant_type_constituents_1.default,
'no-require-imports': no_require_imports_1.default,
'no-restricted-imports': no_restricted_imports_1.default,
'no-shadow': no_shadow_1.default,
'no-this-alias': no_this_alias_1.default,
'no-throw-literal': no_throw_literal_1.default,
'no-type-alias': no_type_alias_1.default,
'no-unnecessary-boolean-literal-compare': no_unnecessary_boolean_literal_compare_1.default,
'no-unnecessary-condition': no_unnecessary_condition_1.default,
'no-unnecessary-parameter-property-assignment': no_unnecessary_parameter_property_assignment_1.default,
'no-unnecessary-qualifier': no_unnecessary_qualifier_1.default,
'no-unnecessary-template-expression': no_unnecessary_template_expression_1.default,
'no-unnecessary-type-arguments': no_unnecessary_type_arguments_1.default,
'no-unnecessary-type-assertion': no_unnecessary_type_assertion_1.default,
'no-unnecessary-type-constraint': no_unnecessary_type_constraint_1.default,
'no-unnecessary-type-parameters': no_unnecessary_type_parameters_1.default,
'no-unsafe-argument': no_unsafe_argument_1.default,
'no-unsafe-assignment': no_unsafe_assignment_1.default,
'no-unsafe-call': no_unsafe_call_1.default,
'no-unsafe-declaration-merging': no_unsafe_declaration_merging_1.default,
'no-unsafe-enum-comparison': no_unsafe_enum_comparison_1.default,
'no-unsafe-function-type': no_unsafe_function_type_1.default,
'no-unsafe-member-access': no_unsafe_member_access_1.default,
'no-unsafe-return': no_unsafe_return_1.default,
'no-unsafe-unary-minus': no_unsafe_unary_minus_1.default,
'no-unused-expressions': no_unused_expressions_1.default,
'no-unused-vars': no_unused_vars_1.default,
'no-use-before-define': no_use_before_define_1.default,
'no-useless-constructor': no_useless_constructor_1.default,
'no-useless-empty-export': no_useless_empty_export_1.default,
'no-useless-template-literals': no_useless_template_literals_1.default,
'no-var-requires': no_var_requires_1.default,
'no-wrapper-object-types': no_wrapper_object_types_1.default,
'non-nullable-type-assertion-style': non_nullable_type_assertion_style_1.default,
'object-curly-spacing': object_curly_spacing_1.default,
'only-throw-error': only_throw_error_1.default,
'padding-line-between-statements': padding_line_between_statements_1.default,
'parameter-properties': parameter_properties_1.default,
'prefer-as-const': prefer_as_const_1.default,
'prefer-destructuring': prefer_destructuring_1.default,
'prefer-enum-initializers': prefer_enum_initializers_1.default,
'prefer-find': prefer_find_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-promise-reject-errors': prefer_promise_reject_errors_1.default,
'prefer-readonly': prefer_readonly_1.default,
'prefer-readonly-parameter-types': prefer_readonly_parameter_types_1.default,
'prefer-reduce-type-parameter': prefer_reduce_type_parameter_1.default,
'prefer-regexp-exec': prefer_regexp_exec_1.default,
'prefer-return-this-type': prefer_return_this_type_1.default,
'prefer-string-starts-ends-with': prefer_string_starts_ends_with_1.default,
'prefer-ts-expect-error': prefer_ts_expect_error_1.default,
'promise-function-async': promise_function_async_1.default,
quotes: quotes_1.default,
'require-array-sort-compare': require_array_sort_compare_1.default,
'require-await': require_await_1.default,
'restrict-plus-operands': restrict_plus_operands_1.default,
'restrict-template-expressions': restrict_template_expressions_1.default,
'return-await': return_await_1.default,
semi: semi_1.default,
'sort-type-constituents': sort_type_constituents_1.default,
'space-before-blocks': space_before_blocks_1.default,
'space-before-function-paren': space_before_function_paren_1.default,
'space-infix-ops': space_infix_ops_1.default,
'strict-boolean-expressions': strict_boolean_expressions_1.default,
'switch-exhaustiveness-check': switch_exhaustiveness_check_1.default,
'triple-slash-reference': triple_slash_reference_1.default,
'type-annotation-spacing': type_annotation_spacing_1.default,
typedef: typedef_1.default,
'unbound-method': unbound_method_1.default,
'unified-signatures': unified_signatures_1.default,
'use-unknown-in-catch-callback-variable': use_unknown_in_catch_callback_variable_1.default,
};
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,104 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('init-declarations');
exports.default = (0, util_1.createRule)({
name: 'init-declarations',
meta: {
type: 'suggestion',
docs: {
description: 'Require or disallow initialization in variable declarations',
extendsBaseRule: true,
},
hasSuggestions: baseRule.meta.hasSuggestions,
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
},
defaultOptions: ['always'],
create(context, [mode]) {
// Make a custom context to adjust the the loc of reports where the base
// rule's behavior is a bit too aggressive with TS-specific syntax (namely,
// type annotations).
function getBaseContextOverride() {
const reportOverride = descriptor => {
if ('node' in descriptor && descriptor.loc == null) {
const { node, ...rest } = descriptor;
// We only want to special case the report loc when reporting on
// variables declarations that are not initialized. Declarations that
// _are_ initialized get reported by the base rule due to a setting to
// prohibit initializing variables entirely, in which case underlining
// the whole node including the type annotation and initializer is
// appropriate.
if (node.type === utils_1.AST_NODE_TYPES.VariableDeclarator &&
node.init == null) {
context.report({
...rest,
loc: getReportLoc(node),
});
return;
}
}
context.report(descriptor);
};
// `return { ...context, report: reportOverride }` isn't safe because the
// `context` object has some getters that need to be preserved.
//
// `return new Proxy(context, ...)` doesn't work because `context` has
// non-configurable properties that throw when constructing a Proxy.
//
// So, we'll just use Proxy on a dummy object and use the `get` trap to
// proxy `context`'s properties.
return new Proxy({}, {
get: (target, prop, receiver) => prop === 'report'
? reportOverride
: Reflect.get(context, prop, receiver),
});
}
const rules = baseRule.create(getBaseContextOverride());
return {
'VariableDeclaration:exit'(node) {
if (mode === 'always') {
if (node.declare) {
return;
}
if (isAncestorNamespaceDeclared(node)) {
return;
}
}
rules['VariableDeclaration:exit'](node);
},
};
function isAncestorNamespaceDeclared(node) {
let ancestor = node.parent;
while (ancestor) {
if (ancestor.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
ancestor.declare) {
return true;
}
ancestor = ancestor.parent;
}
return false;
}
},
});
/**
* When reporting an uninitialized variable declarator, get the loc excluding
* the type annotation.
*/
function getReportLoc(node) {
const start = structuredClone(node.loc.start);
const end = {
line: node.loc.start.line,
// `if (id.type === AST_NODE_TYPES.Identifier)` is a condition for
// reporting in the base rule (as opposed to things like destructuring
// assignment), so the type assertion should always be valid.
column: node.loc.start.column + node.id.name.length,
};
return {
start,
end,
};
}
//# sourceMappingURL=init-declarations.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"init-declarations.js","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAM1D,kCAAqC;AACrC,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,mBAAmB,CAAC,CAAC;AAKxD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,6DAA6D;YAC/D,eAAe,EAAE,IAAI;SACtB;QACD,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,wEAAwE;QACxE,2EAA2E;QAC3E,qBAAqB;QACrB,SAAS,sBAAsB;YAC7B,MAAM,cAAc,GAA0B,UAAU,CAAC,EAAE;gBACzD,IAAI,MAAM,IAAI,UAAU,IAAI,UAAU,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;oBACnD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAC;oBACrC,gEAAgE;oBAChE,qEAAqE;oBACrE,sEAAsE;oBACtE,sEAAsE;oBACtE,kEAAkE;o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,IACE,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;oBACpD,QAAQ,CAAC,OAAO,EAChB,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;gBAED,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;YAC7B,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAS,YAAY,CACnB,IAAiC;IAEjC,MAAM,KAAK,GAAsB,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjE,MAAM,GAAG,GAAsB;QAC7B,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI;QACzB,kEAAkE;QAClE,sEAAsE;QACtE,6DAA6D;QAC7D,MAAM,EACJ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAI,IAAI,CAAC,EAA0B,CAAC,IAAI,CAAC,MAAM;KACvE,CAAC;IAEF,OAAO;QACL,KAAK;QACL,GAAG;KACJ,CAAC;AACJ,CAAC"}

View file

@ -1,320 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('key-spacing');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const baseSchema = Array.isArray(baseRule.meta.schema)
? baseRule.meta.schema[0]
: baseRule.meta.schema;
exports.default = (0, util_1.createRule)({
name: 'key-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/key-spacing'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing between property names and type annotations in types and interfaces',
extendsBaseRule: true,
},
fixable: 'whitespace',
hasSuggestions: baseRule.meta.hasSuggestions,
schema: [baseSchema],
messages: baseRule.meta.messages,
},
defaultOptions: [{}],
create(context, [options]) {
const baseRules = baseRule.create(context);
/**
* @returns the column of the position after converting all unicode characters in the line to 1 char length
*/
function adjustedColumn(position) {
const line = position.line - 1; // position.line is 1-indexed
return (0, util_1.getStringLength)(context.sourceCode.lines.at(line).slice(0, position.column));
}
/**
* Starting from the given a node (a property.key node here) looks forward
* until it finds the last token before a colon punctuator and returns it.
*/
function getLastTokenBeforeColon(node) {
const colonToken = context.sourceCode.getTokenAfter(node, util_1.isColonToken);
return context.sourceCode.getTokenBefore(colonToken);
}
function isKeyTypeNode(node) {
return ((node.type === utils_1.AST_NODE_TYPES.TSPropertySignature ||
node.type === utils_1.AST_NODE_TYPES.TSIndexSignature ||
node.type === utils_1.AST_NODE_TYPES.PropertyDefinition) &&
!!node.typeAnnotation);
}
function isApplicable(node) {
return (isKeyTypeNode(node) &&
node.typeAnnotation.loc.start.line === node.loc.end.line);
}
/**
* To handle index signatures, to get the whole text for the parameters
*/
function getKeyText(node) {
if (node.type !== utils_1.AST_NODE_TYPES.TSIndexSignature) {
return context.sourceCode.getText(node.key);
}
const code = context.sourceCode.getText(node);
return code.slice(0, context.sourceCode.getTokenAfter(node.parameters.at(-1), util_1.isClosingBracketToken).range[1] - node.range[0]);
}
/**
* To handle index signatures, be able to get the end position of the parameters
*/
function getKeyLocEnd(node) {
return getLastTokenBeforeColon(node.type !== utils_1.AST_NODE_TYPES.TSIndexSignature
? node.key
: node.parameters.at(-1)).loc.end;
}
function checkBeforeColon(node, expectedWhitespaceBeforeColon, mode) {
const { typeAnnotation } = node;
const colon = typeAnnotation.loc.start.column;
const keyEnd = getKeyLocEnd(node);
const difference = colon - keyEnd.column - expectedWhitespaceBeforeColon;
if (mode === 'strict' ? difference : difference < 0) {
context.report({
node,
messageId: difference > 0 ? 'extraKey' : 'missingKey',
fix: fixer => {
if (difference > 0) {
return fixer.removeRange([
typeAnnotation.range[0] - difference,
typeAnnotation.range[0],
]);
}
return fixer.insertTextBefore(typeAnnotation, ' '.repeat(-difference));
},
data: {
computed: '',
key: getKeyText(node),
},
});
}
}
function checkAfterColon(node, expectedWhitespaceAfterColon, mode) {
const { typeAnnotation } = node;
const colonToken = context.sourceCode.getFirstToken(typeAnnotation);
const typeStart = context.sourceCode.getTokenAfter(colonToken, {
includeComments: true,
}).loc.start.column;
const difference = typeStart -
colonToken.loc.start.column -
1 -
expectedWhitespaceAfterColon;
if (mode === 'strict' ? difference : difference < 0) {
context.report({
node,
messageId: difference > 0 ? 'extraValue' : 'missingValue',
fix: fixer => {
if (difference > 0) {
return fixer.removeRange([
colonToken.range[1],
colonToken.range[1] + difference,
]);
}
return fixer.insertTextAfter(colonToken, ' '.repeat(-difference));
},
data: {
computed: '',
key: getKeyText(node),
},
});
}
}
// adapted from https://github.com/eslint/eslint/blob/ba74253e8bd63e9e163bbee0540031be77e39253/lib/rules/key-spacing.js#L356
function continuesAlignGroup(lastMember, candidate) {
const groupEndLine = lastMember.loc.start.line;
const candidateValueStartLine = (isKeyTypeNode(candidate) ? candidate.typeAnnotation : candidate).loc.start.line;
if (candidateValueStartLine === groupEndLine) {
return false;
}
if (candidateValueStartLine - groupEndLine === 1) {
return true;
}
/*
* Check that the first comment is adjacent to the end of the group, the
* last comment is adjacent to the candidate property, and that successive
* comments are adjacent to each other.
*/
const leadingComments = context.sourceCode.getCommentsBefore(candidate);
if (leadingComments.length &&
leadingComments[0].loc.start.line - groupEndLine <= 1 &&
candidateValueStartLine - leadingComments.at(-1).loc.end.line <= 1) {
for (let i = 1; i < leadingComments.length; i++) {
if (leadingComments[i].loc.start.line -
leadingComments[i - 1].loc.end.line >
1) {
return false;
}
}
return true;
}
return false;
}
function checkAlignGroup(group) {
let alignColumn = 0;
const align = (typeof options.align === 'object'
? options.align.on
: typeof options.multiLine?.align === 'object'
? options.multiLine.align.on
: options.multiLine?.align ?? options.align) ?? 'colon';
const beforeColon = (typeof options.align === 'object'
? options.align.beforeColon
: options.multiLine
? typeof options.multiLine.align === 'object'
? options.multiLine.align.beforeColon
: options.multiLine.beforeColon
: options.beforeColon) ?? false;
const expectedWhitespaceBeforeColon = beforeColon ? 1 : 0;
const afterColon = (typeof options.align === 'object'
? options.align.afterColon
: options.multiLine
? typeof options.multiLine.align === 'object'
? options.multiLine.align.afterColon
: options.multiLine.afterColon
: options.afterColon) ?? true;
const expectedWhitespaceAfterColon = afterColon ? 1 : 0;
const mode = (typeof options.align === 'object'
? options.align.mode
: options.multiLine
? typeof options.multiLine.align === 'object'
? // same behavior as in original rule
options.multiLine.align.mode ?? options.multiLine.mode
: options.multiLine.mode
: options.mode) ?? 'strict';
for (const node of group) {
if (isKeyTypeNode(node)) {
const keyEnd = adjustedColumn(getKeyLocEnd(node));
alignColumn = Math.max(alignColumn, align === 'colon'
? keyEnd + expectedWhitespaceBeforeColon
: keyEnd +
':'.length +
expectedWhitespaceAfterColon +
expectedWhitespaceBeforeColon);
}
}
for (const node of group) {
if (!isApplicable(node)) {
continue;
}
const { typeAnnotation } = node;
const toCheck = align === 'colon' ? typeAnnotation : typeAnnotation.typeAnnotation;
const difference = adjustedColumn(toCheck.loc.start) - alignColumn;
if (difference) {
context.report({
node,
messageId: difference > 0
? align === 'colon'
? 'extraKey'
: 'extraValue'
: align === 'colon'
? 'missingKey'
: 'missingValue',
fix: fixer => {
if (difference > 0) {
return fixer.removeRange([
toCheck.range[0] - difference,
toCheck.range[0],
]);
}
return fixer.insertTextBefore(toCheck, ' '.repeat(-difference));
},
data: {
computed: '',
key: getKeyText(node),
},
});
}
if (align === 'colon') {
checkAfterColon(node, expectedWhitespaceAfterColon, mode);
}
else {
checkBeforeColon(node, expectedWhitespaceBeforeColon, mode);
}
}
}
function checkIndividualNode(node, { singleLine }) {
const beforeColon = (singleLine
? options.singleLine
? options.singleLine.beforeColon
: options.beforeColon
: options.multiLine
? options.multiLine.beforeColon
: options.beforeColon) ?? false;
const expectedWhitespaceBeforeColon = beforeColon ? 1 : 0;
const afterColon = (singleLine
? options.singleLine
? options.singleLine.afterColon
: options.afterColon
: options.multiLine
? options.multiLine.afterColon
: options.afterColon) ?? true;
const expectedWhitespaceAfterColon = afterColon ? 1 : 0;
const mode = (singleLine
? options.singleLine
? options.singleLine.mode
: options.mode
: options.multiLine
? options.multiLine.mode
: options.mode) ?? 'strict';
if (isApplicable(node)) {
checkBeforeColon(node, expectedWhitespaceBeforeColon, mode);
checkAfterColon(node, expectedWhitespaceAfterColon, mode);
}
}
function validateBody(body) {
const isSingleLine = body.loc.start.line === body.loc.end.line;
const members = body.type === utils_1.AST_NODE_TYPES.TSTypeLiteral ? body.members : body.body;
let alignGroups = [];
let unalignedElements = [];
if (options.align || options.multiLine?.align) {
let currentAlignGroup = [];
alignGroups.push(currentAlignGroup);
let prevNode = undefined;
for (const node of members) {
let prevAlignedNode = currentAlignGroup.at(-1);
if (prevAlignedNode !== prevNode) {
prevAlignedNode = undefined;
}
if (prevAlignedNode && continuesAlignGroup(prevAlignedNode, node)) {
currentAlignGroup.push(node);
}
else if (prevNode?.loc.start.line === node.loc.start.line) {
if (prevAlignedNode) {
// Here, prevNode === prevAlignedNode === currentAlignGroup.at(-1)
unalignedElements.push(prevAlignedNode);
currentAlignGroup.pop();
}
unalignedElements.push(node);
}
else {
currentAlignGroup = [node];
alignGroups.push(currentAlignGroup);
}
prevNode = node;
}
unalignedElements = unalignedElements.concat(...alignGroups.filter(group => group.length === 1));
alignGroups = alignGroups.filter(group => group.length >= 2);
}
else {
unalignedElements = members;
}
for (const group of alignGroups) {
checkAlignGroup(group);
}
for (const node of unalignedElements) {
checkIndividualNode(node, { singleLine: isSingleLine });
}
}
return {
...baseRules,
TSTypeLiteral: validateBody,
TSInterfaceBody: validateBody,
ClassBody: validateBody,
};
},
});
//# sourceMappingURL=key-spacing.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,93 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('keyword-spacing');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const baseSchema = Array.isArray(baseRule.meta.schema)
? baseRule.meta.schema[0]
: baseRule.meta.schema;
const schema = (0, util_1.deepMerge)(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- https://github.com/microsoft/TypeScript/issues/17002
baseSchema, {
properties: {
overrides: {
properties: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
type: baseSchema.properties.overrides.properties.import,
},
},
},
});
exports.default = (0, util_1.createRule)({
name: 'keyword-spacing',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/keyword-spacing'],
type: 'layout',
docs: {
description: 'Enforce consistent spacing before and after keywords',
extendsBaseRule: true,
},
fixable: 'whitespace',
hasSuggestions: baseRule.meta.hasSuggestions,
schema: [schema],
messages: baseRule.meta.messages,
},
defaultOptions: [{}],
create(context, [{ after, overrides }]) {
const baseRules = baseRule.create(context);
return {
...baseRules,
TSAsExpression(node) {
const asToken = (0, util_1.nullThrows)(context.sourceCode.getTokenAfter(node.expression, token => token.value === 'as'), util_1.NullThrowsReasons.MissingToken('as', node.type));
const oldTokenType = asToken.type;
// as is a contextual keyword, so it's always reported as an Identifier
// the rule looks for keyword tokens, so we temporarily override it
// we mutate it at the token level because the rule calls sourceCode.getFirstToken,
// so mutating a copy would not change the underlying copy returned by that method
asToken.type = utils_1.AST_TOKEN_TYPES.Keyword;
// use this selector just because it is just a call to `checkSpacingAroundFirstToken`
baseRules.DebuggerStatement(asToken);
// make sure to reset the type afterward so we don't permanently mutate the AST
asToken.type = oldTokenType;
},
'ImportDeclaration[importKind=type]'(node) {
const { type: typeOptionOverride = {} } = overrides ?? {};
const typeToken = context.sourceCode.getFirstToken(node, { skip: 1 });
const punctuatorToken = context.sourceCode.getTokenAfter(typeToken);
if (node.specifiers[0]?.type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier) {
return;
}
const spacesBetweenTypeAndPunctuator = punctuatorToken.range[0] - typeToken.range[1];
if ((typeOptionOverride.after ?? after) === true &&
spacesBetweenTypeAndPunctuator === 0) {
context.report({
loc: typeToken.loc,
messageId: 'expectedAfter',
data: { value: 'type' },
fix(fixer) {
return fixer.insertTextAfter(typeToken, ' ');
},
});
}
if ((typeOptionOverride.after ?? after) === false &&
spacesBetweenTypeAndPunctuator > 0) {
context.report({
loc: typeToken.loc,
messageId: 'unexpectedAfter',
data: { value: 'type' },
fix(fixer) {
return fixer.removeRange([
typeToken.range[1],
typeToken.range[1] + spacesBetweenTypeAndPunctuator,
]);
},
});
}
},
};
},
});
//# sourceMappingURL=keyword-spacing.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"keyword-spacing.js","sourceRoot":"","sources":["../../src/rules/keyword-spacing.ts"],"names":[],"mappings":";;AAEA,oDAA2E;AAO3E,kCAA+E;AAC/E,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,iBAAiB,CAAC,CAAC;AAKtD,mEAAmE;AACnE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IACpD,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;AACzB,MAAM,MAAM,GAAG,IAAA,gBAAS;AACtB,yHAAyH;AACzH,UAAU,EACV;IACE,UAAU,EAAE;QACV,SAAS,EAAE;YACT,UAAU,EAAE;gBACV,+GAA+G;gBAC/G,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM;aACxD;SACF;KACF;CACF,CACwB,CAAC;AAE5B,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,+BAA+B,CAAC;QAC7C,IAAI,EAAE,Q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;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,355 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('lines-around-comment');
const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
/**
* @returns an array with with any line numbers that are empty.
*/
function getEmptyLineNums(lines) {
const emptyLines = lines
.map((line, i) => ({
code: line.trim(),
num: i + 1,
}))
.filter(line => !line.code)
.map(line => line.num);
return emptyLines;
}
/**
* @returns an array with with any line numbers that contain comments.
*/
function getCommentLineNums(comments) {
const lines = [];
comments.forEach(token => {
const start = token.loc.start.line;
const end = token.loc.end.line;
lines.push(start, end);
});
return lines;
}
exports.default = (0, util_1.createRule)({
name: 'lines-around-comment',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/lines-around-comment'],
type: 'layout',
docs: {
description: 'Require empty lines around comments',
extendsBaseRule: true,
},
schema: [
{
type: 'object',
properties: {
beforeBlockComment: {
type: 'boolean',
default: true,
},
afterBlockComment: {
type: 'boolean',
default: false,
},
beforeLineComment: {
type: 'boolean',
default: false,
},
afterLineComment: {
type: 'boolean',
default: false,
},
allowBlockStart: {
type: 'boolean',
default: false,
},
allowBlockEnd: {
type: 'boolean',
default: false,
},
allowClassStart: {
type: 'boolean',
},
allowClassEnd: {
type: 'boolean',
},
allowObjectStart: {
type: 'boolean',
},
allowObjectEnd: {
type: 'boolean',
},
allowArrayStart: {
type: 'boolean',
},
allowArrayEnd: {
type: 'boolean',
},
allowInterfaceStart: {
type: 'boolean',
},
allowInterfaceEnd: {
type: 'boolean',
},
allowTypeStart: {
type: 'boolean',
},
allowTypeEnd: {
type: 'boolean',
},
allowEnumStart: {
type: 'boolean',
},
allowEnumEnd: {
type: 'boolean',
},
allowModuleStart: {
type: 'boolean',
},
allowModuleEnd: {
type: 'boolean',
},
ignorePattern: {
type: 'string',
},
applyDefaultIgnorePatterns: {
type: 'boolean',
},
},
additionalProperties: false,
},
],
fixable: baseRule.meta.fixable,
hasSuggestions: baseRule.meta.hasSuggestions,
messages: baseRule.meta.messages,
},
defaultOptions: [
{
beforeBlockComment: true,
},
],
create(context, [_options]) {
const options = _options;
const defaultIgnoreRegExp = COMMENTS_IGNORE_PATTERN;
const customIgnoreRegExp = new RegExp(options.ignorePattern ?? '', 'u');
const comments = context.sourceCode.getAllComments();
const lines = context.sourceCode.lines;
const commentLines = getCommentLineNums(comments);
const emptyLines = getEmptyLineNums(lines);
const commentAndEmptyLines = new Set(commentLines.concat(emptyLines));
/**
* @returns whether comments are on lines starting with or ending with code.
*/
function codeAroundComment(token) {
let currentToken = token;
do {
currentToken = context.sourceCode.getTokenBefore(currentToken, {
includeComments: true,
});
} while (currentToken && (0, util_1.isCommentToken)(currentToken));
if (currentToken && (0, util_1.isTokenOnSameLine)(currentToken, token)) {
return true;
}
currentToken = token;
do {
currentToken = context.sourceCode.getTokenAfter(currentToken, {
includeComments: true,
});
} while (currentToken && (0, util_1.isCommentToken)(currentToken));
if (currentToken && (0, util_1.isTokenOnSameLine)(token, currentToken)) {
return true;
}
return false;
}
/**
* @returns whether comments are inside a node type.
*/
function isParentNodeType(parent, nodeType) {
return parent.type === nodeType;
}
/**
* @returns the parent node that contains the given token.
*/
function getParentNodeOfToken(token) {
const node = context.sourceCode.getNodeByRangeIndex(token.range[0]);
return node;
}
/**
* @returns whether comments are at the parent start.
*/
function isCommentAtParentStart(token, nodeType) {
const parent = getParentNodeOfToken(token);
if (parent && isParentNodeType(parent, nodeType)) {
const parentStartNodeOrToken = parent;
return (token.loc.start.line - parentStartNodeOrToken.loc.start.line === 1);
}
return false;
}
/**
* @returns whether comments are at the parent end.
*/
function isCommentAtParentEnd(token, nodeType) {
const parent = getParentNodeOfToken(token);
return (!!parent &&
isParentNodeType(parent, nodeType) &&
parent.loc.end.line - token.loc.end.line === 1);
}
function isCommentAtInterfaceStart(token) {
return isCommentAtParentStart(token, utils_1.AST_NODE_TYPES.TSInterfaceBody);
}
function isCommentAtInterfaceEnd(token) {
return isCommentAtParentEnd(token, utils_1.AST_NODE_TYPES.TSInterfaceBody);
}
function isCommentAtTypeStart(token) {
return isCommentAtParentStart(token, utils_1.AST_NODE_TYPES.TSTypeLiteral);
}
function isCommentAtTypeEnd(token) {
return isCommentAtParentEnd(token, utils_1.AST_NODE_TYPES.TSTypeLiteral);
}
function isCommentAtEnumStart(token) {
return isCommentAtParentStart(token, utils_1.AST_NODE_TYPES.TSEnumDeclaration);
}
function isCommentAtEnumEnd(token) {
return isCommentAtParentEnd(token, utils_1.AST_NODE_TYPES.TSEnumDeclaration);
}
function isCommentAtModuleStart(token) {
return isCommentAtParentStart(token, utils_1.AST_NODE_TYPES.TSModuleBlock);
}
function isCommentAtModuleEnd(token) {
return isCommentAtParentEnd(token, utils_1.AST_NODE_TYPES.TSModuleBlock);
}
function isCommentNearTSConstruct(token) {
return (isCommentAtInterfaceStart(token) ||
isCommentAtInterfaceEnd(token) ||
isCommentAtTypeStart(token) ||
isCommentAtTypeEnd(token) ||
isCommentAtEnumStart(token) ||
isCommentAtEnumEnd(token) ||
isCommentAtModuleStart(token) ||
isCommentAtModuleEnd(token));
}
function checkForEmptyLine(token, { before, after }) {
// the base rule handles comments away from TS constructs blocks correctly, we skip those
if (!isCommentNearTSConstruct(token)) {
return;
}
if (options.applyDefaultIgnorePatterns !== false &&
defaultIgnoreRegExp.test(token.value)) {
return;
}
if (options.ignorePattern && customIgnoreRegExp.test(token.value)) {
return;
}
const prevLineNum = token.loc.start.line - 1;
const nextLineNum = token.loc.end.line + 1;
// we ignore all inline comments
if (codeAroundComment(token)) {
return;
}
const interfaceStartAllowed = Boolean(options.allowInterfaceStart) &&
isCommentAtInterfaceStart(token);
const interfaceEndAllowed = Boolean(options.allowInterfaceEnd) && isCommentAtInterfaceEnd(token);
const typeStartAllowed = Boolean(options.allowTypeStart) && isCommentAtTypeStart(token);
const typeEndAllowed = Boolean(options.allowTypeEnd) && isCommentAtTypeEnd(token);
const enumStartAllowed = Boolean(options.allowEnumStart) && isCommentAtEnumStart(token);
const enumEndAllowed = Boolean(options.allowEnumEnd) && isCommentAtEnumEnd(token);
const moduleStartAllowed = Boolean(options.allowModuleStart) && isCommentAtModuleStart(token);
const moduleEndAllowed = Boolean(options.allowModuleEnd) && isCommentAtModuleEnd(token);
const exceptionStartAllowed = interfaceStartAllowed ||
typeStartAllowed ||
enumStartAllowed ||
moduleStartAllowed;
const exceptionEndAllowed = interfaceEndAllowed ||
typeEndAllowed ||
enumEndAllowed ||
moduleEndAllowed;
const previousTokenOrComment = context.sourceCode.getTokenBefore(token, {
includeComments: true,
});
const nextTokenOrComment = context.sourceCode.getTokenAfter(token, {
includeComments: true,
});
// check for newline before
if (!exceptionStartAllowed &&
before &&
!commentAndEmptyLines.has(prevLineNum) &&
!((0, util_1.isCommentToken)(previousTokenOrComment) &&
(0, util_1.isTokenOnSameLine)(previousTokenOrComment, token))) {
const lineStart = token.range[0] - token.loc.start.column;
const range = [lineStart, lineStart];
context.report({
node: token,
messageId: 'before',
fix(fixer) {
return fixer.insertTextBeforeRange(range, '\n');
},
});
}
// check for newline after
if (!exceptionEndAllowed &&
after &&
!commentAndEmptyLines.has(nextLineNum) &&
!((0, util_1.isCommentToken)(nextTokenOrComment) &&
(0, util_1.isTokenOnSameLine)(token, nextTokenOrComment))) {
context.report({
node: token,
messageId: 'after',
fix(fixer) {
return fixer.insertTextAfter(token, '\n');
},
});
}
}
/**
* A custom report function for the baseRule to ignore false positive errors
* caused by TS-specific codes
*/
const customReport = descriptor => {
if ('node' in descriptor) {
if (descriptor.node.type === utils_1.AST_TOKEN_TYPES.Line ||
descriptor.node.type === utils_1.AST_TOKEN_TYPES.Block) {
if (isCommentNearTSConstruct(descriptor.node)) {
return;
}
}
}
return context.report(descriptor);
};
const customContext = { report: customReport };
// we can't directly proxy `context` because its `report` property is non-configurable
// and non-writable. So we proxy `customContext` and redirect all
// property access to the original context except for `report`
const proxiedContext = new Proxy(customContext, {
get(target, path, receiver) {
if (path !== 'report') {
return Reflect.get(context, path, receiver);
}
return Reflect.get(target, path, receiver);
},
});
const rules = baseRule.create(proxiedContext);
return {
Program() {
rules.Program();
comments.forEach(token => {
if (token.type === utils_1.AST_TOKEN_TYPES.Line) {
if (options.beforeLineComment || options.afterLineComment) {
checkForEmptyLine(token, {
after: options.afterLineComment,
before: options.beforeLineComment,
});
}
}
else if (options.beforeBlockComment || options.afterBlockComment) {
checkForEmptyLine(token, {
after: options.afterBlockComment,
before: options.beforeBlockComment,
});
}
});
},
};
},
});
//# sourceMappingURL=lines-around-comment.js.map

View file

@ -1,57 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('lines-between-class-members');
const schema = Object.values((0, util_1.deepMerge)({ ...baseRule.meta.schema }, {
1: {
properties: {
exceptAfterOverload: {
type: 'boolean',
default: true,
},
},
},
}));
exports.default = (0, util_1.createRule)({
name: 'lines-between-class-members',
meta: {
deprecated: true,
replacedBy: ['@stylistic/ts/lines-between-class-members'],
type: 'layout',
docs: {
description: 'Require or disallow an empty line between class members',
extendsBaseRule: true,
},
fixable: 'whitespace',
hasSuggestions: baseRule.meta.hasSuggestions,
schema,
messages: baseRule.meta.messages,
},
defaultOptions: [
'always',
{
exceptAfterOverload: true,
exceptAfterSingleLine: false,
},
],
create(context, [firstOption, secondOption]) {
const rules = baseRule.create(context);
const exceptAfterOverload = secondOption?.exceptAfterOverload && firstOption === 'always';
function isOverload(node) {
return ((node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
node.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
node.value.type === utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression);
}
return {
ClassBody(node) {
const body = exceptAfterOverload
? node.body.filter(node => !isOverload(node))
: node.body;
rules.ClassBody({ ...node, body });
},
};
},
});
//# sourceMappingURL=lines-between-class-members.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"lines-between-class-members.js","sourceRoot":"","sources":["../../src/rules/lines-between-class-members.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAO1D,kCAAgD;AAChD,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,6BAA6B,CAAC,CAAC;AAKlE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC1B,IAAA,gBAAS,EACP,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAC3B;IACE,CAAC,EAAE;QACD,UAAU,EAAE;YACV,mBAAmB,EAAE;gBACnB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,IAAI;aACd;SACF;KACF;CACF,CACF,CACe,CAAC;AAEnB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,2CAA2C,CAAC;QACzD,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,yDAAyD;YACtE,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM;QACN,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE;QACd,QAAQ;QACR;YACE,mBAAmB,EAAE,IAAI;YACzB,qBAAqB,EAAE,KAAK;SAC7B;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;QACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,mBAAmB,GACvB,YAAY,EAAE,mBAAmB,IAAI,WAAW,KAAK,QAAQ,CAAC;QAEhE,SAAS,UAAU,CAAC,IAAmB;YACrC,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,0BAA0B;gBACtD,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB,CAAC;gBAChD,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAc,CAAC,6BAA6B,CACjE,CAAC;QACJ,CAAC;QAED,OAAO;YACL,SAAS,CAAC,IAAI;gBACZ,MAAM,IAAI,GAAG,mBAAmB;oBAC9B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBAC7C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAEd,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YACrC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}

View file

@ -1,67 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('max-params');
exports.default = (0, util_1.createRule)({
name: 'max-params',
meta: {
type: 'suggestion',
docs: {
description: 'Enforce a maximum number of parameters in function definitions',
extendsBaseRule: true,
},
schema: [
{
type: 'object',
properties: {
maximum: {
type: 'integer',
minimum: 0,
},
max: {
type: 'integer',
minimum: 0,
},
countVoidThis: {
type: 'boolean',
},
},
additionalProperties: false,
},
],
messages: baseRule.meta.messages,
},
defaultOptions: [{ max: 3, countVoidThis: false }],
create(context, [{ countVoidThis }]) {
const baseRules = baseRule.create(context);
if (countVoidThis === true) {
return baseRules;
}
const removeVoidThisParam = (node) => {
if (node.params.length === 0 ||
node.params[0].type !== utils_1.AST_NODE_TYPES.Identifier ||
node.params[0].name !== 'this' ||
node.params[0].typeAnnotation?.typeAnnotation.type !==
utils_1.AST_NODE_TYPES.TSVoidKeyword) {
return node;
}
return {
...node,
params: node.params.slice(1),
};
};
const wrapListener = (listener) => {
return (node) => {
listener(removeVoidThisParam(node));
};
};
return {
ArrowFunctionExpression: wrapListener(baseRules.ArrowFunctionExpression),
FunctionDeclaration: wrapListener(baseRules.FunctionDeclaration),
FunctionExpression: wrapListener(baseRules.FunctionExpression),
};
},
});
//# sourceMappingURL=max-params.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"max-params.js","sourceRoot":"","sources":["../../src/rules/max-params.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAM1D,kCAAqC;AACrC,iEAA8D;AAS9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,YAAY,CAAC,CAAC;AAKjD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,gEAAgE;YAClE,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,CAAC;qBACX;oBACD,GAAG,EAAE;wBACH,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,CAAC;qBACX;oBACD,aAAa,EAAE;wBACb,IAAI,EAAE,SAAS;qBAChB;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAElD,MAAM,CAAC,OAAO,EAAE,CAAC,E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