Skip to content

Commit

Permalink
Merge branch 'master' into typescript-eslint-await-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg committed Feb 5, 2019
2 parents 5316313 + c1abae9 commit b93f223
Show file tree
Hide file tree
Showing 26 changed files with 8,176 additions and 3,091 deletions.
8 changes: 5 additions & 3 deletions README.md
Expand Up @@ -42,11 +42,13 @@ The `canary` (latest master) version is:

## Supported TypeScript Version

We will always endeavor to support the latest stable version of TypeScript.
We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript.

The version of TypeScript currently supported by this parser is `~3.2.1`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.4.0`.**

If you use a non-supported version of TypeScript, the parser will log a warning to the console.
This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.

If you use a non-supported version of TypeScript, the parser will log a warning to the console. If you want to disable this warning, you can configure this in your `parserOptions`. See: [`@typescript-eslint/parser`](./packages/parser/) and [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/).

**Please ensure that you are using a supported version before submitting any issues/bug reports.**

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -69,6 +69,6 @@
"rimraf": "^2.6.3",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"typescript": "~3.2.1"
"typescript": ">=3.2.1 <3.4.0"
}
}
16 changes: 16 additions & 0 deletions packages/eslint-plugin/README.md
Expand Up @@ -84,6 +84,22 @@ Install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-pre

**Note: Make sure you have `eslint-config-prettier@4.0.0` or newer.**

## Usage with Airbnb

Airbnb has two configs, a base one [`eslint-config-airbnb-base`](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base) and one that includes rules for React [`eslint-config-airbnb`](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb).

First you'll need to install the config according to the instructions in one of the links above. `npx install-peerdeps --dev eslint-config-airbnb` or `npx install-peerdeps --dev eslint-config-airbnb-base` should work if you are using **npm 5+**.

Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.eslintrc`. You might also want to turn on `plugin:@typescript-eslint/recommended` as well to enable all of the recommended rules.

```json
{
"extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"]
}
```

**Note: You can use Airbnb's rules alongside Prettier, see [Usage with Prettier](#usage-with-prettier)**

## Supported Rules

<!-- Please run `npm run docs` to update this section -->
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Expand Up @@ -34,6 +34,6 @@
},
"peerDependencies": {
"eslint": "^5.0.0",
"typescript": "~3.2.1"
"typescript": "*"
}
}
2 changes: 2 additions & 0 deletions packages/parser/README.md
Expand Up @@ -54,6 +54,8 @@ The following additional configuration options are available by specifying them

- **`extraFileExtensions`** - default `undefined`. This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation. E.g. a `.vue` file

- **`warnOnUnsupportedTypeScriptVersion`** - default `true`. This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported

### .eslintrc.json

```json
Expand Down
1 change: 1 addition & 0 deletions packages/parser/src/parser-options.ts
Expand Up @@ -17,4 +17,5 @@ export interface ParserOptions {
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
tsconfigRootDir?: string;
extraFileExtensions?: string[];
warnOnUnsupportedTypeScriptVersion?: boolean;
}
12 changes: 12 additions & 0 deletions packages/parser/src/parser.ts
Expand Up @@ -75,6 +75,18 @@ export function parseForESLint(
}
}

/**
* Allow the user to suppress the warning from typescript-estree if they are using an unsupported
* version of TypeScript
*/
const warnOnUnsupportedTypeScriptVersion = validateBoolean(
options.warnOnUnsupportedTypeScriptVersion,
true
);
if (!warnOnUnsupportedTypeScriptVersion) {
parserOptions.loggerFn = false;
}

const { ast, services } = parseAndGenerateServices(code, parserOptions);
ast.sourceType = options.sourceType;

Expand Down
50 changes: 22 additions & 28 deletions packages/parser/tests/lib/__snapshots__/jsx.ts.snap
Expand Up @@ -9526,7 +9526,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 41,
Expand All @@ -9548,11 +9547,12 @@ Object {
"line": 2,
},
},
"name": "this",
"range": Array [
45,
49,
],
"type": "ThisExpression",
"type": "JSXIdentifier",
},
"property": Object {
"loc": Object {
Expand All @@ -9570,13 +9570,13 @@ Object {
50,
55,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
45,
55,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand Down Expand Up @@ -9677,7 +9677,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 13,
Expand All @@ -9699,11 +9698,12 @@ Object {
"line": 2,
},
},
"name": "this",
"range": Array [
17,
21,
],
"type": "ThisExpression",
"type": "JSXIdentifier",
},
"property": Object {
"loc": Object {
Expand All @@ -9721,13 +9721,13 @@ Object {
22,
27,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
17,
27,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand Down Expand Up @@ -9846,7 +9846,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 9,
Expand All @@ -9858,7 +9857,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 7,
Expand All @@ -9870,7 +9868,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 5,
Expand All @@ -9897,7 +9894,7 @@ Object {
74,
75,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"property": Object {
"loc": Object {
Expand All @@ -9915,13 +9912,13 @@ Object {
76,
77,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
74,
77,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand All @@ -9939,13 +9936,13 @@ Object {
78,
79,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
74,
79,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand All @@ -9963,13 +9960,13 @@ Object {
80,
81,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
74,
81,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand Down Expand Up @@ -10070,7 +10067,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 8,
Expand All @@ -10082,7 +10078,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 6,
Expand All @@ -10094,7 +10089,6 @@ Object {
},
},
"object": Object {
"computed": false,
"loc": Object {
"end": Object {
"column": 4,
Expand All @@ -10121,7 +10115,7 @@ Object {
1,
2,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"property": Object {
"loc": Object {
Expand All @@ -10139,13 +10133,13 @@ Object {
3,
4,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
1,
4,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand All @@ -10163,13 +10157,13 @@ Object {
5,
6,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
1,
6,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand All @@ -10187,13 +10181,13 @@ Object {
7,
8,
],
"type": "Identifier",
"type": "JSXIdentifier",
},
"range": Array [
1,
8,
],
"type": "MemberExpression",
"type": "JSXMemberExpression",
},
"property": Object {
"loc": Object {
Expand Down

0 comments on commit b93f223

Please sign in to comment.