From f00d78db03ab511fbe1eea7c2c6b0298b6633564 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 12:37:20 +0100 Subject: [PATCH 1/3] feat(eslint-plugin): add new rule restrict-plus-operands --- packages/eslint-plugin/README.md | 69 ++--- .../docs/rules/restrict-plus-operands.md | 25 ++ .../lib/rules/restrict-plus-operands.js | 104 +++++++ .../tests/fixtures/tsconfig.json | 9 + .../tests/lib/rules/restrict-plus-operands.js | 282 ++++++++++++++++++ 5 files changed, 455 insertions(+), 34 deletions(-) create mode 100644 packages/eslint-plugin/docs/rules/restrict-plus-operands.md create mode 100644 packages/eslint-plugin/lib/rules/restrict-plus-operands.js create mode 100644 packages/eslint-plugin/tests/fixtures/tsconfig.json create mode 100644 packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 82e116951b03..6ec6e995754f 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 } ``` -Note: The plugin provides its own version of the `@typescript-eslint/parser` via `@typescript-eslint/eslint-plugin/parser`. +Note: The plugin provides its own version of the `@typescript-eslint/eslint-plugin/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. @@ -70,38 +70,39 @@ 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/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | | +| [`@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/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md new file mode 100644 index 000000000000..98b3b15ca4b5 --- /dev/null +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -0,0 +1,25 @@ +# When adding two variables, operands must both be of type number or of type string. (restrict-plus-operands) + +Examples of **correct** code: + +```ts +var foo = parseInt("5.5", 10) + 10; +``` + +Examples of **incorrect** code: + +```ts +var foo = "5.5" + 5; +``` + +## Options + +```json +{ + "@typescript-eslint/restrict-plus-operands": "error" +} +``` + +## Compatibility + +- TSLint: [restrict-plus-operands](https://palantir.github.io/tslint/rules/restrict-plus-operands/) diff --git a/packages/eslint-plugin/lib/rules/restrict-plus-operands.js b/packages/eslint-plugin/lib/rules/restrict-plus-operands.js new file mode 100644 index 000000000000..222f51e5c8af --- /dev/null +++ b/packages/eslint-plugin/lib/rules/restrict-plus-operands.js @@ -0,0 +1,104 @@ +/** + * @fileoverview When adding two variables, operands must both be of type number or of type string. + * @author James Henry + * @author Armano + */ +'use strict'; + +const util = require('../util'); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: 'problem', + docs: { + description: + 'When adding two variables, operands must both be of type number or of type string.', + extraDescription: [util.tslintRule('restrict-plus-operands')], + category: 'TypeScript', + url: util.metaDocsUrl('restrict-plus-operands') + }, + messages: { + notNumbers: + "Operands of '+' operation must either be both strings or both numbers.", + notStrings: + "Operands of '+' operation must either be both strings or both numbers. Consider using a template literal." + }, + schema: [] + }, + + create(context) { + const service = util.getParserServices(context); + + const typeChecker = service.program.getTypeChecker(); + + /** + * Helper function to get base type of node + * @param {ts.Type} type type to be evaluated + * @returns {*} string, number or invalid + */ + function getBaseTypeOfLiteralType(type) { + if (type.isNumberLiteral()) { + return 'number'; + } + if (type.isStringLiteral()) { + return 'string'; + } + if (type.isUnion()) { + const types = type.types.map(getBaseTypeOfLiteralType); + + return types.every(value => value === types[0]) ? types[0] : 'invalid'; + } + + const stringType = typeChecker.typeToString(type); + + if (stringType === 'number' || stringType === 'string') { + return stringType; + } + return 'invalid'; + } + + /** + * Helper function to get base type of node + * @param {ASTNode} node the node to be evaluated. + * @returns {*} string, number or invalid + */ + function getNodeType(node) { + const tsNode = service.esTreeNodeToTSNodeMap.get(node); + const type = typeChecker.getTypeAtLocation(tsNode); + + return getBaseTypeOfLiteralType(type); + } + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + return { + "BinaryExpression[operator='+']"(node) { + const leftType = getNodeType(node.left); + const rightType = getNodeType(node.right); + + if ( + leftType === 'invalid' || + rightType === 'invalid' || + leftType !== rightType + ) { + if (leftType === 'string' || rightType === 'string') { + context.report({ + node, + messageId: 'notStrings' + }); + } else { + context.report({ + node, + messageId: 'notNumbers' + }); + } + } + } + }; + } +}; diff --git a/packages/eslint-plugin/tests/fixtures/tsconfig.json b/packages/eslint-plugin/tests/fixtures/tsconfig.json new file mode 100644 index 000000000000..8702b63472ba --- /dev/null +++ b/packages/eslint-plugin/tests/fixtures/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "lib": ["es2015", "es2017"] + } +} diff --git a/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js b/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js new file mode 100644 index 000000000000..a13b7cea3e47 --- /dev/null +++ b/packages/eslint-plugin/tests/lib/rules/restrict-plus-operands.js @@ -0,0 +1,282 @@ +/** + * @fileoverview When adding two variables, operands must both be of type number or of type string. + * @author James Henry + * @author Armano + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ +const path = require('path'); + +const rule = require('../../../lib/rules/restrict-plus-operands'), + RuleTester = require('eslint').RuleTester; + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +const rootPath = path.join(process.cwd(), 'tests/fixtures/'); + +const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser', + parserOptions: { + generateServices: true, + tsconfigRootDir: rootPath, + project: './tsconfig.json' + } +}); + +ruleTester.run('restrict-plus-operands', rule, { + valid: [ + `var x = 5;`, + `var y = "10";`, + `var z = 8.2;`, + `var w = "6.5";`, + `var foo = 5 + 10;`, + `var foo = "5.5" + "10";`, + `var foo = parseInt("5.5", 10) + 10;`, + `var foo = parseFloat("5.5", 10) + 10;`, + ` +function test () : number { return 2; } +var foo = test("5.5", 10) + 10; + `, + ` +var x = 5; +var z = 8.2; +var foo = x + z; + `, + ` +var w = "6.5"; +var y = "10"; +var foo = y + w; + `, + 'var foo = 1 + 1;', + "var foo = '1' + '1';", + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = pair.first + 10; + `, + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = pair.first + (10 as number); + `, + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = "5.5" + pair.second; + `, + ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = ("5.5" as string) + pair.second; + `, + `const foo = 'hello' + (someBoolean ? 'a' : 'b') + (() => someBoolean ? 'c' : 'd')() + 'e';`, + `const balls = true;`, + `balls === true;` + ], + invalid: [ + { + code: "var foo = '1' + 1;", + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: 'var foo = [] + {};', + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = 5 + "10";`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = [] + 5;`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = [] + {};`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = [] + [];`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = 5 + [];`, + errors: [ + { + messageId: 'notNumbers', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = "5" + {};`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = 5.5 + "5";`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: `var foo = "5.5" + 5;`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: ` +var x = 5; +var y = "10"; +var foo = x + y; + `, + errors: [ + { + messageId: 'notStrings', + line: 4, + column: 11 + } + ] + }, + { + code: ` +var x = 5; +var y = "10"; +var foo = y + x; + `, + errors: [ + { + messageId: 'notStrings', + line: 4, + column: 11 + } + ] + }, + { + code: ` +var x = 5; +var foo = x + {}; + `, + errors: [ + { + messageId: 'notNumbers', + line: 3, + column: 11 + } + ] + }, + { + code: ` +var y = "10"; +var foo = [] + y; + `, + errors: [ + { + messageId: 'notStrings', + line: 3, + column: 11 + } + ] + }, + { + code: ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = pair.first + "10"; + `, + errors: [ + { + messageId: 'notStrings', + line: 3, + column: 11 + } + ] + }, + { + code: ` +var pair: { first: number, second: string } = { first: 5, second: "10" }; +var foo = 5 + pair.second; + `, + errors: [ + { + messageId: 'notStrings', + line: 3, + column: 11 + } + ] + }, + { + code: `var foo = parseInt("5.5", 10) + "10";`, + errors: [ + { + messageId: 'notStrings', + line: 1, + column: 11 + } + ] + }, + { + code: ` +var pair = { first: 5, second: "10" }; +var foo = pair + pair; + `, + errors: [ + { + messageId: 'notNumbers', + line: 3, + column: 11 + } + ] + } + ] +}); From 134086535ecdb8c50226b46d810b0de0b64c7e5d Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 12:46:04 +0100 Subject: [PATCH 2/3] docs(eslint-plugin): update wrong parser package name --- packages/eslint-plugin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 6ec6e995754f..3d59c78a65b7 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 } ``` -Note: The plugin provides its own version of the `@typescript-eslint/eslint-plugin/parser` via `@typescript-eslint/eslint-plugin/parser`. +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. From b8919855be8902cb8521817eab7ef0f73e10c640 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 20 Jan 2019 15:24:37 +0100 Subject: [PATCH 3/3] docs(eslint-plugin): update format --- packages/eslint-plugin/docs/rules/restrict-plus-operands.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index 98b3b15ca4b5..a1436daf7695 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -3,13 +3,13 @@ Examples of **correct** code: ```ts -var foo = parseInt("5.5", 10) + 10; +var foo = parseInt('5.5', 10) + 10; ``` Examples of **incorrect** code: ```ts -var foo = "5.5" + 5; +var foo = '5.5' + 5; ``` ## Options