From 033e87cb71a54c895a6165da3fe514bb5ba5b6c6 Mon Sep 17 00:00:00 2001 From: Jeffrey Bosch Date: Wed, 25 Jan 2023 18:30:13 +0100 Subject: [PATCH 01/21] test: verify that there are no errors on the website (#6365) closes: #6354 --- packages/website/tests/index.spec.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/website/tests/index.spec.ts b/packages/website/tests/index.spec.ts index 1fd2a70b413..e0a99f3d12c 100644 --- a/packages/website/tests/index.spec.ts +++ b/packages/website/tests/index.spec.ts @@ -1,7 +1,22 @@ import AxeBuilder from '@axe-core/playwright'; -import { test } from '@playwright/test'; +import { expect, test } from '@playwright/test'; -test('Index', async ({ page }) => { - await page.goto('/'); - await new AxeBuilder({ page }).analyze(); +test.describe('Website', () => { + test('Axe', async ({ page }) => { + await page.goto('/'); + await new AxeBuilder({ page }).analyze(); + }); + + test('should have no errors', async ({ page }) => { + const errorMessages: string[] = []; + page.on('console', msg => { + if (['error', 'warning'].includes(msg.type())) { + errorMessages.push(`[${msg.type()}] ${msg.text()}`); + } + }); + await page.goto('/'); + expect(errorMessages).toStrictEqual([ + "[error] Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot", + ]); + }); }); From b0f6c8ec0b372696ef26ca3a2b4f82dafd9dc417 Mon Sep 17 00:00:00 2001 From: Sviatoslav Zaytsev Date: Thu, 26 Jan 2023 19:18:52 +0300 Subject: [PATCH 02/21] fix(eslint-plugin): [prefer-optional-chain] fixer produces wrong logic (#5919) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(eslint-plugin): [prefer-optional-chain] fixer produces wrong logic (#1438) * Update packages/eslint-plugin/src/rules/prefer-optional-chain.ts * fix(eslint-plugin): [prefer-optional-chain] fix tests * fix(eslint-plugin): [prefer-optional-chain] fix tests Co-authored-by: Josh Goldberg Co-authored-by: Святослав Зайцев --- .../src/rules/prefer-optional-chain.ts | 16 +- .../rules/prefer-optional-chain/base-cases.ts | 228 ++++++++++++++++++ .../prefer-optional-chain.test.ts | 208 +++------------- 3 files changed, 273 insertions(+), 179 deletions(-) create mode 100644 packages/eslint-plugin/tests/rules/prefer-optional-chain/base-cases.ts rename packages/eslint-plugin/tests/rules/{ => prefer-optional-chain}/prefer-optional-chain.test.ts (85%) diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index 9a4949b734b..f5ed3ccb589 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -490,10 +490,20 @@ function reportIfMoreThanOne({ shouldHandleChainedAnds && previous.right.type === AST_NODE_TYPES.BinaryExpression ) { + let operator = previous.right.operator; + if ( + previous.right.operator === '!==' && + // TODO(#4820): Use the type checker to know whether this is `null` + previous.right.right.type === AST_NODE_TYPES.Literal && + previous.right.right.raw === 'null' + ) { + // case like foo !== null && foo.bar !== null + operator = '!='; + } // case like foo && foo.bar !== someValue - optionallyChainedCode += ` ${ - previous.right.operator - } ${sourceCode.getText(previous.right.right)}`; + optionallyChainedCode += ` ${operator} ${sourceCode.getText( + previous.right.right, + )}`; } context.report({ diff --git a/packages/eslint-plugin/tests/rules/prefer-optional-chain/base-cases.ts b/packages/eslint-plugin/tests/rules/prefer-optional-chain/base-cases.ts new file mode 100644 index 00000000000..99cfe6b0ff9 --- /dev/null +++ b/packages/eslint-plugin/tests/rules/prefer-optional-chain/base-cases.ts @@ -0,0 +1,228 @@ +import type { TSESLint } from '@typescript-eslint/utils'; + +import type rule from '../../../src/rules/prefer-optional-chain'; +import type { + InferMessageIdsTypeFromRule, + InferOptionsTypeFromRule, +} from '../../../src/util'; + +type InvalidTestCase = TSESLint.InvalidTestCase< + InferMessageIdsTypeFromRule, + InferOptionsTypeFromRule +>; + +interface BaseCase { + canReplaceAndWithOr: boolean; + output: string; + code: string; +} + +const mapper = (c: BaseCase): InvalidTestCase => ({ + code: c.code.trim(), + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: c.output.trim(), + }, + ], + }, + ], +}); + +const baseCases: Array = [ + // chained members + { + code: 'foo && foo.bar', + output: 'foo?.bar', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar.baz', + output: 'foo.bar?.baz', + canReplaceAndWithOr: true, + }, + { + code: 'foo && foo()', + output: 'foo?.()', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar()', + output: 'foo.bar?.()', + canReplaceAndWithOr: true, + }, + { + code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz', + output: 'foo?.bar?.baz?.buzz', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar.baz && foo.bar.baz.buzz', + output: 'foo.bar?.baz?.buzz', + canReplaceAndWithOr: true, + }, + // case with a jump (i.e. a non-nullish prop) + { + code: 'foo && foo.bar && foo.bar.baz.buzz', + output: 'foo?.bar?.baz.buzz', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar.baz.buzz', + output: 'foo.bar?.baz.buzz', + canReplaceAndWithOr: true, + }, + // case where for some reason there is a doubled up expression + { + code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz', + output: 'foo?.bar?.baz?.buzz', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz', + output: 'foo.bar?.baz?.buzz', + canReplaceAndWithOr: true, + }, + // chained members with element access + { + code: 'foo && foo[bar] && foo[bar].baz && foo[bar].baz.buzz', + output: 'foo?.[bar]?.baz?.buzz', + canReplaceAndWithOr: true, + }, + { + // case with a jump (i.e. a non-nullish prop) + code: 'foo && foo[bar].baz && foo[bar].baz.buzz', + output: 'foo?.[bar].baz?.buzz', + canReplaceAndWithOr: true, + }, + // case with a property access in computed property + { + code: 'foo && foo[bar.baz] && foo[bar.baz].buzz', + output: 'foo?.[bar.baz]?.buzz', + canReplaceAndWithOr: true, + }, + // case with this keyword + { + code: 'foo[this.bar] && foo[this.bar].baz', + output: 'foo[this.bar]?.baz', + canReplaceAndWithOr: true, + }, + // chained calls + { + code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz()', + output: 'foo?.bar?.baz?.buzz()', + canReplaceAndWithOr: true, + }, + { + code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz()', + output: 'foo?.bar?.baz?.buzz?.()', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz()', + output: 'foo.bar?.baz?.buzz?.()', + canReplaceAndWithOr: true, + }, + // case with a jump (i.e. a non-nullish prop) + { + code: 'foo && foo.bar && foo.bar.baz.buzz()', + output: 'foo?.bar?.baz.buzz()', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar.baz.buzz()', + output: 'foo.bar?.baz.buzz()', + canReplaceAndWithOr: true, + }, + { + // case with a jump (i.e. a non-nullish prop) + code: 'foo && foo.bar && foo.bar.baz.buzz && foo.bar.baz.buzz()', + output: 'foo?.bar?.baz.buzz?.()', + canReplaceAndWithOr: true, + }, + { + // case with a call expr inside the chain for some inefficient reason + code: 'foo && foo.bar() && foo.bar().baz && foo.bar().baz.buzz && foo.bar().baz.buzz()', + output: 'foo?.bar()?.baz?.buzz?.()', + canReplaceAndWithOr: true, + }, + // chained calls with element access + { + code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz]()', + output: 'foo?.bar?.baz?.[buzz]()', + canReplaceAndWithOr: true, + }, + { + code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz] && foo.bar.baz[buzz]()', + output: 'foo?.bar?.baz?.[buzz]?.()', + canReplaceAndWithOr: true, + }, + // (partially) pre-optional chained + { + code: 'foo && foo?.bar && foo?.bar.baz && foo?.bar.baz[buzz] && foo?.bar.baz[buzz]()', + output: 'foo?.bar?.baz?.[buzz]?.()', + canReplaceAndWithOr: true, + }, + { + code: 'foo && foo?.bar.baz && foo?.bar.baz[buzz]', + output: 'foo?.bar.baz?.[buzz]', + canReplaceAndWithOr: true, + }, + { + code: 'foo && foo?.() && foo?.().bar', + output: 'foo?.()?.bar', + canReplaceAndWithOr: true, + }, + { + code: 'foo.bar && foo.bar?.() && foo.bar?.().baz', + output: 'foo.bar?.()?.baz', + canReplaceAndWithOr: true, + }, + { + code: 'foo !== null && foo.bar !== null', + output: 'foo?.bar != null', + canReplaceAndWithOr: false, + }, + { + code: 'foo != null && foo.bar != null', + output: 'foo?.bar != null', + canReplaceAndWithOr: false, + }, + { + code: 'foo != null && foo.bar !== null', + output: 'foo?.bar != null', + canReplaceAndWithOr: false, + }, + { + code: 'foo !== null && foo.bar != null', + output: 'foo?.bar != null', + canReplaceAndWithOr: false, + }, +]; + +interface Selector { + all(): Array; + select>( + key: K, + value: BaseCase[K], + ): Selector; +} + +const selector = (cases: Array): Selector => ({ + all: () => cases.map(mapper), + select: >( + key: K, + value: BaseCase[K], + ): Selector => { + const selectedCases = baseCases.filter(c => c[key] === value); + return selector(selectedCases); + }, +}); + +const { all, select } = selector(baseCases); + +export { all, select }; diff --git a/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts b/packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts similarity index 85% rename from packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts rename to packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts index 120ad20aaea..ca783df13b3 100644 --- a/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts @@ -1,160 +1,11 @@ -import type { TSESLint } from '@typescript-eslint/utils'; - -import rule from '../../src/rules/prefer-optional-chain'; -import type { - InferMessageIdsTypeFromRule, - InferOptionsTypeFromRule, -} from '../../src/util'; -import { noFormat, RuleTester } from '../RuleTester'; +import rule from '../../../src/rules/prefer-optional-chain'; +import { noFormat, RuleTester } from '../../RuleTester'; +import * as BaseCases from './base-cases'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); -const baseCases = [ - // chained members - { - code: 'foo && foo.bar', - output: 'foo?.bar', - }, - { - code: 'foo.bar && foo.bar.baz', - output: 'foo.bar?.baz', - }, - { - code: 'foo && foo()', - output: 'foo?.()', - }, - { - code: 'foo.bar && foo.bar()', - output: 'foo.bar?.()', - }, - { - code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz', - output: 'foo?.bar?.baz?.buzz', - }, - { - code: 'foo.bar && foo.bar.baz && foo.bar.baz.buzz', - output: 'foo.bar?.baz?.buzz', - }, - // case with a jump (i.e. a non-nullish prop) - { - code: 'foo && foo.bar && foo.bar.baz.buzz', - output: 'foo?.bar?.baz.buzz', - }, - { - code: 'foo.bar && foo.bar.baz.buzz', - output: 'foo.bar?.baz.buzz', - }, - // case where for some reason there is a doubled up expression - { - code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz', - output: 'foo?.bar?.baz?.buzz', - }, - { - code: 'foo.bar && foo.bar.baz && foo.bar.baz && foo.bar.baz.buzz', - output: 'foo.bar?.baz?.buzz', - }, - // chained members with element access - { - code: 'foo && foo[bar] && foo[bar].baz && foo[bar].baz.buzz', - output: 'foo?.[bar]?.baz?.buzz', - }, - { - // case with a jump (i.e. a non-nullish prop) - code: 'foo && foo[bar].baz && foo[bar].baz.buzz', - output: 'foo?.[bar].baz?.buzz', - }, - // case with a property access in computed property - { - code: 'foo && foo[bar.baz] && foo[bar.baz].buzz', - output: 'foo?.[bar.baz]?.buzz', - }, - // case with this keyword - { - code: 'foo[this.bar] && foo[this.bar].baz', - output: 'foo[this.bar]?.baz', - }, - // chained calls - { - code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz()', - output: 'foo?.bar?.baz?.buzz()', - }, - { - code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz()', - output: 'foo?.bar?.baz?.buzz?.()', - }, - { - code: 'foo.bar && foo.bar.baz && foo.bar.baz.buzz && foo.bar.baz.buzz()', - output: 'foo.bar?.baz?.buzz?.()', - }, - // case with a jump (i.e. a non-nullish prop) - { - code: 'foo && foo.bar && foo.bar.baz.buzz()', - output: 'foo?.bar?.baz.buzz()', - }, - { - code: 'foo.bar && foo.bar.baz.buzz()', - output: 'foo.bar?.baz.buzz()', - }, - { - // case with a jump (i.e. a non-nullish prop) - code: 'foo && foo.bar && foo.bar.baz.buzz && foo.bar.baz.buzz()', - output: 'foo?.bar?.baz.buzz?.()', - }, - { - // case with a call expr inside the chain for some inefficient reason - code: 'foo && foo.bar() && foo.bar().baz && foo.bar().baz.buzz && foo.bar().baz.buzz()', - output: 'foo?.bar()?.baz?.buzz?.()', - }, - // chained calls with element access - { - code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz]()', - output: 'foo?.bar?.baz?.[buzz]()', - }, - { - code: 'foo && foo.bar && foo.bar.baz && foo.bar.baz[buzz] && foo.bar.baz[buzz]()', - output: 'foo?.bar?.baz?.[buzz]?.()', - }, - // (partially) pre-optional chained - { - code: 'foo && foo?.bar && foo?.bar.baz && foo?.bar.baz[buzz] && foo?.bar.baz[buzz]()', - output: 'foo?.bar?.baz?.[buzz]?.()', - }, - { - code: 'foo && foo?.bar.baz && foo?.bar.baz[buzz]', - output: 'foo?.bar.baz?.[buzz]', - }, - { - code: 'foo && foo?.() && foo?.().bar', - output: 'foo?.()?.bar', - }, - { - code: 'foo.bar && foo.bar?.() && foo.bar?.().baz', - output: 'foo.bar?.()?.baz', - }, -].map( - c => - ({ - code: c.code.trim(), - output: null, - errors: [ - { - messageId: 'preferOptionalChain', - suggestions: [ - { - messageId: 'optionalChainSuggest', - output: c.output.trim(), - }, - ], - }, - ], - } as TSESLint.InvalidTestCase< - InferMessageIdsTypeFromRule, - InferOptionsTypeFromRule - >), -); - ruleTester.run('prefer-optional-chain', rule, { valid: [ '!a || !b;', @@ -219,18 +70,18 @@ ruleTester.run('prefer-optional-chain', rule, { '!new.target || true;', ], invalid: [ - ...baseCases, + ...BaseCases.all(), // it should ignore whitespace in the expressions - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: c.code.replace(/\./g, '. '), })), - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: c.code.replace(/\./g, '.\n'), })), // it should ignore parts of the expression that aren't part of the expression chain - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: `${c.code} && bing`, errors: [ @@ -245,7 +96,7 @@ ruleTester.run('prefer-optional-chain', rule, { }, ], })), - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: `${c.code} && bing.bong`, errors: [ @@ -261,22 +112,42 @@ ruleTester.run('prefer-optional-chain', rule, { ], })), // strict nullish equality checks x !== null && x.y !== null - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: c.code.replace(/&&/g, '!== null &&'), })), - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: c.code.replace(/&&/g, '!= null &&'), })), - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: c.code.replace(/&&/g, '!== undefined &&'), })), - ...baseCases.map(c => ({ + ...BaseCases.all().map(c => ({ ...c, code: c.code.replace(/&&/g, '!= undefined &&'), })), + + // replace && with ||: foo && foo.bar -> !foo || !foo.bar + ...BaseCases.select('canReplaceAndWithOr', true) + .all() + .map(c => ({ + ...c, + code: c.code.replace(/(^|\s)foo/g, '$1!foo').replace(/&&/g, '||'), + errors: [ + { + ...c.errors[0], + suggestions: [ + { + ...c.errors[0].suggestions![0], + output: `!${c.errors[0].suggestions![0].output}`, + }, + ], + }, + ], + })), + // two errors { code: noFormat`foo && foo.bar && foo.bar.baz || baz && baz.bar && baz.bar.foo`, @@ -1211,21 +1082,6 @@ foo?.bar(/* comment */a, }, ], }, - ...baseCases.map(c => ({ - ...c, - code: c.code.replace(/foo/g, '!foo').replace(/&&/g, '||'), - errors: [ - { - ...c.errors[0], - suggestions: [ - { - ...c.errors[0].suggestions![0], - output: `!${c.errors[0].suggestions![0].output}`, - }, - ], - }, - ], - })), // case with this keyword at the start of expression { code: '!this.bar || !this.bar.baz;', From f17d34b74c83d4fed8dc4224d3594a6b44c19952 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 29 Jan 2023 20:44:01 -0500 Subject: [PATCH 03/21] docs(eslint-plugin): update site description of ban-types docs (#6209) --- packages/eslint-plugin/docs/rules/ban-types.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index 016b2a7217e..3f2e663669a 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -72,12 +72,6 @@ The default options provide a set of "best practices", intended to provide safet - This is a point of confusion for many developers, who think it means "any object type". - See [this comment for more information](https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492). -:::important - -The default options suggest using `Record`; this was a stylistic decision, as the built-in `Record` type is considered to look cleaner. - -::: -
Default Options @@ -115,15 +109,16 @@ const defaultTypes = { Object: { message: [ 'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.', - '- If you want a type meaning "any object", you probably want `Record` instead.', + '- If you want a type meaning "any object", you probably want `object` instead.', '- If you want a type meaning "any value", you probably want `unknown` instead.', ].join('\n'), }, '{}': { message: [ '`{}` actually means "any non-nullish value".', - '- If you want a type meaning "any object", you probably want `Record` instead.', + '- If you want a type meaning "any object", you probably want `object` instead.', '- If you want a type meaning "any value", you probably want `unknown` instead.', + '- If you want a type meaning "empty object", you probably want `Record` instead.', ].join('\n'), }, }; From 1623350899c5d0ac8776933ca99f0561d0ec1827 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 29 Jan 2023 20:44:14 -0500 Subject: [PATCH 04/21] docs(eslint-plugin): corrected eslint-plugin README.md getting started link (#6223) --- 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 b9dd0cecd03..9c98f8c7d4b 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -5,6 +5,6 @@ An ESLint plugin which provides lint rules for TypeScript codebases. [![NPM Version](https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) [![NPM Downloads](https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) -👉 See **https://typescript-eslint.io/architecture/utils** for our Getting Started docs. +👉 See **https://typescript-eslint.io/getting-started** for our Getting Started docs. > See https://typescript-eslint.io for general documentation on typescript-eslint, the tooling that allows you to run ESLint and Prettier on TypeScript code. From 403f2afc1a33f9ef3d6e4f6b97894c4773424815 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 29 Jan 2023 20:44:55 -0500 Subject: [PATCH 05/21] docs: explained tsconfigRootDir in website (#6236) --- docs/architecture/Parser.mdx | 3 ++- docs/linting/Typed_Linting.md | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/architecture/Parser.mdx b/docs/architecture/Parser.mdx index 9f5d51a53bb..d8d4f05ee43 100644 --- a/docs/architecture/Parser.mdx +++ b/docs/architecture/Parser.mdx @@ -226,7 +226,8 @@ For example, by default it will ensure that a glob like `./**/tsconfig.json` wil > Default `undefined`. -This option allows you to provide the root directory for relative tsconfig paths specified in the `project` option above. +This option allows you to provide the root directory for relative TSConfig paths specified in the `project` option above. +Doing so ensures running ESLint from a directory other than the root will still be able to find your TSConfig. ### `warnOnUnsupportedTypeScriptVersion` diff --git a/docs/linting/Typed_Linting.md b/docs/linting/Typed_Linting.md index 3e1beb396a8..65e2c875fff 100644 --- a/docs/linting/Typed_Linting.md +++ b/docs/linting/Typed_Linting.md @@ -8,30 +8,30 @@ To tap into TypeScript's additional powers, there are two small changes you need ```js title=".eslintrc.js" module.exports = { - root: true, - parser: '@typescript-eslint/parser', - // Added lines start - parserOptions: { - tsconfigRootDir: __dirname, - project: ['./tsconfig.json'], - }, - // Added lines end - plugins: ['@typescript-eslint'], extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', // Add this line 'plugin:@typescript-eslint/recommended-requiring-type-checking', ], + plugins: ['@typescript-eslint'], + parser: '@typescript-eslint/parser', + // Added lines start + parserOptions: { + project: ['./tsconfig.json'], + tsconfigRootDir: __dirname, + }, + // Added lines end + root: true, }; ``` In more detail: -- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory. +- `plugin:@typescript-eslint/recommended-requiring-type-checking` is another [recommended configuration](./CONFIGURATIONS.mdx) we provide. This one contains recommended rules that additionally require type information. - `parserOptions.project` tells our parser the relative path where your project's `tsconfig.json` is. - If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.md). -- `plugin:@typescript-eslint/recommended-requiring-type-checking` is another recommended configuration we provide. This one contains rules that specifically require type information. +- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory (see [Parser#tsconfigRootDir](../architecture/Parser.mdx#tsconfigRootDir)). With that done, run the same lint command you ran before. You may see new rules reporting errors based on type information! From e8d2af308eb9e82181e47c553d13cda65083e678 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 29 Jan 2023 21:09:43 -0500 Subject: [PATCH 06/21] docs: added Contributing > Discussions page (#6249) --- .cspell.json | 1 + docs/contributing/Discussions.md | 28 +++++++++++++++++++++++ docs/maintenance/ISSUES.md | 2 +- packages/website/sidebars/sidebar.base.js | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 docs/contributing/Discussions.md diff --git a/.cspell.json b/.cspell.json index f1806362b47..edd2532abf9 100644 --- a/.cspell.json +++ b/.cspell.json @@ -62,6 +62,7 @@ "declarators", "destructure", "destructured", + "discoverability", "dprint", "errored", "erroring", diff --git a/docs/contributing/Discussions.md b/docs/contributing/Discussions.md new file mode 100644 index 00000000000..52de9991409 --- /dev/null +++ b/docs/contributing/Discussions.md @@ -0,0 +1,28 @@ +--- +id: discussions +title: Discussions +--- + +Most proposals in the typescript-eslint repository happen in [GitHub Issues](https://docs.github.com/issues). +We generally try to keep conversations inside issues for their discoverability and ability to be linked to [GitHub Pull Requests](https://docs.github.com/pull-requests). + +We have [GitHub Discussions](https://docs.github.com/discussions) enabled to enable three kinds of deeper, threaded conversations: + +- **Community Feedback**: Questions from the maintainer team that should be raised to the broader community +- **RFCs (Requests For Comments)**: Formalized proposals for larger changes that should be discussed before turned into issues +- **Technical Discussions**: Deeper questions about typescript-eslint's architecture and/or APIs + +Before filing a Discussion, search the issue tracker for any related conversations. +Link to them in the Discussion, along with a detailed description of what you'd like to discuss. + +:::tip +For change proposals that match an [existing issue format](https://github.com/typescript-eslint/typescript-eslint/issues/new/choose), keep to filing issues. +Most don't need to be moved to this separate format. +We can always move an issue to a discussion if it becomes unexpectedly deep. +::: + +:::caution +Please don't use Discussions as a support forum. +We don't have the maintainer-budget to handle that. +See [Issues > Questions and Support Requests](./Issues.mdx#questions-and-support-requests). +::: diff --git a/docs/maintenance/ISSUES.md b/docs/maintenance/ISSUES.md index ebddcc6df1b..012ece57fff 100644 --- a/docs/maintenance/ISSUES.md +++ b/docs/maintenance/ISSUES.md @@ -3,7 +3,7 @@ id: issues title: Issues --- -This document serves as a guide for how you might manage issues, also known as issue triaging. +This document serves as a guide for how you might manage our [GitHub Issues](https://docs.github.com/issues), also known as issue triaging. Use your best judgement when triaging issues, and most of all remember to be **kind, friendly, and encouraging** when responding to users. Many users are new to open source and/or typed linting. diff --git a/packages/website/sidebars/sidebar.base.js b/packages/website/sidebars/sidebar.base.js index e6e7401727f..770ab620ec0 100644 --- a/packages/website/sidebars/sidebar.base.js +++ b/packages/website/sidebars/sidebar.base.js @@ -39,6 +39,7 @@ module.exports = { 'custom-rules', { items: [ + 'contributing/discussions', 'contributing/issues', 'contributing/local-development', 'contributing/pull-requests', From 2545b6828780612d31f270c4cba75bcbdcbc33c2 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 29 Jan 2023 21:16:52 -0500 Subject: [PATCH 07/21] docs(website): added maintenance docs for rule feature requests (#6254) --- docs/maintenance/ISSUES.md | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/docs/maintenance/ISSUES.md b/docs/maintenance/ISSUES.md index 012ece57fff..e7850e3a4b3 100644 --- a/docs/maintenance/ISSUES.md +++ b/docs/maintenance/ISSUES.md @@ -93,13 +93,41 @@ These bugs should be reported with a link to a GitHub repository that can be che If you cannot reproduce the issue as described using repository's README.md and issue description, it has not provided enough information. Consider using a specific response like the _Needs Full Reproduction_ response. -### ✨ Rule Enhancements +### 🏗 Feature Requests -TODO: This will be filled out... soon! +For any feature request, make sure the requested support is either: -### 🚀 New Rules +- Very useful for at least one commonly used way to run TypeScript (e.g. tsc-built CLI package; bundler-managed web app) +- Relevant for _most_ projects that would be using typescript-eslint -TODO: This will be filled out... soon! +We avoid features that: + +- Are only relevant for a minority of users, as they aren't likely worth the maintenance burden +- Aren't TypeScript-specific (e.g. should be in ESLint core instead) +- Are only relevant with specific userland frameworks or libraries, such as Jest or React +- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../linting/troubleshooting/FORMATTING.md)) + +#### ✨ Rule Enhancements + +We're generally accepting of rule enhancements that meet the above feature request criteria. +If a rule enhancement would substantially change the target area of the rule, consider whether it should instead be a new rule. +Common signs of this are the rule's original name now being inaccurate, or some options being relevant just for the old functionality. + +Enhancements that can cause new reports to be reported are considered breaking changes. +We have two common strategies for them: + +- Treat the enhancement as a breaking change, and block merging it until the next major version +- Add an option to disable the new logic: which is a breaking change if opt-in, and a non-breaking change if opt-out +- Add an option to enable the new logic: which is a breaking change if opt-out, and a non-breaking change if opt-in + +See [Can we standardize logical direction of rule options?](https://github.com/typescript-eslint/typescript-eslint/discussions/6101) for context on naming options. + +For enhancements meant to limit which kinds of nodes the rule targets, mark the issue as blocked on [RFC: Common format to specify a type or value as a rule option](https://github.com/typescript-eslint/typescript-eslint/discussions/6017). + +#### 🚀 New Rules + +We're generally accepting of new rules that meet the above feature request criteria. +The biggest exception is rules that can roughly be implemented with [`@typescript-eslint/ban-types`](https://typescript-eslint.io/rules/ban-types) and/or [`no-restricted-syntax`](https://eslint.org/docs/latest/rules/no-restricted-syntax). ## Pruning Old Issues From f53bcbc4ba9d67612b61340a2c98d12fe9186985 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 30 Jan 2023 02:31:23 -0500 Subject: [PATCH 08/21] chore(website): add links to and widen Silver Supporters (#6327) --- .../FinancialContributors/Sponsor.tsx | 34 ++++++++----------- .../FinancialContributors/Sponsors/index.tsx | 8 ++--- .../Sponsors/styles.module.css | 1 - .../FinancialContributors/index.tsx | 3 +- .../FinancialContributors/styles.module.css | 15 ++++---- .../components/FinancialContributors/types.ts | 5 --- 6 files changed, 29 insertions(+), 37 deletions(-) diff --git a/packages/website/src/components/FinancialContributors/Sponsor.tsx b/packages/website/src/components/FinancialContributors/Sponsor.tsx index 06f53dd438f..c50ab89b609 100644 --- a/packages/website/src/components/FinancialContributors/Sponsor.tsx +++ b/packages/website/src/components/FinancialContributors/Sponsor.tsx @@ -1,17 +1,17 @@ import React from 'react'; import styles from './styles.module.css'; -import type { SponsorData, SponsorIncludeOptions } from './types'; +import type { SponsorData } from './types'; interface SponsorProps { - include?: SponsorIncludeOptions; + includeName?: boolean; sponsor: SponsorData; } -export function Sponsor({ include = {}, sponsor }: SponsorProps): JSX.Element { +export function Sponsor({ includeName, sponsor }: SponsorProps): JSX.Element { let children = {`${sponsor.name}; - if (include.name) { + if (includeName) { children = ( <> {children} @@ -20,19 +20,15 @@ export function Sponsor({ include = {}, sponsor }: SponsorProps): JSX.Element { ); } - if (include.link) { - children = ( - - {children} - - ); - } - - return children; + return ( + + {children} + + ); } diff --git a/packages/website/src/components/FinancialContributors/Sponsors/index.tsx b/packages/website/src/components/FinancialContributors/Sponsors/index.tsx index dfcdad8c7b9..6c2d8874593 100644 --- a/packages/website/src/components/FinancialContributors/Sponsors/index.tsx +++ b/packages/website/src/components/FinancialContributors/Sponsors/index.tsx @@ -2,12 +2,12 @@ import clsx from 'clsx'; import React from 'react'; import { Sponsor } from '../Sponsor'; -import type { SponsorData, SponsorIncludeOptions } from '../types'; +import type { SponsorData } from '../types'; import styles from './styles.module.css'; interface SponsorsProps { className: string; - include?: SponsorIncludeOptions; + includeName?: boolean; expanded?: boolean; sponsors: SponsorData[]; title: string; @@ -16,7 +16,7 @@ interface SponsorsProps { export function Sponsors({ className, - include, + includeName, title, tier, sponsors, @@ -27,7 +27,7 @@ export function Sponsors({
    {sponsors.map(sponsor => (
  • - +
  • ))}
diff --git a/packages/website/src/components/FinancialContributors/Sponsors/styles.module.css b/packages/website/src/components/FinancialContributors/Sponsors/styles.module.css index b92051eddcb..526e1ab745e 100644 --- a/packages/website/src/components/FinancialContributors/Sponsors/styles.module.css +++ b/packages/website/src/components/FinancialContributors/Sponsors/styles.module.css @@ -82,7 +82,6 @@ .tierArea { margin: 16px 0; width: auto; - padding: 0 60px; } .tier-gold-supporter { diff --git a/packages/website/src/components/FinancialContributors/index.tsx b/packages/website/src/components/FinancialContributors/index.tsx index d71bd065004..0460e1e8694 100644 --- a/packages/website/src/components/FinancialContributors/index.tsx +++ b/packages/website/src/components/FinancialContributors/index.tsx @@ -16,14 +16,13 @@ export function FinancialContributors(): JSX.Element {
Date: Mon, 30 Jan 2023 02:33:27 -0500 Subject: [PATCH 09/21] chore(website): mention 3 months SLA for issue and PR questions (#6313) --- docs/contributing/Issues.mdx | 1 + docs/contributing/Pull_Requests.mdx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/contributing/Issues.mdx b/docs/contributing/Issues.mdx index ae61dd0e312..d577248b2e6 100644 --- a/docs/contributing/Issues.mdx +++ b/docs/contributing/Issues.mdx @@ -21,6 +21,7 @@ Please don't: - Leave useless comments such as _"+1"_ or _"when's this getting fixed?"_ that only act as spam - If you have nothing to add but enthusiasm and joy, add a reaction such as 👍 + - One exception: if an issue has been blocked on a question to a maintainer for 3 or more months, please ping us - we probably lost track of it - Bring up unrelated topics in existing issues: instead, file a new issue - Comment on closed PRs: instead, [file a new issue](#raising-issues) - Comment on commits directly, as those comments are not searchable: instead, file a new issue diff --git a/docs/contributing/Pull_Requests.mdx b/docs/contributing/Pull_Requests.mdx index edb76feb7d6..c5af830718c 100644 --- a/docs/contributing/Pull_Requests.mdx +++ b/docs/contributing/Pull_Requests.mdx @@ -19,8 +19,9 @@ Please don't: - Force push after opening a PR - Reasoning: GitHub is not able to track changes across force pushes, which makes it take longer for us to perform incremental reviews -- Comment asking for updates +- Comment on an existing PR asking for updates - Reasoning: Your PR hasn't been forgotten! The volunteer maintainers have limited time to work on the project, and they will get to it as soon as they are able. + - One exception: if a PR has been blocked on a question to a maintainer for 3 or more months, please ping us - we probably lost track of it. ### Raising a PR From 4b27777ed26cc83d6efc52a89b2d3fc6c01bc0d7 Mon Sep 17 00:00:00 2001 From: Yuri Pieters Date: Mon, 30 Jan 2023 07:39:36 +0000 Subject: [PATCH 10/21] fix(ast-spec): a JSXEmptyExpression is not a possible JSXExpression (#6321) --- packages/ast-spec/src/unions/JSXExpression.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/ast-spec/src/unions/JSXExpression.ts b/packages/ast-spec/src/unions/JSXExpression.ts index 78dfad53525..d30c150cc6f 100644 --- a/packages/ast-spec/src/unions/JSXExpression.ts +++ b/packages/ast-spec/src/unions/JSXExpression.ts @@ -1,8 +1,4 @@ -import type { JSXEmptyExpression } from '../jsx/JSXEmptyExpression/spec'; import type { JSXExpressionContainer } from '../jsx/JSXExpressionContainer/spec'; import type { JSXSpreadChild } from '../jsx/JSXSpreadChild/spec'; -export type JSXExpression = - | JSXEmptyExpression - | JSXExpressionContainer - | JSXSpreadChild; +export type JSXExpression = JSXExpressionContainer | JSXSpreadChild; From 587bd4ebc71061bc652f9a82ede250558785494b Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 30 Jan 2023 15:05:09 -0500 Subject: [PATCH 11/21] docs: describe update steps for ESLint, Node, and TypeScript (#6251) * docs: describe update steps for ESLint, Node, and TypeScript * lil typo fix, and a heart * Finalize VERSIONING/Versioning.md rename --- .../{VERSIONING.md => Versioning.md} | 29 +++-- .../versioning/dependant-version-upgrades.mdx | 121 ++++++++++++++++++ .../src/parseSettings/warnAboutTSVersion.ts | 2 +- packages/website/sidebars/sidebar.base.js | 11 +- 4 files changed, 147 insertions(+), 16 deletions(-) rename docs/maintenance/{VERSIONING.md => Versioning.md} (95%) create mode 100644 docs/maintenance/versioning/dependant-version-upgrades.mdx diff --git a/docs/maintenance/VERSIONING.md b/docs/maintenance/Versioning.md similarity index 95% rename from docs/maintenance/VERSIONING.md rename to docs/maintenance/Versioning.md index 0dd31ae90c1..d9a4224dbf8 100644 --- a/docs/maintenance/VERSIONING.md +++ b/docs/maintenance/Versioning.md @@ -1,6 +1,5 @@ --- id: versioning -sidebar_label: Versioning title: Versioning --- @@ -28,9 +27,22 @@ During these periods, we manually publish `canary` releases until we are happy w ## Dependant Versions +> See [Versioning > Dependant Version Upgrades](./versioning/dependant-version-upgrades.mdx) for maintenance steps to update these versions. + +### ESLint + +> The version range of ESLint currently supported is `^6.0.0 || ^7.0.0 || ^8.0.0`. + +We generally support at least the latest two major versions of ESLint. + +### Node + +This project makes an effort to support Active LTS and Maintenance LTS release statuses of Node according to [Node's release document](https://nodejs.org/en/about/releases). +Support for specific Current status releases are considered periodically. + ### TypeScript -> The version range of TypeScript currently supported is `>=3.3.1 <4.9.0`. +> The version range of TypeScript currently supported is `>=3.3.1 <5.0.0`. These versions are what we test against. @@ -42,18 +54,7 @@ Note that our packages have an open `peerDependency` requirement in order to all If you use a non-supported version of TypeScript, the parser will log a warning to the console. If you want to disable this warning, you can configure this in your `parserOptions`. -See: [`@typescript-eslint/parser`](./packages/parser/ TODO JOSH) and [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/ TODO JOSH). - -### ESLint - -> The version range of ESLint currently supported is `^6.0.0 || ^7.0.0 || ^8.0.0`. - -We generally support at least the latest two major versions of ESLint. - -### Node - -This project makes an effort to support Active LTS and Maintenance LTS release statuses of Node according to [Node's release document](https://nodejs.org/en/about/releases). -Support for specific Current status releases are considered periodically. +See: [Parser > `warnOnUnsupportedTypeScriptVersion`](../architecture/Parser.mdx#warnonunsupportedtypescriptversion). ## Breaking Changes diff --git a/docs/maintenance/versioning/dependant-version-upgrades.mdx b/docs/maintenance/versioning/dependant-version-upgrades.mdx new file mode 100644 index 00000000000..49ba51ce1e4 --- /dev/null +++ b/docs/maintenance/versioning/dependant-version-upgrades.mdx @@ -0,0 +1,121 @@ +--- +id: dependant-version-upgrades +title: Dependant Version Upgrades +--- + +## ESLint + +The typescript-eslint repository contains four kinds of version ranges for the `eslint` package: + +- Integration tests: Pinned to our lowest supported ESLint version +- Packages with a `*` `peerDependency` version: These fall back to the explicit `peerDependency` versions +- Packages with explicit `peerDependency` versions: The full range of supported ESLint major versions +- [Root `package.json`](https://github.com/typescript-eslint/typescript-eslint/blob/main/package.json)'s' `devDependency`: A relatively recent release, used only for repository development + +:::tip +Whenever you discover any new areas of work that are blocked by dropping an old ESLint version, such as new ESLint API deprecations, add a _TODO_ comment that will be caught by the regular expressions under [Removing Support for an Old ESLint Version](#removing-support-for-an-old-eslint-version). +::: + +### Adding Support for a New ESLint Version + +1. Upgrade the root `package.json` `devDependency` to the latest ESLint +1. Add the new major version to the explicit `peerDependency` versions +1. Check [`eslint-visitor-keys`](https://www.npmjs.com/package/eslint-visitor-keys) for a new version to be upgraded to as well. +1. Update [Versioning > ESLint](../Versioning.md#eslint) + +### Removing Support for an Old ESLint Version + +1. Increase the integration tests to the next lowest supported major version (`*.0.0`) +1. Remove the old major versions from packages with explicit `peerDependency` versions +1. Search for source code comments (excluding `CHANGELOG.md` files) that mention a now-unsupported version of ESLint. + - For example, to remove support for v5, searches might include: + - `/eslint.*5/i` + - `/todo.*eslint.*5/i` + - `/todo.*eslint/i` +1. Update [Versioning > ESLint](../Versioning.md#eslint) + +See [chore: drop support for ESLint v6](https://github.com/typescript-eslint/typescript-eslint/pull/5972) for reference. + +## Node + +The typescript-eslint repository contains three kinds of version ranges for Node: + +- [`.github/workflows/ci.yml`](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/workflows/ci.yml)'s `PRIMARY_NODE_VERSION`: Set to the highest Node version we support +- `node-version`: Set to a tuple of our [lowest, highest] supported versions for our unit tests in CI +- `engines` field in all `package.json`s: explicitly lists all supported Node ranges + +Change those numbers accordingly when adding support for a new Node version or removing support for an old Node version. + +See [feat: drop support for node v12](https://github.com/typescript-eslint/typescript-eslint/pull/5918) + [chore: test node v14 on ci.yml](https://github.com/typescript-eslint/typescript-eslint/pull/5512) for reference. + +## TypeScript + +### Adding Support for a New TypeScript Version + +We generally start the process of supporting a new TypeScript version just after the first beta release for that version is made available. + +1. Create and pin an issue with a title like _TypeScript X.Y Support_, `accepting prs`, `AST`, `dependencies`, and `New TypeScript Version` labels, and the following contents: + + 1. A link to the _TypeScript X.Y Iteration Plan_ issue from the Microsoft issue tracker + 2. The following text: + + ```md + This issue is just to track all of the new features and their implementation state in this project. + As with all releases, we will not necessarily support all features until closer to the full release when everything the features are stabilised. + + _Please be patient._ ❤️ + ``` + + 3. A heading starting with `🔲 ` for each new TypeScript feature called out in the iteration plan that will impact us + 4. A heading titled _🔲 `lib.d.ts` Updates_ and the content _We will need to regenerate our types within `scope-manager`_ + 5. A heading titled _Other changes with no impact to us_ containing a list of other changes that we don't believe will impact us + +1. At this stage, it's fine to send and/or review PRs that implement necessary features, but wait to merge them until the new TypeScript version's RC is released + - Whenever a PR is created, add ` (#1234)` to its respective heading, and change the heading's emoji from 🔲 to 🏗 + - Search for `expectBabelToNotSupport` to see how to support syntaxes not yet supported by Babel +1. Once the TypeScript RC version is released, start merging PRs + - Whenever a PR is merged, change the respective heading's emoji from 🏗 to ✅ +1. Create a PR with a title like `feat: update TypeScript to X.Y-rc` and the following changes: + - In the root `package.json`, add `|| X.Y.2-rc2` to the `dependency` on `typescript` + - In the root `package.json`, change the `devDependency` on `typescript` to `~X.Y.2-rc2` + - Change the `SUPPORTED_TYPESCRIPT_VERSIONS` constant's `<` version to the next version of TypeScript + - Change the `SUPPORTED_PRERELEASE_RANGES` constant to equal `['X.Y.2-rc']` + - Rename and update `patches/typescript*` to the new TypeScript version + - Run `yarn generate:lib` to update `scope-manager` +1. Once all PRs needed for the RC update PR are merged, merge the RC update PR +1. Once TypeScript releases the stable X.Y version, create and merge a PR with a title like `chore: bump TypeScript from X.YRC to X.Y` and the following changes: + - In the root `package.json`, remove `|| X.Y.2-rc2` from the `dependency` on `typescript`, and bump its `<` version to the next version of TypeScript + - In the root `package.json`, change the `devDependency` on `typescript` to `~X.Y.3` + - Rename and update `patches/typescript*` to the new TypeScript version + - Any other changes made necessary due to changes in TypeScript between the RC version and stable version + - Update the supported version range in [Versioning](../Versioning.md) +1. Update [Versioning > TypeScript](../Versioning.md#typescript) +1. Send a PR that updates this documentation page to point to your newer issues and PRs + - Also update any of these steps if you go with a different process + +See for reference (caveat: these don't follow the exact process described here): + +- [TypeScript 4.7 Support](https://github.com/typescript-eslint/typescript-eslint/issues/4800) +- [TypeScript 4.8 Support](https://github.com/typescript-eslint/typescript-eslint/issues/5227) +- [feat: support TypeScript 4.8](https://github.com/typescript-eslint/typescript-eslint/pull/5551) +- [feat: support TypeScript 4.9](https://github.com/typescript-eslint/typescript-eslint/pull/5716) +- [chore: bump TS from 4.9RC to 4.9](https://github.com/typescript-eslint/typescript-eslint/commit/a40a311bb52a2b1cfac43851b201f8cfc96c8d5d) + +### Removing Support for an Old TypeScript Version + +A single PR can remove support for old TypeScript versions as a breaking change: + +1. Update the root `package.json` `devDependency` +1. Update the `SUPPORTED_TYPESCRIPT_VERSIONS` constant in `warnAboutTSVersion.ts` +1. Update the `versions` constant in `version-check.ts` +1. Update [Versioning > TypeScript](../Versioning.md#typescript) +1. Search for source code comments (excluding `CHANGELOG.md` files) that mention a now-unsupported version of TypeScript. + - For example, to remove support for v4.3, searches might include: + - `4.3` + - `/is.*4.*3/i` + - `/semver.*4.*3/i` + - `/semver.satisfies/` + - `/todo.*ts/i` + - `/todo.*typescript/i` + +See [feat: bump minimum supported TS version to 4.2.4](https://github.com/typescript-eslint/typescript-eslint/pull/5915). diff --git a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts index 191ac029325..13eef19e796 100644 --- a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts +++ b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts @@ -3,7 +3,7 @@ import * as ts from 'typescript'; import type { ParseSettings } from './index'; /** - * This needs to be kept in sync with /docs/maintenance/VERSIONING.md + * This needs to be kept in sync with /docs/maintenance/Versioning.md * in the typescript-eslint monorepo */ const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <5.0.0'; diff --git a/packages/website/sidebars/sidebar.base.js b/packages/website/sidebars/sidebar.base.js index 770ab620ec0..7f0de759728 100644 --- a/packages/website/sidebars/sidebar.base.js +++ b/packages/website/sidebars/sidebar.base.js @@ -82,7 +82,16 @@ module.exports = { }, 'maintenance/pull-requests', 'maintenance/releases', - 'maintenance/versioning', + { + collapsible: false, + items: ['maintenance/versioning/dependant-version-upgrades'], + label: 'Versioning', + link: { + id: 'maintenance/versioning', + type: 'doc', + }, + type: 'category', + }, ], label: 'Maintenance', link: { From ca190def071c56c0ebbdbbdfdcb31d2eb2c11809 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 30 Jan 2023 15:06:52 -0500 Subject: [PATCH 12/21] chore(website): reorganized sidebar and header nav a bit (#6311) * chore(website): reorganized sidebar and header nav a bit * Fix Formatting.md link case --- docs/maintenance/ISSUES.md | 2 +- packages/website/docusaurusConfig.ts | 2 +- packages/website/sidebars/sidebar.base.js | 28 +++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/maintenance/ISSUES.md b/docs/maintenance/ISSUES.md index e7850e3a4b3..fb5eb655dd6 100644 --- a/docs/maintenance/ISSUES.md +++ b/docs/maintenance/ISSUES.md @@ -105,7 +105,7 @@ We avoid features that: - Are only relevant for a minority of users, as they aren't likely worth the maintenance burden - Aren't TypeScript-specific (e.g. should be in ESLint core instead) - Are only relevant with specific userland frameworks or libraries, such as Jest or React -- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../linting/troubleshooting/FORMATTING.md)) +- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../linting/troubleshooting/Formatting.md)) #### ✨ Rule Enhancements diff --git a/packages/website/docusaurusConfig.ts b/packages/website/docusaurusConfig.ts index bfa844fc2f0..ab543e80783 100644 --- a/packages/website/docusaurusConfig.ts +++ b/packages/website/docusaurusConfig.ts @@ -76,7 +76,7 @@ const themeConfig: ThemeCommonConfig & AlgoliaThemeConfig = { items: [ { to: 'getting-started/', - label: 'Getting started', + label: 'Docs', position: 'left', }, { diff --git a/packages/website/sidebars/sidebar.base.js b/packages/website/sidebars/sidebar.base.js index 7f0de759728..2a097b02a70 100644 --- a/packages/website/sidebars/sidebar.base.js +++ b/packages/website/sidebars/sidebar.base.js @@ -37,20 +37,6 @@ module.exports = { type: 'category', }, 'custom-rules', - { - items: [ - 'contributing/discussions', - 'contributing/issues', - 'contributing/local-development', - 'contributing/pull-requests', - ], - label: 'Contributing', - link: { - id: 'contributing', - type: 'doc', - }, - type: 'category', - }, { items: [ 'architecture/eslint-plugin', @@ -67,6 +53,20 @@ module.exports = { }, type: 'category', }, + { + items: [ + 'contributing/discussions', + 'contributing/issues', + 'contributing/local-development', + 'contributing/pull-requests', + ], + label: 'Contributing', + link: { + id: 'contributing', + type: 'doc', + }, + type: 'category', + }, { items: [ 'maintenance/branding', From 202d9fb3209c87f25671119296046ef78270b558 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 23:40:14 +0000 Subject: [PATCH 13/21] chore(deps): update dependency eslint-plugin-simple-import-sort to v10 (#6391) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 78 ++++------------------------------------------------ 2 files changed, 7 insertions(+), 73 deletions(-) diff --git a/package.json b/package.json index 16fef2bf3ba..8324e5d971d 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "eslint-plugin-eslint-plugin": "^5.0.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jest": "^27.0.0", - "eslint-plugin-simple-import-sort": "^9.0.0", + "eslint-plugin-simple-import-sort": "^10.0.0", "execa": "5.1.1", "glob": "^8.0.1", "husky": "^8.0.1", diff --git a/yarn.lock b/yarn.lock index a1ed8351014..e88792c6fec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3246,13 +3246,6 @@ read-package-json-fast "^2.0.3" which "^2.0.2" -"@nrwl/cli@15.4.5": - version "15.4.5" - resolved "https://registry.yarnpkg.com/@nrwl/cli/-/cli-15.4.5.tgz#2a8f663e5265379812ba83c0577abdc94dcdba8f" - integrity sha512-f13s0/hzS9jsV1+QPr1Lp3Um+3dOHD8gEP2h7uw17rEPrtJ5ggRKMj/HcZ9dkT9zDM9EmPtVTb6k38ON+NWcUw== - dependencies: - nx "15.4.5" - "@nrwl/cli@15.5.3": version "15.5.3" resolved "https://registry.npmjs.org/@nrwl/cli/-/cli-15.5.3.tgz#13277e5a0e8ba713850bcf13fa76717ea747a2bb" @@ -3260,7 +3253,7 @@ dependencies: nx "15.5.3" -"@nrwl/devkit@15.5.3": +"@nrwl/devkit@15.5.3", "@nrwl/devkit@>=15.4.2 < 16": version "15.5.3" resolved "https://registry.npmjs.org/@nrwl/devkit/-/devkit-15.5.3.tgz#16fac0147c2ab6ebba7b5357b2b959ad46b6eb26" integrity sha512-GGNLLGXDGWflrpaLimnE6hChfZfq3+XWZ0LJWL0IuCnchngPbNzuyh8S8KPgNKKgq4Nv0hglWefIwMg2UhHysA== @@ -3271,17 +3264,6 @@ semver "7.3.4" tslib "^2.3.0" -"@nrwl/devkit@>=15.4.2 < 16": - version "15.4.5" - resolved "https://registry.yarnpkg.com/@nrwl/devkit/-/devkit-15.4.5.tgz#22b7aa16bc14c171f061f770060d9af480d5f1cb" - integrity sha512-oag+wJgusKz+rwvgcVy9i8bNtTo7ikbjVVtSOmyVBE0ZrgN1CMFjugBj4FEjKGtd73djjpvW9Mm36uJRujrc2w== - dependencies: - "@phenomnomnominal/tsquery" "4.1.1" - ejs "^3.1.7" - ignore "^5.0.4" - semver "7.3.4" - tslib "^2.3.0" - "@nrwl/jest@15.5.3": version "15.5.3" resolved "https://registry.npmjs.org/@nrwl/jest/-/jest-15.5.3.tgz#492ab42ac3171354a9afd6f93a7c43a6c56b3f61" @@ -3324,13 +3306,6 @@ tar "6.1.11" yargs-parser ">=21.0.1" -"@nrwl/tao@15.4.5": - version "15.4.5" - resolved "https://registry.yarnpkg.com/@nrwl/tao/-/tao-15.4.5.tgz#d07f6d06cecb6acb84259e0654cfc59fcc5edd53" - integrity sha512-UMtxXxTWqbyZOdyD9Zt2IsDY/JVXIFZtY6pO4jPha7+UIHWf2Zi8Dszs6UoUTS4mqpNMIkKymwpZGtkDTfiAJA== - dependencies: - nx "15.4.5" - "@nrwl/tao@15.5.3": version "15.5.3" resolved "https://registry.npmjs.org/@nrwl/tao/-/tao-15.5.3.tgz#08c05715d2ecb108ed8b2c5381b9017cf1448b4a" @@ -7135,10 +7110,10 @@ eslint-plugin-react@^7.29.4: semver "^6.3.0" string.prototype.matchall "^4.0.7" -eslint-plugin-simple-import-sort@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-9.0.0.tgz#04c97f06a2e526afd40e0ac694b70d1aaaec1aef" - integrity sha512-PtrLjyXP8kjRneWT1n0b99y/2Fyup37we7FVoWsI61/O7x4ztLohzhep/pxI/cYlECr/cQ2j6utckdvWpVwXNA== +eslint-plugin-simple-import-sort@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-10.0.0.tgz#cc4ceaa81ba73252427062705b64321946f61351" + integrity sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw== eslint-scope@5.1.1, eslint-scope@^5.1.1: version "5.1.1" @@ -10794,48 +10769,7 @@ nth-check@^2.0.0, nth-check@^2.0.1: dependencies: boolbase "^1.0.0" -nx@15.4.5, "nx@>=15.4.2 < 16": - version "15.4.5" - resolved "https://registry.yarnpkg.com/nx/-/nx-15.4.5.tgz#12daa740256fa29ba634fbc4f3f87b6d078c2990" - integrity sha512-1spZL6sgOV8JJJuN8W5CLtJYwTOnlyaV32jPXfidavU0QMS8MP+rW3+NUQ9Uzc1UYhOu8llZWtnen93neVGQRw== - dependencies: - "@nrwl/cli" "15.4.5" - "@nrwl/tao" "15.4.5" - "@parcel/watcher" "2.0.4" - "@yarnpkg/lockfile" "^1.1.0" - "@yarnpkg/parsers" "^3.0.0-rc.18" - "@zkochan/js-yaml" "0.0.6" - axios "^1.0.0" - chalk "4.1.0" - chokidar "^3.5.1" - cli-cursor "3.1.0" - cli-spinners "2.6.1" - cliui "^7.0.2" - dotenv "~10.0.0" - enquirer "~2.3.6" - fast-glob "3.2.7" - figures "3.2.0" - flat "^5.0.2" - fs-extra "^10.1.0" - glob "7.1.4" - ignore "^5.0.4" - js-yaml "4.1.0" - jsonc-parser "3.2.0" - minimatch "3.0.5" - npm-run-path "^4.0.1" - open "^8.4.0" - semver "7.3.4" - string-width "^4.2.3" - strong-log-transformer "^2.1.0" - tar-stream "~2.2.0" - tmp "~0.2.1" - tsconfig-paths "^4.1.2" - tslib "^2.3.0" - v8-compile-cache "2.3.0" - yargs "^17.6.2" - yargs-parser "21.1.1" - -nx@15.5.3: +nx@15.5.3, "nx@>=15.4.2 < 16": version "15.5.3" resolved "https://registry.npmjs.org/nx/-/nx-15.5.3.tgz#bf6252e7d9e17121dd82dec4f6fce319b9e005fa" integrity sha512-PHB8VbiBLP108xb+yR8IGEsYWr7OcmDDOjHL+73oP4lVjyPgT8wdTMe6tI5LdBgv+KZ+0kiThK3ckvcPsfgvLQ== From 85e783c1fabe96d390729a5796d6d346e401692b Mon Sep 17 00:00:00 2001 From: Omri Luzon Date: Tue, 31 Jan 2023 09:21:23 +0200 Subject: [PATCH 14/21] fix(eslint-plugin): [prefer-optional-chain] fix `ThisExpression` and `PrivateIdentifier` errors (#6028) --- .../src/rules/prefer-optional-chain.ts | 46 +++++++++++++------ .../prefer-optional-chain.test.ts | 15 +++++- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index f5ed3ccb589..efccc2ccfd2 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -10,6 +10,7 @@ type ValidChainTarget = | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.Identifier + | TSESTree.PrivateIdentifier | TSESTree.MemberExpression | TSESTree.ThisExpression | TSESTree.MetaProperty; @@ -164,7 +165,9 @@ export default util.createRule({ break; } + let invalidOptionallyChainedPrivateProperty; ({ + invalidOptionallyChainedPrivateProperty, expressionCount, previousLeftText, optionallyChainedCode, @@ -178,6 +181,9 @@ export default util.createRule({ previous, current, )); + if (invalidOptionallyChainedPrivateProperty) { + return; + } } reportIfMoreThanOne({ @@ -243,7 +249,9 @@ export default util.createRule({ break; } + let invalidOptionallyChainedPrivateProperty; ({ + invalidOptionallyChainedPrivateProperty, expressionCount, previousLeftText, optionallyChainedCode, @@ -257,6 +265,9 @@ export default util.createRule({ previous, current, )); + if (invalidOptionallyChainedPrivateProperty) { + return; + } } reportIfMoreThanOne({ @@ -343,7 +354,10 @@ export default util.createRule({ return `${calleeText}${argumentsText}`; } - if (node.type === AST_NODE_TYPES.Identifier) { + if ( + node.type === AST_NODE_TYPES.Identifier || + node.type === AST_NODE_TYPES.PrivateIdentifier + ) { return node.name; } @@ -381,15 +395,12 @@ export default util.createRule({ // cases should match the list in ALLOWED_MEMBER_OBJECT_TYPES switch (node.object.type) { - case AST_NODE_TYPES.CallExpression: - case AST_NODE_TYPES.Identifier: - objectText = getText(node.object); - break; - case AST_NODE_TYPES.MemberExpression: objectText = getMemberExpressionText(node.object); break; + case AST_NODE_TYPES.CallExpression: + case AST_NODE_TYPES.Identifier: case AST_NODE_TYPES.MetaProperty: case AST_NODE_TYPES.ThisExpression: objectText = getText(node.object); @@ -397,7 +408,7 @@ export default util.createRule({ /* istanbul ignore next */ default: - throw new Error(`Unexpected member object type: ${node.object.type}`); + return ''; } let propertyText: string; @@ -420,9 +431,7 @@ export default util.createRule({ /* istanbul ignore next */ default: - throw new Error( - `Unexpected member property type: ${node.object.type}`, - ); + return ''; } return `${objectText}${node.optional ? '?.' : ''}[${propertyText}]`; @@ -432,12 +441,12 @@ export default util.createRule({ case AST_NODE_TYPES.Identifier: propertyText = getText(node.property); break; + case AST_NODE_TYPES.PrivateIdentifier: + propertyText = '#' + getText(node.property); + break; - /* istanbul ignore next */ default: - throw new Error( - `Unexpected member property type: ${node.object.type}`, - ); + propertyText = sourceCode.getText(node.property); } return `${objectText}${node.optional ? '?.' : '.'}${propertyText}`; @@ -461,6 +470,7 @@ const ALLOWED_COMPUTED_PROP_TYPES: ReadonlySet = new Set([ ]); const ALLOWED_NON_COMPUTED_PROP_TYPES: ReadonlySet = new Set([ AST_NODE_TYPES.Identifier, + AST_NODE_TYPES.PrivateIdentifier, ]); interface ReportIfMoreThanOneOptions { @@ -525,6 +535,7 @@ function reportIfMoreThanOne({ } interface NormalizedPattern { + invalidOptionallyChainedPrivateProperty: boolean; expressionCount: number; previousLeftText: string; optionallyChainedCode: string; @@ -541,6 +552,7 @@ function normalizeRepeatingPatterns( current: TSESTree.Node, ): NormalizedPattern { const leftText = previousLeftText; + let invalidOptionallyChainedPrivateProperty = false; // omit weird doubled up expression that make no sense like foo.bar && foo.bar if (rightText !== previousLeftText) { expressionCount += 1; @@ -576,6 +588,11 @@ function normalizeRepeatingPatterns( diff === '?.buzz' */ const diff = rightText.replace(leftText, ''); + if (diff.startsWith('.#')) { + // Do not handle direct optional chaining on private properties because of a typescript bug (https://github.com/microsoft/TypeScript/issues/42734) + // We still allow in computed properties + invalidOptionallyChainedPrivateProperty = true; + } if (diff.startsWith('?')) { // item was "pre optional chained" optionallyChainedCode += diff; @@ -591,6 +608,7 @@ function normalizeRepeatingPatterns( util.NullThrowsReasons.MissingParent, ); return { + invalidOptionallyChainedPrivateProperty, expressionCount, previousLeftText, optionallyChainedCode, diff --git a/packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts b/packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts index ca783df13b3..a18de12bf7b 100644 --- a/packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts @@ -45,6 +45,16 @@ ruleTester.run('prefer-optional-chain', rule, { 'match && match$1 !== undefined;', 'foo !== null && foo !== undefined;', "x['y'] !== undefined && x['y'] !== null;", + // private properties + 'this.#a && this.#b;', + '!this.#a || !this.#b;', + 'a.#foo?.bar;', + '!a.#foo?.bar;', + '!foo().#a || a;', + '!a.b.#a || a;', + '!new A().#b || a;', + '!(await a).#b || a;', + "!(foo as any).bar || 'anything';", // currently do not handle complex computed properties 'foo && foo[bar as string] && foo[bar as string].baz;', 'foo && foo[1 + 2] && foo[1 + 2].baz;', @@ -68,6 +78,10 @@ ruleTester.run('prefer-optional-chain', rule, { '!import.meta && !import.meta.foo;', 'new.target || new.target.length;', '!new.target || true;', + // Do not handle direct optional chaining on private properties because of a typescript bug (https://github.com/microsoft/TypeScript/issues/42734) + // We still allow in computed properties + 'foo && foo.#bar;', + '!foo || !foo.#bar;', ], invalid: [ ...BaseCases.all(), @@ -1240,7 +1254,6 @@ foo?.bar(/* comment */a, }, ], }, - { code: noFormat`import.meta && import.meta?.() && import.meta?.().baz;`, output: null, From a3ba163ccd73cf369c18493d5393003cc932cc23 Mon Sep 17 00:00:00 2001 From: James Henry Date: Tue, 31 Jan 2023 13:12:09 +0400 Subject: [PATCH 15/21] chore: update nx to 15.6 (#6387) --- nx.json | 35 ++++-- package.json | 6 +- packages/ast-spec/project.json | 2 +- packages/shared-fixtures/project.json | 4 +- .../type-utils/tests/isTypeReadonly.test.ts | 2 +- packages/website-eslint/project.json | 4 +- yarn.lock | 110 +++++++++++++----- 7 files changed, 113 insertions(+), 50 deletions(-) diff --git a/nx.json b/nx.json index b34a91f7800..731dc56a3c7 100644 --- a/nx.json +++ b/nx.json @@ -1,22 +1,12 @@ { "$schema": "./node_modules/nx/schemas/nx-schema.json", "npmScope": "typescript-eslint", - "affected": { - "defaultBase": "main" - }, - "workspaceLayout": { - "libsDir": "packages" - }, "tasksRunnerOptions": { "default": { "runner": "@nrwl/nx-cloud", "options": { "cacheableOperations": ["build", "lint", "package", "prebuild", "test"], - "accessToken": "YjFjNTBhOWUtY2JmNy00ZDhiLWE5N2UtZjliNDAwNmIzOTdjfHJlYWQtd3JpdGU=", - "canTrackAnalytics": false, - "showUsageWarnings": true, - "runtimeCacheInputs": ["node -v", "echo $NETLIFY"], - "parallel": 1 + "accessToken": "YjFjNTBhOWUtY2JmNy00ZDhiLWE5N2UtZjliNDAwNmIzOTdjfHJlYWQtd3JpdGU=" } } }, @@ -26,11 +16,32 @@ "inputs": ["production", "^production"] }, "test": { + "inputs": [ + "default", + "{workspaceRoot}/jest.config.js", + "{workspaceRoot}/jest.config.base.js" + ], "outputs": ["{projectRoot}/coverage"] + }, + "lint": { + "inputs": [ + "default", + "{workspaceRoot}/.eslintrc.js", + "{workspaceRoot}/.eslintignore" + ] } }, "namedInputs": { - "default": ["{projectRoot}/**/*", "sharedGlobals"], + "default": [ + "{projectRoot}/**/*", + "sharedGlobals", + { + "runtime": "node -v" + }, + { + "runtime": "echo $NETLIFY" + } + ], "sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"], "production": ["default"] } diff --git a/package.json b/package.json index 8324e5d971d..f8b24d34edf 100644 --- a/package.json +++ b/package.json @@ -54,9 +54,9 @@ "@babel/eslint-parser": "^7.19.1", "@babel/parser": "^7.20.7", "@babel/types": "^7.20.2", - "@nrwl/jest": "15.5.3", + "@nrwl/jest": "15.6.3", "@nrwl/nx-cloud": "15.0.2", - "@nrwl/workspace": "15.5.3", + "@nrwl/workspace": "15.6.3", "@swc/core": "^1.3.1", "@swc/jest": "^0.2.21", "@types/babel__code-frame": "^7.0.3", @@ -99,7 +99,7 @@ "make-dir": "^3.1.0", "markdownlint-cli": "^0.33.0", "ncp": "^2.0.0", - "nx": "15.5.3", + "nx": "15.6.3", "patch-package": "^6.4.7", "prettier": "2.8.1", "pretty-format": "^29.0.3", diff --git a/packages/ast-spec/project.json b/packages/ast-spec/project.json index 682cdbf3d91..41721d18d71 100644 --- a/packages/ast-spec/project.json +++ b/packages/ast-spec/project.json @@ -10,7 +10,7 @@ "cwd": "packages/ast-spec", "commands": ["yarn build"] }, - "outputs": ["packages/ast-spec/dist/**/*.ts"] + "outputs": ["{projectRoot}/dist/**/*.ts"] }, "lint": { "executor": "@nrwl/linter:eslint", diff --git a/packages/shared-fixtures/project.json b/packages/shared-fixtures/project.json index 18cfac97135..412bca4935f 100644 --- a/packages/shared-fixtures/project.json +++ b/packages/shared-fixtures/project.json @@ -1,6 +1,6 @@ { + "name": "shared-fixtures", "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [], - "name": "shared-fixtures" + "implicitDependencies": [] } diff --git a/packages/type-utils/tests/isTypeReadonly.test.ts b/packages/type-utils/tests/isTypeReadonly.test.ts index 382091a2375..0b171dc12a2 100644 --- a/packages/type-utils/tests/isTypeReadonly.test.ts +++ b/packages/type-utils/tests/isTypeReadonly.test.ts @@ -4,8 +4,8 @@ import path from 'path'; import type * as ts from 'typescript'; import { - type ReadonlynessOptions, isTypeReadonly, + type ReadonlynessOptions, } from '../src/isTypeReadonly'; describe('isTypeReadonly', () => { diff --git a/packages/website-eslint/project.json b/packages/website-eslint/project.json index 517439cbec3..862c5b948f1 100644 --- a/packages/website-eslint/project.json +++ b/packages/website-eslint/project.json @@ -1,6 +1,6 @@ { + "name": "website-eslint", "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [], - "name": "website-eslint" + "implicitDependencies": [] } diff --git a/yarn.lock b/yarn.lock index e88792c6fec..bbe5aba913b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3246,14 +3246,25 @@ read-package-json-fast "^2.0.3" which "^2.0.2" -"@nrwl/cli@15.5.3": - version "15.5.3" - resolved "https://registry.npmjs.org/@nrwl/cli/-/cli-15.5.3.tgz#13277e5a0e8ba713850bcf13fa76717ea747a2bb" - integrity sha512-NWf9CWswvdYM6YzXuweaZPAZ2erMtQrrHZdgFbUGeojZBZ+b4TCGzLWNodZj4yQOa/eTwlyPMYO2LEw9CoapDQ== +"@nrwl/cli@15.6.3": + version "15.6.3" + resolved "https://registry.npmjs.org/@nrwl/cli/-/cli-15.6.3.tgz#999531d6efb30afc39373bdcbd7e78254a3a3fd3" + integrity sha512-K4E0spofThZXMnhA6R8hkUTdfqmwSnUE2+DlD5Y3jqsvKTAgwF5U41IFkEouFZCf+dWjy0RA20bWoX48EVFtmQ== + dependencies: + nx "15.6.3" + +"@nrwl/devkit@15.6.3": + version "15.6.3" + resolved "https://registry.npmjs.org/@nrwl/devkit/-/devkit-15.6.3.tgz#e4e96c53ba3304786a49034286c8511534b2b194" + integrity sha512-/JDvdzNxUM+C1PCZPCrvmFx+OfywqZdOq1GS9QR8C0VctTLG4D/SGSFD88O1SAdcbH/f1mMiBGfEYZYd23fghQ== dependencies: - nx "15.5.3" + "@phenomnomnominal/tsquery" "4.1.1" + ejs "^3.1.7" + ignore "^5.0.4" + semver "7.3.4" + tslib "^2.3.0" -"@nrwl/devkit@15.5.3", "@nrwl/devkit@>=15.4.2 < 16": +"@nrwl/devkit@>=15.4.2 < 16": version "15.5.3" resolved "https://registry.npmjs.org/@nrwl/devkit/-/devkit-15.5.3.tgz#16fac0147c2ab6ebba7b5357b2b959ad46b6eb26" integrity sha512-GGNLLGXDGWflrpaLimnE6hChfZfq3+XWZ0LJWL0IuCnchngPbNzuyh8S8KPgNKKgq4Nv0hglWefIwMg2UhHysA== @@ -3264,14 +3275,14 @@ semver "7.3.4" tslib "^2.3.0" -"@nrwl/jest@15.5.3": - version "15.5.3" - resolved "https://registry.npmjs.org/@nrwl/jest/-/jest-15.5.3.tgz#492ab42ac3171354a9afd6f93a7c43a6c56b3f61" - integrity sha512-BSs4ZQJtRjQ+OAPHdfeemoAiYsGL3Zuq2Ezj8XwGp50SkgVLUBZdXg2Ld1ARjTh/d3pMg+Mf+yKfjoYqFzKx+A== +"@nrwl/jest@15.6.3": + version "15.6.3" + resolved "https://registry.npmjs.org/@nrwl/jest/-/jest-15.6.3.tgz#66b1c387352cbbf666959fd7fe921d4980c6084a" + integrity sha512-pG8ESEJFkgyBGOOVZ6bFohklkDXn7JrDPSjmnoKvcOzprluPS7Nx4Ce5bw7wk2Ul3fqJcpAcH5LAZvb+HtA85w== dependencies: "@jest/reporters" "28.1.1" "@jest/test-result" "28.1.1" - "@nrwl/devkit" "15.5.3" + "@nrwl/devkit" "15.6.3" "@phenomnomnominal/tsquery" "4.1.1" chalk "^4.1.0" dotenv "~10.0.0" @@ -3282,12 +3293,12 @@ resolve.exports "1.1.0" tslib "^2.3.0" -"@nrwl/linter@15.5.3": - version "15.5.3" - resolved "https://registry.npmjs.org/@nrwl/linter/-/linter-15.5.3.tgz#de9c10c51d2ec92d51cc89207f642d41493314ba" - integrity sha512-ZeUtLOT0olORBL4FpEXmJoaiSKq4VIffW/vmCbosRIuHZqL4Cye5uHyQ6/KJXjD44Z+P6QCkyfr0etcy3lhSkg== +"@nrwl/linter@15.6.3": + version "15.6.3" + resolved "https://registry.npmjs.org/@nrwl/linter/-/linter-15.6.3.tgz#9cffa150109c604827c06ce0ccd5c925d4cd7c01" + integrity sha512-efGOduHbUa/L6MuJLb2SoDwi4hEKpz6lM1X/Yg36dYDjLuJdpLC23K4WwEOQeZL6jkcUerfY65W8NMPinAHWKg== dependencies: - "@nrwl/devkit" "15.5.3" + "@nrwl/devkit" "15.6.3" "@phenomnomnominal/tsquery" "4.1.1" tmp "~0.2.1" tslib "^2.3.0" @@ -3306,20 +3317,20 @@ tar "6.1.11" yargs-parser ">=21.0.1" -"@nrwl/tao@15.5.3": - version "15.5.3" - resolved "https://registry.npmjs.org/@nrwl/tao/-/tao-15.5.3.tgz#08c05715d2ecb108ed8b2c5381b9017cf1448b4a" - integrity sha512-vgPLIW9IoBfQ4IkHRT5RC4LqNwFBK5jmHYmFIRgbIeFRudFBbnpmOaKRME0OwN7qJ6964PVVbzahAPvYVD02xw== +"@nrwl/tao@15.6.3": + version "15.6.3" + resolved "https://registry.npmjs.org/@nrwl/tao/-/tao-15.6.3.tgz#b24e11345375dea96bc386c60b9b1102a7584932" + integrity sha512-bDZbPIbU5Mf2BvX0q8GjPxrm1WkYyfW+gp7mLuuJth2sEpZiCr47mSwuGko/y4CKXvIX46VQcAS0pKQMKugXsg== dependencies: - nx "15.5.3" + nx "15.6.3" -"@nrwl/workspace@15.5.3": - version "15.5.3" - resolved "https://registry.npmjs.org/@nrwl/workspace/-/workspace-15.5.3.tgz#3343b0de3a0fb8b0b7176c0c3cb7c19907e1485e" - integrity sha512-/Udv+dF4Z/9GZ4QmdCu/6e4QUJYx7zGTcoCOZi+Pt+OPRqOULkBbfKmB+xtiG/D32WnFePsxcssaZGux/aysUQ== +"@nrwl/workspace@15.6.3": + version "15.6.3" + resolved "https://registry.npmjs.org/@nrwl/workspace/-/workspace-15.6.3.tgz#a9fd3c5692dfaebb04642e4e86d930d144bc2fed" + integrity sha512-RkCmDvcMXCVanR0RS8CZ14D7OMojSyvAal+b37P521MpizDkiN+zdRKewKvyOonzDeTAmZODtYccQ/uM5DjRfQ== dependencies: - "@nrwl/devkit" "15.5.3" - "@nrwl/linter" "15.5.3" + "@nrwl/devkit" "15.6.3" + "@nrwl/linter" "15.6.3" "@parcel/watcher" "2.0.4" chalk "^4.1.0" chokidar "^3.5.1" @@ -3335,7 +3346,7 @@ jsonc-parser "3.2.0" minimatch "3.0.5" npm-run-path "^4.0.1" - nx "15.5.3" + nx "15.6.3" open "^8.4.0" rxjs "^6.5.4" semver "7.3.4" @@ -10769,7 +10780,48 @@ nth-check@^2.0.0, nth-check@^2.0.1: dependencies: boolbase "^1.0.0" -nx@15.5.3, "nx@>=15.4.2 < 16": +nx@15.6.3: + version "15.6.3" + resolved "https://registry.npmjs.org/nx/-/nx-15.6.3.tgz#900087bce38c6e5975660c23ebd41ead1bf54f98" + integrity sha512-3t0A0GPLNen1yPAyE+VGZ3nkAzZYb5nfXtAcx8SHBlKq4u42yBY3khBmP1y4Og3jhIwFIj7J7Npeh8ZKrthmYQ== + dependencies: + "@nrwl/cli" "15.6.3" + "@nrwl/tao" "15.6.3" + "@parcel/watcher" "2.0.4" + "@yarnpkg/lockfile" "^1.1.0" + "@yarnpkg/parsers" "^3.0.0-rc.18" + "@zkochan/js-yaml" "0.0.6" + axios "^1.0.0" + chalk "^4.1.0" + cli-cursor "3.1.0" + cli-spinners "2.6.1" + cliui "^7.0.2" + dotenv "~10.0.0" + enquirer "~2.3.6" + fast-glob "3.2.7" + figures "3.2.0" + flat "^5.0.2" + fs-extra "^11.1.0" + glob "7.1.4" + ignore "^5.0.4" + js-yaml "4.1.0" + jsonc-parser "3.2.0" + lines-and-columns "~2.0.3" + minimatch "3.0.5" + npm-run-path "^4.0.1" + open "^8.4.0" + semver "7.3.4" + string-width "^4.2.3" + strong-log-transformer "^2.1.0" + tar-stream "~2.2.0" + tmp "~0.2.1" + tsconfig-paths "^4.1.2" + tslib "^2.3.0" + v8-compile-cache "2.3.0" + yargs "^17.6.2" + yargs-parser "21.1.1" + +"nx@>=15.4.2 < 16": version "15.5.3" resolved "https://registry.npmjs.org/nx/-/nx-15.5.3.tgz#bf6252e7d9e17121dd82dec4f6fce319b9e005fa" integrity sha512-PHB8VbiBLP108xb+yR8IGEsYWr7OcmDDOjHL+73oP4lVjyPgT8wdTMe6tI5LdBgv+KZ+0kiThK3ckvcPsfgvLQ== From 99c091e0e3cf38a28aa5e1d1d2b03b602d51aa0a Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" Date: Tue, 31 Jan 2023 09:39:21 +0000 Subject: [PATCH 16/21] chore: publish v5.50.0 --- CHANGELOG.md | 19 +++++++++++++++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 11 +++++++++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-internal/package.json | 8 ++++---- packages/eslint-plugin-tslint/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 18 ++++++++++++++++++ packages/eslint-plugin/package.json | 11 +++++------ packages/experimental-utils/CHANGELOG.md | 8 ++++++++ packages/experimental-utils/package.json | 4 ++-- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 8 ++++---- packages/scope-manager/CHANGELOG.md | 8 ++++++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/type-utils/CHANGELOG.md | 8 ++++++++ packages/type-utils/package.json | 8 ++++---- packages/types/CHANGELOG.md | 8 ++++++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 8 ++++++++ packages/typescript-estree/package.json | 8 ++++---- packages/utils/CHANGELOG.md | 8 ++++++++ packages/utils/package.json | 10 +++++----- packages/visitor-keys/CHANGELOG.md | 8 ++++++++ packages/visitor-keys/package.json | 4 ++-- packages/website-eslint/CHANGELOG.md | 8 ++++++++ packages/website-eslint/package.json | 16 ++++++++-------- packages/website/CHANGELOG.md | 8 ++++++++ packages/website/package.json | 8 ++++---- 32 files changed, 205 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e18c2ad1d33..9ad61e896af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + + +### Bug Fixes + +* **ast-spec:** a JSXEmptyExpression is not a possible JSXExpression ([#6321](https://github.com/typescript-eslint/typescript-eslint/issues/6321)) ([4b27777](https://github.com/typescript-eslint/typescript-eslint/commit/4b27777ed26cc83d6efc52a89b2d3fc6c01bc0d7)) +* **eslint-plugin:** [ban-ts-comment] counts graphemes instead of `String.prototype.length` ([#5704](https://github.com/typescript-eslint/typescript-eslint/issues/5704)) ([09d57ce](https://github.com/typescript-eslint/typescript-eslint/commit/09d57cec8901880c6b24ea80dfa7d9fcdc463930)) +* **eslint-plugin:** [prefer-optional-chain] fix `ThisExpression` and `PrivateIdentifier` errors ([#6028](https://github.com/typescript-eslint/typescript-eslint/issues/6028)) ([85e783c](https://github.com/typescript-eslint/typescript-eslint/commit/85e783c1fabe96d390729a5796d6d346e401692b)) +* **eslint-plugin:** [prefer-optional-chain] fixer produces wrong logic ([#5919](https://github.com/typescript-eslint/typescript-eslint/issues/5919)) ([b0f6c8e](https://github.com/typescript-eslint/typescript-eslint/commit/b0f6c8ec0b372696ef26ca3a2b4f82dafd9dc417)), closes [#1438](https://github.com/typescript-eslint/typescript-eslint/issues/1438) + + +### Features + +* **eslint-plugin:** add `key-spacing` rule extension for interface & type declarations ([#6211](https://github.com/typescript-eslint/typescript-eslint/issues/6211)) ([67706e7](https://github.com/typescript-eslint/typescript-eslint/commit/67706e72e332bf11c82fdf51f3d417d3c93a86cf)) + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) diff --git a/lerna.json b/lerna.json index ca3b45abd27..e150bc530f7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.49.0", + "version": "5.50.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 49507c45359..3b4168eff86 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + + +### Bug Fixes + +* **ast-spec:** a JSXEmptyExpression is not a possible JSXExpression ([#6321](https://github.com/typescript-eslint/typescript-eslint/issues/6321)) ([4b27777](https://github.com/typescript-eslint/typescript-eslint/commit/4b27777ed26cc83d6efc52a89b2d3fc6c01bc0d7)) + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **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 75a1485853d..c5e160a5c41 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.49.0", + "version": "5.50.0", "description": "Complete specification for the TypeScript-ESTree AST", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index 7bb1ad9d0df..0cd6ad00030 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **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 b2e03c24a7a..7b81526e7ed 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": "5.49.0", + "version": "5.50.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,9 +14,9 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.49.0", - "@typescript-eslint/type-utils": "5.49.0", - "@typescript-eslint/utils": "5.49.0", + "@typescript-eslint/scope-manager": "5.50.0", + "@typescript-eslint/type-utils": "5.50.0", + "@typescript-eslint/utils": "5.50.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 92e446a5cc6..b2551812889 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **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 47762f6b1e0..23bf62f3fc5 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": "5.49.0", + "version": "5.50.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "ESLint plugin that wraps a TSLint configuration and lints the whole source using TSLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.49.0", + "@typescript-eslint/utils": "5.50.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.49.0" + "@typescript-eslint/parser": "5.50.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 52c4bf72c2a..25cce92ccc4 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + + +### Bug Fixes + +* **eslint-plugin:** [ban-ts-comment] counts graphemes instead of `String.prototype.length` ([#5704](https://github.com/typescript-eslint/typescript-eslint/issues/5704)) ([09d57ce](https://github.com/typescript-eslint/typescript-eslint/commit/09d57cec8901880c6b24ea80dfa7d9fcdc463930)) +* **eslint-plugin:** [prefer-optional-chain] fix `ThisExpression` and `PrivateIdentifier` errors ([#6028](https://github.com/typescript-eslint/typescript-eslint/issues/6028)) ([85e783c](https://github.com/typescript-eslint/typescript-eslint/commit/85e783c1fabe96d390729a5796d6d346e401692b)) +* **eslint-plugin:** [prefer-optional-chain] fixer produces wrong logic ([#5919](https://github.com/typescript-eslint/typescript-eslint/issues/5919)) ([b0f6c8e](https://github.com/typescript-eslint/typescript-eslint/commit/b0f6c8ec0b372696ef26ca3a2b4f82dafd9dc417)), closes [#1438](https://github.com/typescript-eslint/typescript-eslint/issues/1438) + + +### Features + +* **eslint-plugin:** add `key-spacing` rule extension for interface & type declarations ([#6211](https://github.com/typescript-eslint/typescript-eslint/issues/6211)) ([67706e7](https://github.com/typescript-eslint/typescript-eslint/commit/67706e72e332bf11c82fdf51f3d417d3c93a86cf)) + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 55992f5b727..724b3eea0f1 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.49.0", + "version": "5.50.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,13 +44,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.49.0", - "@typescript-eslint/type-utils": "5.49.0", - "@typescript-eslint/utils": "5.49.0", + "@typescript-eslint/scope-manager": "5.50.0", + "@typescript-eslint/type-utils": "5.50.0", + "@typescript-eslint/utils": "5.50.0", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", - "grapheme-splitter": "^1.0.4", "natural-compare-lite": "^1.4.0", "regexpp": "^3.2.0", "semver": "^7.3.7", @@ -63,8 +62,8 @@ "@types/natural-compare-lite": "^1.4.0", "@types/prettier": "*", "chalk": "^5.0.1", - "grapheme-splitter": "^1.0.4", "cross-fetch": "^3.1.5", + "grapheme-splitter": "^1.0.4", "json-schema": "*", "markdown-table": "^3.0.2", "marked": "^4.0.15", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index e578cc75abf..a11333dc15c 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **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 ef176c09959..e3d44a14dfe 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.49.0", + "version": "5.50.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.49.0" + "@typescript-eslint/utils": "5.50.0" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index e1b4ba3f698..8dd79a4e7d1 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index fd704210cc8..72b9df7a210 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.49.0", + "version": "5.50.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -45,9 +45,9 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.49.0", - "@typescript-eslint/types": "5.49.0", - "@typescript-eslint/typescript-estree": "5.49.0", + "@typescript-eslint/scope-manager": "5.50.0", + "@typescript-eslint/types": "5.50.0", + "@typescript-eslint/typescript-estree": "5.50.0", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index 7643d240f88..4243c56c73e 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index b91e07821da..afa72f7662a 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.49.0", + "version": "5.50.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -38,12 +38,12 @@ "typecheck": "nx typecheck" }, "dependencies": { - "@typescript-eslint/types": "5.49.0", - "@typescript-eslint/visitor-keys": "5.49.0" + "@typescript-eslint/types": "5.50.0", + "@typescript-eslint/visitor-keys": "5.50.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.49.0", + "@typescript-eslint/typescript-estree": "5.50.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index a5102cf788e..3548d5254c6 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **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 3abb676c6ae..0e3d35976d4 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,6 +1,6 @@ { "description": "Code fixtures used to test the typescript-estree parser.", "name": "@typescript-eslint/shared-fixtures", - "version": "5.49.0", + "version": "5.50.0", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 97cbdcabbc0..26f418c1436 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/type-utils + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package @typescript-eslint/type-utils diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index 88b6dc5b898..2b44585a682 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.49.0", + "version": "5.50.0", "description": "Type utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -39,13 +39,13 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/typescript-estree": "5.49.0", - "@typescript-eslint/utils": "5.49.0", + "@typescript-eslint/typescript-estree": "5.50.0", + "@typescript-eslint/utils": "5.50.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.49.0", + "@typescript-eslint/parser": "5.50.0", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 4424df99e42..0cd6d24aa09 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/types + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index d35920bf1c5..ccc72bcd698 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.49.0", + "version": "5.50.0", "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 7db432d3477..b74f9d0a82d 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 6972beac90d..728c8d417e9 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.49.0", + "version": "5.50.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -42,8 +42,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.49.0", - "@typescript-eslint/visitor-keys": "5.49.0", + "@typescript-eslint/types": "5.50.0", + "@typescript-eslint/visitor-keys": "5.50.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "5.49.0", + "@typescript-eslint/shared-fixtures": "5.50.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 119494deff1..ec49364f3e7 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/utils + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package @typescript-eslint/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 5a1427cd797..13e83257c67 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.49.0", + "version": "5.50.0", "description": "Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -41,9 +41,9 @@ "dependencies": { "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.49.0", - "@typescript-eslint/types": "5.49.0", - "@typescript-eslint/typescript-estree": "5.49.0", + "@typescript-eslint/scope-manager": "5.50.0", + "@typescript-eslint/types": "5.50.0", + "@typescript-eslint/typescript-estree": "5.50.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0", "semver": "^7.3.7" @@ -52,7 +52,7 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.49.0", + "@typescript-eslint/parser": "5.50.0", "typescript": "*" }, "funding": { diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 77bc19f5a7d..a7c260ce870 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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **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 0227b099772..14527dc3f80 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.49.0", + "version": "5.50.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -39,7 +39,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.49.0", + "@typescript-eslint/types": "5.50.0", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index f8a5a882f82..ea36b42047a 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package @typescript-eslint/website-eslint diff --git a/packages/website-eslint/package.json b/packages/website-eslint/package.json index 978b82451ae..6bb1f6d3f90 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.49.0", + "version": "5.50.0", "private": true, "description": "ESLint which works in browsers.", "engines": { @@ -16,19 +16,19 @@ "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore" }, "dependencies": { - "@typescript-eslint/types": "5.49.0", - "@typescript-eslint/utils": "5.49.0" + "@typescript-eslint/types": "5.50.0", + "@typescript-eslint/utils": "5.50.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^23.0.0", "@rollup/plugin-json": "^5.0.0", "@rollup/plugin-node-resolve": "^15.0.0", "@rollup/pluginutils": "^5.0.0", - "@typescript-eslint/eslint-plugin": "5.49.0", - "@typescript-eslint/parser": "5.49.0", - "@typescript-eslint/scope-manager": "5.49.0", - "@typescript-eslint/typescript-estree": "5.49.0", - "@typescript-eslint/visitor-keys": "5.49.0", + "@typescript-eslint/eslint-plugin": "5.50.0", + "@typescript-eslint/parser": "5.50.0", + "@typescript-eslint/scope-manager": "5.50.0", + "@typescript-eslint/typescript-estree": "5.50.0", + "@typescript-eslint/visitor-keys": "5.50.0", "eslint": "*", "rollup": "^2.75.4", "rollup-plugin-terser": "^7.0.2", diff --git a/packages/website/CHANGELOG.md b/packages/website/CHANGELOG.md index 3558af9ab44..547367d081f 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/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. +# [5.50.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.49.0...v5.50.0) (2023-01-31) + +**Note:** Version bump only for package website + + + + + # [5.49.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.48.2...v5.49.0) (2023-01-23) **Note:** Version bump only for package website diff --git a/packages/website/package.json b/packages/website/package.json index 2397fc252a2..8f4ee2b74aa 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.49.0", + "version": "5.50.0", "private": true, "scripts": { "build": "docusaurus build", @@ -21,8 +21,8 @@ "@docusaurus/remark-plugin-npm2yarn": "~2.2.0", "@docusaurus/theme-common": "~2.2.0", "@mdx-js/react": "1.6.22", - "@typescript-eslint/parser": "5.49.0", - "@typescript-eslint/website-eslint": "5.49.0", + "@typescript-eslint/parser": "5.50.0", + "@typescript-eslint/website-eslint": "5.50.0", "clsx": "^1.1.1", "eslint": "*", "json-schema": "^0.4.0", @@ -48,7 +48,7 @@ "@types/react": "^18.0.9", "@types/react-helmet": "^6.1.5", "@types/react-router-dom": "^5.3.3", - "@typescript-eslint/eslint-plugin": "5.49.0", + "@typescript-eslint/eslint-plugin": "5.50.0", "copy-webpack-plugin": "^11.0.0", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.29.4", From 2c61bdbe1ea4c755f8e4fe7e5d2d209f59c80c6f Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 31 Jan 2023 09:40:45 -0500 Subject: [PATCH 17/21] chore(website): consistent .mdx file naming (#6325) * chore(website): consistent .mdx file naming * Ran Prettier * .md/s/x * Post merge fixups * Ignore warnonunsupportedtypescriptversion * Fix Versioning merge conflicts --- .cspell.json | 1 + .github/pull_request_template.md | 2 +- docs/{Architecture.md => Architecture.mdx} | 0 docs/{Custom_Rules.md => Custom_Rules.mdx} | 0 docs/{Getting_Started.md => Getting_Started.mdx} | 4 ++-- docs/{MAINTENANCE.md => Maintenance.mdx} | 0 docs/architecture/ESLint_Plugin.mdx | 2 +- docs/architecture/ESLint_Plugin_TSLint.mdx | 4 ++-- docs/linting/CONFIGURATIONS.mdx | 2 +- .../{Troubleshooting.md => Troubleshooting.mdx} | 6 +++--- .../{Typed_Linting.md => Typed_Linting.mdx} | 6 +++--- .../{Formatting.md => Formatting.mdx} | 0 docs/linting/troubleshooting/Performance.md | 4 ++-- .../troubleshooting/{TSLint.md => TSLint.mdx} | 0 .../typed-linting/{Monorepos.md => Monorepos.mdx} | 4 ++-- docs/maintenance/{BRANDING.md => Branding.mdx} | 7 ++++++- docs/maintenance/{ISSUES.md => Issues.mdx} | 2 +- .../{PULL_REQUESTS.md => Pull_Requests.mdx} | 0 docs/maintenance/{RELEASES.md => Releases.mdx} | 0 docs/maintenance/{Versioning.md => Versioning.mdx} | 14 ++++++++++++-- ...{Rule_Deprecations.md => Rule_Deprecations.mdx} | 0 .../versioning/dependant-version-upgrades.mdx | 10 +++++----- packages/experimental-utils/README.md | 2 +- 23 files changed, 43 insertions(+), 27 deletions(-) rename docs/{Architecture.md => Architecture.mdx} (100%) rename docs/{Custom_Rules.md => Custom_Rules.mdx} (100%) rename docs/{Getting_Started.md => Getting_Started.mdx} (94%) rename docs/{MAINTENANCE.md => Maintenance.mdx} (100%) rename docs/linting/{Troubleshooting.md => Troubleshooting.mdx} (99%) rename docs/linting/{Typed_Linting.md => Typed_Linting.mdx} (90%) rename docs/linting/troubleshooting/{Formatting.md => Formatting.mdx} (100%) rename docs/linting/troubleshooting/{TSLint.md => TSLint.mdx} (100%) rename docs/linting/typed-linting/{Monorepos.md => Monorepos.mdx} (96%) rename docs/maintenance/{BRANDING.md => Branding.mdx} (92%) rename docs/maintenance/{ISSUES.md => Issues.mdx} (99%) rename docs/maintenance/{PULL_REQUESTS.md => Pull_Requests.mdx} (100%) rename docs/maintenance/{RELEASES.md => Releases.mdx} (100%) rename docs/maintenance/{Versioning.md => Versioning.mdx} (95%) rename docs/maintenance/issues/{Rule_Deprecations.md => Rule_Deprecations.mdx} (100%) diff --git a/.cspell.json b/.cspell.json index edd2532abf9..415d46de1cf 100644 --- a/.cspell.json +++ b/.cspell.json @@ -121,6 +121,7 @@ "unoptimized", "unprefixed", "upsert", + "warnonunsupportedtypescriptversion", "Zacher" ], "overrides": [ diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3e72e13f7a9..b5037407620 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,7 +8,7 @@ Otherwise we may not be able to review your PR. - [ ] Addresses an existing open issue: fixes #000 - [ ] That issue was marked as [accepting prs](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aopen+is%3Aissue+label%3A%22accepting+prs%22) -- [ ] Steps in [CONTRIBUTING.md](https://github.com/typescript-eslint/typescript-eslint/blob/main/CONTRIBUTING.md) were taken +- [ ] Steps in [Contributing](https://typescript-eslint.io/contributing) were taken ## Overview diff --git a/docs/Architecture.md b/docs/Architecture.mdx similarity index 100% rename from docs/Architecture.md rename to docs/Architecture.mdx diff --git a/docs/Custom_Rules.md b/docs/Custom_Rules.mdx similarity index 100% rename from docs/Custom_Rules.md rename to docs/Custom_Rules.mdx diff --git a/docs/Getting_Started.md b/docs/Getting_Started.mdx similarity index 94% rename from docs/Getting_Started.md rename to docs/Getting_Started.mdx index 91c978322f4..cdaf39899a9 100644 --- a/docs/Getting_Started.md +++ b/docs/Getting_Started.mdx @@ -73,6 +73,6 @@ ESLint will lint all TypeScript compatible files within the current folder, and ## Next Steps -We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit the next page for a setup guide](./linting/Typed_Linting.md 'Visit the next page for a typed rules setup guide'). +We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit the next page for a setup guide](./linting/Typed_Linting.mdx 'Visit the next page for a typed rules setup guide'). -If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](./linting/Troubleshooting.md). +If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](./linting/Troubleshooting.mdx). diff --git a/docs/MAINTENANCE.md b/docs/Maintenance.mdx similarity index 100% rename from docs/MAINTENANCE.md rename to docs/Maintenance.mdx diff --git a/docs/architecture/ESLint_Plugin.mdx b/docs/architecture/ESLint_Plugin.mdx index eca60141555..6db78ddfceb 100644 --- a/docs/architecture/ESLint_Plugin.mdx +++ b/docs/architecture/ESLint_Plugin.mdx @@ -8,7 +8,7 @@ sidebar_label: eslint-plugin > The TypeScript plugin for ESLint. ✨ :::info -See [Getting Started](../Getting_Started.md) for documentation on how to lint your TypeScript code with ESLint. +See [Getting Started](../Getting_Started.mdx) for documentation on how to lint your TypeScript code with ESLint. ::: `@typescript-eslint/eslint-plugin` is an ESLint plugin used to load in custom rules and rule configurations lists from typescript-eslint. diff --git a/docs/architecture/ESLint_Plugin_TSLint.mdx b/docs/architecture/ESLint_Plugin_TSLint.mdx index 582d93aab8e..525b1c07247 100644 --- a/docs/architecture/ESLint_Plugin_TSLint.mdx +++ b/docs/architecture/ESLint_Plugin_TSLint.mdx @@ -8,8 +8,8 @@ sidebar_label: eslint-plugin-tslint > ESLint plugin that allows running TSLint rules within ESLint to help you migrate from TSLint to ESLint. ✨ :::caution -Per [What About TSLint?](../linting/troubleshooting/TSLint.md), we highly recommend migrating off TSLint. -See [Getting Started](../Getting_Started.md) for documentation on how to lint your TypeScript code with ESLint. +Per [What About TSLint?](../linting/troubleshooting/TSLint.mdx), we highly recommend migrating off TSLint. +See [Getting Started](../Getting_Started.mdx) for documentation on how to lint your TypeScript code with ESLint. ::: ## Installation diff --git a/docs/linting/CONFIGURATIONS.mdx b/docs/linting/CONFIGURATIONS.mdx index aec668a16dd..10d3f6293d5 100644 --- a/docs/linting/CONFIGURATIONS.mdx +++ b/docs/linting/CONFIGURATIONS.mdx @@ -18,7 +18,7 @@ Most projects should extend from at least one of: - [`strict`](#strict): Additional strict rules that can also catch bugs but are more opinionated than recommended rules. :::tip -We recommend most projects use [`recommended-requiring-type-checking`](#recommended-requiring-type-checking) (which requires [typed linting](./Typed_Linting.md)). +We recommend most projects use [`recommended-requiring-type-checking`](#recommended-requiring-type-checking) (which requires [typed linting](./Typed_Linting.mdx)). ::: :::note diff --git a/docs/linting/Troubleshooting.md b/docs/linting/Troubleshooting.mdx similarity index 99% rename from docs/linting/Troubleshooting.md rename to docs/linting/Troubleshooting.mdx index 67e4316608f..cb59af28447 100644 --- a/docs/linting/Troubleshooting.md +++ b/docs/linting/Troubleshooting.mdx @@ -35,11 +35,11 @@ If you don't find an existing extension rule, or the extension rule doesn't work - If you **do not** want to lint the file: - Use [one of the options ESLint offers](https://eslint.org/docs/latest/user-guide/configuring/ignoring-code) to ignore files, namely a `.eslintignore` file, or `ignorePatterns` config. - If you **do** want to lint the file: - - If you **do not** want to lint the file with [type-aware linting](./Typed_Linting.md): + - If you **do not** want to lint the file with [type-aware linting](./Typed_Linting.mdx): - Use [ESLint's `overrides` configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns) to configure the file to not be parsed with type information. - A popular setup is to omit the above additions from top-level configuration and only apply them to TypeScript files via an override. - Alternatively, you can add `parserOptions: { project: null }` to an override for the files you wish to exclude. Note that `{ project: undefined }` will not work. - - If you **do** want to lint the file with [type-aware linting](./Typed_Linting.md): + - If you **do** want to lint the file with [type-aware linting](./Typed_Linting.mdx): - Check the `include` option of each of the tsconfigs that you provide to `parserOptions.project` - you must ensure that all files match an `include` glob, or else our tooling will not be able to find it. - If your file shouldn't be a part of one of your existing tsconfigs (for example, it is a script/tool local to the repo), then consider creating a new tsconfig (we advise calling it `tsconfig.eslint.json`) in your project root which lists this file in its `include`. For an example of this, you can check out the configuration we use in this repo: - [`tsconfig.eslint.json`](https://github.com/typescript-eslint/typescript-eslint/blob/main/tsconfig.eslint.json) @@ -64,7 +64,7 @@ For example, many projects have files like: In that case, viewing the `.eslintrc.cjs` in an IDE with the ESLint extension will show the error notice that the file couldn't be linted because it isn't included in `tsconfig.json`. -See our docs on [type aware linting](./Typed_Linting.md) for more information. +See our docs on [type aware linting](./Typed_Linting.mdx) for more information. ## I get errors telling me "The file must be included in at least one of the projects provided" diff --git a/docs/linting/Typed_Linting.md b/docs/linting/Typed_Linting.mdx similarity index 90% rename from docs/linting/Typed_Linting.md rename to docs/linting/Typed_Linting.mdx index 65e2c875fff..7d9de2f25bb 100644 --- a/docs/linting/Typed_Linting.md +++ b/docs/linting/Typed_Linting.mdx @@ -30,7 +30,7 @@ In more detail: - `plugin:@typescript-eslint/recommended-requiring-type-checking` is another [recommended configuration](./CONFIGURATIONS.mdx) we provide. This one contains recommended rules that additionally require type information. - `parserOptions.project` tells our parser the relative path where your project's `tsconfig.json` is. - - If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.md). + - If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.mdx). - `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory (see [Parser#tsconfigRootDir](../architecture/Parser.mdx#tsconfigRootDir)). With that done, run the same lint command you ran before. @@ -53,8 +53,8 @@ This means that generally they usually only run a complete lint before a push, o ### I get errors telling me "The file must be included in at least one of the projects provided" You're using an outdated version of `@typescript-eslint/parser`. -Update to the latest version to see a more informative version of this error message, explained in our [Troubleshooting and FAQs page](./Troubleshooting.md#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file). +Update to the latest version to see a more informative version of this error message, explained in our [Troubleshooting and FAQs page](./Troubleshooting.mdx#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file). ## Troubleshooting -If you're having problems getting this working, please have a look at our [Troubleshooting and FAQs page](./Troubleshooting.md). +If you're having problems getting this working, please have a look at our [Troubleshooting and FAQs page](./Troubleshooting.mdx). diff --git a/docs/linting/troubleshooting/Formatting.md b/docs/linting/troubleshooting/Formatting.mdx similarity index 100% rename from docs/linting/troubleshooting/Formatting.md rename to docs/linting/troubleshooting/Formatting.mdx diff --git a/docs/linting/troubleshooting/Performance.md b/docs/linting/troubleshooting/Performance.md index 6f696a7a05f..f4d0f9e3d53 100644 --- a/docs/linting/troubleshooting/Performance.md +++ b/docs/linting/troubleshooting/Performance.md @@ -3,7 +3,7 @@ id: performance-troubleshooting title: Performance Troubleshooting --- -As mentioned in the [type-aware linting doc](../Typed_Linting.md), if you're using type-aware linting, your lint times should be roughly the same as your build times. +As mentioned in the [type-aware linting doc](../Typed_Linting.mdx), if you're using type-aware linting, your lint times should be roughly the same as your build times. If you're experiencing times much slower than that, then there are a few common culprits. @@ -53,7 +53,7 @@ Across a large codebase, these can add up, and severely impact performance. We recommend not using this rule, and instead using a tool like [`prettier`](https://www.npmjs.com/package/prettier) to enforce a standardized formatting. -See our [documentation on formatting](./Formatting.md) for more information. +See our [documentation on formatting](./Formatting.mdx) for more information. ## `eslint-plugin-prettier` diff --git a/docs/linting/troubleshooting/TSLint.md b/docs/linting/troubleshooting/TSLint.mdx similarity index 100% rename from docs/linting/troubleshooting/TSLint.md rename to docs/linting/troubleshooting/TSLint.mdx diff --git a/docs/linting/typed-linting/Monorepos.md b/docs/linting/typed-linting/Monorepos.mdx similarity index 96% rename from docs/linting/typed-linting/Monorepos.md rename to docs/linting/typed-linting/Monorepos.mdx index e55d2064779..7b01b81d662 100644 --- a/docs/linting/typed-linting/Monorepos.md +++ b/docs/linting/typed-linting/Monorepos.mdx @@ -38,7 +38,7 @@ Be sure to update your `.eslintrc.js` to point at this new config file. ## One `tsconfig.json` per package (and an optional one in the root) -The `parserOptions.project` option introduced in [Linting with Type Information](../Typed_Linting.md) accepts an array of relative paths. +The `parserOptions.project` option introduced in [Linting with Type Information](../Typed_Linting.mdx) accepts an array of relative paths. Paths may be provided as [Node globs](https://github.com/isaacs/node-glob/blob/f5a57d3d6e19b324522a3fa5bdd5075fd1aa79d1/README.md#glob-primer). For each file being linted, the first matching project path will be used as its backing TSConfig. @@ -104,4 +104,4 @@ As an interim workaround, consider one of the following: ## Troubleshooting -If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](../Troubleshooting.md). +If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](../Troubleshooting.mdx). diff --git a/docs/maintenance/BRANDING.md b/docs/maintenance/Branding.mdx similarity index 92% rename from docs/maintenance/BRANDING.md rename to docs/maintenance/Branding.mdx index 25c08b216e6..d4e84d90dea 100644 --- a/docs/maintenance/BRANDING.md +++ b/docs/maintenance/Branding.mdx @@ -31,7 +31,12 @@ You can call it _blurple_ if you want. Our logo is also a halfway between [ESLint's logo](https://en.wikipedia.org/wiki/ESLint#/media/File:ESLint_logo.svg) and [TypeScript's logo](https://en.wikipedia.org/wiki/TypeScript#/media/File:Typescript.svg): -typescript-eslint logo +typescript-eslint logo - [Logo PNG download](/img/logo.png) - [Logo SVG download](/img/logo.svg) diff --git a/docs/maintenance/ISSUES.md b/docs/maintenance/Issues.mdx similarity index 99% rename from docs/maintenance/ISSUES.md rename to docs/maintenance/Issues.mdx index fb5eb655dd6..fc8a89711de 100644 --- a/docs/maintenance/ISSUES.md +++ b/docs/maintenance/Issues.mdx @@ -105,7 +105,7 @@ We avoid features that: - Are only relevant for a minority of users, as they aren't likely worth the maintenance burden - Aren't TypeScript-specific (e.g. should be in ESLint core instead) - Are only relevant with specific userland frameworks or libraries, such as Jest or React -- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../linting/troubleshooting/Formatting.md)) +- Are for "formatting" functionality (we [strongly recommend users use a separate dedicated formatter](../linting/troubleshooting/Formatting.mdx)) #### ✨ Rule Enhancements diff --git a/docs/maintenance/PULL_REQUESTS.md b/docs/maintenance/Pull_Requests.mdx similarity index 100% rename from docs/maintenance/PULL_REQUESTS.md rename to docs/maintenance/Pull_Requests.mdx diff --git a/docs/maintenance/RELEASES.md b/docs/maintenance/Releases.mdx similarity index 100% rename from docs/maintenance/RELEASES.md rename to docs/maintenance/Releases.mdx diff --git a/docs/maintenance/Versioning.md b/docs/maintenance/Versioning.mdx similarity index 95% rename from docs/maintenance/Versioning.md rename to docs/maintenance/Versioning.mdx index d9a4224dbf8..68a007c89c1 100644 --- a/docs/maintenance/Versioning.md +++ b/docs/maintenance/Versioning.mdx @@ -14,11 +14,21 @@ Additionally, we promote to the `latest` tag on NPM once per week, **on Mondays The latest version under the `latest` tag is: -NPM Version + + NPM Version + The latest version under the `canary` tag **(latest commit to `main`)** is: -NPM Version + + NPM Version + :::note The only exception to the automated publishes described above is when we are in the final phases of creating the next major version of the libraries - e.g. going from `1.x.x` to `2.x.x`. diff --git a/docs/maintenance/issues/Rule_Deprecations.md b/docs/maintenance/issues/Rule_Deprecations.mdx similarity index 100% rename from docs/maintenance/issues/Rule_Deprecations.md rename to docs/maintenance/issues/Rule_Deprecations.mdx diff --git a/docs/maintenance/versioning/dependant-version-upgrades.mdx b/docs/maintenance/versioning/dependant-version-upgrades.mdx index 49ba51ce1e4..bf1a17f2829 100644 --- a/docs/maintenance/versioning/dependant-version-upgrades.mdx +++ b/docs/maintenance/versioning/dependant-version-upgrades.mdx @@ -21,7 +21,7 @@ Whenever you discover any new areas of work that are blocked by dropping an old 1. Upgrade the root `package.json` `devDependency` to the latest ESLint 1. Add the new major version to the explicit `peerDependency` versions 1. Check [`eslint-visitor-keys`](https://www.npmjs.com/package/eslint-visitor-keys) for a new version to be upgraded to as well. -1. Update [Versioning > ESLint](../Versioning.md#eslint) +1. Update [Versioning > ESLint](../Versioning.mdx#eslint) ### Removing Support for an Old ESLint Version @@ -32,7 +32,7 @@ Whenever you discover any new areas of work that are blocked by dropping an old - `/eslint.*5/i` - `/todo.*eslint.*5/i` - `/todo.*eslint/i` -1. Update [Versioning > ESLint](../Versioning.md#eslint) +1. Update [Versioning > ESLint](../Versioning.mdx#eslint) See [chore: drop support for ESLint v6](https://github.com/typescript-eslint/typescript-eslint/pull/5972) for reference. @@ -88,8 +88,8 @@ We generally start the process of supporting a new TypeScript version just after - In the root `package.json`, change the `devDependency` on `typescript` to `~X.Y.3` - Rename and update `patches/typescript*` to the new TypeScript version - Any other changes made necessary due to changes in TypeScript between the RC version and stable version - - Update the supported version range in [Versioning](../Versioning.md) -1. Update [Versioning > TypeScript](../Versioning.md#typescript) + - Update the supported version range in [Versioning](../Versioning.mdx) +1. Update [Versioning > TypeScript](../Versioning.mdx#typescript) 1. Send a PR that updates this documentation page to point to your newer issues and PRs - Also update any of these steps if you go with a different process @@ -108,7 +108,7 @@ A single PR can remove support for old TypeScript versions as a breaking change: 1. Update the root `package.json` `devDependency` 1. Update the `SUPPORTED_TYPESCRIPT_VERSIONS` constant in `warnAboutTSVersion.ts` 1. Update the `versions` constant in `version-check.ts` -1. Update [Versioning > TypeScript](../Versioning.md#typescript) +1. Update [Versioning > TypeScript](../Versioning.mdx#typescript) 1. Search for source code comments (excluding `CHANGELOG.md` files) that mention a now-unsupported version of TypeScript. - For example, to remove support for v4.3, searches might include: - `4.3` diff --git a/packages/experimental-utils/README.md b/packages/experimental-utils/README.md index d1468f928b1..a285229f638 100644 --- a/packages/experimental-utils/README.md +++ b/packages/experimental-utils/README.md @@ -19,4 +19,4 @@ You should switch to importing from that non-experimental package instead. ## Contributing -[See the contributing guide here](../../CONTRIBUTING.md) +[See the contributing guide here](https://typescript-eslint.io). From fbe811c8c8a7135edff290f0a3a99d60457b59dc Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 31 Jan 2023 09:42:55 -0500 Subject: [PATCH 18/21] chore: enable eqeqeq internally (#6228) * chore: enable eqeqeq internally * Switch to null: never * Why not add some test coverage --- .eslintrc.js | 7 +++++ .../src/rules/adjacent-overload-signatures.ts | 4 +-- packages/eslint-plugin/src/rules/ban-types.ts | 2 +- .../eslint-plugin/src/rules/comma-spacing.ts | 2 +- .../src/rules/member-ordering.ts | 4 +-- .../naming-convention-utils/validator.ts | 12 +++---- .../src/rules/naming-convention.ts | 4 +-- .../src/rules/no-implied-eval.ts | 2 +- .../src/rules/no-inferrable-types.ts | 2 +- .../src/rules/no-loss-of-precision.ts | 2 +- .../src/rules/no-misused-promises.ts | 6 ++-- ...no-non-null-asserted-nullish-coalescing.ts | 2 +- .../src/rules/no-unnecessary-condition.ts | 2 +- .../src/rules/no-unnecessary-qualifier.ts | 2 +- .../src/rules/no-use-before-define.ts | 4 +-- .../eslint-plugin/src/rules/prefer-for-of.ts | 8 ++--- .../src/rules/prefer-function-type.ts | 5 ++- .../src/rules/prefer-includes.ts | 2 +- .../src/rules/prefer-regexp-exec.ts | 2 +- .../rules/prefer-string-starts-ends-with.ts | 2 +- .../src/rules/switch-exhaustiveness-check.ts | 2 +- .../src/rules/triple-slash-reference.ts | 2 +- .../eslint-plugin/src/util/isNullLiteral.ts | 2 +- .../tests/rules/indent/indent.test.ts | 2 +- .../prefer-string-starts-ends-with.test.ts | 2 +- packages/scope-manager/src/ScopeManager.ts | 2 +- .../src/referencer/ClassVisitor.ts | 2 +- .../src/referencer/PatternVisitor.ts | 5 +-- .../src/referencer/Referencer.ts | 4 +-- .../typescript-estree/src/convert-comments.ts | 2 +- packages/typescript-estree/src/convert.ts | 2 +- .../typescript-estree/src/getModifiers.ts | 2 +- .../typescript-estree/src/simple-traverse.ts | 2 +- .../typescript-estree/tools/test-utils.ts | 2 +- .../utils/src/eslint-utils/applyDefault.ts | 2 +- packages/utils/src/eslint-utils/nullThrows.ts | 2 +- .../tests/eslint-utils/nullThrows.test.ts | 31 +++++++++++++++++++ .../components/ast/serializer/serializer.ts | 2 +- 38 files changed, 89 insertions(+), 57 deletions(-) create mode 100644 packages/utils/tests/eslint-utils/nullThrows.test.ts diff --git a/.eslintrc.js b/.eslintrc.js index 7380b874d88..006f52f143c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -106,6 +106,13 @@ module.exports = { // curly: ['error', 'all'], + eqeqeq: [ + 'error', + 'always', + { + null: 'never', + }, + ], 'no-mixed-operators': 'error', 'no-console': 'error', 'no-process-exit': 'error', diff --git a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts index 5f5ddfc0aad..498a9bf5ae1 100644 --- a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts +++ b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts @@ -65,7 +65,7 @@ export default util.createRule({ case AST_NODE_TYPES.TSDeclareFunction: case AST_NODE_TYPES.FunctionDeclaration: { const name = member.id?.name ?? null; - if (name === null) { + if (name == null) { return null; } return { @@ -143,7 +143,7 @@ export default util.createRule({ members.forEach(member => { const method = getMemberMethod(member); - if (method === null) { + if (method == null) { lastMethod = null; return; } diff --git a/packages/eslint-plugin/src/rules/ban-types.ts b/packages/eslint-plugin/src/rules/ban-types.ts index dce41140515..f21dda8a249 100644 --- a/packages/eslint-plugin/src/rules/ban-types.ts +++ b/packages/eslint-plugin/src/rules/ban-types.ts @@ -36,7 +36,7 @@ function stringifyNode( function getCustomMessage( bannedType: null | string | { message?: string; fixWith?: string }, ): string { - if (bannedType === null) { + if (bannedType == null) { return ''; } diff --git a/packages/eslint-plugin/src/rules/comma-spacing.ts b/packages/eslint-plugin/src/rules/comma-spacing.ts index fda50d1b2e4..a1ebcc181f2 100644 --- a/packages/eslint-plugin/src/rules/comma-spacing.ts +++ b/packages/eslint-plugin/src/rules/comma-spacing.ts @@ -68,7 +68,7 @@ export default createRule({ let previousToken = sourceCode.getFirstToken(node); for (const element of node.elements) { let token: TSESTree.Token | null; - if (element === null) { + if (element == null) { token = sourceCode.getTokenAfter(previousToken!); if (token && isCommaToken(token)) { ignoredTokens.add(token); diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 81e0ae6484e..f8db5ade0ca 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -489,7 +489,7 @@ function getRank( ): number { const type = getNodeType(node); - if (type === null) { + if (type == null) { // shouldn't happen but just in case, put it on the end return orderConfig.length - 1; } @@ -842,7 +842,7 @@ export default util.createRule({ supportsModifiers, ); - if (grouped === null) { + if (grouped == null) { return false; } diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts index e96ff19e374..c2b87ccc33b 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts @@ -101,25 +101,25 @@ function createValidator( let name: string | null = originalName; name = validateUnderscore('leading', config, name, node, originalName); - if (name === null) { + if (name == null) { // fail return; } name = validateUnderscore('trailing', config, name, node, originalName); - if (name === null) { + if (name == null) { // fail return; } name = validateAffix('prefix', config, name, node, originalName); - if (name === null) { + if (name == null) { // fail return; } name = validateAffix('suffix', config, name, node, originalName); - if (name === null) { + if (name == null) { // fail return; } @@ -383,7 +383,7 @@ function createValidator( modifiers: Set, ): boolean { const formats = config.format; - if (formats === null || formats.length === 0) { + if (!formats?.length) { return true; } @@ -427,7 +427,7 @@ function isCorrectType( context: Context, selector: Selectors, ): boolean { - if (config.types === null) { + if (config.types == null) { return true; } diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 3b500b0b347..0a4ce6c4413 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -271,7 +271,7 @@ export default util.createRule({ | TSESTree.FunctionExpression, ): void { const validator = validators.function; - if (!validator || node.id === null) { + if (!validator || node.id == null) { return; } @@ -491,7 +491,7 @@ export default util.createRule({ } const id = node.id; - if (id === null) { + if (id == null) { return; } diff --git a/packages/eslint-plugin/src/rules/no-implied-eval.ts b/packages/eslint-plugin/src/rules/no-implied-eval.ts index 0ae6698c533..d88cd05ff6f 100644 --- a/packages/eslint-plugin/src/rules/no-implied-eval.ts +++ b/packages/eslint-plugin/src/rules/no-implied-eval.ts @@ -135,7 +135,7 @@ export default util.createRule({ node: TSESTree.NewExpression | TSESTree.CallExpression, ): void { const calleeName = getCalleeName(node.callee); - if (calleeName === null) { + if (calleeName == null) { return; } diff --git a/packages/eslint-plugin/src/rules/no-inferrable-types.ts b/packages/eslint-plugin/src/rules/no-inferrable-types.ts index effbed48eaa..1bc83c07c70 100644 --- a/packages/eslint-plugin/src/rules/no-inferrable-types.ts +++ b/packages/eslint-plugin/src/rules/no-inferrable-types.ts @@ -147,7 +147,7 @@ export default util.createRule({ } case AST_NODE_TYPES.TSNullKeyword: - return init.type === AST_NODE_TYPES.Literal && init.value === null; + return init.type === AST_NODE_TYPES.Literal && init.value == null; case AST_NODE_TYPES.TSStringKeyword: return ( diff --git a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts index 7b9492972e8..2c0d84364e4 100644 --- a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts +++ b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts @@ -25,7 +25,7 @@ export default util.createRule({ }, defaultOptions: [], create(context) { - /* istanbul ignore if */ if (baseRule === null) { + /* istanbul ignore if */ if (baseRule == null) { throw new Error( '@typescript-eslint/no-loss-of-precision requires at least ESLint v7.1.0', ); diff --git a/packages/eslint-plugin/src/rules/no-misused-promises.ts b/packages/eslint-plugin/src/rules/no-misused-promises.ts index b6914ae2c39..15bf0c501d1 100644 --- a/packages/eslint-plugin/src/rules/no-misused-promises.ts +++ b/packages/eslint-plugin/src/rules/no-misused-promises.ts @@ -250,7 +250,7 @@ export default util.createRule({ function checkVariableDeclaration(node: TSESTree.VariableDeclarator): void { const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); - if (tsNode.initializer === undefined || node.init === null) { + if (tsNode.initializer === undefined || node.init == null) { return; } const varType = checker.getTypeAtLocation(tsNode.name); @@ -344,7 +344,7 @@ export default util.createRule({ function checkReturnStatement(node: TSESTree.ReturnStatement): void { const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); - if (tsNode.expression === undefined || node.argument === null) { + if (tsNode.expression === undefined || node.argument == null) { return; } const contextualType = checker.getContextualType(tsNode.expression); @@ -368,7 +368,7 @@ export default util.createRule({ const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); const value = tsNode.initializer; if ( - node.value === null || + node.value == null || value === undefined || !ts.isJsxExpression(value) || value.expression === undefined diff --git a/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts index 8706703c9ba..a79fa4062b1 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts @@ -27,7 +27,7 @@ function isDefinitionWithAssignment(definition: Definition): boolean { const variableDeclarator = definition.node; return ( - variableDeclarator.definite === true || variableDeclarator.init !== null + variableDeclarator.definite === true || variableDeclarator.init != null ); } diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts index 5a6872f5748..42f12748af9 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts @@ -384,7 +384,7 @@ export default createRule({ | TSESTree.ForStatement | TSESTree.WhileStatement, ): void { - if (node.test === null) { + if (node.test == null) { // e.g. `for(;;)` return; } diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts index fbf3b41e966..632ad6c5ba0 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts @@ -53,7 +53,7 @@ export default util.createRule({ const alias = tryGetAliasedSymbol(symbol, checker); - return alias !== null && symbolIsNamespaceInScope(alias); + return alias != null && symbolIsNamespaceInScope(alias); } function getSymbolInScope( diff --git a/packages/eslint-plugin/src/rules/no-use-before-define.ts b/packages/eslint-plugin/src/rules/no-use-before-define.ts index 5153ed47fcd..b88cd82d39d 100644 --- a/packages/eslint-plugin/src/rules/no-use-before-define.ts +++ b/packages/eslint-plugin/src/rules/no-use-before-define.ts @@ -21,7 +21,7 @@ function parseOptions(options: string | Config | null): Required { if (typeof options === 'string') { functions = options !== 'nofunc'; - } else if (typeof options === 'object' && options !== null) { + } else if (typeof options === 'object' && options != null) { functions = options.functions !== false; classes = options.classes !== false; enums = options.enums !== false; @@ -64,7 +64,7 @@ function isOuterEnum( reference: TSESLint.Scope.Reference, ): boolean { return ( - variable.defs[0].type == DefinitionType.TSEnumName && + variable.defs[0].type === DefinitionType.TSEnumName && variable.scope.variableScope !== reference.from.variableScope ); } diff --git a/packages/eslint-plugin/src/rules/prefer-for-of.ts b/packages/eslint-plugin/src/rules/prefer-for-of.ts index 9bb8802a7da..ddde074a234 100644 --- a/packages/eslint-plugin/src/rules/prefer-for-of.ts +++ b/packages/eslint-plugin/src/rules/prefer-for-of.ts @@ -24,8 +24,7 @@ export default util.createRule({ node: TSESTree.Node | null, ): node is TSESTree.VariableDeclaration { return ( - node !== null && - node.type === AST_NODE_TYPES.VariableDeclaration && + node?.type === AST_NODE_TYPES.VariableDeclaration && node.kind !== 'const' && node.declarations.length === 1 ); @@ -39,7 +38,7 @@ export default util.createRule({ } function isZeroInitialized(node: TSESTree.VariableDeclarator): boolean { - return node.init !== null && isLiteral(node.init, 0); + return node.init != null && isLiteral(node.init, 0); } function isMatchingIdentifier( @@ -54,8 +53,7 @@ export default util.createRule({ name: string, ): TSESTree.Expression | null { if ( - node !== null && - node.type === AST_NODE_TYPES.BinaryExpression && + node?.type === AST_NODE_TYPES.BinaryExpression && node.operator === '<' && isMatchingIdentifier(node.left, name) && node.right.type === AST_NODE_TYPES.MemberExpression && diff --git a/packages/eslint-plugin/src/rules/prefer-function-type.ts b/packages/eslint-plugin/src/rules/prefer-function-type.ts index 95b3ee5d33b..db5dde69d00 100644 --- a/packages/eslint-plugin/src/rules/prefer-function-type.ts +++ b/packages/eslint-plugin/src/rules/prefer-function-type.ts @@ -82,8 +82,7 @@ export default util.createRule({ typeof member.returnType !== 'undefined' ) { if ( - tsThisTypes !== null && - tsThisTypes.length > 0 && + tsThisTypes?.length && node.type === AST_NODE_TYPES.TSInterfaceDeclaration ) { // the message can be confusing if we don't point directly to the `this` node instead of the whole member @@ -205,7 +204,7 @@ export default util.createRule({ // inside an interface keep track of all ThisType references. // unless it's inside a nested type literal in which case it's invalid code anyway // we don't want to incorrectly say "it refers to name" while typescript says it's completely invalid. - if (literalNesting === 0 && tsThisTypes !== null) { + if (literalNesting === 0 && tsThisTypes != null) { tsThisTypes.push(node); } }, diff --git a/packages/eslint-plugin/src/rules/prefer-includes.ts b/packages/eslint-plugin/src/rules/prefer-includes.ts index 9c50ce118f8..720d5fbe809 100644 --- a/packages/eslint-plugin/src/rules/prefer-includes.ts +++ b/packages/eslint-plugin/src/rules/prefer-includes.ts @@ -38,7 +38,7 @@ export default createRule({ function isNumber(node: TSESTree.Node, value: number): boolean { const evaluated = getStaticValue(node, globalScope); - return evaluated !== null && evaluated.value === value; + return evaluated != null && evaluated.value === value; } function isPositiveCheck(node: TSESTree.BinaryExpression): boolean { diff --git a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts index 13452d48f86..60bf310947f 100644 --- a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts +++ b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts @@ -123,7 +123,7 @@ export default createRule({ if ( argumentNode.type === AST_NODE_TYPES.Literal && - typeof argumentNode.value == 'string' + typeof argumentNode.value === 'string' ) { const regExp = RegExp(argumentNode.value); return context.report({ diff --git a/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts b/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts index 31a570652dc..104637062bb 100644 --- a/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts +++ b/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts @@ -60,7 +60,7 @@ export default createRule({ */ function isNull(node: TSESTree.Node): node is TSESTree.Literal { const evaluated = getStaticValue(node, globalScope); - return evaluated != null && evaluated.value === null; + return evaluated != null && evaluated.value == null; } /** diff --git a/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts b/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts index cff8960dac8..43d4913b4ca 100644 --- a/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts +++ b/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts @@ -121,7 +121,7 @@ export default createRule({ const unionTypes = unionTypeParts(discriminantType); const caseTypes: Set = new Set(); for (const switchCase of node.cases) { - if (switchCase.test === null) { + if (switchCase.test == null) { // Switch has 'default' branch - do nothing. return; } diff --git a/packages/eslint-plugin/src/rules/triple-slash-reference.ts b/packages/eslint-plugin/src/rules/triple-slash-reference.ts index 5780d55cb5c..4425e666338 100644 --- a/packages/eslint-plugin/src/rules/triple-slash-reference.ts +++ b/packages/eslint-plugin/src/rules/triple-slash-reference.ts @@ -87,7 +87,7 @@ export default util.createRule({ } }, Program(node): void { - if (lib === 'always' && path === 'always' && types == 'always') { + if (lib === 'always' && path === 'always' && types === 'always') { return; } programNode = node; diff --git a/packages/eslint-plugin/src/util/isNullLiteral.ts b/packages/eslint-plugin/src/util/isNullLiteral.ts index f8695f26092..85bf4588212 100644 --- a/packages/eslint-plugin/src/util/isNullLiteral.ts +++ b/packages/eslint-plugin/src/util/isNullLiteral.ts @@ -2,5 +2,5 @@ import type { TSESTree } from '@typescript-eslint/utils'; import { AST_NODE_TYPES } from '@typescript-eslint/utils'; export function isNullLiteral(i: TSESTree.Node): boolean { - return i.type === AST_NODE_TYPES.Literal && i.value === null; + return i.type === AST_NODE_TYPES.Literal && i.value == null; } diff --git a/packages/eslint-plugin/tests/rules/indent/indent.test.ts b/packages/eslint-plugin/tests/rules/indent/indent.test.ts index 65fe9240377..f9191d3ef10 100644 --- a/packages/eslint-plugin/tests/rules/indent/indent.test.ts +++ b/packages/eslint-plugin/tests/rules/indent/indent.test.ts @@ -638,7 +638,7 @@ type Foo = string | { }) .filter( (error): error is TSESLint.TestCaseError => - error !== null, + error != null, ), }; if (invalid.errors.length > 0) { diff --git a/packages/eslint-plugin/tests/rules/prefer-string-starts-ends-with.test.ts b/packages/eslint-plugin/tests/rules/prefer-string-starts-ends-with.test.ts index 82a25e2f472..c9fe331c99d 100644 --- a/packages/eslint-plugin/tests/rules/prefer-string-starts-ends-with.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-string-starts-ends-with.test.ts @@ -1083,7 +1083,7 @@ function addOptional< function makeOptional(code: string): string; function makeOptional(code: string | null | undefined): string | null; function makeOptional(code: string | null | undefined): string | null { - if (code === null || code === undefined) { + if (code == null) { return null; } return ( diff --git a/packages/scope-manager/src/ScopeManager.ts b/packages/scope-manager/src/ScopeManager.ts index 5368cca1dc3..7f4b2a5f705 100644 --- a/packages/scope-manager/src/ScopeManager.ts +++ b/packages/scope-manager/src/ScopeManager.ts @@ -140,7 +140,7 @@ class ScopeManager { protected nestScope(scope: T): T; protected nestScope(scope: Scope): Scope { if (scope instanceof GlobalScope) { - assert(this.currentScope === null); + assert(this.currentScope == null); this.globalScope = scope; } this.currentScope = scope; diff --git a/packages/scope-manager/src/referencer/ClassVisitor.ts b/packages/scope-manager/src/referencer/ClassVisitor.ts index 5f84e37404f..662b70813c8 100644 --- a/packages/scope-manager/src/referencer/ClassVisitor.ts +++ b/packages/scope-manager/src/referencer/ClassVisitor.ts @@ -163,7 +163,7 @@ class ClassVisitor extends Visitor { * } */ if ( - keyName !== null && + keyName != null && this.#classNode.body.body.find( (node): node is TSESTree.MethodDefinition => node !== methodNode && diff --git a/packages/scope-manager/src/referencer/PatternVisitor.ts b/packages/scope-manager/src/referencer/PatternVisitor.ts index 308c4c29208..53de28469e8 100644 --- a/packages/scope-manager/src/referencer/PatternVisitor.ts +++ b/packages/scope-manager/src/referencer/PatternVisitor.ts @@ -97,10 +97,7 @@ class PatternVisitor extends VisitorBase { this.#callback(pattern, { topLevel: pattern === this.#rootPattern, - rest: - lastRestElement !== null && - lastRestElement !== undefined && - lastRestElement.argument === pattern, + rest: lastRestElement != null && lastRestElement.argument === pattern, assignments: this.#assignments, }); } diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts index e7b41127ba4..7a14de51df1 100644 --- a/packages/scope-manager/src/referencer/Referencer.ts +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -124,7 +124,7 @@ class Referencer extends Visitor { } private referenceJsxPragma(): void { - if (this.#jsxPragma === null || this.#hasReferencedJsxFactory) { + if (this.#jsxPragma == null || this.#hasReferencedJsxFactory) { return; } this.#hasReferencedJsxFactory = this.referenceInSomeUpperScope( @@ -134,7 +134,7 @@ class Referencer extends Visitor { private referenceJsxFragment(): void { if ( - this.#jsxFragmentName === null || + this.#jsxFragmentName == null || this.#hasReferencedJsxFragmentFactory ) { return; diff --git a/packages/typescript-estree/src/convert-comments.ts b/packages/typescript-estree/src/convert-comments.ts index ea02be41276..d4dd9f124a7 100644 --- a/packages/typescript-estree/src/convert-comments.ts +++ b/packages/typescript-estree/src/convert-comments.ts @@ -22,7 +22,7 @@ export function convertComments( ast, (_, comment) => { const type = - comment.kind == ts.SyntaxKind.SingleLineCommentTrivia + comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? AST_TOKEN_TYPES.Line : AST_TOKEN_TYPES.Block; const range: TSESTree.Range = [comment.pos, comment.end]; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index b21a42614da..70ee9da4e0c 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2183,7 +2183,7 @@ export class Converter { type: AST_NODE_TYPES.Literal, raw: rawValue, value: value, - bigint: value === null ? bigint : String(value), + bigint: value == null ? bigint : String(value), range, }); } diff --git a/packages/typescript-estree/src/getModifiers.ts b/packages/typescript-estree/src/getModifiers.ts index d8f8e716f9e..a584a7659a7 100644 --- a/packages/typescript-estree/src/getModifiers.ts +++ b/packages/typescript-estree/src/getModifiers.ts @@ -31,7 +31,7 @@ export function getModifiers( export function getDecorators( node: ts.Node | null | undefined, ): undefined | ts.Decorator[] { - if (node == undefined) { + if (node == null) { return undefined; } diff --git a/packages/typescript-estree/src/simple-traverse.ts b/packages/typescript-estree/src/simple-traverse.ts index 13c763ec228..2d51cdbe4fa 100644 --- a/packages/typescript-estree/src/simple-traverse.ts +++ b/packages/typescript-estree/src/simple-traverse.ts @@ -5,7 +5,7 @@ import type { TSESTree } from './ts-estree'; // eslint-disable-next-line @typescript-eslint/no-explicit-any function isValidNode(x: any): x is TSESTree.Node { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - return x !== null && typeof x === 'object' && typeof x.type === 'string'; + return x != null && typeof x === 'object' && typeof x.type === 'string'; } function getVisitorKeysForNode( diff --git a/packages/typescript-estree/tools/test-utils.ts b/packages/typescript-estree/tools/test-utils.ts index 6f40b597ca7..aef5601ebe2 100644 --- a/packages/typescript-estree/tools/test-utils.ts +++ b/packages/typescript-estree/tools/test-utils.ts @@ -92,7 +92,7 @@ type UnknownObject = Record; function isObjectLike(value: unknown | null): value is UnknownObject { return ( - typeof value === 'object' && !(value instanceof RegExp) && value !== null + typeof value === 'object' && !(value instanceof RegExp) && value != null ); } diff --git a/packages/utils/src/eslint-utils/applyDefault.ts b/packages/utils/src/eslint-utils/applyDefault.ts index 85cd3b3653b..f16ae798715 100644 --- a/packages/utils/src/eslint-utils/applyDefault.ts +++ b/packages/utils/src/eslint-utils/applyDefault.ts @@ -16,7 +16,7 @@ function applyDefault( JSON.stringify(defaultOptions), ) as AsMutable; - if (userOptions === null || userOptions === undefined) { + if (userOptions == null) { return options; } diff --git a/packages/utils/src/eslint-utils/nullThrows.ts b/packages/utils/src/eslint-utils/nullThrows.ts index df644c2befb..1a79b2e09d4 100644 --- a/packages/utils/src/eslint-utils/nullThrows.ts +++ b/packages/utils/src/eslint-utils/nullThrows.ts @@ -18,7 +18,7 @@ function nullThrows(value: T | null | undefined, message: string): T { // so ignore it in coverage metrics. /* istanbul ignore if */ - if (value === null || value === undefined) { + if (value == null) { throw new Error(`Non-null Assertion Failed: ${message}`); } diff --git a/packages/utils/tests/eslint-utils/nullThrows.test.ts b/packages/utils/tests/eslint-utils/nullThrows.test.ts new file mode 100644 index 00000000000..7997fecaa6d --- /dev/null +++ b/packages/utils/tests/eslint-utils/nullThrows.test.ts @@ -0,0 +1,31 @@ +import { nullThrows, NullThrowsReasons } from '../../src/eslint-utils'; + +describe('nullThrows', () => { + it('returns a falsy value when it exists', () => { + const value = 0; + + const actual = nullThrows(value, NullThrowsReasons.MissingParent); + + expect(actual).toBe(value); + }); + + it('returns a truthy value when it exists', () => { + const value = { abc: 'def' }; + + const actual = nullThrows(value, NullThrowsReasons.MissingParent); + + expect(actual).toBe(value); + }); + + it('throws an error when the value is null', () => { + expect(() => nullThrows(null, NullThrowsReasons.MissingParent)).toThrow( + NullThrowsReasons.MissingParent, + ); + }); + + it('throws an error when the value is undefined', () => { + expect(() => + nullThrows(undefined, NullThrowsReasons.MissingParent), + ).toThrow(NullThrowsReasons.MissingParent); + }); +}); diff --git a/packages/website/src/components/ast/serializer/serializer.ts b/packages/website/src/components/ast/serializer/serializer.ts index 74a94de9a47..f6c75be3302 100644 --- a/packages/website/src/components/ast/serializer/serializer.ts +++ b/packages/website/src/components/ast/serializer/serializer.ts @@ -26,7 +26,7 @@ function getSimpleModel(data: unknown): ASTViewerModelSimple { value: String(data), type: 'regexp', }; - } else if (typeof data === 'undefined' || data === null) { + } else if (data == null) { return { value: String(data), type: 'undefined', From 077ed1b5be844df35b7fba554ddae579b3144787 Mon Sep 17 00:00:00 2001 From: Eliott C Date: Tue, 31 Jan 2023 17:22:40 +0100 Subject: [PATCH 19/21] fix(eslint-plugin): do not use .at(), Node 14 does not support it (#6402) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(key-spacing): do not use .at(), Node 14 does not support it * 🚨 Coverage on at() * Apply suggestions from code review --------- Co-authored-by: Josh Goldberg --- .../eslint-plugin/src/rules/key-spacing.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin/src/rules/key-spacing.ts b/packages/eslint-plugin/src/rules/key-spacing.ts index 587d2674f4f..2562107ee05 100644 --- a/packages/eslint-plugin/src/rules/key-spacing.ts +++ b/packages/eslint-plugin/src/rules/key-spacing.ts @@ -14,6 +14,16 @@ const baseSchema = Array.isArray(baseRule.meta.schema) ? baseRule.meta.schema[0] : baseRule.meta.schema; +/** + * TODO: replace with native .at() once Node 14 stops being supported + */ +function at(arr: T[], position: number): T | undefined { + if (position < 0) { + return arr[arr.length + position]; + } + return arr[position]; +} + export default util.createRule({ name: 'key-spacing', meta: { @@ -41,7 +51,7 @@ export default util.createRule({ function adjustedColumn(position: TSESTree.Position): number { const line = position.line - 1; // position.line is 1-indexed return util.getStringLength( - sourceCode.lines[line].slice(0, position.column), + at(sourceCode.lines, line)!.slice(0, position.column), ); } @@ -87,7 +97,7 @@ export default util.createRule({ return code.slice( 0, sourceCode.getTokenAfter( - node.parameters.at(-1)!, + at(node.parameters, -1)!, util.isClosingBracketToken, )!.range[1] - node.range[0], ); @@ -102,7 +112,7 @@ export default util.createRule({ return getLastTokenBeforeColon( node.type !== AST_NODE_TYPES.TSIndexSignature ? node.key - : node.parameters.at(-1)!, + : at(node.parameters, -1)!, ).loc.end; } @@ -202,7 +212,7 @@ export default util.createRule({ if ( leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && - candidateValueStartLine - leadingComments.at(-1)!.loc.end.line <= 1 + candidateValueStartLine - at(leadingComments, -1)!.loc.end.line <= 1 ) { for (let i = 1; i < leadingComments.length; i++) { if ( @@ -373,7 +383,7 @@ export default util.createRule({ let prevNode: TSESTree.Node | undefined = undefined; for (const node of members) { - let prevAlignedNode = currentAlignGroup.at(-1); + let prevAlignedNode = at(currentAlignGroup, -1); if (prevAlignedNode !== prevNode) { prevAlignedNode = undefined; } From 056e9f089a302187d91f99359c7be8aff3cf1ea8 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Tue, 31 Jan 2023 17:34:59 +0100 Subject: [PATCH 20/21] docs(eslint-plugin): fix key-spacing core rule name (#6395) docs(key-spacing): fix core rule name --- packages/eslint-plugin/docs/rules/key-spacing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/key-spacing.md b/packages/eslint-plugin/docs/rules/key-spacing.md index 3bfcf5f389f..35108c28f86 100644 --- a/packages/eslint-plugin/docs/rules/key-spacing.md +++ b/packages/eslint-plugin/docs/rules/key-spacing.md @@ -8,5 +8,5 @@ description: 'Enforce consistent spacing between property names and type annotat ## Examples -This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/key-spacing) rule. +This rule extends the base [`eslint/key-spacing`](https://eslint.org/docs/rules/key-spacing) rule. This version adds support for type annotations on interfaces, classes and type literals properties. From 5bf7f7fe48aee61a676dfbe829c2a5e9e44cd552 Mon Sep 17 00:00:00 2001 From: Sviatoslav Zaytsev Date: Tue, 31 Jan 2023 19:37:28 +0300 Subject: [PATCH 21/21] fix(eslint-plugin): [sort-type-constituents] fixed behavior change (#6384) fix(sort-type-constituents): Fixed behavior change when sorting TSConditionalType (#6339) --- packages/eslint-plugin/src/util/misc.ts | 1 + .../tests/rules/sort-type-constituents.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/eslint-plugin/src/util/misc.ts b/packages/eslint-plugin/src/util/misc.ts index fa9c5ccf528..8362736bd62 100644 --- a/packages/eslint-plugin/src/util/misc.ts +++ b/packages/eslint-plugin/src/util/misc.ts @@ -210,6 +210,7 @@ function typeNodeRequiresParentheses( return ( node.type === AST_NODE_TYPES.TSFunctionType || node.type === AST_NODE_TYPES.TSConstructorType || + node.type === AST_NODE_TYPES.TSConditionalType || (node.type === AST_NODE_TYPES.TSUnionType && text.startsWith('|')) || (node.type === AST_NODE_TYPES.TSIntersectionType && text.startsWith('&')) ); diff --git a/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts b/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts index 1aa6f8a6c9a..42f9ab8153a 100644 --- a/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts +++ b/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts @@ -359,6 +359,7 @@ type T = 1 | string | {} | A; }, ], }, + "type A = string | (T extends number ? 'hi' : 'there');", ], invalid: [ ...invalid('|'), @@ -376,5 +377,18 @@ type T = 1 | string | {} | A; }, ], }, + { + output: "type A = string | (T extends number ? 'hi' : 'there');", + code: "type A = (T extends number ? 'hi' : 'there') | string;", + errors: [ + { + messageId: 'notSortedNamed', + data: { + type: 'Union', + name: 'A', + }, + }, + ], + }, ], });