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

Skip to content

Commit 0cf1963

Browse files
authored
Merge branch 'master' into snapshot-tests
2 parents 432681a + 78a8b7c commit 0cf1963

File tree

15 files changed

+357
-189
lines changed

15 files changed

+357
-189
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
This repo contains several packages which allow ESLint users to lint their TypeScript code.
1818

19-
- `typescript-estree` - An entirely generic TypeScript parser which takes TypeScript source code and produces an <a href="https://github.com/estree/estree">ESTree</a>-compatible AST</p>
19+
- [`typescript-estree`](./packages/typescript-estree/) - An entirely generic TypeScript parser which takes TypeScript source code and produces an <a href="https://github.com/estree/estree">ESTree</a>-compatible AST</p>
2020

2121
- This package is also used to power the amazing opinionated code formatter [Prettier](https://prettier.io)'s own TypeScript use-case.
2222

23-
- `typescript-eslint-parser` - An ESLint-specific parser which leverages `typescript-estree` and is designed to be used as a replacement for ESLint's default parser, `espree`.
23+
- [`typescript-eslint-parser`](./packages/typescript-eslint-parser/) - An ESLint-specific parser which leverages `typescript-estree` and is designed to be used as a replacement for ESLint's default parser, `espree`.
2424

25-
- `eslint-plugin-typescript` - An ESLint-specific plugin which, when used in conjunction with `typescript-eslint-parser`, allows for TypeScript-specific linting rules to run.
25+
- [`eslint-plugin-typescript`](./packages/eslint-plugin-typescript/) - An ESLint-specific plugin which, when used in conjunction with `typescript-eslint-parser`, allows for TypeScript-specific linting rules to run.
2626

27-
- `eslint-plugin-tslint` - An ESLint-specific plugin which runs an instance of TSLint within your ESLint setup to allow for users to more easily migrate from TSLint to ESLint.
27+
- [`eslint-plugin-tslint`](./packages/eslint-plugin-tslint) - An ESLint-specific plugin which runs an instance of TSLint within your ESLint setup to allow for users to more easily migrate from TSLint to ESLint.
2828

2929
## Supported TypeScript Version
3030

packages/eslint-plugin-typescript/ROADMAP.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Roadmap
22

3-
## TSLint rules
3+
✅ (27) = done
4+
🌟 (79) = in ESLint core
5+
🔌 (33) = in another plugin
6+
🌓 (16) = implementations differ or ESLint version is missing functionality
7+
🛑 (71) = unimplemented
48

5-
✅ = done
6-
🌟 = in ESLint core
7-
🔌 = in another plugin
8-
🛑 = unimplemented
9-
◐ = implementations differ or ESLint version is missing functionality
9+
## TSLint rules
1010

1111
### TypeScript-specific
1212

@@ -72,15 +72,15 @@
7272
| [`no-sparse-arrays`] | 🌟 | [`no-sparse-arrays`][no-sparse-arrays] |
7373
| [`no-string-literal`] | 🌟 | [`dot-notation`][dot-notation] |
7474
| [`no-string-throw`] | 🌟 | [`no-throw-literal`][no-throw-literal] |
75-
| [`no-submodule-imports`] | | [`import/no-internal-modules`] (slightly different) |
75+
| [`no-submodule-imports`] | 🌓 | [`import/no-internal-modules`] (slightly different) |
7676
| [`no-switch-case-fall-through`] | 🌟 | [`no-fallthrough`][no-fallthrough] |
7777
| [`no-this-assignment`] || [`typescript/no-this-alias`] |
7878
| [`no-unbound-method`] | 🛑 | N/A |
7979
| [`no-unnecessary-class`] || [`typescript/no-extraneous-class`] |
8080
| [`no-unsafe-any`] | 🛑 | N/A |
8181
| [`no-unsafe-finally`] | 🌟 | [`no-unsafe-finally`][no-unsafe-finally] |
8282
| [`no-unused-expression`] | 🌟 | [`no-unused-expression`][no-unused-expressions] |
83-
| [`no-unused-variable`] | | [`no-unused-vars`][no-unused-vars] <sup>[2]</sup> |
83+
| [`no-unused-variable`] | 🌓 | [`no-unused-vars`][no-unused-vars] <sup>[2]</sup> |
8484
| [`no-use-before-declare`] || [`typescript/no-use-before-define`] |
8585
| [`no-var-keyword`] | 🌟 | [`no-var`][no-var] |
8686
| [`no-void-expression`] | 🌟 | [`no-void`][no-void] |
@@ -104,7 +104,7 @@
104104
| TSLint rule | | ESLint rule |
105105
| ---------------------------- | :-: | -------------------------------------------------- |
106106
| [`cyclomatic-complexity`] | 🌟 | [`complexity`][complexity] |
107-
| [`deprecation`] | | [`import/no-deprecated`] <sup>[1]</sup> |
107+
| [`deprecation`] | 🌓 | [`import/no-deprecated`] <sup>[1]</sup> |
108108
| [`eofline`] | 🌟 | [`eol-last`][eol-last] |
109109
| [`indent`] || [`typescript/indent`] or [Prettier] |
110110
| [`linebreak-style`] | 🌟 | [`linebreak-style`][linebreak-style] or [Prettier] |
@@ -115,10 +115,10 @@
115115
| [`no-duplicate-imports`] | 🔌 | [`import/no-duplicates`] |
116116
| [`no-mergeable-namespace`] | 🛑 | N/A |
117117
| [`no-require-imports`] | 🛑 | N/A |
118-
| [`object-literal-sort-keys`] | | [`sort-keys`][sort-keys] <sup>[2]</sup> |
118+
| [`object-literal-sort-keys`] | 🌓 | [`sort-keys`][sort-keys] <sup>[2]</sup> |
119119
| [`prefer-const`] | 🌟 | [`prefer-const`][prefer-const] |
120120
| [`prefer-readonly`] | 🛑 | N/A |
121-
| [`trailing-comma`] | | [`comma-dangle`][comma-dangle] or [Prettier] |
121+
| [`trailing-comma`] | 🌓 | [`comma-dangle`][comma-dangle] or [Prettier] |
122122

123123
<sup>[1]</sup> Only warns when importing deprecated symbols
124124
<sup>[2]</sup> Missing support for blank-line-delimited sections
@@ -142,7 +142,7 @@
142142
| [`import-spacing`] | 🔌 | Use [Prettier] |
143143
| [`interface-name`] || [`typescript/interface-name-prefix`] |
144144
| [`interface-over-type-literal`] || [`typescript/prefer-interface`] |
145-
| [`jsdoc-format`] | | [`valid-jsdoc`][valid-jsdoc] or [`eslint-plugin-jsdoc`][plugin:jsdoc] |
145+
| [`jsdoc-format`] | 🌓 | [`valid-jsdoc`][valid-jsdoc] or [`eslint-plugin-jsdoc`][plugin:jsdoc] |
146146
| [`match-default-export-name`] | 🛑 | N/A |
147147
| [`newline-before-return`] | 🌟 | [`padding-line-between-statements`][padding-line-between-statements] <sup>[1]</sup> |
148148
| [`newline-per-chained-call`] | 🌟 | [`newline-per-chained-call`][newline-per-chained-call] |
@@ -202,7 +202,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
202202

203203
| tslint-microsoft-contrib rule | | ESLint rule |
204204
| ----------------------------- | :-: | -------------------------------------------------- |
205-
| `prefer-array-literal` | | [`typescript/no-array-constructor`] <sup>[1]</sup> |
205+
| `prefer-array-literal` | 🌓 | [`typescript/no-array-constructor`] <sup>[1]</sup> |
206206
| `prefer-type-cast` | 🛑 | N/A |
207207

208208
<sup>[1]</sup> ESLint rule is slightly less strict, allowing `new Array<Foo>()` and `Array(2)`.
@@ -211,17 +211,17 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
211211

212212
| tslint-microsoft-contrib rule | | ESLint rule |
213213
| ------------------------------------- | :-: | ---------------------------------------------------------------------- |
214-
| `export-name` | 🛑 | N/A ([relevant plugin](plugin:import)) |
214+
| `export-name` | 🛑 | N/A ([relevant plugin][plugin:import]) |
215215
| `function-name` | 🛑 | N/A |
216-
| `import-name` | 🛑 | N/A ([relevant plugin](plugin:import)) |
216+
| `import-name` | 🛑 | N/A ([relevant plugin][plugin:import]) |
217217
| `function-name` | 🛑 | N/A |
218218
| `informative-docs` | 🛑 | N/A |
219219
| `insecure-random` | 🔌 | [custom implementation][insecure-random] |
220220
| `max-func-body-length` | 🌟 | [`max-statements`][max-statements] |
221-
| `no-banned-terms` | 🌟 | [`no-callee`][no-callee] & [`no-eval`][no-eval] |
221+
| `no-banned-terms` | 🌟 | [`no-caller`][no-caller] & [`no-eval`][no-eval] |
222222
| `no-constant-condition` | 🌟 | [`no-constant-condition`][no-constant-condition] |
223223
| `no-control-regex` | 🌟 | [`no-control-regex`][no-control-regex] |
224-
| `no-delete-expression` | | [`no-delete-var`][no-delete-var] |
224+
| `no-delete-expression` | 🌓 | [`no-delete-var`][no-delete-var] |
225225
| `no-empty-line-after-opening-brace` | 🌟 | [`padded-blocks`][padded-blocks] <sup>[1]</sup> or [Prettier] |
226226
| `no-for-in` | 🌟 | [`no-restricted-syntax`][no-restricted-syntax] <sup>[2]</sup> |
227227
| `no-function-expression` | 🌟 | [`func-style`][func-style] <sup>[3]</sup> |
@@ -234,7 +234,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
234234
| `no-suspicious-comment` | 🌟 | [`no-warning-comments`][no-warning-comments] <sup>[4]</sup> |
235235
| `no-typeof-undefined` | 🛑 | N/A (this actually has a valid use: checking if a variable is defined) |
236236
| `no-unexternalized-strings` | 🛑 | N/A |
237-
| `no-unnecessary-field-initialization` | | [`no-undef-init`][no-undef-init] <sup>[5]</sup> |
237+
| `no-unnecessary-field-initialization` | 🌓 | [`no-undef-init`][no-undef-init] <sup>[5]</sup> |
238238
| `no-unnecessary-local-variable` | 🛑 | N/A |
239239
| `no-unnecessary-override` | 🛑 | N/A |
240240
| `no-unnecessary-semicolons` | 🌟 | [`no-extra-semi`][no-extra-semi] or [Prettier] |
@@ -258,7 +258,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
258258
| tslint-microsoft-contrib rule | | ESLint rule |
259259
| ------------------------------------------ | :-: | -------------------------------------------------- |
260260
| `no-disable-auto-sanitization` | 🛑 | N/A |
261-
| `no-document-domain` | | Use [`no-restricted-syntax`][no-restricted-syntax] |
261+
| `no-document-domain` | 🌓 | Use [`no-restricted-syntax`][no-restricted-syntax] |
262262
| `no-function-constructor-with-string-args` | 🌟 | [`no-new-func`][no-new-func] |
263263
| `no-http-string` | 🛑 | N/A |
264264
| `no-inner-html` | 🛑 | N/A |
@@ -277,23 +277,23 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
277277
| ----------------------------------- | :-: | -------------------------------------------------- |
278278
| `jquery-deferred-must-complete` | 🛑 | N/A |
279279
| `no-backbone-get-set-outside-model` | 🛑 | N/A |
280-
| `no-cookies` | | Use [`no-restricted-syntax`][no-restricted-syntax] |
281-
| `no-document-write` | | Use [`no-restricted-syntax`][no-restricted-syntax] |
282-
| `no-exec-script` | | Use [`no-restricted-syntax`][no-restricted-syntax] |
280+
| `no-cookies` | 🌓 | Use [`no-restricted-syntax`][no-restricted-syntax] |
281+
| `no-document-write` | 🌓 | Use [`no-restricted-syntax`][no-restricted-syntax] |
282+
| `no-exec-script` | 🌓 | Use [`no-restricted-syntax`][no-restricted-syntax] |
283283
| `no-jquery-raw-elements` | 🛑 | N/A |
284284
| `no-unsupported-browser-code` | 🔌 | [`eslint-plugin-compat`][plugin:compat] |
285285
| `react-this-binding-issue` | 🛑 | |
286286
| `react-tsx-curly-spacing` | 🔌 | [`react/jsx-curly-spacing`] |
287-
| `react-unused-props-and-state` | | [`react/no-unused-state`] |
287+
| `react-unused-props-and-state` | 🌓 | [`react/no-unused-state`] |
288288

289289
### React A11y
290290

291291
| tslint-microsoft-contrib rule | | ESLint rule |
292292
| ----------------------------------------- | :-: | ---------------------------------------------------------- |
293-
| `react-a11y-accessible-headings` | | [`jsx-a11y/heading-has-content`] <sup>[1]</sup> |
293+
| `react-a11y-accessible-headings` | 🌓 | [`jsx-a11y/heading-has-content`] <sup>[1]</sup> |
294294
| `react-a11y-anchors` | 🔌 | [`jsx-a11y/anchor-is-valid`] |
295295
| `react-a11y-aria-unsupported-elements` | 🔌 | [`jsx-a11y/aria-unsupported-elements`] |
296-
| `react-a11y-event-has-role` | | [`jsx-a11y/no-static-element-interactions`] <sup>[2]</sup> |
296+
| `react-a11y-event-has-role` | 🌓 | [`jsx-a11y/no-static-element-interactions`] <sup>[2]</sup> |
297297
| `react-a11y-image-button-has-alt` | 🔌 | [`jsx-a11y/alt-text`] |
298298
| `react-a11y-img-has-alt` | 🔌 | [`jsx-a11y/alt-text`] |
299299
| `react-a11y-input-elements` | 🛑 | N/A |
@@ -553,6 +553,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
553553
[no-octal-escape]: https://eslint.org/docs/rules/no-octal-escape
554554
[no-extra-semi]: https://eslint.org/docs/rules/no-extra-semi
555555
[no-with]: https://eslint.org/docs/rules/no-with
556+
[no-warning-comments]: https://eslint.org/docs/rules/no-warning-comments
556557

557558
<!-- eslint-plugin-typescript -->
558559

packages/eslint-plugin-typescript/lib/rules/class-name-casing.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ module.exports = {
5454
switch (decl.type) {
5555
case 'ClassDeclaration':
5656
case 'ClassExpression':
57-
friendlyName = 'Class';
58-
break;
59-
case 'TSAbstractClassDeclaration':
60-
friendlyName = 'Abstract class';
57+
friendlyName = decl.abstract ? 'Abstract class' : 'Class';
6158
break;
6259
case 'TSInterfaceDeclaration':
6360
friendlyName = 'Interface';
@@ -81,9 +78,7 @@ module.exports = {
8178
//----------------------------------------------------------------------
8279

8380
return {
84-
'ClassDeclaration, TSInterfaceDeclaration, TSAbstractClassDeclaration, ClassExpression'(
85-
node
86-
) {
81+
'ClassDeclaration, TSInterfaceDeclaration, ClassExpression'(node) {
8782
// class expressions (i.e. export default class {}) are OK
8883
if (node.id && !isPascalCase(node.id.name)) {
8984
report(node);

packages/eslint-plugin-typescript/lib/rules/indent.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const KNOWN_NODES = new Set([
2929
'TSNullKeyword',
3030

3131
// ts specific nodes we want to support
32-
'TSAbstractClassDeclaration',
3332
'TSAbstractClassProperty',
3433
'TSAbstractMethodDefinition',
3534
'TSArrayType',

packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-shadow.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ ruleTester.run('no-shadow', rule, {
2222
`
2323
type foo = any;
2424
function bar(foo: any) {}
25+
`,
26+
// https://github.com/typescript-eslint/typescript-eslint/issues/20
27+
`
28+
export abstract class Foo {}
29+
export class FooBar extends Foo {}
2530
`
2631
],
2732
invalid: []

packages/eslint-plugin-typescript/tests/lib/eslint-rules/no-undef.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ interface Runnable {
6161
export type SomeThing = {
6262
id: string;
6363
}
64+
`,
65+
// https://github.com/typescript-eslint/typescript-eslint/issues/20
66+
`
67+
export abstract class Foo {}
68+
export class FooBar extends Foo {}
6469
`
6570
],
6671
invalid: []

packages/eslint-plugin-typescript/tests/lib/rules/indent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function nonTsTestCase(example) {
2222

2323
const individualNodeTests = [
2424
{
25-
node: 'TSAbstractClassDeclaration',
25+
node: 'ClassDeclaration',
2626
code: [
2727
`
2828
abstract class Foo {
@@ -157,7 +157,7 @@ interface Foo {
157157
]
158158
},
159159
{
160-
node: 'TSEmptyBodyDeclareFunction',
160+
node: 'TSDeclareFunction',
161161
code: [
162162
`
163163
declare function foo() : {

packages/typescript-eslint-parser/src/analyze-scope.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class Referencer extends OriginalReferencer {
202202
/**
203203
* Override.
204204
* Visit decorators.
205-
* @param {ClassDeclaration|ClassExpression|TSAbstractClassDeclaration} node The class node to visit.
205+
* @param {ClassDeclaration|ClassExpression} node The class node to visit.
206206
* @returns {void}
207207
*/
208208
visitClass(node: any) {
@@ -709,9 +709,6 @@ class Referencer extends OriginalReferencer {
709709
this.close(node);
710710
}
711711

712-
TSAbstractClassDeclaration(node: any) {
713-
this.ClassDeclaration(node);
714-
}
715712
TSAbstractClassProperty(node: any) {
716713
this.ClassProperty(node);
717714
}

packages/typescript-eslint-parser/src/visitor-keys.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
3636
ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
3737
Decorator: ['expression'],
3838
TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
39-
TSAbstractClassDeclaration: [
40-
'decorators',
41-
'id',
42-
'typeParameters',
43-
'superClass',
44-
'superTypeParameters',
45-
'implements',
46-
'body'
47-
],
4839
TSAbstractKeyword: [],
4940
TSAbstractMethodDefinition: ['key', 'value'],
5041
TSAnyKeyword: [],

0 commit comments

Comments
 (0)