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

Skip to content

Commit 7d3fac0

Browse files
committed
Merge branch 'master' into migrate-plugin-to-ts
# Conflicts: # packages/eslint-plugin/lib/rules/adjacent-overload-signatures.js # packages/eslint-plugin/lib/util.js # packages/eslint-plugin/package.json # packages/parser/src/eslint-scope.d.ts # packages/parser/src/parser.ts # packages/parser/src/typings.d.ts # packages/parser/typings/eslint-scope.d.ts # packages/typescript-estree/package.json # packages/typescript-estree/src/node-utils.ts # packages/typescript-estree/src/parser.ts
2 parents 79fe2b7 + d178499 commit 7d3fac0

File tree

58 files changed

+49355
-39981
lines changed

Some content is hidden

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

58 files changed

+49355
-39981
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
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+
# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07)
7+
8+
### Bug Fixes
9+
10+
- **eslint-plugin:** fix false positive from adjacent-overload-signatures ([#206](https://github.com/typescript-eslint/typescript-eslint/issues/206)) ([07e950e](https://github.com/typescript-eslint/typescript-eslint/commit/07e950e))
11+
- **ts-estree:** align typeArguments and typeParameters across nodes ([#223](https://github.com/typescript-eslint/typescript-eslint/issues/223)) ([3306198](https://github.com/typescript-eslint/typescript-eslint/commit/3306198))
12+
- **ts-estree:** convert decorators on var and fn decs ([#211](https://github.com/typescript-eslint/typescript-eslint/issues/211)) ([0a1777f](https://github.com/typescript-eslint/typescript-eslint/commit/0a1777f))
13+
- **ts-estree:** fix issues with typeParams in FunctionExpression ([#208](https://github.com/typescript-eslint/typescript-eslint/issues/208)) ([d4dfa3b](https://github.com/typescript-eslint/typescript-eslint/commit/d4dfa3b))
14+
15+
### Features
16+
17+
- change TypeScript version range to >=3.2.1 <3.4.0 ([#184](https://github.com/typescript-eslint/typescript-eslint/issues/184)) ([f513a14](https://github.com/typescript-eslint/typescript-eslint/commit/f513a14))
18+
- **eslint-plugin:** add new rule no-for-in-array ([#155](https://github.com/typescript-eslint/typescript-eslint/issues/155)) ([84162ba](https://github.com/typescript-eslint/typescript-eslint/commit/84162ba))
19+
- **eslint-plugin:** add new rule no-require-imports ([#199](https://github.com/typescript-eslint/typescript-eslint/issues/199)) ([683e5bc](https://github.com/typescript-eslint/typescript-eslint/commit/683e5bc))
20+
- **eslint-plugin:** added new rule promise-function-async ([#194](https://github.com/typescript-eslint/typescript-eslint/issues/194)) ([5f3aec9](https://github.com/typescript-eslint/typescript-eslint/commit/5f3aec9))
21+
- **ts-estree:** enable errors 1098 and 1099 ([#219](https://github.com/typescript-eslint/typescript-eslint/issues/219)) ([fc50167](https://github.com/typescript-eslint/typescript-eslint/commit/fc50167))
22+
623
# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01)
724

825
### Bug Fixes

lerna.json

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

packages/eslint-plugin-tslint/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
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+
# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07)
7+
8+
**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint
9+
610
# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01)
711

812
**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint

packages/eslint-plugin-tslint/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typescript-eslint/eslint-plugin-tslint",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"main": "dist/index.js",
55
"typings": "src/index.ts",
66
"description": "TSLint wrapper plugin for ESLint",
@@ -35,6 +35,6 @@
3535
"devDependencies": {
3636
"@types/eslint": "^4.16.3",
3737
"@types/lodash.memoize": "^4.1.4",
38-
"@typescript-eslint/parser": "1.2.0"
38+
"@typescript-eslint/parser": "1.3.0"
3939
}
4040
}

packages/eslint-plugin-tslint/src/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@ import memoize from 'lodash.memoize';
33
import { Configuration, RuleSeverity } from 'tslint';
44
import { Program } from 'typescript';
55
import { CustomLinter } from './custom-linter';
6+
import { ParserServices } from '@typescript-eslint/typescript-estree';
67

78
//------------------------------------------------------------------------------
89
// Plugin Definition
910
//------------------------------------------------------------------------------
1011

11-
/**
12-
* @todo share types between packages
13-
*/
14-
interface ParserServices {
15-
program: Program | undefined;
16-
esTreeNodeToTSNodeMap: WeakMap<object, any> | undefined;
17-
tsNodeToESTreeNodeMap: WeakMap<object, any> | undefined;
18-
}
19-
2012
type RawRuleConfig =
2113
| null
2214
| undefined

packages/eslint-plugin/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
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+
# [1.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.2.0...v1.3.0) (2019-02-07)
7+
8+
### Bug Fixes
9+
10+
- **eslint-plugin:** fix false positive from adjacent-overload-signatures ([#206](https://github.com/typescript-eslint/typescript-eslint/issues/206)) ([07e950e](https://github.com/typescript-eslint/typescript-eslint/commit/07e950e))
11+
12+
### Features
13+
14+
- change TypeScript version range to >=3.2.1 <3.4.0 ([#184](https://github.com/typescript-eslint/typescript-eslint/issues/184)) ([f513a14](https://github.com/typescript-eslint/typescript-eslint/commit/f513a14))
15+
- **eslint-plugin:** add new rule no-for-in-array ([#155](https://github.com/typescript-eslint/typescript-eslint/issues/155)) ([84162ba](https://github.com/typescript-eslint/typescript-eslint/commit/84162ba))
16+
- **eslint-plugin:** add new rule no-require-imports ([#199](https://github.com/typescript-eslint/typescript-eslint/issues/199)) ([683e5bc](https://github.com/typescript-eslint/typescript-eslint/commit/683e5bc))
17+
- **eslint-plugin:** added new rule promise-function-async ([#194](https://github.com/typescript-eslint/typescript-eslint/issues/194)) ([5f3aec9](https://github.com/typescript-eslint/typescript-eslint/commit/5f3aec9))
18+
619
# [1.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.1.1...v1.2.0) (2019-02-01)
720

821
### Bug Fixes

packages/eslint-plugin/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,14 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
128128
| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | |
129129
| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | |
130130
| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | |
131+
| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop (`no-for-in-array` from TSLint) | | |
131132
| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: |
132133
| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | |
133134
| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | |
134135
| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | |
135136
| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | |
136137
| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | |
138+
| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` (`no-require-imports` from TSLint) | :heavy_check_mark: | |
137139
| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | |
138140
| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// <reference path="" />` comments (`no-reference` from TSLint) | :heavy_check_mark: | |
139141
| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | |
@@ -144,6 +146,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
144146
| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | |
145147
| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: |
146148
| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: |
149+
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | :heavy_check_mark: | |
147150
| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | |
148151
| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: |
149152

packages/eslint-plugin/ROADMAP.md

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

3-
(29) = done<br>
4-
🌟 (79) = in ESLint core<br>
5-
🔌 (33) = in another plugin<br>
6-
🌓 (16) = implementations differ or ESLint version is missing functionality<br>
7-
🛑 (68) = unimplemented
3+
✅ = done<br>
4+
🌟 = in ESLint core<br>
5+
🔌 = in another plugin<br>
6+
🌓 = implementations differ or ESLint version is missing functionality<br>
7+
🛑 = unimplemented<br>
88

99
## TSLint rules
1010

@@ -30,7 +30,7 @@
3030
| [`no-var-requires`] || [`@typescript-eslint/no-var-requires`] |
3131
| [`only-arrow-functions`] | 🔌 | [`prefer-arrow/prefer-arrow-functions`] |
3232
| [`prefer-for-of`] | 🛑 | N/A |
33-
| [`promise-function-async`] | 🛑 | N/A ([relevant plugin][plugin:promise]) |
33+
| [`promise-function-async`] | | [`@typescript-eslint/promise-function-async`] |
3434
| [`typedef`] | 🛑 | N/A |
3535
| [`typedef-whitespace`] || [`@typescript-eslint/type-annotation-spacing`] |
3636
| [`unified-signatures`] | 🛑 | N/A |
@@ -59,7 +59,7 @@
5959
| [`no-empty`] | 🌟 | [`no-empty`][no-empty] |
6060
| [`no-eval`] | 🌟 | [`no-eval`][no-eval] |
6161
| [`no-floating-promises`] | 🛑 | N/A ([relevant plugin][plugin:promise]) |
62-
| [`no-for-in-array`] | 🛑 | N/A |
62+
| [`no-for-in-array`] | | [`@typescript-eslint/no-for-in-array`] |
6363
| [`no-implicit-dependencies`] | 🔌 | [`import/no-extraneous-dependencies`] |
6464
| [`no-inferred-empty-object-type`] | 🛑 | N/A |
6565
| [`no-invalid-template-strings`] | 🌟 | [`no-template-curly-in-string`][no-template-curly-in-string] |
@@ -114,7 +114,7 @@
114114
| [`no-default-export`] | 🔌 | [`import/no-default-export`] |
115115
| [`no-duplicate-imports`] | 🔌 | [`import/no-duplicates`] |
116116
| [`no-mergeable-namespace`] | 🛑 | N/A |
117-
| [`no-require-imports`] | 🛑 | N/A |
117+
| [`no-require-imports`] | | [`@typescript-eslint/no-require-imports`] |
118118
| [`object-literal-sort-keys`] | 🌓 | [`sort-keys`][sort-keys] <sup>[2]</sup> |
119119
| [`prefer-const`] | 🌟 | [`prefer-const`][prefer-const] |
120120
| [`prefer-readonly`] | 🛑 | N/A |
@@ -578,6 +578,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
578578
[`@typescript-eslint/no-use-before-define`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
579579
[`@typescript-eslint/restrict-plus-operands`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-plus-operands.md
580580
[`@typescript-eslint/indent`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
581+
[`@typescript-eslint/no-require-imports`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-require-imports.md
581582
[`@typescript-eslint/array-type`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md
582583
[`@typescript-eslint/class-name-casing`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/class-name-casing.md
583584
[`@typescript-eslint/interface-name-prefix`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/interface-name-prefix.md
@@ -586,6 +587,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
586587
[`@typescript-eslint/member-delimiter-style`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md
587588
[`@typescript-eslint/prefer-interface`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-interface.md
588589
[`@typescript-eslint/no-array-constructor`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
590+
[`@typescript-eslint/no-for-in-array`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-for-in-array.md
589591

590592
<!-- eslint-plugin-import -->
591593

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Disallow iterating over an array with a for-in loop (no-for-in-array)
2+
3+
This rule prohibits iterating over an array with a for-in loop.
4+
5+
## Rule Details
6+
7+
Rationale from TSLint:
8+
9+
A for-in loop (`for (var k in o)`) iterates over the properties of an Object.
10+
While it is legal to use for-in loops with array types, it is not common.
11+
for-in will iterate over the indices of the array as strings, omitting any "holes" in
12+
the array.
13+
More common is to use for-of, which iterates over the values of an array.
14+
If you want to iterate over the indices, alternatives include:
15+
16+
```js
17+
array.forEach((value, index) => { ... });
18+
for (const [index, value] of array.entries()) { ... }
19+
for (let i = 0; i < array.length; i++) { ... }
20+
```
21+
22+
Examples of **incorrect** code for this rule:
23+
24+
```js
25+
for (const x in [3, 4, 5]) {
26+
console.log(x);
27+
}
28+
```
29+
30+
Examples of **correct** code for this rule:
31+
32+
```js
33+
for (const x in { a: 3, b: 4, c: 5 }) {
34+
console.log(x);
35+
}
36+
```
37+
38+
## When Not To Use It
39+
40+
If you want to iterate through a loop using the indices in an array as strings, you can turn off this rule.
41+
42+
## Related to
43+
44+
- TSLint: ['no-for-in-array'](https://palantir.github.io/tslint/rules/no-for-in-array/)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Disallows invocation of `require()` (no-require-imports)
2+
3+
Prefer the newer ES6-style imports over `require()`.
4+
5+
## Rule Details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
var lib = require('lib');
11+
let lib2 = require('lib2');
12+
var lib5 = require('lib5'),
13+
lib6 = require('lib6');
14+
import lib8 = require('lib8');
15+
```
16+
17+
Examples of **correct** code for this rule:
18+
19+
```ts
20+
import { l } from 'lib';
21+
var lib3 = load('not_an_import');
22+
var lib4 = lib2.subImport;
23+
var lib7 = 700;
24+
import lib9 = lib2.anotherSubImport;
25+
import lib10 from 'lib10';
26+
```
27+
28+
## When Not To Use It
29+
30+
If you don't care about TypeScript module syntax, then you will not need this rule.
31+
32+
## Compatibility
33+
34+
- TSLint: [no-require-imports](https://palantir.github.io/tslint/rules/no-require-imports/)

0 commit comments

Comments
 (0)