feat: docker compose maybe
This commit is contained in:
21
node_modules/@typescript-eslint/eslint-plugin/LICENSE
generated
vendored
Normal file
21
node_modules/@typescript-eslint/eslint-plugin/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 typescript-eslint and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
12
node_modules/@typescript-eslint/eslint-plugin/README.md
generated
vendored
Normal file
12
node_modules/@typescript-eslint/eslint-plugin/README.md
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# `@typescript-eslint/eslint-plugin`
|
||||
|
||||
An ESLint plugin which provides lint rules for TypeScript codebases.
|
||||
|
||||
[](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
|
||||
[](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 -->
|
191
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js
generated
vendored
Normal file
191
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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',
|
||||
'block-spacing': 'off',
|
||||
'@typescript-eslint/block-spacing': 'error',
|
||||
'brace-style': 'off',
|
||||
'@typescript-eslint/brace-style': 'error',
|
||||
'@typescript-eslint/class-literal-property-style': 'error',
|
||||
'class-methods-use-this': 'off',
|
||||
'@typescript-eslint/class-methods-use-this': 'error',
|
||||
'comma-dangle': 'off',
|
||||
'@typescript-eslint/comma-dangle': 'error',
|
||||
'comma-spacing': 'off',
|
||||
'@typescript-eslint/comma-spacing': 'error',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'error',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'error',
|
||||
'@typescript-eslint/consistent-type-assertions': 'error',
|
||||
'@typescript-eslint/consistent-type-definitions': 'error',
|
||||
'@typescript-eslint/consistent-type-exports': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'default-param-last': 'off',
|
||||
'@typescript-eslint/default-param-last': 'error',
|
||||
'dot-notation': 'off',
|
||||
'@typescript-eslint/dot-notation': 'error',
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
'@typescript-eslint/explicit-member-accessibility': 'error',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
||||
'func-call-spacing': 'off',
|
||||
'@typescript-eslint/func-call-spacing': 'error',
|
||||
indent: 'off',
|
||||
'@typescript-eslint/indent': 'error',
|
||||
'init-declarations': 'off',
|
||||
'@typescript-eslint/init-declarations': 'error',
|
||||
'key-spacing': 'off',
|
||||
'@typescript-eslint/key-spacing': 'error',
|
||||
'keyword-spacing': 'off',
|
||||
'@typescript-eslint/keyword-spacing': 'error',
|
||||
'lines-around-comment': 'off',
|
||||
'@typescript-eslint/lines-around-comment': 'error',
|
||||
'lines-between-class-members': 'off',
|
||||
'@typescript-eslint/lines-between-class-members': 'error',
|
||||
'max-params': 'off',
|
||||
'@typescript-eslint/max-params': 'error',
|
||||
'@typescript-eslint/member-delimiter-style': 'error',
|
||||
'@typescript-eslint/member-ordering': 'error',
|
||||
'@typescript-eslint/method-signature-style': 'error',
|
||||
'@typescript-eslint/naming-convention': 'error',
|
||||
'no-array-constructor': 'off',
|
||||
'@typescript-eslint/no-array-constructor': 'error',
|
||||
'@typescript-eslint/no-base-to-string': 'error',
|
||||
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
|
||||
'@typescript-eslint/no-confusing-void-expression': 'error',
|
||||
'no-dupe-class-members': 'off',
|
||||
'@typescript-eslint/no-dupe-class-members': 'error',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'error',
|
||||
'@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-explicit-any': 'error',
|
||||
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
||||
'no-extra-parens': 'off',
|
||||
'@typescript-eslint/no-extra-parens': 'error',
|
||||
'no-extra-semi': 'off',
|
||||
'@typescript-eslint/no-extra-semi': 'error',
|
||||
'@typescript-eslint/no-extraneous-class': 'error',
|
||||
'@typescript-eslint/no-floating-promises': 'error',
|
||||
'@typescript-eslint/no-for-in-array': 'error',
|
||||
'no-implied-eval': 'off',
|
||||
'@typescript-eslint/no-implied-eval': 'error',
|
||||
'@typescript-eslint/no-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',
|
||||
'no-throw-literal': 'off',
|
||||
'@typescript-eslint/no-throw-literal': 'error',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
||||
'@typescript-eslint/no-unnecessary-condition': 'error',
|
||||
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
||||
'@typescript-eslint/no-unsafe-argument': 'error',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'error',
|
||||
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
|
||||
'@typescript-eslint/no-unsafe-enum-comparison': '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/non-nullable-type-assertion-style': 'error',
|
||||
'object-curly-spacing': 'off',
|
||||
'@typescript-eslint/object-curly-spacing': 'error',
|
||||
'padding-line-between-statements': 'off',
|
||||
'@typescript-eslint/padding-line-between-statements': 'error',
|
||||
'@typescript-eslint/parameter-properties': 'error',
|
||||
'@typescript-eslint/prefer-as-const': 'error',
|
||||
'@typescript-eslint/prefer-enum-initializers': 'error',
|
||||
'prefer-destructuring': 'off',
|
||||
'@typescript-eslint/prefer-destructuring': 'error',
|
||||
'@typescript-eslint/prefer-for-of': 'error',
|
||||
'@typescript-eslint/prefer-function-type': 'error',
|
||||
'@typescript-eslint/prefer-includes': 'error',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
||||
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
||||
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
||||
'@typescript-eslint/prefer-optional-chain': 'error',
|
||||
'@typescript-eslint/prefer-readonly': 'error',
|
||||
'@typescript-eslint/prefer-readonly-parameter-types': 'error',
|
||||
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
||||
'@typescript-eslint/prefer-regexp-exec': 'error',
|
||||
'@typescript-eslint/prefer-return-this-type': 'error',
|
||||
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
|
||||
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
||||
'@typescript-eslint/promise-function-async': 'error',
|
||||
quotes: 'off',
|
||||
'@typescript-eslint/quotes': 'error',
|
||||
'@typescript-eslint/require-array-sort-compare': 'error',
|
||||
'require-await': 'off',
|
||||
'@typescript-eslint/require-await': 'error',
|
||||
'@typescript-eslint/restrict-plus-operands': 'error',
|
||||
'@typescript-eslint/restrict-template-expressions': 'error',
|
||||
'no-return-await': 'off',
|
||||
'@typescript-eslint/return-await': 'error',
|
||||
semi: 'off',
|
||||
'@typescript-eslint/semi': 'error',
|
||||
'@typescript-eslint/sort-type-constituents': 'error',
|
||||
'space-before-blocks': 'off',
|
||||
'@typescript-eslint/space-before-blocks': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'@typescript-eslint/space-before-function-paren': 'error',
|
||||
'space-infix-ops': 'off',
|
||||
'@typescript-eslint/space-infix-ops': 'error',
|
||||
'@typescript-eslint/strict-boolean-expressions': 'error',
|
||||
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
||||
'@typescript-eslint/triple-slash-reference': 'error',
|
||||
'@typescript-eslint/type-annotation-spacing': 'error',
|
||||
'@typescript-eslint/typedef': 'error',
|
||||
'@typescript-eslint/unbound-method': 'error',
|
||||
'@typescript-eslint/unified-signatures': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=all.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/configs/all.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,aAAa,EAAE,KAAK;QACpB,gCAAgC,EAAE,OAAO;QACzC,iDAAiD,EAAE,OAAO;QAC1D,wBAAwB,EAAE,KAAK;QAC/B,2CAA2C,EAAE,OAAO;QACpD,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,oDAAoD,EAAE,OAAO;QAC7D,oDAAoD,EAAE,OAAO;QAC7D,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,4CAA4C,EAAE,OAAO;QACrD,4CAA4C,EAAE,OAAO;QACrD,oBAAoB,EAAE,KAAK;QAC3B,uCAAuC,EAAE,OAAO;QAChD,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,kDAAkD,EAAE,OAAO;QAC3D,kDAAkD,EAAE,OAAO;QAC3D,mDAAmD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A6B,EAAE,KAAK;QACpC,gDAAgD,EAAE,OAAO;QACzD,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,2CAA2C,EAAE,OAAO;QACpD,4CAA4C,EAAE,OAAO;QACrD,4BAA4B,EAAE,OAAO;QACrC,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;KACjD;CACF,CAAC"}
|
13
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js
generated
vendored
Normal file
13
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/configs
|
||||
//
|
||||
// For developers working in the typescript-eslint monorepo:
|
||||
// You can regenerate it using `yarn generate:configs`
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: { sourceType: 'module' },
|
||||
plugins: ['@typescript-eslint'],
|
||||
};
|
||||
//# sourceMappingURL=base.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/configs/base.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE;IACvC,OAAO,EAAE,CAAC,oBAAoB,CAAC;CAChC,CAAC"}
|
58
node_modules/@typescript-eslint/eslint-plugin/dist/configs/disable-type-checked.js
generated
vendored
Normal file
58
node_modules/@typescript-eslint/eslint-plugin/dist/configs/disable-type-checked.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/configs
|
||||
//
|
||||
// For developers working in the typescript-eslint monorepo:
|
||||
// You can regenerate it using `yarn generate:configs`
|
||||
module.exports = {
|
||||
parserOptions: { project: null, program: null },
|
||||
rules: {
|
||||
'@typescript-eslint/await-thenable': 'off',
|
||||
'@typescript-eslint/consistent-type-exports': 'off',
|
||||
'@typescript-eslint/dot-notation': 'off',
|
||||
'@typescript-eslint/naming-convention': '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-type-arguments': 'off',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': '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/non-nullable-type-assertion-style': 'off',
|
||||
'@typescript-eslint/prefer-includes': 'off',
|
||||
'@typescript-eslint/prefer-nullish-coalescing': 'off',
|
||||
'@typescript-eslint/prefer-optional-chain': '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',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=disable-type-checked.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/disable-type-checked.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/disable-type-checked.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"disable-type-checked.js","sourceRoot":"","sources":["../../src/configs/disable-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,iBAAS;IACP,aAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE;IAC/C,KAAK,EAAE;QACL,mCAAmC,EAAE,KAAK;QAC1C,4CAA4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/eslint-recommended.js
generated
vendored
Normal file
31
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.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)
|
||||
'no-new-symbol': '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.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"eslint-recommended.js","sourceRoot":"","sources":["../../src/configs/eslint-recommended.ts"],"names":[],"mappings":";AAKA,iBAAS;IACP,SAAS,EAAE;QACT;YACE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;YAC1C,KAAK,EAAE;gBACL,mBAAmB,EAAE,KAAK,EAAE,sBAAsB;gBAClD,eAAe,EAAE,KAAK,EAAE,WAAW;gBACnC,iBAAiB,EAAE,KAAK,EAAE,WAAW;gBACrC,cAAc,EAAE,KAAK,EAAE,WAAW;gBAClC,uBAAuB,EAAE,KAAK,EAAE,sBAAsB;gBACtD,cAAc,EAAE,KAAK,EAAE,WAAW;gBAClC,gBAAgB,EAAE,KAAK,EAAE,WAAW;gBACpC,kBAAkB,EAAE,KAAK,EAAE,sBAAsB;gBACjD,eAAe,EAAE,KAAK,EAAE,WAAW;gBACnC,cAAc,EAAE,KAAK,EAAE,WAAW;gBAClC,cAAc,EAAE,KAAK,EAAE,WAAW;gBAClC,kBAAkB,EAAE,KAAK,EAAE,WAAW;gBACtC,sBAAsB,EAAE,KAAK,EAAE,uBAAuB;gBACtD,UAAU,EAAE,KAAK,EAAE,sBAAsB;gBACzC,gBAAgB,EAAE,KAAK,EAAE,WAAW;gBACpC,oBAAoB,EAAE,KAAK,EAAE,iCAAiC;gBAC9D,QAAQ,EAAE,OAAO,EAAE,+DAA+D;gBAClF,cAAc,EAAE,OAAO,EAAE,sCAAsC;gBAC/D,oBAAoB,EAAE,OAAO,EAAE,yDAAyD;gBACxF,eAAe,EAAE,OAAO,EAAE,6DAA6D;aACxF;SACF;KACF;CACF,CAAC"}
|
54
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-type-checked.js
generated
vendored
Normal file
54
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-type-checked.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-type-checked.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended-type-checked.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"recommended-type-checked.js","sourceRoot":"","sources":["../../src/configs/recommended-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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;CACF,CAAC"}
|
33
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js
generated
vendored
Normal file
33
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/recommended.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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;CACF,CAAC"}
|
75
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict-type-checked.js
generated
vendored
Normal file
75
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict-type-checked.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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-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',
|
||||
'no-throw-literal': 'off',
|
||||
'@typescript-eslint/no-throw-literal': 'error',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
||||
'@typescript-eslint/no-unnecessary-condition': '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',
|
||||
'@typescript-eslint/prefer-as-const': 'error',
|
||||
'@typescript-eslint/prefer-includes': 'error',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'error',
|
||||
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
||||
'@typescript-eslint/prefer-return-this-type': 'error',
|
||||
'@typescript-eslint/prefer-ts-expect-error': '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',
|
||||
'@typescript-eslint/unified-signatures': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=strict-type-checked.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict-type-checked.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict-type-checked.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"strict-type-checked.js","sourceRoot":"","sources":["../../src/configs/strict-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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,iDAAiD,EAAE,OAAO;QAC1D,6CAA6C,EAAE,OAAO;QACtD,mDAAmD,EAAE,OAAO;QAC5D,sCAAsC,EAAE,OAAO;QAC/C,oCAAoC,EAAE,OAAO;QAC7C,gDAAgD,EAAE,OAAO;QACzD,wCAAwC,EAAE,OAAO;QACjD,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,yCAAyC,EAAE,OAAO;QAClD,sBAAsB,EAAE,KAAK;QA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
Normal file
43
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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-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/prefer-ts-expect-error': 'error',
|
||||
'@typescript-eslint/triple-slash-reference': 'error',
|
||||
'@typescript-eslint/unified-signatures': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=strict.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/configs/strict.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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,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,2CAA2C,EAAE,OAAO;QACpD,uCAAuC,EAAE,OAAO;KACjD;CACF,CAAC"}
|
35
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic-type-checked.js
generated
vendored
Normal file
35
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic-type-checked.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic-type-checked.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic-type-checked.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stylistic-type-checked.js","sourceRoot":"","sources":["../../src/configs/stylistic-type-checked.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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;CACF,CAAC"}
|
29
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic.js
generated
vendored
Normal file
29
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/linting/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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/configs/stylistic.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"stylistic.js","sourceRoot":"","sources":["../../src/configs/stylistic.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,sDAAsD;AAEtD,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;CACF,CAAC"}
|
33
node_modules/@typescript-eslint/eslint-plugin/dist/index.js
generated
vendored
Normal file
33
node_modules/@typescript-eslint/eslint-plugin/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"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 strict_1 = __importDefault(require("./configs/strict"));
|
||||
const strict_type_checked_1 = __importDefault(require("./configs/strict-type-checked"));
|
||||
const stylistic_1 = __importDefault(require("./configs/stylistic"));
|
||||
const stylistic_type_checked_1 = __importDefault(require("./configs/stylistic-type-checked"));
|
||||
const rules_1 = __importDefault(require("./rules"));
|
||||
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,
|
||||
strict: strict_1.default,
|
||||
'strict-type-checked': strict_type_checked_1.default,
|
||||
stylistic: stylistic_1.default,
|
||||
'stylistic-type-checked': stylistic_type_checked_1.default,
|
||||
},
|
||||
rules: rules_1.default,
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,wDAAgC;AAChC,0DAAkC;AAClC,0FAAgE;AAChE,sFAA6D;AAC7D,wEAAgD;AAChD,kGAAwE;AACxE,8DAAsC;AACtC,wFAA8D;AAC9D,oEAA4C;AAC5C,8FAAoE;AACpE,oDAA4B;AAE5B,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,MAAM,EAAN,gBAAM;QACN,qBAAqB,EAAE,6BAAiB;QACxC,SAAS,EAAT,mBAAS;QACT,wBAAwB,EAAE,gCAAoB;KAC/C;IACD,KAAK,EAAL,eAAK;CACN,CAAC"}
|
140
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
generated
vendored
Normal file
140
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(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) {
|
||||
const isStatic = 'static' in member && !!member.static;
|
||||
switch (member.type) {
|
||||
case utils_1.AST_NODE_TYPES.ExportDefaultDeclaration:
|
||||
case utils_1.AST_NODE_TYPES.ExportNamedDeclaration: {
|
||||
// export statements (e.g. export { a };)
|
||||
// have no declarations, so ignore them
|
||||
if (!member.declaration) {
|
||||
return null;
|
||||
}
|
||||
return getMemberMethod(member.declaration);
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSDeclareFunction:
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration: {
|
||||
const name = member.id?.name ?? null;
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
name,
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
type: util_1.MemberNameType.Normal,
|
||||
};
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
return {
|
||||
...(0, util_1.getNameFromMember)(member, sourceCode),
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return {
|
||||
name: 'call',
|
||||
static: isStatic,
|
||||
callSignature: true,
|
||||
type: util_1.MemberNameType.Normal,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return {
|
||||
name: 'new',
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
type: util_1.MemberNameType.Normal,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return {
|
||||
...(0, util_1.getNameFromMember)(member, sourceCode),
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isSameMethod(method1, method2) {
|
||||
return (!!method2 &&
|
||||
method1.name === method2.name &&
|
||||
method1.static === method2.static &&
|
||||
method1.callSignature === method2.callSignature &&
|
||||
method1.type === method2.type);
|
||||
}
|
||||
function getMembers(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.ClassBody:
|
||||
case utils_1.AST_NODE_TYPES.Program:
|
||||
case utils_1.AST_NODE_TYPES.TSModuleBlock:
|
||||
case utils_1.AST_NODE_TYPES.TSInterfaceBody:
|
||||
case utils_1.AST_NODE_TYPES.BlockStatement:
|
||||
return node.body;
|
||||
case utils_1.AST_NODE_TYPES.TSTypeLiteral:
|
||||
return node.members;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the body for overload methods.
|
||||
* @param {ASTNode} node the body to be inspected.
|
||||
*/
|
||||
function checkBodyForOverloadMethods(node) {
|
||||
const members = getMembers(node);
|
||||
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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"adjacent-overload-signatures.js","sourceRoot":"","sources":["../../src/rules/adjacent-overload-signatures.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAC1D,wEAAsE;AAEtE,kCAAwE;AAcxE,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;QACZ,MAAM,UAAU,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC,CAAC;QAS1C;;;;WAIG;QACH,SAAS,eAAe,CAAC,MAAqB;YAC5C,MAAM,QAAQ,GAAG,QAAQ,IAAI,MAAM,IAAI,CAAC,CAAC,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AAM,IAAI,IAAI,EAAE,CAAC;oBACnB,UAAU,GAAG,IAAI,CAAC;oBAClB,OAAO;gBACT,CAAC;gBAED,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAC/C,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CACjC,CAAC;gBACF,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC;oBACpD,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,MAAM;wBACZ,SAAS,EAAE,mBAAmB;wBAC9B,IAAI,EAAE;4BACJ,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE;yBACxD;qBACF,CAAC,CAAC;gBACL,CAAC;qBAAM,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;oBACxB,WAAW,CAAC,IAAI,CAAC,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"}
|
222
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js
generated
vendored
Normal file
222
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js
generated
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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.",
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const defaultOption = options.default;
|
||||
const readonlyOption = options.readonly ?? defaultOption;
|
||||
/**
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function getMessageType(node) {
|
||||
if (isSimpleType(node)) {
|
||||
return 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')) {
|
||||
return;
|
||||
}
|
||||
const isReadonlyArrayType = node.typeName.name === 'ReadonlyArray';
|
||||
const currentOption = isReadonlyArrayType
|
||||
? readonlyOption
|
||||
: defaultOption;
|
||||
if (currentOption === 'generic') {
|
||||
return;
|
||||
}
|
||||
const readonlyPrefix = isReadonlyArrayType ? 'readonly ' : '';
|
||||
const typeParams = node.typeArguments?.params;
|
||||
const messageId = currentOption === 'array'
|
||||
? 'errorStringArray'
|
||||
: 'errorStringArraySimple';
|
||||
if (!typeParams || typeParams.length === 0) {
|
||||
// Create an 'any' array
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix,
|
||||
type: 'any',
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(node, `${readonlyPrefix}any[]`);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeParams.length !== 1 ||
|
||||
(currentOption === 'array-simple' && !isSimpleType(typeParams[0]))) {
|
||||
return;
|
||||
}
|
||||
const type = typeParams[0];
|
||||
const typeParens = typeNeedsParentheses(type);
|
||||
const parentParens = readonlyPrefix &&
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.TSArrayType &&
|
||||
!(0, util_1.isParenthesized)(node.parent.elementType, sourceCode);
|
||||
const start = `${parentParens ? '(' : ''}${readonlyPrefix}${typeParens ? '(' : ''}`;
|
||||
const end = `${typeParens ? ')' : ''}[]${parentParens ? ')' : ''}`;
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix,
|
||||
type: getMessageType(type),
|
||||
},
|
||||
fix(fixer) {
|
||||
return [
|
||||
fixer.replaceTextRange([node.range[0], type.range[0]], start),
|
||||
fixer.replaceTextRange([type.range[1], node.range[1]], end),
|
||||
];
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=array-type.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
76
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js
generated
vendored
Normal file
76
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
"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 eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const awaitKeyword = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isAwaitKeyword), util_1.NullThrowsReasons.MissingToken('await', 'await expression'));
|
||||
return fixer.remove(awaitKeyword);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=await-thenable.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"await-thenable.js","sourceRoot":"","sources":["../../src/rules/await-thenable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,wEAAsE;AACtE,sDAAwC;AAExC,kCAQiB;AAEjB,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,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AO,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"}
|
156
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js
generated
vendored
Normal file
156
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultMinimumDescriptionLength = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
exports.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',
|
||||
},
|
||||
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: exports.defaultMinimumDescriptionLength,
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
'ts-expect-error': 'allow-with-description',
|
||||
'ts-ignore': true,
|
||||
'ts-nocheck': true,
|
||||
'ts-check': false,
|
||||
minimumDescriptionLength: exports.defaultMinimumDescriptionLength,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
/*
|
||||
The regex used are taken from the ones used in the official TypeScript repo -
|
||||
https://github.com/microsoft/TypeScript/blob/408c760fae66080104bc85c449282c2d207dfe8e/src/compiler/scanner.ts#L288-L296
|
||||
*/
|
||||
const commentDirectiveRegExSingleLine = /^\/*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
|
||||
const commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const descriptionFormats = new Map();
|
||||
for (const directive of [
|
||||
'ts-expect-error',
|
||||
'ts-ignore',
|
||||
'ts-nocheck',
|
||||
'ts-check',
|
||||
]) {
|
||||
const option = options[directive];
|
||||
if (typeof option === 'object' && option.descriptionFormat) {
|
||||
descriptionFormats.set(directive, new RegExp(option.descriptionFormat));
|
||||
}
|
||||
}
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.forEach(comment => {
|
||||
const regExp = comment.type === utils_1.AST_TOKEN_TYPES.Line
|
||||
? commentDirectiveRegExSingleLine
|
||||
: commentDirectiveRegExMultiLine;
|
||||
const match = regExp.exec(comment.value);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
const { directive, description } = match.groups;
|
||||
const fullDirective = `ts-${directive}`;
|
||||
const option = options[fullDirective];
|
||||
if (option === true) {
|
||||
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 = exports.defaultMinimumDescriptionLength, } = options;
|
||||
const format = descriptionFormats.get(fullDirective);
|
||||
if ((0, util_1.getStringLength)(description.trim()) < minimumDescriptionLength) {
|
||||
context.report({
|
||||
data: { directive, minimumDescriptionLength },
|
||||
node: comment,
|
||||
messageId: 'tsDirectiveCommentRequiresDescription',
|
||||
});
|
||||
}
|
||||
else if (format && !format.test(description)) {
|
||||
context.report({
|
||||
data: { directive, format: format.source },
|
||||
node: comment,
|
||||
messageId: 'tsDirectiveCommentDescriptionNotMatchPattern',
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-ts-comment.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ban-ts-comment.js","sourceRoot":"","sources":["../../src/rules/ban-ts-comment.ts"],"names":[],"mappings":";;;AAAA,oDAA0E;AAC1E,wEAAsE;AAEtE,kCAAsD;AAezC,QAAA,+BAA+B,GAAG,CAAC,CAAC;AASjD,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,aAAa;SAC3B;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;4BACD;gCACE,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,wBAAwB,CAAC;6BACjC;4BACD;gCACE,IAAI,EAAE,QAAQ;gCACd,oBAAoB,EAAE,KAAK;gCAC3B,UAAU,EAAE;oCACV,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iCACtC;6BACF;yBACF;qB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AoB;6BAChC,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;oBAED,IACE,MAAM,KAAK,wBAAwB;wBACnC,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,iBAAiB,CAAC,EACxD,CAAC;wBACD,MAAM,EACJ,wBAAwB,GAAG,uCAA+B,GAC3D,GAAG,OAAO,CAAC;wBACZ,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;wBACrD,IACE,IAAA,sBAAe,EAAC,WAAW,CAAC,IAAI,EAAE,CAAC,GAAG,wBAAwB,EAC9D,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"}
|
56
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js
generated
vendored
Normal file
56
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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 => {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.forEach(c => {
|
||||
if (ENABLE_DISABLE_REGEX.test(c.value)) {
|
||||
context.report({
|
||||
data: { text: toText(c.value, c.type) },
|
||||
node: c,
|
||||
messageId: 'commentDetected',
|
||||
fix(fixer) {
|
||||
const rangeStart = sourceCode.getIndexFromLoc({
|
||||
column: c.loc.start.column > 0 ? c.loc.start.column - 1 : 0,
|
||||
line: c.loc.start.line,
|
||||
});
|
||||
const rangeEnd = sourceCode.getIndexFromLoc({
|
||||
column: c.loc.end.column,
|
||||
line: c.loc.end.line,
|
||||
});
|
||||
return fixer.removeRange([rangeStart, rangeEnd + 1]);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-tslint-comment.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-tslint-comment.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ban-tslint-comment.js","sourceRoot":"","sources":["../../src/rules/ban-tslint-comment.ts"],"names":[],"mappings":";;AAAA,oDAA2D;AAC3D,wEAAsE;AAEtE,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;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,OAAO,CAAC,EAAE;QAChB,MAAM,UAAU,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC,CAAC;QAC1C,OAAO;YACL,OAAO;gBACL,MAAM,QAAQ,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;gBAC7C,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBACnB,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;wBACvC,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE;4BACvC,IAAI,EAAE,CAAC;4BACP,SAAS,EAAE,iBAAiB;4BAC5B,GAAG,CAAC,KAAK;gCACP,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,CAAC;oCAC5C,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;oCAC3D,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI;iCACvB,CAAC,CAAC;gCACH,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC;oCAC1C,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;oCACxB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;iCACrB,CAAC,CAAC;gCACH,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;4BACvD,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
240
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js
generated
vendored
Normal file
240
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js
generated
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TYPE_KEYWORDS = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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 = Object.assign({}, extendDefaults ? defaultTypes : {}, customTypes);
|
||||
const bannedTypes = new Map(Object.entries(types).map(([type, data]) => [removeSpaces(type), data]));
|
||||
function checkBannedTypes(typeNode, name = stringifyNode(typeNode, (0, eslint_utils_1.getSourceCode)(context))) {
|
||||
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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-types.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
138
node_modules/@typescript-eslint/eslint-plugin/dist/rules/block-spacing.js
generated
vendored
Normal file
138
node_modules/@typescript-eslint/eslint-plugin/dist/rules/block-spacing.js
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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 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) ||
|
||||
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 = sourceCode.getLastToken(node);
|
||||
const firstToken = sourceCode.getTokenAfter(openBrace, {
|
||||
includeComments: true,
|
||||
});
|
||||
const lastToken = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/block-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/block-spacing.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"block-spacing.js","sourceRoot":"","sources":["../../src/rules/block-spacing.ts"],"names":[],"mappings":";;AACA,oDAA2D;AAC3D,wEAAsE;AAMtE,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,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;QACjC,MAAM,UAAU,GAAG,IAAA,4BAAa,EAA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AAE,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"}
|
97
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js
generated
vendored
Normal file
97
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
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: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const rules = baseRule.create(context);
|
||||
/**
|
||||
* Checks a pair of curly brackets based on the user's config
|
||||
*/
|
||||
function validateCurlyPair(openingCurlyToken, closingCurlyToken) {
|
||||
if (allowSingleLine &&
|
||||
(0, util_1.isTokenOnSameLine)(openingCurlyToken, closingCurlyToken)) {
|
||||
return;
|
||||
}
|
||||
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurlyToken);
|
||||
const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurlyToken);
|
||||
const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurlyToken);
|
||||
if (!isAllmanStyle &&
|
||||
!(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'nextLineOpen',
|
||||
fix: fixer => {
|
||||
const textRange = [
|
||||
tokenBeforeOpeningCurly.range[1],
|
||||
openingCurlyToken.range[0],
|
||||
];
|
||||
const textBetween = sourceCode.text.slice(textRange[0], textRange[1]);
|
||||
if (textBetween.trim()) {
|
||||
return null;
|
||||
}
|
||||
return fixer.replaceTextRange(textRange, ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
if (isAllmanStyle &&
|
||||
(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'sameLineOpen',
|
||||
fix: fixer => fixer.insertTextBefore(openingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
if ((0, util_1.isTokenOnSameLine)(openingCurlyToken, tokenAfterOpeningCurly) &&
|
||||
tokenAfterOpeningCurly !== closingCurlyToken) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'blockSameLine',
|
||||
fix: fixer => fixer.insertTextAfter(openingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
if ((0, util_1.isTokenOnSameLine)(tokenBeforeClosingCurly, closingCurlyToken) &&
|
||||
tokenBeforeClosingCurly !== openingCurlyToken) {
|
||||
context.report({
|
||||
node: closingCurlyToken,
|
||||
messageId: 'singleLineClose',
|
||||
fix: fixer => fixer.insertTextBefore(closingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
...rules,
|
||||
'TSInterfaceBody, TSModuleBlock'(node) {
|
||||
const openingCurly = sourceCode.getFirstToken(node);
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
},
|
||||
TSEnumDeclaration(node) {
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
const openingCurly = sourceCode.getTokenBefore(node.members.length ? node.members[0] : closingCurly);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=brace-style.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/brace-style.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"brace-style.js","sourceRoot":"","sources":["../../src/rules/brace-style.ts"],"names":[],"mappings":";;AACA,wEAAsE;AAMtE,kCAAwD;AACxD,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,aAAa,CAAC,CAAC;AAKlD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AiB,CAAC;gBAC7D,uBAAuB,KAAK,iBAAiB,EAC7C,CAAC;gBACD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,iBAAiB;oBACvB,SAAS,EAAE,iBAAiB;oBAC5B,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,IAAI,CAAC;iBAC9D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,GAAG,KAAK;YACR,gCAAgC,CAC9B,IAAuD;gBAEvD,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAE,CAAC;gBACrD,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAE,CAAC;gBAEpD,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;YACD,iBAAiB,CAAC,IAAI;gBACpB,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAE,CAAC;gBACpD,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CACpD,CAAC;gBAEH,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
109
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js
generated
vendored
Normal file
109
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
const printNodeModifiers = (node, final) => `${node.accessibility ?? ''}${node.static ? ' static' : ''} ${final} `.trimStart();
|
||||
const isSupportedLiteral = (node) => {
|
||||
if (node.type === utils_1.AST_NODE_TYPES.Literal) {
|
||||
return true;
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression ||
|
||||
node.type === utils_1.AST_NODE_TYPES.TemplateLiteral) {
|
||||
return ('quasi' in node ? node.quasi.quasis : node.quasis).length === 1;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.default = (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]) {
|
||||
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;
|
||||
}
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'preferFieldStyle',
|
||||
suggest: [
|
||||
{
|
||||
messageId: 'preferFieldStyleSuggestion',
|
||||
fix(fixer) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const name = sourceCode.getText(node.key);
|
||||
let text = '';
|
||||
text += printNodeModifiers(node, 'readonly');
|
||||
text += node.computed ? `[${name}]` : name;
|
||||
text += ` = ${sourceCode.getText(argument)};`;
|
||||
return fixer.replaceText(node, text);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
}),
|
||||
...(style === 'getters' && {
|
||||
PropertyDefinition(node) {
|
||||
if (!node.readonly || node.declare) {
|
||||
return;
|
||||
}
|
||||
const { value } = node;
|
||||
if (!value || !isSupportedLiteral(value)) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'preferGetterStyle',
|
||||
suggest: [
|
||||
{
|
||||
messageId: 'preferGetterStyleSuggestion',
|
||||
fix(fixer) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const name = sourceCode.getText(node.key);
|
||||
let text = '';
|
||||
text += printNodeModifiers(node, 'get');
|
||||
text += node.computed ? `[${name}]` : name;
|
||||
text += `() { return ${sourceCode.getText(value)}; }`;
|
||||
return fixer.replaceText(node, text);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=class-literal-property-style.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"class-literal-property-style.js","sourceRoot":"","sources":["../../src/rules/class-literal-property-style.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAC1D,wEAAsE;AAEtE,kCAAqC;AAcrC,MAAM,kBAAkB,GAAG,CACzB,IAAuB,EACvB,KAAyB,EACjB,EAAE,CACV,GAAG,IAAI,CAAC,aAAa,IAAI,EAAE,GACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC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;gBACzB,kBAAkB,CAAC,IAAI;oBACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;wBACnC,OAAO;oBACT,CAAC;oBAED,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;oBAEvB,IAAI,CAAC,KAAK,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;wBACzC,OAAO;oBACT,CAAC;oBAED,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,GAAG;wBACd,SAAS,EAAE,mBAAmB;wBAC9B,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,6BAA6B;gCACxC,GAAG,CAAC,KAAK;oCACP,MAAM,UAAU,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC,CAAC;oCAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oCAE1C,IAAI,IAAI,GAAG,EAAE,CAAC;oCAEd,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oCACxC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;oCAC3C,IAAI,IAAI,eAAe,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;oCAEtD,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gCACvC,CAAC;6BACF;yBACF;qBACF,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
194
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-methods-use-this.js
generated
vendored
Normal file
194
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-methods-use-this.js
generated
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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,
|
||||
},
|
||||
fixable: 'code',
|
||||
hasSuggestions: 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: 'Ingore members marked with the `override` modifier',
|
||||
},
|
||||
ignoreClassesThatImplementAnInterface: {
|
||||
type: 'boolean',
|
||||
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;
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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 &&
|
||||
stackContext.class.implements.length)) {
|
||||
return;
|
||||
}
|
||||
if (isIncludedInstanceMethod(stackContext.member)) {
|
||||
context.report({
|
||||
node,
|
||||
loc: (0, util_1.getFunctionHeadLoc)(node, 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-methods-use-this.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-methods-use-this.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"class-methods-use-this.js","sourceRoot":"","sources":["../../src/rules/class-methods-use-this.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAC1D,wEAAsE;AAEtE,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,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,KAAK;QACrB,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,IAAI,EAAE,SAAS;wBACf,WAAW,EACT,2DAA2D;qBAC9D;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,+CAA+C;SAC7D;KACF;IACD,cAAc,EAAE;QACd;YACE,qBAAqB,EAAE,IAAI;YAC3B,aAAa,EAAE,EAAE;YACjB,qCAAqC,EAAE,KAAK;YAC5C,qBAAqB,EAAE,KAAK;SAC7B;KACF;IACD,MAAM,CACJ,OAAO,EACP,CACE,EACE,qBAAqB,EACrB,aAAa,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;oBACzC,SAAS,EAAE,aAAa;oBACxB,IAAI,EAAE;wBACJ,IAAI,EAAE,IAAA,8BAAuB,EAAC,IAAI,CAAC;qBACpC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,sDAAsD;YACtD,mBAAmB;gBACjB,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,0BAA0B;gBACxB,UAAU,EAAE,CAAC;YACf,CAAC;YAED,kBAAkB,CAAC,IAAI;gBACrB,aAAa,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,yBAAyB,CAAC,IAAI;gBAC5B,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,GAAG,CAAC,qBAAqB;gBACvB,CAAC,CAAC;oBACE,oDAAoD,CAClD,IAAsC;wBAEtC,aAAa,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC;oBACD,yDAAyD,CACvD,IAAsC;wBAEtC,YAAY,CAAC,IAAI,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"}
|
164
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js
generated
vendored
Normal file
164
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(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 && sourceCode.getTokenAfter(last);
|
||||
return trailing;
|
||||
}
|
||||
function isMultiline(node) {
|
||||
const last = getLastItem(node);
|
||||
const lastToken = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-dangle.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"comma-dangle.js","sourceRoot":"","sources":["../../src/rules/comma-dangle.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAC1D,wEAAsE;AAMtE,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,O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AAC,QAAQ,CAAC,EAAE,CAAC;gBAChD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,SAAS;oBACpB,GAAG,CAAC,KAAK;wBACP,OAAO,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;oBAC1C,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,SAAS,qBAAqB,CAAC,IAAmB;YAChD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,WAAW,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAED,SAAS,qBAAqB,CAAC,IAAmB;YAChD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,UAAU,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OAAO;YACL,GAAG,KAAK;YACR,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"}
|
150
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js
generated
vendored
Normal file
150
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js
generated
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'comma-spacing',
|
||||
meta: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const tokensAndComments = sourceCode.tokensAndComments;
|
||||
const ignoredTokens = new Set();
|
||||
/**
|
||||
* Adds null elements of the ArrayExpression or ArrayPattern node to the ignore list
|
||||
* @param node node to evaluate
|
||||
*/
|
||||
function addNullElementsToIgnoreList(node) {
|
||||
let previousToken = sourceCode.getFirstToken(node);
|
||||
for (const element of node.elements) {
|
||||
let token;
|
||||
if (element == null) {
|
||||
token = sourceCode.getTokenAfter(previousToken);
|
||||
if (token && (0, util_1.isCommaToken)(token)) {
|
||||
ignoredTokens.add(token);
|
||||
}
|
||||
}
|
||||
else {
|
||||
token = sourceCode.getTokenAfter(element);
|
||||
}
|
||||
previousToken = token;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds type parameters trailing comma token to the ignore list
|
||||
* @param node node to evaluate
|
||||
*/
|
||||
function addTypeParametersTrailingCommaToIgnoreList(node) {
|
||||
const paramLength = node.params.length;
|
||||
if (paramLength) {
|
||||
const param = node.params[paramLength - 1];
|
||||
const afterToken = sourceCode.getTokenAfter(param);
|
||||
if (afterToken && (0, util_1.isCommaToken)(afterToken)) {
|
||||
ignoredTokens.add(afterToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates the spacing around a comma token.
|
||||
* @param commaToken The token representing the comma
|
||||
* @param prevToken The last token before the comma
|
||||
* @param nextToken The first token after the comma
|
||||
*/
|
||||
function validateCommaSpacing(commaToken, prevToken, nextToken) {
|
||||
if (prevToken &&
|
||||
(0, util_1.isTokenOnSameLine)(prevToken, commaToken) &&
|
||||
// eslint-disable-next-line deprecation/deprecation -- TODO - switch once our min ESLint version is 6.7.0
|
||||
spaceBefore !== sourceCode.isSpaceBetweenTokens(prevToken, commaToken)) {
|
||||
context.report({
|
||||
node: commaToken,
|
||||
data: {
|
||||
loc: 'before',
|
||||
},
|
||||
messageId: spaceBefore ? 'missing' : 'unexpected',
|
||||
fix: fixer => spaceBefore
|
||||
? fixer.insertTextBefore(commaToken, ' ')
|
||||
: fixer.replaceTextRange([prevToken.range[1], commaToken.range[0]], ''),
|
||||
});
|
||||
}
|
||||
if (nextToken && (0, util_1.isClosingParenToken)(nextToken)) {
|
||||
return;
|
||||
}
|
||||
if (spaceAfter &&
|
||||
nextToken &&
|
||||
((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) &&
|
||||
// eslint-disable-next-line deprecation/deprecation -- TODO - switch once our min ESLint version is 6.7.0
|
||||
spaceAfter !== sourceCode.isSpaceBetweenTokens(commaToken, nextToken)) {
|
||||
context.report({
|
||||
node: commaToken,
|
||||
data: {
|
||||
loc: 'after',
|
||||
},
|
||||
messageId: spaceAfter ? 'missing' : 'unexpected',
|
||||
fix: fixer => spaceAfter
|
||||
? fixer.insertTextAfter(commaToken, ' ')
|
||||
: fixer.replaceTextRange([commaToken.range[1], nextToken.range[0]], ''),
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
TSTypeParameterDeclaration: addTypeParametersTrailingCommaToIgnoreList,
|
||||
ArrayExpression: addNullElementsToIgnoreList,
|
||||
ArrayPattern: addNullElementsToIgnoreList,
|
||||
'Program:exit'() {
|
||||
tokensAndComments.forEach((token, i) => {
|
||||
if (!(0, util_1.isCommaToken)(token)) {
|
||||
return;
|
||||
}
|
||||
const prevToken = tokensAndComments[i - 1];
|
||||
const nextToken = tokensAndComments.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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"comma-spacing.js","sourceRoot":"","sources":["../../src/rules/comma-spacing.ts"],"names":[],"mappings":";;AACA,oDAA2D;AAC3D,wEAAsE;AAEtE,kCAOiB;AAUjB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,oDAAoD;YACjE,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;Q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,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"}
|
109
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js
generated
vendored
Normal file
109
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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]) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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 = sourceCode.getText(callee) + 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 sourceCode.getTokenAfter(node.key);
|
||||
}
|
||||
return [
|
||||
fixer.remove(typeArguments),
|
||||
fixer.insertTextAfter(getIDToAttachAnnotation(), ': ' + typeAnnotation),
|
||||
];
|
||||
},
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (lhs?.typeArguments && !rhs.typeArguments) {
|
||||
const hasParens = sourceCode.getTokenAfter(rhs.callee)?.value === '(';
|
||||
const extraComments = new Set(sourceCode.getCommentsInside(lhs.parent));
|
||||
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, sourceCode.getText(comment));
|
||||
}
|
||||
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(lhs.typeArguments));
|
||||
if (!hasParens) {
|
||||
yield fixer.insertTextAfter(rhs.callee, '()');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-generic-constructors.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-generic-constructors.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-generic-constructors.js","sourceRoot":"","sources":["../../src/rules/consistent-generic-constructors.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAC1D,wEAAsE;AAEtE,kCAAqC;AAKrC,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,wGAAwG;YAC1G,WAAW,EAAE,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,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AC,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;oBACzC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,mBAAmB;wBAC9B,CAAC,GAAG,CAAC,KAAK;4BACR,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;4BAC/B,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;gCACpC,MAAM,KAAK,CAAC,eAAe,CACzB,GAAG,CAAC,MAAM,EACV,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAC5B,CAAC;4BACJ,CAAC;4BACD,MAAM,KAAK,CAAC,eAAe,CACzB,GAAG,CAAC,MAAM,EACV,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CACtC,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"}
|
128
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js
generated
vendored
Normal file
128
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js
generated
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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]) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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 = (0, eslint_utils_1.getScope)(context);
|
||||
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 = sourceCode.getText(keyType.typeAnnotation);
|
||||
const value = sourceCode.getText(valueType.typeAnnotation);
|
||||
const record = member.readonly
|
||||
? `Readonly<Record<${key}, ${value}>>`
|
||||
: `Record<${key}, ${value}>`;
|
||||
return fixer.replaceText(node, `${prefix}${record}${postfix}`);
|
||||
}
|
||||
: null,
|
||||
});
|
||||
}
|
||||
return {
|
||||
...(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 = sourceCode.getText(params[0]);
|
||||
const type = sourceCode.getText(params[1]);
|
||||
return fixer.replaceText(node, `{ [key: ${key}]: ${type} }`);
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
...(mode === 'record' && {
|
||||
TSTypeLiteral(node) {
|
||||
const parent = findParentDeclaration(node);
|
||||
checkMembers(node.members, node, parent?.id, '', '');
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
let genericTypes = '';
|
||||
if (node.typeParameters?.params.length) {
|
||||
genericTypes = `<${node.typeParameters.params
|
||||
.map(p => 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-indexed-object-style.js","sourceR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,sBAAsB,CAAC,IAAI;oBACzB,IAAI,YAAY,GAAG,EAAE,CAAC;oBAEtB,IAAI,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;wBACvC,YAAY,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM;6BAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;6BAC/B,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"}
|
222
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js
generated
vendored
Normal file
222
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js
generated
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
"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 eslint_utils_1 = require("@typescript-eslint/utils/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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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 getTextWithParentheses(node) {
|
||||
// Capture parentheses before and after the node
|
||||
let beforeCount = 0;
|
||||
let afterCount = 0;
|
||||
if ((0, util_1.isParenthesized)(node, sourceCode)) {
|
||||
const bodyOpeningParen = sourceCode.getTokenBefore(node, util_1.isOpeningParenToken);
|
||||
const bodyClosingParen = sourceCode.getTokenAfter(node, util_1.isClosingParenToken);
|
||||
beforeCount = node.range[0] - bodyOpeningParen.range[0];
|
||||
afterCount = bodyClosingParen.range[1] - node.range[1];
|
||||
}
|
||||
return sourceCode.getText(node, beforeCount, afterCount);
|
||||
}
|
||||
function reportIncorrectAssertionType(node) {
|
||||
const messageId = options.assertionStyle;
|
||||
// If this node is `as const`, then don't report an error.
|
||||
if (isConst(node.typeAnnotation) && messageId === 'never') {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: messageId !== 'never'
|
||||
? { cast: sourceCode.getText(node.typeAnnotation) }
|
||||
: {},
|
||||
fix: messageId === 'as'
|
||||
? (fixer) => {
|
||||
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
||||
/**
|
||||
* AsExpression has lower precedence than TypeAssertionExpression,
|
||||
* so we don't need to wrap expression and typeAnnotation in parens.
|
||||
*/
|
||||
const expressionCode = sourceCode.getText(node.expression);
|
||||
const typeAnnotationCode = 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 text = `${expressionCode} as ${typeAnnotationCode}`;
|
||||
return fixer.replaceText(node, (0, util_1.isParenthesized)(node, 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)) {
|
||||
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: sourceCode.getText(node.typeAnnotation) },
|
||||
fix: fixer => [
|
||||
fixer.insertTextAfter(parent.id, `: ${sourceCode.getText(node.typeAnnotation)}`),
|
||||
fixer.replaceText(node, getTextWithParentheses(node.expression)),
|
||||
],
|
||||
});
|
||||
}
|
||||
suggest.push({
|
||||
messageId: 'replaceObjectTypeAssertionWithSatisfies',
|
||||
data: { cast: sourceCode.getText(node.typeAnnotation) },
|
||||
fix: fixer => [
|
||||
fixer.replaceText(node, getTextWithParentheses(node.expression)),
|
||||
fixer.insertTextAfter(node, ` satisfies ${(0, eslint_utils_1.getSourceCode)(context).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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-assertions.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
98
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js
generated
vendored
Normal file
98
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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]) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
/**
|
||||
* Iterates from the highest parent to the currently traversed node
|
||||
* to determine whether any node in tree is globally declared module declaration
|
||||
*/
|
||||
function isCurrentlyTraversedNodeWithinModuleDeclaration() {
|
||||
return (0, eslint_utils_1.getAncestors)(context).some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
|
||||
node.declare &&
|
||||
node.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 = sourceCode.getTokenBefore(node.id);
|
||||
if (firstToken) {
|
||||
fixes.push(fixer.replaceText(firstToken, 'interface'));
|
||||
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.typeAnnotation.range[0]], ' '));
|
||||
}
|
||||
const afterToken = sourceCode.getTokenAfter(node.typeAnnotation);
|
||||
if (afterToken &&
|
||||
afterToken.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
|
||||
afterToken.value === ';') {
|
||||
fixes.push(fixer.remove(afterToken));
|
||||
}
|
||||
return fixes;
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
...(option === 'type' && {
|
||||
TSInterfaceDeclaration(node) {
|
||||
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration()
|
||||
? null
|
||||
: (fixer) => {
|
||||
const typeNode = node.typeParameters ?? node.id;
|
||||
const fixes = [];
|
||||
const firstToken = sourceCode.getTokenBefore(node.id);
|
||||
if (firstToken) {
|
||||
fixes.push(fixer.replaceText(firstToken, 'type'));
|
||||
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.body.range[0]], ' = '));
|
||||
}
|
||||
node.extends.forEach(heritage => {
|
||||
const typeIdentifier = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-definitions.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"consistent-type-definitions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-definitions.ts"],"names":[],"mappings":";;AACA,oDAA2E;AAC3E,wEAG+C;AAE/C,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;YAC5D,iBAAiB,EAAE,yCAAyC;SAC7D;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;aAC5B;SACF;QACD,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,CAAC,WAAW,CAAC;IAC7B,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;QACtB,MAAM,UAAU,GAAG,IAAA,4BAAa,EAAC,OAAO,CAAC,CAAC;QAE1C;;;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AC,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"}
|
244
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js
generated
vendored
Normal file
244
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js
generated
vendored
Normal file
@ -0,0 +1,244 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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';
|
||||
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, sourceCode, report.node);
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
// We have both type and value violations.
|
||||
const allExportNames = report.typeBasedSpecifiers.map(specifier => `${specifier.local.name}`);
|
||||
if (allExportNames.length === 1) {
|
||||
const exportNames = allExportNames[0];
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'singleExportIsType',
|
||||
data: { exportNames },
|
||||
*fix(fixer) {
|
||||
if (fixMixedExportsWithInlineTypeSpecifier) {
|
||||
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
|
||||
}
|
||||
else {
|
||||
yield* fixSeparateNamedExports(fixer, sourceCode, report);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
const exportNames = (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, 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
631
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js
generated
vendored
Normal file
631
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js
generated
vendored
Normal file
@ -0,0 +1,631 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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 types.',
|
||||
aImportIsOnlyTypes: 'Import {{typeImports}} is only used as types.',
|
||||
someImportsInDecoMeta: 'Type imports {{typeImports}} are used by decorator metadata.',
|
||||
aImportInDecoMeta: 'Type import {{typeImports}} is used by decorator metadata.',
|
||||
valueOverType: 'Use an `import` instead of an `import type`.',
|
||||
noImportTypeAnnotations: '`import()` type annotations are forbidden.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
prefer: {
|
||||
type: 'string',
|
||||
enum: ['type-imports', 'no-type-imports'],
|
||||
},
|
||||
disallowTypeAnnotations: {
|
||||
type: 'boolean',
|
||||
},
|
||||
fixStyle: {
|
||||
type: 'string',
|
||||
enum: ['separate-type-imports', 'inline-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 fixStyle = option.fixStyle ?? 'separate-type-imports';
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const sourceImportsMap = {};
|
||||
return {
|
||||
...(prefer === 'type-imports'
|
||||
? {
|
||||
// prefer type imports
|
||||
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.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] = (0, eslint_utils_1.getDeclaredVariables)(context, 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;
|
||||
*/
|
||||
if (ref.identifier.parent.type ===
|
||||
utils_1.AST_NODE_TYPES.ExportSpecifier ||
|
||||
ref.identifier.parent.type ===
|
||||
utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
||||
if (ref.isValueReference && ref.isTypeReference) {
|
||||
return node.importKind === 'type';
|
||||
}
|
||||
}
|
||||
if (ref.isValueReference) {
|
||||
let parent = ref.identifier.parent;
|
||||
let child = ref.identifier;
|
||||
while (parent) {
|
||||
switch (parent.type) {
|
||||
// CASE 1:
|
||||
// `type T = typeof foo` will create a value reference because "foo" must be a value type
|
||||
// however this value reference is safe to use with type-only imports
|
||||
case utils_1.AST_NODE_TYPES.TSTypeQuery:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
||||
// TSTypeQuery must have a TSESTree.EntityName as its child, so we can filter here and break early
|
||||
if (parent.left !== child) {
|
||||
return false;
|
||||
}
|
||||
child = parent;
|
||||
parent = parent.parent;
|
||||
continue;
|
||||
// END CASE 1
|
||||
//////////////
|
||||
// CASE 2:
|
||||
// `type T = { [foo]: string }` will create a value reference because "foo" must be a value type
|
||||
// however this value reference is safe to use with type-only imports.
|
||||
// Also this is represented as a non-type AST - hence it uses MemberExpression
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
return parent.key === child;
|
||||
case utils_1.AST_NODE_TYPES.MemberExpression:
|
||||
if (parent.object !== child) {
|
||||
return false;
|
||||
}
|
||||
child = parent;
|
||||
parent = parent.parent;
|
||||
continue;
|
||||
// END CASE 2
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ref.isTypeReference;
|
||||
});
|
||||
if (onlyHasTypeReferences) {
|
||||
typeSpecifiers.push(specifier);
|
||||
}
|
||||
else {
|
||||
valueSpecifiers.push(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((node.importKind === 'value' && typeSpecifiers.length) ||
|
||||
(node.importKind === 'type' && valueSpecifiers.length)) {
|
||||
sourceImports.reportValueImports.push({
|
||||
node,
|
||||
typeSpecifiers,
|
||||
valueSpecifiers,
|
||||
unusedSpecifiers,
|
||||
inlineTypeSpecifiers,
|
||||
});
|
||||
}
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const sourceImports of Object.values(sourceImportsMap)) {
|
||||
if (sourceImports.reportValueImports.length === 0) {
|
||||
// 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
|
||||
* ```
|
||||
* 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 {
|
||||
const isTypeImport = report.node.importKind === 'type';
|
||||
// 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 = (isTypeImport
|
||||
? report.valueSpecifiers // import type { A } from 'roo'; // WHERE A is used in value position
|
||||
: report.typeSpecifiers) // import { A, B } from 'roo'; // WHERE A is used in type position and B is in value position
|
||||
.map(specifier => `"${specifier.local.name}"`);
|
||||
const message = (() => {
|
||||
const typeImports = (0, util_1.formatWordList)(importNames);
|
||||
if (importNames.length === 1) {
|
||||
if (isTypeImport) {
|
||||
return {
|
||||
messageId: 'aImportInDecoMeta',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
return {
|
||||
messageId: 'aImportIsOnlyTypes',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
if (isTypeImport) {
|
||||
return {
|
||||
messageId: 'someImportsInDecoMeta',
|
||||
data: { typeImports }, // typeImports are all the value specifiers that are in the type position
|
||||
};
|
||||
}
|
||||
return {
|
||||
messageId: 'someImportsAreOnlyTypes',
|
||||
data: { typeImports }, // typeImports are all the type specifiers in the value position
|
||||
};
|
||||
})();
|
||||
context.report({
|
||||
node: report.node,
|
||||
...message,
|
||||
*fix(fixer) {
|
||||
if (isTypeImport) {
|
||||
// take all the valueSpecifiers and put them on a new line
|
||||
yield* fixToValueImportDeclaration(fixer, report, sourceImports);
|
||||
}
|
||||
else {
|
||||
// take all the typeSpecifiers and put them on a new line
|
||||
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
: {
|
||||
// prefer no type imports
|
||||
'ImportDeclaration[importKind = "type"]'(node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'valueOverType',
|
||||
fix(fixer) {
|
||||
return fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
},
|
||||
});
|
||||
},
|
||||
'ImportSpecifier[importKind = "type"]'(node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'valueOverType',
|
||||
fix(fixer) {
|
||||
return fixRemoveTypeSpecifierFromImportSpecifier(fixer, node);
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
...(disallowTypeAnnotations
|
||||
? {
|
||||
// disallow `import()` type
|
||||
TSImportType(node) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'noImportTypeAnnotations',
|
||||
});
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
function classifySpecifier(node) {
|
||||
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)(sourceCode.getTokenBefore(subsetNamedSpecifiers[0], util_1.isOpeningBraceToken), util_1.NullThrowsReasons.MissingToken('{', node.type));
|
||||
const commaToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(openingBraceToken, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
|
||||
const closingBraceToken = (0, util_1.nullThrows)(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(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(sourceCode.text.slice(...textRange));
|
||||
}
|
||||
}
|
||||
return {
|
||||
typeNamedSpecifiersText: typeNamedSpecifiersTexts.join(','),
|
||||
removeTypeNamedSpecifiers,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns ranges for fixing named specifier.
|
||||
*/
|
||||
function getNamedSpecifierRanges(namedSpecifierGroup, allNamedSpecifiers) {
|
||||
const first = namedSpecifierGroup[0];
|
||||
const last = namedSpecifierGroup[namedSpecifierGroup.length - 1];
|
||||
const removeRange = [first.range[0], last.range[1]];
|
||||
const textRange = [...removeRange];
|
||||
const before = sourceCode.getTokenBefore(first);
|
||||
textRange[0] = before.range[1];
|
||||
if ((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 = sourceCode.getTokenAfter(last);
|
||||
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)(sourceCode.getFirstTokenBetween(sourceCode.getFirstToken(target), target.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', target.type));
|
||||
const before = sourceCode.getTokenBefore(closingBraceToken);
|
||||
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 = 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
|
||||
if (fixStyle === 'inline-type-imports') {
|
||||
yield fixer.insertTextBefore(node, `import {${typeNamedSpecifiers
|
||||
.map(spec => {
|
||||
const insertText = sourceCode.text.slice(...spec.range);
|
||||
return `type ${insertText}`;
|
||||
})
|
||||
.join(', ')}} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
else {
|
||||
yield fixer.insertTextBefore(node, `import type {${fixesNamedSpecifiers.typeNamedSpecifiersText}} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
}
|
||||
}
|
||||
const fixesRemoveTypeNamespaceSpecifier = [];
|
||||
if (namespaceSpecifier &&
|
||||
report.typeSpecifiers.includes(namespaceSpecifier)) {
|
||||
// import Foo, * as Type from 'foo'
|
||||
// import DefType, * as Type from 'foo'
|
||||
// import DefType, * as Type from 'foo'
|
||||
const commaToken = (0, util_1.nullThrows)(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 ${sourceCode.getText(namespaceSpecifier)} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
if (defaultSpecifier &&
|
||||
report.typeSpecifiers.includes(defaultSpecifier)) {
|
||||
if (report.typeSpecifiers.length === node.specifiers.length) {
|
||||
const importToken = (0, util_1.nullThrows)(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)(sourceCode.getTokenAfter(defaultSpecifier, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', defaultSpecifier.type));
|
||||
// import Type , {...} from 'foo'
|
||||
// ^^^^^ pick
|
||||
const defaultText = sourceCode.text
|
||||
.slice(defaultSpecifier.range[0], commaToken.range[0])
|
||||
.trim();
|
||||
yield fixer.insertTextBefore(node, `import type ${defaultText} from ${sourceCode.getText(node.source)};\n`);
|
||||
const afterToken = (0, util_1.nullThrows)(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)(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 = sourceCode.getFirstTokenBetween(importToken, node.source, util_1.isOpeningBraceToken);
|
||||
if (openingBraceToken) {
|
||||
// Only braces. e.g. import Foo, {} from 'foo'
|
||||
const commaToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(openingBraceToken, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
|
||||
const closingBraceToken = (0, util_1.nullThrows)(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 = sourceCode.text.slice(commaToken.range[1], closingBraceToken.range[1]);
|
||||
if (node.specifiers.length > 1) {
|
||||
yield fixer.insertTextAfter(node, `\nimport type${specifiersText} from ${sourceCode.getText(node.source)};`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// make sure we don't do anything like `import type {type T} from 'foo';`
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
|
||||
specifier.importKind === 'type') {
|
||||
yield* fixRemoveTypeSpecifierFromImportSpecifier(fixer, specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
function* fixToValueImportDeclaration(fixer, report, sourceImports) {
|
||||
const { node } = report;
|
||||
const { defaultSpecifier, namespaceSpecifier, namedSpecifiers } = classifySpecifier(node);
|
||||
if (namespaceSpecifier) {
|
||||
// import type * as types from 'foo'
|
||||
yield* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
return;
|
||||
}
|
||||
else if (defaultSpecifier) {
|
||||
if (report.valueSpecifiers.includes(defaultSpecifier) &&
|
||||
namedSpecifiers.length === 0) {
|
||||
// import type Type from 'foo'
|
||||
yield* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (namedSpecifiers.every(specifier => report.valueSpecifiers.includes(specifier))) {
|
||||
// import type {Type1, Type2} from 'foo'
|
||||
yield* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// we have some valueSpecifiers intermixed in types that need to be put on their own line
|
||||
// import type { Type1, A } from 'foo'
|
||||
// import type { A } from 'foo'
|
||||
const valueNamedSpecifiers = namedSpecifiers.filter(specifier => report.valueSpecifiers.includes(specifier));
|
||||
const fixesNamedSpecifiers = getFixesNamedSpecifiers(fixer, node, valueNamedSpecifiers, namedSpecifiers);
|
||||
const afterFixes = [];
|
||||
if (valueNamedSpecifiers.length) {
|
||||
if (sourceImports.valueOnlyNamedImport) {
|
||||
const insertTypeNamedSpecifiers = fixInsertNamedSpecifiersInNamedSpecifierList(fixer, sourceImports.valueOnlyNamedImport, fixesNamedSpecifiers.typeNamedSpecifiersText);
|
||||
if (sourceImports.valueOnlyNamedImport.range[1] <= node.range[0]) {
|
||||
yield insertTypeNamedSpecifiers;
|
||||
}
|
||||
else {
|
||||
afterFixes.push(insertTypeNamedSpecifiers);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// some are types.
|
||||
// Add new value import and later remove those value specifiers from import type
|
||||
yield fixer.insertTextBefore(node, `import {${fixesNamedSpecifiers.typeNamedSpecifiersText}} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
}
|
||||
yield* fixesNamedSpecifiers.removeTypeNamedSpecifiers;
|
||||
yield* afterFixes;
|
||||
}
|
||||
function* fixRemoveTypeSpecifierFromImportDeclaration(fixer, node) {
|
||||
// import type Foo from 'foo'
|
||||
// ^^^^ remove
|
||||
const importToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
|
||||
const typeToken = (0, util_1.nullThrows)(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)(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)(sourceCode.getFirstToken(node, util_1.isTypeKeyword), util_1.NullThrowsReasons.MissingToken('type', node.type));
|
||||
const afterToken = (0, util_1.nullThrows)(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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
63
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js
generated
vendored
Normal file
63
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
"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 'optional' in node && 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/default-param-last.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"default-param-last.js","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAqC;AAErC,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,YAAY,EAAE,oCAAoC;SACnD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ;;;;WAIG;QACH,SAAS,eAAe,CAAC,IAAwB;YAC/C,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC;QAC7C,CAAC;QAED;;;;WAIG;QACH,SAAS,YAAY,CAAC,IAAwB;YAC5C,OAAO,CAAC,CACN,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB;gBAC9C,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,WAAW;gBACxC,eAAe,CAAC,IAAI,CAAC,CACtB,CAAC;QACJ,CAAC;QAED,SAAS,qBAAqB,CAC5B,IAG+B;YAE/B,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAC9B,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,KAAK,GACT,OAAO,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;oBACjD,CAAC,CAAC,OAAO,CAAC,SAAS;oBACnB,CAAC,CAAC,OAAO,CAAC;gBAEd,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,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"}
|
120
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js
generated
vendored
Normal file
120
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
"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)('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);
|
||||
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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"dot-notation.js","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwC;AACxC,+CAAiC;AAMj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;gBACH,CAAC;gBACD,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
112
node_modules/@typescript-eslint/eslint-plugin/dist/rules/enum-utils/shared.js
generated
vendored
Normal file
112
node_modules/@typescript-eslint/eslint-plugin/dist/rules/enum-utils/shared.js
generated
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
"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.getEnumKeyForLiteral = exports.getEnumTypes = exports.getEnumLiterals = void 0;
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
exports.getEnumLiterals = getEnumLiterals;
|
||||
/**
|
||||
* 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));
|
||||
}
|
||||
exports.getEnumTypes = getEnumTypes;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
exports.getEnumKeyForLiteral = getEnumKeyForLiteral;
|
||||
//# sourceMappingURL=shared.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/enum-utils/shared.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/enum-utils/shared.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/rules/enum-utils/shared.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,+CAAiC;AAEjC,qCAA2C;AAE3C;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,WAA2B,EAAE,IAAa;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAG,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,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AAI,oBAAoB,CAAC,IAAI,EAAE,CAAC;gBAEpD,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;oBACjC,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;oBAElE,OAAO,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;AAlCD,oDAkCC"}
|
164
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js
generated
vendored
Normal file
164
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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;
|
||||
}
|
||||
return {
|
||||
'ArrowFunctionExpression, FunctionExpression'(node) {
|
||||
if (options.allowConciseArrowFunctionExpressionsStartingWithVoid &&
|
||||
node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
|
||||
node.expression &&
|
||||
node.body.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
||||
node.body.operator === 'void') {
|
||||
return;
|
||||
}
|
||||
if (isAllowedFunction(node)) {
|
||||
return;
|
||||
}
|
||||
if (options.allowTypedFunctionExpressions &&
|
||||
((0, explicitReturnTypeUtils_1.isValidFunctionExpressionReturnType)(node, options) ||
|
||||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node))) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
}));
|
||||
},
|
||||
FunctionDeclaration(node) {
|
||||
if (isAllowedFunction(node)) {
|
||||
return;
|
||||
}
|
||||
if (options.allowTypedFunctionExpressions && node.returnType) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
}));
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-function-return-type.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-function-return-type.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAC1D,wEAAsE;AAEtE,kCAAqC;AACrC,6EAIyC;AAgBzC,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,6EA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AC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CACH,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
283
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js
generated
vendored
Normal file
283
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js
generated
vendored
Normal file
@ -0,0 +1,283 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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, sourceCode);
|
||||
if (check === 'off' || ignoredMethodNames.has(methodName)) {
|
||||
return;
|
||||
}
|
||||
if (check === 'no-public' &&
|
||||
methodDefinition.accessibility === 'public') {
|
||||
context.report({
|
||||
node: methodDefinition,
|
||||
messageId: 'unwantedPublicAccessibility',
|
||||
data: {
|
||||
type: nodeType,
|
||||
name: methodName,
|
||||
},
|
||||
fix: getUnwantedPublicAccessibilityFixer(methodDefinition),
|
||||
});
|
||||
}
|
||||
else if (check === 'explicit' && !methodDefinition.accessibility) {
|
||||
context.report({
|
||||
node: methodDefinition,
|
||||
messageId: 'missingAccessibility',
|
||||
data: {
|
||||
type: nodeType,
|
||||
name: methodName,
|
||||
},
|
||||
suggest: getMissingAccessibilitySuggestions(methodDefinition),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a fixer that removes a "public" keyword with following spaces
|
||||
*/
|
||||
function getUnwantedPublicAccessibilityFixer(node) {
|
||||
return function (fixer) {
|
||||
const tokens = sourceCode.getTokens(node);
|
||||
let rangeToRemove;
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const token = tokens[i];
|
||||
if (token.type === utils_1.AST_TOKEN_TYPES.Keyword &&
|
||||
token.value === 'public') {
|
||||
const commensAfterPublicKeyword = sourceCode.getCommentsAfter(token);
|
||||
if (commensAfterPublicKeyword.length) {
|
||||
// public /* Hi there! */ static foo()
|
||||
// ^^^^^^^
|
||||
rangeToRemove = [
|
||||
token.range[0],
|
||||
commensAfterPublicKeyword[0].range[0],
|
||||
];
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// public static foo()
|
||||
// ^^^^^^^
|
||||
rangeToRemove = [token.range[0], tokens[i + 1].range[0]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fixer.removeRange(rangeToRemove);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates a fixer that adds a "public" keyword with following spaces
|
||||
*/
|
||||
function getMissingAccessibilitySuggestions(node) {
|
||||
function fix(accessibility, fixer) {
|
||||
if (node.decorators.length) {
|
||||
const lastDecorator = node.decorators[node.decorators.length - 1];
|
||||
const nextToken = sourceCode.getTokenAfter(lastDecorator);
|
||||
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, sourceCode);
|
||||
if (propCheck === 'no-public' &&
|
||||
propertyDefinition.accessibility === 'public') {
|
||||
context.report({
|
||||
node: propertyDefinition,
|
||||
messageId: 'unwantedPublicAccessibility',
|
||||
data: {
|
||||
type: nodeType,
|
||||
name: propertyName,
|
||||
},
|
||||
fix: getUnwantedPublicAccessibilityFixer(propertyDefinition),
|
||||
});
|
||||
}
|
||||
else if (propCheck === 'explicit' &&
|
||||
!propertyDefinition.accessibility) {
|
||||
context.report({
|
||||
node: 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({
|
||||
node,
|
||||
messageId: 'missingAccessibility',
|
||||
data: {
|
||||
type: nodeType,
|
||||
name: nodeName,
|
||||
},
|
||||
suggest: getMissingAccessibilitySuggestions(node),
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'no-public': {
|
||||
if (node.accessibility === 'public' && node.readonly) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unwantedPublicAccessibility',
|
||||
data: {
|
||||
type: nodeType,
|
||||
name: nodeName,
|
||||
},
|
||||
fix: getUnwantedPublicAccessibilityFixer(node),
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
'MethodDefinition, TSAbstractMethodDefinition': checkMethodAccessibilityModifier,
|
||||
'PropertyDefinition, TSAbstractPropertyDefinition': checkPropertyAccessibilityModifier,
|
||||
TSParameterProperty: checkParameterPropertyAccessibilityModifier,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-member-accessibility.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-member-accessibility.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
366
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js
generated
vendored
Normal file
366
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js
generated
vendored
Normal file
@ -0,0 +1,366 @@
|
||||
"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 eslint_utils_1 = require("@typescript-eslint/utils/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 expresion.',
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowArgumentsExplicitlyTypedAsAny: false,
|
||||
allowDirectConstAssertionInArrowFunctions: true,
|
||||
allowedNames: [],
|
||||
allowHigherOrderFunctions: true,
|
||||
allowTypedFunctionExpressions: true,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
// tracks all of the functions we've already checked
|
||||
const checkedFunctions = new Set();
|
||||
// tracks functions that were found whilst traversing
|
||||
const foundFunctions = [];
|
||||
// all nodes visited, avoids infinite recursion for cyclic references
|
||||
// (such as class member referring to itself)
|
||||
const alreadyVisited = new Set();
|
||||
/*
|
||||
# How the rule works:
|
||||
|
||||
As the rule traverses the AST, it immediately checks every single function that it finds is exported.
|
||||
"exported" means that it is either directly exported, or that its name is exported.
|
||||
|
||||
It also collects a list of every single function it finds on the way, but does not check them.
|
||||
After it's finished traversing the AST, it then iterates through the list of found functions, and checks to see if
|
||||
any of them are part of a higher-order function
|
||||
*/
|
||||
return {
|
||||
ExportDefaultDeclaration(node) {
|
||||
checkNode(node.declaration);
|
||||
},
|
||||
'ExportNamedDeclaration:not([source])'(node) {
|
||||
if (node.declaration) {
|
||||
checkNode(node.declaration);
|
||||
}
|
||||
else {
|
||||
for (const specifier of node.specifiers) {
|
||||
followReference(specifier.local);
|
||||
}
|
||||
}
|
||||
},
|
||||
TSExportAssignment(node) {
|
||||
checkNode(node.expression);
|
||||
},
|
||||
'ArrowFunctionExpression, FunctionDeclaration, FunctionExpression'(node) {
|
||||
foundFunctions.push(node);
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const func of foundFunctions) {
|
||||
if (isExportedHigherOrderFunction(func)) {
|
||||
checkNode(func);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
function checkParameters(node) {
|
||||
function checkParameter(param) {
|
||||
function report(namedMessageId, unnamedMessageId) {
|
||||
if (param.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: namedMessageId,
|
||||
data: { name: param.name },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Array pattern' },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Object pattern' },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.RestElement) {
|
||||
if (param.argument.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: namedMessageId,
|
||||
data: { name: param.argument.name },
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Rest' },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (param.type) {
|
||||
case utils_1.AST_NODE_TYPES.ArrayPattern:
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
case utils_1.AST_NODE_TYPES.ObjectPattern:
|
||||
case utils_1.AST_NODE_TYPES.RestElement:
|
||||
if (!param.typeAnnotation) {
|
||||
report('missingArgType', 'missingArgTypeUnnamed');
|
||||
}
|
||||
else if (options.allowArgumentsExplicitlyTypedAsAny !== true &&
|
||||
param.typeAnnotation.typeAnnotation.type ===
|
||||
utils_1.AST_NODE_TYPES.TSAnyKeyword) {
|
||||
report('anyTypedArg', 'anyTypedArgUnnamed');
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.TSParameterProperty:
|
||||
return checkParameter(param.parameter);
|
||||
case utils_1.AST_NODE_TYPES.AssignmentPattern: // ignored as it has a type via its assignment
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const arg of node.params) {
|
||||
checkParameter(arg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if a function name is allowed and should not be checked.
|
||||
*/
|
||||
function isAllowedName(node) {
|
||||
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) ||
|
||||
!(0, explicitReturnTypeUtils_1.doesImmediatelyReturnFunctionExpression)(current)) {
|
||||
return false;
|
||||
}
|
||||
if (checkedFunctions.has(current)) {
|
||||
return true;
|
||||
}
|
||||
current = current.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function followReference(node) {
|
||||
const scope = (0, eslint_utils_1.getScope)(context);
|
||||
const variable = scope.set.get(node.name);
|
||||
/* istanbul ignore if */ if (!variable) {
|
||||
return;
|
||||
}
|
||||
// check all of the definitions
|
||||
for (const definition of variable.defs) {
|
||||
// cases we don't care about in this rule
|
||||
if ([
|
||||
scope_manager_1.DefinitionType.ImplicitGlobalVariable,
|
||||
scope_manager_1.DefinitionType.ImportBinding,
|
||||
scope_manager_1.DefinitionType.CatchClause,
|
||||
scope_manager_1.DefinitionType.Parameter,
|
||||
].includes(definition.type)) {
|
||||
continue;
|
||||
}
|
||||
checkNode(definition.node);
|
||||
}
|
||||
// follow references to find writes to the variable
|
||||
for (const reference of variable.references) {
|
||||
if (
|
||||
// we don't want to check the initialization ref, as this is handled by the declaration check
|
||||
!reference.init &&
|
||||
reference.writeExpr) {
|
||||
checkNode(reference.writeExpr);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkNode(node) {
|
||||
if (node == null || alreadyVisited.has(node)) {
|
||||
return;
|
||||
}
|
||||
alreadyVisited.add(node);
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
||||
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
||||
return checkFunctionExpression(node);
|
||||
case utils_1.AST_NODE_TYPES.ArrayExpression:
|
||||
for (const element of node.elements) {
|
||||
checkNode(element);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
if (node.accessibility === 'private' ||
|
||||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.ClassDeclaration:
|
||||
case utils_1.AST_NODE_TYPES.ClassExpression:
|
||||
for (const element of node.body.body) {
|
||||
checkNode(element);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration:
|
||||
return checkFunction(node);
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
if (node.accessibility === 'private' ||
|
||||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
return followReference(node);
|
||||
case utils_1.AST_NODE_TYPES.ObjectExpression:
|
||||
for (const property of node.properties) {
|
||||
checkNode(property);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.Property:
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression:
|
||||
return checkEmptyBodyFunctionExpression(node);
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclaration:
|
||||
for (const declaration of node.declarations) {
|
||||
checkNode(declaration);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclarator:
|
||||
return checkNode(node.init);
|
||||
}
|
||||
}
|
||||
function checkEmptyBodyFunctionExpression(node) {
|
||||
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) {
|
||||
if (checkedFunctions.has(node)) {
|
||||
return;
|
||||
}
|
||||
checkedFunctions.add(node);
|
||||
if (isAllowedName(node.parent) ||
|
||||
(0, explicitReturnTypeUtils_1.isTypedFunctionExpression)(node, options) ||
|
||||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionExpressionReturnType)(node, options, sourceCode, loc => {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
});
|
||||
checkParameters(node);
|
||||
}
|
||||
function checkFunction(node) {
|
||||
if (checkedFunctions.has(node)) {
|
||||
return;
|
||||
}
|
||||
checkedFunctions.add(node);
|
||||
if (isAllowedName(node) || (0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
});
|
||||
checkParameters(node);
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-module-boundary-types.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/explicit-module-boundary-types.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
146
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js
generated
vendored
Normal file
146
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js
generated
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'func-call-spacing',
|
||||
meta: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const text = sourceCode.getText();
|
||||
/**
|
||||
* Check if open space is present in a function name
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkSpacing(node) {
|
||||
const isOptionalCall = (0, util_1.isOptionalCallExpression)(node);
|
||||
const closingParenToken = sourceCode.getLastToken(node);
|
||||
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken(node.typeArguments ?? node.callee);
|
||||
const openingParenToken = sourceCode.getFirstTokenBetween(lastCalleeTokenWithoutPossibleParens, closingParenToken, util_1.isOpeningParenToken);
|
||||
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {
|
||||
// new expression with no parens...
|
||||
return;
|
||||
}
|
||||
const lastCalleeToken = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/func-call-spacing.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"func-call-spacing.js","sourceRoot":"","sources":["../../src/rules/func-call-spacing.ts"],"names":[],"mappings":";;AACA,wEAAsE;AAEtE,kCAMiB;AAajB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EACT,gFAAgF;YAClF,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE;YACN,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE,CAAC,OAAO,CAAC;yBAChB;qBACF;oBACD,QAAQ,EAAE,CAAC;oBACX,QAAQ,EAAE,CAAC;iBACZ;gBACD;oBACE,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE,CAAC,QAAQ,CAAC;yBACjB;wBACD;4BACE,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,aAAa,EAAE;oCACb,IAAI,EAAE,SAAS;iCAChB;6BACF;4BACD,oBAAoB,EAAE,KAAK;yBAC5B;qBACF;oBACD,QAAQ,EAAE,CAAC;oBACX,QAAQ,EAAE,CAAC;iBACZ;aACF;SACF;QAED,QAAQ,EAAE;YACR,oBAAoB,EAClB,wDAAwD;YAC1D,iBAAiB,EAAE,qDAAqD;YACxE,OAAO,EAAE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ACb,IAAI;wBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,mBAAmB;wBAC9B,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,gBAAgB,CAC3B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACtD,GAAG,CACJ,CAAC;wBACJ,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,YAAY;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
413
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js
generated
vendored
Normal file
413
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js
generated
vendored
Normal file
@ -0,0 +1,413 @@
|
||||
"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 */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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: {
|
||||
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 Object.assign({}, rules, {
|
||||
// overwrite the base rule here so we can use our KNOWN_NODES list instead
|
||||
'*:exit'(node) {
|
||||
// For nodes we care about, skip the default handling, because it just marks the node as ignored...
|
||||
if (!KNOWN_NODES.has(node.type)) {
|
||||
rules['*:exit'](node);
|
||||
}
|
||||
},
|
||||
VariableDeclaration(node) {
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/441
|
||||
if (node.declarations.length === 0) {
|
||||
return;
|
||||
}
|
||||
return rules.VariableDeclaration(node);
|
||||
},
|
||||
TSAsExpression(node) {
|
||||
// transform it to a BinaryExpression
|
||||
return rules['BinaryExpression, LogicalExpression']({
|
||||
type: utils_1.AST_NODE_TYPES.BinaryExpression,
|
||||
operator: 'as',
|
||||
left: node.expression,
|
||||
// the first typeAnnotation includes the as token
|
||||
right: node.typeAnnotation,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSConditionalType(node) {
|
||||
// transform it to a ConditionalExpression
|
||||
return rules.ConditionalExpression({
|
||||
type: utils_1.AST_NODE_TYPES.ConditionalExpression,
|
||||
test: {
|
||||
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) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const squareBracketStart = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/indent.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
280
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
generated
vendored
Normal file
280
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
generated
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
"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_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_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_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_qualifier_1 = __importDefault(require("./no-unnecessary-qualifier"));
|
||||
const no_unnecessary_type_arguments_1 = __importDefault(require("./no-unnecessary-type-arguments"));
|
||||
const no_unnecessary_type_assertion_1 = __importDefault(require("./no-unnecessary-type-assertion"));
|
||||
const no_unnecessary_type_constraint_1 = __importDefault(require("./no-unnecessary-type-constraint"));
|
||||
const no_unsafe_argument_1 = __importDefault(require("./no-unsafe-argument"));
|
||||
const no_unsafe_assignment_1 = __importDefault(require("./no-unsafe-assignment"));
|
||||
const no_unsafe_call_1 = __importDefault(require("./no-unsafe-call"));
|
||||
const no_unsafe_declaration_merging_1 = __importDefault(require("./no-unsafe-declaration-merging"));
|
||||
const no_unsafe_enum_comparison_1 = __importDefault(require("./no-unsafe-enum-comparison"));
|
||||
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_var_requires_1 = __importDefault(require("./no-var-requires"));
|
||||
const non_nullable_type_assertion_style_1 = __importDefault(require("./non-nullable-type-assertion-style"));
|
||||
const object_curly_spacing_1 = __importDefault(require("./object-curly-spacing"));
|
||||
const padding_line_between_statements_1 = __importDefault(require("./padding-line-between-statements"));
|
||||
const parameter_properties_1 = __importDefault(require("./parameter-properties"));
|
||||
const prefer_as_const_1 = __importDefault(require("./prefer-as-const"));
|
||||
const prefer_destructuring_1 = __importDefault(require("./prefer-destructuring"));
|
||||
const prefer_enum_initializers_1 = __importDefault(require("./prefer-enum-initializers"));
|
||||
const prefer_for_of_1 = __importDefault(require("./prefer-for-of"));
|
||||
const prefer_function_type_1 = __importDefault(require("./prefer-function-type"));
|
||||
const prefer_includes_1 = __importDefault(require("./prefer-includes"));
|
||||
const prefer_literal_enum_member_1 = __importDefault(require("./prefer-literal-enum-member"));
|
||||
const prefer_namespace_keyword_1 = __importDefault(require("./prefer-namespace-keyword"));
|
||||
const prefer_nullish_coalescing_1 = __importDefault(require("./prefer-nullish-coalescing"));
|
||||
const prefer_optional_chain_1 = __importDefault(require("./prefer-optional-chain"));
|
||||
const prefer_readonly_1 = __importDefault(require("./prefer-readonly"));
|
||||
const prefer_readonly_parameter_types_1 = __importDefault(require("./prefer-readonly-parameter-types"));
|
||||
const prefer_reduce_type_parameter_1 = __importDefault(require("./prefer-reduce-type-parameter"));
|
||||
const prefer_regexp_exec_1 = __importDefault(require("./prefer-regexp-exec"));
|
||||
const prefer_return_this_type_1 = __importDefault(require("./prefer-return-this-type"));
|
||||
const prefer_string_starts_ends_with_1 = __importDefault(require("./prefer-string-starts-ends-with"));
|
||||
const prefer_ts_expect_error_1 = __importDefault(require("./prefer-ts-expect-error"));
|
||||
const promise_function_async_1 = __importDefault(require("./promise-function-async"));
|
||||
const quotes_1 = __importDefault(require("./quotes"));
|
||||
const require_array_sort_compare_1 = __importDefault(require("./require-array-sort-compare"));
|
||||
const require_await_1 = __importDefault(require("./require-await"));
|
||||
const restrict_plus_operands_1 = __importDefault(require("./restrict-plus-operands"));
|
||||
const restrict_template_expressions_1 = __importDefault(require("./restrict-template-expressions"));
|
||||
const return_await_1 = __importDefault(require("./return-await"));
|
||||
const semi_1 = __importDefault(require("./semi"));
|
||||
const sort_type_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"));
|
||||
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-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-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-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-qualifier': no_unnecessary_qualifier_1.default,
|
||||
'no-unnecessary-type-arguments': no_unnecessary_type_arguments_1.default,
|
||||
'no-unnecessary-type-assertion': no_unnecessary_type_assertion_1.default,
|
||||
'no-unnecessary-type-constraint': no_unnecessary_type_constraint_1.default,
|
||||
'no-unsafe-argument': no_unsafe_argument_1.default,
|
||||
'no-unsafe-assignment': no_unsafe_assignment_1.default,
|
||||
'no-unsafe-call': no_unsafe_call_1.default,
|
||||
'no-unsafe-declaration-merging': no_unsafe_declaration_merging_1.default,
|
||||
'no-unsafe-enum-comparison': no_unsafe_enum_comparison_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-var-requires': no_var_requires_1.default,
|
||||
'non-nullable-type-assertion-style': non_nullable_type_assertion_style_1.default,
|
||||
'object-curly-spacing': object_curly_spacing_1.default,
|
||||
'padding-line-between-statements': padding_line_between_statements_1.default,
|
||||
'parameter-properties': parameter_properties_1.default,
|
||||
'prefer-as-const': prefer_as_const_1.default,
|
||||
'prefer-destructuring': prefer_destructuring_1.default,
|
||||
'prefer-enum-initializers': prefer_enum_initializers_1.default,
|
||||
'prefer-for-of': prefer_for_of_1.default,
|
||||
'prefer-function-type': prefer_function_type_1.default,
|
||||
'prefer-includes': prefer_includes_1.default,
|
||||
'prefer-literal-enum-member': prefer_literal_enum_member_1.default,
|
||||
'prefer-namespace-keyword': prefer_namespace_keyword_1.default,
|
||||
'prefer-nullish-coalescing': prefer_nullish_coalescing_1.default,
|
||||
'prefer-optional-chain': prefer_optional_chain_1.default,
|
||||
'prefer-readonly': prefer_readonly_1.default,
|
||||
'prefer-readonly-parameter-types': prefer_readonly_parameter_types_1.default,
|
||||
'prefer-reduce-type-parameter': prefer_reduce_type_parameter_1.default,
|
||||
'prefer-regexp-exec': prefer_regexp_exec_1.default,
|
||||
'prefer-return-this-type': prefer_return_this_type_1.default,
|
||||
'prefer-string-starts-ends-with': prefer_string_starts_ends_with_1.default,
|
||||
'prefer-ts-expect-error': prefer_ts_expect_error_1.default,
|
||||
'promise-function-async': promise_function_async_1.default,
|
||||
quotes: quotes_1.default,
|
||||
'require-array-sort-compare': require_array_sort_compare_1.default,
|
||||
'require-await': require_await_1.default,
|
||||
'restrict-plus-operands': restrict_plus_operands_1.default,
|
||||
'restrict-template-expressions': restrict_template_expressions_1.default,
|
||||
'return-await': return_await_1.default,
|
||||
semi: semi_1.default,
|
||||
'sort-type-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,
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
48
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js
generated
vendored
Normal file
48
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"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]) {
|
||||
const rules = baseRule.create(context);
|
||||
return {
|
||||
'VariableDeclaration:exit'(node) {
|
||||
if (mode === 'always') {
|
||||
if (node.declare) {
|
||||
return;
|
||||
}
|
||||
if (isAncestorNamespaceDeclared(node)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
rules['VariableDeclaration:exit'](node);
|
||||
},
|
||||
};
|
||||
function isAncestorNamespaceDeclared(node) {
|
||||
let ancestor = node.parent;
|
||||
while (ancestor) {
|
||||
if (ancestor.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
|
||||
ancestor.declare) {
|
||||
return true;
|
||||
}
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=init-declarations.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/init-declarations.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"init-declarations.js","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":";;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,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO;YACL,0BAA0B,CAAC,IAAkC;gBAC3D,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACtB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;wBACjB,OAAO;oBACT,CAAC;oBACD,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE,CAAC;wBACtC,OAAO;oBACT,CAAC;gBACH,CAAC;gBAED,KAAK,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC;QAEF,SAAS,2BAA2B,CAClC,IAAkC;YAElC,IAAI,QAAQ,GAA8B,IAAI,CAAC,MAAM,CAAC;YAEtD,OAAO,QAAQ,EAAE,CAAC;gBAChB,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"}
|
320
node_modules/@typescript-eslint/eslint-plugin/dist/rules/key-spacing.js
generated
vendored
Normal file
320
node_modules/@typescript-eslint/eslint-plugin/dist/rules/key-spacing.js
generated
vendored
Normal file
@ -0,0 +1,320 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
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)(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 = sourceCode.getTokenAfter(node, util_1.isColonToken);
|
||||
return 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 sourceCode.getText(node.key);
|
||||
}
|
||||
const code = sourceCode.getText(node);
|
||||
return code.slice(0, 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 = sourceCode.getFirstToken(typeAnnotation);
|
||||
const typeStart = 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 = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/key-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/key-spacing.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
93
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js
generated
vendored
Normal file
93
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const baseRules = baseRule.create(context);
|
||||
return {
|
||||
...baseRules,
|
||||
TSAsExpression(node) {
|
||||
const asToken = (0, util_1.nullThrows)(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 = sourceCode.getFirstToken(node, { skip: 1 });
|
||||
const punctuatorToken = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/keyword-spacing.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"keyword-spacing.js","sourceRoot":"","sources":["../../src/rules/keyword-spacing.ts"],"names":[],"mappings":";;AACA,oDAA2E;AAC3E,wEAAsE;AAOtE,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,CAA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,GAAG,CAAC,EAClC,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC;wBACb,GAAG,EAAE,SAAS,CAAC,GAAG;wBAClB,SAAS,EAAE,iBAAiB;wBAC5B,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;wBACvB,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,WAAW,CAAC;gCACvB,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;gCAClB,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,8BAA8B;6BACpD,CAAC,CAAC;wBACL,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
355
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-around-comment.js
generated
vendored
Normal file
355
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-around-comment.js
generated
vendored
Normal file
@ -0,0 +1,355 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/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: {
|
||||
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 sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
const comments = sourceCode.getAllComments();
|
||||
const lines = 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 = 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 = 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 = 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 = sourceCode.getTokenBefore(token, {
|
||||
includeComments: true,
|
||||
});
|
||||
const nextTokenOrComment = 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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-around-comment.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-around-comment.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
55
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js
generated
vendored
Normal file
55
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
"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: {
|
||||
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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/lines-between-class-members.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"lines-between-class-members.js","sourceRoot":"","sources":["../../src/rules/lines-between-class-members.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAO1D,kCAAgD;AAChD,iEAA8D;AAE9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BACZ,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"}
|
67
node_modules/@typescript-eslint/eslint-plugin/dist/rules/max-params.js
generated
vendored
Normal file
67
node_modules/@typescript-eslint/eslint-plugin/dist/rules/max-params.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
"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
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/max-params.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/max-params.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"max-params.js","sourceRoot":"","sources":["../../src/rules/max-params.ts"],"names":[],"mappings":";;AAAA,oDAAyE;AAMzE,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;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YACxE,mBAAmB,EAAE,YAAY,CAAC,SAAS,CAAC,mBAAmB,CAAC;YAChE,kBAAkB,EAAE,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
256
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js
generated
vendored
Normal file
256
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js
generated
vendored
Normal file
@ -0,0 +1,256 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
const isLastTokenEndOfLine = (token, line) => {
|
||||
const positionInLine = token.loc.start.column;
|
||||
return positionInLine === line.length - 1;
|
||||
};
|
||||
const isCommentsEndOfLine = (token, comments, line) => {
|
||||
if (!comments) {
|
||||
return false;
|
||||
}
|
||||
if (comments.loc.end.line > token.loc.end.line) {
|
||||
return true;
|
||||
}
|
||||
const positionInLine = comments.loc.end.column;
|
||||
return positionInLine === line.length;
|
||||
};
|
||||
const makeFixFunction = ({ optsNone, optsSemi, lastToken, commentsAfterLastToken, missingDelimiter, lastTokenLine, isSingleLine, }) => {
|
||||
// if removing is the action but last token is not the end of the line
|
||||
if (optsNone &&
|
||||
!isLastTokenEndOfLine(lastToken, lastTokenLine) &&
|
||||
!isCommentsEndOfLine(lastToken, commentsAfterLastToken, lastTokenLine) &&
|
||||
!isSingleLine) {
|
||||
return null;
|
||||
}
|
||||
return (fixer) => {
|
||||
if (optsNone) {
|
||||
// remove the unneeded token
|
||||
return fixer.remove(lastToken);
|
||||
}
|
||||
const token = optsSemi ? ';' : ',';
|
||||
if (missingDelimiter) {
|
||||
// add the missing delimiter
|
||||
return fixer.insertTextAfter(lastToken, token);
|
||||
}
|
||||
// correct the current delimiter
|
||||
return fixer.replaceText(lastToken, token);
|
||||
};
|
||||
};
|
||||
const BASE_SCHEMA = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
multiline: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
delimiter: { $ref: '#/items/0/$defs/multiLineOption' },
|
||||
requireLast: { type: 'boolean' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
singleline: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
delimiter: { $ref: '#/items/0/$defs/singleLineOption' },
|
||||
requireLast: { type: 'boolean' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'member-delimiter-style',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require a specific member delimiter style for interfaces and type literals',
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
messages: {
|
||||
unexpectedComma: 'Unexpected separator (,).',
|
||||
unexpectedSemi: 'Unexpected separator (;).',
|
||||
expectedComma: 'Expected a comma.',
|
||||
expectedSemi: 'Expected a semicolon.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
$defs: {
|
||||
multiLineOption: {
|
||||
type: 'string',
|
||||
enum: ['none', 'semi', 'comma'],
|
||||
},
|
||||
// note can't have "none" for single line delimiter as it's invalid syntax
|
||||
singleLineOption: {
|
||||
type: 'string',
|
||||
enum: ['semi', 'comma'],
|
||||
},
|
||||
// note - need to define this last as it references the enums
|
||||
delimiterConfig: BASE_SCHEMA,
|
||||
},
|
||||
type: 'object',
|
||||
properties: {
|
||||
...BASE_SCHEMA.properties,
|
||||
overrides: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
interface: {
|
||||
$ref: '#/items/0/$defs/delimiterConfig',
|
||||
},
|
||||
typeLiteral: {
|
||||
$ref: '#/items/0/$defs/delimiterConfig',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
multilineDetection: {
|
||||
type: 'string',
|
||||
enum: ['brackets', 'last-member'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
multiline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: true,
|
||||
},
|
||||
singleline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: false,
|
||||
},
|
||||
multilineDetection: 'brackets',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
// use the base options as the defaults for the cases
|
||||
const baseOptions = options;
|
||||
const overrides = baseOptions.overrides ?? {};
|
||||
const interfaceOptions = (0, util_1.deepMerge)(baseOptions, overrides.interface);
|
||||
const typeLiteralOptions = (0, util_1.deepMerge)(baseOptions, overrides.typeLiteral);
|
||||
/**
|
||||
* Check the last token in the given member.
|
||||
* @param member the member to be evaluated.
|
||||
* @param opts the options to be validated.
|
||||
* @param isLast a flag indicating `member` is the last in the interface or type literal.
|
||||
*/
|
||||
function checkLastToken(member, opts, isLast) {
|
||||
/**
|
||||
* Resolves the boolean value for the given setting enum value
|
||||
* @param type the option name
|
||||
*/
|
||||
function getOption(type) {
|
||||
if (isLast && !opts.requireLast) {
|
||||
// only turn the option on if its expecting no delimiter for the last member
|
||||
return type === 'none';
|
||||
}
|
||||
return opts.delimiter === type;
|
||||
}
|
||||
let messageId = null;
|
||||
let missingDelimiter = false;
|
||||
const lastToken = sourceCode.getLastToken(member, {
|
||||
includeComments: false,
|
||||
});
|
||||
if (!lastToken) {
|
||||
return;
|
||||
}
|
||||
const commentsAfterLastToken = sourceCode
|
||||
.getCommentsAfter(lastToken)
|
||||
.pop();
|
||||
const sourceCodeLines = sourceCode.getLines();
|
||||
const lastTokenLine = sourceCodeLines[lastToken.loc.start.line - 1];
|
||||
const optsSemi = getOption('semi');
|
||||
const optsComma = getOption('comma');
|
||||
const optsNone = getOption('none');
|
||||
if (lastToken.value === ';') {
|
||||
if (optsComma) {
|
||||
messageId = 'expectedComma';
|
||||
}
|
||||
else if (optsNone) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'unexpectedSemi';
|
||||
}
|
||||
}
|
||||
else if (lastToken.value === ',') {
|
||||
if (optsSemi) {
|
||||
messageId = 'expectedSemi';
|
||||
}
|
||||
else if (optsNone) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'unexpectedComma';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (optsSemi) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'expectedSemi';
|
||||
}
|
||||
else if (optsComma) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'expectedComma';
|
||||
}
|
||||
}
|
||||
if (messageId) {
|
||||
context.report({
|
||||
node: lastToken,
|
||||
loc: {
|
||||
start: {
|
||||
line: lastToken.loc.end.line,
|
||||
column: lastToken.loc.end.column,
|
||||
},
|
||||
end: {
|
||||
line: lastToken.loc.end.line,
|
||||
column: lastToken.loc.end.column,
|
||||
},
|
||||
},
|
||||
messageId,
|
||||
fix: makeFixFunction({
|
||||
optsNone,
|
||||
optsSemi,
|
||||
lastToken,
|
||||
commentsAfterLastToken,
|
||||
missingDelimiter,
|
||||
lastTokenLine,
|
||||
isSingleLine: opts.type === 'single-line',
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the member separator being used matches the delimiter.
|
||||
* @param {ASTNode} node the node to be evaluated.
|
||||
*/
|
||||
function checkMemberSeparatorStyle(node) {
|
||||
const members = node.type === utils_1.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
||||
let isSingleLine = node.loc.start.line === node.loc.end.line;
|
||||
if (options.multilineDetection === 'last-member' &&
|
||||
!isSingleLine &&
|
||||
members.length > 0) {
|
||||
const lastMember = members[members.length - 1];
|
||||
if (lastMember.loc.end.line === node.loc.end.line) {
|
||||
isSingleLine = true;
|
||||
}
|
||||
}
|
||||
const typeOpts = node.type === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
||||
? interfaceOptions
|
||||
: typeLiteralOptions;
|
||||
const opts = isSingleLine
|
||||
? { ...typeOpts.singleline, type: 'single-line' }
|
||||
: { ...typeOpts.multiline, type: 'multi-line' };
|
||||
members.forEach((member, index) => {
|
||||
checkLastToken(member, opts, index === members.length - 1);
|
||||
});
|
||||
}
|
||||
return {
|
||||
TSInterfaceBody: checkMemberSeparatorStyle,
|
||||
TSTypeLiteral: checkMemberSeparatorStyle,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=member-delimiter-style.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
719
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js
generated
vendored
Normal file
719
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js
generated
vendored
Normal file
@ -0,0 +1,719 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultOrder = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const natural_compare_1 = __importDefault(require("natural-compare"));
|
||||
const util_1 = require("../util");
|
||||
const neverConfig = {
|
||||
type: 'string',
|
||||
enum: ['never'],
|
||||
};
|
||||
const arrayConfig = (memberTypes) => ({
|
||||
type: 'array',
|
||||
items: {
|
||||
oneOf: [
|
||||
{
|
||||
$ref: memberTypes,
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: memberTypes,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const objectConfig = (memberTypes) => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
memberTypes: {
|
||||
oneOf: [arrayConfig(memberTypes), neverConfig],
|
||||
},
|
||||
order: {
|
||||
$ref: '#/items/0/$defs/orderOptions',
|
||||
},
|
||||
optionalityOrder: {
|
||||
$ref: '#/items/0/$defs/optionalityOrderOptions',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
});
|
||||
exports.defaultOrder = [
|
||||
// Index signature
|
||||
'signature',
|
||||
'call-signature',
|
||||
// Fields
|
||||
'public-static-field',
|
||||
'protected-static-field',
|
||||
'private-static-field',
|
||||
'#private-static-field',
|
||||
'public-decorated-field',
|
||||
'protected-decorated-field',
|
||||
'private-decorated-field',
|
||||
'public-instance-field',
|
||||
'protected-instance-field',
|
||||
'private-instance-field',
|
||||
'#private-instance-field',
|
||||
'public-abstract-field',
|
||||
'protected-abstract-field',
|
||||
'public-field',
|
||||
'protected-field',
|
||||
'private-field',
|
||||
'#private-field',
|
||||
'static-field',
|
||||
'instance-field',
|
||||
'abstract-field',
|
||||
'decorated-field',
|
||||
'field',
|
||||
// Static initialization
|
||||
'static-initialization',
|
||||
// Constructors
|
||||
'public-constructor',
|
||||
'protected-constructor',
|
||||
'private-constructor',
|
||||
'constructor',
|
||||
// Getters
|
||||
'public-static-get',
|
||||
'protected-static-get',
|
||||
'private-static-get',
|
||||
'#private-static-get',
|
||||
'public-decorated-get',
|
||||
'protected-decorated-get',
|
||||
'private-decorated-get',
|
||||
'public-instance-get',
|
||||
'protected-instance-get',
|
||||
'private-instance-get',
|
||||
'#private-instance-get',
|
||||
'public-abstract-get',
|
||||
'protected-abstract-get',
|
||||
'public-get',
|
||||
'protected-get',
|
||||
'private-get',
|
||||
'#private-get',
|
||||
'static-get',
|
||||
'instance-get',
|
||||
'abstract-get',
|
||||
'decorated-get',
|
||||
'get',
|
||||
// Setters
|
||||
'public-static-set',
|
||||
'protected-static-set',
|
||||
'private-static-set',
|
||||
'#private-static-set',
|
||||
'public-decorated-set',
|
||||
'protected-decorated-set',
|
||||
'private-decorated-set',
|
||||
'public-instance-set',
|
||||
'protected-instance-set',
|
||||
'private-instance-set',
|
||||
'#private-instance-set',
|
||||
'public-abstract-set',
|
||||
'protected-abstract-set',
|
||||
'public-set',
|
||||
'protected-set',
|
||||
'private-set',
|
||||
'#private-set',
|
||||
'static-set',
|
||||
'instance-set',
|
||||
'abstract-set',
|
||||
'decorated-set',
|
||||
'set',
|
||||
// Methods
|
||||
'public-static-method',
|
||||
'protected-static-method',
|
||||
'private-static-method',
|
||||
'#private-static-method',
|
||||
'public-decorated-method',
|
||||
'protected-decorated-method',
|
||||
'private-decorated-method',
|
||||
'public-instance-method',
|
||||
'protected-instance-method',
|
||||
'private-instance-method',
|
||||
'#private-instance-method',
|
||||
'public-abstract-method',
|
||||
'protected-abstract-method',
|
||||
'public-method',
|
||||
'protected-method',
|
||||
'private-method',
|
||||
'#private-method',
|
||||
'static-method',
|
||||
'instance-method',
|
||||
'abstract-method',
|
||||
'decorated-method',
|
||||
'method',
|
||||
];
|
||||
const allMemberTypes = Array.from([
|
||||
'readonly-signature',
|
||||
'signature',
|
||||
'readonly-field',
|
||||
'field',
|
||||
'method',
|
||||
'call-signature',
|
||||
'constructor',
|
||||
'get',
|
||||
'set',
|
||||
'static-initialization',
|
||||
].reduce((all, type) => {
|
||||
all.add(type);
|
||||
['public', 'protected', 'private', '#private'].forEach(accessibility => {
|
||||
if (type !== 'readonly-signature' &&
|
||||
type !== 'signature' &&
|
||||
type !== 'static-initialization' &&
|
||||
type !== 'call-signature' &&
|
||||
!(type === 'constructor' && accessibility === '#private')) {
|
||||
all.add(`${accessibility}-${type}`); // e.g. `public-field`
|
||||
}
|
||||
// Only class instance fields, methods, get and set can have decorators attached to them
|
||||
if (accessibility !== '#private' &&
|
||||
(type === 'readonly-field' ||
|
||||
type === 'field' ||
|
||||
type === 'method' ||
|
||||
type === 'get' ||
|
||||
type === 'set')) {
|
||||
all.add(`${accessibility}-decorated-${type}`);
|
||||
all.add(`decorated-${type}`);
|
||||
}
|
||||
if (type !== 'constructor' &&
|
||||
type !== 'readonly-signature' &&
|
||||
type !== 'signature' &&
|
||||
type !== 'call-signature') {
|
||||
// There is no `static-constructor` or `instance-constructor` or `abstract-constructor`
|
||||
if (accessibility === '#private' || accessibility === 'private') {
|
||||
['static', 'instance'].forEach(scope => {
|
||||
all.add(`${scope}-${type}`);
|
||||
all.add(`${accessibility}-${scope}-${type}`);
|
||||
});
|
||||
}
|
||||
else {
|
||||
['static', 'instance', 'abstract'].forEach(scope => {
|
||||
all.add(`${scope}-${type}`);
|
||||
all.add(`${accessibility}-${scope}-${type}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return all;
|
||||
}, new Set()));
|
||||
const functionExpressions = [
|
||||
utils_1.AST_NODE_TYPES.FunctionExpression,
|
||||
utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
|
||||
];
|
||||
/**
|
||||
* Gets the node type.
|
||||
*
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function getNodeType(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return node.kind;
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
return 'method';
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return 'call-signature';
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return 'constructor';
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
||||
return node.readonly ? 'readonly-field' : 'field';
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
return node.value && functionExpressions.includes(node.value.type)
|
||||
? 'method'
|
||||
: node.readonly
|
||||
? 'readonly-field'
|
||||
: 'field';
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
return node.readonly ? 'readonly-field' : 'field';
|
||||
case utils_1.AST_NODE_TYPES.TSIndexSignature:
|
||||
return node.readonly ? 'readonly-signature' : 'signature';
|
||||
case utils_1.AST_NODE_TYPES.StaticBlock:
|
||||
return 'static-initialization';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the raw string value of a member's name
|
||||
*/
|
||||
function getMemberRawName(member, sourceCode) {
|
||||
const { name, type } = (0, util_1.getNameFromMember)(member, sourceCode);
|
||||
if (type === util_1.MemberNameType.Quoted) {
|
||||
return name.slice(1, -1);
|
||||
}
|
||||
if (type === util_1.MemberNameType.Private) {
|
||||
return name.slice(1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Gets the member name based on the member type.
|
||||
*
|
||||
* @param node the node to be evaluated.
|
||||
* @param sourceCode
|
||||
*/
|
||||
function getMemberName(node, sourceCode) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
return getMemberRawName(node, sourceCode);
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return node.kind === 'constructor'
|
||||
? 'constructor'
|
||||
: getMemberRawName(node, sourceCode);
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return 'new';
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return 'call';
|
||||
case utils_1.AST_NODE_TYPES.TSIndexSignature:
|
||||
return (0, util_1.getNameFromIndexSignature)(node);
|
||||
case utils_1.AST_NODE_TYPES.StaticBlock:
|
||||
return 'static block';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns true if the member is optional based on the member type.
|
||||
*
|
||||
* @param node the node to be evaluated.
|
||||
*
|
||||
* @returns Whether the member is optional, or false if it cannot be optional at all.
|
||||
*/
|
||||
function isMemberOptional(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return !!node.optional;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Gets the calculated rank using the provided method definition.
|
||||
* The algorithm is as follows:
|
||||
* - Get the rank based on the accessibility-scope-type name, e.g. public-instance-field
|
||||
* - If there is no order for accessibility-scope-type, then strip out the accessibility.
|
||||
* - If there is no order for scope-type, then strip out the scope.
|
||||
* - If there is no order for type, then return -1
|
||||
* @param memberGroups the valid names to be validated.
|
||||
* @param orderConfig the current order to be validated.
|
||||
*
|
||||
* @return Index of the matching member type in the order configuration.
|
||||
*/
|
||||
function getRankOrder(memberGroups, orderConfig) {
|
||||
let rank = -1;
|
||||
const stack = memberGroups.slice(); // Get a copy of the member groups
|
||||
while (stack.length > 0 && rank === -1) {
|
||||
const memberGroup = stack.shift();
|
||||
rank = orderConfig.findIndex(memberType => Array.isArray(memberType)
|
||||
? memberType.includes(memberGroup)
|
||||
: memberType === memberGroup);
|
||||
}
|
||||
return rank;
|
||||
}
|
||||
function getAccessibility(node) {
|
||||
if ('accessibility' in node && node.accessibility) {
|
||||
return node.accessibility;
|
||||
}
|
||||
if ('key' in node && node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return '#private';
|
||||
}
|
||||
return 'public';
|
||||
}
|
||||
/**
|
||||
* Gets the rank of the node given the order.
|
||||
* @param node the node to be evaluated.
|
||||
* @param orderConfig the current order to be validated.
|
||||
* @param supportsModifiers a flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*/
|
||||
function getRank(node, orderConfig, supportsModifiers) {
|
||||
const type = getNodeType(node);
|
||||
if (type == null) {
|
||||
// shouldn't happen but just in case, put it on the end
|
||||
return orderConfig.length - 1;
|
||||
}
|
||||
const abstract = node.type === utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition ||
|
||||
node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition;
|
||||
const scope = 'static' in node && node.static
|
||||
? 'static'
|
||||
: abstract
|
||||
? 'abstract'
|
||||
: 'instance';
|
||||
const accessibility = getAccessibility(node);
|
||||
// Collect all existing member groups that apply to this node...
|
||||
// (e.g. 'public-instance-field', 'instance-field', 'public-field', 'constructor' etc.)
|
||||
const memberGroups = [];
|
||||
if (supportsModifiers) {
|
||||
const decorated = 'decorators' in node && node.decorators.length > 0;
|
||||
if (decorated &&
|
||||
(type === 'readonly-field' ||
|
||||
type === 'field' ||
|
||||
type === 'method' ||
|
||||
type === 'get' ||
|
||||
type === 'set')) {
|
||||
memberGroups.push(`${accessibility}-decorated-${type}`);
|
||||
memberGroups.push(`decorated-${type}`);
|
||||
if (type === 'readonly-field') {
|
||||
memberGroups.push(`${accessibility}-decorated-field`);
|
||||
memberGroups.push(`decorated-field`);
|
||||
}
|
||||
}
|
||||
if (type !== 'readonly-signature' &&
|
||||
type !== 'signature' &&
|
||||
type !== 'static-initialization') {
|
||||
if (type !== 'constructor') {
|
||||
// Constructors have no scope
|
||||
memberGroups.push(`${accessibility}-${scope}-${type}`);
|
||||
memberGroups.push(`${scope}-${type}`);
|
||||
if (type === 'readonly-field') {
|
||||
memberGroups.push(`${accessibility}-${scope}-field`);
|
||||
memberGroups.push(`${scope}-field`);
|
||||
}
|
||||
}
|
||||
memberGroups.push(`${accessibility}-${type}`);
|
||||
if (type === 'readonly-field') {
|
||||
memberGroups.push(`${accessibility}-field`);
|
||||
}
|
||||
}
|
||||
}
|
||||
memberGroups.push(type);
|
||||
if (type === 'readonly-signature') {
|
||||
memberGroups.push('signature');
|
||||
}
|
||||
else if (type === 'readonly-field') {
|
||||
memberGroups.push('field');
|
||||
}
|
||||
// ...then get the rank order for those member groups based on the node
|
||||
return getRankOrder(memberGroups, orderConfig);
|
||||
}
|
||||
/**
|
||||
* Gets the lowest possible rank(s) higher than target.
|
||||
* e.g. given the following order:
|
||||
* ...
|
||||
* public-static-method
|
||||
* protected-static-method
|
||||
* private-static-method
|
||||
* public-instance-method
|
||||
* protected-instance-method
|
||||
* private-instance-method
|
||||
* ...
|
||||
* and considering that a public-instance-method has already been declared, so ranks contains
|
||||
* public-instance-method, then the lowest possible rank for public-static-method is
|
||||
* public-instance-method.
|
||||
* If a lowest possible rank is a member group, a comma separated list of ranks is returned.
|
||||
* @param ranks the existing ranks in the object.
|
||||
* @param target the target rank.
|
||||
* @param order the current order to be validated.
|
||||
* @returns the name(s) of the lowest possible rank without dashes (-).
|
||||
*/
|
||||
function getLowestRank(ranks, target, order) {
|
||||
let lowest = ranks[ranks.length - 1];
|
||||
ranks.forEach(rank => {
|
||||
if (rank > target) {
|
||||
lowest = Math.min(lowest, rank);
|
||||
}
|
||||
});
|
||||
const lowestRank = order[lowest];
|
||||
const lowestRanks = Array.isArray(lowestRank) ? lowestRank : [lowestRank];
|
||||
return lowestRanks.map(rank => rank.replace(/-/g, ' ')).join(', ');
|
||||
}
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'member-ordering',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require a consistent member declaration order',
|
||||
},
|
||||
messages: {
|
||||
incorrectOrder: 'Member {{member}} should be declared before member {{beforeMember}}.',
|
||||
incorrectGroupOrder: 'Member {{name}} should be declared before all {{rank}} definitions.',
|
||||
incorrectRequiredMembersOrder: `Member {{member}} should be declared after all {{optionalOrRequired}} members.`,
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
$defs: {
|
||||
orderOptions: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'alphabetically',
|
||||
'alphabetically-case-insensitive',
|
||||
'as-written',
|
||||
'natural',
|
||||
'natural-case-insensitive',
|
||||
],
|
||||
},
|
||||
optionalityOrderOptions: {
|
||||
type: 'string',
|
||||
enum: ['optional-first', 'required-first'],
|
||||
},
|
||||
allItems: {
|
||||
type: 'string',
|
||||
enum: allMemberTypes,
|
||||
},
|
||||
typeItems: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'readonly-signature',
|
||||
'signature',
|
||||
'readonly-field',
|
||||
'field',
|
||||
'method',
|
||||
'constructor',
|
||||
],
|
||||
},
|
||||
baseConfig: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig('#/items/0/$defs/allItems'),
|
||||
objectConfig('#/items/0/$defs/allItems'),
|
||||
],
|
||||
},
|
||||
typesConfig: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig('#/items/0/$defs/typeItems'),
|
||||
objectConfig('#/items/0/$defs/typeItems'),
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
properties: {
|
||||
default: {
|
||||
$ref: '#/items/0/$defs/baseConfig',
|
||||
},
|
||||
classes: {
|
||||
$ref: '#/items/0/$defs/baseConfig',
|
||||
},
|
||||
classExpressions: {
|
||||
$ref: '#/items/0/$defs/baseConfig',
|
||||
},
|
||||
interfaces: {
|
||||
$ref: '#/items/0/$defs/typesConfig',
|
||||
},
|
||||
typeLiterals: {
|
||||
$ref: '#/items/0/$defs/typesConfig',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
default: exports.defaultOrder,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
/**
|
||||
* Checks if the member groups are correctly sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param groupOrder Group order to be validated.
|
||||
* @param supportsModifiers A flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*
|
||||
* @return Array of member groups or null if one of the groups is not correctly sorted.
|
||||
*/
|
||||
function checkGroupSort(members, groupOrder, supportsModifiers) {
|
||||
const previousRanks = [];
|
||||
const memberGroups = [];
|
||||
let isCorrectlySorted = true;
|
||||
// Find first member which isn't correctly sorted
|
||||
for (const member of members) {
|
||||
const rank = getRank(member, groupOrder, supportsModifiers);
|
||||
const name = getMemberName(member, (0, eslint_utils_1.getSourceCode)(context));
|
||||
const rankLastMember = previousRanks[previousRanks.length - 1];
|
||||
if (rank === -1) {
|
||||
continue;
|
||||
}
|
||||
// Works for 1st item because x < undefined === false for any x (typeof string)
|
||||
if (rank < rankLastMember) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'incorrectGroupOrder',
|
||||
data: {
|
||||
name,
|
||||
rank: getLowestRank(previousRanks, rank, groupOrder),
|
||||
},
|
||||
});
|
||||
isCorrectlySorted = false;
|
||||
}
|
||||
else if (rank === rankLastMember) {
|
||||
// Same member group --> Push to existing member group array
|
||||
memberGroups[memberGroups.length - 1].push(member);
|
||||
}
|
||||
else {
|
||||
// New member group --> Create new member group array
|
||||
previousRanks.push(rank);
|
||||
memberGroups.push([member]);
|
||||
}
|
||||
}
|
||||
return isCorrectlySorted ? memberGroups : null;
|
||||
}
|
||||
/**
|
||||
* Checks if the members are alphabetically sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param caseSensitive indicates if the alpha ordering is case sensitive or not.
|
||||
*
|
||||
* @return True if all members are correctly sorted.
|
||||
*/
|
||||
function checkAlphaSort(members, order) {
|
||||
let previousName = '';
|
||||
let isCorrectlySorted = true;
|
||||
// Find first member which isn't correctly sorted
|
||||
members.forEach(member => {
|
||||
const name = getMemberName(member, (0, eslint_utils_1.getSourceCode)(context));
|
||||
// Note: Not all members have names
|
||||
if (name) {
|
||||
if (naturalOutOfOrder(name, previousName, order)) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'incorrectOrder',
|
||||
data: {
|
||||
member: name,
|
||||
beforeMember: previousName,
|
||||
},
|
||||
});
|
||||
isCorrectlySorted = false;
|
||||
}
|
||||
previousName = name;
|
||||
}
|
||||
});
|
||||
return isCorrectlySorted;
|
||||
}
|
||||
function naturalOutOfOrder(name, previousName, order) {
|
||||
if (name === previousName) {
|
||||
return false;
|
||||
}
|
||||
switch (order) {
|
||||
case 'alphabetically':
|
||||
return name < previousName;
|
||||
case 'alphabetically-case-insensitive':
|
||||
return name.toLowerCase() < previousName.toLowerCase();
|
||||
case 'natural':
|
||||
return (0, natural_compare_1.default)(name, previousName) !== 1;
|
||||
case 'natural-case-insensitive':
|
||||
return ((0, natural_compare_1.default)(name.toLowerCase(), previousName.toLowerCase()) !== 1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if the order of optional and required members is correct based
|
||||
* on the given 'required' parameter.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param optionalityOrder Where to place optional members, if not intermixed.
|
||||
*
|
||||
* @return True if all required and optional members are correctly sorted.
|
||||
*/
|
||||
function checkRequiredOrder(members, optionalityOrder) {
|
||||
const switchIndex = members.findIndex((member, i) => i && isMemberOptional(member) !== isMemberOptional(members[i - 1]));
|
||||
const report = (member) => context.report({
|
||||
messageId: 'incorrectRequiredMembersOrder',
|
||||
loc: member.loc,
|
||||
data: {
|
||||
member: getMemberName(member, (0, eslint_utils_1.getSourceCode)(context)),
|
||||
optionalOrRequired: optionalityOrder === 'required-first' ? 'required' : 'optional',
|
||||
},
|
||||
});
|
||||
// if the optionality of the first item is correct (based on optionalityOrder)
|
||||
// then the first 0 inclusive to switchIndex exclusive members all
|
||||
// have the correct optionality
|
||||
if (isMemberOptional(members[0]) !==
|
||||
(optionalityOrder === 'optional-first')) {
|
||||
report(members[0]);
|
||||
return false;
|
||||
}
|
||||
for (let i = switchIndex + 1; i < members.length; i++) {
|
||||
if (isMemberOptional(members[i]) !==
|
||||
isMemberOptional(members[switchIndex])) {
|
||||
report(members[switchIndex]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Validates if all members are correctly sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param orderConfig Order config to be validated.
|
||||
* @param supportsModifiers A flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*/
|
||||
function validateMembersOrder(members, orderConfig, supportsModifiers) {
|
||||
if (orderConfig === 'never') {
|
||||
return;
|
||||
}
|
||||
// Standardize config
|
||||
let order;
|
||||
let memberTypes;
|
||||
let optionalityOrder;
|
||||
// returns true if everything is good and false if an error was reported
|
||||
const checkOrder = (memberSet) => {
|
||||
const hasAlphaSort = !!(order && order !== 'as-written');
|
||||
// Check order
|
||||
if (Array.isArray(memberTypes)) {
|
||||
const grouped = checkGroupSort(memberSet, memberTypes, supportsModifiers);
|
||||
if (grouped == null) {
|
||||
return false;
|
||||
}
|
||||
if (hasAlphaSort) {
|
||||
return !grouped.some(groupMember => !checkAlphaSort(groupMember, order));
|
||||
}
|
||||
}
|
||||
else if (hasAlphaSort) {
|
||||
return checkAlphaSort(memberSet, order);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (Array.isArray(orderConfig)) {
|
||||
memberTypes = orderConfig;
|
||||
}
|
||||
else {
|
||||
order = orderConfig.order;
|
||||
memberTypes = orderConfig.memberTypes;
|
||||
optionalityOrder = orderConfig.optionalityOrder;
|
||||
}
|
||||
if (!optionalityOrder) {
|
||||
checkOrder(members);
|
||||
return;
|
||||
}
|
||||
const switchIndex = members.findIndex((member, i) => i && isMemberOptional(member) !== isMemberOptional(members[i - 1]));
|
||||
if (switchIndex !== -1) {
|
||||
if (!checkRequiredOrder(members, optionalityOrder)) {
|
||||
return;
|
||||
}
|
||||
checkOrder(members.slice(0, switchIndex));
|
||||
checkOrder(members.slice(switchIndex));
|
||||
}
|
||||
else {
|
||||
checkOrder(members);
|
||||
}
|
||||
}
|
||||
return {
|
||||
ClassDeclaration(node) {
|
||||
validateMembersOrder(node.body.body, options.classes ?? options.default, true);
|
||||
},
|
||||
ClassExpression(node) {
|
||||
validateMembersOrder(node.body.body, options.classExpressions ?? options.default, true);
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
validateMembersOrder(node.body.body, options.interfaces ?? options.default, false);
|
||||
},
|
||||
TSTypeLiteral(node) {
|
||||
validateMembersOrder(node.members, options.typeLiterals ?? options.default, false);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=member-ordering.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
181
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js
generated
vendored
Normal file
181
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'method-signature-style',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce using a particular method signature syntax',
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
errorMethod: 'Shorthand method signature is forbidden. Use a function property instead.',
|
||||
errorProperty: 'Function property signature is forbidden. Use a method shorthand instead.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'string',
|
||||
enum: ['property', 'method'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['property'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
|
||||
function getMethodKey(node) {
|
||||
let key = sourceCode.getText(node.key);
|
||||
if (node.computed) {
|
||||
key = `[${key}]`;
|
||||
}
|
||||
if (node.optional) {
|
||||
key = `${key}?`;
|
||||
}
|
||||
if (node.readonly) {
|
||||
key = `readonly ${key}`;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
function getMethodParams(node) {
|
||||
let params = '()';
|
||||
if (node.params.length > 0) {
|
||||
const openingParen = (0, util_1.nullThrows)(sourceCode.getTokenBefore(node.params[0], util_1.isOpeningParenToken), 'Missing opening paren before first parameter');
|
||||
const closingParen = (0, util_1.nullThrows)(sourceCode.getTokenAfter(node.params[node.params.length - 1], util_1.isClosingParenToken), 'Missing closing paren after last parameter');
|
||||
params = sourceCode.text.substring(openingParen.range[0], closingParen.range[1]);
|
||||
}
|
||||
if (node.typeParameters != null) {
|
||||
const typeParams = sourceCode.getText(node.typeParameters);
|
||||
params = `${typeParams}${params}`;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
function getMethodReturnType(node) {
|
||||
return node.returnType == null
|
||||
? // if the method has no return type, it implicitly has an `any` return type
|
||||
// we just make it explicit here so we can do the fix
|
||||
'any'
|
||||
: sourceCode.getText(node.returnType.typeAnnotation);
|
||||
}
|
||||
function getDelimiter(node) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (lastToken &&
|
||||
((0, util_1.isSemicolonToken)(lastToken) || (0, util_1.isCommaToken)(lastToken))) {
|
||||
return lastToken.value;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function isNodeParentModuleDeclaration(node) {
|
||||
if (!node.parent) {
|
||||
return false;
|
||||
}
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration) {
|
||||
return true;
|
||||
}
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.Program) {
|
||||
return false;
|
||||
}
|
||||
return isNodeParentModuleDeclaration(node.parent);
|
||||
}
|
||||
return {
|
||||
...(mode === 'property' && {
|
||||
TSMethodSignature(methodNode) {
|
||||
if (methodNode.kind !== 'method') {
|
||||
return;
|
||||
}
|
||||
const parent = methodNode.parent;
|
||||
const members = parent.type === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
||||
? parent.body
|
||||
: parent.type === utils_1.AST_NODE_TYPES.TSTypeLiteral
|
||||
? parent.members
|
||||
: [];
|
||||
const duplicatedKeyMethodNodes = members.filter((element) => element.type === utils_1.AST_NODE_TYPES.TSMethodSignature &&
|
||||
element !== methodNode &&
|
||||
getMethodKey(element) === getMethodKey(methodNode));
|
||||
const isParentModule = isNodeParentModuleDeclaration(methodNode);
|
||||
if (duplicatedKeyMethodNodes.length > 0) {
|
||||
if (isParentModule) {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
*fix(fixer) {
|
||||
const methodNodes = [
|
||||
methodNode,
|
||||
...duplicatedKeyMethodNodes,
|
||||
].sort((a, b) => (a.range[0] < b.range[0] ? -1 : 1));
|
||||
const typeString = methodNodes
|
||||
.map(node => {
|
||||
const params = getMethodParams(node);
|
||||
const returnType = getMethodReturnType(node);
|
||||
return `(${params} => ${returnType})`;
|
||||
})
|
||||
.join(' & ');
|
||||
const key = getMethodKey(methodNode);
|
||||
const delimiter = getDelimiter(methodNode);
|
||||
yield fixer.replaceText(methodNode, `${key}: ${typeString}${delimiter}`);
|
||||
for (const node of duplicatedKeyMethodNodes) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (lastToken) {
|
||||
const nextToken = sourceCode.getTokenAfter(lastToken);
|
||||
if (nextToken) {
|
||||
yield fixer.remove(node);
|
||||
yield fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], '');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isParentModule) {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
fix: fixer => {
|
||||
const key = getMethodKey(methodNode);
|
||||
const params = getMethodParams(methodNode);
|
||||
const returnType = getMethodReturnType(methodNode);
|
||||
const delimiter = getDelimiter(methodNode);
|
||||
return fixer.replaceText(methodNode, `${key}: ${params} => ${returnType}${delimiter}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
...(mode === 'method' && {
|
||||
TSPropertySignature(propertyNode) {
|
||||
const typeNode = propertyNode.typeAnnotation?.typeAnnotation;
|
||||
if (typeNode?.type !== utils_1.AST_NODE_TYPES.TSFunctionType) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: propertyNode,
|
||||
messageId: 'errorProperty',
|
||||
fix: fixer => {
|
||||
const key = getMethodKey(propertyNode);
|
||||
const params = getMethodParams(typeNode);
|
||||
const returnType = getMethodReturnType(typeNode);
|
||||
const delimiter = getDelimiter(propertyNode);
|
||||
return fixer.replaceText(propertyNode, `${key}${params}: ${returnType}${delimiter}`);
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=method-signature-style.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/method-signature-style.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
101
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js
generated
vendored
Normal file
101
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UnderscoreOptions = exports.TypeModifiers = exports.Selectors = exports.PredefinedFormats = exports.Modifiers = exports.MetaSelectors = void 0;
|
||||
var PredefinedFormats;
|
||||
(function (PredefinedFormats) {
|
||||
PredefinedFormats[PredefinedFormats["camelCase"] = 1] = "camelCase";
|
||||
PredefinedFormats[PredefinedFormats["strictCamelCase"] = 2] = "strictCamelCase";
|
||||
PredefinedFormats[PredefinedFormats["PascalCase"] = 3] = "PascalCase";
|
||||
PredefinedFormats[PredefinedFormats["StrictPascalCase"] = 4] = "StrictPascalCase";
|
||||
PredefinedFormats[PredefinedFormats["snake_case"] = 5] = "snake_case";
|
||||
PredefinedFormats[PredefinedFormats["UPPER_CASE"] = 6] = "UPPER_CASE";
|
||||
})(PredefinedFormats || (exports.PredefinedFormats = PredefinedFormats = {}));
|
||||
var UnderscoreOptions;
|
||||
(function (UnderscoreOptions) {
|
||||
UnderscoreOptions[UnderscoreOptions["forbid"] = 1] = "forbid";
|
||||
UnderscoreOptions[UnderscoreOptions["allow"] = 2] = "allow";
|
||||
UnderscoreOptions[UnderscoreOptions["require"] = 3] = "require";
|
||||
// special cases as it's common practice to use double underscore
|
||||
UnderscoreOptions[UnderscoreOptions["requireDouble"] = 4] = "requireDouble";
|
||||
UnderscoreOptions[UnderscoreOptions["allowDouble"] = 5] = "allowDouble";
|
||||
UnderscoreOptions[UnderscoreOptions["allowSingleOrDouble"] = 6] = "allowSingleOrDouble";
|
||||
})(UnderscoreOptions || (exports.UnderscoreOptions = UnderscoreOptions = {}));
|
||||
var Selectors;
|
||||
(function (Selectors) {
|
||||
// variableLike
|
||||
Selectors[Selectors["variable"] = 1] = "variable";
|
||||
Selectors[Selectors["function"] = 2] = "function";
|
||||
Selectors[Selectors["parameter"] = 4] = "parameter";
|
||||
// memberLike
|
||||
Selectors[Selectors["parameterProperty"] = 8] = "parameterProperty";
|
||||
Selectors[Selectors["accessor"] = 16] = "accessor";
|
||||
Selectors[Selectors["enumMember"] = 32] = "enumMember";
|
||||
Selectors[Selectors["classMethod"] = 64] = "classMethod";
|
||||
Selectors[Selectors["objectLiteralMethod"] = 128] = "objectLiteralMethod";
|
||||
Selectors[Selectors["typeMethod"] = 256] = "typeMethod";
|
||||
Selectors[Selectors["classProperty"] = 512] = "classProperty";
|
||||
Selectors[Selectors["objectLiteralProperty"] = 1024] = "objectLiteralProperty";
|
||||
Selectors[Selectors["typeProperty"] = 2048] = "typeProperty";
|
||||
// typeLike
|
||||
Selectors[Selectors["class"] = 4096] = "class";
|
||||
Selectors[Selectors["interface"] = 8192] = "interface";
|
||||
Selectors[Selectors["typeAlias"] = 16384] = "typeAlias";
|
||||
Selectors[Selectors["enum"] = 32768] = "enum";
|
||||
Selectors[Selectors["typeParameter"] = 131072] = "typeParameter";
|
||||
// other
|
||||
Selectors[Selectors["import"] = 262144] = "import";
|
||||
})(Selectors || (exports.Selectors = Selectors = {}));
|
||||
var MetaSelectors;
|
||||
(function (MetaSelectors) {
|
||||
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
|
||||
MetaSelectors[MetaSelectors["default"] = -1] = "default";
|
||||
MetaSelectors[MetaSelectors["variableLike"] = 7] = "variableLike";
|
||||
MetaSelectors[MetaSelectors["memberLike"] = 4088] = "memberLike";
|
||||
MetaSelectors[MetaSelectors["typeLike"] = 192512] = "typeLike";
|
||||
MetaSelectors[MetaSelectors["method"] = 448] = "method";
|
||||
MetaSelectors[MetaSelectors["property"] = 3584] = "property";
|
||||
/* eslint-enable @typescript-eslint/prefer-literal-enum-member */
|
||||
})(MetaSelectors || (exports.MetaSelectors = MetaSelectors = {}));
|
||||
var Modifiers;
|
||||
(function (Modifiers) {
|
||||
// const variable
|
||||
Modifiers[Modifiers["const"] = 1] = "const";
|
||||
// readonly members
|
||||
Modifiers[Modifiers["readonly"] = 2] = "readonly";
|
||||
// static members
|
||||
Modifiers[Modifiers["static"] = 4] = "static";
|
||||
// member accessibility
|
||||
Modifiers[Modifiers["public"] = 8] = "public";
|
||||
Modifiers[Modifiers["protected"] = 16] = "protected";
|
||||
Modifiers[Modifiers["private"] = 32] = "private";
|
||||
Modifiers[Modifiers["#private"] = 64] = "#private";
|
||||
Modifiers[Modifiers["abstract"] = 128] = "abstract";
|
||||
// destructured variable
|
||||
Modifiers[Modifiers["destructured"] = 256] = "destructured";
|
||||
// variables declared in the top-level scope
|
||||
Modifiers[Modifiers["global"] = 512] = "global";
|
||||
// things that are exported
|
||||
Modifiers[Modifiers["exported"] = 1024] = "exported";
|
||||
// things that are unused
|
||||
Modifiers[Modifiers["unused"] = 2048] = "unused";
|
||||
// properties that require quoting
|
||||
Modifiers[Modifiers["requiresQuotes"] = 4096] = "requiresQuotes";
|
||||
// class members that are overridden
|
||||
Modifiers[Modifiers["override"] = 8192] = "override";
|
||||
// class methods, object function properties, or functions that are async via the `async` keyword
|
||||
Modifiers[Modifiers["async"] = 16384] = "async";
|
||||
// default imports
|
||||
Modifiers[Modifiers["default"] = 32768] = "default";
|
||||
// namespace imports
|
||||
Modifiers[Modifiers["namespace"] = 65536] = "namespace";
|
||||
// make sure TypeModifiers starts at Modifiers + 1 or else sorting won't work
|
||||
})(Modifiers || (exports.Modifiers = Modifiers = {}));
|
||||
var TypeModifiers;
|
||||
(function (TypeModifiers) {
|
||||
TypeModifiers[TypeModifiers["boolean"] = 131072] = "boolean";
|
||||
TypeModifiers[TypeModifiers["string"] = 262144] = "string";
|
||||
TypeModifiers[TypeModifiers["number"] = 524288] = "number";
|
||||
TypeModifiers[TypeModifiers["function"] = 1048576] = "function";
|
||||
TypeModifiers[TypeModifiers["array"] = 2097152] = "array";
|
||||
})(TypeModifiers || (exports.TypeModifiers = TypeModifiers = {}));
|
||||
//# sourceMappingURL=enums.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/enums.ts"],"names":[],"mappings":";;;AAAA,IAAK,iBAOJ;AAPD,WAAK,iBAAiB;IACpB,mEAAa,CAAA;IACb,+EAAe,CAAA;IACf,qEAAU,CAAA;IACV,iFAAgB,CAAA;IAChB,qEAAU,CAAA;IACV,qEAAU,CAAA;AACZ,CAAC,EAPI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AA;IACjB,wBAAwB;IACxB,2DAAqB,CAAA;IACrB,4CAA4C;IAC5C,+CAAe,CAAA;IACf,2BAA2B;IAC3B,oDAAkB,CAAA;IAClB,yBAAyB;IACzB,gDAAgB,CAAA;IAChB,kCAAkC;IAClC,gEAAwB,CAAA;IACxB,oCAAoC;IACpC,oDAAkB,CAAA;IAClB,iGAAiG;IACjG,+CAAe,CAAA;IACf,kBAAkB;IAClB,mDAAiB,CAAA;IACjB,oBAAoB;IACpB,uDAAmB,CAAA;IAEnB,6EAA6E;AAC/E,CAAC,EAjCI,SAAS,yBAAT,SAAS,QAiCb;AAGD,IAAK,aAMJ;AAND,WAAK,aAAa;IAChB,4DAAiB,CAAA;IACjB,0DAAgB,CAAA;IAChB,0DAAgB,CAAA;IAChB,+DAAkB,CAAA;IAClB,yDAAe,CAAA;AACjB,CAAC,EANI,aAAa,6BAAb,aAAa,QAMjB"}
|
91
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js
generated
vendored
Normal file
91
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PredefinedFormatToCheckFunction = void 0;
|
||||
const enums_1 = require("./enums");
|
||||
/*
|
||||
These format functions are taken from `tslint-consistent-codestyle/naming-convention`:
|
||||
https://github.com/ajafff/tslint-consistent-codestyle/blob/ab156cc8881bcc401236d999f4ce034b59039e81/rules/namingConventionRule.ts#L603-L645
|
||||
|
||||
The license for the code can be viewed here:
|
||||
https://github.com/ajafff/tslint-consistent-codestyle/blob/ab156cc8881bcc401236d999f4ce034b59039e81/LICENSE
|
||||
*/
|
||||
/*
|
||||
Why not regex here? Because it's actually really, really difficult to create a regex to handle
|
||||
all of the unicode cases, and we have many non-english users that use non-english characters.
|
||||
https://gist.github.com/mathiasbynens/6334847
|
||||
*/
|
||||
function isPascalCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toUpperCase() && !name.includes('_')));
|
||||
}
|
||||
function isStrictPascalCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toUpperCase() && hasStrictCamelHumps(name, true)));
|
||||
}
|
||||
function isCamelCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toLowerCase() && !name.includes('_')));
|
||||
}
|
||||
function isStrictCamelCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name[0] === name[0].toLowerCase() && hasStrictCamelHumps(name, false)));
|
||||
}
|
||||
function hasStrictCamelHumps(name, isUpper) {
|
||||
function isUppercaseChar(char) {
|
||||
return char === char.toUpperCase() && char !== char.toLowerCase();
|
||||
}
|
||||
if (name.startsWith('_')) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 1; i < name.length; ++i) {
|
||||
if (name[i] === '_') {
|
||||
return false;
|
||||
}
|
||||
if (isUpper === isUppercaseChar(name[i])) {
|
||||
if (isUpper) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
isUpper = !isUpper;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isSnakeCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name === name.toLowerCase() && validateUnderscores(name)));
|
||||
}
|
||||
function isUpperCase(name) {
|
||||
return (name.length === 0 ||
|
||||
(name === name.toUpperCase() && validateUnderscores(name)));
|
||||
}
|
||||
/** Check for leading trailing and adjacent underscores */
|
||||
function validateUnderscores(name) {
|
||||
if (name.startsWith('_')) {
|
||||
return false;
|
||||
}
|
||||
let wasUnderscore = false;
|
||||
for (let i = 1; i < name.length; ++i) {
|
||||
if (name[i] === '_') {
|
||||
if (wasUnderscore) {
|
||||
return false;
|
||||
}
|
||||
wasUnderscore = true;
|
||||
}
|
||||
else {
|
||||
wasUnderscore = false;
|
||||
}
|
||||
}
|
||||
return !wasUnderscore;
|
||||
}
|
||||
const PredefinedFormatToCheckFunction = {
|
||||
[enums_1.PredefinedFormats.PascalCase]: isPascalCase,
|
||||
[enums_1.PredefinedFormats.StrictPascalCase]: isStrictPascalCase,
|
||||
[enums_1.PredefinedFormats.camelCase]: isCamelCase,
|
||||
[enums_1.PredefinedFormats.strictCamelCase]: isStrictCamelCase,
|
||||
[enums_1.PredefinedFormats.UPPER_CASE]: isUpperCase,
|
||||
[enums_1.PredefinedFormats.snake_case]: isSnakeCase,
|
||||
};
|
||||
exports.PredefinedFormatToCheckFunction = PredefinedFormatToCheckFunction;
|
||||
//# sourceMappingURL=format.js.map
|
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js.map
generated
vendored
Normal file
1
node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/format.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/format.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAE5C;;;;;;EAME;AAEF;;;;EAIE;AAEF,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC;AACD,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CACvE,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAA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CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,EAAE,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAC3D,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACpB,IAAI,aAAa,EAAE,CAAC;gBAClB,OAAO,KAAK,CAAC;YACf,CAAC;YACD,aAAa,GAAG,IAAI,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,aAAa,CAAC;AACxB,CAAC;AAED,MAAM,+BAA+B,GAEjC;IACF,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,YAAY;IAC5C,CAAC,yBAAiB,CAAC,gBAAgB,CAAC,EAAE,kBAAkB;IACxD,CAAC,yBAAiB,CAAC,SAAS,CAAC,EAAE,WAAW;IAC1C,CAAC,yBAAiB,CAAC,eAAe,CAAC,EAAE,iBAAiB;IACtD,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW;IAC3C,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW;CAC5C,CAAC;AAEO,0EAA+B"}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user