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; ```