mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Update checked-in dependencies
This commit is contained in:
2
node_modules/.bin/prettier
generated
vendored
2
node_modules/.bin/prettier
generated
vendored
@@ -1 +1 @@
|
||||
../prettier/bin-prettier.js
|
||||
../prettier/bin/prettier.cjs
|
||||
277
node_modules/.package-lock.json
generated
vendored
277
node_modules/.package-lock.json
generated
vendored
@@ -804,9 +804,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@schemastore/package": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@schemastore/package/-/package-0.0.8.tgz",
|
||||
"integrity": "sha512-1jMrmFLUZBeQ7zdxe3ez1LSLYrUH4eY3gAPisW1rbNZ62zoYy8sudo9fXSS182s8f7p6TRy7wD6ybZvz9SUT1Q=="
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@schemastore/package/-/package-0.0.10.tgz",
|
||||
"integrity": "sha512-D3LxMCnkgsb4LO5sDKf6E+yahM2SqpEHmkqMPDSJis5Cy/j2MgWo/g/iq0lECK0mrPWfx3hqKm2ZJlqxwbRJQA=="
|
||||
},
|
||||
"node_modules/@sinonjs/samsam": {
|
||||
"version": "8.0.0",
|
||||
@@ -2613,14 +2613,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github": {
|
||||
"version": "4.9.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-4.9.0.tgz",
|
||||
"integrity": "sha512-c4jnJXJzHy8lzdYjOXlXcY7jX4b2ciGh+ugZM5b6vs6q2+m+6BrNl20u5WxloJvH6Q8CbZ0+Lnh7lDJxUd3WkQ==",
|
||||
"version": "4.9.2",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-4.9.2.tgz",
|
||||
"integrity": "sha512-osez6Sio/fLr/3QkW5HE1wbCOcmYG5030/6QIa9IcKyyfchewlecdnYcsbeUMUtdIiU9lWqhroQp2H/O7auxBA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@github/browserslist-config": "^1.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.1.0",
|
||||
"@typescript-eslint/parser": "^5.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"aria-query": "^5.3.0",
|
||||
"eslint-config-prettier": ">=8.0.0",
|
||||
"eslint-plugin-escompat": "^3.3.3",
|
||||
@@ -2630,10 +2630,10 @@
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-plugin-jsx-a11y": "^6.7.1",
|
||||
"eslint-plugin-no-only-tests": "^3.0.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-rule-documentation": ">=1.0.0",
|
||||
"jsx-ast-utils": "^3.3.2",
|
||||
"prettier": "^2.2.1",
|
||||
"prettier": "^3.0.0",
|
||||
"svg-element-attributes": "^1.3.1"
|
||||
},
|
||||
"bin": {
|
||||
@@ -2643,194 +2643,6 @@
|
||||
"eslint": "^8.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz",
|
||||
"integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "5.62.0",
|
||||
"@typescript-eslint/type-utils": "5.62.0",
|
||||
"@typescript-eslint/utils": "5.62.0",
|
||||
"debug": "^4.3.4",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.2.0",
|
||||
"natural-compare-lite": "^1.4.0",
|
||||
"semver": "^7.3.7",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/parser": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz",
|
||||
"integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "5.62.0",
|
||||
"@typescript-eslint/types": "5.62.0",
|
||||
"@typescript-eslint/typescript-estree": "5.62.0",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz",
|
||||
"integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.62.0",
|
||||
"@typescript-eslint/visitor-keys": "5.62.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz",
|
||||
"integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "5.62.0",
|
||||
"@typescript-eslint/utils": "5.62.0",
|
||||
"debug": "^4.3.4",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/types": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz",
|
||||
"integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz",
|
||||
"integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.62.0",
|
||||
"@typescript-eslint/visitor-keys": "5.62.0",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"semver": "^7.3.7",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/utils": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz",
|
||||
"integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"@types/semver": "^7.3.12",
|
||||
"@typescript-eslint/scope-manager": "5.62.0",
|
||||
"@typescript-eslint/types": "5.62.0",
|
||||
"@typescript-eslint/typescript-estree": "5.62.0",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"semver": "^7.3.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-github/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "5.62.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz",
|
||||
"integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.62.0",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-i18n-text": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-i18n-text/-/eslint-plugin-i18n-text-1.0.1.tgz",
|
||||
@@ -2953,21 +2765,29 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-prettier": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz",
|
||||
"integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==",
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz",
|
||||
"integrity": "sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"prettier-linter-helpers": "^1.0.0"
|
||||
"prettier-linter-helpers": "^1.0.0",
|
||||
"synckit": "^0.8.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/prettier"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=7.28.0",
|
||||
"prettier": ">=2.0.0"
|
||||
"@types/eslint": ">=8.0.0",
|
||||
"eslint": ">=8.0.0",
|
||||
"prettier": ">=3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/eslint": {
|
||||
"optional": true
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"optional": true
|
||||
}
|
||||
@@ -2981,19 +2801,6 @@
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-scope": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"esrecurse": "^4.3.0",
|
||||
"estraverse": "^4.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-visitor-keys": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz",
|
||||
@@ -3267,15 +3074,6 @@
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/estraverse": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
|
||||
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
@@ -5138,15 +4936,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz",
|
||||
"integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz",
|
||||
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
@@ -6037,21 +5835,6 @@
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
},
|
||||
"node_modules/tsutils": {
|
||||
"version": "3.21.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
|
||||
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"tslib": "^1.8.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
||||
}
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
|
||||
28
node_modules/@schemastore/package/README.md
generated
vendored
28
node_modules/@schemastore/package/README.md
generated
vendored
@@ -1,12 +1,28 @@
|
||||
# Installation
|
||||
> `npm install --save @schemastore/package`
|
||||
# Type definitions for package
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm i @schemastore/package
|
||||
yarn add @schemastore/package
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for package.
|
||||
|
||||
## Details
|
||||
Files were exported from https://github.com/ffflorian/schemastore-updater/tree/main/schemas/package.
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import * as package from '@schemastore/package';
|
||||
```
|
||||
|
||||
## Note
|
||||
|
||||
The definitions were auto-generated by [schemastore-updater](https://github.com/ffflorian/schemastore-updater) using [`json-schema-to-typescript`](https://www.npmjs.com/package/json-schema-to-typescript).
|
||||
|
||||
## Additional Details
|
||||
* Last updated: Fri, Feb 24, 2023, 21:03:09 GMT
|
||||
|
||||
* [Schema source](https://github.com/SchemaStore/schemastore/tree/master/src/schemas/json/package)
|
||||
* Last updated: Fri, Jun 30, 2023, 21:04:02 GMT
|
||||
* Dependencies: none
|
||||
|
||||
18
node_modules/@schemastore/package/index.d.ts
generated
vendored
18
node_modules/@schemastore/package/index.d.ts
generated
vendored
@@ -15343,11 +15343,17 @@ export interface JSONSchemaForNPMPackageJsonFiles2 {
|
||||
*/
|
||||
bundleDependencies?: string[] | boolean;
|
||||
/**
|
||||
* Resolutions is used to support selective version resolutions, which lets you define custom package versions or ranges inside your dependencies. See: https://classic.yarnpkg.com/en/docs/selective-version-resolutions
|
||||
* Resolutions is used to support selective version resolutions using yarn, which lets you define custom package versions or ranges inside your dependencies. For npm, use overrides instead. See: https://classic.yarnpkg.com/en/docs/selective-version-resolutions
|
||||
*/
|
||||
resolutions?: {
|
||||
[k: string]: unknown | undefined;
|
||||
};
|
||||
/**
|
||||
* Overrides is used to support selective version overrides using npm, which lets you define custom package versions or ranges inside your dependencies. For yarn, use resolutions instead. See: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides
|
||||
*/
|
||||
overrides?: {
|
||||
[k: string]: unknown | undefined;
|
||||
};
|
||||
/**
|
||||
* Defines which package manager is expected to be used when working on the current project. This field is currently experimental and needs to be opted-in; see https://nodejs.org/api/corepack.html
|
||||
*/
|
||||
@@ -15450,6 +15456,10 @@ export interface PackageExportsEntryObject {
|
||||
* The module path that is resolved when no other export type matches.
|
||||
*/
|
||||
default?: PackageExportsEntry | PackageExportsFallback;
|
||||
/**
|
||||
* The module path that is resolved for TypeScript types when this specifier is imported. Should be listed before other conditions.
|
||||
*/
|
||||
types?: PackageExportsEntry | PackageExportsFallback;
|
||||
/**
|
||||
* The module path that is resolved when this environment matches the property name.
|
||||
*
|
||||
@@ -15481,6 +15491,10 @@ export interface PackageExportsEntryObject1 {
|
||||
* The module path that is resolved when no other export type matches.
|
||||
*/
|
||||
default?: PackageExportsEntry | PackageExportsFallback;
|
||||
/**
|
||||
* The module path that is resolved for TypeScript types when this specifier is imported. Should be listed before other conditions.
|
||||
*/
|
||||
types?: PackageExportsEntry | PackageExportsFallback;
|
||||
/**
|
||||
* The module path that is resolved when this environment matches the property name.
|
||||
*
|
||||
@@ -17440,7 +17454,7 @@ export interface Block {
|
||||
);
|
||||
"block-closing-brace-newline-after"?: NewlineSpaceWithIgnoreRule;
|
||||
"block-closing-brace-newline-before"?: NewlineRule;
|
||||
"block-closing-brace-space-afte"?: NewlineSpaceRule;
|
||||
"block-closing-brace-space-after"?: NewlineSpaceRule;
|
||||
"block-closing-brace-space-before"?: NewlineSpaceRule1;
|
||||
"block-no-empty"?: BooleanRule1;
|
||||
"block-no-single-line"?: BooleanRule2;
|
||||
|
||||
4
node_modules/@schemastore/package/package.json
generated
vendored
4
node_modules/@schemastore/package/package.json
generated
vendored
@@ -9,6 +9,6 @@
|
||||
"scripts": {},
|
||||
"typeScriptVersion": "2.2",
|
||||
"types": "index.d.ts",
|
||||
"typesPublisherContentHash": "4643ec01eaaf150d3302a3fd1e3e3cb7329b192ebec86d0660777a13c741c6b7",
|
||||
"version": "0.0.8"
|
||||
"typesPublisherContentHash": "706ba9014643c594ac6ab92494abf9e4a452b9fe9ab42b75d159300ddf0ee64e",
|
||||
"version": "0.0.10"
|
||||
}
|
||||
8
node_modules/eslint-plugin-github/lib/configs/react.js
generated
vendored
8
node_modules/eslint-plugin-github/lib/configs/react.js
generated
vendored
@@ -22,5 +22,13 @@ module.exports = {
|
||||
words: ['this', 'more', 'read here', 'read more'],
|
||||
},
|
||||
],
|
||||
'jsx-a11y/no-interactive-element-to-noninteractive-role': [
|
||||
'error',
|
||||
{
|
||||
tr: ['none', 'presentation'],
|
||||
td: ['cell'], // TODO: Remove once https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/937#issuecomment-1638128318 is addressed.
|
||||
canvas: ['img'],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
2
node_modules/eslint-plugin-github/lib/rules/a11y-no-title-attribute.js
generated
vendored
2
node_modules/eslint-plugin-github/lib/rules/a11y-no-title-attribute.js
generated
vendored
@@ -50,7 +50,7 @@ module.exports = {
|
||||
create(context) {
|
||||
return {
|
||||
JSXElement: node => {
|
||||
const elementType = getElementType(context, node.openingElement)
|
||||
const elementType = getElementType(context, node.openingElement, true)
|
||||
if (elementType !== `iframe` && ifSemanticElement(context, node)) {
|
||||
const titleProp = getPropValue(getProp(node.openingElement.attributes, `title`))
|
||||
if (titleProp) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const {getProp, getPropValue} = require('jsx-ast-utils')
|
||||
const {getProp, getLiteralPropValue} = require('jsx-ast-utils')
|
||||
const {getElementType} = require('../utils/get-element-type')
|
||||
const {generateObjSchema} = require('eslint-plugin-jsx-a11y/lib/util/schemas')
|
||||
|
||||
@@ -32,9 +32,12 @@ const checkIfInteractiveElement = (context, node) => {
|
||||
const checkIfVisuallyHiddenAndInteractive = (context, options, node, isParentVisuallyHidden) => {
|
||||
const {className, componentName} = options
|
||||
if (node.type === 'JSXElement') {
|
||||
const classes = getPropValue(getProp(node.openingElement.attributes, 'className'))
|
||||
const classes = getLiteralPropValue(getProp(node.openingElement.attributes, 'className'))
|
||||
const isVisuallyHiddenElement = node.openingElement.name.name === componentName
|
||||
const hasSROnlyClass = typeof classes !== 'undefined' && classes.includes(className)
|
||||
let hasSROnlyClass = false
|
||||
if (classes != null) {
|
||||
hasSROnlyClass = classes.includes(className)
|
||||
}
|
||||
let isHidden = false
|
||||
if (hasSROnlyClass || isVisuallyHiddenElement || !!isParentVisuallyHidden) {
|
||||
if (checkIfInteractiveElement(context, node)) {
|
||||
|
||||
4
node_modules/eslint-plugin-github/lib/rules/no-innerText.js
generated
vendored
4
node_modules/eslint-plugin-github/lib/rules/no-innerText.js
generated
vendored
@@ -12,6 +12,10 @@ module.exports = {
|
||||
create(context) {
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
// If the member expression is part of a call expression like `.innerText()` then it is not the same
|
||||
// as the `Element.innerText` property, and should not trigger a warning
|
||||
if (node.parent.type === 'CallExpression') return
|
||||
|
||||
if (node.property && node.property.name === 'innerText') {
|
||||
context.report({
|
||||
meta: {
|
||||
|
||||
12
node_modules/eslint-plugin-github/lib/utils/get-element-type.js
generated
vendored
12
node_modules/eslint-plugin-github/lib/utils/get-element-type.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
const {elementType, getProp, getPropValue} = require('jsx-ast-utils')
|
||||
const {elementType, getProp, getLiteralPropValue} = require('jsx-ast-utils')
|
||||
|
||||
/*
|
||||
Allows custom component to be mapped to an element type.
|
||||
@@ -7,15 +7,19 @@ If a prop determines the type, it can be specified with `props`.
|
||||
|
||||
For now, we only support the mapping of one prop type to an element type, rather than combinations of props.
|
||||
*/
|
||||
function getElementType(context, node, ignoreMap = false) {
|
||||
function getElementType(context, node, lazyElementCheck = false) {
|
||||
const {settings} = context
|
||||
|
||||
if (lazyElementCheck) {
|
||||
return elementType(node)
|
||||
}
|
||||
|
||||
// check if the node contains a polymorphic prop
|
||||
const polymorphicPropName = settings?.github?.polymorphicPropName ?? 'as'
|
||||
const rawElement = getPropValue(getProp(node.attributes, polymorphicPropName)) ?? elementType(node)
|
||||
const rawElement = getLiteralPropValue(getProp(node.attributes, polymorphicPropName)) ?? elementType(node)
|
||||
|
||||
// if a component configuration does not exists, return the raw element
|
||||
if (ignoreMap || !settings?.github?.components?.[rawElement]) return rawElement
|
||||
if (!settings?.github?.components?.[rawElement]) return rawElement
|
||||
|
||||
const defaultComponent = settings.github.components[rawElement]
|
||||
|
||||
|
||||
10
node_modules/eslint-plugin-github/lib/utils/get-role.js
generated
vendored
10
node_modules/eslint-plugin-github/lib/utils/get-role.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
const {getProp, getPropValue} = require('jsx-ast-utils')
|
||||
const {getProp, getLiteralPropValue} = require('jsx-ast-utils')
|
||||
const {elementRoles} = require('aria-query')
|
||||
const {getElementType} = require('./get-element-type')
|
||||
const ObjectMap = require('./object-map')
|
||||
@@ -43,7 +43,7 @@ function cleanElementRolesMap() {
|
||||
*/
|
||||
function getRole(context, node) {
|
||||
// Early return if role is explicitly set
|
||||
const explicitRole = getPropValue(getProp(node.attributes, 'role'))
|
||||
const explicitRole = getLiteralPropValue(getProp(node.attributes, 'role'))
|
||||
if (explicitRole) {
|
||||
return explicitRole
|
||||
}
|
||||
@@ -80,8 +80,8 @@ function getRole(context, node) {
|
||||
continue
|
||||
}
|
||||
|
||||
const value = getPropValue(propOnNode)
|
||||
if (value || (value === '' && prop === 'alt')) {
|
||||
const value = getLiteralPropValue(propOnNode)
|
||||
if (propOnNode) {
|
||||
if (
|
||||
prop === 'href' ||
|
||||
prop === 'aria-labelledby' ||
|
||||
@@ -90,7 +90,7 @@ function getRole(context, node) {
|
||||
(prop === 'alt' && value !== '')
|
||||
) {
|
||||
key.attributes.push({name: prop, constraints: ['set']})
|
||||
} else {
|
||||
} else if (value || (value === '' && prop === 'alt')) {
|
||||
key.attributes.push({name: prop, value})
|
||||
}
|
||||
}
|
||||
|
||||
21
node_modules/eslint-plugin-github/node_modules/@typescript-eslint/eslint-plugin/LICENSE
generated
vendored
21
node_modules/eslint-plugin-github/node_modules/@typescript-eslint/eslint-plugin/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 typescript-eslint and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,10 +0,0 @@
|
||||
# `@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.
|
||||
@@ -1,182 +0,0 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||
'@typescript-eslint/array-type': 'error',
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
'@typescript-eslint/ban-tslint-comment': 'error',
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'block-spacing': 'off',
|
||||
'@typescript-eslint/block-spacing': 'error',
|
||||
'brace-style': 'off',
|
||||
'@typescript-eslint/brace-style': 'error',
|
||||
'@typescript-eslint/class-literal-property-style': 'error',
|
||||
'comma-dangle': 'off',
|
||||
'@typescript-eslint/comma-dangle': 'error',
|
||||
'comma-spacing': 'off',
|
||||
'@typescript-eslint/comma-spacing': 'error',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'error',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'error',
|
||||
'@typescript-eslint/consistent-type-assertions': 'error',
|
||||
'@typescript-eslint/consistent-type-definitions': 'error',
|
||||
'@typescript-eslint/consistent-type-exports': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': 'error',
|
||||
'default-param-last': 'off',
|
||||
'@typescript-eslint/default-param-last': 'error',
|
||||
'dot-notation': 'off',
|
||||
'@typescript-eslint/dot-notation': 'error',
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
'@typescript-eslint/explicit-member-accessibility': 'error',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
||||
'func-call-spacing': 'off',
|
||||
'@typescript-eslint/func-call-spacing': 'error',
|
||||
indent: 'off',
|
||||
'@typescript-eslint/indent': 'error',
|
||||
'init-declarations': 'off',
|
||||
'@typescript-eslint/init-declarations': 'error',
|
||||
'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',
|
||||
'@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-type-alias': 'error',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
||||
'@typescript-eslint/no-unnecessary-condition': 'error',
|
||||
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
||||
'@typescript-eslint/no-unsafe-argument': 'error',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'error',
|
||||
'@typescript-eslint/no-unsafe-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-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',
|
||||
'@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 +0,0 @@
|
||||
{"version":3,"file":"all.js","sourceRoot":"","sources":["../../src/configs/all.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,+BAA+B,EAAE,OAAO;QACxC,mCAAmC,EAAE,OAAO;QAC5C,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;QAChD,8BAA8B,EAAE,OAAO;QACvC,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,aAAa,EAAE,KAAK;QACpB,gCAAgC,EAAE,OAAO;QACzC,iDAAiD,EAAE,OAAO;QAC1D,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,OAAO;QAC1C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,oDAAoD,EAAE,OAAO;QAC7D,oDAAoD,EAAE,OAAO;QAC7D,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,4CAA4C,EAAE,OA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AAE,OAAO;QAClC,2CAA2C,EAAE,OAAO;QACpD,qBAAqB,EAAE,KAAK;QAC5B,wCAAwC,EAAE,OAAO;QACjD,6BAA6B,EAAE,KAAK;QACpC,gDAAgD,EAAE,OAAO;QACzD,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,+CAA+C,EAAE,OAAO;QACxD,gDAAgD,EAAE,OAAO;QACzD,2CAA2C,EAAE,OAAO;QACpD,4CAA4C,EAAE,OAAO;QACrD,4BAA4B,EAAE,OAAO;QACrC,mCAAmC,EAAE,OAAO;QAC5C,uCAAuC,EAAE,OAAO;KACjD;CACF,CAAC"}
|
||||
@@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: { sourceType: 'module' },
|
||||
plugins: ['@typescript-eslint'],
|
||||
};
|
||||
//# sourceMappingURL=base.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/configs/base.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE;IACvC,OAAO,EAAE,CAAC,oBAAoB,CAAC;CAChC,CAAC"}
|
||||
@@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
|
||||
rules: {
|
||||
'constructor-super': 'off',
|
||||
'getter-return': 'off',
|
||||
'no-const-assign': 'off',
|
||||
'no-dupe-args': 'off',
|
||||
'no-dupe-class-members': 'off',
|
||||
'no-dupe-keys': 'off',
|
||||
'no-func-assign': 'off',
|
||||
'no-import-assign': 'off',
|
||||
'no-new-symbol': 'off',
|
||||
'no-obj-calls': 'off',
|
||||
'no-redeclare': 'off',
|
||||
'no-setter-return': 'off',
|
||||
'no-this-before-super': 'off',
|
||||
'no-undef': 'off',
|
||||
'no-unreachable': 'off',
|
||||
'no-unsafe-negation': 'off',
|
||||
'no-var': 'error',
|
||||
'prefer-const': 'error',
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'valid-typeof': 'off', // ts(2367)
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
//# sourceMappingURL=eslint-recommended.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"eslint-recommended.js","sourceRoot":"","sources":["../../src/configs/eslint-recommended.ts"],"names":[],"mappings":";AAKA,iBAAS;IACP,SAAS,EAAE;QACT;YACE,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;YAC1C,KAAK,EAAE;gBACL,mBAAmB,EAAE,KAAK;gBAC1B,eAAe,EAAE,KAAK;gBACtB,iBAAiB,EAAE,KAAK;gBACxB,cAAc,EAAE,KAAK;gBACrB,uBAAuB,EAAE,KAAK;gBAC9B,cAAc,EAAE,KAAK;gBACrB,gBAAgB,EAAE,KAAK;gBACvB,kBAAkB,EAAE,KAAK;gBACzB,eAAe,EAAE,KAAK;gBACtB,cAAc,EAAE,KAAK;gBACrB,cAAc,EAAE,KAAK;gBACrB,kBAAkB,EAAE,KAAK;gBACzB,sBAAsB,EAAE,KAAK;gBAC7B,UAAU,EAAE,KAAK;gBACjB,gBAAgB,EAAE,KAAK;gBACvB,oBAAoB,EAAE,KAAK;gBAC3B,QAAQ,EAAE,OAAO;gBACjB,cAAc,EAAE,OAAO;gBACvB,oBAAoB,EAAE,OAAO;gBAC7B,eAAe,EAAE,OAAO;gBACxB,cAAc,EAAE,KAAK,EAAE,WAAW;aACnC;SACF;KACF;CACF,CAAC"}
|
||||
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/no-floating-promises': 'error',
|
||||
'@typescript-eslint/no-for-in-array': 'error',
|
||||
'no-implied-eval': 'off',
|
||||
'@typescript-eslint/no-implied-eval': 'error',
|
||||
'@typescript-eslint/no-misused-promises': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/no-unsafe-argument': 'error',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'error',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'error',
|
||||
'@typescript-eslint/no-unsafe-return': 'error',
|
||||
'require-await': 'off',
|
||||
'@typescript-eslint/require-await': 'error',
|
||||
'@typescript-eslint/restrict-plus-operands': 'error',
|
||||
'@typescript-eslint/restrict-template-expressions': 'error',
|
||||
'@typescript-eslint/unbound-method': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=recommended-requiring-type-checking.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"recommended-requiring-type-checking.js","sourceRoot":"","sources":["../../src/configs/recommended-requiring-type-checking.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,mCAAmC,EAAE,OAAO;QAC5C,yCAAyC,EAAE,OAAO;QAClD,oCAAoC,EAAE,OAAO;QAC7C,iBAAiB,EAAE,KAAK;QACxB,oCAAoC,EAAE,OAAO;QAC7C,wCAAwC,EAAE,OAAO;QACjD,kDAAkD,EAAE,OAAO;QAC3D,uCAAuC,EAAE,OAAO;QAChD,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,4CAA4C,EAAE,OAAO;QACrD,qCAAqC,EAAE,OAAO;QAC9C,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,2CAA2C,EAAE,OAAO;QACpD,kDAAkD,EAAE,OAAO;QAC3D,mCAAmC,EAAE,OAAO;KAC7C;CACF,CAAC"}
|
||||
@@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'no-array-constructor': 'off',
|
||||
'@typescript-eslint/no-array-constructor': 'error',
|
||||
'no-empty-function': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'error',
|
||||
'@typescript-eslint/no-empty-interface': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-extra-non-null-assertion': 'error',
|
||||
'no-extra-semi': 'off',
|
||||
'@typescript-eslint/no-extra-semi': 'error',
|
||||
'@typescript-eslint/no-inferrable-types': 'error',
|
||||
'no-loss-of-precision': 'off',
|
||||
'@typescript-eslint/no-loss-of-precision': 'error',
|
||||
'@typescript-eslint/no-misused-new': 'error',
|
||||
'@typescript-eslint/no-namespace': 'error',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
||||
'@typescript-eslint/no-non-null-assertion': 'warn',
|
||||
'@typescript-eslint/no-this-alias': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
|
||||
'no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'warn',
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
'@typescript-eslint/prefer-as-const': 'error',
|
||||
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
||||
'@typescript-eslint/triple-slash-reference': 'error',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=recommended.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,mCAAmC,EAAE,OAAO;QAC5C,8BAA8B,EAAE,OAAO;QACvC,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mBAAmB,EAAE,KAAK;QAC1B,sCAAsC,EAAE,OAAO;QAC/C,uCAAuC,EAAE,OAAO;QAChD,oCAAoC,EAAE,MAAM;QAC5C,gDAAgD,EAAE,OAAO;QACzD,eAAe,EAAE,KAAK;QACtB,kCAAkC,EAAE,OAAO;QAC3C,wCAAwC,EAAE,OAAO;QACjD,sBAAsB,EAAE,KAAK;QAC7B,yCAAyC,EAAE,OAAO;QAClD,mCAAmC,EAAE,OAAO;QAC5C,iCAAiC,EAAE,OAAO;QAC1C,wDAAwD,EAAE,OAAO;QACjE,0CAA0C,EAAE,MAAM;QAClD,kCAAkC,EAAE,OAAO;QAC3C,mDAAmD,EAAE,OAAO;QAC5D,gBAAgB,EAAE,KAAK;QACvB,mCAAmC,EAAE,MAAM;QAC3C,oCAAoC,EAAE,OAAO;QAC7C,oCAAoC,EAAE,OAAO;QAC7C,6CAA6C,EAAE,OAAO;QACtD,2CAA2C,EAAE,OAAO;KACrD;CACF,CAAC"}
|
||||
@@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// YOU CAN REGENERATE IT USING yarn generate:configs
|
||||
module.exports = {
|
||||
extends: ['./configs/base', './configs/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/array-type': 'warn',
|
||||
'@typescript-eslint/ban-tslint-comment': 'warn',
|
||||
'@typescript-eslint/class-literal-property-style': 'warn',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'warn',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'warn',
|
||||
'@typescript-eslint/consistent-type-assertions': 'warn',
|
||||
'@typescript-eslint/consistent-type-definitions': 'warn',
|
||||
'dot-notation': 'off',
|
||||
'@typescript-eslint/dot-notation': 'warn',
|
||||
'@typescript-eslint/no-base-to-string': 'warn',
|
||||
'@typescript-eslint/no-confusing-non-null-assertion': 'warn',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'warn',
|
||||
'@typescript-eslint/no-dynamic-delete': 'warn',
|
||||
'@typescript-eslint/no-extraneous-class': 'warn',
|
||||
'@typescript-eslint/no-invalid-void-type': 'warn',
|
||||
'@typescript-eslint/no-meaningless-void-operator': 'warn',
|
||||
'@typescript-eslint/no-mixed-enums': 'warn',
|
||||
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'warn',
|
||||
'no-throw-literal': 'off',
|
||||
'@typescript-eslint/no-throw-literal': 'warn',
|
||||
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
|
||||
'@typescript-eslint/no-unnecessary-condition': 'warn',
|
||||
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
|
||||
'@typescript-eslint/no-unsafe-declaration-merging': 'warn',
|
||||
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
|
||||
'no-useless-constructor': 'off',
|
||||
'@typescript-eslint/no-useless-constructor': 'warn',
|
||||
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
|
||||
'@typescript-eslint/prefer-for-of': 'warn',
|
||||
'@typescript-eslint/prefer-function-type': 'warn',
|
||||
'@typescript-eslint/prefer-includes': 'warn',
|
||||
'@typescript-eslint/prefer-literal-enum-member': 'warn',
|
||||
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
||||
'@typescript-eslint/prefer-optional-chain': 'warn',
|
||||
'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
|
||||
'@typescript-eslint/prefer-return-this-type': 'warn',
|
||||
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
|
||||
'@typescript-eslint/prefer-ts-expect-error': 'warn',
|
||||
'@typescript-eslint/unified-signatures': 'warn',
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=strict.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/configs/strict.ts"],"names":[],"mappings":";AAAA,wCAAwC;AACxC,gCAAgC;AAChC,oDAAoD;AAEpD,iBAAS;IACP,OAAO,EAAE,CAAC,gBAAgB,EAAE,8BAA8B,CAAC;IAC3D,KAAK,EAAE;QACL,+BAA+B,EAAE,MAAM;QACvC,uCAAuC,EAAE,MAAM;QAC/C,iDAAiD,EAAE,MAAM;QACzD,oDAAoD,EAAE,MAAM;QAC5D,oDAAoD,EAAE,MAAM;QAC5D,+CAA+C,EAAE,MAAM;QACvD,gDAAgD,EAAE,MAAM;QACxD,cAAc,EAAE,KAAK;QACrB,iCAAiC,EAAE,MAAM;QACzC,sCAAsC,EAAE,MAAM;QAC9C,oDAAoD,EAAE,MAAM;QAC5D,6CAA6C,EAAE,MAAM;QACrD,sCAAsC,EAAE,MAAM;QAC9C,wCAAwC,EAAE,MAAM;QAChD,yCAAyC,EAAE,MAAM;QACjD,iDAAiD,EAAE,MAAM;QACzD,mCAAmC,EAAE,MAAM;QAC3C,4DAA4D,EAAE,MAAM;QACpE,kBAAkB,EAAE,KAAK;QACzB,qCAAqC,EAAE,MAAM;QAC7C,2DAA2D,EAAE,MAAM;QACnE,6CAA6C,EAAE,MAAM;QACrD,kDAAkD,EAAE,MAAM;QAC1D,kDAAkD,EAAE,MAAM;QAC1D,8CAA8C,EAAE,MAAM;QACtD,wBAAwB,EAAE,KAAK;QAC/B,2CAA2C,EAAE,MAAM;QACnD,sDAAsD,EAAE,MAAM;QAC9D,kCAAkC,EAAE,MAAM;QAC1C,yCAAyC,EAAE,MAAM;QACjD,oCAAoC,EAAE,MAAM;QAC5C,+CAA+C,EAAE,MAAM;QACvD,8CAA8C,EAAE,MAAM;QACtD,0CAA0C,EAAE,MAAM;QAClD,iDAAiD,EAAE,MAAM;QACzD,4CAA4C,EAAE,MAAM;QACpD,mDAAmD,EAAE,MAAM;QAC3D,2CAA2C,EAAE,MAAM;QACnD,uCAAuC,EAAE,MAAM;KAChD;CACF,CAAC"}
|
||||
@@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const all_1 = __importDefault(require("./configs/all"));
|
||||
const base_1 = __importDefault(require("./configs/base"));
|
||||
const eslint_recommended_1 = __importDefault(require("./configs/eslint-recommended"));
|
||||
const recommended_1 = __importDefault(require("./configs/recommended"));
|
||||
const recommended_requiring_type_checking_1 = __importDefault(require("./configs/recommended-requiring-type-checking"));
|
||||
const strict_1 = __importDefault(require("./configs/strict"));
|
||||
const rules_1 = __importDefault(require("./rules"));
|
||||
module.exports = {
|
||||
rules: rules_1.default,
|
||||
configs: {
|
||||
all: all_1.default,
|
||||
base: base_1.default,
|
||||
recommended: recommended_1.default,
|
||||
'eslint-recommended': eslint_recommended_1.default,
|
||||
'recommended-requiring-type-checking': recommended_requiring_type_checking_1.default,
|
||||
strict: strict_1.default,
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,wDAAgC;AAChC,0DAAkC;AAClC,sFAA6D;AAC7D,wEAAgD;AAChD,wHAA6F;AAC7F,8DAAsC;AACtC,oDAA4B;AAE5B,iBAAS;IACP,KAAK,EAAL,eAAK;IACL,OAAO,EAAE;QACP,GAAG,EAAH,aAAG;QACH,IAAI,EAAJ,cAAI;QACJ,WAAW,EAAX,qBAAW;QACX,oBAAoB,EAAE,4BAAiB;QACvC,qCAAqC,EAAE,6CAAgC;QACvE,MAAM,EAAN,gBAAM;KACP;CACF,CAAC"}
|
||||
@@ -1,160 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'adjacent-overload-signatures',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require that function overload signatures be consecutive',
|
||||
recommended: 'error',
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
adjacentSignature: 'All {{name}} signatures should be adjacent.',
|
||||
},
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
/**
|
||||
* Gets the name and attribute of the member being processed.
|
||||
* @param member the member being processed.
|
||||
* @returns the name and attribute of the member or null if it's a member not relevant to the rule.
|
||||
*/
|
||||
function getMemberMethod(member) {
|
||||
var _a, _b;
|
||||
if (!member) {
|
||||
return null;
|
||||
}
|
||||
const isStatic = 'static' in member && !!member.static;
|
||||
switch (member.type) {
|
||||
case utils_1.AST_NODE_TYPES.ExportDefaultDeclaration:
|
||||
case utils_1.AST_NODE_TYPES.ExportNamedDeclaration: {
|
||||
// export statements (e.g. export { a };)
|
||||
// have no declarations, so ignore them
|
||||
if (!member.declaration) {
|
||||
return null;
|
||||
}
|
||||
return getMemberMethod(member.declaration);
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSDeclareFunction:
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration: {
|
||||
const name = (_b = (_a = member.id) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
name,
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
type: util.MemberNameType.Normal,
|
||||
};
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
return Object.assign(Object.assign({}, util.getNameFromMember(member, sourceCode)), { static: isStatic, callSignature: false });
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return {
|
||||
name: 'call',
|
||||
static: isStatic,
|
||||
callSignature: true,
|
||||
type: util.MemberNameType.Normal,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return {
|
||||
name: 'new',
|
||||
static: isStatic,
|
||||
callSignature: false,
|
||||
type: util.MemberNameType.Normal,
|
||||
};
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return Object.assign(Object.assign({}, util.getNameFromMember(member, sourceCode)), { static: isStatic, callSignature: false });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isSameMethod(method1, method2) {
|
||||
return (!!method2 &&
|
||||
method1.name === method2.name &&
|
||||
method1.static === method2.static &&
|
||||
method1.callSignature === method2.callSignature &&
|
||||
method1.type === method2.type);
|
||||
}
|
||||
function getMembers(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.ClassBody:
|
||||
case utils_1.AST_NODE_TYPES.Program:
|
||||
case utils_1.AST_NODE_TYPES.TSModuleBlock:
|
||||
case utils_1.AST_NODE_TYPES.TSInterfaceBody:
|
||||
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);
|
||||
if (members) {
|
||||
let lastMethod = null;
|
||||
const seenMethods = [];
|
||||
members.forEach(member => {
|
||||
const method = getMemberMethod(member);
|
||||
if (method == null) {
|
||||
lastMethod = null;
|
||||
return;
|
||||
}
|
||||
const index = seenMethods.findIndex(seenMethod => isSameMethod(method, seenMethod));
|
||||
if (index > -1 && !isSameMethod(method, lastMethod)) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'adjacentSignature',
|
||||
data: {
|
||||
name: `${method.static ? 'static ' : ''}${method.name}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
else if (index === -1) {
|
||||
seenMethods.push(method);
|
||||
}
|
||||
lastMethod = method;
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
ClassBody: checkBodyForOverloadMethods,
|
||||
Program: checkBodyForOverloadMethods,
|
||||
TSModuleBlock: checkBodyForOverloadMethods,
|
||||
TSTypeLiteral: checkBodyForOverloadMethods,
|
||||
TSInterfaceBody: checkBodyForOverloadMethods,
|
||||
BlockStatement: checkBodyForOverloadMethods,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=adjacent-overload-signatures.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"adjacent-overload-signatures.js","sourceRoot":"","sources":["../../src/rules/adjacent-overload-signatures.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAchC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,0DAA0D;YACvE,WAAW,EAAE,OAAO;SACrB;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,OAAO,CAAC,aAAa,EAAE,CAAC;QAS3C;;;;WAIG;QACH,SAAS,eAAe,CAAC,MAAqB;;YAC5C,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,IAAI,CAAC;aACb;YAED,MAAM,QAAQ,GAAG,QAAQ,IAAI,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;YAEvD,QAAQ,MAAM,CAAC,IAAI,EAAE;gBACnB,KAAK,sBAAc,CAAC,wBAAwB,CAAC;gBAC7C,KAAK,sBAAc,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,yCAAyC;oBACzC,uCAAuC;oBACvC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;wBACvB,OAAO,IAAI,CAAC;qBACb;oBAED,OAAO,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;iBAC5C;gBACD,KAAK,sBAAc,CAA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IAAI,EAAE;gCACJ,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE;6BACxD;yBACF,CAAC,CAAC;qBACJ;yBAAM,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;wBACvB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;qBAC1B;oBAED,UAAU,GAAG,MAAM,CAAC;gBACtB,CAAC,CAAC,CAAC;aACJ;QACH,CAAC;QAED,OAAO;YACL,SAAS,EAAE,2BAA2B;YACtC,OAAO,EAAE,2BAA2B;YACpC,aAAa,EAAE,2BAA2B;YAC1C,aAAa,EAAE,2BAA2B;YAC1C,eAAe,EAAE,2BAA2B;YAC5C,cAAc,EAAE,2BAA2B;SAC5C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,249 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
/**
|
||||
* Check whatever node can be considered as simple
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function isSimpleType(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
case utils_1.AST_NODE_TYPES.TSAnyKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSBooleanKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNeverKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNumberKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSBigIntKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSObjectKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSStringKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSSymbolKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSUnknownKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSVoidKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSNullKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSArrayType:
|
||||
case utils_1.AST_NODE_TYPES.TSUndefinedKeyword:
|
||||
case utils_1.AST_NODE_TYPES.TSThisType:
|
||||
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
||||
if (node.typeName &&
|
||||
node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
node.typeName.name === 'Array') {
|
||||
if (!node.typeParameters) {
|
||||
return true;
|
||||
}
|
||||
if (node.typeParameters.params.length === 1) {
|
||||
return isSimpleType(node.typeParameters.params[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (node.typeParameters) {
|
||||
return false;
|
||||
}
|
||||
return isSimpleType(node.typeName);
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if node needs parentheses
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function typeNeedsParentheses(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSTypeReference:
|
||||
return typeNeedsParentheses(node.typeName);
|
||||
case utils_1.AST_NODE_TYPES.TSUnionType:
|
||||
case utils_1.AST_NODE_TYPES.TSFunctionType:
|
||||
case utils_1.AST_NODE_TYPES.TSIntersectionType:
|
||||
case utils_1.AST_NODE_TYPES.TSTypeOperator:
|
||||
case utils_1.AST_NODE_TYPES.TSInferType:
|
||||
case utils_1.AST_NODE_TYPES.TSConstructorType:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
return node.name === 'ReadonlyArray';
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.default = util.createRule({
|
||||
name: 'array-type',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require consistently using either `T[]` or `Array<T>` for arrays',
|
||||
recommended: 'strict',
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
errorStringGeneric: "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden. Use '{{className}}<{{type}}>' instead.",
|
||||
errorStringArray: "Array type using '{{className}}<{{type}}>' is forbidden. Use '{{readonlyPrefix}}{{type}}[]' instead.",
|
||||
errorStringArraySimple: "Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}[]' instead.",
|
||||
errorStringGenericSimple: "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead.",
|
||||
},
|
||||
schema: {
|
||||
$defs: {
|
||||
arrayOption: {
|
||||
enum: ['array', 'generic', 'array-simple'],
|
||||
},
|
||||
},
|
||||
prefixItems: [
|
||||
{
|
||||
properties: {
|
||||
default: {
|
||||
$ref: '#/$defs/arrayOption',
|
||||
description: 'The array type expected for mutable cases...',
|
||||
},
|
||||
readonly: {
|
||||
$ref: '#/$defs/arrayOption',
|
||||
description: 'The array type expected for readonly cases. If omitted, the value for `default` will be used.',
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
},
|
||||
],
|
||||
type: 'array',
|
||||
},
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
default: 'array',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
var _a;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const defaultOption = options.default;
|
||||
const readonlyOption = (_a = options.readonly) !== null && _a !== void 0 ? _a : defaultOption;
|
||||
/**
|
||||
* @param node the node to be evaluated.
|
||||
*/
|
||||
function getMessageType(node) {
|
||||
if (node && isSimpleType(node)) {
|
||||
return sourceCode.getText(node);
|
||||
}
|
||||
return 'T';
|
||||
}
|
||||
return {
|
||||
TSArrayType(node) {
|
||||
const isReadonly = node.parent &&
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.TSTypeOperator &&
|
||||
node.parent.operator === 'readonly';
|
||||
const currentOption = isReadonly ? readonlyOption : defaultOption;
|
||||
if (currentOption === 'array' ||
|
||||
(currentOption === 'array-simple' && isSimpleType(node.elementType))) {
|
||||
return;
|
||||
}
|
||||
const messageId = currentOption === 'generic'
|
||||
? 'errorStringGeneric'
|
||||
: 'errorStringGenericSimple';
|
||||
const errorNode = isReadonly ? node.parent : node;
|
||||
context.report({
|
||||
node: errorNode,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonly ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix: isReadonly ? 'readonly ' : '',
|
||||
type: getMessageType(node.elementType),
|
||||
},
|
||||
fix(fixer) {
|
||||
const typeNode = node.elementType;
|
||||
const arrayType = isReadonly ? 'ReadonlyArray' : 'Array';
|
||||
return [
|
||||
fixer.replaceTextRange([errorNode.range[0], typeNode.range[0]], `${arrayType}<`),
|
||||
fixer.replaceTextRange([typeNode.range[1], errorNode.range[1]], '>'),
|
||||
];
|
||||
},
|
||||
});
|
||||
},
|
||||
TSTypeReference(node) {
|
||||
var _a, _b;
|
||||
if (node.typeName.type !== utils_1.AST_NODE_TYPES.Identifier ||
|
||||
!(node.typeName.name === 'Array' ||
|
||||
node.typeName.name === 'ReadonlyArray')) {
|
||||
return;
|
||||
}
|
||||
const isReadonlyArrayType = node.typeName.name === 'ReadonlyArray';
|
||||
const currentOption = isReadonlyArrayType
|
||||
? readonlyOption
|
||||
: defaultOption;
|
||||
if (currentOption === 'generic') {
|
||||
return;
|
||||
}
|
||||
const readonlyPrefix = isReadonlyArrayType ? 'readonly ' : '';
|
||||
const typeParams = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params;
|
||||
const messageId = currentOption === 'array'
|
||||
? 'errorStringArray'
|
||||
: 'errorStringArraySimple';
|
||||
if (!typeParams || typeParams.length === 0) {
|
||||
// Create an 'any' array
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix,
|
||||
type: 'any',
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(node, `${readonlyPrefix}any[]`);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeParams.length !== 1 ||
|
||||
(currentOption === 'array-simple' && !isSimpleType(typeParams[0]))) {
|
||||
return;
|
||||
}
|
||||
const type = typeParams[0];
|
||||
const typeParens = typeNeedsParentheses(type);
|
||||
const parentParens = readonlyPrefix &&
|
||||
((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.TSArrayType &&
|
||||
!util.isParenthesized(node.parent.elementType, sourceCode);
|
||||
const start = `${parentParens ? '(' : ''}${readonlyPrefix}${typeParens ? '(' : ''}`;
|
||||
const end = `${typeParens ? ')' : ''}[]${parentParens ? ')' : ''}`;
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
data: {
|
||||
className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array',
|
||||
readonlyPrefix,
|
||||
type: getMessageType(type),
|
||||
},
|
||||
fix(fixer) {
|
||||
return [
|
||||
fixer.replaceTextRange([node.range[0], type.range[0]], start),
|
||||
fixer.replaceTextRange([type.range[1], node.range[1]], end),
|
||||
];
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=array-type.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,62 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tsutils = __importStar(require("tsutils"));
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'await-thenable',
|
||||
meta: {
|
||||
docs: {
|
||||
description: 'Disallow awaiting a value that is not a Thenable',
|
||||
recommended: 'error',
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
messages: {
|
||||
await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
|
||||
},
|
||||
schema: [],
|
||||
type: 'problem',
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
const parserServices = util.getParserServices(context);
|
||||
const checker = parserServices.program.getTypeChecker();
|
||||
return {
|
||||
AwaitExpression(node) {
|
||||
const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
||||
const type = checker.getTypeAtLocation(originalNode.expression);
|
||||
if (!util.isTypeAnyType(type) &&
|
||||
!util.isTypeUnknownType(type) &&
|
||||
!tsutils.isThenableType(checker, originalNode.expression, type)) {
|
||||
context.report({
|
||||
messageId: 'await',
|
||||
node,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=await-thenable.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"await-thenable.js","sourceRoot":"","sources":["../../src/rules/await-thenable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,kDAAkD;YAC/D,WAAW,EAAE,OAAO;YACpB,oBAAoB,EAAE,IAAI;SAC3B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,6DAA6D;SACrE;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,cAAc,EAAE,EAAE;IAElB,MAAM,CAAC,OAAO;QACZ,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAExD,OAAO;YACL,eAAe,CAAC,IAAI;gBAClB,MAAM,YAAY,GAAG,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpE,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;gBAEhE,IACE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;oBACzB,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;oBAC7B,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,EAC/D;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,OAAO;wBAClB,IAAI;qBACL,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,158 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defaultMinimumDescriptionLength = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.defaultMinimumDescriptionLength = 3;
|
||||
exports.default = util.createRule({
|
||||
name: 'ban-ts-comment',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Disallow `@ts-<directive>` comments or require descriptions after directives',
|
||||
recommended: 'error',
|
||||
},
|
||||
messages: {
|
||||
tsDirectiveComment: 'Do not use "@ts-{{directive}}" because it alters compilation errors.',
|
||||
tsDirectiveCommentRequiresDescription: 'Include a description after the "@ts-{{directive}}" directive to explain why the @ts-{{directive}} is necessary. The description must be {{minimumDescriptionLength}} characters or longer.',
|
||||
tsDirectiveCommentDescriptionNotMatchPattern: 'The description for the "@ts-{{directive}}" directive must match the {{format}} format.',
|
||||
},
|
||||
schema: {
|
||||
$defs: {
|
||||
directiveConfigSchema: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
enum: ['allow-with-description'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
descriptionFormat: { type: 'string' },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
prefixItems: [
|
||||
{
|
||||
properties: {
|
||||
'ts-expect-error': {
|
||||
$ref: '#/$defs/directiveConfigSchema',
|
||||
},
|
||||
'ts-ignore': { $ref: '#/$defs/directiveConfigSchema' },
|
||||
'ts-nocheck': { $ref: '#/$defs/directiveConfigSchema' },
|
||||
'ts-check': { $ref: '#/$defs/directiveConfigSchema' },
|
||||
minimumDescriptionLength: {
|
||||
type: 'number',
|
||||
default: exports.defaultMinimumDescriptionLength,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
type: 'array',
|
||||
},
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
'ts-expect-error': 'allow-with-description',
|
||||
'ts-ignore': true,
|
||||
'ts-nocheck': true,
|
||||
'ts-check': false,
|
||||
minimumDescriptionLength: exports.defaultMinimumDescriptionLength,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
/*
|
||||
The regex used are taken from the ones used in the official TypeScript repo -
|
||||
https://github.com/microsoft/TypeScript/blob/408c760fae66080104bc85c449282c2d207dfe8e/src/compiler/scanner.ts#L288-L296
|
||||
*/
|
||||
const commentDirectiveRegExSingleLine = /^\/*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
|
||||
const commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const descriptionFormats = new Map();
|
||||
for (const directive of [
|
||||
'ts-expect-error',
|
||||
'ts-ignore',
|
||||
'ts-nocheck',
|
||||
'ts-check',
|
||||
]) {
|
||||
const option = options[directive];
|
||||
if (typeof option === 'object' && option.descriptionFormat) {
|
||||
descriptionFormats.set(directive, new RegExp(option.descriptionFormat));
|
||||
}
|
||||
}
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.forEach(comment => {
|
||||
const regExp = comment.type === utils_1.AST_TOKEN_TYPES.Line
|
||||
? commentDirectiveRegExSingleLine
|
||||
: commentDirectiveRegExMultiLine;
|
||||
const match = regExp.exec(comment.value);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
const { directive, description } = match.groups;
|
||||
const fullDirective = `ts-${directive}`;
|
||||
const option = options[fullDirective];
|
||||
if (option === true) {
|
||||
context.report({
|
||||
data: { directive },
|
||||
node: comment,
|
||||
messageId: 'tsDirectiveComment',
|
||||
});
|
||||
}
|
||||
if (option === 'allow-with-description' ||
|
||||
(typeof option === 'object' && option.descriptionFormat)) {
|
||||
const { minimumDescriptionLength = exports.defaultMinimumDescriptionLength, } = options;
|
||||
const format = descriptionFormats.get(fullDirective);
|
||||
if (util.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 +0,0 @@
|
||||
{"version":3,"file":"ban-ts-comment.js","sourceRoot":"","sources":["../../src/rules/ban-ts-comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2D;AAE3D,8CAAgC;AAenB,QAAA,+BAA+B,GAAG,CAAC,CAAC;AAOjD,kBAAe,IAAI,CAAC,UAAU,CAAwB;IACpD,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8EAA8E;YAChF,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,kBAAkB,EAChB,sEAAsE;YACxE,qCAAqC,EACnC,6LAA6L;YAC/L,4CAA4C,EAC1C,yFAAyF;SAC5F;QACD,MAAM,EAAE;YACN,KAAK,EAAE;gBACL,qBAAqB,EAAE;oBACrB,KAAK,EAAE;wBACL;4BACE,IAAI,EAAE,SAAS;4BACf,OAAO,EAAE,IAAI;yBACd;wBACD;4BACE,IAAI,EAAE,CAAC,wBAAwB,CAAC;yBACjC;wBACD;4BACE,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;6BACtC;yBACF;qBACF;iBACF;aACF;YACD,WAAW,EAAE;gBACX;oBACE,UAAU,EAAE;wBACV,iBAAiB,EAAE;4BACjB,IAAI,EAAE,+BAA+B;yBACtC;wBACD,WAAW,EAAE,EAAE,IAAI,EA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AAO;gCACb,SAAS,EAAE,8CAA8C;6BAC1D,CAAC,CAAC;yBACJ;qBACF;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,78 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
// tslint regex
|
||||
// https://github.com/palantir/tslint/blob/95d9d958833fd9dc0002d18cbe34db20d0fbf437/src/enableDisableRules.ts#L32
|
||||
const ENABLE_DISABLE_REGEX = /^\s*tslint:(enable|disable)(?:-(line|next-line))?(:|\s|$)/;
|
||||
const toText = (text, type) => type === utils_1.AST_TOKEN_TYPES.Line
|
||||
? ['//', text.trim()].join(' ')
|
||||
: ['/*', text.trim(), '*/'].join(' ');
|
||||
exports.default = util.createRule({
|
||||
name: 'ban-tslint-comment',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow `// tslint:<rule-flag>` comments',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
commentDetected: 'tslint comment detected: "{{ text }}"',
|
||||
},
|
||||
schema: [],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: [],
|
||||
create: context => {
|
||||
const sourceCode = context.getSourceCode();
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
comments.forEach(c => {
|
||||
if (ENABLE_DISABLE_REGEX.test(c.value)) {
|
||||
context.report({
|
||||
data: { text: toText(c.value, c.type) },
|
||||
node: c,
|
||||
messageId: 'commentDetected',
|
||||
fix(fixer) {
|
||||
const rangeStart = sourceCode.getIndexFromLoc({
|
||||
column: c.loc.start.column > 0 ? c.loc.start.column - 1 : 0,
|
||||
line: c.loc.start.line,
|
||||
});
|
||||
const rangeEnd = sourceCode.getIndexFromLoc({
|
||||
column: c.loc.end.column,
|
||||
line: c.loc.end.line,
|
||||
});
|
||||
return fixer.removeRange([rangeStart, rangeEnd + 1]);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-tslint-comment.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"ban-tslint-comment.js","sourceRoot":"","sources":["../../src/rules/ban-tslint-comment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA2D;AAE3D,8CAAgC;AAEhC,eAAe;AACf,iHAAiH;AACjH,MAAM,oBAAoB,GACxB,2DAA2D,CAAC;AAE9D,MAAM,MAAM,GAAG,CACb,IAAY,EACZ,IAAkD,EAC1C,EAAE,CACV,IAAI,KAAK,uBAAe,CAAC,IAAI;IAC3B,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI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vB,CAAC,CAAC;gCACH,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC;oCAC1C,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;oCACxB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI;iCACrB,CAAC,CAAC;gCACH,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,UAAU,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;4BACvD,CAAC;yBACF,CAAC,CAAC;qBACJ;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,231 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TYPE_KEYWORDS = void 0;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
function removeSpaces(str) {
|
||||
return str.replace(/\s/g, '');
|
||||
}
|
||||
function stringifyNode(node, sourceCode) {
|
||||
return removeSpaces(sourceCode.getText(node));
|
||||
}
|
||||
function getCustomMessage(bannedType) {
|
||||
if (bannedType == null) {
|
||||
return '';
|
||||
}
|
||||
if (typeof bannedType === 'string') {
|
||||
return ` ${bannedType}`;
|
||||
}
|
||||
if (bannedType.message) {
|
||||
return ` ${bannedType.message}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
const defaultTypes = {
|
||||
String: {
|
||||
message: 'Use string instead',
|
||||
fixWith: 'string',
|
||||
},
|
||||
Boolean: {
|
||||
message: 'Use boolean instead',
|
||||
fixWith: 'boolean',
|
||||
},
|
||||
Number: {
|
||||
message: 'Use number instead',
|
||||
fixWith: 'number',
|
||||
},
|
||||
Symbol: {
|
||||
message: 'Use symbol instead',
|
||||
fixWith: 'symbol',
|
||||
},
|
||||
BigInt: {
|
||||
message: 'Use bigint instead',
|
||||
fixWith: 'bigint',
|
||||
},
|
||||
Function: {
|
||||
message: [
|
||||
'The `Function` type accepts any function-like value.',
|
||||
'It provides no type safety when calling the function, which can be a common source of bugs.',
|
||||
'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.',
|
||||
'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
|
||||
].join('\n'),
|
||||
},
|
||||
// object typing
|
||||
Object: {
|
||||
message: [
|
||||
'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.',
|
||||
'- If you want a type meaning "any object", you probably want `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 = util.createRule({
|
||||
name: 'ban-types',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow certain types',
|
||||
recommended: 'error',
|
||||
},
|
||||
fixable: 'code',
|
||||
hasSuggestions: true,
|
||||
messages: {
|
||||
bannedTypeMessage: "Don't use `{{name}}` as a type.{{customMessage}}",
|
||||
bannedTypeReplacement: 'Replace `{{name}}` with `{{replacement}}`.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
types: {
|
||||
type: 'object',
|
||||
additionalProperties: {
|
||||
oneOf: [
|
||||
{ type: 'null' },
|
||||
{ type: 'boolean' },
|
||||
{ type: 'string' },
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
message: { type: 'string' },
|
||||
fixWith: { type: 'string' },
|
||||
suggest: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
extendDefaults: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [{}],
|
||||
create(context, [options]) {
|
||||
var _a, _b;
|
||||
const extendDefaults = (_a = options.extendDefaults) !== null && _a !== void 0 ? _a : true;
|
||||
const customTypes = (_b = options.types) !== null && _b !== void 0 ? _b : {};
|
||||
const types = Object.assign({}, extendDefaults ? defaultTypes : {}, customTypes);
|
||||
const bannedTypes = new Map(Object.entries(types).map(([type, data]) => [removeSpaces(type), data]));
|
||||
function checkBannedTypes(typeNode, name = stringifyNode(typeNode, context.getSourceCode())) {
|
||||
const bannedType = bannedTypes.get(name);
|
||||
if (bannedType === undefined || bannedType === false) {
|
||||
return;
|
||||
}
|
||||
const customMessage = getCustomMessage(bannedType);
|
||||
const fixWith = bannedType && typeof bannedType === 'object' && bannedType.fixWith;
|
||||
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 === null || suggest === void 0 ? void 0 : suggest.map(replacement => ({
|
||||
messageId: 'bannedTypeReplacement',
|
||||
data: {
|
||||
name,
|
||||
replacement,
|
||||
},
|
||||
fix: (fixer) => fixer.replaceText(typeNode, replacement),
|
||||
})),
|
||||
});
|
||||
}
|
||||
const keywordSelectors = util.objectReduceKey(exports.TYPE_KEYWORDS, (acc, keyword) => {
|
||||
if (bannedTypes.has(keyword)) {
|
||||
acc[exports.TYPE_KEYWORDS[keyword]] = (node) => checkBannedTypes(node, keyword);
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
return Object.assign(Object.assign({}, keywordSelectors), { TSTypeLiteral(node) {
|
||||
if (node.members.length) {
|
||||
return;
|
||||
}
|
||||
checkBannedTypes(node);
|
||||
},
|
||||
TSTupleType(node) {
|
||||
if (node.elementTypes.length === 0) {
|
||||
checkBannedTypes(node);
|
||||
}
|
||||
},
|
||||
TSTypeReference(node) {
|
||||
checkBannedTypes(node.typeName);
|
||||
if (node.typeParameters) {
|
||||
checkBannedTypes(node);
|
||||
}
|
||||
},
|
||||
TSInterfaceHeritage(node) {
|
||||
checkBannedTypes(node);
|
||||
},
|
||||
TSClassImplements(node) {
|
||||
checkBannedTypes(node);
|
||||
} });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=ban-types.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,158 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('block-spacing');
|
||||
exports.default = util.createRule({
|
||||
name: 'block-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Disallow or enforce spaces inside of blocks after opening block and before closing block',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: ['always'],
|
||||
create(context, [whenToApplyOption]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
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 (!util.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.type !== utils_1.AST_TOKEN_TYPES.Punctuator ||
|
||||
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 Object.assign(Object.assign({}, 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 +0,0 @@
|
||||
{"version":3,"file":"block-spacing.js","sourceRoot":"","sources":["../../src/rules/block-spacing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA2D;AAE3D,8CAAgC;AAChC,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,eAAe,CAAC,CAAC;AAKpD,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EACT,0FAA0F;YAC5F,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAE1B,MAAM,CAAC,OAAO,EAAE,CAAC,iBAAiB,CAAC;QACjC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C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AAC;iBACH;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;4BACV,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;yBAC9C;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;aACJ;QACH,CAAC;QACD,uCACK,SAAS;YAEZ,mEAAmE;YACnE,mIAAmI;YACnI,wFAAwF;YACxF,sEAAsE;YACtE,eAAe,EAAE,SAAS,CAAC,cAAuB,EAClD,aAAa,EAAE,SAAS,CAAC,cAAuB,EAChD,iBAAiB,EAAE,wBAAwB,IAC3C;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,94 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../util");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('brace-style');
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'brace-style',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent brace style for blocks',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
messages: baseRule.meta.messages,
|
||||
fixable: baseRule.meta.fixable,
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
},
|
||||
defaultOptions: ['1tbs'],
|
||||
create(context) {
|
||||
const [style, { allowSingleLine } = { allowSingleLine: false }] =
|
||||
// eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules.
|
||||
context.options;
|
||||
const isAllmanStyle = style === 'allman';
|
||||
const sourceCode = context.getSourceCode();
|
||||
const rules = baseRule.create(context);
|
||||
/**
|
||||
* Checks a pair of curly brackets based on the user's config
|
||||
*/
|
||||
function validateCurlyPair(openingCurlyToken, closingCurlyToken) {
|
||||
if (allowSingleLine &&
|
||||
(0, util_1.isTokenOnSameLine)(openingCurlyToken, closingCurlyToken)) {
|
||||
return;
|
||||
}
|
||||
const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurlyToken);
|
||||
const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurlyToken);
|
||||
const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurlyToken);
|
||||
if (!isAllmanStyle &&
|
||||
!(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'nextLineOpen',
|
||||
fix: fixer => {
|
||||
const textRange = [
|
||||
tokenBeforeOpeningCurly.range[1],
|
||||
openingCurlyToken.range[0],
|
||||
];
|
||||
const textBetween = sourceCode.text.slice(textRange[0], textRange[1]);
|
||||
if (textBetween.trim()) {
|
||||
return null;
|
||||
}
|
||||
return fixer.replaceTextRange(textRange, ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
if (isAllmanStyle &&
|
||||
(0, util_1.isTokenOnSameLine)(tokenBeforeOpeningCurly, openingCurlyToken)) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'sameLineOpen',
|
||||
fix: fixer => fixer.insertTextBefore(openingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
if ((0, util_1.isTokenOnSameLine)(openingCurlyToken, tokenAfterOpeningCurly) &&
|
||||
tokenAfterOpeningCurly !== closingCurlyToken) {
|
||||
context.report({
|
||||
node: openingCurlyToken,
|
||||
messageId: 'blockSameLine',
|
||||
fix: fixer => fixer.insertTextAfter(openingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
if ((0, util_1.isTokenOnSameLine)(tokenBeforeClosingCurly, closingCurlyToken) &&
|
||||
tokenBeforeClosingCurly !== openingCurlyToken) {
|
||||
context.report({
|
||||
node: closingCurlyToken,
|
||||
messageId: 'singleLineClose',
|
||||
fix: fixer => fixer.insertTextBefore(closingCurlyToken, '\n'),
|
||||
});
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, rules), { 'TSInterfaceBody, TSModuleBlock'(node) {
|
||||
const openingCurly = sourceCode.getFirstToken(node);
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
},
|
||||
TSEnumDeclaration(node) {
|
||||
const closingCurly = sourceCode.getLastToken(node);
|
||||
const openingCurly = sourceCode.getTokenBefore(node.members.length ? node.members[0] : closingCurly);
|
||||
validateCurlyPair(openingCurly, closingCurly);
|
||||
} });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=brace-style.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"brace-style.js","sourceRoot":"","sources":["../../src/rules/brace-style.ts"],"names":[],"mappings":";;AAMA,kCAAwD;AACxD,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,aAAa,CAAC,CAAC;AAKlD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;QAChC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;QAC9B,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI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Y,CAAC,IAAI,CAAE,CAAC;gBAEpD,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;YACD,iBAAiB,CAAC,IAAI;gBACpB,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAE,CAAC;gBACpD,MAAM,YAAY,GAAG,UAAU,CAAC,cAAc,CAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CACpD,CAAC;gBAEH,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,126 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const printNodeModifiers = (node, final) => {
|
||||
var _a;
|
||||
return `${(_a = node.accessibility) !== null && _a !== void 0 ? _a : ''}${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 = util.createRule({
|
||||
name: 'class-literal-property-style',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Enforce that literals on classes are exposed in a consistent style',
|
||||
recommended: 'strict',
|
||||
},
|
||||
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: [{ enum: ['fields', 'getters'] }],
|
||||
},
|
||||
defaultOptions: ['fields'],
|
||||
create(context, [style]) {
|
||||
return Object.assign(Object.assign({}, (style === 'fields' && {
|
||||
MethodDefinition(node) {
|
||||
if (node.kind !== 'get' ||
|
||||
!node.value.body ||
|
||||
!node.value.body.body.length) {
|
||||
return;
|
||||
}
|
||||
const [statement] = node.value.body.body;
|
||||
if (statement.type !== utils_1.AST_NODE_TYPES.ReturnStatement) {
|
||||
return;
|
||||
}
|
||||
const { argument } = statement;
|
||||
if (!argument || !isSupportedLiteral(argument)) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'preferFieldStyle',
|
||||
suggest: [
|
||||
{
|
||||
messageId: 'preferFieldStyleSuggestion',
|
||||
fix(fixer) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const name = sourceCode.getText(node.key);
|
||||
let text = '';
|
||||
text += printNodeModifiers(node, 'readonly');
|
||||
text += node.computed ? `[${name}]` : name;
|
||||
text += ` = ${sourceCode.getText(argument)};`;
|
||||
return fixer.replaceText(node, text);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
})), (style === 'getters' && {
|
||||
PropertyDefinition(node) {
|
||||
if (!node.readonly || node.declare) {
|
||||
return;
|
||||
}
|
||||
const { value } = node;
|
||||
if (!value || !isSupportedLiteral(value)) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'preferGetterStyle',
|
||||
suggest: [
|
||||
{
|
||||
messageId: 'preferGetterStyleSuggestion',
|
||||
fix(fixer) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const name = sourceCode.getText(node.key);
|
||||
let text = '';
|
||||
text += printNodeModifiers(node, 'get');
|
||||
text += node.computed ? `[${name}]` : name;
|
||||
text += `() { return ${sourceCode.getText(value)}; }`;
|
||||
return fixer.replaceText(node, text);
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=class-literal-property-style.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"class-literal-property-style.js","sourceRoot":"","sources":["../../src/rules/class-literal-property-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAchC,MAAM,kBAAkB,GAAG,CACzB,IAAuB,EACvB,KAAyB,EACjB,EAAE;;IACV,OAAA,GAAG,MAAA,IAAI,CAAC,aAAa,mCAAI,EAAE,GACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC5B,IAAI,KAAK,GAAG,CAAC,SAAS,EAAE,CAAA;CAAA,CAAC;AAE3B,MAAM,kBAAkB,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I,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE;oBACxC,OAAO;iBACR;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,IAAI,CAAC,GAAG;oBACd,SAAS,EAAE,mBAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,6BAA6B;4BACxC,GAAG,CAAC,KAAK;gCACP,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;gCAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gCAE1C,IAAI,IAAI,GAAG,EAAE,CAAC;gCAEd,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gCACxC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;gCAC3C,IAAI,IAAI,eAAe,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;gCAEtD,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;4BACvC,CAAC;yBACF;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,EACF;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,180 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(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) {
|
||||
var _a, _b, _c;
|
||||
if (typeof options === 'string') {
|
||||
return {
|
||||
enums: options,
|
||||
generics: options,
|
||||
tuples: options,
|
||||
};
|
||||
}
|
||||
return {
|
||||
enums: (_a = options.enums) !== null && _a !== void 0 ? _a : DEFAULT_OPTION_VALUE,
|
||||
generics: (_b = options.generics) !== null && _b !== void 0 ? _b : DEFAULT_OPTION_VALUE,
|
||||
tuples: (_c = options.tuples) !== null && _c !== void 0 ? _c : DEFAULT_OPTION_VALUE,
|
||||
};
|
||||
}
|
||||
exports.default = util.createRule({
|
||||
name: 'comma-dangle',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require or disallow trailing commas',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
schema: {
|
||||
$defs: {
|
||||
value: {
|
||||
enum: OPTION_VALUE_SCHEME,
|
||||
},
|
||||
valueWithIgnore: {
|
||||
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,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
additionalProperties: false,
|
||||
},
|
||||
fixable: 'code',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: ['never'],
|
||||
create(context, [options]) {
|
||||
const rules = baseRule.create(context);
|
||||
const sourceCode = context.getSourceCode();
|
||||
const normalizedOptions = normalizeOptions(options);
|
||||
const predicate = {
|
||||
always: forceComma,
|
||||
'always-multiline': forceCommaIfMultiline,
|
||||
'only-multiline': allowCommaIfMultiline,
|
||||
never: forbidComma,
|
||||
ignore: () => { },
|
||||
};
|
||||
function last(nodes) {
|
||||
var _a;
|
||||
return (_a = nodes[nodes.length - 1]) !== null && _a !== void 0 ? _a : null;
|
||||
}
|
||||
function getLastItem(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSEnumDeclaration:
|
||||
return last(node.members);
|
||||
case utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration:
|
||||
return last(node.params);
|
||||
case utils_1.AST_NODE_TYPES.TSTupleType:
|
||||
return last(node.elementTypes);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function getTrailingToken(node) {
|
||||
const last = getLastItem(node);
|
||||
const trailing = last && sourceCode.getTokenAfter(last);
|
||||
return trailing;
|
||||
}
|
||||
function isMultiline(node) {
|
||||
const last = getLastItem(node);
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
return (last === null || last === void 0 ? void 0 : last.loc.end.line) !== (lastToken === null || lastToken === void 0 ? void 0 : lastToken.loc.end.line);
|
||||
}
|
||||
function forbidComma(node) {
|
||||
const last = getLastItem(node);
|
||||
const trailing = getTrailingToken(node);
|
||||
if (last && trailing && util.isCommaToken(trailing)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unexpected',
|
||||
fix(fixer) {
|
||||
return fixer.remove(trailing);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
function forceComma(node) {
|
||||
const last = getLastItem(node);
|
||||
const trailing = getTrailingToken(node);
|
||||
if (last && trailing && !util.isCommaToken(trailing)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missing',
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(last, ',');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
function allowCommaIfMultiline(node) {
|
||||
if (!isMultiline(node)) {
|
||||
forbidComma(node);
|
||||
}
|
||||
}
|
||||
function forceCommaIfMultiline(node) {
|
||||
if (isMultiline(node)) {
|
||||
forceComma(node);
|
||||
}
|
||||
else {
|
||||
forbidComma(node);
|
||||
}
|
||||
}
|
||||
return Object.assign(Object.assign({}, rules), { TSEnumDeclaration: predicate[normalizedOptions.enums], TSTypeParameterDeclaration: predicate[normalizedOptions.generics], TSTupleType: predicate[normalizedOptions.tuples] });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=comma-dangle.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"comma-dangle.js","sourceRoot":"","sources":["../../src/rules/comma-dangle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAChC,iEAA8D;AAE9D,MAAM,QAA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AAmB;YACrC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,IAAI,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;gBACpD,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;aACJ;QACH,CAAC;QAED,SAAS,qBAAqB,CAAC,IAAmB;YAChD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gBACtB,WAAW,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC;QAED,SAAS,qBAAqB,CAAC,IAAmB;YAChD,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;gBACrB,UAAU,CAAC,IAAI,CAAC,CAAC;aAClB;iBAAM;gBACL,WAAW,CAAC,IAAI,CAAC,CAAC;aACnB;QACH,CAAC;QAED,uCACK,KAAK,KACR,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,EACrD,0BAA0B,EAAE,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EACjE,WAAW,EAAE,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAChD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,150 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'comma-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent spacing before and after commas',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
before: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
after: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
unexpected: `There should be no space {{loc}} ','.`,
|
||||
missing: `A space is required {{loc}} ','.`,
|
||||
},
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
before: false,
|
||||
after: true,
|
||||
},
|
||||
],
|
||||
create(context, [{ before: spaceBefore, after: spaceAfter }]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const tokensAndComments = sourceCode.tokensAndComments;
|
||||
const ignoredTokens = new Set();
|
||||
/**
|
||||
* Adds null elements of the ArrayExpression or ArrayPattern node to the ignore list
|
||||
* @param node node to evaluate
|
||||
*/
|
||||
function addNullElementsToIgnoreList(node) {
|
||||
let previousToken = sourceCode.getFirstToken(node);
|
||||
for (const element of node.elements) {
|
||||
let token;
|
||||
if (element == null) {
|
||||
token = sourceCode.getTokenAfter(previousToken);
|
||||
if (token && (0, util_1.isCommaToken)(token)) {
|
||||
ignoredTokens.add(token);
|
||||
}
|
||||
}
|
||||
else {
|
||||
token = sourceCode.getTokenAfter(element);
|
||||
}
|
||||
previousToken = token;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds type parameters trailing comma token to the ignore list
|
||||
* @param node node to evaluate
|
||||
*/
|
||||
function addTypeParametersTrailingCommaToIgnoreList(node) {
|
||||
const paramLength = node.params.length;
|
||||
if (paramLength) {
|
||||
const param = node.params[paramLength - 1];
|
||||
const afterToken = sourceCode.getTokenAfter(param);
|
||||
if (afterToken && (0, util_1.isCommaToken)(afterToken)) {
|
||||
ignoredTokens.add(afterToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates the spacing around a comma token.
|
||||
* @param commaToken The token representing the comma
|
||||
* @param prevToken The last token before the comma
|
||||
* @param nextToken The first token after the comma
|
||||
*/
|
||||
function validateCommaSpacing(commaToken, prevToken, nextToken) {
|
||||
if (prevToken &&
|
||||
(0, util_1.isTokenOnSameLine)(prevToken, commaToken) &&
|
||||
// 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[i + 1];
|
||||
validateCommaSpacing(token, (0, util_1.isCommaToken)(prevToken) || ignoredTokens.has(token)
|
||||
? null
|
||||
: prevToken, (nextToken && (0, util_1.isCommaToken)(nextToken)) || ignoredTokens.has(token)
|
||||
? null
|
||||
: nextToken);
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=comma-spacing.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"comma-spacing.js","sourceRoot":"","sources":["../../src/rules/comma-spacing.ts"],"names":[],"mappings":";;AACA,oDAA2D;AAE3D,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,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,UAAU,EAAE,uCAAuC;YACnD,OAAO,EAAE,kCAAkC;SAC5C;KACF;IACD,cAAc,EAAE;QACd;YACE,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,IAAI;SACZ;KACF;IACD,MAAM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"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'consistent-generic-constructors',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce specifying generic type arguments on type annotation or constructor name of a constructor call',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
preferTypeAnnotation: 'The generic type arguments should be specified as part of the type annotation.',
|
||||
preferConstructor: 'The generic type arguments should be specified as part of the constructor type arguments.',
|
||||
},
|
||||
fixable: 'code',
|
||||
schema: [
|
||||
{
|
||||
enum: ['type-annotation', 'constructor'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['constructor'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
return {
|
||||
'VariableDeclarator,PropertyDefinition,:matches(FunctionDeclaration,FunctionExpression) > AssignmentPattern'(node) {
|
||||
var _a, _b;
|
||||
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 = (_a = lhsName.typeAnnotation) === null || _a === void 0 ? void 0 : _a.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.typeParameters) {
|
||||
const { typeParameters, callee } = rhs;
|
||||
const typeAnnotation = sourceCode.getText(callee) + sourceCode.getText(typeParameters);
|
||||
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(typeParameters),
|
||||
fixer.insertTextAfter(getIDToAttachAnnotation(), ': ' + typeAnnotation),
|
||||
];
|
||||
},
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mode === 'constructor') {
|
||||
if ((lhs === null || lhs === void 0 ? void 0 : lhs.typeParameters) && !rhs.typeParameters) {
|
||||
const hasParens = ((_b = sourceCode.getTokenAfter(rhs.callee)) === null || _b === void 0 ? void 0 : _b.value) === '(';
|
||||
const extraComments = new Set(sourceCode.getCommentsInside(lhs.parent));
|
||||
sourceCode
|
||||
.getCommentsInside(lhs.typeParameters)
|
||||
.forEach(c => extraComments.delete(c));
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'preferConstructor',
|
||||
*fix(fixer) {
|
||||
yield fixer.remove(lhs.parent);
|
||||
for (const comment of extraComments) {
|
||||
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(comment));
|
||||
}
|
||||
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(lhs.typeParameters));
|
||||
if (!hasParens) {
|
||||
yield fixer.insertTextAfter(rhs.callee, '()');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-generic-constructors.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"consistent-generic-constructors.js","sourceRoot":"","sources":["../../src/rules/consistent-generic-constructors.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAqC;AAKrC,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,wGAAwG;YAC1G,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,oBAAoB,EAClB,gFAAgF;YAClF,iBAAiB,EACf,2FAA2F;SAC9F;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC;aACzC;SACF;KACF;IACD,cAAc,EAAE,CAAC,aAAa,CAAC;IAC/B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,OAAO;YACL,4GAA4G,CAC1G,IAG8B;;gBAE9B,SAAS,SAAS;oBAIhB,QAAQ,IAAI,CAAC,IAAI,EAAE;wBACjB,KAAK,sBAAc,CAAC,kBAAkB;4BACpC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC9B,KAAK,sBAAc,CAAC,kBAAkB;4BACpC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;wBAC5B,KAAK,sBAAc,CAAC,iBAAiB;4BACnC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;wBACjC;4BACE,MAAM,IAAI,KAAK,CACb,wBAAyB,IAAyB,CAAC,IAAI,EAAE,CAC1D,CAAC;qBACL;gBACH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,MAAM,EAAE,IAAI,CAAC,CAAC;iCAC/C;4BACH,CAAC;yBACF,CAAC,CAAC;qBACJ;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,126 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'consistent-indexed-object-style',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require or disallow the `Record` type',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
preferRecord: 'A record is preferred over an index signature.',
|
||||
preferIndexSignature: 'An index signature is preferred over a record.',
|
||||
},
|
||||
fixable: 'code',
|
||||
schema: [
|
||||
{
|
||||
enum: ['record', 'index-signature'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['record'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function checkMembers(members, node, parentId, prefix, postfix, safeFix = true) {
|
||||
if (members.length !== 1) {
|
||||
return;
|
||||
}
|
||||
const [member] = members;
|
||||
if (member.type !== utils_1.AST_NODE_TYPES.TSIndexSignature) {
|
||||
return;
|
||||
}
|
||||
const [parameter] = member.parameters;
|
||||
if (!parameter) {
|
||||
return;
|
||||
}
|
||||
if (parameter.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return;
|
||||
}
|
||||
const keyType = parameter.typeAnnotation;
|
||||
if (!keyType) {
|
||||
return;
|
||||
}
|
||||
const valueType = member.typeAnnotation;
|
||||
if (!valueType) {
|
||||
return;
|
||||
}
|
||||
if (parentId) {
|
||||
const scope = context.getScope();
|
||||
const superVar = 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 Object.assign(Object.assign({}, (mode === 'index-signature' && {
|
||||
TSTypeReference(node) {
|
||||
var _a;
|
||||
const typeName = node.typeName;
|
||||
if (typeName.type !== utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return;
|
||||
}
|
||||
if (typeName.name !== 'Record') {
|
||||
return;
|
||||
}
|
||||
const params = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params;
|
||||
if ((params === null || params === void 0 ? void 0 : params.length) !== 2) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'preferIndexSignature',
|
||||
fix(fixer) {
|
||||
const key = sourceCode.getText(params[0]);
|
||||
const type = sourceCode.getText(params[1]);
|
||||
return fixer.replaceText(node, `{ [key: ${key}]: ${type} }`);
|
||||
},
|
||||
});
|
||||
},
|
||||
})), (mode === 'record' && {
|
||||
TSTypeLiteral(node) {
|
||||
const parent = findParentDeclaration(node);
|
||||
checkMembers(node.members, node, parent === null || parent === void 0 ? void 0 : parent.id, '', '');
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
var _a, _b, _c, _d;
|
||||
let genericTypes = '';
|
||||
if (((_b = (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : []).length > 0) {
|
||||
genericTypes = `<${(_c = node.typeParameters) === null || _c === void 0 ? void 0 : _c.params.map(p => sourceCode.getText(p)).join(', ')}>`;
|
||||
}
|
||||
checkMembers(node.body.body, node, node.id, `type ${node.id.name}${genericTypes} = `, ';', !((_d = node.extends) === null || _d === void 0 ? void 0 : _d.length));
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
function findParentDeclaration(node) {
|
||||
if (node.parent && node.parent.type !== utils_1.AST_NODE_TYPES.TSTypeAnnotation) {
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
||||
return node.parent;
|
||||
}
|
||||
return findParentDeclaration(node.parent);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
//# sourceMappingURL=consistent-indexed-object-style.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"consistent-indexed-object-style.js","sourceRoot":"","sources":["../../src/rules/consistent-indexed-object-style.ts"],"names":[],"mappings":";;AACA,oDAAoE;AAEpE,kCAAqC;AAKrC,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,gDAAgD;YAC9D,oBAAoB,EAAE,gDAAgD;SACvE;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;aACpC;SACF;KACF;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE3C,SAAS,YAAY,CACnB,OAA+B,EAC/B,IAA8D,EAC9D,QAAyC,EACzC,MAAc,EACd,OAAe,EACf,OAAO,GAAG,IAAI;YAEd,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE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E;YAC9D,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;QACD,OAAO,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC3C;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
||||
@@ -1,204 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-assertions',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
fixable: 'code',
|
||||
hasSuggestions: true,
|
||||
docs: {
|
||||
description: 'Enforce consistent usage of type assertions',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
as: "Use 'as {{cast}}' instead of '<{{cast}}>'.",
|
||||
'angle-bracket': "Use '<{{cast}}>' instead of 'as {{cast}}'.",
|
||||
never: 'Do not use any type assertions.',
|
||||
unexpectedObjectTypeAssertion: 'Always prefer const x: T = { ... }.',
|
||||
replaceObjectTypeAssertionWithAnnotation: 'Use const x: {{cast}} = { ... } instead.',
|
||||
replaceObjectTypeAssertionWithSatisfies: 'Use const x = { ... } satisfies {{cast}} instead.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
assertionStyle: {
|
||||
enum: ['never'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['assertionStyle'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
assertionStyle: {
|
||||
enum: ['as', 'angle-bracket'],
|
||||
},
|
||||
objectLiteralTypeAssertions: {
|
||||
enum: ['allow', 'allow-as-parameter', 'never'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
required: ['assertionStyle'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
assertionStyle: 'as',
|
||||
objectLiteralTypeAssertions: 'allow',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function isConst(node) {
|
||||
if (node.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
|
||||
return false;
|
||||
}
|
||||
return (node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
node.typeName.name === 'const');
|
||||
}
|
||||
function getTextWithParentheses(node) {
|
||||
// Capture parentheses before and after the node
|
||||
let beforeCount = 0;
|
||||
let afterCount = 0;
|
||||
if (util.isParenthesized(node, sourceCode)) {
|
||||
const bodyOpeningParen = sourceCode.getTokenBefore(node, util.isOpeningParenToken);
|
||||
const bodyClosingParen = sourceCode.getTokenAfter(node, util.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) => [
|
||||
fixer.replaceText(node, getTextWithParentheses(node.expression)),
|
||||
fixer.insertTextAfter(node, ` as ${getTextWithParentheses(node.typeAnnotation)}`),
|
||||
]
|
||||
: 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) {
|
||||
var _a;
|
||||
if (options.assertionStyle === 'never' ||
|
||||
options.objectLiteralTypeAssertions === 'allow' ||
|
||||
node.expression.type !== utils_1.AST_NODE_TYPES.ObjectExpression) {
|
||||
return;
|
||||
}
|
||||
if (options.objectLiteralTypeAssertions === 'allow-as-parameter' &&
|
||||
node.parent &&
|
||||
(node.parent.type === utils_1.AST_NODE_TYPES.NewExpression ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.CallExpression ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.ThrowStatement ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer)) {
|
||||
return;
|
||||
}
|
||||
if (checkType(node.typeAnnotation) &&
|
||||
node.expression.type === utils_1.AST_NODE_TYPES.ObjectExpression) {
|
||||
const suggest = [];
|
||||
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.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 ${context
|
||||
.getSourceCode()
|
||||
.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
|
||||
File diff suppressed because one or more lines are too long
@@ -1,122 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-definitions',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce type definitions to consistently use either `interface` or `type`',
|
||||
recommended: 'strict',
|
||||
},
|
||||
messages: {
|
||||
interfaceOverType: 'Use an `interface` instead of a `type`.',
|
||||
typeOverInterface: 'Use a `type` instead of an `interface`.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
enum: ['interface', 'type'],
|
||||
},
|
||||
],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: ['interface'],
|
||||
create(context, [option]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
/**
|
||||
* Iterates from the highest parent to the currently traversed node
|
||||
* to determine whether any node in tree is globally declared module declaration
|
||||
*/
|
||||
function isCurrentlyTraversedNodeWithinModuleDeclaration() {
|
||||
return context
|
||||
.getAncestors()
|
||||
.some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
|
||||
node.declare &&
|
||||
node.global);
|
||||
}
|
||||
return Object.assign(Object.assign({}, (option === 'interface' && {
|
||||
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(node) {
|
||||
context.report({
|
||||
node: node.id,
|
||||
messageId: 'interfaceOverType',
|
||||
fix(fixer) {
|
||||
var _a;
|
||||
const typeNode = (_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.id;
|
||||
const fixes = [];
|
||||
const firstToken = sourceCode.getTokenBefore(node.id);
|
||||
if (firstToken) {
|
||||
fixes.push(fixer.replaceText(firstToken, 'interface'));
|
||||
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.typeAnnotation.range[0]], ' '));
|
||||
}
|
||||
const afterToken = sourceCode.getTokenAfter(node.typeAnnotation);
|
||||
if (afterToken &&
|
||||
afterToken.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
|
||||
afterToken.value === ';') {
|
||||
fixes.push(fixer.remove(afterToken));
|
||||
}
|
||||
return fixes;
|
||||
},
|
||||
});
|
||||
},
|
||||
})), (option === 'type' && {
|
||||
TSInterfaceDeclaration(node) {
|
||||
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration()
|
||||
? null
|
||||
: (fixer) => {
|
||||
var _a, _b;
|
||||
const typeNode = (_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.id;
|
||||
const fixes = [];
|
||||
const firstToken = sourceCode.getTokenBefore(node.id);
|
||||
if (firstToken) {
|
||||
fixes.push(fixer.replaceText(firstToken, 'type'));
|
||||
fixes.push(fixer.replaceTextRange([typeNode.range[1], node.body.range[0]], ' = '));
|
||||
}
|
||||
if (node.extends) {
|
||||
node.extends.forEach(heritage => {
|
||||
const typeIdentifier = sourceCode.getText(heritage);
|
||||
fixes.push(fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`));
|
||||
});
|
||||
}
|
||||
if (((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
||||
fixes.push(fixer.removeRange([node.parent.range[0], node.range[0]]), fixer.insertTextAfter(node.body, `\nexport default ${node.id.name}`));
|
||||
}
|
||||
return fixes;
|
||||
};
|
||||
context.report({
|
||||
node: node.id,
|
||||
messageId: 'typeOverInterface',
|
||||
/**
|
||||
* remove automatically fix when the interface is within a declare global
|
||||
* @see {@link https://github.com/typescript-eslint/typescript-eslint/issues/2707}
|
||||
*/
|
||||
fix,
|
||||
});
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-type-definitions.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"consistent-type-definitions.js","sourceRoot":"","sources":["../../src/rules/consistent-type-definitions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA2E;AAE3E,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,2EAA2E;YAC7E,WAAW,EAAE,QAAQ;SACtB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,yCAAyC;YAC5D,iBAAiB,EAAE,yCAAyC;SAC7D;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;aAC5B;SACF;QACD,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,CAAC,WAAW,CAAC;IAC7B,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;QACtB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE3C;;;WAGG;QACH,SAAS,+CAA+C;YACtD,OAAO,OAAO;iBACX,YAAY,EAAE;iBACd,IAAI,CACH,IAAI,CAAC,EAAE,CACL,IAAI,CAAC,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oB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CACnC,CACF,CAAC;yBACH;wBAED,OAAO,KAAK,CAAC;oBACf,CAAC,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,IAAI,CAAC,EAAE;oBACb,SAAS,EAAE,mBAAmB;oBAC9B;;;uBAGG;oBACH,GAAG;iBACJ,CAAC,CAAC;YACL,CAAC;SACF,CAAC,EACF;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,266 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const typescript_1 = require("typescript");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-exports',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce consistent usage of type exports',
|
||||
recommended: false,
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
messages: {
|
||||
typeOverValue: 'All exports in the declaration are only used as types. Use `export type`.',
|
||||
singleExportIsType: 'Type export {{exportNames}} is not a value and should be exported using `export type`.',
|
||||
multipleExportsAreTypes: 'Type exports {{exportNames}} are not values and should be exported using `export type`.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
fixMixedExportsWithInlineTypeSpecifier: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
fixMixedExportsWithInlineTypeSpecifier: false,
|
||||
},
|
||||
],
|
||||
create(context, [{ fixMixedExportsWithInlineTypeSpecifier }]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceExportsMap = {};
|
||||
const parserServices = util.getParserServices(context);
|
||||
return {
|
||||
ExportNamedDeclaration(node) {
|
||||
var _a;
|
||||
// Coerce the source into a string for use as a lookup entry.
|
||||
const source = (_a = getSourceFromExport(node)) !== null && _a !== void 0 ? _a : 'undefined';
|
||||
const sourceExports = (sourceExportsMap[source] || (sourceExportsMap[source] = {
|
||||
source,
|
||||
reportValueExports: [],
|
||||
typeOnlyNamedExport: null,
|
||||
valueOnlyNamedExport: null,
|
||||
}));
|
||||
// Cache the first encountered exports for the package. We will need to come
|
||||
// back to these later when fixing the problems.
|
||||
if (node.exportKind === 'type') {
|
||||
if (sourceExports.typeOnlyNamedExport == null) {
|
||||
// The export is a type export
|
||||
sourceExports.typeOnlyNamedExport = node;
|
||||
}
|
||||
}
|
||||
else if (sourceExports.valueOnlyNamedExport == null) {
|
||||
// The export is a value export
|
||||
sourceExports.valueOnlyNamedExport = node;
|
||||
}
|
||||
// Next for the current export, we will separate type/value specifiers.
|
||||
const typeBasedSpecifiers = [];
|
||||
const inlineTypeSpecifiers = [];
|
||||
const valueSpecifiers = [];
|
||||
// Note: it is valid to export values as types. We will avoid reporting errors
|
||||
// when this is encountered.
|
||||
if (node.exportKind !== 'type') {
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.exportKind === 'type') {
|
||||
inlineTypeSpecifiers.push(specifier);
|
||||
continue;
|
||||
}
|
||||
const isTypeBased = isSpecifierTypeBased(parserServices, specifier);
|
||||
if (isTypeBased === true) {
|
||||
typeBasedSpecifiers.push(specifier);
|
||||
}
|
||||
else if (isTypeBased === false) {
|
||||
// When isTypeBased is undefined, we should avoid reporting them.
|
||||
valueSpecifiers.push(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((node.exportKind === 'value' && typeBasedSpecifiers.length) ||
|
||||
(node.exportKind === 'type' && valueSpecifiers.length)) {
|
||||
sourceExports.reportValueExports.push({
|
||||
node,
|
||||
typeBasedSpecifiers,
|
||||
valueSpecifiers,
|
||||
inlineTypeSpecifiers,
|
||||
});
|
||||
}
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const sourceExports of Object.values(sourceExportsMap)) {
|
||||
// If this export has no issues, move on.
|
||||
if (sourceExports.reportValueExports.length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const report of sourceExports.reportValueExports) {
|
||||
if (report.valueSpecifiers.length === 0) {
|
||||
// Export is all type-only with no type specifiers; convert the entire export to `export type`.
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'typeOverValue',
|
||||
*fix(fixer) {
|
||||
yield* fixExportInsertType(fixer, sourceCode, report.node);
|
||||
},
|
||||
});
|
||||
continue;
|
||||
}
|
||||
// We have both type and value violations.
|
||||
const allExportNames = report.typeBasedSpecifiers.map(specifier => `${specifier.local.name}`);
|
||||
if (allExportNames.length === 1) {
|
||||
const exportNames = allExportNames[0];
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'singleExportIsType',
|
||||
data: { exportNames },
|
||||
*fix(fixer) {
|
||||
if (fixMixedExportsWithInlineTypeSpecifier) {
|
||||
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
|
||||
}
|
||||
else {
|
||||
yield* fixSeparateNamedExports(fixer, sourceCode, report);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
const exportNames = util.formatWordList(allExportNames);
|
||||
context.report({
|
||||
node: report.node,
|
||||
messageId: 'multipleExportsAreTypes',
|
||||
data: { exportNames },
|
||||
*fix(fixer) {
|
||||
if (fixMixedExportsWithInlineTypeSpecifier) {
|
||||
yield* fixAddTypeSpecifierToNamedExports(fixer, report);
|
||||
}
|
||||
else {
|
||||
yield* fixSeparateNamedExports(fixer, sourceCode, report);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
/**
|
||||
* Helper for identifying if an export specifier resolves to a
|
||||
* JavaScript value or a TypeScript type.
|
||||
*
|
||||
* @returns True/false if is a type or not, or undefined if the specifier
|
||||
* can't be resolved.
|
||||
*/
|
||||
function isSpecifierTypeBased(parserServices, specifier) {
|
||||
const checker = parserServices.program.getTypeChecker();
|
||||
const node = parserServices.esTreeNodeToTSNodeMap.get(specifier.exported);
|
||||
const symbol = checker.getSymbolAtLocation(node);
|
||||
const aliasedSymbol = checker.getAliasedSymbol(symbol);
|
||||
if (!aliasedSymbol || aliasedSymbol.escapedName === 'unknown') {
|
||||
return undefined;
|
||||
}
|
||||
return !(aliasedSymbol.flags & typescript_1.SymbolFlags.Value);
|
||||
}
|
||||
/**
|
||||
* Inserts "type" into an export.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* export type { Foo } from 'foo';
|
||||
* ^^^^
|
||||
*/
|
||||
function* fixExportInsertType(fixer, sourceCode, node) {
|
||||
const exportToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('export', node.type));
|
||||
yield fixer.insertTextAfter(exportToken, ' type');
|
||||
for (const specifier of node.specifiers) {
|
||||
if (specifier.exportKind === 'type') {
|
||||
const kindToken = util.nullThrows(sourceCode.getFirstToken(specifier), util.NullThrowsReasons.MissingToken('export', specifier.type));
|
||||
const firstTokenAfter = util.nullThrows(sourceCode.getTokenAfter(kindToken, {
|
||||
includeComments: true,
|
||||
}), 'Missing token following the export kind.');
|
||||
yield fixer.removeRange([kindToken.range[0], firstTokenAfter.range[0]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Separates the exports which mismatch the kind of export the given
|
||||
* node represents. For example, a type export's named specifiers which
|
||||
* represent values will be inserted in a separate `export` statement.
|
||||
*/
|
||||
function* fixSeparateNamedExports(fixer, sourceCode, report) {
|
||||
const { node, typeBasedSpecifiers, inlineTypeSpecifiers, valueSpecifiers } = report;
|
||||
const typeSpecifiers = typeBasedSpecifiers.concat(inlineTypeSpecifiers);
|
||||
const source = getSourceFromExport(node);
|
||||
const specifierNames = typeSpecifiers.map(getSpecifierText).join(', ');
|
||||
const exportToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('export', node.type));
|
||||
// Filter the bad exports from the current line.
|
||||
const filteredSpecifierNames = valueSpecifiers
|
||||
.map(getSpecifierText)
|
||||
.join(', ');
|
||||
const openToken = util.nullThrows(sourceCode.getFirstToken(node, util.isOpeningBraceToken), util.NullThrowsReasons.MissingToken('{', node.type));
|
||||
const closeToken = util.nullThrows(sourceCode.getLastToken(node, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
|
||||
// Remove exports from the current line which we're going to re-insert.
|
||||
yield fixer.replaceTextRange([openToken.range[1], closeToken.range[0]], ` ${filteredSpecifierNames} `);
|
||||
// Insert the bad exports into a new export line above.
|
||||
yield fixer.insertTextBefore(exportToken, `export type { ${specifierNames} }${source ? ` from '${source}'` : ''};\n`);
|
||||
}
|
||||
function* fixAddTypeSpecifierToNamedExports(fixer, report) {
|
||||
if (report.node.exportKind === 'type') {
|
||||
return;
|
||||
}
|
||||
for (const specifier of report.typeBasedSpecifiers) {
|
||||
yield fixer.insertTextBefore(specifier, 'type ');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the source of the export, or undefined if the named export has no source.
|
||||
*/
|
||||
function getSourceFromExport(node) {
|
||||
var _a;
|
||||
if (((_a = node.source) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.Literal &&
|
||||
typeof node.source.value === 'string') {
|
||||
return node.source.value;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Returns the specifier text for the export. If it is aliased, we take care to return
|
||||
* the proper formatting.
|
||||
*/
|
||||
function getSpecifierText(specifier) {
|
||||
return `${specifier.local.name}${specifier.exported.name !== specifier.local.name
|
||||
? ` as ${specifier.exported.name}`
|
||||
: ''}`;
|
||||
}
|
||||
//# sourceMappingURL=consistent-type-exports.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,644 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'consistent-type-imports',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce consistent usage of type imports',
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
typeOverValue: 'All imports in the declaration are only used as types. Use `import type`.',
|
||||
someImportsAreOnlyTypes: 'Imports {{typeImports}} are only used as types.',
|
||||
aImportIsOnlyTypes: 'Import {{typeImports}} is only used as types.',
|
||||
someImportsInDecoMeta: 'Type imports {{typeImports}} are used by decorator metadata.',
|
||||
aImportInDecoMeta: 'Type import {{typeImports}} is used by decorator metadata.',
|
||||
valueOverType: 'Use an `import` instead of an `import type`.',
|
||||
noImportTypeAnnotations: '`import()` type annotations are forbidden.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
prefer: {
|
||||
enum: ['type-imports', 'no-type-imports'],
|
||||
},
|
||||
disallowTypeAnnotations: {
|
||||
type: 'boolean',
|
||||
},
|
||||
fixStyle: {
|
||||
enum: ['separate-type-imports', 'inline-type-imports'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: 'code',
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
prefer: 'type-imports',
|
||||
disallowTypeAnnotations: true,
|
||||
fixStyle: 'separate-type-imports',
|
||||
},
|
||||
],
|
||||
create(context, [option]) {
|
||||
var _a, _b;
|
||||
const prefer = (_a = option.prefer) !== null && _a !== void 0 ? _a : 'type-imports';
|
||||
const disallowTypeAnnotations = option.disallowTypeAnnotations !== false;
|
||||
const fixStyle = (_b = option.fixStyle) !== null && _b !== void 0 ? _b : 'separate-type-imports';
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceImportsMap = {};
|
||||
return Object.assign(Object.assign({}, (prefer === 'type-imports'
|
||||
? {
|
||||
// prefer type imports
|
||||
ImportDeclaration(node) {
|
||||
var _a;
|
||||
const source = node.source.value;
|
||||
// sourceImports is the object containing all the specifics for a particular import source, type or value
|
||||
const sourceImports = (_a = sourceImportsMap[source]) !== null && _a !== void 0 ? _a : (sourceImportsMap[source] = {
|
||||
source,
|
||||
reportValueImports: [],
|
||||
typeOnlyNamedImport: null,
|
||||
valueOnlyNamedImport: null,
|
||||
valueImport: null, // if only value imports
|
||||
});
|
||||
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] = context.getDeclaredVariables(specifier);
|
||||
if (variable.references.length === 0) {
|
||||
unusedSpecifiers.push(specifier);
|
||||
}
|
||||
else {
|
||||
const onlyHasTypeReferences = variable.references.every(ref => {
|
||||
var _a, _b;
|
||||
/**
|
||||
* keep origin import kind when export
|
||||
* export { Type }
|
||||
* export default Type;
|
||||
*/
|
||||
if (((_a = ref.identifier.parent) === null || _a === void 0 ? void 0 : _a.type) ===
|
||||
utils_1.AST_NODE_TYPES.ExportSpecifier ||
|
||||
((_b = ref.identifier.parent) === null || _b === void 0 ? void 0 : _b.type) ===
|
||||
utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
|
||||
if (ref.isValueReference && ref.isTypeReference) {
|
||||
return node.importKind === 'type';
|
||||
}
|
||||
}
|
||||
if (ref.isValueReference) {
|
||||
let parent = ref.identifier.parent;
|
||||
let child = ref.identifier;
|
||||
while (parent) {
|
||||
switch (parent.type) {
|
||||
// CASE 1:
|
||||
// `type T = typeof foo` will create a value reference because "foo" must be a value type
|
||||
// however this value reference is safe to use with type-only imports
|
||||
case utils_1.AST_NODE_TYPES.TSTypeQuery:
|
||||
return true;
|
||||
case utils_1.AST_NODE_TYPES.TSQualifiedName:
|
||||
// TSTypeQuery must have a TSESTree.EntityName as its child, so we can filter here and break early
|
||||
if (parent.left !== child) {
|
||||
return false;
|
||||
}
|
||||
child = parent;
|
||||
parent = parent.parent;
|
||||
continue;
|
||||
// END CASE 1
|
||||
//////////////
|
||||
// CASE 2:
|
||||
// `type T = { [foo]: string }` will create a value reference because "foo" must be a value type
|
||||
// however this value reference is safe to use with type-only imports.
|
||||
// Also this is represented as a non-type AST - hence it uses MemberExpression
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
return parent.key === child;
|
||||
case utils_1.AST_NODE_TYPES.MemberExpression:
|
||||
if (parent.object !== child) {
|
||||
return false;
|
||||
}
|
||||
child = parent;
|
||||
parent = parent.parent;
|
||||
continue;
|
||||
// END CASE 2
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ref.isTypeReference;
|
||||
});
|
||||
if (onlyHasTypeReferences) {
|
||||
typeSpecifiers.push(specifier);
|
||||
}
|
||||
else {
|
||||
valueSpecifiers.push(specifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((node.importKind === 'value' && typeSpecifiers.length) ||
|
||||
(node.importKind === 'type' && valueSpecifiers.length)) {
|
||||
sourceImports.reportValueImports.push({
|
||||
node,
|
||||
typeSpecifiers,
|
||||
valueSpecifiers,
|
||||
unusedSpecifiers,
|
||||
inlineTypeSpecifiers,
|
||||
});
|
||||
}
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const sourceImports of Object.values(sourceImportsMap)) {
|
||||
if (sourceImports.reportValueImports.length === 0) {
|
||||
// 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') {
|
||||
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 = util.formatWordList(importNames);
|
||||
if (importNames.length === 1) {
|
||||
if (isTypeImport) {
|
||||
return {
|
||||
messageId: 'aImportInDecoMeta',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
messageId: 'aImportIsOnlyTypes',
|
||||
data: { typeImports },
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isTypeImport) {
|
||||
return {
|
||||
messageId: 'someImportsInDecoMeta',
|
||||
data: { typeImports }, // typeImports are all the value specifiers that are in the type position
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
messageId: 'someImportsAreOnlyTypes',
|
||||
data: { typeImports }, // typeImports are all the type specifiers in the value position
|
||||
};
|
||||
}
|
||||
}
|
||||
})();
|
||||
context.report(Object.assign(Object.assign({ 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) {
|
||||
var _a;
|
||||
const defaultSpecifier = node.specifiers[0].type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier
|
||||
? node.specifiers[0]
|
||||
: null;
|
||||
const namespaceSpecifier = (_a = node.specifiers.find((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier)) !== null && _a !== void 0 ? _a : null;
|
||||
const namedSpecifiers = node.specifiers.filter((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier);
|
||||
return {
|
||||
defaultSpecifier,
|
||||
namespaceSpecifier,
|
||||
namedSpecifiers,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns information for fixing named specifiers, 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 = util.nullThrows(sourceCode.getTokenBefore(subsetNamedSpecifiers[0], util.isOpeningBraceToken), util.NullThrowsReasons.MissingToken('{', node.type));
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenBefore(openingBraceToken, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
|
||||
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
|
||||
// import DefType, {...} from 'foo'
|
||||
// ^^^^^^^ remove
|
||||
removeTypeNamedSpecifiers.push(fixer.removeRange([commaToken.range[0], closingBraceToken.range[1]]));
|
||||
typeNamedSpecifiersTexts.push(sourceCode.text.slice(openingBraceToken.range[1], closingBraceToken.range[0]));
|
||||
}
|
||||
else {
|
||||
const 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 (util.isCommaToken(before)) {
|
||||
removeRange[0] = before.range[0];
|
||||
}
|
||||
else {
|
||||
removeRange[0] = before.range[1];
|
||||
}
|
||||
const isFirst = allNamedSpecifiers[0] === first;
|
||||
const isLast = allNamedSpecifiers[allNamedSpecifiers.length - 1] === last;
|
||||
const after = sourceCode.getTokenAfter(last);
|
||||
textRange[1] = after.range[0];
|
||||
if (isFirst || isLast) {
|
||||
if (util.isCommaToken(after)) {
|
||||
removeRange[1] = after.range[1];
|
||||
}
|
||||
}
|
||||
return {
|
||||
textRange,
|
||||
removeRange,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* insert specifiers to named import node.
|
||||
* e.g.
|
||||
* import type { Already, Type1, Type2 } from 'foo'
|
||||
* ^^^^^^^^^^^^^ insert
|
||||
*/
|
||||
function fixInsertNamedSpecifiersInNamedSpecifierList(fixer, target, insertText) {
|
||||
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(sourceCode.getFirstToken(target), target.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', target.type));
|
||||
const before = sourceCode.getTokenBefore(closingBraceToken);
|
||||
if (!util.isCommaToken(before) && !util.isOpeningBraceToken(before)) {
|
||||
insertText = `,${insertText}`;
|
||||
}
|
||||
return fixer.insertTextBefore(closingBraceToken, insertText);
|
||||
}
|
||||
/**
|
||||
* 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'
|
||||
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 = util.nullThrows(sourceCode.getTokenBefore(namespaceSpecifier, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
|
||||
// import Def, * as Ns from 'foo'
|
||||
// ^^^^^^^^^ remove
|
||||
fixesRemoveTypeNamespaceSpecifier.push(fixer.removeRange([commaToken.range[0], namespaceSpecifier.range[1]]));
|
||||
// import type * as Ns from 'foo'
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ insert
|
||||
yield fixer.insertTextBefore(node, `import type ${sourceCode.getText(namespaceSpecifier)} from ${sourceCode.getText(node.source)};\n`);
|
||||
}
|
||||
if (defaultSpecifier &&
|
||||
report.typeSpecifiers.includes(defaultSpecifier)) {
|
||||
if (report.typeSpecifiers.length === node.specifiers.length) {
|
||||
const importToken = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import', node.type));
|
||||
// import type Type from 'foo'
|
||||
// ^^^^ insert
|
||||
yield fixer.insertTextAfter(importToken, ' type');
|
||||
}
|
||||
else {
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenAfter(defaultSpecifier, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', defaultSpecifier.type));
|
||||
// import Type , {...} from 'foo'
|
||||
// ^^^^^ pick
|
||||
const defaultText = sourceCode.text
|
||||
.slice(defaultSpecifier.range[0], commaToken.range[0])
|
||||
.trim();
|
||||
yield fixer.insertTextBefore(node, `import type ${defaultText} from ${sourceCode.getText(node.source)};\n`);
|
||||
const afterToken = util.nullThrows(sourceCode.getTokenAfter(commaToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
|
||||
// import Type , {...} from 'foo'
|
||||
// ^^^^^^^ remove
|
||||
yield fixer.removeRange([
|
||||
defaultSpecifier.range[0],
|
||||
afterToken.range[0],
|
||||
]);
|
||||
}
|
||||
}
|
||||
yield* fixesNamedSpecifiers.removeTypeNamedSpecifiers;
|
||||
yield* fixesRemoveTypeNamespaceSpecifier;
|
||||
yield* afterFixes;
|
||||
}
|
||||
function* fixInsertTypeSpecifierForImportDeclaration(fixer, node, isDefaultImport) {
|
||||
// import type Foo from 'foo'
|
||||
// ^^^^^ insert
|
||||
const importToken = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import', node.type));
|
||||
yield fixer.insertTextAfter(importToken, ' type');
|
||||
if (isDefaultImport) {
|
||||
// Has default import
|
||||
const openingBraceToken = sourceCode.getFirstTokenBetween(importToken, node.source, util.isOpeningBraceToken);
|
||||
if (openingBraceToken) {
|
||||
// Only braces. e.g. import Foo, {} from 'foo'
|
||||
const commaToken = util.nullThrows(sourceCode.getTokenBefore(openingBraceToken, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
|
||||
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
|
||||
// import type Foo, {} from 'foo'
|
||||
// ^^ remove
|
||||
yield fixer.removeRange([
|
||||
commaToken.range[0],
|
||||
closingBraceToken.range[1],
|
||||
]);
|
||||
const specifiersText = sourceCode.text.slice(commaToken.range[1], closingBraceToken.range[1]);
|
||||
if (node.specifiers.length > 1) {
|
||||
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) {
|
||||
var _a, _b;
|
||||
// import type Foo from 'foo'
|
||||
// ^^^^ remove
|
||||
const importToken = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import', node.type));
|
||||
const typeToken = util.nullThrows(sourceCode.getFirstTokenBetween(importToken, (_b = (_a = node.specifiers[0]) === null || _a === void 0 ? void 0 : _a.local) !== null && _b !== void 0 ? _b : node.source, util.isTypeKeyword), util.NullThrowsReasons.MissingToken('type', node.type));
|
||||
const afterToken = util.nullThrows(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
|
||||
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);
|
||||
}
|
||||
function* fixRemoveTypeSpecifierFromImportSpecifier(fixer, node) {
|
||||
// import { type Foo } from 'foo'
|
||||
// ^^^^ remove
|
||||
const typeToken = util.nullThrows(sourceCode.getFirstToken(node, util.isTypeKeyword), util.NullThrowsReasons.MissingToken('type', node.type));
|
||||
const afterToken = util.nullThrows(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
|
||||
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=consistent-type-imports.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,64 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'default-param-last',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce default parameters to be last',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
shouldBeLast: 'Default parameters should be last.',
|
||||
},
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
/**
|
||||
* checks if node is optional parameter
|
||||
* @param node the node to be evaluated
|
||||
* @private
|
||||
*/
|
||||
function isOptionalParam(node) {
|
||||
return 'optional' in node && node.optional === true;
|
||||
}
|
||||
/**
|
||||
* checks if node is plain parameter
|
||||
* @param node the node to be evaluated
|
||||
* @private
|
||||
*/
|
||||
function isPlainParam(node) {
|
||||
return !(node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
|
||||
node.type === utils_1.AST_NODE_TYPES.RestElement ||
|
||||
isOptionalParam(node));
|
||||
}
|
||||
function checkDefaultParamLast(node) {
|
||||
let hasSeenPlainParam = false;
|
||||
for (let i = node.params.length - 1; i >= 0; i--) {
|
||||
const current = node.params[i];
|
||||
const param = current.type === utils_1.AST_NODE_TYPES.TSParameterProperty
|
||||
? current.parameter
|
||||
: current;
|
||||
if (isPlainParam(param)) {
|
||||
hasSeenPlainParam = true;
|
||||
continue;
|
||||
}
|
||||
if (hasSeenPlainParam &&
|
||||
(isOptionalParam(param) ||
|
||||
param.type === utils_1.AST_NODE_TYPES.AssignmentPattern)) {
|
||||
context.report({ node: current, messageId: 'shouldBeLast' });
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: checkDefaultParamLast,
|
||||
FunctionDeclaration: checkDefaultParamLast,
|
||||
FunctionExpression: checkDefaultParamLast,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=default-param-last.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"default-param-last.js","sourceRoot":"","sources":["../../src/rules/default-param-last.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAAqC;AAErC,kBAAe,IAAA,iBAAU,EAAC;IACxB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,uCAAuC;YACpD,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,YAAY,EAAE,oCAAoC;SACnD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ;;;;WAIG;QACH,SAAS,eAAe,CAAC,IAAwB;YAC/C,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC;QACtD,CAAC;QAED;;;;WAIG;QACH,SAAS,YAAY,CAAC,IAAwB;YAC5C,OAAO,CAAC,CACN,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB;gBAC9C,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,WAAW;gBACxC,eAAe,CAAC,IAAI,CAAC,CACtB,CAAC;QACJ,CAAC;QAED,SAAS,qBAAqB,CAC5B,IAG+B;YAE/B,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAC9B,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;gBAChD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,KAAK,GACT,OAAO,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;oBACjD,CAAC,CAAC,OAAO,CAAC,SAAS;oBACnB,CAAC,CAAC,OAAO,CAAC;gBAEd,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;oBACvB,iBAAiB,GAAG,IAAI,CAAC;oBACzB,SAAS;iBACV;gBAED,IACE,iBAAiB;oBACjB,CAAC,eAAe,CAAC,KAAK,CAAC;wBACrB,KAAK,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB,CAAC,EAClD;oBACA,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;iBAC9D;aACF;QACH,CAAC;QAED,OAAO;YACL,uBAAuB,EAAE,qBAAqB;YAC9C,mBAAmB,EAAE,qBAAqB;YAC1C,kBAAkB,EAAE,qBAAqB;SAC1C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,125 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tsutils = __importStar(require("tsutils"));
|
||||
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: 'strict',
|
||||
extendsBaseRule: true,
|
||||
requiresTypeChecking: true,
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowKeywords: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
allowPattern: {
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
allowPrivateClassPropertyAccess: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
allowProtectedClassPropertyAccess: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
allowIndexSignaturePropertyAccess: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
fixable: baseRule.meta.fixable,
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowPrivateClassPropertyAccess: false,
|
||||
allowProtectedClassPropertyAccess: false,
|
||||
allowIndexSignaturePropertyAccess: false,
|
||||
allowKeywords: true,
|
||||
allowPattern: '',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
var _a;
|
||||
const rules = baseRule.create(context);
|
||||
const { program, esTreeNodeToTSNodeMap } = (0, util_1.getParserServices)(context);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const allowPrivateClassPropertyAccess = options.allowPrivateClassPropertyAccess;
|
||||
const allowProtectedClassPropertyAccess = options.allowProtectedClassPropertyAccess;
|
||||
const allowIndexSignaturePropertyAccess = ((_a = options.allowIndexSignaturePropertyAccess) !== null && _a !== void 0 ? _a : false) ||
|
||||
tsutils.isCompilerOptionEnabled(program.getCompilerOptions(),
|
||||
// @ts-expect-error - TS is refining the type to never for some reason
|
||||
'noPropertyAccessFromIndexSignature');
|
||||
return {
|
||||
MemberExpression(node) {
|
||||
var _a, _b;
|
||||
if ((allowPrivateClassPropertyAccess ||
|
||||
allowProtectedClassPropertyAccess ||
|
||||
allowIndexSignaturePropertyAccess) &&
|
||||
node.computed) {
|
||||
// for perf reasons - only fetch symbols if we have to
|
||||
const propertySymbol = typeChecker.getSymbolAtLocation(esTreeNodeToTSNodeMap.get(node.property));
|
||||
const modifierKind = (_b = (0, util_1.getModifiers)((_a = propertySymbol === null || propertySymbol === void 0 ? void 0 : propertySymbol.getDeclarations()) === null || _a === void 0 ? void 0 : _a[0])) === null || _b === void 0 ? void 0 : _b[0].kind;
|
||||
if ((allowPrivateClassPropertyAccess &&
|
||||
modifierKind === ts.SyntaxKind.PrivateKeyword) ||
|
||||
(allowProtectedClassPropertyAccess &&
|
||||
modifierKind === ts.SyntaxKind.ProtectedKeyword)) {
|
||||
return;
|
||||
}
|
||||
if (propertySymbol === undefined &&
|
||||
allowIndexSignaturePropertyAccess) {
|
||||
const objectType = typeChecker.getTypeAtLocation(esTreeNodeToTSNodeMap.get(node.object));
|
||||
const indexType = objectType
|
||||
.getNonNullableType()
|
||||
.getStringIndexType();
|
||||
if (indexType !== undefined) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
rules.MemberExpression(node);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=dot-notation.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"dot-notation.js","sourceRoot":"","sources":["../../src/rules/dot-notation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAmC;AACnC,+CAAiC;AAMjC,kCAAsE;AACtE,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC;AAKnD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,wCAAwC;YACrD,WAAW,EAAE,QAAQ;YACrB,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,IAAI;qBACd;oBACD,YAAY,EAAE;wBACZ,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,EAAE;qBACZ;oBACD,+BAA+B,EAAE;wBAC/B,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,iCAAiC,EAAE;wBACjC,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;oBACD,iCAAiC,EAAE;wBACjC,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,KAAK;qBACf;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;QAC9B,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE;QACd;YACE,+BAA+B,EAAE,KAAK;YACtC,iCAAiC,EAAE,KAAK;YACxC,iCAAiC,EAAE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;oBACD,IACE,cAAc,KAAK,SAAS;wBAC5B,iCAAiC,EACjC;wBACA,MAAM,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAC9C,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CACvC,CAAC;wBACF,MAAM,SAAS,GAAG,UAAU;6BACzB,kBAAkB,EAAE;6BACpB,kBAAkB,EAAE,CAAC;wBACxB,IAAI,SAAS,KAAK,SAAS,EAAE;4BAC3B,OAAO;yBACR;qBACF;iBACF;gBACD,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,61 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getEnumTypes = void 0;
|
||||
const tsutils = __importStar(require("tsutils"));
|
||||
const ts = __importStar(require("typescript"));
|
||||
const util = __importStar(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);
|
||||
}
|
||||
/**
|
||||
* 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 tsutils
|
||||
.unionTypeParts(type)
|
||||
.filter(subType => util.isTypeFlagSet(subType, ts.TypeFlags.EnumLiteral))
|
||||
.map(type => getBaseEnumType(typeChecker, type));
|
||||
}
|
||||
exports.getEnumTypes = getEnumTypes;
|
||||
//# sourceMappingURL=shared.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/rules/enum-utils/shared.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,+CAAiC;AAEjC,iDAAmC;AAEnC;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,WAA2B,EAAE,IAAa;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAG,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;QAC/D,OAAO,IAAI,CAAC;KACb;IAED,OAAO,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,gBAAiB,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAC1B,WAA2B,EAC3B,IAAa;IAEb,OAAO,OAAO;SACX,cAAc,CAAC,IAAI,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;SACxE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC;AARD,oCAQC"}
|
||||
@@ -1,189 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
|
||||
exports.default = util.createRule({
|
||||
name: 'explicit-function-return-type',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Require explicit return types on functions and class methods',
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
missingReturnType: 'Missing return type on function.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
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 = context.getSourceCode();
|
||||
function isAllowedFunction(node) {
|
||||
var _a, _b;
|
||||
if (options.allowFunctionsWithoutTypeParameters && !node.typeParameters) {
|
||||
return true;
|
||||
}
|
||||
if (options.allowIIFEs && isIIFE(node)) {
|
||||
return true;
|
||||
}
|
||||
if (!((_a = options.allowedNames) === null || _a === void 0 ? void 0 : _a.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 ((_b = node.id) === null || _b === void 0 ? void 0 : _b.name) {
|
||||
funcName = node.id.name;
|
||||
}
|
||||
else if (parent) {
|
||||
switch (parent.type) {
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclarator: {
|
||||
if (parent.id.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
funcName = parent.id.name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.Property: {
|
||||
if (parent.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
parent.computed === false) {
|
||||
funcName = parent.key.name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!!funcName && !!options.allowedNames.includes(funcName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration &&
|
||||
node.id &&
|
||||
node.id.type === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
!!options.allowedNames.includes(node.id.name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
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 +0,0 @@
|
||||
{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA0D;AAE1D,8CAAgC;AAChC,6EAIyC;AAgBzC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI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CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CACH,CAAC;YACJ,CAAC;YACD,mBAAmB,CAAC,IAAI;gBACtB,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;oBAC3B,OAAO;iBACR;gBACD,IAAI,OAAO,CAAC,6BAA6B,IAAI,IAAI,CAAC,UAAU,EAAE;oBAC5D,OAAO;iBACR;gBAED,IAAA,iDAAuB,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,CACvD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG;oBACH,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CACH,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,309 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const accessibilityLevel = {
|
||||
oneOf: [
|
||||
{
|
||||
const: 'explicit',
|
||||
description: 'Always require an accessor.',
|
||||
},
|
||||
{
|
||||
const: 'no-public',
|
||||
description: 'Require an accessor except when public.',
|
||||
},
|
||||
{
|
||||
const: 'off',
|
||||
description: 'Never check whether there is an accessor.',
|
||||
},
|
||||
],
|
||||
};
|
||||
exports.default = util.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
|
||||
recommended: false,
|
||||
},
|
||||
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,
|
||||
},
|
||||
prefixItems: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
accessibility: { $ref: '#/$defs/accessibilityLevel' },
|
||||
overrides: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
accessors: { $ref: '#/$defs/accessibilityLevel' },
|
||||
constructors: { $ref: '#/$defs/accessibilityLevel' },
|
||||
methods: { $ref: '#/$defs/accessibilityLevel' },
|
||||
properties: { $ref: '#/$defs/accessibilityLevel' },
|
||||
parameterProperties: {
|
||||
$ref: '#/$defs/accessibilityLevel',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
ignoredMethodNames: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
type: 'array',
|
||||
},
|
||||
},
|
||||
defaultOptions: [{ accessibility: 'explicit' }],
|
||||
create(context, [option]) {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const baseCheck = (_a = option.accessibility) !== null && _a !== void 0 ? _a : 'explicit';
|
||||
const overrides = (_b = option.overrides) !== null && _b !== void 0 ? _b : {};
|
||||
const ctorCheck = (_c = overrides.constructors) !== null && _c !== void 0 ? _c : baseCheck;
|
||||
const accessorCheck = (_d = overrides.accessors) !== null && _d !== void 0 ? _d : baseCheck;
|
||||
const methodCheck = (_e = overrides.methods) !== null && _e !== void 0 ? _e : baseCheck;
|
||||
const propCheck = (_f = overrides.properties) !== null && _f !== void 0 ? _f : baseCheck;
|
||||
const paramPropCheck = (_g = overrides.parameterProperties) !== null && _g !== void 0 ? _g : baseCheck;
|
||||
const ignoredMethodNames = new Set((_h = option.ignoredMethodNames) !== null && _h !== void 0 ? _h : []);
|
||||
/**
|
||||
* Checks if a method declaration has an accessibility modifier.
|
||||
* @param methodDefinition The node representing a MethodDefinition.
|
||||
*/
|
||||
function checkMethodAccessibilityModifier(methodDefinition) {
|
||||
if (methodDefinition.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
let nodeType = 'method definition';
|
||||
let check = baseCheck;
|
||||
switch (methodDefinition.kind) {
|
||||
case 'method':
|
||||
check = methodCheck;
|
||||
break;
|
||||
case 'constructor':
|
||||
check = ctorCheck;
|
||||
break;
|
||||
case 'get':
|
||||
case 'set':
|
||||
check = accessorCheck;
|
||||
nodeType = `${methodDefinition.kind} property accessor`;
|
||||
break;
|
||||
}
|
||||
const { name: methodName } = util.getNameFromMember(methodDefinition, sourceCode);
|
||||
if (check === 'off' || ignoredMethodNames.has(methodName)) {
|
||||
return;
|
||||
}
|
||||
if (check === 'no-public' &&
|
||||
methodDefinition.accessibility === 'public') {
|
||||
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) {
|
||||
var _a;
|
||||
if ((_a = node === null || node === void 0 ? void 0 : node.decorators) === null || _a === void 0 ? void 0 : _a.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 } = util.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
|
||||
File diff suppressed because one or more lines are too long
@@ -1,396 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const scope_manager_1 = require("@typescript-eslint/scope-manager");
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
|
||||
exports.default = util.createRule({
|
||||
name: 'explicit-module-boundary-types',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: "Require explicit return and argument types on exported functions' and classes' public class methods",
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
missingReturnType: 'Missing return type on function.',
|
||||
missingArgType: "Argument '{{name}}' should be typed.",
|
||||
missingArgTypeUnnamed: '{{type}} argument should be typed.',
|
||||
anyTypedArg: "Argument '{{name}}' should be typed with a non-any type.",
|
||||
anyTypedArgUnnamed: '{{type}} argument should be typed with a non-any type.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowArgumentsExplicitlyTypedAsAny: {
|
||||
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',
|
||||
},
|
||||
// DEPRECATED - To be removed in next major
|
||||
shouldTrackReferences: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
allowArgumentsExplicitlyTypedAsAny: false,
|
||||
allowDirectConstAssertionInArrowFunctions: true,
|
||||
allowedNames: [],
|
||||
allowHigherOrderFunctions: true,
|
||||
allowTypedFunctionExpressions: true,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
// tracks all of the functions we've already checked
|
||||
const checkedFunctions = new Set();
|
||||
// tracks functions that were found whilst traversing
|
||||
const foundFunctions = [];
|
||||
// all nodes visited, avoids infinite recursion for cyclic references
|
||||
// (such as class member referring to itself)
|
||||
const alreadyVisited = new Set();
|
||||
/*
|
||||
# How the rule works:
|
||||
|
||||
As the rule traverses the AST, it immediately checks every single function that it finds is exported.
|
||||
"exported" means that it is either directly exported, or that its name is exported.
|
||||
|
||||
It also collects a list of every single function it finds on the way, but does not check them.
|
||||
After it's finished traversing the AST, it then iterates through the list of found functions, and checks to see if
|
||||
any of them are part of a higher-order function
|
||||
*/
|
||||
return {
|
||||
ExportDefaultDeclaration(node) {
|
||||
checkNode(node.declaration);
|
||||
},
|
||||
'ExportNamedDeclaration:not([source])'(node) {
|
||||
if (node.declaration) {
|
||||
checkNode(node.declaration);
|
||||
}
|
||||
else {
|
||||
for (const specifier of node.specifiers) {
|
||||
followReference(specifier.local);
|
||||
}
|
||||
}
|
||||
},
|
||||
TSExportAssignment(node) {
|
||||
checkNode(node.expression);
|
||||
},
|
||||
'ArrowFunctionExpression, FunctionDeclaration, FunctionExpression'(node) {
|
||||
foundFunctions.push(node);
|
||||
},
|
||||
'Program:exit'() {
|
||||
for (const func of foundFunctions) {
|
||||
if (isExportedHigherOrderFunction(func)) {
|
||||
checkNode(func);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
function checkParameters(node) {
|
||||
function checkParameter(param) {
|
||||
function report(namedMessageId, unnamedMessageId) {
|
||||
if (param.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: namedMessageId,
|
||||
data: { name: param.name },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Array pattern' },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Object pattern' },
|
||||
});
|
||||
}
|
||||
else if (param.type === utils_1.AST_NODE_TYPES.RestElement) {
|
||||
if (param.argument.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: namedMessageId,
|
||||
data: { name: param.argument.name },
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: param,
|
||||
messageId: unnamedMessageId,
|
||||
data: { type: 'Rest' },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (param.type) {
|
||||
case utils_1.AST_NODE_TYPES.ArrayPattern:
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
case utils_1.AST_NODE_TYPES.ObjectPattern:
|
||||
case utils_1.AST_NODE_TYPES.RestElement:
|
||||
if (!param.typeAnnotation) {
|
||||
report('missingArgType', 'missingArgTypeUnnamed');
|
||||
}
|
||||
else if (options.allowArgumentsExplicitlyTypedAsAny !== true &&
|
||||
param.typeAnnotation.typeAnnotation.type ===
|
||||
utils_1.AST_NODE_TYPES.TSAnyKeyword) {
|
||||
report('anyTypedArg', 'anyTypedArgUnnamed');
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.TSParameterProperty:
|
||||
return checkParameter(param.parameter);
|
||||
case utils_1.AST_NODE_TYPES.AssignmentPattern: // ignored as it has a type via its assignment
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const arg of node.params) {
|
||||
checkParameter(arg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if a function name is allowed and should not be checked.
|
||||
*/
|
||||
function isAllowedName(node) {
|
||||
var _a;
|
||||
if (!node || !options.allowedNames || !options.allowedNames.length) {
|
||||
return false;
|
||||
}
|
||||
if (node.type === utils_1.AST_NODE_TYPES.VariableDeclarator ||
|
||||
node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration) {
|
||||
return (((_a = node.id) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.Identifier &&
|
||||
options.allowedNames.includes(node.id.name));
|
||||
}
|
||||
else if (node.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
|
||||
node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
|
||||
(node.type === utils_1.AST_NODE_TYPES.Property && node.method) ||
|
||||
node.type === utils_1.AST_NODE_TYPES.PropertyDefinition) {
|
||||
if (node.key.type === utils_1.AST_NODE_TYPES.Literal &&
|
||||
typeof node.key.value === 'string') {
|
||||
return options.allowedNames.includes(node.key.value);
|
||||
}
|
||||
if (node.key.type === utils_1.AST_NODE_TYPES.TemplateLiteral &&
|
||||
node.key.expressions.length === 0) {
|
||||
return options.allowedNames.includes(node.key.quasis[0].value.raw);
|
||||
}
|
||||
if (!node.computed && node.key.type === utils_1.AST_NODE_TYPES.Identifier) {
|
||||
return options.allowedNames.includes(node.key.name);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isExportedHigherOrderFunction(node) {
|
||||
var _a;
|
||||
let current = node.parent;
|
||||
while (current) {
|
||||
if (current.type === utils_1.AST_NODE_TYPES.ReturnStatement) {
|
||||
// the parent of a return will always be a block statement, so we can skip over it
|
||||
current = (_a = current.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
||||
continue;
|
||||
}
|
||||
if (!util.isFunction(current) ||
|
||||
!(0, explicitReturnTypeUtils_1.doesImmediatelyReturnFunctionExpression)(current)) {
|
||||
return false;
|
||||
}
|
||||
if (checkedFunctions.has(current)) {
|
||||
return true;
|
||||
}
|
||||
current = current.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function followReference(node) {
|
||||
const scope = context.getScope();
|
||||
const variable = scope.set.get(node.name);
|
||||
/* istanbul ignore if */ if (!variable) {
|
||||
return;
|
||||
}
|
||||
// check all of the definitions
|
||||
for (const definition of variable.defs) {
|
||||
// cases we don't care about in this rule
|
||||
if ([
|
||||
scope_manager_1.DefinitionType.ImplicitGlobalVariable,
|
||||
scope_manager_1.DefinitionType.ImportBinding,
|
||||
scope_manager_1.DefinitionType.CatchClause,
|
||||
scope_manager_1.DefinitionType.Parameter,
|
||||
].includes(definition.type)) {
|
||||
continue;
|
||||
}
|
||||
checkNode(definition.node);
|
||||
}
|
||||
// follow references to find writes to the variable
|
||||
for (const reference of variable.references) {
|
||||
if (
|
||||
// we don't want to check the initialization ref, as this is handled by the declaration check
|
||||
!reference.init &&
|
||||
reference.writeExpr) {
|
||||
checkNode(reference.writeExpr);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkNode(node) {
|
||||
if (node == null || alreadyVisited.has(node)) {
|
||||
return;
|
||||
}
|
||||
alreadyVisited.add(node);
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
||||
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
||||
return checkFunctionExpression(node);
|
||||
case utils_1.AST_NODE_TYPES.ArrayExpression:
|
||||
for (const element of node.elements) {
|
||||
checkNode(element);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
if (node.accessibility === 'private' ||
|
||||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.ClassDeclaration:
|
||||
case utils_1.AST_NODE_TYPES.ClassExpression:
|
||||
for (const element of node.body.body) {
|
||||
checkNode(element);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration:
|
||||
return checkFunction(node);
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
if (node.accessibility === 'private' ||
|
||||
node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
|
||||
return;
|
||||
}
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
return followReference(node);
|
||||
case utils_1.AST_NODE_TYPES.ObjectExpression:
|
||||
for (const property of node.properties) {
|
||||
checkNode(property);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.Property:
|
||||
return checkNode(node.value);
|
||||
case utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression:
|
||||
return checkEmptyBodyFunctionExpression(node);
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclaration:
|
||||
for (const declaration of node.declarations) {
|
||||
checkNode(declaration);
|
||||
}
|
||||
return;
|
||||
case utils_1.AST_NODE_TYPES.VariableDeclarator:
|
||||
return checkNode(node.init);
|
||||
}
|
||||
}
|
||||
function checkEmptyBodyFunctionExpression(node) {
|
||||
var _a, _b, _c;
|
||||
const isConstructor = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
||||
node.parent.kind === 'constructor';
|
||||
const isSetAccessor = (((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
|
||||
((_c = node.parent) === null || _c === void 0 ? void 0 : _c.type) === utils_1.AST_NODE_TYPES.MethodDefinition) &&
|
||||
node.parent.kind === 'set';
|
||||
if (!isConstructor && !isSetAccessor && !node.returnType) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
}
|
||||
checkParameters(node);
|
||||
}
|
||||
function checkFunctionExpression(node) {
|
||||
if (checkedFunctions.has(node)) {
|
||||
return;
|
||||
}
|
||||
checkedFunctions.add(node);
|
||||
if (isAllowedName(node.parent) ||
|
||||
(0, explicitReturnTypeUtils_1.isTypedFunctionExpression)(node, options) ||
|
||||
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionExpressionReturnType)(node, options, sourceCode, loc => {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
});
|
||||
checkParameters(node);
|
||||
}
|
||||
function checkFunction(node) {
|
||||
if (checkedFunctions.has(node)) {
|
||||
return;
|
||||
}
|
||||
checkedFunctions.add(node);
|
||||
if (isAllowedName(node) || (0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node)) {
|
||||
return;
|
||||
}
|
||||
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(node, options, sourceCode, loc => {
|
||||
context.report({
|
||||
node,
|
||||
loc,
|
||||
messageId: 'missingReturnType',
|
||||
});
|
||||
});
|
||||
checkParameters(node);
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=explicit-module-boundary-types.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,168 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'func-call-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require or disallow spacing between function identifiers and their invocations',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
schema: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'array',
|
||||
items: [
|
||||
{
|
||||
enum: ['never'],
|
||||
},
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 1,
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: [
|
||||
{
|
||||
enum: ['always'],
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
allowNewlines: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
minItems: 0,
|
||||
maxItems: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
messages: {
|
||||
unexpectedWhitespace: 'Unexpected whitespace between function name and paren.',
|
||||
unexpectedNewline: 'Unexpected newline between function name and paren.',
|
||||
missing: 'Missing space between function name and paren.',
|
||||
},
|
||||
},
|
||||
defaultOptions: ['never', {}],
|
||||
create(context, [option, config]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const text = sourceCode.getText();
|
||||
/**
|
||||
* Check if open space is present in a function name
|
||||
* @param {ASTNode} node node to evaluate
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkSpacing(node) {
|
||||
var _a;
|
||||
const isOptionalCall = util.isOptionalCallExpression(node);
|
||||
const closingParenToken = sourceCode.getLastToken(node);
|
||||
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken((_a = node.typeParameters) !== null && _a !== void 0 ? _a : node.callee);
|
||||
const openingParenToken = sourceCode.getFirstTokenBetween(lastCalleeTokenWithoutPossibleParens, closingParenToken, util.isOpeningParenToken);
|
||||
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {
|
||||
// new expression with no parens...
|
||||
return;
|
||||
}
|
||||
const lastCalleeToken = sourceCode.getTokenBefore(openingParenToken, util.isNotOptionalChainPunctuator);
|
||||
const textBetweenTokens = text
|
||||
.slice(lastCalleeToken.range[1], openingParenToken.range[0])
|
||||
.replace(/\/\*.*?\*\//gu, '');
|
||||
const hasWhitespace = /\s/u.test(textBetweenTokens);
|
||||
const hasNewline = hasWhitespace && util.LINEBREAK_MATCHER.test(textBetweenTokens);
|
||||
if (option === 'never') {
|
||||
if (hasWhitespace) {
|
||||
return context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'unexpectedWhitespace',
|
||||
fix(fixer) {
|
||||
/*
|
||||
* Only autofix if there is no newline
|
||||
* https://github.com/eslint/eslint/issues/7787
|
||||
*/
|
||||
if (!hasNewline &&
|
||||
// don't fix optional calls
|
||||
!isOptionalCall) {
|
||||
return fixer.removeRange([
|
||||
lastCalleeToken.range[1],
|
||||
openingParenToken.range[0],
|
||||
]);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (isOptionalCall) {
|
||||
// disallow:
|
||||
// foo?. ();
|
||||
// foo ?.();
|
||||
// foo ?. ();
|
||||
if (hasWhitespace || hasNewline) {
|
||||
context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'unexpectedWhitespace',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!hasWhitespace) {
|
||||
context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'missing',
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(openingParenToken, ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
else if (!config.allowNewlines && hasNewline) {
|
||||
context.report({
|
||||
node,
|
||||
loc: lastCalleeToken.loc.start,
|
||||
messageId: 'unexpectedNewline',
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange([lastCalleeToken.range[1], openingParenToken.range[0]], ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
CallExpression: checkSpacing,
|
||||
NewExpression: checkSpacing,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=func-call-spacing.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"func-call-spacing.js","sourceRoot":"","sources":["../../src/rules/func-call-spacing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,8CAAgC;AAahC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EACT,gFAAgF;YAClF,WAAW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YAAY;gBACZ,YAAY;gBACZ,YAAY;gBACZ,aAAa;gBACb,IAAI,aAAa,IAAI,UAAU,EAAE;oBAC/B,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,sBAAsB;qBAClC,CAAC,CAAC;iBACJ;aACF;iBAAM;gBACL,IAAI,CAAC,aAAa,EAAE;oBAClB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,SAAS;wBACpB,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;wBACxD,CAAC;qBACF,CAAC,CAAC;iBACJ;qBAAM,IAAI,CAAC,MAAO,CAAC,aAAa,IAAI,UAAU,EAAE;oBAC/C,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK;wBAC9B,SAAS,EAAE,mBAAmB;wBAC9B,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,gBAAgB,CAC3B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACtD,GAAG,CACJ,CAAC;wBACJ,CAAC;qBACF,CAAC,CAAC;iBACJ;aACF;QACH,CAAC;QAED,OAAO;YACL,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,YAAY;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,410 +0,0 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Note this file is rather type-unsafe in its current state.
|
||||
* This is due to some really funky type conversions between different node types.
|
||||
* This is done intentionally based on the internal implementation of the base indent rule.
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const 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 = util.createRule({
|
||||
name: 'indent',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent indentation',
|
||||
// too opinionated to be recommended
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [
|
||||
// typescript docs and playground use 4 space indent
|
||||
4,
|
||||
{
|
||||
// typescript docs indent the case from the switch
|
||||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#example-4
|
||||
SwitchCase: 1,
|
||||
flatTernaryExpressions: false,
|
||||
ignoredNodes: [],
|
||||
},
|
||||
],
|
||||
create(context, optionsWithDefaults) {
|
||||
// because we extend the base rule, have to update opts on the context
|
||||
// the context defines options as readonly though...
|
||||
const contextWithDefaults = Object.create(context, {
|
||||
options: {
|
||||
writable: false,
|
||||
configurable: false,
|
||||
value: optionsWithDefaults,
|
||||
},
|
||||
});
|
||||
const rules = baseRule.create(contextWithDefaults);
|
||||
/**
|
||||
* Converts from a TSPropertySignature to a Property
|
||||
* @param node a TSPropertySignature node
|
||||
* @param [type] the type to give the new node
|
||||
* @returns a Property node
|
||||
*/
|
||||
function TSPropertySignatureToProperty(node, type = utils_1.AST_NODE_TYPES.Property) {
|
||||
const base = {
|
||||
// indent doesn't actually use these
|
||||
key: null,
|
||||
value: null,
|
||||
// Property flags
|
||||
computed: false,
|
||||
method: false,
|
||||
kind: 'init',
|
||||
// this will stop eslint from interrogating the type literal
|
||||
shorthand: true,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
};
|
||||
if (type === utils_1.AST_NODE_TYPES.Property) {
|
||||
return Object.assign({ type }, base);
|
||||
}
|
||||
else {
|
||||
return Object.assign({ type, static: false, readonly: false, declare: false }, base);
|
||||
}
|
||||
}
|
||||
return Object.assign({}, rules, {
|
||||
// overwrite the base rule here so we can use our KNOWN_NODES list instead
|
||||
'*:exit'(node) {
|
||||
// For nodes we care about, skip the default handling, because it just marks the node as ignored...
|
||||
if (!KNOWN_NODES.has(node.type)) {
|
||||
rules['*:exit'](node);
|
||||
}
|
||||
},
|
||||
VariableDeclaration(node) {
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/441
|
||||
if (node.declarations.length === 0) {
|
||||
return;
|
||||
}
|
||||
return rules.VariableDeclaration(node);
|
||||
},
|
||||
TSAsExpression(node) {
|
||||
// transform it to a BinaryExpression
|
||||
return rules['BinaryExpression, LogicalExpression']({
|
||||
type: utils_1.AST_NODE_TYPES.BinaryExpression,
|
||||
operator: 'as',
|
||||
left: node.expression,
|
||||
// the first typeAnnotation includes the as token
|
||||
right: node.typeAnnotation,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSConditionalType(node) {
|
||||
// transform it to a ConditionalExpression
|
||||
return rules.ConditionalExpression({
|
||||
type: utils_1.AST_NODE_TYPES.ConditionalExpression,
|
||||
test: {
|
||||
type: utils_1.AST_NODE_TYPES.BinaryExpression,
|
||||
operator: 'extends',
|
||||
left: node.checkType,
|
||||
right: node.extendsType,
|
||||
// location data
|
||||
range: [node.checkType.range[0], node.extendsType.range[1]],
|
||||
loc: {
|
||||
start: node.checkType.loc.start,
|
||||
end: node.extendsType.loc.end,
|
||||
},
|
||||
},
|
||||
consequent: node.trueType,
|
||||
alternate: node.falseType,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
'TSEnumDeclaration, TSTypeLiteral'(node) {
|
||||
// transform it to an ObjectExpression
|
||||
return rules['ObjectExpression, ObjectPattern']({
|
||||
type: utils_1.AST_NODE_TYPES.ObjectExpression,
|
||||
properties: node.members.map(member => TSPropertySignatureToProperty(member)),
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSImportEqualsDeclaration(node) {
|
||||
// transform it to an VariableDeclaration
|
||||
// use VariableDeclaration instead of ImportDeclaration because it's essentially the same thing
|
||||
const { id, moduleReference } = node;
|
||||
return rules.VariableDeclaration({
|
||||
type: utils_1.AST_NODE_TYPES.VariableDeclaration,
|
||||
kind: 'const',
|
||||
declarations: [
|
||||
{
|
||||
type: utils_1.AST_NODE_TYPES.VariableDeclarator,
|
||||
range: [id.range[0], moduleReference.range[1]],
|
||||
loc: {
|
||||
start: id.loc.start,
|
||||
end: moduleReference.loc.end,
|
||||
},
|
||||
id: id,
|
||||
init: {
|
||||
type: utils_1.AST_NODE_TYPES.CallExpression,
|
||||
callee: {
|
||||
type: utils_1.AST_NODE_TYPES.Identifier,
|
||||
name: 'require',
|
||||
range: [
|
||||
moduleReference.range[0],
|
||||
moduleReference.range[0] + 'require'.length,
|
||||
],
|
||||
loc: {
|
||||
start: moduleReference.loc.start,
|
||||
end: {
|
||||
line: moduleReference.loc.end.line,
|
||||
column: moduleReference.loc.start.line + 'require'.length,
|
||||
},
|
||||
},
|
||||
},
|
||||
arguments: 'expression' in moduleReference
|
||||
? [moduleReference.expression]
|
||||
: [],
|
||||
// location data
|
||||
range: moduleReference.range,
|
||||
loc: moduleReference.loc,
|
||||
},
|
||||
},
|
||||
],
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSIndexedAccessType(node) {
|
||||
// convert to a MemberExpression
|
||||
return rules['MemberExpression, JSXMemberExpression, MetaProperty']({
|
||||
type: utils_1.AST_NODE_TYPES.MemberExpression,
|
||||
object: node.objectType,
|
||||
property: node.indexType,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
optional: false,
|
||||
computed: true,
|
||||
});
|
||||
},
|
||||
TSInterfaceBody(node) {
|
||||
// transform it to an ClassBody
|
||||
return rules['BlockStatement, ClassBody']({
|
||||
type: utils_1.AST_NODE_TYPES.ClassBody,
|
||||
body: node.body.map(p => TSPropertySignatureToProperty(p, utils_1.AST_NODE_TYPES.PropertyDefinition)),
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
'TSInterfaceDeclaration[extends.length > 0]'(node) {
|
||||
// transform it to a ClassDeclaration
|
||||
return rules['ClassDeclaration[superClass], ClassExpression[superClass]']({
|
||||
type: utils_1.AST_NODE_TYPES.ClassDeclaration,
|
||||
body: node.body,
|
||||
id: null,
|
||||
// TODO: This is invalid, there can be more than one extends in interface
|
||||
superClass: node.extends[0].expression,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSMappedType(node) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const squareBracketStart = sourceCode.getTokenBefore(node.typeParameter);
|
||||
// transform it to an ObjectExpression
|
||||
return rules['ObjectExpression, ObjectPattern']({
|
||||
type: utils_1.AST_NODE_TYPES.ObjectExpression,
|
||||
properties: [
|
||||
{
|
||||
type: utils_1.AST_NODE_TYPES.Property,
|
||||
key: node.typeParameter,
|
||||
value: node.typeAnnotation,
|
||||
// location data
|
||||
range: [
|
||||
squareBracketStart.range[0],
|
||||
node.typeAnnotation
|
||||
? node.typeAnnotation.range[1]
|
||||
: squareBracketStart.range[0],
|
||||
],
|
||||
loc: {
|
||||
start: squareBracketStart.loc.start,
|
||||
end: node.typeAnnotation
|
||||
? node.typeAnnotation.loc.end
|
||||
: squareBracketStart.loc.end,
|
||||
},
|
||||
kind: 'init',
|
||||
computed: false,
|
||||
method: false,
|
||||
shorthand: false,
|
||||
},
|
||||
],
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSModuleBlock(node) {
|
||||
// transform it to a BlockStatement
|
||||
return rules['BlockStatement, ClassBody']({
|
||||
type: utils_1.AST_NODE_TYPES.BlockStatement,
|
||||
body: node.body,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSQualifiedName(node) {
|
||||
return rules['MemberExpression, JSXMemberExpression, MetaProperty']({
|
||||
type: utils_1.AST_NODE_TYPES.MemberExpression,
|
||||
object: node.left,
|
||||
property: node.right,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
optional: false,
|
||||
computed: false,
|
||||
});
|
||||
},
|
||||
TSTupleType(node) {
|
||||
// transform it to an ArrayExpression
|
||||
return rules['ArrayExpression, ArrayPattern']({
|
||||
type: utils_1.AST_NODE_TYPES.ArrayExpression,
|
||||
elements: node.elementTypes,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
TSTypeParameterDeclaration(node) {
|
||||
if (!node.params.length) {
|
||||
return;
|
||||
}
|
||||
const [name, ...attributes] = node.params;
|
||||
// JSX is about the closest we can get because the angle brackets
|
||||
// it's not perfect but it works!
|
||||
return rules.JSXOpeningElement({
|
||||
type: utils_1.AST_NODE_TYPES.JSXOpeningElement,
|
||||
selfClosing: false,
|
||||
name: name,
|
||||
attributes: attributes,
|
||||
// location data
|
||||
parent: node.parent,
|
||||
range: node.range,
|
||||
loc: node.loc,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=indent.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,280 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const adjacent_overload_signatures_1 = __importDefault(require("./adjacent-overload-signatures"));
|
||||
const array_type_1 = __importDefault(require("./array-type"));
|
||||
const await_thenable_1 = __importDefault(require("./await-thenable"));
|
||||
const ban_ts_comment_1 = __importDefault(require("./ban-ts-comment"));
|
||||
const ban_tslint_comment_1 = __importDefault(require("./ban-tslint-comment"));
|
||||
const ban_types_1 = __importDefault(require("./ban-types"));
|
||||
const block_spacing_1 = __importDefault(require("./block-spacing"));
|
||||
const brace_style_1 = __importDefault(require("./brace-style"));
|
||||
const class_literal_property_style_1 = __importDefault(require("./class-literal-property-style"));
|
||||
const 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 member_delimiter_style_1 = __importDefault(require("./member-delimiter-style"));
|
||||
const member_ordering_1 = __importDefault(require("./member-ordering"));
|
||||
const method_signature_style_1 = __importDefault(require("./method-signature-style"));
|
||||
const naming_convention_1 = __importDefault(require("./naming-convention"));
|
||||
const no_array_constructor_1 = __importDefault(require("./no-array-constructor"));
|
||||
const no_base_to_string_1 = __importDefault(require("./no-base-to-string"));
|
||||
const no_confusing_non_null_assertion_1 = __importDefault(require("./no-confusing-non-null-assertion"));
|
||||
const no_confusing_void_expression_1 = __importDefault(require("./no-confusing-void-expression"));
|
||||
const no_dupe_class_members_1 = __importDefault(require("./no-dupe-class-members"));
|
||||
const no_duplicate_enum_values_1 = __importDefault(require("./no-duplicate-enum-values"));
|
||||
const no_duplicate_imports_1 = __importDefault(require("./no-duplicate-imports"));
|
||||
const no_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_implicit_any_catch_1 = __importDefault(require("./no-implicit-any-catch"));
|
||||
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_parameter_properties_1 = __importDefault(require("./no-parameter-properties"));
|
||||
const no_redeclare_1 = __importDefault(require("./no-redeclare"));
|
||||
const no_redundant_type_constituents_1 = __importDefault(require("./no-redundant-type-constituents"));
|
||||
const no_require_imports_1 = __importDefault(require("./no-require-imports"));
|
||||
const no_restricted_imports_1 = __importDefault(require("./no-restricted-imports"));
|
||||
const no_shadow_1 = __importDefault(require("./no-shadow"));
|
||||
const no_this_alias_1 = __importDefault(require("./no-this-alias"));
|
||||
const no_throw_literal_1 = __importDefault(require("./no-throw-literal"));
|
||||
const no_type_alias_1 = __importDefault(require("./no-type-alias"));
|
||||
const no_unnecessary_boolean_literal_compare_1 = __importDefault(require("./no-unnecessary-boolean-literal-compare"));
|
||||
const no_unnecessary_condition_1 = __importDefault(require("./no-unnecessary-condition"));
|
||||
const no_unnecessary_qualifier_1 = __importDefault(require("./no-unnecessary-qualifier"));
|
||||
const no_unnecessary_type_arguments_1 = __importDefault(require("./no-unnecessary-type-arguments"));
|
||||
const no_unnecessary_type_assertion_1 = __importDefault(require("./no-unnecessary-type-assertion"));
|
||||
const no_unnecessary_type_constraint_1 = __importDefault(require("./no-unnecessary-type-constraint"));
|
||||
const no_unsafe_argument_1 = __importDefault(require("./no-unsafe-argument"));
|
||||
const no_unsafe_assignment_1 = __importDefault(require("./no-unsafe-assignment"));
|
||||
const no_unsafe_call_1 = __importDefault(require("./no-unsafe-call"));
|
||||
const no_unsafe_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_unused_expressions_1 = __importDefault(require("./no-unused-expressions"));
|
||||
const no_unused_vars_1 = __importDefault(require("./no-unused-vars"));
|
||||
const no_use_before_define_1 = __importDefault(require("./no-use-before-define"));
|
||||
const no_useless_constructor_1 = __importDefault(require("./no-useless-constructor"));
|
||||
const no_useless_empty_export_1 = __importDefault(require("./no-useless-empty-export"));
|
||||
const no_var_requires_1 = __importDefault(require("./no-var-requires"));
|
||||
const non_nullable_type_assertion_style_1 = __importDefault(require("./non-nullable-type-assertion-style"));
|
||||
const object_curly_spacing_1 = __importDefault(require("./object-curly-spacing"));
|
||||
const padding_line_between_statements_1 = __importDefault(require("./padding-line-between-statements"));
|
||||
const parameter_properties_1 = __importDefault(require("./parameter-properties"));
|
||||
const prefer_as_const_1 = __importDefault(require("./prefer-as-const"));
|
||||
const prefer_enum_initializers_1 = __importDefault(require("./prefer-enum-initializers"));
|
||||
const prefer_for_of_1 = __importDefault(require("./prefer-for-of"));
|
||||
const prefer_function_type_1 = __importDefault(require("./prefer-function-type"));
|
||||
const prefer_includes_1 = __importDefault(require("./prefer-includes"));
|
||||
const prefer_literal_enum_member_1 = __importDefault(require("./prefer-literal-enum-member"));
|
||||
const prefer_namespace_keyword_1 = __importDefault(require("./prefer-namespace-keyword"));
|
||||
const prefer_nullish_coalescing_1 = __importDefault(require("./prefer-nullish-coalescing"));
|
||||
const prefer_optional_chain_1 = __importDefault(require("./prefer-optional-chain"));
|
||||
const prefer_readonly_1 = __importDefault(require("./prefer-readonly"));
|
||||
const prefer_readonly_parameter_types_1 = __importDefault(require("./prefer-readonly-parameter-types"));
|
||||
const prefer_reduce_type_parameter_1 = __importDefault(require("./prefer-reduce-type-parameter"));
|
||||
const prefer_regexp_exec_1 = __importDefault(require("./prefer-regexp-exec"));
|
||||
const prefer_return_this_type_1 = __importDefault(require("./prefer-return-this-type"));
|
||||
const prefer_string_starts_ends_with_1 = __importDefault(require("./prefer-string-starts-ends-with"));
|
||||
const prefer_ts_expect_error_1 = __importDefault(require("./prefer-ts-expect-error"));
|
||||
const promise_function_async_1 = __importDefault(require("./promise-function-async"));
|
||||
const quotes_1 = __importDefault(require("./quotes"));
|
||||
const require_array_sort_compare_1 = __importDefault(require("./require-array-sort-compare"));
|
||||
const require_await_1 = __importDefault(require("./require-await"));
|
||||
const restrict_plus_operands_1 = __importDefault(require("./restrict-plus-operands"));
|
||||
const restrict_template_expressions_1 = __importDefault(require("./restrict-template-expressions"));
|
||||
const return_await_1 = __importDefault(require("./return-await"));
|
||||
const semi_1 = __importDefault(require("./semi"));
|
||||
const sort_type_constituents_1 = __importDefault(require("./sort-type-constituents"));
|
||||
const sort_type_union_intersection_members_1 = __importDefault(require("./sort-type-union-intersection-members"));
|
||||
const space_before_blocks_1 = __importDefault(require("./space-before-blocks"));
|
||||
const space_before_function_paren_1 = __importDefault(require("./space-before-function-paren"));
|
||||
const space_infix_ops_1 = __importDefault(require("./space-infix-ops"));
|
||||
const strict_boolean_expressions_1 = __importDefault(require("./strict-boolean-expressions"));
|
||||
const switch_exhaustiveness_check_1 = __importDefault(require("./switch-exhaustiveness-check"));
|
||||
const triple_slash_reference_1 = __importDefault(require("./triple-slash-reference"));
|
||||
const type_annotation_spacing_1 = __importDefault(require("./type-annotation-spacing"));
|
||||
const typedef_1 = __importDefault(require("./typedef"));
|
||||
const unbound_method_1 = __importDefault(require("./unbound-method"));
|
||||
const unified_signatures_1 = __importDefault(require("./unified-signatures"));
|
||||
exports.default = {
|
||||
'adjacent-overload-signatures': adjacent_overload_signatures_1.default,
|
||||
'array-type': array_type_1.default,
|
||||
'await-thenable': await_thenable_1.default,
|
||||
'ban-ts-comment': ban_ts_comment_1.default,
|
||||
'ban-tslint-comment': ban_tslint_comment_1.default,
|
||||
'ban-types': ban_types_1.default,
|
||||
'block-spacing': block_spacing_1.default,
|
||||
'brace-style': brace_style_1.default,
|
||||
'class-literal-property-style': class_literal_property_style_1.default,
|
||||
'comma-dangle': comma_dangle_1.default,
|
||||
'comma-spacing': comma_spacing_1.default,
|
||||
'consistent-generic-constructors': consistent_generic_constructors_1.default,
|
||||
'consistent-indexed-object-style': consistent_indexed_object_style_1.default,
|
||||
'consistent-type-assertions': consistent_type_assertions_1.default,
|
||||
'consistent-type-definitions': consistent_type_definitions_1.default,
|
||||
'consistent-type-exports': consistent_type_exports_1.default,
|
||||
'consistent-type-imports': consistent_type_imports_1.default,
|
||||
'default-param-last': default_param_last_1.default,
|
||||
'dot-notation': dot_notation_1.default,
|
||||
'explicit-function-return-type': explicit_function_return_type_1.default,
|
||||
'explicit-member-accessibility': explicit_member_accessibility_1.default,
|
||||
'explicit-module-boundary-types': explicit_module_boundary_types_1.default,
|
||||
'func-call-spacing': func_call_spacing_1.default,
|
||||
indent: indent_1.default,
|
||||
'init-declarations': init_declarations_1.default,
|
||||
'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,
|
||||
'member-delimiter-style': member_delimiter_style_1.default,
|
||||
'member-ordering': member_ordering_1.default,
|
||||
'method-signature-style': method_signature_style_1.default,
|
||||
'naming-convention': naming_convention_1.default,
|
||||
'no-array-constructor': no_array_constructor_1.default,
|
||||
'no-base-to-string': no_base_to_string_1.default,
|
||||
'no-confusing-non-null-assertion': no_confusing_non_null_assertion_1.default,
|
||||
'no-confusing-void-expression': no_confusing_void_expression_1.default,
|
||||
'no-dupe-class-members': no_dupe_class_members_1.default,
|
||||
'no-duplicate-enum-values': no_duplicate_enum_values_1.default,
|
||||
'no-duplicate-imports': no_duplicate_imports_1.default,
|
||||
'no-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-implicit-any-catch': no_implicit_any_catch_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-parameter-properties': no_parameter_properties_1.default,
|
||||
'no-redeclare': no_redeclare_1.default,
|
||||
'no-redundant-type-constituents': no_redundant_type_constituents_1.default,
|
||||
'no-require-imports': no_require_imports_1.default,
|
||||
'no-restricted-imports': no_restricted_imports_1.default,
|
||||
'no-shadow': no_shadow_1.default,
|
||||
'no-this-alias': no_this_alias_1.default,
|
||||
'no-throw-literal': no_throw_literal_1.default,
|
||||
'no-type-alias': no_type_alias_1.default,
|
||||
'no-unnecessary-boolean-literal-compare': no_unnecessary_boolean_literal_compare_1.default,
|
||||
'no-unnecessary-condition': no_unnecessary_condition_1.default,
|
||||
'no-unnecessary-qualifier': no_unnecessary_qualifier_1.default,
|
||||
'no-unnecessary-type-arguments': no_unnecessary_type_arguments_1.default,
|
||||
'no-unnecessary-type-assertion': no_unnecessary_type_assertion_1.default,
|
||||
'no-unnecessary-type-constraint': no_unnecessary_type_constraint_1.default,
|
||||
'no-unsafe-argument': no_unsafe_argument_1.default,
|
||||
'no-unsafe-assignment': no_unsafe_assignment_1.default,
|
||||
'no-unsafe-call': no_unsafe_call_1.default,
|
||||
'no-unsafe-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-unused-expressions': no_unused_expressions_1.default,
|
||||
'no-unused-vars': no_unused_vars_1.default,
|
||||
'no-use-before-define': no_use_before_define_1.default,
|
||||
'no-useless-constructor': no_useless_constructor_1.default,
|
||||
'no-useless-empty-export': no_useless_empty_export_1.default,
|
||||
'no-var-requires': no_var_requires_1.default,
|
||||
'non-nullable-type-assertion-style': non_nullable_type_assertion_style_1.default,
|
||||
'object-curly-spacing': object_curly_spacing_1.default,
|
||||
'padding-line-between-statements': padding_line_between_statements_1.default,
|
||||
'parameter-properties': parameter_properties_1.default,
|
||||
'prefer-as-const': prefer_as_const_1.default,
|
||||
'prefer-enum-initializers': prefer_enum_initializers_1.default,
|
||||
'prefer-for-of': prefer_for_of_1.default,
|
||||
'prefer-function-type': prefer_function_type_1.default,
|
||||
'prefer-includes': prefer_includes_1.default,
|
||||
'prefer-literal-enum-member': prefer_literal_enum_member_1.default,
|
||||
'prefer-namespace-keyword': prefer_namespace_keyword_1.default,
|
||||
'prefer-nullish-coalescing': prefer_nullish_coalescing_1.default,
|
||||
'prefer-optional-chain': prefer_optional_chain_1.default,
|
||||
'prefer-readonly': prefer_readonly_1.default,
|
||||
'prefer-readonly-parameter-types': prefer_readonly_parameter_types_1.default,
|
||||
'prefer-reduce-type-parameter': prefer_reduce_type_parameter_1.default,
|
||||
'prefer-regexp-exec': prefer_regexp_exec_1.default,
|
||||
'prefer-return-this-type': prefer_return_this_type_1.default,
|
||||
'prefer-string-starts-ends-with': prefer_string_starts_ends_with_1.default,
|
||||
'prefer-ts-expect-error': prefer_ts_expect_error_1.default,
|
||||
'promise-function-async': promise_function_async_1.default,
|
||||
quotes: quotes_1.default,
|
||||
'require-array-sort-compare': require_array_sort_compare_1.default,
|
||||
'require-await': require_await_1.default,
|
||||
'restrict-plus-operands': restrict_plus_operands_1.default,
|
||||
'restrict-template-expressions': restrict_template_expressions_1.default,
|
||||
'return-await': return_await_1.default,
|
||||
semi: semi_1.default,
|
||||
'sort-type-constituents': sort_type_constituents_1.default,
|
||||
'sort-type-union-intersection-members': sort_type_union_intersection_members_1.default,
|
||||
'space-before-blocks': space_before_blocks_1.default,
|
||||
'space-before-function-paren': space_before_function_paren_1.default,
|
||||
'space-infix-ops': space_infix_ops_1.default,
|
||||
'strict-boolean-expressions': strict_boolean_expressions_1.default,
|
||||
'switch-exhaustiveness-check': switch_exhaustiveness_check_1.default,
|
||||
'triple-slash-reference': triple_slash_reference_1.default,
|
||||
'type-annotation-spacing': type_annotation_spacing_1.default,
|
||||
typedef: typedef_1.default,
|
||||
'unbound-method': unbound_method_1.default,
|
||||
'unified-signatures': unified_signatures_1.default,
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('init-declarations');
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'init-declarations',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require or disallow initialization in variable declarations',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: baseRule.meta.schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: ['always'],
|
||||
create(context, [mode]) {
|
||||
const rules = baseRule.create(context);
|
||||
return {
|
||||
'VariableDeclaration:exit'(node) {
|
||||
if (mode === 'always') {
|
||||
if (node.declare) {
|
||||
return;
|
||||
}
|
||||
if (isAncestorNamespaceDeclared(node)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
rules['VariableDeclaration:exit'](node);
|
||||
},
|
||||
};
|
||||
function isAncestorNamespaceDeclared(node) {
|
||||
let ancestor = node.parent;
|
||||
while (ancestor) {
|
||||
if (ancestor.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
|
||||
ancestor.declare) {
|
||||
return true;
|
||||
}
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=init-declarations.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"init-declarations.js","sourceRoot":"","sources":["../../src/rules/init-declarations.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAM1D,kCAAqC;AACrC,iEAA8D;AAE9D,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAC,mBAAmB,CAAC,CAAC;AAKxD,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,6DAA6D;YAC/D,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,IAAI;SACtB;QACD,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc;QAC5C,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC;QACpB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO;YACL,0BAA0B,CAAC,IAAkC;gBAC3D,IAAI,IAAI,KAAK,QAAQ,EAAE;oBACrB,IAAI,IAAI,CAAC,OAAO,EAAE;wBAChB,OAAO;qBACR;oBACD,IAAI,2BAA2B,CAAC,IAAI,CAAC,EAAE;wBACrC,OAAO;qBACR;iBACF;gBAED,KAAK,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,CAAC;YAC1C,CAAC;SACF,CAAC;QAEF,SAAS,2BAA2B,CAClC,IAAkC;YAElC,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;YAE3B,OAAO,QAAQ,EAAE;gBACf,IACE,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;oBACpD,QAAQ,CAAC,OAAO,EAChB;oBACA,OAAO,IAAI,CAAC;iBACb;gBAED,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;aAC5B;YAED,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,351 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(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;
|
||||
/**
|
||||
* TODO: replace with native .at() once Node 14 stops being supported
|
||||
*/
|
||||
function at(arr, position) {
|
||||
if (position < 0) {
|
||||
return arr[arr.length + position];
|
||||
}
|
||||
return arr[position];
|
||||
}
|
||||
exports.default = util.createRule({
|
||||
name: 'key-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent spacing between property names and type annotations in types and interfaces',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: [baseSchema],
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [{}],
|
||||
create(context, [options]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
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 util.getStringLength(at(sourceCode.lines, 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.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(at(node.parameters, -1), util.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
|
||||
: at(node.parameters, -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],
|
||||
]);
|
||||
}
|
||||
else {
|
||||
return fixer.insertTextBefore(typeAnnotation, ' '.repeat(-difference));
|
||||
}
|
||||
},
|
||||
data: {
|
||||
computed: '',
|
||||
key: getKeyText(node),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
function checkAfterColon(node, expectedWhitespaceAfterColon, mode) {
|
||||
const { typeAnnotation } = node;
|
||||
const colon = typeAnnotation.loc.start.column;
|
||||
const typeStart = typeAnnotation.typeAnnotation.loc.start.column;
|
||||
const difference = typeStart - colon - 1 - expectedWhitespaceAfterColon;
|
||||
if (mode === 'strict' ? difference : difference < 0) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: difference > 0 ? 'extraValue' : 'missingValue',
|
||||
fix: fixer => {
|
||||
if (difference > 0) {
|
||||
return fixer.removeRange([
|
||||
typeAnnotation.typeAnnotation.range[0] - difference,
|
||||
typeAnnotation.typeAnnotation.range[0],
|
||||
]);
|
||||
}
|
||||
else {
|
||||
return fixer.insertTextBefore(typeAnnotation.typeAnnotation, ' '.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 - at(leadingComments, -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) {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||
let alignColumn = 0;
|
||||
const align = (_d = (typeof options.align === 'object'
|
||||
? options.align.on
|
||||
: typeof ((_a = options.multiLine) === null || _a === void 0 ? void 0 : _a.align) === 'object'
|
||||
? options.multiLine.align.on
|
||||
: (_c = (_b = options.multiLine) === null || _b === void 0 ? void 0 : _b.align) !== null && _c !== void 0 ? _c : options.align)) !== null && _d !== void 0 ? _d : 'colon';
|
||||
const beforeColon = (_e = (typeof options.align === 'object'
|
||||
? options.align.beforeColon
|
||||
: options.multiLine
|
||||
? typeof options.multiLine.align === 'object'
|
||||
? options.multiLine.align.beforeColon
|
||||
: options.multiLine.beforeColon
|
||||
: options.beforeColon)) !== null && _e !== void 0 ? _e : false;
|
||||
const expectedWhitespaceBeforeColon = beforeColon ? 1 : 0;
|
||||
const afterColon = (_f = (typeof options.align === 'object'
|
||||
? options.align.afterColon
|
||||
: options.multiLine
|
||||
? typeof options.multiLine.align === 'object'
|
||||
? options.multiLine.align.afterColon
|
||||
: options.multiLine.afterColon
|
||||
: options.afterColon)) !== null && _f !== void 0 ? _f : true;
|
||||
const expectedWhitespaceAfterColon = afterColon ? 1 : 0;
|
||||
const mode = (_h = (typeof options.align === 'object'
|
||||
? options.align.mode
|
||||
: options.multiLine
|
||||
? typeof options.multiLine.align === 'object'
|
||||
? // same behavior as in original rule
|
||||
(_g = options.multiLine.align.mode) !== null && _g !== void 0 ? _g : options.multiLine.mode
|
||||
: options.multiLine.mode
|
||||
: options.mode)) !== null && _h !== void 0 ? _h : '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],
|
||||
]);
|
||||
}
|
||||
else {
|
||||
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 }) {
|
||||
var _a, _b, _c;
|
||||
const beforeColon = (_a = (singleLine
|
||||
? options.singleLine
|
||||
? options.singleLine.beforeColon
|
||||
: options.beforeColon
|
||||
: options.multiLine
|
||||
? options.multiLine.beforeColon
|
||||
: options.beforeColon)) !== null && _a !== void 0 ? _a : false;
|
||||
const expectedWhitespaceBeforeColon = beforeColon ? 1 : 0;
|
||||
const afterColon = (_b = (singleLine
|
||||
? options.singleLine
|
||||
? options.singleLine.afterColon
|
||||
: options.afterColon
|
||||
: options.multiLine
|
||||
? options.multiLine.afterColon
|
||||
: options.afterColon)) !== null && _b !== void 0 ? _b : true;
|
||||
const expectedWhitespaceAfterColon = afterColon ? 1 : 0;
|
||||
const mode = (_c = (singleLine
|
||||
? options.singleLine
|
||||
? options.singleLine.mode
|
||||
: options.mode
|
||||
: options.multiLine
|
||||
? options.multiLine.mode
|
||||
: options.mode)) !== null && _c !== void 0 ? _c : 'strict';
|
||||
if (isApplicable(node)) {
|
||||
checkBeforeColon(node, expectedWhitespaceBeforeColon, mode);
|
||||
checkAfterColon(node, expectedWhitespaceAfterColon, mode);
|
||||
}
|
||||
}
|
||||
function validateBody(body) {
|
||||
var _a;
|
||||
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 || ((_a = options.multiLine) === null || _a === void 0 ? void 0 : _a.align)) {
|
||||
let currentAlignGroup = [];
|
||||
alignGroups.push(currentAlignGroup);
|
||||
let prevNode = undefined;
|
||||
for (const node of members) {
|
||||
let prevAlignedNode = at(currentAlignGroup, -1);
|
||||
if (prevAlignedNode !== prevNode) {
|
||||
prevAlignedNode = undefined;
|
||||
}
|
||||
if (prevAlignedNode && continuesAlignGroup(prevAlignedNode, node)) {
|
||||
currentAlignGroup.push(node);
|
||||
}
|
||||
else if ((prevNode === null || prevNode === void 0 ? void 0 : 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 Object.assign(Object.assign({}, baseRules), { TSTypeLiteral: validateBody, TSInterfaceBody: validateBody, ClassBody: validateBody });
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=key-spacing.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,114 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(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 = util.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 = util.createRule({
|
||||
name: 'keyword-spacing',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Enforce consistent spacing before and after keywords',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema: [schema],
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [{}],
|
||||
create(context, [{ after, overrides }]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const baseRules = baseRule.create(context);
|
||||
return Object.assign(Object.assign({}, baseRules), { TSAsExpression(node) {
|
||||
const asToken = util.nullThrows(sourceCode.getTokenAfter(node.expression, token => token.value === 'as'), util.NullThrowsReasons.MissingToken('as', node.type));
|
||||
const oldTokenType = asToken.type;
|
||||
// as is a contextual keyword, so it's always reported as an Identifier
|
||||
// the rule looks for keyword tokens, so we temporarily override it
|
||||
// we mutate it at the token level because the rule calls sourceCode.getFirstToken,
|
||||
// so mutating a copy would not change the underlying copy returned by that method
|
||||
asToken.type = utils_1.AST_TOKEN_TYPES.Keyword;
|
||||
// use this selector just because it is just a call to `checkSpacingAroundFirstToken`
|
||||
baseRules.DebuggerStatement(asToken);
|
||||
// make sure to reset the type afterward so we don't permanently mutate the AST
|
||||
asToken.type = oldTokenType;
|
||||
},
|
||||
'ImportDeclaration[importKind=type]'(node) {
|
||||
var _a, _b, _c, _d;
|
||||
const { type: typeOptionOverride = {} } = overrides !== null && overrides !== void 0 ? overrides : {};
|
||||
const typeToken = sourceCode.getFirstToken(node, { skip: 1 });
|
||||
const punctuatorToken = sourceCode.getTokenAfter(typeToken);
|
||||
if (((_b = (_a = node.specifiers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier) {
|
||||
return;
|
||||
}
|
||||
const spacesBetweenTypeAndPunctuator = punctuatorToken.range[0] - typeToken.range[1];
|
||||
if (((_c = typeOptionOverride.after) !== null && _c !== void 0 ? _c : after) === true &&
|
||||
spacesBetweenTypeAndPunctuator === 0) {
|
||||
context.report({
|
||||
loc: typeToken.loc,
|
||||
messageId: 'expectedAfter',
|
||||
data: { value: 'type' },
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(typeToken, ' ');
|
||||
},
|
||||
});
|
||||
}
|
||||
if (((_d = typeOptionOverride.after) !== null && _d !== void 0 ? _d : 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 +0,0 @@
|
||||
{"version":3,"file":"keyword-spacing.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AAC,KAAK,mCAAI,KAAK,CAAC,KAAK,IAAI;oBAC5C,8BAA8B,KAAK,CAAC,EACpC;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,GAAG,EAAE,SAAS,CAAC,GAAG;wBAClB,SAAS,EAAE,eAAe;wBAC1B,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;wBACvB,GAAG,CAAC,KAAK;4BACP,OAAO,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;wBAC/C,CAAC;qBACF,CAAC,CAAC;iBACJ;gBACD,IACE,CAAC,MAAA,kBAAkB,CAAC,KAAK,mCAAI,KAAK,CAAC,KAAK,KAAK;oBAC7C,8BAA8B,GAAG,CAAC,EAClC;oBACA,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;iBACJ;YACH,CAAC,IACD;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,384 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(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 = util.createRule({
|
||||
name: 'lines-around-comment',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require empty lines around comments',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
schema: {
|
||||
type: 'array',
|
||||
items: [
|
||||
{
|
||||
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]) {
|
||||
var _a;
|
||||
const options = _options;
|
||||
const defaultIgnoreRegExp = COMMENTS_IGNORE_PATTERN;
|
||||
const customIgnoreRegExp = new RegExp((_a = options.ignorePattern) !== null && _a !== void 0 ? _a : '', 'u');
|
||||
const sourceCode = context.getSourceCode();
|
||||
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 && util.isCommentToken(currentToken));
|
||||
if (currentToken && util.isTokenOnSameLine(currentToken, token)) {
|
||||
return true;
|
||||
}
|
||||
currentToken = token;
|
||||
do {
|
||||
currentToken = sourceCode.getTokenAfter(currentToken, {
|
||||
includeComments: true,
|
||||
});
|
||||
} while (currentToken && util.isCommentToken(currentToken));
|
||||
if (currentToken && util.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) &&
|
||||
!(util.isCommentToken(previousTokenOrComment) &&
|
||||
util.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) &&
|
||||
!(util.isCommentToken(nextTokenOrComment) &&
|
||||
util.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 (token.type === utils_1.AST_TOKEN_TYPES.Block) {
|
||||
if (options.beforeBlockComment || options.afterBlockComment) {
|
||||
checkForEmptyLine(token, {
|
||||
after: options.afterBlockComment,
|
||||
before: options.beforeBlockComment,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=lines-around-comment.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,77 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('lines-between-class-members');
|
||||
const schema = util.deepMerge(Object.assign({}, baseRule.meta.schema), {
|
||||
1: {
|
||||
exceptAfterOverload: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
exports.default = util.createRule({
|
||||
name: 'lines-between-class-members',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require or disallow an empty line between class members',
|
||||
recommended: false,
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
schema,
|
||||
messages: baseRule.meta.messages,
|
||||
},
|
||||
defaultOptions: [
|
||||
'always',
|
||||
{
|
||||
exceptAfterOverload: true,
|
||||
exceptAfterSingleLine: false,
|
||||
},
|
||||
],
|
||||
create(context, [firstOption, secondOption]) {
|
||||
const rules = baseRule.create(context);
|
||||
const exceptAfterOverload = (secondOption === null || secondOption === void 0 ? void 0 : secondOption.exceptAfterOverload) && firstOption === 'always';
|
||||
function isOverload(node) {
|
||||
return ((node.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
|
||||
node.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
|
||||
node.value.type === utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression);
|
||||
}
|
||||
return {
|
||||
ClassBody(node) {
|
||||
const body = exceptAfterOverload
|
||||
? node.body.filter(node => !isOverload(node))
|
||||
: node.body;
|
||||
rules.ClassBody(Object.assign(Object.assign({}, node), { body }));
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=lines-between-class-members.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"lines-between-class-members.js","sourceRoot":"","sources":["../../src/rules/lines-between-class-members.ts"],"names":[],"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Ac,CAAC,6BAA6B,CACjE,CAAC;QACJ,CAAC;QAED,OAAO;YACL,SAAS,CAAC,IAAI;gBACZ,MAAM,IAAI,GAAG,mBAAmB;oBAC9B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;oBAC7C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAEd,KAAK,CAAC,SAAS,iCAAM,IAAI,KAAE,IAAI,IAAG,CAAC;YACrC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -1,261 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
const definition = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
multiline: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
delimiter: { enum: ['none', 'semi', 'comma'] },
|
||||
requireLast: { type: 'boolean' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
singleline: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
// note can't have "none" for single line delimiter as it's invalid syntax
|
||||
delimiter: { enum: ['semi', 'comma'] },
|
||||
requireLast: { type: 'boolean' },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
const isLastTokenEndOfLine = (token, line) => {
|
||||
const positionInLine = token.loc.start.column;
|
||||
return positionInLine === line.length - 1;
|
||||
};
|
||||
const isCommentsEndOfLine = (token, comments, line) => {
|
||||
if (!comments) {
|
||||
return false;
|
||||
}
|
||||
if (comments.loc.end.line > token.loc.end.line) {
|
||||
return true;
|
||||
}
|
||||
const positionInLine = comments.loc.end.column;
|
||||
return positionInLine === line.length;
|
||||
};
|
||||
const makeFixFunction = ({ optsNone, optsSemi, lastToken, commentsAfterLastToken, missingDelimiter, lastTokenLine, isSingleLine, }) => {
|
||||
// if removing is the action but last token is not the end of the line
|
||||
if (optsNone &&
|
||||
!isLastTokenEndOfLine(lastToken, lastTokenLine) &&
|
||||
!isCommentsEndOfLine(lastToken, commentsAfterLastToken, lastTokenLine) &&
|
||||
!isSingleLine) {
|
||||
return null;
|
||||
}
|
||||
return (fixer) => {
|
||||
if (optsNone) {
|
||||
// remove the unneeded token
|
||||
return fixer.remove(lastToken);
|
||||
}
|
||||
const token = optsSemi ? ';' : ',';
|
||||
if (missingDelimiter) {
|
||||
// add the missing delimiter
|
||||
return fixer.insertTextAfter(lastToken, token);
|
||||
}
|
||||
// correct the current delimiter
|
||||
return fixer.replaceText(lastToken, token);
|
||||
};
|
||||
};
|
||||
exports.default = util.createRule({
|
||||
name: 'member-delimiter-style',
|
||||
meta: {
|
||||
type: 'layout',
|
||||
docs: {
|
||||
description: 'Require a specific member delimiter style for interfaces and type literals',
|
||||
recommended: false,
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
messages: {
|
||||
unexpectedComma: 'Unexpected separator (,).',
|
||||
unexpectedSemi: 'Unexpected separator (;).',
|
||||
expectedComma: 'Expected a comma.',
|
||||
expectedSemi: 'Expected a semicolon.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: Object.assign({}, definition.properties, {
|
||||
overrides: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
interface: definition,
|
||||
typeLiteral: definition,
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
multilineDetection: {
|
||||
enum: ['brackets', 'last-member'],
|
||||
},
|
||||
}),
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
multiline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: true,
|
||||
},
|
||||
singleline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: false,
|
||||
},
|
||||
multilineDetection: 'brackets',
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
var _a;
|
||||
const sourceCode = context.getSourceCode();
|
||||
// use the base options as the defaults for the cases
|
||||
const baseOptions = options;
|
||||
const overrides = (_a = baseOptions.overrides) !== null && _a !== void 0 ? _a : {};
|
||||
const interfaceOptions = util.deepMerge(baseOptions, overrides.interface);
|
||||
const typeLiteralOptions = util.deepMerge(baseOptions, overrides.typeLiteral);
|
||||
/**
|
||||
* Check the last token in the given member.
|
||||
* @param member the member to be evaluated.
|
||||
* @param opts the options to be validated.
|
||||
* @param isLast a flag indicating `member` is the last in the interface or type literal.
|
||||
*/
|
||||
function checkLastToken(member, opts, isLast) {
|
||||
/**
|
||||
* Resolves the boolean value for the given setting enum value
|
||||
* @param type the option name
|
||||
*/
|
||||
function getOption(type) {
|
||||
if (isLast && !opts.requireLast) {
|
||||
// only turn the option on if its expecting no delimiter for the last member
|
||||
return type === 'none';
|
||||
}
|
||||
return opts.delimiter === type;
|
||||
}
|
||||
let messageId = null;
|
||||
let missingDelimiter = false;
|
||||
const lastToken = sourceCode.getLastToken(member, {
|
||||
includeComments: false,
|
||||
});
|
||||
if (!lastToken) {
|
||||
return;
|
||||
}
|
||||
const commentsAfterLastToken = sourceCode
|
||||
.getCommentsAfter(lastToken)
|
||||
.pop();
|
||||
const sourceCodeLines = sourceCode.getLines();
|
||||
const lastTokenLine = sourceCodeLines[(lastToken === null || lastToken === void 0 ? void 0 : lastToken.loc.start.line) - 1];
|
||||
const optsSemi = getOption('semi');
|
||||
const optsComma = getOption('comma');
|
||||
const optsNone = getOption('none');
|
||||
if (lastToken.value === ';') {
|
||||
if (optsComma) {
|
||||
messageId = 'expectedComma';
|
||||
}
|
||||
else if (optsNone) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'unexpectedSemi';
|
||||
}
|
||||
}
|
||||
else if (lastToken.value === ',') {
|
||||
if (optsSemi) {
|
||||
messageId = 'expectedSemi';
|
||||
}
|
||||
else if (optsNone) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'unexpectedComma';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (optsSemi) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'expectedSemi';
|
||||
}
|
||||
else if (optsComma) {
|
||||
missingDelimiter = true;
|
||||
messageId = 'expectedComma';
|
||||
}
|
||||
}
|
||||
if (messageId) {
|
||||
context.report({
|
||||
node: lastToken,
|
||||
loc: {
|
||||
start: {
|
||||
line: lastToken.loc.end.line,
|
||||
column: lastToken.loc.end.column,
|
||||
},
|
||||
end: {
|
||||
line: lastToken.loc.end.line,
|
||||
column: lastToken.loc.end.column,
|
||||
},
|
||||
},
|
||||
messageId,
|
||||
fix: makeFixFunction({
|
||||
optsNone,
|
||||
optsSemi,
|
||||
lastToken,
|
||||
commentsAfterLastToken,
|
||||
missingDelimiter,
|
||||
lastTokenLine,
|
||||
isSingleLine: opts.type === 'single-line',
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check the member separator being used matches the delimiter.
|
||||
* @param {ASTNode} node the node to be evaluated.
|
||||
*/
|
||||
function checkMemberSeparatorStyle(node) {
|
||||
const members = node.type === utils_1.AST_NODE_TYPES.TSInterfaceBody ? node.body : node.members;
|
||||
let isSingleLine = node.loc.start.line === node.loc.end.line;
|
||||
if (options.multilineDetection === 'last-member' &&
|
||||
!isSingleLine &&
|
||||
members.length > 0) {
|
||||
const lastMember = members[members.length - 1];
|
||||
if (lastMember.loc.end.line === node.loc.end.line) {
|
||||
isSingleLine = true;
|
||||
}
|
||||
}
|
||||
const typeOpts = node.type === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
||||
? interfaceOptions
|
||||
: typeLiteralOptions;
|
||||
const opts = isSingleLine
|
||||
? Object.assign(Object.assign({}, typeOpts.singleline), { type: 'single-line' }) : Object.assign(Object.assign({}, typeOpts.multiline), { type: 'multi-line' });
|
||||
members.forEach((member, index) => {
|
||||
checkLastToken(member, opts !== null && opts !== void 0 ? opts : {}, index === members.length - 1);
|
||||
});
|
||||
}
|
||||
return {
|
||||
TSInterfaceBody: checkMemberSeparatorStyle,
|
||||
TSTypeLiteral: checkMemberSeparatorStyle,
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=member-delimiter-style.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,755 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
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 natural_compare_lite_1 = __importDefault(require("natural-compare-lite"));
|
||||
const util = __importStar(require("../util"));
|
||||
const neverConfig = {
|
||||
type: 'string',
|
||||
enum: ['never'],
|
||||
};
|
||||
const arrayConfig = (memberTypes) => ({
|
||||
type: 'array',
|
||||
items: {
|
||||
oneOf: [
|
||||
{
|
||||
enum: memberTypes,
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
enum: memberTypes,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const objectConfig = (memberTypes) => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
memberTypes: {
|
||||
oneOf: [arrayConfig(memberTypes), neverConfig],
|
||||
},
|
||||
order: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'alphabetically',
|
||||
'alphabetically-case-insensitive',
|
||||
'as-written',
|
||||
'natural',
|
||||
'natural-case-insensitive',
|
||||
],
|
||||
},
|
||||
optionalityOrder: {
|
||||
type: 'string',
|
||||
enum: ['optional-first', 'required-first'],
|
||||
},
|
||||
},
|
||||
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 } = util.getNameFromMember(member, sourceCode);
|
||||
if (type === util.MemberNameType.Quoted) {
|
||||
return name.slice(1, -1);
|
||||
}
|
||||
if (type === util.MemberNameType.Private) {
|
||||
return name.slice(1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Gets the member name based on the member type.
|
||||
*
|
||||
* @param node the node to be evaluated.
|
||||
* @param sourceCode
|
||||
*/
|
||||
function getMemberName(node, sourceCode) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.TSPropertySignature:
|
||||
case utils_1.AST_NODE_TYPES.TSMethodSignature:
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition:
|
||||
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
||||
return getMemberRawName(node, sourceCode);
|
||||
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:
|
||||
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
||||
return node.kind === 'constructor'
|
||||
? 'constructor'
|
||||
: getMemberRawName(node, sourceCode);
|
||||
case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:
|
||||
return 'new';
|
||||
case utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration:
|
||||
return 'call';
|
||||
case utils_1.AST_NODE_TYPES.TSIndexSignature:
|
||||
return util.getNameFromIndexSignature(node);
|
||||
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) {
|
||||
var _a;
|
||||
if ('accessibility' in node && node.accessibility) {
|
||||
return node.accessibility;
|
||||
}
|
||||
if ('key' in node && ((_a = node.key) === null || _a === void 0 ? void 0 : _a.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 = util.createRule({
|
||||
name: 'member-ordering',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Require a consistent member declaration order',
|
||||
recommended: false,
|
||||
},
|
||||
messages: {
|
||||
incorrectOrder: 'Member {{member}} should be declared before member {{beforeMember}}.',
|
||||
incorrectGroupOrder: 'Member {{name}} should be declared before all {{rank}} definitions.',
|
||||
incorrectRequiredMembersOrder: `Member {{member}} should be declared after all {{optionalOrRequired}} members.`,
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
default: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(allMemberTypes),
|
||||
objectConfig(allMemberTypes),
|
||||
],
|
||||
},
|
||||
classes: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(allMemberTypes),
|
||||
objectConfig(allMemberTypes),
|
||||
],
|
||||
},
|
||||
classExpressions: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig(allMemberTypes),
|
||||
objectConfig(allMemberTypes),
|
||||
],
|
||||
},
|
||||
interfaces: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig([
|
||||
'readonly-signature',
|
||||
'signature',
|
||||
'readonly-field',
|
||||
'field',
|
||||
'method',
|
||||
'constructor',
|
||||
]),
|
||||
objectConfig([
|
||||
'readonly-signature',
|
||||
'signature',
|
||||
'readonly-field',
|
||||
'field',
|
||||
'method',
|
||||
'constructor',
|
||||
]),
|
||||
],
|
||||
},
|
||||
typeLiterals: {
|
||||
oneOf: [
|
||||
neverConfig,
|
||||
arrayConfig([
|
||||
'readonly-signature',
|
||||
'signature',
|
||||
'readonly-field',
|
||||
'field',
|
||||
'method',
|
||||
'constructor',
|
||||
]),
|
||||
objectConfig([
|
||||
'readonly-signature',
|
||||
'signature',
|
||||
'readonly-field',
|
||||
'field',
|
||||
'method',
|
||||
'constructor',
|
||||
]),
|
||||
],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: [
|
||||
{
|
||||
default: exports.defaultOrder,
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
/**
|
||||
* Checks if the member groups are correctly sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param groupOrder Group order to be validated.
|
||||
* @param supportsModifiers A flag indicating whether the type supports modifiers (scope or accessibility) or not.
|
||||
*
|
||||
* @return Array of member groups or null if one of the groups is not correctly sorted.
|
||||
*/
|
||||
function checkGroupSort(members, groupOrder, supportsModifiers) {
|
||||
const previousRanks = [];
|
||||
const memberGroups = [];
|
||||
let isCorrectlySorted = true;
|
||||
// Find first member which isn't correctly sorted
|
||||
members.forEach(member => {
|
||||
const rank = getRank(member, groupOrder, supportsModifiers);
|
||||
const name = getMemberName(member, context.getSourceCode());
|
||||
const rankLastMember = previousRanks[previousRanks.length - 1];
|
||||
if (rank === -1) {
|
||||
return;
|
||||
}
|
||||
// Works for 1st item because x < undefined === false for any x (typeof string)
|
||||
if (rank < rankLastMember) {
|
||||
context.report({
|
||||
node: member,
|
||||
messageId: 'incorrectGroupOrder',
|
||||
data: {
|
||||
name,
|
||||
rank: getLowestRank(previousRanks, rank, groupOrder),
|
||||
},
|
||||
});
|
||||
isCorrectlySorted = false;
|
||||
}
|
||||
else if (rank === rankLastMember) {
|
||||
// Same member group --> Push to existing member group array
|
||||
memberGroups[memberGroups.length - 1].push(member);
|
||||
}
|
||||
else {
|
||||
// New member group --> Create new member group array
|
||||
previousRanks.push(rank);
|
||||
memberGroups.push([member]);
|
||||
}
|
||||
});
|
||||
return isCorrectlySorted ? memberGroups : null;
|
||||
}
|
||||
/**
|
||||
* Checks if the members are alphabetically sorted.
|
||||
*
|
||||
* @param members Members to be validated.
|
||||
* @param caseSensitive indicates if the alpha ordering is case sensitive or not.
|
||||
*
|
||||
* @return True if all members are correctly sorted.
|
||||
*/
|
||||
function checkAlphaSort(members, order) {
|
||||
let previousName = '';
|
||||
let isCorrectlySorted = true;
|
||||
// Find first member which isn't correctly sorted
|
||||
members.forEach(member => {
|
||||
const name = getMemberName(member, context.getSourceCode());
|
||||
// Note: Not all members have names
|
||||
if (name) {
|
||||
if (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) {
|
||||
switch (order) {
|
||||
case 'alphabetically':
|
||||
return name < previousName;
|
||||
case 'alphabetically-case-insensitive':
|
||||
return name.toLowerCase() < previousName.toLowerCase();
|
||||
case 'natural':
|
||||
return (0, natural_compare_lite_1.default)(name, previousName) !== 1;
|
||||
case 'natural-case-insensitive':
|
||||
return ((0, natural_compare_lite_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, context.getSourceCode()),
|
||||
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) {
|
||||
var _a;
|
||||
validateMembersOrder(node.body.body, (_a = options.classes) !== null && _a !== void 0 ? _a : options.default, true);
|
||||
},
|
||||
ClassExpression(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.body.body, (_a = options.classExpressions) !== null && _a !== void 0 ? _a : options.default, true);
|
||||
},
|
||||
TSInterfaceDeclaration(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.body.body, (_a = options.interfaces) !== null && _a !== void 0 ? _a : options.default, false);
|
||||
},
|
||||
TSTypeLiteral(node) {
|
||||
var _a;
|
||||
validateMembersOrder(node.members, (_a = options.typeLiterals) !== null && _a !== void 0 ? _a : options.default, false);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=member-ordering.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,201 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util = __importStar(require("../util"));
|
||||
exports.default = util.createRule({
|
||||
name: 'method-signature-style',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Enforce using a particular method signature syntax',
|
||||
recommended: false,
|
||||
},
|
||||
fixable: 'code',
|
||||
messages: {
|
||||
errorMethod: 'Shorthand method signature is forbidden. Use a function property instead.',
|
||||
errorProperty: 'Function property signature is forbidden. Use a method shorthand instead.',
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
enum: ['property', 'method'],
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultOptions: ['property'],
|
||||
create(context, [mode]) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
function getMethodKey(node) {
|
||||
let key = sourceCode.getText(node.key);
|
||||
if (node.computed) {
|
||||
key = `[${key}]`;
|
||||
}
|
||||
if (node.optional) {
|
||||
key = `${key}?`;
|
||||
}
|
||||
if (node.readonly) {
|
||||
key = `readonly ${key}`;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
function getMethodParams(node) {
|
||||
let params = '()';
|
||||
if (node.params.length > 0) {
|
||||
const openingParen = util.nullThrows(sourceCode.getTokenBefore(node.params[0], util.isOpeningParenToken), 'Missing opening paren before first parameter');
|
||||
const closingParen = util.nullThrows(sourceCode.getTokenAfter(node.params[node.params.length - 1], util.isClosingParenToken), 'Missing closing paren after last parameter');
|
||||
params = sourceCode.text.substring(openingParen.range[0], closingParen.range[1]);
|
||||
}
|
||||
if (node.typeParameters != null) {
|
||||
const typeParams = sourceCode.getText(node.typeParameters);
|
||||
params = `${typeParams}${params}`;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
function getMethodReturnType(node) {
|
||||
return node.returnType == null
|
||||
? // if the method has no return type, it implicitly has an `any` return type
|
||||
// we just make it explicit here so we can do the fix
|
||||
'any'
|
||||
: sourceCode.getText(node.returnType.typeAnnotation);
|
||||
}
|
||||
function getDelimiter(node) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (lastToken &&
|
||||
(util.isSemicolonToken(lastToken) || util.isCommaToken(lastToken))) {
|
||||
return lastToken.value;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function isNodeParentModuleDeclaration(node) {
|
||||
if (!node.parent) {
|
||||
return false;
|
||||
}
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration) {
|
||||
return true;
|
||||
}
|
||||
if (node.parent.type === utils_1.AST_NODE_TYPES.Program) {
|
||||
return false;
|
||||
}
|
||||
return isNodeParentModuleDeclaration(node.parent);
|
||||
}
|
||||
return Object.assign(Object.assign({}, (mode === 'property' && {
|
||||
TSMethodSignature(methodNode) {
|
||||
if (methodNode.kind !== 'method') {
|
||||
return;
|
||||
}
|
||||
const parent = methodNode.parent;
|
||||
const members = (parent === null || parent === void 0 ? void 0 : parent.type) === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
||||
? parent.body
|
||||
: (parent === null || parent === void 0 ? void 0 : parent.type) === utils_1.AST_NODE_TYPES.TSTypeLiteral
|
||||
? parent.members
|
||||
: [];
|
||||
const duplicatedKeyMethodNodes = members.filter((element) => element.type === utils_1.AST_NODE_TYPES.TSMethodSignature &&
|
||||
element !== methodNode &&
|
||||
getMethodKey(element) === getMethodKey(methodNode));
|
||||
const isParentModule = isNodeParentModuleDeclaration(methodNode);
|
||||
if (duplicatedKeyMethodNodes.length > 0) {
|
||||
if (isParentModule) {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
*fix(fixer) {
|
||||
const methodNodes = [
|
||||
methodNode,
|
||||
...duplicatedKeyMethodNodes,
|
||||
].sort((a, b) => (a.range[0] < b.range[0] ? -1 : 1));
|
||||
const typeString = methodNodes
|
||||
.map(node => {
|
||||
const params = getMethodParams(node);
|
||||
const returnType = getMethodReturnType(node);
|
||||
return `(${params} => ${returnType})`;
|
||||
})
|
||||
.join(' & ');
|
||||
const key = getMethodKey(methodNode);
|
||||
const delimiter = getDelimiter(methodNode);
|
||||
yield fixer.replaceText(methodNode, `${key}: ${typeString}${delimiter}`);
|
||||
for (const node of duplicatedKeyMethodNodes) {
|
||||
const lastToken = sourceCode.getLastToken(node);
|
||||
if (lastToken) {
|
||||
const nextToken = sourceCode.getTokenAfter(lastToken);
|
||||
if (nextToken) {
|
||||
yield fixer.remove(node);
|
||||
yield fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], '');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isParentModule) {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
});
|
||||
}
|
||||
else {
|
||||
context.report({
|
||||
node: methodNode,
|
||||
messageId: 'errorMethod',
|
||||
fix: fixer => {
|
||||
const key = getMethodKey(methodNode);
|
||||
const params = getMethodParams(methodNode);
|
||||
const returnType = getMethodReturnType(methodNode);
|
||||
const delimiter = getDelimiter(methodNode);
|
||||
return fixer.replaceText(methodNode, `${key}: ${params} => ${returnType}${delimiter}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
})), (mode === 'method' && {
|
||||
TSPropertySignature(propertyNode) {
|
||||
var _a;
|
||||
const typeNode = (_a = propertyNode.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation;
|
||||
if ((typeNode === null || typeNode === void 0 ? void 0 : typeNode.type) !== utils_1.AST_NODE_TYPES.TSFunctionType) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
node: propertyNode,
|
||||
messageId: 'errorProperty',
|
||||
fix: fixer => {
|
||||
const key = getMethodKey(propertyNode);
|
||||
const params = getMethodParams(typeNode);
|
||||
const returnType = getMethodReturnType(typeNode);
|
||||
const delimiter = getDelimiter(propertyNode);
|
||||
return fixer.replaceText(propertyNode, `${key}${params}: ${returnType}${delimiter}`);
|
||||
},
|
||||
});
|
||||
},
|
||||
}));
|
||||
},
|
||||
});
|
||||
//# sourceMappingURL=method-signature-style.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,93 +0,0 @@
|
||||
"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";
|
||||
})(Selectors || (exports.Selectors = Selectors = {}));
|
||||
var MetaSelectors;
|
||||
(function (MetaSelectors) {
|
||||
MetaSelectors[MetaSelectors["default"] = -1] = "default";
|
||||
MetaSelectors[MetaSelectors["variableLike"] = 7] = "variableLike";
|
||||
MetaSelectors[MetaSelectors["memberLike"] = 4088] = "memberLike";
|
||||
MetaSelectors[MetaSelectors["typeLike"] = 192512] = "typeLike";
|
||||
MetaSelectors[MetaSelectors["method"] = 448] = "method";
|
||||
MetaSelectors[MetaSelectors["property"] = 3584] = "property";
|
||||
})(MetaSelectors || (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";
|
||||
// make sure TypeModifiers starts at Modifiers + 1 or else sorting won't work
|
||||
})(Modifiers || (exports.Modifiers = Modifiers = {}));
|
||||
var TypeModifiers;
|
||||
(function (TypeModifiers) {
|
||||
TypeModifiers[TypeModifiers["boolean"] = 32768] = "boolean";
|
||||
TypeModifiers[TypeModifiers["string"] = 65536] = "string";
|
||||
TypeModifiers[TypeModifiers["number"] = 131072] = "number";
|
||||
TypeModifiers[TypeModifiers["function"] = 262144] = "function";
|
||||
TypeModifiers[TypeModifiers["array"] = 524288] = "array";
|
||||
})(TypeModifiers || (exports.TypeModifiers = TypeModifiers = {}));
|
||||
//# sourceMappingURL=enums.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../src/rules/naming-convention-utils/enums.ts"],"names":[],"mappings":";;;AAAA,IAAK,iBAOJ;AAPD,WAAK,iBAAiB;IACpB,mEAAa,CAAA;IACb,+EAAe,CAAA;IACf,qEAAU,CAAA;IACV,iFAAgB,CAAA;IAChB,qEAAU,CAAA;IACV,qEAAU,CAAA;AACZ,CAAC,EAPI,iBAAiB,iCAAjB,iBAAiB,QAOrB;AAGD,IAAK,iBASJ;AATD,WAAK,iBAAiB;IACpB,6DAAU,CAAA;IACV,2DAAK,CAAA;IACL,+DAAO,CAAA;IAEP,iEAAiE;IACjE,2EAAa,CAAA;IACb,uEAAW,CAAA;IACX,uFAAmB,CAAA;AACrB,CAAC,EATI,iBAAiB,iCAAjB,iBAAiB,QASrB;AAGD,IAAK,SAuBJ;AAvBD,WAAK,SAAS;IACZ,eAAe;IACf,iDAAiB,CAAA;IACjB,iDAAiB,CAAA;IACjB,mDAAkB,CAAA;IAElB,aAAa;IACb,mEAA0B,CAAA;IAC1B,kDAAiB,CAAA;IACjB,sDAAmB,CAAA;IACnB,wDAAoB,CAAA;IACpB,yEAA4B,CAAA;IAC5B,uDAAmB,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"__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 +0,0 @@
|
||||
{"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,kB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B;IACtD,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW;IAC3C,CAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW;CAC5C,CAAC;AAEO,0EAA+B"}
|
||||
@@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseOptions = exports.selectorTypeToMessageString = exports.SCHEMA = exports.Modifiers = void 0;
|
||||
var enums_1 = require("./enums");
|
||||
Object.defineProperty(exports, "Modifiers", { enumerable: true, get: function () { return enums_1.Modifiers; } });
|
||||
var schema_1 = require("./schema");
|
||||
Object.defineProperty(exports, "SCHEMA", { enumerable: true, get: function () { return schema_1.SCHEMA; } });
|
||||
var shared_1 = require("./shared");
|
||||
Object.defineProperty(exports, "selectorTypeToMessageString", { enumerable: true, get: function () { return shared_1.selectorTypeToMessageString; } });
|
||||
var parse_options_1 = require("./parse-options");
|
||||
Object.defineProperty(exports, "parseOptions", { enumerable: true, get: function () { return parse_options_1.parseOptions; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user