From dbd27c585d324fc1e875c4b5cf6209c39080d347 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 19 Jan 2019 19:26:10 -0500 Subject: [PATCH 01/14] build: remove deploy job for now --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10d7a2a909e6..6c53fba944cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,3 @@ after_success: branches: only: - master -deploy: - on: - branch: master - provider: script - script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN && npx lerna publish --canary --force-publish --yes - skip_cleanup: true From cbb7ffefc18da6647edb0322bd6f0058580b6944 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:19:52 +0100 Subject: [PATCH 02/14] test(plugin-tslint): update tslint tests (#83) --- .../eslint-plugin-tslint/tests/index.spec.ts | 39 +++++++------------ .../tests/ast-alignment/fixtures-to-test.ts | 5 +-- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/packages/eslint-plugin-tslint/tests/index.spec.ts b/packages/eslint-plugin-tslint/tests/index.spec.ts index 1b78c3943f85..8232a16ec21c 100644 --- a/packages/eslint-plugin-tslint/tests/index.spec.ts +++ b/packages/eslint-plugin-tslint/tests/index.spec.ts @@ -2,18 +2,19 @@ import { rules } from '../src/index'; import { RuleTester } from 'eslint'; import { readFileSync } from 'fs'; -const ruleTester = new RuleTester(); - -const parserOptions: any = { - ecmaVersion: 6, - sourceType: 'module', - ecmaFeatures: {}, - /** - * Project is needed to generate the parserServices - * within @typescript-eslint/parser - */ - project: './tests/tsconfig.json' -}; +const ruleTester = new RuleTester({ + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + ecmaFeatures: {}, + /** + * Project is needed to generate the parserServices + * within @typescript-eslint/parser + */ + project: './tests/tsconfig.json' + }, + parser: '@typescript-eslint/parser' +}); /** * Inline rules should be supported @@ -40,8 +41,6 @@ ruleTester.run('tslint/config', rules.config, { valid: [ { code: 'var foo = true;', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesConfig] }, { @@ -50,9 +49,7 @@ ruleTester.run('tslint/config', rules.config, { /\n/g, ' ' ), - parser: '@typescript-eslint/parser', parserOptions: { - ...parserOptions, project: `${__dirname}/test-project/tsconfig.json` }, options: [ @@ -63,8 +60,6 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'throw "should be ok because rule is not loaded";', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesConfig] } ], @@ -72,8 +67,6 @@ ruleTester.run('tslint/config', rules.config, { invalid: [ { options: [{ lintFile: './tests/test-project/tslint.json' }], - parser: '@typescript-eslint/parser', - parserOptions, code: 'throw "err" // no-string-throw', errors: [ { @@ -84,8 +77,6 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'var foo = true // semicolon', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesConfig], output: 'var foo = true // semicolon', errors: [ @@ -98,8 +89,6 @@ ruleTester.run('tslint/config', rules.config, { }, { code: 'var foo = true // fail', - parser: '@typescript-eslint/parser', - parserOptions, options: [tslintRulesDirectoryConfig], output: 'var foo = true // fail', errors: [ @@ -116,9 +105,7 @@ ruleTester.run('tslint/config', rules.config, { /\n/g, ' ' ), - parser: '@typescript-eslint/parser', parserOptions: { - ...parserOptions, project: `${__dirname}/test-project/tsconfig.json` }, options: [ diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index 22bddf6b7baf..178b86573537 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -352,9 +352,8 @@ tester.addFixturePatternConfig('typescript/basics', { */ 'interface-with-extends-member-expression', /** - * Babel bug for parsing exported abstract interface - * https://github.com/babel/babel/issues/9304 - * PR: https://github.com/babel/babel/pull/9336 + * PR for parsing exported abstract interface has been merged into Babel: https://github.com/babel/babel/pull/9336 + * TODO: remove me in next babel > 7.2.3 */ 'abstract-interface', /** From 590064966a13d6de719ce29bece1d2cf1a6fc2f5 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Sun, 20 Jan 2019 09:28:14 -0500 Subject: [PATCH 03/14] chore: update .codecov.yml comment config (#84) --- .codecov.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index 119f1a50499c..750d876773d3 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -7,3 +7,7 @@ coverage: default: target: auto threshold: 2% +comment: + layout: diff, flags, files + require_changes: true + From c13b21a74d4fc68ae9c5577bdb07eff5a27b4809 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:28:42 +0100 Subject: [PATCH 04/14] docs: align readme across packages (#86) --- README.md | 4 +- packages/eslint-plugin-tslint/README.md | 48 ++++++---- packages/eslint-plugin/README.md | 90 +++++++++--------- .../eslint-plugin/docs/rules/ban-types.md | 4 +- .../eslint-plugin/docs/rules/camelcase.md | 18 ++-- packages/eslint-plugin/docs/rules/indent.md | 92 +++++++++---------- .../docs/rules/no-misused-new.md | 2 +- .../rules/no-object-literal-type-assertion.md | 2 +- .../eslint-plugin/docs/rules/no-this-alias.md | 2 +- .../docs/rules/no-unused-vars.md | 14 ++- packages/parser/README.md | 14 ++- packages/typescript-estree/README.md | 87 +++++++++--------- 12 files changed, 200 insertions(+), 177 deletions(-) diff --git a/README.md b/README.md index 47493a417b0e..2d6dda93ecb3 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@

Travis GitHub license - NPM Version - NPM Downloads + NPM Downloads + Codecov Commitizen friendly

diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 09cc6e4c0b71..8ecccbd1001a 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -1,41 +1,49 @@ -# ESLint Plugin TSLint +

ESLint Plugin TSLint

-[![Travis](https://img.shields.io/travis/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://travis-ci.org/@typescript-eslint/eslint-plugin-tslint) -[![GitHub license](https://img.shields.io/npm/l/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://github.com/@typescript-eslint/eslint-plugin-tslint/blob/master/LICENSE) -[![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint) -[![NPM Downloads](https://img.shields.io/npm/dt/@typescript-eslint/eslint-plugin-tslint.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin-tslint) -[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) +

ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint.

-ESLint plugin wraps a TSLint configuration and lints the whole source using TSLint. +

+ Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly +

-## INSTALL +## Installation -``` -npm i -D @typescript-eslint/eslint-plugin-tslint +```sh +npm i @typescript-eslint/eslint-plugin-tslint --save-dev ``` -## USAGE +## Usage Configure in your eslint config file: -``` -"plugins": [ +```js +{ + "plugins": [ "tslint" -], -"rules": { + ], + "rules": { "tslint/config": ["warn", { - lintFile: '/* path to tslint.json of your project */', - rules: { /* tslint rules (will be used if `lintFile` is not specified) */ }, - rulesDirectory: [ /* array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified) */ ] + "lintFile": '', // path to tslint.json of your project + "rules": { + // tslint rules (will be used if `lintFile` is not specified) + }, + "rulesDirectory": [ + // array of paths to directories with rules, e.g. 'node_modules/tslint/lib/rules' (will be used if `lintFile` is not specified) + ] }], + } } ``` -## RULES +## Rules Plugin contains only single rule `tslint/config`. -## EXAMPLES +## Examples - [unlight/node-package-starter/.eslintrc.js](https://github.com/unlight/node-package-starter/blob/master/.eslintrc.js) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 82e116951b03..c9ee4a63bb0e 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -1,27 +1,31 @@ -# @typescript-eslint/eslint-plugin +

ESLint Plugin TypeScript

-[![NPM version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) -[![NPM downloads](https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) -[![TravisCI](https://img.shields.io/travis/@typescript-eslint/eslint-plugin.svg)](https://travis-ci.com/@typescript-eslint/eslint-plugin) +

+ Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly +

## Installation You'll first need to install [ESLint](http://eslint.org): -```shellsession -$ npm i eslint --save-dev +```sh +npm i eslint --save-dev ``` Next, install `typescript` if you haven’t already: -```shellsession -$ npm i typescript@~3.1.1 --save-dev +```sh +npm i typescript@~3.1.1 --save-dev ``` Last, install `@typescript-eslint/eslint-plugin`: -```shellsession -$ npm install @typescript-eslint/eslint-plugin --save-dev +```sh +npm i @typescript-eslint/eslint-plugin --save-dev ``` **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. @@ -70,38 +74,38 @@ You can also enable all the recommended rules at once. Add `plugin:typescript/re | Name | Description | :heavy_check_mark: | :wrench: | | ---- | ----------- | ------------------ | -------- | -| [`typescript/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | -| [`typescript/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | -| [`typescript/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | -| [`typescript/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | -| [`typescript/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | -| [`typescript/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | -| [`typescript/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | -| [`typescript/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | -| [`typescript/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: | -| [`typescript/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | -| [`typescript/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | -| [`typescript/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | -| [`typescript/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | -| [`typescript/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: | -| [`typescript/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | -| [`typescript/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: | | -| [`typescript/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: | | -| [`typescript/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: | | -| [`typescript/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | -| [`typescript/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | -| [`typescript/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | -| [`typescript/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | -| [`typescript/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: | | -| [`typescript/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: | -| [`typescript/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: | -| [`typescript/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | +| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | +| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | +| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: | +| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | +| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | +| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | +| [`@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: | | +| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | +| [`@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: | +| [`@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: | | +| [`@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: | | +| [`@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: | | +| [`@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: | | +| [`@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: | | +| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | +| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// ` comments (`no-reference` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | +| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | +| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | +| [`@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: | | +| [`@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: | +| [`@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: | +| [`@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: | diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index 64eaa018df9f..5ab5e6e96e76 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -32,7 +32,7 @@ class Foo extends Bar implements Baz { ```CJSON { - "typescript/ban-types": ["error", { + "@typescript-eslint/ban-types": ["error", { "types": { // report usages of the type using the default error message "Foo": null, @@ -54,7 +54,7 @@ class Foo extends Bar implements Baz { ```json { - "typescript/ban-types": [ + "@typescript-eslint/ban-types": [ "error", { "types": { diff --git a/packages/eslint-plugin/docs/rules/camelcase.md b/packages/eslint-plugin/docs/rules/camelcase.md index ab624c2f9931..203a3885ed43 100644 --- a/packages/eslint-plugin/docs/rules/camelcase.md +++ b/packages/eslint-plugin/docs/rules/camelcase.md @@ -24,7 +24,7 @@ variable that will be imported into the local module scope. { // note you must disable the base rule as it can report incorrect errors "camelcase": "off", - "typescript/camelcase": ["error", { "properties": "always" }] + "@typescript-eslint/camelcase": ["error", { "properties": "always" }] } ``` @@ -41,7 +41,7 @@ This rule has an object option: Examples of **incorrect** code for this rule with the default `{ "properties": "always" }` option: ```js -/*eslint typescript/camelcase: "error"*/ +/*eslint @typescript-eslint/camelcase: "error"*/ import { no_camelcased } from 'external-module'; @@ -81,7 +81,7 @@ var { foo: bar_baz = 1 } = quz; Examples of **correct** code for this rule with the default `{ "properties": "always" }` option: ```js -/*eslint typescript/camelcase: "error"*/ +/*eslint @typescript-eslint/camelcase: "error"*/ import { no_camelcased as camelCased } from 'external-module'; @@ -122,7 +122,7 @@ var { foo: isCamelCased = 1 } = quz; Examples of **correct** code for this rule with the `{ "properties": "never" }` option: ```js -/*eslint typescript/camelcase: ["error", {properties: "never"}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {properties: "never"}]*/ var obj = { my_pref: 1 @@ -134,7 +134,7 @@ var obj = { Examples of **incorrect** code for this rule with the default `{ "ignoreDestructuring": false }` option: ```js -/*eslint typescript/camelcase: "error"*/ +/*eslint @typescript-eslint/camelcase: "error"*/ var { category_id } = query; @@ -152,7 +152,7 @@ var { category_id: categoryId, ...other_props } = query; Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring": true }` option: ```js -/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/ var { category_id: category_alias } = query; @@ -162,7 +162,7 @@ var { category_id, ...other_props } = query; Examples of **correct** code for this rule with the `{ "ignoreDestructuring": true }` option: ```js -/*eslint typescript/camelcase: ["error", {ignoreDestructuring: true}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {ignoreDestructuring: true}]*/ var { category_id } = query; @@ -176,7 +176,7 @@ var { category_id: category_id } = query; Examples of **correct** code for this rule with the `allow` option: ```js -/*eslint typescript/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {allow: ["UNSAFE_componentWillMount"]}]*/ function UNSAFE_componentWillMount() { // ... @@ -184,7 +184,7 @@ function UNSAFE_componentWillMount() { ``` ```js -/*eslint typescript/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/ +/*eslint @typescript-eslint/camelcase: ["error", {allow: ["^UNSAFE_"]}]*/ function UNSAFE_componentWillMount() { // ... diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 1ef6595a8ad8..5678ba291da2 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -30,7 +30,7 @@ For example, for 2-space indentation: { // note you must disable the base rule as it can report incorrect errors "indent": "off", - "typescript/indent": ["error", 2] + "@typescript-eslint/indent": ["error", 2] } ``` @@ -40,7 +40,7 @@ Or for tabbed indentation: { // note you must disable the base rule as it can report incorrect errors "indent": "off", - "typescript/indent": ["error", "tab"] + "@typescript-eslint/indent": ["error", "tab"] } ``` @@ -48,7 +48,7 @@ Examples of **incorrect** code for this rule with the default options: ```js -/*eslint typescript/indent: "error"*/ +/*eslint @typescript-eslint/indent: "error"*/ if (a) { b=c; @@ -62,7 +62,7 @@ Examples of **correct** code for this rule with the default options: ```js -/*eslint typescript/indent: "error"*/ +/*eslint @typescript-eslint/indent: "error"*/ if (a) { b=c; @@ -116,7 +116,7 @@ Examples of **incorrect** code for this rule with the `"tab"` option: ```js -/*eslint typescript/indent: ["error", "tab"]*/ +/*eslint @typescript-eslint/indent: ["error", "tab"]*/ if (a) { b=c; @@ -130,7 +130,7 @@ Examples of **correct** code for this rule with the `"tab"` option: ```js -/*eslint typescript/indent: ["error", "tab"]*/ +/*eslint @typescript-eslint/indent: ["error", "tab"]*/ if (a) { /*tab*/b=c; @@ -146,7 +146,7 @@ Examples of **incorrect** code for this rule with the `2, { "SwitchCase": 1 }` o ```js -/*eslint typescript/indent: ["error", 2, { "SwitchCase": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "SwitchCase": 1 }]*/ switch(a){ case "a": @@ -160,7 +160,7 @@ Examples of **correct** code for this rule with the `2, { "SwitchCase": 1 }` opt ```js -/*eslint typescript/indent: ["error", 2, { "SwitchCase": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "SwitchCase": 1 }]*/ switch(a){ case "a": @@ -176,7 +176,7 @@ Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator" ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ /*eslint-env es6*/ var a, @@ -194,7 +194,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 1 }]*/ /*eslint-env es6*/ var a, @@ -212,7 +212,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": 2 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": 2 }]*/ /*eslint-env es6*/ var a, @@ -230,7 +230,7 @@ Examples of **correct** code for this rule with the `2, { "VariableDeclarator": ```js -/*eslint typescript/indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/ /*eslint-env es6*/ var a, @@ -250,7 +250,7 @@ Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBo ```js -/*eslint typescript/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ (function() { @@ -270,7 +270,7 @@ Examples of **correct** code for this rule with the options `2, {"outerIIFEBody" ```js -/*eslint typescript/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "outerIIFEBody": 0 }]*/ (function() { @@ -292,7 +292,7 @@ Examples of **incorrect** code for this rule with the `2, { "MemberExpression": ```js -/*eslint typescript/indent: ["error", 2, { "MemberExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "MemberExpression": 1 }]*/ foo .bar @@ -303,7 +303,7 @@ Examples of **correct** code for this rule with the `2, { "MemberExpression": 1 ```js -/*eslint typescript/indent: ["error", 2, { "MemberExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "MemberExpression": 1 }]*/ foo .bar @@ -316,7 +316,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration ```js -/*eslint typescript/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ function foo(bar, baz, @@ -329,7 +329,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration": ```js -/*eslint typescript/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/ function foo(bar, baz, @@ -342,7 +342,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration ```js -/*eslint typescript/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ function foo(bar, baz, qux, boop) { @@ -354,7 +354,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionDeclaration": ```js -/*eslint typescript/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/ function foo(bar, baz, qux, boop) { @@ -368,7 +368,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression" ```js -/*eslint typescript/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ var foo = function(bar, baz, @@ -381,7 +381,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression": ```js -/*eslint typescript/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/ var foo = function(bar, baz, @@ -394,7 +394,7 @@ Examples of **incorrect** code for this rule with the `2, { "FunctionExpression" ```js -/*eslint typescript/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ var foo = function(bar, baz, qux, boop) { @@ -406,7 +406,7 @@ Examples of **correct** code for this rule with the `2, { "FunctionExpression": ```js -/*eslint typescript/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/ var foo = function(bar, baz, qux, boop) { @@ -420,7 +420,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {" ```js -/*eslint typescript/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ foo(bar, baz, @@ -432,7 +432,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar ```js -/*eslint typescript/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/ foo(bar, baz, @@ -444,7 +444,7 @@ Examples of **incorrect** code for this rule with the `2, { "CallExpression": {" ```js -/*eslint typescript/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ foo(bar, baz, baz, boop, beep); @@ -454,7 +454,7 @@ Examples of **correct** code for this rule with the `2, { "CallExpression": {"ar ```js -/*eslint typescript/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/ foo(bar, baz, baz, boop, beep); @@ -466,7 +466,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": 1 ```js -/*eslint typescript/indent: ["error", 2, { "ArrayExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ArrayExpression": 1 }]*/ var foo = [ bar, @@ -479,7 +479,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": 1 } ```js -/*eslint typescript/indent: ["error", 2, { "ArrayExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ArrayExpression": 1 }]*/ var foo = [ bar, @@ -492,7 +492,7 @@ Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": " ```js -/*eslint typescript/indent: ["error", 2, {"ArrayExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ArrayExpression": "first"}]*/ var foo = [bar, baz, @@ -504,7 +504,7 @@ Examples of **correct** code for this rule with the `2, { "ArrayExpression": "fi ```js -/*eslint typescript/indent: ["error", 2, {"ArrayExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ArrayExpression": "first"}]*/ var foo = [bar, baz, @@ -518,7 +518,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": ```js -/*eslint typescript/indent: ["error", 2, { "ObjectExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ObjectExpression": 1 }]*/ var foo = { bar: 1, @@ -531,7 +531,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": 1 ```js -/*eslint typescript/indent: ["error", 2, { "ObjectExpression": 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 2, { "ObjectExpression": 1 }]*/ var foo = { bar: 1, @@ -544,7 +544,7 @@ Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": ```js -/*eslint typescript/indent: ["error", 2, {"ObjectExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ObjectExpression": "first"}]*/ var foo = { bar: 1, baz: 2 }; @@ -554,7 +554,7 @@ Examples of **correct** code for this rule with the `2, { "ObjectExpression": "f ```js -/*eslint typescript/indent: ["error", 2, {"ObjectExpression": "first"}]*/ +/*eslint @typescript-eslint/indent: ["error", 2, {"ObjectExpression": "first"}]*/ var foo = { bar: 1, baz: 2 }; @@ -566,7 +566,7 @@ Examples of **correct** code for this rule with the `4, { "ImportDeclaration": 1 ```js -/*eslint typescript/indent: ["error", 4, { ImportDeclaration: 1 }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: 1 }]*/ import { foo, bar, @@ -584,7 +584,7 @@ Examples of **incorrect** code for this rule with the `4, { ImportDeclaration: " ```js -/*eslint typescript/indent: ["error", 4, { ImportDeclaration: "first" }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: "first" }]*/ import { foo, bar, @@ -596,7 +596,7 @@ Examples of **correct** code for this rule with the `4, { ImportDeclaration: "fi ```js -/*eslint typescript/indent: ["error", 4, { ImportDeclaration: "first" }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { ImportDeclaration: "first" }]*/ import { foo, bar, @@ -610,7 +610,7 @@ Examples of **incorrect** code for this rule with the default `4, { "flatTernary ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ var a = foo ? bar : @@ -622,7 +622,7 @@ Examples of **correct** code for this rule with the default `4, { "flatTernaryEx ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": false }]*/ var a = foo ? bar : @@ -634,7 +634,7 @@ Examples of **incorrect** code for this rule with the `4, { "flatTernaryExpressi ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ var a = foo ? bar : @@ -646,7 +646,7 @@ Examples of **correct** code for this rule with the `4, { "flatTernaryExpression ```js -/*eslint typescript/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "flatTernaryExpressions": true }]*/ var a = foo ? bar : @@ -662,7 +662,7 @@ Examples of **correct** code for this rule with the `4, { "ignoredNodes": ["Cond ```js -/*eslint typescript/indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }]*/ var a = foo ? bar @@ -679,7 +679,7 @@ Examples of **correct** code for this rule with the `4, { "ignoredNodes": ["Call ```js -/*eslint typescript/indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/ +/*eslint @typescript-eslint/indent: ["error", 4, { "ignoredNodes": ["CallExpression > FunctionExpression.callee > BlockStatement.body"] }]*/ (function() { @@ -695,7 +695,7 @@ Examples of additional **correct** code for this rule with the `4, { "ignoreComm ```js -/*eslint typescript/indent: ["error", 4, { "ignoreComments": true }] */ +/*eslint @typescript-eslint/indent: ["error", 4, { "ignoreComments": true }] */ if (foo) { doSomething(); diff --git a/packages/eslint-plugin/docs/rules/no-misused-new.md b/packages/eslint-plugin/docs/rules/no-misused-new.md index ea588fd5ec29..df1aec7ad605 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-new.md +++ b/packages/eslint-plugin/docs/rules/no-misused-new.md @@ -32,7 +32,7 @@ interface I { ```json { - "typescript/no-misused-new": "error" + "@typescript-eslint/no-misused-new": "error" } ``` diff --git a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md index c833fe9fbbbd..fe25f8f64107 100644 --- a/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md +++ b/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md @@ -22,7 +22,7 @@ const z = { ... } as unknown; ```json { - "typescript/no-object-literal-type-assertion": "error" + "@typescript-eslint/no-object-literal-type-assertion": "error" } ``` diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index ea747805e0ee..b40c165b3db7 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -41,7 +41,7 @@ You can pass an object option: ```json5 { - 'typescript/no-this-alias': [ + '@typescript-eslint/no-this-alias': [ 'error', { allowDestructuring: true, // Allow `const { props, state } = this`; false by default diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index 58dcc78f1ee0..63f148f7a3f4 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -110,11 +110,15 @@ By default this rule is enabled with `all` option for variables and `after-used` ```CJSON { - "rules": { - // note you must disable the base rule as it can report incorrect errors - "no-unused-vars": "off", - "typescript/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }] - } + "rules": { + // note you must disable the base rule as it can report incorrect errors + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": ["error", { + "vars": "all", + "args": "after-used", + "ignoreRestSiblings": false + }] + } } ``` diff --git a/packages/parser/README.md b/packages/parser/README.md index 253ed00e4686..bcf4d941c7f4 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -1,11 +1,19 @@ -# TypeScript ESLint Parser +

TypeScript ESLint Parser

-An ESLint custom parser which leverages [TypeScript ESTree](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/typescript-estree) to allow for ESLint to lint TypeScript source code. +

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.

+ +

+ Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly +

## Installation: ```sh -npm install --save-dev @typescript-eslint/parser +npm install @typescript-eslint/parser --save-dev ``` ## Usage diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index 110521f37616..910002f4fae0 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -3,12 +3,11 @@

A parser that converts TypeScript source code into an ESTree-compatible form

- Travis - GitHub license - NPM Version - NPM Downloads - Commitizen friendly - semantic-release + Travis + GitHub license + NPM Version + NPM Downloads + Commitizen friendly


@@ -24,8 +23,8 @@ In fact, it is already used within these hyper-popular open-source projects to p ## Installation -``` -npm install --save @typescript-eslint/typescript-estree +```sh +npm install @typescript-eslint/typescript-estree --save-dev ``` ## API @@ -34,46 +33,46 @@ npm install --save @typescript-eslint/typescript-estree Parses the given string of code with the options provided and returns an ESTree-compatible AST. The options object has the following properties: -```javascript +```js { - // attach range information to each node - range: false, - - // attach line/column location information to each node - loc: false, - - // create a top-level tokens array containing all tokens - tokens: false, - - // create a top-level comments array containing all comments - comment: false, - - // enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html - jsx: false, - - /* - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. - * When value is `true`, these nodes will be parsed as type `JSXText`. - * When value is `false`, these nodes will be parsed as type `Literal`. - */ - useJSXTextNode: false, - - // Cause the parser to error if it encounters an unknown AST node type (useful for testing) - errorOnUnknownASTType: false, - - /* - * Allows overriding of function used for logging. - * When value is `false`, no logging will occur. - * When value is not provided, `console.log()` will be used. - */ - loggerFn: undefined + // attach range information to each node + range: false, + + // attach line/column location information to each node + loc: false, + + // create a top-level tokens array containing all tokens + tokens: false, + + // create a top-level comments array containing all comments + comment: false, + + // enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html + jsx: false, + + /* + * The JSX AST changed the node type for string literals + * inside a JSX Element from `Literal` to `JSXText`. + * When value is `true`, these nodes will be parsed as type `JSXText`. + * When value is `false`, these nodes will be parsed as type `Literal`. + */ + useJSXTextNode: false, + + // Cause the parser to error if it encounters an unknown AST node type (useful for testing) + errorOnUnknownASTType: false, + + /* + * Allows overriding of function used for logging. + * When value is `false`, no logging will occur. + * When value is not provided, `console.log()` will be used. + */ + loggerFn: undefined } ``` Example usage: -```javascript +```js const parser = require('@typescript-eslint/typescript-estree'); const code = `const hello: string = 'world';`; const ast = parser.parse(code, { @@ -88,7 +87,7 @@ Exposes the current version of typescript-estree as specified in package.json. Example usage: -```javascript +```js const parser = require('@typescript-eslint/typescript-estree'); const version = parser.version; ``` @@ -99,7 +98,7 @@ Exposes an object that contains the AST node types produced by the parser. Example usage: -```javascript +```js const parser = require('@typescript-eslint/typescript-estree'); const astNodeTypes = parser.AST_NODE_TYPES; ``` From c5aabf7515fe80a8a1de208b7dbf75f18e87432e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sun, 20 Jan 2019 15:28:58 +0100 Subject: [PATCH 05/14] docs(plugin-typescript): fix readme instructions (#91) --- packages/eslint-plugin/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index c9ee4a63bb0e..6f649ef0ada6 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -37,7 +37,7 @@ Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescr ```json { "parser": "@typescript-eslint/eslint-plugin/parser", - "plugins": ["typescript"] + "plugins": ["@typescript-eslint"] } ``` @@ -49,9 +49,9 @@ Then configure the rules you want to use under the rules section. ```json { "parser": "@typescript-eslint/eslint-plugin/parser", - "plugins": ["typescript"], + "plugins": ["@typescript-eslint"], "rules": { - "typescript/rule-name": "error" + "@typescript-eslint/rule-name": "error" } } ``` @@ -60,7 +60,7 @@ You can also enable all the recommended rules at once. Add `plugin:typescript/re ```json { - "extends": ["plugin:typescript/recommended"] + "extends": ["plugin:@typescript-eslint/recommended"] } ``` From b321736a837c6c335a2bef91f7cda5d0d972826e Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:29:32 +0100 Subject: [PATCH 06/14] feat(parser): support ecmaFeatures.jsx flag and tests (#85) --- packages/parser/README.md | 6 ++- packages/parser/src/parser-options.ts | 23 ++++---- packages/parser/src/parser.ts | 69 +++++++++++++++--------- packages/parser/tests/lib/comments.ts | 6 ++- packages/parser/tests/lib/jsx.ts | 4 +- packages/parser/tests/lib/parser.ts | 54 +++++++++++++++++++ packages/parser/tests/lib/tsx.ts | 16 ++++-- packages/typescript-estree/src/parser.ts | 8 +-- 8 files changed, 138 insertions(+), 48 deletions(-) diff --git a/packages/parser/README.md b/packages/parser/README.md index bcf4d941c7f4..3a18f79735e6 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -40,7 +40,7 @@ By far the most common case will be installing the [@typescript-eslint/eslint-pl The following additional configuration options are available by specifying them in [`parserOptions`](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) in your ESLint configuration file. -- **`jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html). +- **`ecmaFeatures.jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html). - It's `false` on `*.ts` files regardless of this option. - It's `true` on `*.tsx` files regardless of this option. @@ -54,7 +54,9 @@ The following additional configuration options are available by specifying them { "parser": "@typescript-eslint/parser", "parserOptions": { - "jsx": true, + "ecmaFeatures": { + "jsx": true + }, "useJSXTextNode": true } } diff --git a/packages/parser/src/parser-options.ts b/packages/parser/src/parser-options.ts index 6bb6b160bca7..95d6e54c182c 100644 --- a/packages/parser/src/parser-options.ts +++ b/packages/parser/src/parser-options.ts @@ -1,17 +1,20 @@ export interface ParserOptions { - useJSXTextNode?: boolean; - loc?: true; - range?: true; - tokens?: true; - filePath?: string; + loc?: boolean; + comment?: boolean; + range?: boolean; + tokens?: boolean; sourceType?: 'script' | 'module'; ecmaVersion?: number; ecmaFeatures?: { globalReturn?: boolean; + jsx?: boolean; }; - /** - * @deprecated We should finalize the work from - * https://github.com/eslint/typescript-eslint-parser#595 - */ - jsx?: boolean; + // ts-estree specific + filePath?: string; + project?: string | string[]; + useJSXTextNode?: boolean; + errorOnUnknownASTType?: boolean; + errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; + tsconfigRootDir?: string; + extraFileExtensions?: string[]; } diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 49aabf26074a..2dd32b383625 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -1,5 +1,9 @@ import traverser from 'eslint/lib/util/traverser'; -import * as typescriptESTree from '@typescript-eslint/typescript-estree'; +import { + AST_NODE_TYPES, + parseAndGenerateServices, + ParserOptions as ParserOptionsTsESTree +} from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; import { visitorKeys } from './visitor-keys'; @@ -20,52 +24,67 @@ interface ParseForESLintResult { scopeManager: ReturnType; } +function validateBoolean( + value: boolean | undefined, + fallback: boolean = false +): boolean { + if (typeof value !== 'boolean') { + return fallback; + } + return value; +} + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + export const version = packageJSON.version; +export const Syntax = Object.freeze(AST_NODE_TYPES); + export function parse(code: string, options?: ParserOptions) { return parseForESLint(code, options).ast; } -export const Syntax = Object.freeze(typescriptESTree.AST_NODE_TYPES); - -export function parseForESLint( +export function parseForESLint( code: string, - options?: T | null + options?: ParserOptions | null ): ParseForESLintResult { - if (typeof options !== 'object' || options === null) { - options = { useJSXTextNode: true } as T; - } else if (typeof options.useJSXTextNode !== 'boolean') { - options = Object.assign({}, options, { useJSXTextNode: true }); - } - if (typeof options.filePath === 'string') { - const tsx = options.filePath.endsWith('.tsx'); - if (tsx || options.filePath.endsWith('.ts')) { - options = Object.assign({}, options, { jsx: tsx }); - } + if (!options || typeof options !== 'object') { + options = {}; } - // https://eslint.org/docs/user-guide/configuring#specifying-parser-options // if sourceType is not provided by default eslint expect that it will be set to "script" - options.sourceType = options.sourceType || 'script'; if (options.sourceType !== 'module' && options.sourceType !== 'script') { options.sourceType = 'script'; } + if (typeof options.ecmaFeatures !== 'object') { + options.ecmaFeatures = {}; + } + + const parserOptions: ParserOptionsTsESTree = {}; + Object.assign(parserOptions, options, { + useJSXTextNode: validateBoolean(options.useJSXTextNode, true), + jsx: validateBoolean(options.ecmaFeatures.jsx) + }); + + if (typeof options.filePath === 'string') { + const tsx = options.filePath.endsWith('.tsx'); + if (tsx || options.filePath.endsWith('.ts')) { + parserOptions.jsx = tsx; + } + } - const { ast, services } = typescriptESTree.parseAndGenerateServices( - code, - options - ); + const { ast, services } = parseAndGenerateServices(code, parserOptions); ast.sourceType = options.sourceType; traverser.traverse(ast, { - enter: (node: any) => { + enter(node: any) { switch (node.type) { // Function#body cannot be null in ESTree spec. case 'FunctionExpression': if (!node.body) { - node.type = `TSEmptyBody${ - node.type - }` as typescriptESTree.AST_NODE_TYPES; + node.type = `TSEmptyBody${node.type}` as AST_NODE_TYPES; } break; // no default diff --git a/packages/parser/tests/lib/comments.ts b/packages/parser/tests/lib/comments.ts index bdf3356f3a4b..f2bb2260d651 100644 --- a/packages/parser/tests/lib/comments.ts +++ b/packages/parser/tests/lib/comments.ts @@ -15,8 +15,10 @@ describe('Comments', () => { testFiles.forEach(filename => { const code = fs.readFileSync(filename, 'utf8'); const config: ParserOptions = { - jsx: true, - sourceType: 'module' + sourceType: 'module', + ecmaFeatures: { + jsx: true + } }; it( testUtils.formatSnapshotName(filename, FIXTURES_DIR), diff --git a/packages/parser/tests/lib/jsx.ts b/packages/parser/tests/lib/jsx.ts index 55bb4e5f742f..05adef987f6f 100644 --- a/packages/parser/tests/lib/jsx.ts +++ b/packages/parser/tests/lib/jsx.ts @@ -28,7 +28,9 @@ describe('JSX', () => { const code = fs.readFileSync(filename, 'utf8'); const config = { useJSXTextNode, - jsx: true + ecmaFeatures: { + jsx: true + } }; it( testUtils.formatSnapshotName(filename, fixturesDir), diff --git a/packages/parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts index f5b1f7a9ac4a..bfc23bac5abb 100644 --- a/packages/parser/tests/lib/parser.ts +++ b/packages/parser/tests/lib/parser.ts @@ -1,5 +1,6 @@ import * as typescriptESTree from '@typescript-eslint/typescript-estree'; import { parse, parseForESLint, Syntax } from '../../src/parser'; +import * as scope from '../../src/analyze-scope'; describe('parser', () => { it('parse() should return just the AST from parseForESLint()', () => { @@ -15,11 +16,64 @@ describe('parser', () => { it('parseForESLint() should set the sourceType to script, if an invalid one is provided', () => { const code = 'const valid = true;'; const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); + const spyScope = jest.spyOn(scope, 'analyzeScope'); parseForESLint(code, { sourceType: 'foo' as any }); expect(spy).toHaveBeenCalledWith(code, { + ecmaFeatures: {}, + jsx: false, sourceType: 'script', useJSXTextNode: true }); + expect(spyScope).toHaveBeenCalledWith(jasmine.any(Object), { + ecmaFeatures: {}, + sourceType: 'script' + }); + }); + + it('parseAndGenerateServices() should be called with options', () => { + const code = 'const valid = true;'; + const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); + parseForESLint(code, { + loc: false, + comment: false, + range: false, + tokens: false, + sourceType: 'module', + ecmaVersion: 10, + ecmaFeatures: { + globalReturn: false, + jsx: false + }, + // ts-estree specific + filePath: 'test/foo', + project: 'tsconfig.json', + useJSXTextNode: false, + errorOnUnknownASTType: false, + errorOnTypeScriptSyntacticAndSemanticIssues: false, + tsconfigRootDir: '../../', + extraFileExtensions: ['foo'] + }); + expect(spy).toHaveBeenCalledWith(code, { + jsx: false, + loc: false, + comment: false, + range: false, + tokens: false, + sourceType: 'module', + ecmaVersion: 10, + ecmaFeatures: { + globalReturn: false, + jsx: false + }, + // ts-estree specific + filePath: 'test/foo', + project: 'tsconfig.json', + useJSXTextNode: false, + errorOnUnknownASTType: false, + errorOnTypeScriptSyntacticAndSemanticIssues: false, + tsconfigRootDir: '../../', + extraFileExtensions: ['foo'] + }); }); it('Syntax should contain a frozen object of typescriptESTree.AST_NODE_TYPES', () => { diff --git a/packages/parser/tests/lib/tsx.ts b/packages/parser/tests/lib/tsx.ts index 0872edf307b0..a18278e80458 100644 --- a/packages/parser/tests/lib/tsx.ts +++ b/packages/parser/tests/lib/tsx.ts @@ -17,7 +17,9 @@ describe('TSX', () => { const code = fs.readFileSync(filename, 'utf8'); const config = { useJSXTextNode: true, - jsx: true + ecmaFeatures: { + jsx: true + } }; it( testUtils.formatSnapshotName(filename, FIXTURES_DIR, '.tsx'), @@ -53,7 +55,9 @@ describe('TSX', () => { const config = { parser: '@typescript-eslint/parser', parserOptions: { - jsx: true + ecmaFeatures: { + jsx: true + } } }; const messages = linter.verify(code, config); @@ -85,7 +89,9 @@ describe('TSX', () => { const config = { parser: '@typescript-eslint/parser', parserOptions: { - jsx: true + ecmaFeatures: { + jsx: true + } } }; const messages = linter.verify(code, config, { filename: 'test.ts' }); @@ -117,7 +123,9 @@ describe('TSX', () => { const config = { parser: '@typescript-eslint/parser', parserOptions: { - jsx: false + ecmaFeatures: { + jsx: false + } } }; const messages = linter.verify(code, config, { filename: 'test.tsx' }); diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 1a39cfd2f31f..2f6347e0a7a2 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -350,10 +350,7 @@ function generateAST( // Public //------------------------------------------------------------------------------ -export { AST_NODE_TYPES } from './ast-node-types'; -export { version }; - -const version = packageJSON.version; +export const version: string = packageJSON.version; export function parse( code: string, @@ -378,3 +375,6 @@ export function parseAndGenerateServices(code: string, options: ParserOptions) { } }; } + +export { AST_NODE_TYPES } from './ast-node-types'; +export { ParserOptions }; From 2df5e0c039d3a5c558c164f8b748c6e2da447436 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:29:46 +0100 Subject: [PATCH 07/14] fix(eslint-plugin): no-unused-vars: mark declared statements as used (#88) --- .../eslint-plugin/lib/rules/no-unused-vars.js | 3 +++ .../tests/lib/rules/no-unused-vars.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js index eef6ddb2310f..ecf62b154002 100644 --- a/packages/eslint-plugin/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js @@ -62,6 +62,9 @@ module.exports = Object.assign({}, baseRule, { }, 'TSEnumMember Identifier'(node) { context.markVariableAsUsed(node.name); + }, + '*[declare=true] Identifier'(node) { + context.markVariableAsUsed(node.name); } }); } diff --git a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js index 8e7a5a8a7892..25410bbf2701 100644 --- a/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/tests/lib/rules/no-unused-vars.js @@ -525,6 +525,22 @@ import * as fastify from 'fastify' import { Server, IncomingMessage, ServerResponse } from 'http' const server: fastify.FastifyInstance = fastify({}) server.get('/ping') + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/61 + `declare function foo();`, + // https://github.com/typescript-eslint/typescript-eslint/issues/61 + ` +declare namespace Foo { + function bar(line: string, index: number | null, tabSize: number): number; + var baz: string; +} + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/61 + ` +declare var Foo: { + new (value?: any): Object, + foo(): string +} ` ], From 3f51d51f93a0f3b415394ac3309d3becfdf5009c Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:30:11 +0100 Subject: [PATCH 08/14] fix(eslint-plugin): fix crash in rule indent for eslint 5.12.1 (#89) --- packages/eslint-plugin/lib/rules/indent.js | 3 ++- packages/eslint-plugin/lib/rules/no-unused-vars.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/lib/rules/indent.js b/packages/eslint-plugin/lib/rules/indent.js index a8024145a1c4..84144219faff 100644 --- a/packages/eslint-plugin/lib/rules/indent.js +++ b/packages/eslint-plugin/lib/rules/indent.js @@ -101,7 +101,8 @@ module.exports = Object.assign({}, baseRule, { url: util.metaDocsUrl('indent') }, fixable: 'whitespace', - schema: baseRule.meta.schema + schema: baseRule.meta.schema, + messages: baseRule.meta.messages }, create(context) { diff --git a/packages/eslint-plugin/lib/rules/no-unused-vars.js b/packages/eslint-plugin/lib/rules/no-unused-vars.js index ecf62b154002..d7f32f15a5c1 100644 --- a/packages/eslint-plugin/lib/rules/no-unused-vars.js +++ b/packages/eslint-plugin/lib/rules/no-unused-vars.js @@ -21,7 +21,8 @@ module.exports = Object.assign({}, baseRule, { url: util.metaDocsUrl('no-unused-vars'), recommended: 'warn' }, - schema: baseRule.meta.schema + schema: baseRule.meta.schema, + messages: baseRule.meta.messages }, create(context) { From 7d178a96887742808b1730c6017b2c4081571667 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 10:06:30 -0500 Subject: [PATCH 09/14] build: separate job for integration tests (#93) --- .travis.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c53fba944cd..c18b22b64cb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,22 +11,28 @@ notifications: node_js: - '11' - '10' - - '9' - '8' - '6' install: - - yarn --ignore-engines + # This also runs a build as part of the postinstall + # bootstrap + - yarn --ignore-engines --frozen-lockfile script: - - commitlint-travis - - yarn check-format # TODO: Fix this check # - yarn workspace eslint-plugin docs:check - - yarn build - yarn test - - yarn integration-tests - yarn global add codecov after_success: - codecov branches: only: - master + +jobs: + include: + - stage: Code and Commit Formatting and Integration Tests + node_js: "11" + script: + - commitlint-travis + - yarn check-format + - yarn integration-tests From 0ddb93c56b3dce1610b8c4d79d20b764d1665bb2 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 10:36:19 -0500 Subject: [PATCH 10/14] feat(eslint-plugin): remove exported parser (#94) --- packages/eslint-plugin/README.md | 27 +++++++-------------------- packages/eslint-plugin/parser.js | 10 ---------- 2 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 packages/eslint-plugin/parser.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 6f649ef0ada6..b9366b302b31 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -10,45 +10,32 @@ ## Installation -You'll first need to install [ESLint](http://eslint.org): - -```sh -npm i eslint --save-dev -``` - -Next, install `typescript` if you haven’t already: - -```sh -npm i typescript@~3.1.1 --save-dev -``` - -Last, install `@typescript-eslint/eslint-plugin`: +Make sure you have TypeScript and @typescript-eslint/parser installed, then install the plugin: ```sh npm i @typescript-eslint/eslint-plugin --save-dev ``` +It is important that you use the same version number for `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`. + **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. ## Usage -Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file: +Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file: ```json { - "parser": "@typescript-eslint/eslint-plugin/parser", + "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"] } ``` -Note: The plugin provides its own version of the `@typescript-eslint/parser` via `@typescript-eslint/eslint-plugin/parser`. -This helps us guarantee 100% compatibility between the plugin and the parser. - Then configure the rules you want to use under the rules section. ```json { - "parser": "@typescript-eslint/eslint-plugin/parser", + "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"], "rules": { "@typescript-eslint/rule-name": "error" @@ -56,7 +43,7 @@ Then configure the rules you want to use under the rules section. } ``` -You can also enable all the recommended rules at once. Add `plugin:typescript/recommended` in extends: +You can also enable all the recommended rules at once. Add `plugin:@typescript-eslint/recommended` in extends: ```json { diff --git a/packages/eslint-plugin/parser.js b/packages/eslint-plugin/parser.js deleted file mode 100644 index 44041c4bf2c8..000000000000 --- a/packages/eslint-plugin/parser.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @fileoverview Internal parser - * @author Patricio Trevino - */ - -'use strict'; - -// export the @typescript-eslint/parser. -// this forces the parser to be a direct dependency of the plugin. -module.exports = require('@typescript-eslint/parser'); From f0e4d1d26542944b4ff6c5ccf8b8a4cc1572b38b Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 10:59:15 -0500 Subject: [PATCH 11/14] docs: some fixes and consistency (#95) --- packages/eslint-plugin-tslint/README.md | 6 ++-- packages/parser/README.md | 43 ++----------------------- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 8ecccbd1001a..7a1cdf297aa4 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -23,10 +23,10 @@ Configure in your eslint config file: ```js { "plugins": [ - "tslint" + "@typescript-eslint/tslint" ], "rules": { - "tslint/config": ["warn", { + "@typescript-eslint/tslint/config": ["warn", { "lintFile": '', // path to tslint.json of your project "rules": { // tslint rules (will be used if `lintFile` is not specified) @@ -41,7 +41,7 @@ Configure in your eslint config file: ## Rules -Plugin contains only single rule `tslint/config`. +Plugin contains only single rule `@typescript-eslint/tslint/config`. ## Examples diff --git a/packages/parser/README.md b/packages/parser/README.md index 3a18f79735e6..77359a790f34 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -34,7 +34,7 @@ The core rules built into ESLint, such as `indent` have no knowledge of such con Instead, you also need to make use of one more plugins which will add or extend rules with TypeScript-specific features. -By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/nzakas/@typescript-eslint/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/JamesHenry/@typescript-eslint/eslint-plugin-tslint). +By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin-tslint). ## Configuration @@ -64,50 +64,13 @@ The following additional configuration options are available by specifying them ## Supported TypeScript Version -We will always endeavor to support the latest stable 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. - -If you use a non-supported version of TypeScript, the parser will log a warning to the console. +Please see https://github.com/typescript-eslint/typescript-eslint for the supported TypeScript version. **Please ensure that you are using a supported version before submitting any issues/bug reports.** ## Reporting Issues -Please check the current list of open and known issues and ensure the issue has not been reported before. When creating a new issue provide as much information about your environment as possible. This includes: - -- ESLint Version -- TypeScript version -- The `@typescript-eslint/parser` version -- ESLint config or rules and plugins currently enabled - -## Integration Tests - -We have a very flexible way of running integration tests which connects all of the moving parts of the usage of this parser in the ESLint ecosystem. - -We run each test within its own docker container, and so each one has complete autonomy over what dependencies/plugins are installed and what versions are used. This also has the benefit of not bloating the `package.json` and `node_modules` of the parser project itself. - -> If you are going to submit an issue related to the usage of this parser with ESLint, please consider creating a failing integration test which clearly demonstrates the behavior. It's honestly super quick! - -You just need to duplicate one of the existing test sub-directories found in `tests/integration/`, tweak the dependencies and ESLint config to match what you need, and add a new entry to the docker-compose.yml file which matches the format of the existing ones. - -Then run: - -```sh -npm run integration-tests -``` - -If you ever need to change what gets installed when the docker images are built by docker-compose, you will first need to kill the existing containers by running: - -```sh -npm run kill-integration-test-containers -``` - -## Build Commands - -- `npm test` - run all linting and tests -- `npm run lint` - run all linting -- `npm run integration-tests` - run only integration tests +Please use the @typescript-eslint/parser issue template when creating your issue and fill out the information requested as best you can. This will really help us when looking into your issue. ## License From c51d4e0ffd7497d285b48cc271b3be6edcac6ecb Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 15:28:48 -0500 Subject: [PATCH 12/14] chore: versions on issue templates --- .../ISSUE_TEMPLATE/eslint-plugin-tslint.md | 23 +++++++++---------- .../eslint-plugin-typescript.md | 5 +++- .../typescript-eslint-parser.md | 21 ++++++++--------- .github/ISSUE_TEMPLATE/typescript-estree.md | 13 +++++++---- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md index d78e999d908e..313c1880a1ab 100644 --- a/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md +++ b/.github/ISSUE_TEMPLATE/eslint-plugin-tslint.md @@ -6,18 +6,6 @@ labels: 'package: @typescript-eslint/eslint-plugin-tslint, triage' assignees: '' --- -**What version of Node.js and npm are you using?** - -- Node: -- npm: - -**What version of the following packages are you using?** - -- @typescript-eslint/eslint-plugin-tslint: -- @typescript-eslint/parser: -- TypeScript: -- ESLint: - **What code were you trying to parse?** ```ts @@ -27,3 +15,14 @@ assignees: '' **What did you expect to happen?** **What actually happened?** + +**Versions** + +| package | version | +| ----------------------------------------- | ------- | +| `@typescript-eslint/eslint-plugin-tslint` | `X.Y.Z` | +| `@typescript-eslint/parser` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `ESLint` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md index b7566c0069ca..ddae219da635 100644 --- a/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md +++ b/.github/ISSUE_TEMPLATE/eslint-plugin-typescript.md @@ -42,4 +42,7 @@ Please try to avoid code that isn't directly related to the bug, as it makes it | ---------------------------------- | ------- | | `@typescript-eslint/eslint-plugin` | `X.Y.Z` | | `@typescript-eslint/parser` | `X.Y.Z` | -| `typescript` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `ESLint` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md index 601087f77e82..f0cfe5a1e158 100644 --- a/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md +++ b/.github/ISSUE_TEMPLATE/typescript-eslint-parser.md @@ -6,17 +6,6 @@ labels: 'package: parser, triage' assignees: '' --- -**What version of Node.js and npm are you using?** - -- Node: -- npm: - -**What version of the following packages are you using?** - -- @typescript-eslint/parser: -- TypeScript: -- ESLint: - **What code were you trying to parse?** ```ts @@ -26,3 +15,13 @@ assignees: '' **What did you expect to happen?** **What actually happened?** + +**Versions** + +| package | version | +| --------------------------- | ------- | +| `@typescript-eslint/parser` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `ESLint` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | diff --git a/.github/ISSUE_TEMPLATE/typescript-estree.md b/.github/ISSUE_TEMPLATE/typescript-estree.md index f6b12ebafe9e..fc8cca3d9a39 100644 --- a/.github/ISSUE_TEMPLATE/typescript-estree.md +++ b/.github/ISSUE_TEMPLATE/typescript-estree.md @@ -6,10 +6,6 @@ labels: 'package: typescript-estree, triage' assignees: '' --- -**What version of TypeScript are you using?** - -**What version of `@typescript-eslint/typescript-estree` are you using?** - **What code were you trying to parse?** ```ts @@ -19,3 +15,12 @@ assignees: '' **What did you expect to happen?** **What actually happened?** + +**Versions** + +| package | version | +| -------------------------------------- | ------- | +| `@typescript-eslint/typescript-estree` | `X.Y.Z` | +| `TypeScript` | `X.Y.Z` | +| `node` | `X.Y.Z` | +| `npm` | `X.Y.Z` | From 055c3fcddb86189aae7056e51a10cd774156cabb Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 17:46:20 -0500 Subject: [PATCH 13/14] fix(eslint-plugin): update remaining parser refs (#97) --- packages/eslint-plugin/lib/configs/recommended.json | 2 +- packages/eslint-plugin/lib/util.js | 5 +---- packages/eslint-plugin/tools/update-recommended.js | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/eslint-plugin/lib/configs/recommended.json b/packages/eslint-plugin/lib/configs/recommended.json index 77b6e55d31c9..cd21778bfff1 100644 --- a/packages/eslint-plugin/lib/configs/recommended.json +++ b/packages/eslint-plugin/lib/configs/recommended.json @@ -1,5 +1,5 @@ { - "parser": "@typescript-eslint/eslint-plugin/parser", + "parser": "@typescript-eslint/parser", "parserOptions": { "sourceType": "module" }, diff --git a/packages/eslint-plugin/lib/util.js b/packages/eslint-plugin/lib/util.js index 66c6312ea14d..1df02bfb9e8e 100644 --- a/packages/eslint-plugin/lib/util.js +++ b/packages/eslint-plugin/lib/util.js @@ -117,11 +117,8 @@ exports.getParserServices = context => { !context.parserServices.program || !context.parserServices.esTreeNodeToTSNodeMap ) { - // TODO - the message will require revisiting once the @typescript-eslint/parser work finalises - // their work around exposing the parser. They may require that there be a project config field in - // the eslint config, in which case we should check and/or report that here appropriately. throw new Error( - 'This rule requires you to use `@typescript-eslint/eslint-plugin/parser`.' + 'This rule requires you to use `@typescript-eslint/parser`.' ); } return context.parserServices; diff --git a/packages/eslint-plugin/tools/update-recommended.js b/packages/eslint-plugin/tools/update-recommended.js index 73b9571eddbe..ce402c3933be 100644 --- a/packages/eslint-plugin/tools/update-recommended.js +++ b/packages/eslint-plugin/tools/update-recommended.js @@ -49,7 +49,7 @@ function generate() { const filePath = path.resolve(__dirname, '../lib/configs/recommended.json'); const recommendedConfig = { - parser: '@typescript-eslint/eslint-plugin/parser', + parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module' }, From af460d4ad0c4646ed2c6e1de25629c4a2e8fd0f8 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 20 Jan 2019 17:49:02 -0500 Subject: [PATCH 14/14] chore: publish v1.0.0 --- CHANGELOG.md | 13 +++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 4 ++-- packages/eslint-plugin/CHANGELOG.md | 12 ++++++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/parser/CHANGELOG.md | 6 ++++++ packages/parser/package.json | 6 +++--- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 6 ++++++ packages/typescript-estree/package.json | 4 ++-- 12 files changed, 60 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0706cb69e05..c87104215644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Bug Fixes + +- **eslint-plugin:** fix crash in rule indent for eslint 5.12.1 ([#89](https://github.com/typescript-eslint/typescript-eslint/issues/89)) ([3f51d51](https://github.com/typescript-eslint/typescript-eslint/commit/3f51d51)) +- **eslint-plugin:** no-unused-vars: mark declared statements as used ([#88](https://github.com/typescript-eslint/typescript-eslint/issues/88)) ([2df5e0c](https://github.com/typescript-eslint/typescript-eslint/commit/2df5e0c)) +- **eslint-plugin:** update remaining parser refs ([#97](https://github.com/typescript-eslint/typescript-eslint/issues/97)) ([055c3fc](https://github.com/typescript-eslint/typescript-eslint/commit/055c3fc)) + +### Features + +- **eslint-plugin:** remove exported parser ([#94](https://github.com/typescript-eslint/typescript-eslint/issues/94)) ([0ddb93c](https://github.com/typescript-eslint/typescript-eslint/commit/0ddb93c)) +- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/typescript-eslint diff --git a/lerna.json b/lerna.json index d51f69375e6d..c416cf72769b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.2.1", + "version": "1.0.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 241c8cd24624..a95c7b88cb36 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index e6f13409db21..9c0668115ecc 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "0.2.1", + "version": "1.0.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -33,6 +33,6 @@ "devDependencies": { "@types/eslint": "^4.16.3", "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "0.2.1" + "@typescript-eslint/parser": "1.0.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index d0f9e7a9b350..188e6b07bec3 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Bug Fixes + +- **eslint-plugin:** fix crash in rule indent for eslint 5.12.1 ([#89](https://github.com/typescript-eslint/typescript-eslint/issues/89)) ([3f51d51](https://github.com/typescript-eslint/typescript-eslint/commit/3f51d51)) +- **eslint-plugin:** no-unused-vars: mark declared statements as used ([#88](https://github.com/typescript-eslint/typescript-eslint/issues/88)) ([2df5e0c](https://github.com/typescript-eslint/typescript-eslint/commit/2df5e0c)) +- **eslint-plugin:** update remaining parser refs ([#97](https://github.com/typescript-eslint/typescript-eslint/issues/97)) ([055c3fc](https://github.com/typescript-eslint/typescript-eslint/commit/055c3fc)) + +### Features + +- **eslint-plugin:** remove exported parser ([#94](https://github.com/typescript-eslint/typescript-eslint/issues/94)) ([0ddb93c](https://github.com/typescript-eslint/typescript-eslint/commit/0ddb93c)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/eslint-plugin diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index a8f81d0eab0b..34d125380e4c 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "0.2.1", + "version": "1.0.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -24,7 +24,7 @@ "recommended:update": "node tools/update-recommended.js" }, "dependencies": { - "@typescript-eslint/parser": "0.2.1", + "@typescript-eslint/parser": "1.0.0", "requireindex": "^1.2.0" }, "devDependencies": { diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index eec382e512e0..1e519885b94a 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Features + +- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index b4271605c7b9..be34576e324c 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "0.2.1", + "version": "1.0.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "files": [ @@ -36,7 +36,7 @@ "typescript": "*" }, "dependencies": { - "@typescript-eslint/typescript-estree": "0.2.1", + "@typescript-eslint/typescript-estree": "1.0.0", "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0" }, @@ -44,6 +44,6 @@ "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", "@types/estree": "^0.0.39", - "@typescript-eslint/shared-fixtures": "0.2.1" + "@typescript-eslint/shared-fixtures": "1.0.0" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index aebf69abe3ec..2b7402f262e4 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index fe6193c18596..4478df0606e9 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "0.2.1", + "version": "1.0.0", "private": true } diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 2ee862165041..39323d365fd7 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.1...v1.0.0) (2019-01-20) + +### Features + +- **parser:** support ecmaFeatures.jsx flag and tests ([#85](https://github.com/typescript-eslint/typescript-eslint/issues/85)) ([b321736](https://github.com/typescript-eslint/typescript-eslint/commit/b321736)) + ## [0.2.1](https://github.com/typescript-eslint/typescript-eslint/compare/v0.2.0...v0.2.1) (2019-01-20) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 770cf0a1da51..10d0639be1f4 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "0.2.1", + "version": "1.0.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "files": [ @@ -41,7 +41,7 @@ "typescript": "*" }, "devDependencies": { - "@typescript-eslint/shared-fixtures": "0.2.1", + "@typescript-eslint/shared-fixtures": "1.0.0", "typescript": "~3.2.1" } }