Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit feacff2

Browse files
committed
Merge branch 'master'
Conflicts: packages/eslint-plugin/README.md packages/eslint-plugin/tests/docs.test.ts
2 parents 2aa0d77 + bec4572 commit feacff2

File tree

146 files changed

+18697
-3501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+18697
-3501
lines changed

.cspell.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"/\\.\\/docs\\/rules\\/[^.]*.md/",
3030
"/@typescript-eslint\\/[a-z-]+/",
3131
"/\\.all-contributorsrc/",
32-
"/TS[^\\s]+/"
32+
"/TS[^\\s]+/",
33+
"\\(#.+?\\)"
3334
],
3435
"words": [
3536
"ASTs",
@@ -61,6 +62,7 @@
6162
"estree",
6263
"linebreaks",
6364
"necroing",
65+
"nocheck",
6466
"nullish",
6567
"parameterised",
6668
"performant",

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ jest.config.js
44
fixtures
55
shared-fixtures
66
coverage
7+
__snapshots__
78

89
packages/eslint-plugin-tslint/tests

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = {
3333
'@typescript-eslint/prefer-nullish-coalescing': 'error',
3434
'@typescript-eslint/prefer-optional-chain': 'error',
3535
'@typescript-eslint/unbound-method': 'off',
36+
'@typescript-eslint/prefer-as-const': 'error',
3637

3738
'no-empty-function': 'off',
3839
'@typescript-eslint/no-empty-function': [
@@ -123,6 +124,7 @@ module.exports = {
123124
// Internal repo rules
124125
//
125126
'@typescript-eslint/internal/no-typescript-default-import': 'error',
127+
'@typescript-eslint/internal/prefer-ast-types-enum': 'error',
126128
},
127129
parserOptions: {
128130
sourceType: 'module',

.vscode/launch.json

Lines changed: 80 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,85 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
{
8-
"type": "node",
9-
"request": "launch",
10-
"name": "Jest Test Current eslint-plugin Rule",
11-
"cwd": "${workspaceFolder}/packages/eslint-plugin/",
12-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
13-
"args": [
14-
"--runInBand",
15-
"--no-coverage",
16-
// needs the '' around it so that the () are properly handled
17-
"'tests/(.+/)?${fileBasenameNoExtension}'"
18-
],
19-
"sourceMaps": true,
20-
"console": "integratedTerminal",
21-
"internalConsoleOptions": "neverOpen"
22-
},
23-
{
24-
"type": "node",
25-
"request": "launch",
26-
"name": "Jest Test Current eslint-plugin-internal Rule",
27-
"cwd": "${workspaceFolder}/packages/eslint-plugin-internal/",
28-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
29-
"args": [
30-
"--runInBand",
31-
"--no-coverage",
32-
// needs the '' around it so that the () are properly handled
33-
"'tests/(.+/)?${fileBasenameNoExtension}'"
34-
],
35-
"sourceMaps": true,
36-
"console": "integratedTerminal",
37-
"internalConsoleOptions": "neverOpen"
38-
},
39-
{
40-
"type": "node",
41-
"request": "launch",
42-
"name": "Run currently opened typescript-estree test",
43-
"cwd": "${workspaceFolder}/packages/typescript-estree/",
44-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
45-
"args": [
46-
"--runInBand",
47-
"--no-cache",
48-
"--no-coverage",
49-
"${relativeFile}"
50-
],
51-
"sourceMaps": true,
52-
"console": "integratedTerminal",
53-
"internalConsoleOptions": "neverOpen"
54-
},
55-
{
56-
"type": "node",
57-
"request": "launch",
58-
"name": "Run currently opened parser test",
59-
"cwd": "${workspaceFolder}/packages/parser/",
60-
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
61-
"args": [
62-
"--runInBand",
63-
"--no-cache",
64-
"--no-coverage",
65-
"${relativeFile}"
66-
],
67-
"sourceMaps": true,
68-
"console": "integratedTerminal",
69-
"internalConsoleOptions": "neverOpen"
70-
}
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Jest Test Current eslint-plugin Rule",
11+
"cwd": "${workspaceFolder}/packages/eslint-plugin/",
12+
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
13+
"args": [
14+
"--runInBand",
15+
"--no-cache",
16+
"--no-coverage",
17+
"${fileBasenameNoExtension}"
18+
],
19+
"sourceMaps": true,
20+
"console": "integratedTerminal",
21+
"internalConsoleOptions": "neverOpen"
22+
},
23+
{
24+
"type": "node",
25+
"request": "launch",
26+
"name": "Jest Test Current eslint-plugin-internal Rule",
27+
"cwd": "${workspaceFolder}/packages/eslint-plugin-internal/",
28+
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
29+
"args": [
30+
"--runInBand",
31+
"--no-cache",
32+
"--no-coverage",
33+
"${fileBasenameNoExtension}"
34+
],
35+
"sourceMaps": true,
36+
"console": "integratedTerminal",
37+
"internalConsoleOptions": "neverOpen"
38+
},
39+
{
40+
"type": "node",
41+
"request": "launch",
42+
"name": "Run currently opened typescript-estree test",
43+
"cwd": "${workspaceFolder}/packages/typescript-estree/",
44+
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
45+
"args": [
46+
"--runInBand",
47+
"--no-cache",
48+
"--no-coverage",
49+
"${fileBasename}"
50+
],
51+
"sourceMaps": true,
52+
"console": "integratedTerminal",
53+
"internalConsoleOptions": "neverOpen"
54+
},
55+
{
56+
"type": "node",
57+
"request": "launch",
58+
"name": "Run currently opened parser test",
59+
"cwd": "${workspaceFolder}/packages/parser/",
60+
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
61+
"args": [
62+
"--runInBand",
63+
"--no-cache",
64+
"--no-coverage",
65+
"${fileBasename}"
66+
],
67+
"sourceMaps": true,
68+
"console": "integratedTerminal",
69+
"internalConsoleOptions": "neverOpen"
70+
},
71+
{
72+
"type": "node",
73+
"request": "launch",
74+
"name": "Run currently opened experimental-utils test",
75+
"cwd": "${workspaceFolder}/packages/experimental-utils/",
76+
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
77+
"args": [
78+
"--runInBand",
79+
"--no-cache",
80+
"--no-coverage",
81+
"${fileBasenameNoExtension}"
82+
],
83+
"sourceMaps": true,
84+
"console": "integratedTerminal",
85+
"internalConsoleOptions": "neverOpen"
86+
}
7187
]
7288
}

.vscode/settings.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@
44
"eslint.validate": [
55
"javascript",
66
"javascriptreact",
7-
{
8-
"language": "typescript",
9-
"autoFix": true
10-
},
11-
{
12-
"language": "typescriptreact",
13-
"autoFix": true
14-
}
7+
"typescript",
8+
"typescriptreact"
159
],
1610

1711
// When enabled, will trim trailing whitespace when saving a file.

CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,57 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [2.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.17.0...v2.18.0) (2020-01-27)
7+
8+
9+
### Bug Fixes
10+
11+
* **eslint-plugin:** [explicit-module-boundary-types] false positive for returned fns ([#1490](https://github.com/typescript-eslint/typescript-eslint/issues/1490)) ([5562ad5](https://github.com/typescript-eslint/typescript-eslint/commit/5562ad5ed902102d7c09a7fd47ca4ea7e50d6654))
12+
* improve token types and add missing type guards ([#1497](https://github.com/typescript-eslint/typescript-eslint/issues/1497)) ([ce41d7d](https://github.com/typescript-eslint/typescript-eslint/commit/ce41d7de33bcb7ccf96c03ac1438304c5a49ff54))
13+
* **eslint-plugin:** [naming-convention] fix filter option ([#1482](https://github.com/typescript-eslint/typescript-eslint/issues/1482)) ([718cd88](https://github.com/typescript-eslint/typescript-eslint/commit/718cd889c155a75413c571ac006c33fbc271dcc5))
14+
* **eslint-plugin:** fix property access on undefined error ([#1507](https://github.com/typescript-eslint/typescript-eslint/issues/1507)) ([d89e8e8](https://github.com/typescript-eslint/typescript-eslint/commit/d89e8e8a1114989e2727351bee7aadb6579f312b))
15+
* **experimental-utils:** widen type of `settings` property ([#1527](https://github.com/typescript-eslint/typescript-eslint/issues/1527)) ([b515e47](https://github.com/typescript-eslint/typescript-eslint/commit/b515e47af2bc914c7ebcfa4be813409dcd86b1c3))
16+
* **typescript-estree:** error on unexpected jsdoc nodes ([#1525](https://github.com/typescript-eslint/typescript-eslint/issues/1525)) ([c8dfac3](https://github.com/typescript-eslint/typescript-eslint/commit/c8dfac3d2f066e50fa9d2b5a86beffdaafddb643))
17+
* **typescript-estree:** fix identifier tokens typed as `Keyword` ([#1487](https://github.com/typescript-eslint/typescript-eslint/issues/1487)) ([77a1caa](https://github.com/typescript-eslint/typescript-eslint/commit/77a1caa562638645b4717449800e410107d512c8))
18+
19+
20+
### Features
21+
22+
* **eslint-plugin:** add comma-spacing ([#1495](https://github.com/typescript-eslint/typescript-eslint/issues/1495)) ([1fd86be](https://github.com/typescript-eslint/typescript-eslint/commit/1fd86befa6a940a0354c619dd2da08a5c5d69fb4))
23+
* **eslint-plugin:** add new rule prefer-as-const ([#1431](https://github.com/typescript-eslint/typescript-eslint/issues/1431)) ([420db96](https://github.com/typescript-eslint/typescript-eslint/commit/420db96921435e8bf7fb484ae74552a912a6adde))
24+
* **eslint-plugin:** create `ban-ts-comment` rule ([#1361](https://github.com/typescript-eslint/typescript-eslint/issues/1361)) ([2a83d13](https://github.com/typescript-eslint/typescript-eslint/commit/2a83d138a966cd5ce787d1eecf595b59b78232d4))
25+
* **eslint-plugin-internal:** add `prefer-ast-types-enum` ([#1508](https://github.com/typescript-eslint/typescript-eslint/issues/1508)) ([c3d0a3a](https://github.com/typescript-eslint/typescript-eslint/commit/c3d0a3a6bdff0cae226a279f0a0a9b00952ca925))
26+
* **experimental-utils:** make RuleMetaData.docs optional ([#1462](https://github.com/typescript-eslint/typescript-eslint/issues/1462)) ([cde97ac](https://github.com/typescript-eslint/typescript-eslint/commit/cde97aca24df5a0f28f37006ed130ebc217fb2ad))
27+
* **parser:** clean up scope-analysis types ([#1481](https://github.com/typescript-eslint/typescript-eslint/issues/1481)) ([4a727fa](https://github.com/typescript-eslint/typescript-eslint/commit/4a727fa083d749dba9eaf39322856f5f69c28cd8))
28+
29+
30+
31+
32+
33+
# [2.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.16.0...v2.17.0) (2020-01-20)
34+
35+
36+
### Bug Fixes
37+
38+
* **eslint-plugin:** [naming-convention] handle empty array-pattern ([#1450](https://github.com/typescript-eslint/typescript-eslint/issues/1450)) ([4726605](https://github.com/typescript-eslint/typescript-eslint/commit/4726605))
39+
* **eslint-plugin:** [unbound-method] handling of logical expr ([#1440](https://github.com/typescript-eslint/typescript-eslint/issues/1440)) ([9c5b857](https://github.com/typescript-eslint/typescript-eslint/commit/9c5b857))
40+
* **eslint-plugin:** set default-param-last as an extension rule ([#1445](https://github.com/typescript-eslint/typescript-eslint/issues/1445)) ([b5ef704](https://github.com/typescript-eslint/typescript-eslint/commit/b5ef704))
41+
* **typescript-estree:** correct type of `ArrayPattern.elements` ([#1451](https://github.com/typescript-eslint/typescript-eslint/issues/1451)) ([62e4ca0](https://github.com/typescript-eslint/typescript-eslint/commit/62e4ca0))
42+
43+
44+
### Features
45+
46+
* **eslint-plugin:** [naming-convention] allow not check format ([#1455](https://github.com/typescript-eslint/typescript-eslint/issues/1455)) ([61eb434](https://github.com/typescript-eslint/typescript-eslint/commit/61eb434))
47+
* **eslint-plugin:** [naming-convention] correct example ([#1455](https://github.com/typescript-eslint/typescript-eslint/issues/1455)) ([60683d7](https://github.com/typescript-eslint/typescript-eslint/commit/60683d7))
48+
* **eslint-plugin:** [no-extra-!-assert] flag ?. after !-assert ([#1460](https://github.com/typescript-eslint/typescript-eslint/issues/1460)) ([58c7c25](https://github.com/typescript-eslint/typescript-eslint/commit/58c7c25))
49+
* **eslint-plugin:** add explicit-module-boundary-types rule ([#1020](https://github.com/typescript-eslint/typescript-eslint/issues/1020)) ([bb0a846](https://github.com/typescript-eslint/typescript-eslint/commit/bb0a846))
50+
* **eslint-plugin:** add no-non-null-asserted-optional-chain ([#1469](https://github.com/typescript-eslint/typescript-eslint/issues/1469)) ([498aa24](https://github.com/typescript-eslint/typescript-eslint/commit/498aa24))
51+
* **experimental-utils:** expose getParserServices from utils ([#1448](https://github.com/typescript-eslint/typescript-eslint/issues/1448)) ([982c8bc](https://github.com/typescript-eslint/typescript-eslint/commit/982c8bc))
52+
53+
54+
55+
56+
657
# [2.16.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.15.0...v2.16.0) (2020-01-13)
758

859

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ And `<package>` is the name of the package you have made changes within (`eslint
7676

7777
And `<short description>` is a succinct title for the PR.
7878

79-
Within the body of your PR, make sure you reference the issue that you have worked on, as well as a pointing out anything of note you wish us to look at during our review.
79+
Within the body of your PR, make sure you reference the issue that you have worked on, as well as pointing out anything of note you wish us to look at during our review.
8080

8181
Make sure you use the "Fixes #xxx" format to reference issues, so that GitHub automatically closes the issues when we merge the PR. Also note that if you are fixing multiple issues at once, you can only reference one issue per line, and must put one "Fixes #xxx" per issue number.
8282

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ TSLint is a fantastic tool. It is a linter that was written specifically to work
7777

7878
One advantage is there is no tooling required to reconcile differences between AST formats, but the major disadvantage is that the tool is therefore unable to reuse any of the previous work which has been done in the JavaScript ecosystem around linting, and it has to reimplement everything from scratch. Everything from rules to auto-fixing capabilities and more.
7979

80-
Palantir, the backers behind TSLint announced earlier this year that **they would be deprecating TSLint in favor of supporting `typescript-eslint`** in order to benefit the community. You can read more about that here: https://medium.com/palantir/tslint-in-2019-1a144c2317a9
80+
Palantir, the backers behind TSLint announced in 2019 that **they would be deprecating TSLint in favor of supporting `typescript-eslint`** in order to benefit the community. You can read more about that here: https://medium.com/palantir/tslint-in-2019-1a144c2317a9
8181

8282
The TypeScript Team themselves also announced their plans to move the TypeScript codebase from TSLint to `typescript-eslint`, and they have been big supporters of this project. More details at https://github.com/microsoft/TypeScript/issues/30553
8383

azure-pipelines.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ jobs:
55
- job: primary_code_validation_and_tests
66
displayName: Primary code validation and tests
77
pool:
8-
vmImage: 'Ubuntu-16.04'
8+
vmImage: 'Ubuntu-18.04'
99
steps:
1010
- task: NodeTool@0
1111
inputs:
12-
versionSpec: 11
13-
displayName: 'Install Node.js 11'
12+
versionSpec: 12
13+
displayName: 'Install Node.js 12'
1414

1515
- script: |
1616
# This also runs a build as part of the postinstall
1717
# bootstrap
1818
yarn --ignore-engines --frozen-lockfile
19+
yarn check-clean-workspace-after-install
1920
2021
- script: |
2122
# Note that this command *also* typechecks tests/tools,
@@ -43,14 +44,15 @@ jobs:
4344
yarn integration-tests
4445
displayName: 'Run integrations tests'
4546
46-
- script: |
47-
bash <(curl -s https://codecov.io/bash) -t $(CODECOV_TOKEN)
47+
- bash: bash <(curl -s https://codecov.io/bash) -P "$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
48+
env:
49+
CODECOV_TOKEN: $(CODECOV_TOKEN)
4850
displayName: 'Publish code coverage report'
4951

5052
- job: unit_tests_on_other_node_versions
5153
displayName: Run unit tests on other Node.js versions
5254
pool:
53-
vmImage: 'Ubuntu-16.04'
55+
vmImage: 'Ubuntu-18.04'
5456
strategy:
5557
maxParallel: 3
5658
matrix:
@@ -68,6 +70,7 @@ jobs:
6870
# This also runs a build as part of the postinstall
6971
# bootstrap
7072
yarn --ignore-engines --frozen-lockfile
73+
yarn check-clean-workspace-after-install
7174
7275
- script: |
7376
yarn test
@@ -80,17 +83,18 @@ jobs:
8083
- unit_tests_on_other_node_versions
8184
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'), ne(variables['Build.Reason'], 'PullRequest'))
8285
pool:
83-
vmImage: 'Ubuntu-16.04'
86+
vmImage: 'Ubuntu-18.04'
8487
steps:
8588
- task: NodeTool@0
8689
inputs:
87-
versionSpec: 11
88-
displayName: 'Install Node.js 11'
90+
versionSpec: 12
91+
displayName: 'Install Node.js 12'
8992

9093
- script: |
9194
# This also runs a build as part of the postinstall
9295
# bootstrap
9396
yarn --ignore-engines --frozen-lockfile
97+
yarn check-clean-workspace-after-install
9498
9599
- script: |
96100
npm config set //registry.npmjs.org/:_authToken=$(NPM_TOKEN)

docs/getting-started/linting/FAQ.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## Table of Contents
44

5-
- [My linting seems really slow](#my-linting-seems-really-slow)
6-
- [I get errors telling me "The file must be included in at least one of the projects provided"](#i-get-errors-telling-me-"the-file-must-be-included-in-at-least-one-of-the-projects-provided")
7-
- [I use a framework (like Vue) that requires custom file extensions, and I get errors like "You should add `parserOptions.extraFileExtensions` to your config"](<#i-use-a-framework-(like-vue)-that-requires-custom-file-extensions,-and-i-get-errors-like-"you-should-add-`parserOptions.extraFileExtensions`-to-your-config">)
5+
- [My linting feels really slow](#my-linting-feels-really-slow)
6+
- [I get errors telling me "The file must be included in at least one of the projects provided"](#i-get-errors-telling-me-the-file-must-be-included-in-at-least-one-of-the-projects-provided)
7+
- [I use a framework (like Vue) that requires custom file extensions, and I get errors like "You should add `parserOptions.extraFileExtensions` to your config"](#i-use-a-framework-like-vue-that-requires-custom-file-extensions-and-i-get-errors-like-you-should-add-parseroptionsextrafileextensions-to-your-config)
8+
- [I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code](#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code)
89

910
---
1011

@@ -81,3 +82,22 @@ You can use `parserOptions.extraFileExtensions` to specify an array of non-TypeS
8182
```
8283

8384
---
85+
86+
## I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code
87+
88+
This is a pretty common thing because TypeScript adds new features that ESLint doesn't know about.
89+
90+
The first step is to [check our list of "extension" rules here](../../../packages/eslint-plugin/README.md#extension-rules). An extension rule is simply a rule which extends the base ESLint rules to support TypeScript syntax. If you find it in there, give it a go to see if it works for you. You can configure it by disabling the base rule, and turning on the extension rule. Here's an example with the `semi` rule:
91+
92+
```json
93+
{
94+
"rules": {
95+
"semi": "off",
96+
"@typescript-eslint/semi": "error"
97+
}
98+
}
99+
```
100+
101+
If you don't find an existing extension rule, or the extension rule doesn't work for your case, then you can go ahead and check our issues. [The contributing guide outlines the best way to raise an issue](../../../CONTRIBUTING.md#raising-issues).
102+
103+
---

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.16.0",
2+
"version": "2.18.0",
33
"npmClient": "yarn",
44
"useWorkspaces": true,
55
"stream": true

0 commit comments

Comments
 (0)