diff --git a/CHANGELOG.md b/CHANGELOG.md index be14a02b74f8..6cace1e04257 100644 --- a/CHANGELOG.md +++ b/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + + +### Bug Fixes + +* **eslint-plugin:** [prefer-includes] ignore option chaining before indexOfs ([#3432](https://github.com/typescript-eslint/typescript-eslint/issues/3432)) ([bf0cddb](https://github.com/typescript-eslint/typescript-eslint/commit/bf0cddbe5291bbc03e2d79aa680f93680222b67f)) +* **eslint-plugin:** fix doc url generation ([#3475](https://github.com/typescript-eslint/typescript-eslint/issues/3475)) ([fc5f171](https://github.com/typescript-eslint/typescript-eslint/commit/fc5f171b1ade2b45a1a4268b6d22926d420282a6)), closes [#3473](https://github.com/typescript-eslint/typescript-eslint/issues/3473) + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) diff --git a/lerna.json b/lerna.json index 78c7916f2406..757d0fec9038 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "4.26.0", + "version": "4.26.1", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 4c75520dcd34..f7ea1246c5c2 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/ast-spec + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **Note:** Version bump only for package @typescript-eslint/ast-spec diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index 79c4b45c525c..96ec8a09b7dc 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "4.26.0", + "version": "4.26.1", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index d0ea626917c6..e0a9ecca5f7b 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 3b4cd8b53c1b..432794935bc3 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-internal", - "version": "4.26.0", + "version": "4.26.1", "private": true, "main": "dist/index.js", "scripts": { @@ -14,7 +14,7 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/experimental-utils": "4.26.0", + "@typescript-eslint/experimental-utils": "4.26.1", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index c1289a51a619..18539ad609f0 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **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 889ebde1b9b4..5a31ac9fe864 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": "4.26.0", + "version": "4.26.1", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.26.0", + "@typescript-eslint/experimental-utils": "4.26.1", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "4.26.0" + "@typescript-eslint/parser": "4.26.1" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index ec188a44c7a3..8b7f427128d3 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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + + +### Bug Fixes + +* **eslint-plugin:** [prefer-includes] ignore option chaining before indexOfs ([#3432](https://github.com/typescript-eslint/typescript-eslint/issues/3432)) ([bf0cddb](https://github.com/typescript-eslint/typescript-eslint/commit/bf0cddbe5291bbc03e2d79aa680f93680222b67f)) +* **eslint-plugin:** fix doc url generation ([#3475](https://github.com/typescript-eslint/typescript-eslint/issues/3475)) ([fc5f171](https://github.com/typescript-eslint/typescript-eslint/commit/fc5f171b1ade2b45a1a4268b6d22926d420282a6)), closes [#3473](https://github.com/typescript-eslint/typescript-eslint/issues/3473) + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index 07cc9ea44e12..018780a657d2 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -22,6 +22,7 @@ let str: string; let array: any[]; let readonlyArray: ReadonlyArray; let typedArray: UInt8Array; +let maybe: string; let userDefined: { indexOf(x: any): number; includes(x: any): boolean; @@ -31,6 +32,7 @@ str.indexOf(value) !== -1; array.indexOf(value) !== -1; readonlyArray.indexOf(value) === -1; typedArray.indexOf(value) > -1; +maybe?.indexOf('') !== -1; userDefined.indexOf(value) >= 0; // simple RegExp test diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 4037e73b7e04..8f23087a053d 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "4.26.0", + "version": "4.26.1", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,8 +44,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.26.0", - "@typescript-eslint/scope-manager": "4.26.0", + "@typescript-eslint/experimental-utils": "4.26.1", + "@typescript-eslint/scope-manager": "4.26.1", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.21", diff --git a/packages/eslint-plugin/src/rules/prefer-includes.ts b/packages/eslint-plugin/src/rules/prefer-includes.ts index d21b088d4aa2..13a6021c8069 100644 --- a/packages/eslint-plugin/src/rules/prefer-includes.ts +++ b/packages/eslint-plugin/src/rules/prefer-includes.ts @@ -1,5 +1,6 @@ import { AST_NODE_TYPES, + TSESLint, TSESTree, } from '@typescript-eslint/experimental-utils'; import { AST as RegExpAST, parseRegExpLiteral } from 'regexpp'; @@ -125,67 +126,81 @@ export default createRule({ ); } - return { - [[ - // a.indexOf(b) !== 1 - "BinaryExpression > CallExpression.left > MemberExpression.callee[property.name='indexOf'][computed=false]", - // a?.indexOf(b) !== 1 - "BinaryExpression > ChainExpression.left > CallExpression > MemberExpression.callee[property.name='indexOf'][computed=false]", - ].join(', ')](node: TSESTree.MemberExpression): void { - // Check if the comparison is equivalent to `includes()`. - const callNode = node.parent as TSESTree.CallExpression; - const compareNode = ( - callNode.parent?.type === AST_NODE_TYPES.ChainExpression - ? callNode.parent.parent - : callNode.parent - ) as TSESTree.BinaryExpression; - const negative = isNegativeCheck(compareNode); - if (!negative && !isPositiveCheck(compareNode)) { - return; - } + function checkArrayIndexOf( + node: TSESTree.MemberExpression, + allowFixing: boolean, + ): void { + // Check if the comparison is equivalent to `includes()`. + const callNode = node.parent as TSESTree.CallExpression; + const compareNode = ( + callNode.parent?.type === AST_NODE_TYPES.ChainExpression + ? callNode.parent.parent + : callNode.parent + ) as TSESTree.BinaryExpression; + const negative = isNegativeCheck(compareNode); + if (!negative && !isPositiveCheck(compareNode)) { + return; + } - // Get the symbol of `indexOf` method. - const tsNode = services.esTreeNodeToTSNodeMap.get(node.property); - const indexofMethodDeclarations = types - .getSymbolAtLocation(tsNode) + // Get the symbol of `indexOf` method. + const tsNode = services.esTreeNodeToTSNodeMap.get(node.property); + const indexofMethodDeclarations = types + .getSymbolAtLocation(tsNode) + ?.getDeclarations(); + if ( + indexofMethodDeclarations == null || + indexofMethodDeclarations.length === 0 + ) { + return; + } + + // Check if every declaration of `indexOf` method has `includes` method + // and the two methods have the same parameters. + for (const instanceofMethodDecl of indexofMethodDeclarations) { + const typeDecl = instanceofMethodDecl.parent; + const type = types.getTypeAtLocation(typeDecl); + const includesMethodDecl = type + .getProperty('includes') ?.getDeclarations(); if ( - indexofMethodDeclarations == null || - indexofMethodDeclarations.length === 0 + includesMethodDecl == null || + !includesMethodDecl.some(includesMethodDecl => + hasSameParameters(includesMethodDecl, instanceofMethodDecl), + ) ) { return; } + } - // Check if every declaration of `indexOf` method has `includes` method - // and the two methods have the same parameters. - for (const instanceofMethodDecl of indexofMethodDeclarations) { - const typeDecl = instanceofMethodDecl.parent; - const type = types.getTypeAtLocation(typeDecl); - const includesMethodDecl = type - .getProperty('includes') - ?.getDeclarations(); - if ( - includesMethodDecl == null || - !includesMethodDecl.some(includesMethodDecl => - hasSameParameters(includesMethodDecl, instanceofMethodDecl), - ) - ) { - return; - } - } - - // Report it. - context.report({ - node: compareNode, - messageId: 'preferIncludes', - *fix(fixer) { + // Report it. + context.report({ + node: compareNode, + messageId: 'preferIncludes', + ...(allowFixing && { + *fix(fixer): Generator { if (negative) { yield fixer.insertTextBefore(callNode, '!'); } yield fixer.replaceText(node.property, 'includes'); yield fixer.removeRange([callNode.range[1], compareNode.range[1]]); }, - }); + }), + }); + } + + return { + // a.indexOf(b) !== 1 + "BinaryExpression > CallExpression.left > MemberExpression.callee[property.name='indexOf'][computed=false]"( + node: TSESTree.MemberExpression, + ): void { + checkArrayIndexOf(node, /* allowFixing */ true); + }, + + // a?.indexOf(b) !== 1 + "BinaryExpression > ChainExpression.left > CallExpression > MemberExpression.callee[property.name='indexOf'][computed=false]"( + node: TSESTree.MemberExpression, + ): void { + checkArrayIndexOf(node, /* allowFixing */ false); }, // /bar/.test(foo) @@ -230,7 +245,7 @@ export default createRule({ } yield fixer.insertTextAfter( argNode, - `${node.optional ? '?.' : '.'}includes(${JSON.stringify(text)}`, + `${node.optional ? '?.' : '.'}includes('${text}'`, ); }, }); diff --git a/packages/eslint-plugin/src/util/createRule.ts b/packages/eslint-plugin/src/util/createRule.ts index d6684de5d0d0..d56fe6d2a7d7 100644 --- a/packages/eslint-plugin/src/util/createRule.ts +++ b/packages/eslint-plugin/src/util/createRule.ts @@ -2,7 +2,7 @@ import { ESLintUtils } from '@typescript-eslint/experimental-utils'; // note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -const version: string = require('../../package.json'); +const version: string = require('../../package.json').version; export const createRule = ESLintUtils.RuleCreator( name => diff --git a/packages/eslint-plugin/tests/rules/prefer-includes.test.ts b/packages/eslint-plugin/tests/rules/prefer-includes.test.ts index c72488a49372..ceda607df494 100644 --- a/packages/eslint-plugin/tests/rules/prefer-includes.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-includes.test.ts @@ -1,6 +1,4 @@ -import { TSESLint } from '@typescript-eslint/experimental-utils'; import rule from '../../src/rules/prefer-includes'; -import * as util from '../../src/util'; import { RuleTester, getFixturesRootDir } from '../RuleTester'; const rootPath = getFixturesRootDir(); @@ -13,126 +11,101 @@ const ruleTester = new RuleTester({ }, }); -type MessageIds = util.InferMessageIdsTypeFromRule; - -type InvalidTestCase = TSESLint.InvalidTestCase; -type ValidTestCase = TSESLint.ValidTestCase | string; -function addOptional(cases: ValidTestCase[]): ValidTestCase[]; -function addOptional(cases: InvalidTestCase[]): InvalidTestCase[]; -function addOptional( - cases: (ValidTestCase | InvalidTestCase)[], -): (ValidTestCase | InvalidTestCase)[] { - return cases.reduce<(ValidTestCase | InvalidTestCase)[]>((acc, c) => { - acc.push(c); - if (typeof c === 'string') { - acc.push(c.replace('.', '?.')); - } else { - acc.push({ - ...c, - code: c.code.replace('.', '?.'), - output: 'output' in c ? c.output?.replace('.', '?.') : null, - }); - } - - return acc; - }, []); -} - ruleTester.run('prefer-includes', rule, { - valid: addOptional([ + valid: [ ` function f(a: string): void { - a.indexOf(b) + a.indexOf(b); } `, ` function f(a: string): void { - a.indexOf(b) + 0 + a.indexOf(b) + 0; } `, ` - function f(a: string | {value: string}): void { - a.indexOf(b) !== -1 + function f(a: string | { value: string }): void { + a.indexOf(b) !== -1; } `, ` type UserDefined = { - indexOf(x: any): number // don't have 'includes' - } + indexOf(x: any): number; // don't have 'includes' + }; function f(a: UserDefined): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, ` type UserDefined = { - indexOf(x: any, fromIndex?: number): number - includes(x: any): boolean // different parameters - } + indexOf(x: any, fromIndex?: number): number; + includes(x: any): boolean; // different parameters + }; function f(a: UserDefined): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, ` type UserDefined = { - indexOf(x: any, fromIndex?: number): number - includes(x: any, fromIndex: number): boolean // different parameters - } + indexOf(x: any, fromIndex?: number): number; + includes(x: any, fromIndex: number): boolean; // different parameters + }; function f(a: UserDefined): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, ` type UserDefined = { - indexOf(x: any, fromIndex?: number): number - includes: boolean // different type - } + indexOf(x: any, fromIndex?: number): number; + includes: boolean; // different type + }; function f(a: UserDefined): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, ` function f(a: string): void { - /bar/i.test(a) + /bar/i.test(a); } `, ` function f(a: string): void { - /ba[rz]/.test(a) + /ba[rz]/.test(a); } `, ` function f(a: string): void { - /foo|bar/.test(a) + /foo|bar/.test(a); } `, ` function f(a: string): void { - /bar/.test() + /bar/.test(); } `, ` function f(a: string): void { - something.test(a) + something.test(a); } `, ` - const pattern = new RegExp("bar") + const pattern = new RegExp('bar'); function f(a) { - return pattern.test(a) + return pattern.test(a); } `, - ]), - invalid: addOptional([ + ], + invalid: [ // positive { code: ` function f(a: string): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: string): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -140,12 +113,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) != -1 + a.indexOf(b) != -1; } `, output: ` function f(a: string): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -153,12 +126,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) > -1 + a.indexOf(b) > -1; } `, output: ` function f(a: string): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -166,12 +139,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) >= 0 + a.indexOf(b) >= 0; } `, output: ` function f(a: string): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -181,12 +154,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) === -1 + a.indexOf(b) === -1; } `, output: ` function f(a: string): void { - !a.includes(b) + !a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -194,12 +167,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) == -1 + a.indexOf(b) == -1; } `, output: ` function f(a: string): void { - !a.includes(b) + !a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -207,12 +180,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) <= -1 + a.indexOf(b) <= -1; } `, output: ` function f(a: string): void { - !a.includes(b) + !a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -220,12 +193,28 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - a.indexOf(b) < 0 + a.indexOf(b) < 0; } `, output: ` function f(a: string): void { - !a.includes(b) + !a.includes(b); + } + `, + errors: [{ messageId: 'preferIncludes' }], + }, + { + code: ` + function f(a?: string): void { + a?.indexOf(b) === -1; + } + `, + errors: [{ messageId: 'preferIncludes' }], + }, + { + code: ` + function f(a?: string): void { + a?.indexOf(b) !== -1; } `, errors: [{ messageId: 'preferIncludes' }], @@ -235,42 +224,42 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: string): void { - /bar/.test(a) + /bar/.test(a); } `, output: ` function f(a: string): void { - a.includes("bar") + a.includes('bar'); } `, errors: [{ messageId: 'preferStringIncludes' }], }, { code: ` - const pattern = new RegExp("bar") + const pattern = new RegExp('bar'); function f(a: string): void { - pattern.test(a) + pattern.test(a); } `, output: ` - const pattern = new RegExp("bar") + const pattern = new RegExp('bar'); function f(a: string): void { - a.includes("bar") + a.includes('bar'); } `, errors: [{ messageId: 'preferStringIncludes' }], }, { code: ` - const pattern = /bar/ + const pattern = /bar/; function f(a: string, b: string): void { - pattern.test(a + b) + pattern.test(a + b); } `, output: ` - const pattern = /bar/ + const pattern = /bar/; function f(a: string, b: string): void { - (a + b).includes("bar") + (a + b).includes('bar'); } `, errors: [{ messageId: 'preferStringIncludes' }], @@ -280,12 +269,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: any[]): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: any[]): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -293,12 +282,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: ReadonlyArray): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: ReadonlyArray): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -306,12 +295,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Int8Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Int8Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -319,12 +308,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Int16Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Int16Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -332,12 +321,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Int32Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Int32Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -345,12 +334,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Uint8Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Uint8Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -358,12 +347,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Uint16Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Uint16Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -371,12 +360,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Uint32Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Uint32Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -384,12 +373,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Float32Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Float32Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -397,12 +386,12 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Float64Array): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Float64Array): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -410,25 +399,51 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: T[] | ReadonlyArray): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: T[] | ReadonlyArray): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], }, { code: ` - function f | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>(a: U): void { - a.indexOf(b) !== -1 + function f< + T, + U extends + | T[] + | ReadonlyArray + | Int8Array + | Uint8Array + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array, + >(a: U): void { + a.indexOf(b) !== -1; } `, output: ` - function f | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array>(a: U): void { - a.includes(b) + function f< + T, + U extends + | T[] + | ReadonlyArray + | Int8Array + | Uint8Array + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array, + >(a: U): void { + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -436,20 +451,20 @@ ruleTester.run('prefer-includes', rule, { { code: ` type UserDefined = { - indexOf(x: any): number - includes(x: any): boolean - } + indexOf(x: any): number; + includes(x: any): boolean; + }; function f(a: UserDefined): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` type UserDefined = { - indexOf(x: any): number - includes(x: any): boolean - } + indexOf(x: any): number; + includes(x: any): boolean; + }; function f(a: UserDefined): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], @@ -457,15 +472,15 @@ ruleTester.run('prefer-includes', rule, { { code: ` function f(a: Readonly): void { - a.indexOf(b) !== -1 + a.indexOf(b) !== -1; } `, output: ` function f(a: Readonly): void { - a.includes(b) + a.includes(b); } `, errors: [{ messageId: 'preferIncludes' }], }, - ]), + ], }); diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 541e3a78879a..d6055ce29b9c 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 67c30299380b..d0499b562518 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "4.26.0", + "version": "4.26.1", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.26.0", - "@typescript-eslint/types": "4.26.0", - "@typescript-eslint/typescript-estree": "4.26.0", + "@typescript-eslint/scope-manager": "4.26.1", + "@typescript-eslint/types": "4.26.1", + "@typescript-eslint/typescript-estree": "4.26.1", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 8d8892572251..c07db4b495e9 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 6ead2ad64141..3ff1f3968e96 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "4.26.0", + "version": "4.26.1", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -44,14 +44,14 @@ "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "4.26.0", - "@typescript-eslint/types": "4.26.0", - "@typescript-eslint/typescript-estree": "4.26.0", + "@typescript-eslint/scope-manager": "4.26.1", + "@typescript-eslint/types": "4.26.1", + "@typescript-eslint/typescript-estree": "4.26.1", "debug": "^4.3.1" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/experimental-utils": "4.26.0", + "@typescript-eslint/experimental-utils": "4.26.1", "glob": "*", "typescript": "*" }, diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index e7a671269aed..2ee969b4e090 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index df8278c3aae8..b2584b548268 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "4.26.0", + "version": "4.26.1", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -39,12 +39,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.26.0", - "@typescript-eslint/visitor-keys": "4.26.0" + "@typescript-eslint/types": "4.26.1", + "@typescript-eslint/visitor-keys": "4.26.1" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "4.26.0", + "@typescript-eslint/typescript-estree": "4.26.1", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 63b0edc2015e..55b086a682dd 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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **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 3db082050a13..13c290d52509 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "4.26.0", + "version": "4.26.1", "private": true } diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index ccfe38368535..638d10d83e5a 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/types + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) diff --git a/packages/types/package.json b/packages/types/package.json index 7024d906f318..e6a4c44ea3ae 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "4.26.0", + "version": "4.26.1", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 67b5be54903f..31b10925f0cd 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 377fee66555b..1781b27a7345 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "4.26.0", + "version": "4.26.1", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,8 +41,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.26.0", - "@typescript-eslint/visitor-keys": "4.26.0", + "@typescript-eslint/types": "4.26.1", + "@typescript-eslint/visitor-keys": "4.26.1", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "4.26.0", + "@typescript-eslint/shared-fixtures": "4.26.1", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index efa21c5364be..728f075000f4 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/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. +## [4.26.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.26.0...v4.26.1) (2021-06-07) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + + + + + # [4.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.25.0...v4.26.0) (2021-05-31) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index cbfa88c67eb6..8028f5e8f628 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "4.26.0", + "version": "4.26.1", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.26.0", + "@typescript-eslint/types": "4.26.1", "eslint-visitor-keys": "^2.0.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index fde7283b0603..f6cf41a28f74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8726,9 +8726,9 @@ trim-off-newlines@^1.0.0: integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= ts-jest@^27.0.1: - version "27.0.1" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.1.tgz#3cd174561c4bb311e0187a5837543fb858c60d16" - integrity sha512-03qAt77QjhxyM5Bt2KrrT1WbdumiwLz989sD3IUznSp3GIFQrx76kQqSMLF7ynnxrF3/1ipzABnHxMlU8PD4Vw== + version "27.0.2" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.0.2.tgz#acc1525d5fd25c107c777c3b80a11365db579aa1" + integrity sha512-pozjHOOfm+sbv9kXCvTFVyDntWvuJztzkNFql/akD75hSMZ2jsbidVauOhBRImAopXohqcLtPK/NTTIS8Y49Ug== dependencies: bs-logger "0.x" buffer-from "1.x"