From a0c828559187d1e167f2e095b503c887db4d4352 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 27 Oct 2022 01:02:45 -0400 Subject: [PATCH 01/76] feat(eslint-plugin) [sort-type-union-intersection-members] rename to sort-type-constituents (#5879) * feat(eslint-plugin) [sort-type-union-intersection-members] rename to sort-type-constituents * Sigh, test rename * Added back rule, with replacedBy * Fixed up rules exports --- .eslintrc.js | 2 +- .../docs/rules/sort-type-constituents.md | 101 ++++++ .../sort-type-union-intersection-members.md | 5 + packages/eslint-plugin/src/configs/all.ts | 2 +- packages/eslint-plugin/src/rules/index.ts | 2 + .../src/rules/sort-type-constituents.ts | 269 ++++++++++++++ .../sort-type-union-intersection-members.ts | 2 + .../rules/sort-type-constituents.test.ts | 334 ++++++++++++++++++ 8 files changed, 715 insertions(+), 2 deletions(-) create mode 100644 packages/eslint-plugin/docs/rules/sort-type-constituents.md create mode 100644 packages/eslint-plugin/src/rules/sort-type-constituents.ts create mode 100644 packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts diff --git a/.eslintrc.js b/.eslintrc.js index 8e62b6d06e3..da7ff36fd3b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -308,7 +308,7 @@ module.exports = { rules: { // disallow ALL unused vars '@typescript-eslint/no-unused-vars': 'error', - '@typescript-eslint/sort-type-union-intersection-members': 'error', + '@typescript-eslint/sort-type-constituents': 'error', }, }, { diff --git a/packages/eslint-plugin/docs/rules/sort-type-constituents.md b/packages/eslint-plugin/docs/rules/sort-type-constituents.md new file mode 100644 index 00000000000..264ef2b52df --- /dev/null +++ b/packages/eslint-plugin/docs/rules/sort-type-constituents.md @@ -0,0 +1,101 @@ +--- +description: 'Enforce constituents of a type union/intersection to be sorted alphabetically.' +--- + +> 🛑 This file is source code, not the primary documentation location! 🛑 +> +> See **https://typescript-eslint.io/rules/sort-type-constituents** for documentation. + +Sorting union (`|`) and intersection (`&`) types can help: + +- keep your codebase standardized +- find repeated types +- reduce diff churn + +This rule reports on any types that aren't sorted alphabetically. + +> Types are sorted case-insensitively and treating numbers like a human would, falling back to character code sorting in case of ties. + +## Examples + + + +### ❌ Incorrect + +```ts +type T1 = B | A; + +type T2 = { b: string } & { a: string }; + +type T3 = [1, 2, 4] & [1, 2, 3]; + +type T4 = + | [1, 2, 4] + | [1, 2, 3] + | { b: string } + | { a: string } + | (() => void) + | (() => string) + | 'b' + | 'a' + | 'b' + | 'a' + | readonly string[] + | readonly number[] + | string[] + | number[] + | B + | A + | string + | any; +``` + +### ✅ Correct + +```ts +type T1 = A | B; + +type T2 = { a: string } & { b: string }; + +type T3 = [1, 2, 3] & [1, 2, 4]; + +type T4 = + | any + | string + | A + | B + | number[] + | string[] + | readonly number[] + | readonly string[] + | 'a' + | 'b' + | 'a' + | 'b' + | (() => string) + | (() => void) + | { a: string } + | { b: string } + | [1, 2, 3] + | [1, 2, 4]; +``` + +## Options + +### `groupOrder` + +Each constituent of the type is placed into a group, and then the rule sorts alphabetically within each group. +The ordering of groups is determined by this option. + +- `conditional` - Conditional types (`A extends B ? C : D`) +- `function` - Function and constructor types (`() => void`, `new () => type`) +- `import` - Import types (`import('path')`) +- `intersection` - Intersection types (`A & B`) +- `keyword` - Keyword types (`any`, `string`, etc) +- `literal` - Literal types (`1`, `'b'`, `true`, etc) +- `named` - Named types (`A`, `A['prop']`, `B[]`, `Array`) +- `object` - Object types (`{ a: string }`, `{ [key: string]: number }`) +- `operator` - Operator types (`keyof A`, `typeof B`, `readonly C[]`) +- `tuple` - Tuple types (`[A, B, C]`) +- `union` - Union types (`A | B`) +- `nullish` - `null` and `undefined` diff --git a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md index 2a47547219b..dbaf1807edf 100644 --- a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md +++ b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md @@ -6,6 +6,11 @@ description: 'Enforce members of a type union/intersection to be sorted alphabet > > See **https://typescript-eslint.io/rules/sort-type-union-intersection-members** for documentation. +:::danger Deprecated + +This rule has been renamed to [`sort-type-union-intersection-members`](./sort-type-union-intersection-members.md). +::: + Sorting union (`|`) and intersection (`&`) types can help: - keep your codebase standardized diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index 1f6530ead3e..20ea892f581 100644 --- a/packages/eslint-plugin/src/configs/all.ts +++ b/packages/eslint-plugin/src/configs/all.ts @@ -154,7 +154,7 @@ export = { '@typescript-eslint/return-await': 'error', semi: 'off', '@typescript-eslint/semi': 'error', - '@typescript-eslint/sort-type-union-intersection-members': 'error', + '@typescript-eslint/sort-type-constituents': 'error', 'space-before-blocks': 'off', '@typescript-eslint/space-before-blocks': 'error', 'space-before-function-paren': 'off', diff --git a/packages/eslint-plugin/src/rules/index.ts b/packages/eslint-plugin/src/rules/index.ts index 851661400fb..8a3c2bbf437 100644 --- a/packages/eslint-plugin/src/rules/index.ts +++ b/packages/eslint-plugin/src/rules/index.ts @@ -115,6 +115,7 @@ import restrictPlusOperands from './restrict-plus-operands'; import restrictTemplateExpressions from './restrict-template-expressions'; import returnAwait from './return-await'; import semi from './semi'; +import sortTypeConstituents from './sort-type-constituents'; import sortTypeUnionIntersectionMembers from './sort-type-union-intersection-members'; import spaceBeforeBlocks from './space-before-blocks'; import spaceBeforeFunctionParen from './space-before-function-paren'; @@ -245,6 +246,7 @@ export default { 'restrict-template-expressions': restrictTemplateExpressions, 'return-await': returnAwait, semi: semi, + 'sort-type-constituents': sortTypeConstituents, 'sort-type-union-intersection-members': sortTypeUnionIntersectionMembers, 'space-before-blocks': spaceBeforeBlocks, 'space-before-function-paren': spaceBeforeFunctionParen, diff --git a/packages/eslint-plugin/src/rules/sort-type-constituents.ts b/packages/eslint-plugin/src/rules/sort-type-constituents.ts new file mode 100644 index 00000000000..92b5e44c6f9 --- /dev/null +++ b/packages/eslint-plugin/src/rules/sort-type-constituents.ts @@ -0,0 +1,269 @@ +import type { TSESLint, TSESTree } from '@typescript-eslint/utils'; +import { AST_NODE_TYPES } from '@typescript-eslint/utils'; + +import * as util from '../util'; +import { getEnumNames } from '../util'; + +enum Group { + conditional = 'conditional', + function = 'function', + import = 'import', + intersection = 'intersection', + keyword = 'keyword', + nullish = 'nullish', + literal = 'literal', + named = 'named', + object = 'object', + operator = 'operator', + tuple = 'tuple', + union = 'union', +} + +function getGroup(node: TSESTree.TypeNode): Group { + switch (node.type) { + case AST_NODE_TYPES.TSConditionalType: + return Group.conditional; + + case AST_NODE_TYPES.TSConstructorType: + case AST_NODE_TYPES.TSFunctionType: + return Group.function; + + case AST_NODE_TYPES.TSImportType: + return Group.import; + + case AST_NODE_TYPES.TSIntersectionType: + return Group.intersection; + + case AST_NODE_TYPES.TSAnyKeyword: + case AST_NODE_TYPES.TSBigIntKeyword: + case AST_NODE_TYPES.TSBooleanKeyword: + case AST_NODE_TYPES.TSNeverKeyword: + case AST_NODE_TYPES.TSNumberKeyword: + case AST_NODE_TYPES.TSObjectKeyword: + case AST_NODE_TYPES.TSStringKeyword: + case AST_NODE_TYPES.TSSymbolKeyword: + case AST_NODE_TYPES.TSThisType: + case AST_NODE_TYPES.TSUnknownKeyword: + case AST_NODE_TYPES.TSIntrinsicKeyword: + return Group.keyword; + + case AST_NODE_TYPES.TSNullKeyword: + case AST_NODE_TYPES.TSUndefinedKeyword: + case AST_NODE_TYPES.TSVoidKeyword: + return Group.nullish; + + case AST_NODE_TYPES.TSLiteralType: + case AST_NODE_TYPES.TSTemplateLiteralType: + return Group.literal; + + case AST_NODE_TYPES.TSArrayType: + case AST_NODE_TYPES.TSIndexedAccessType: + case AST_NODE_TYPES.TSInferType: + case AST_NODE_TYPES.TSTypeReference: + return Group.named; + + case AST_NODE_TYPES.TSMappedType: + case AST_NODE_TYPES.TSTypeLiteral: + return Group.object; + + case AST_NODE_TYPES.TSTypeOperator: + case AST_NODE_TYPES.TSTypeQuery: + return Group.operator; + + case AST_NODE_TYPES.TSTupleType: + return Group.tuple; + + case AST_NODE_TYPES.TSUnionType: + return Group.union; + + // These types should never occur as part of a union/intersection + case AST_NODE_TYPES.TSAbstractKeyword: + case AST_NODE_TYPES.TSAsyncKeyword: + case AST_NODE_TYPES.TSDeclareKeyword: + case AST_NODE_TYPES.TSExportKeyword: + case AST_NODE_TYPES.TSNamedTupleMember: + case AST_NODE_TYPES.TSOptionalType: + case AST_NODE_TYPES.TSPrivateKeyword: + case AST_NODE_TYPES.TSProtectedKeyword: + case AST_NODE_TYPES.TSPublicKeyword: + case AST_NODE_TYPES.TSReadonlyKeyword: + case AST_NODE_TYPES.TSRestType: + case AST_NODE_TYPES.TSStaticKeyword: + case AST_NODE_TYPES.TSTypePredicate: + /* istanbul ignore next */ + throw new Error(`Unexpected Type ${node.type}`); + } +} + +function requiresParentheses(node: TSESTree.TypeNode): boolean { + return ( + node.type === AST_NODE_TYPES.TSFunctionType || + node.type === AST_NODE_TYPES.TSConstructorType + ); +} + +export type Options = [ + { + checkIntersections?: boolean; + checkUnions?: boolean; + groupOrder?: string[]; + }, +]; +export type MessageIds = 'notSorted' | 'notSortedNamed' | 'suggestFix'; + +export default util.createRule({ + name: 'sort-type-constituents', + meta: { + type: 'suggestion', + docs: { + description: + 'Enforce constituents of a type union/intersection to be sorted alphabetically', + recommended: false, + }, + fixable: 'code', + hasSuggestions: true, + messages: { + notSorted: '{{type}} type constituents must be sorted.', + notSortedNamed: '{{type}} type {{name}} constituents must be sorted.', + suggestFix: 'Sort constituents of type (removes all comments).', + }, + schema: [ + { + type: 'object', + properties: { + checkIntersections: { + description: 'Whether to check intersection types.', + type: 'boolean', + }, + checkUnions: { + description: 'Whether to check union types.', + type: 'boolean', + }, + groupOrder: { + description: 'Ordering of the groups.', + type: 'array', + items: { + type: 'string', + enum: getEnumNames(Group), + }, + }, + }, + }, + ], + }, + defaultOptions: [ + { + checkIntersections: true, + checkUnions: true, + groupOrder: [ + Group.named, + Group.keyword, + Group.operator, + Group.literal, + Group.function, + Group.import, + Group.conditional, + Group.object, + Group.tuple, + Group.intersection, + Group.union, + Group.nullish, + ], + }, + ], + create(context, [{ checkIntersections, checkUnions, groupOrder }]) { + const sourceCode = context.getSourceCode(); + + const collator = new Intl.Collator('en', { + sensitivity: 'base', + numeric: true, + }); + + function checkSorting( + node: TSESTree.TSIntersectionType | TSESTree.TSUnionType, + ): void { + const sourceOrder = node.types.map(type => { + const group = groupOrder?.indexOf(getGroup(type)) ?? -1; + return { + group: group === -1 ? Number.MAX_SAFE_INTEGER : group, + node: type, + text: sourceCode.getText(type), + }; + }); + const expectedOrder = [...sourceOrder].sort((a, b) => { + if (a.group !== b.group) { + return a.group - b.group; + } + + return ( + collator.compare(a.text, b.text) || + (a.text < b.text ? -1 : a.text > b.text ? 1 : 0) + ); + }); + + const hasComments = node.types.some(type => { + const count = + sourceCode.getCommentsBefore(type).length + + sourceCode.getCommentsAfter(type).length; + return count > 0; + }); + + for (let i = 0; i < expectedOrder.length; i += 1) { + if (expectedOrder[i].node !== sourceOrder[i].node) { + let messageId: MessageIds = 'notSorted'; + const data = { + name: '', + type: + node.type === AST_NODE_TYPES.TSIntersectionType + ? 'Intersection' + : 'Union', + }; + if (node.parent?.type === AST_NODE_TYPES.TSTypeAliasDeclaration) { + messageId = 'notSortedNamed'; + data.name = node.parent.id.name; + } + + const fix: TSESLint.ReportFixFunction = fixer => { + const sorted = expectedOrder + .map(t => (requiresParentheses(t.node) ? `(${t.text})` : t.text)) + .join( + node.type === AST_NODE_TYPES.TSIntersectionType ? ' & ' : ' | ', + ); + + return fixer.replaceText(node, sorted); + }; + return context.report({ + node, + messageId, + data, + // don't autofix if any of the types have leading/trailing comments + // the logic for preserving them correctly is a pain - we may implement this later + ...(hasComments + ? { + suggest: [ + { + messageId: 'suggestFix', + fix, + }, + ], + } + : { fix }), + }); + } + } + } + + return { + ...(checkIntersections && { + TSIntersectionType(node): void { + checkSorting(node); + }, + }), + ...(checkUnions && { + TSUnionType(node): void { + checkSorting(node); + }, + }), + }; + }, +}); diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index ded7212c6c9..2a83b4b0525 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -114,6 +114,7 @@ export type MessageIds = 'notSorted' | 'notSortedNamed' | 'suggestFix'; export default util.createRule({ name: 'sort-type-union-intersection-members', meta: { + deprecated: true, type: 'suggestion', docs: { description: @@ -127,6 +128,7 @@ export default util.createRule({ notSortedNamed: '{{type}} type {{name}} members must be sorted.', suggestFix: 'Sort members of type (removes all comments).', }, + replacedBy: ['@typescript-eslint/sort-type-constituents'], schema: [ { type: 'object', diff --git a/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts b/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts new file mode 100644 index 00000000000..b9989c2cf87 --- /dev/null +++ b/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts @@ -0,0 +1,334 @@ +import type { TSESLint } from '@typescript-eslint/utils'; + +import type { + MessageIds, + Options, +} from '../../src/rules/sort-type-constituents'; +import rule from '../../src/rules/sort-type-constituents'; +import { noFormat, RuleTester } from '../RuleTester'; + +const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser', +}); + +const valid = (operator: '|' | '&'): TSESLint.ValidTestCase[] => [ + { + code: `type T = A ${operator} B;`, + }, + { + code: `type T = A ${operator} /* comment */ B;`, + }, + { + code: `type T = 'A' ${operator} 'B';`, + }, + { + code: `type T = 1 ${operator} 2;`, + }, + { + code: noFormat`type T = (A) ${operator} (B);`, + }, + { + code: `type T = { a: string } ${operator} { b: string };`, + }, + { + code: `type T = [1, 2, 3] ${operator} [1, 2, 4];`, + }, + { + code: `type T = (() => string) ${operator} (() => void);`, + }, + { + code: `type T = () => string ${operator} void;`, + }, + { + // testing the default ordering + code: noFormat` +type T = + ${operator} A + ${operator} B + ${operator} intrinsic + ${operator} number[] + ${operator} string[] + ${operator} any + ${operator} string + ${operator} symbol + ${operator} this + ${operator} readonly number[] + ${operator} readonly string[] + ${operator} 'a' + ${operator} 'b' + ${operator} "a" + ${operator} "b" + ${operator} (() => string) + ${operator} (() => void) + ${operator} (new () => string) + ${operator} (new () => void) + ${operator} import('bar') + ${operator} import('foo') + ${operator} (number extends string ? unknown : never) + ${operator} (string extends string ? unknown : never) + ${operator} { [a in string]: string } + ${operator} { [a: string]: string } + ${operator} { [b in string]: string } + ${operator} { [b: string]: string } + ${operator} { a: string } + ${operator} { b: string } + ${operator} [1, 2, 3] + ${operator} [1, 2, 4] + ${operator} (A & B) + ${operator} (B & C) + ${operator} (A | B) + ${operator} (B | C) + ${operator} null + ${operator} undefined + `, + }, +]; +const invalid = ( + operator: '|' | '&', +): TSESLint.InvalidTestCase[] => { + const type = operator === '|' ? 'Union' : 'Intersection'; + return [ + { + code: `type T = B ${operator} A;`, + output: `type T = A ${operator} B;`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = 'B' ${operator} 'A';`, + output: `type T = 'A' ${operator} 'B';`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = 2 ${operator} 1;`, + output: `type T = 1 ${operator} 2;`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: noFormat`type T = (B) ${operator} (A);`, + output: `type T = A ${operator} B;`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = { b: string } ${operator} { a: string };`, + output: `type T = { a: string } ${operator} { b: string };`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = [1, 2, 4] ${operator} [1, 2, 3];`, + output: `type T = [1, 2, 3] ${operator} [1, 2, 4];`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = (() => void) ${operator} (() => string);`, + output: `type T = (() => string) ${operator} (() => void);`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = () => void ${operator} string;`, + output: `type T = () => string ${operator} void;`, + errors: [ + { + messageId: 'notSorted', + data: { + type, + }, + }, + ], + }, + { + code: `type T = () => undefined ${operator} null;`, + output: `type T = () => null ${operator} undefined;`, + errors: [ + { + messageId: 'notSorted', + data: { + type, + }, + }, + ], + }, + { + code: noFormat` +type T = + ${operator} [1, 2, 4] + ${operator} [1, 2, 3] + ${operator} { b: string } + ${operator} { a: string } + ${operator} (() => void) + ${operator} (() => string) + ${operator} "b" + ${operator} "a" + ${operator} 'b' + ${operator} 'a' + ${operator} readonly string[] + ${operator} readonly number[] + ${operator} string[] + ${operator} number[] + ${operator} B + ${operator} A + ${operator} undefined + ${operator} null + ${operator} string + ${operator} any; + `, + output: ` +type T = + A ${operator} B ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined; + `, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + }, + ], + }, + { + code: `type T = B ${operator} /* comment */ A;`, + output: null, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + suggestions: [ + { + messageId: 'suggestFix', + output: `type T = A ${operator} B;`, + }, + ], + }, + ], + }, + { + code: `type T = (() => /* comment */ A) ${operator} B;`, + output: `type T = B ${operator} (() => /* comment */ A);`, + errors: [ + { + messageId: 'notSortedNamed', + data: { + type, + name: 'T', + }, + suggestions: null, + }, + ], + }, + { + code: `type Expected = (new (x: number) => boolean) ${operator} string;`, + output: `type Expected = string ${operator} (new (x: number) => boolean);`, + errors: [ + { + messageId: 'notSortedNamed', + }, + ], + }, + ]; +}; + +ruleTester.run('sort-type-constituents', rule, { + valid: [ + ...valid('|'), + { + code: 'type T = B | A;', + options: [ + { + checkUnions: false, + }, + ], + }, + + ...valid('&'), + { + code: 'type T = B & A;', + options: [ + { + checkIntersections: false, + }, + ], + }, + + { + code: noFormat` +type T = [1] | 'a' | 'b' | "b" | 1 | 2 | {}; + `, + options: [ + { + groupOrder: ['tuple', 'literal', 'object'], + }, + ], + }, + { + // if not specified - groups should be placed last + code: ` +type T = 1 | string | {} | A; + `, + options: [ + { + groupOrder: ['literal', 'keyword'], + }, + ], + }, + ], + invalid: [...invalid('|'), ...invalid('&')], +}); From 344322add846d03c6c9981e486b09e6ba1196555 Mon Sep 17 00:00:00 2001 From: Shogo Hida Date: Thu, 27 Oct 2022 14:12:13 +0900 Subject: [PATCH 02/76] fix(eslint-plugin): enable react/jsx-curly-brace-presence lint rule in website package (#5894) Add 'react/jsx-curly-brace-presence': 'error' Co-authored-by: Josh Goldberg --- packages/website/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/website/.eslintrc.js b/packages/website/.eslintrc.js index 2359a5a4cd5..323ce34a38d 100644 --- a/packages/website/.eslintrc.js +++ b/packages/website/.eslintrc.js @@ -23,6 +23,7 @@ module.exports = { 'react/jsx-no-target-blank': 'off', 'react/no-unescaped-entities': 'off', '@typescript-eslint/internal/prefer-ast-types-enum': 'off', + 'react/jsx-curly-brace-presence': 'error', }, settings: { react: { From d806bda82343712a24e3c78b9b34d4345dd1de3b Mon Sep 17 00:00:00 2001 From: kmin-jeong <53456037+kmin-jeong@users.noreply.github.com> Date: Sat, 29 Oct 2022 21:45:53 +0900 Subject: [PATCH 03/76] feat(eslint-plugin): [no-invalid-void-type] better report message for void used as a constituent inside a function return type (#5274) * feat: update repository * remove duplicate examples * feat:add about re-exporting --isolatedModules in When Not To Use It * feat: add exmaples * fix: remove duplicate examples in correct * fix:correct words * fix: fix space-between * fix: fix code * fix: fix code space * fix: check error * fix:missed examples * feat: read review and fix them fix examples and --Isolatedmodules explain * feat: add two taps one is correct, another is incorrect * fix: add * feat: fix explaination about `isolatedmodules` * fix: fix explain about `isolatedModules` * fis: modify When no to use it * fix: revert change log * fix: add lint * fix: add lint * add: fix code * fix:fix docs splits * feat: add lint * Update packages/eslint-plugin/docs/rules/consistent-type-exports.md * feat:change error message better * fix:separating message and made types about union * fix: separate error message * fix:fix mistake type * fix:fix typo * fix:fix error message in case of union * fix:fix error message in InvalidVoidForUnion * fix: add logic about union * feat: add test case * Switched change to just enhance error message * oops comment Co-authored-by: Josh Goldberg Co-authored-by: Josh Goldberg --- .../src/rules/no-invalid-void-type.ts | 23 +++++++++++----- .../tests/rules/no-invalid-void-type.test.ts | 26 ++++++++++++++++--- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts index 7cda184e4fd..9f938ac438f 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts @@ -13,7 +13,8 @@ type MessageIds = | 'invalidVoidNotReturnOrGeneric' | 'invalidVoidNotReturn' | 'invalidVoidNotReturnOrThisParam' - | 'invalidVoidNotReturnOrThisParamOrGeneric'; + | 'invalidVoidNotReturnOrThisParamOrGeneric' + | 'invalidVoidUnionConstituent'; export default util.createRule<[Options], MessageIds>({ name: 'no-invalid-void-type', @@ -25,14 +26,16 @@ export default util.createRule<[Options], MessageIds>({ }, messages: { invalidVoidForGeneric: - '{{ generic }} may not have void as a type variable.', + '{{ generic }} may not have void as a type argument.', invalidVoidNotReturnOrGeneric: - 'void is only valid as a return type or generic type variable.', + 'void is only valid as a return type or generic type argument.', invalidVoidNotReturn: 'void is only valid as a return type.', invalidVoidNotReturnOrThisParam: 'void is only valid as return type or type of `this` parameter.', invalidVoidNotReturnOrThisParamOrGeneric: - 'void is only valid as a return type or generic type variable or the type of a `this` parameter.', + 'void is only valid as a return type or generic type argument or the type of a `this` parameter.', + invalidVoidUnionConstituent: + 'void is not valid as a constituent in a union type', }, schema: [ { @@ -136,7 +139,7 @@ export default util.createRule<[Options], MessageIds>({ ): void { if (parentNode.default !== node) { context.report({ - messageId: 'invalidVoidNotReturnOrGeneric', + messageId: getNotReturnOrGenericMessageId(node), node, }); } @@ -218,7 +221,7 @@ export default util.createRule<[Options], MessageIds>({ allowInGenericTypeArguments && allowAsThisParameter ? 'invalidVoidNotReturnOrThisParamOrGeneric' : allowInGenericTypeArguments - ? 'invalidVoidNotReturnOrGeneric' + ? getNotReturnOrGenericMessageId(node) : allowAsThisParameter ? 'invalidVoidNotReturnOrThisParam' : 'invalidVoidNotReturn', @@ -228,3 +231,11 @@ export default util.createRule<[Options], MessageIds>({ }; }, }); + +function getNotReturnOrGenericMessageId( + node: TSESTree.TSVoidKeyword, +): MessageIds { + return node.parent!.type === AST_NODE_TYPES.TSUnionType + ? 'invalidVoidUnionConstituent' + : 'invalidVoidNotReturnOrGeneric'; +} diff --git a/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts b/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts index 8164e85b2bd..1a972b665be 100644 --- a/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts +++ b/packages/eslint-plugin/tests/rules/no-invalid-void-type.test.ts @@ -316,7 +316,7 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { code: 'type UnionType2 = string | number | void;', errors: [ { - messageId: 'invalidVoidNotReturnOrGeneric', + messageId: 'invalidVoidUnionConstituent', line: 1, column: 37, }, @@ -326,12 +326,32 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { code: 'type UnionType3 = string | ((number & any) | (string | void));', errors: [ { - messageId: 'invalidVoidNotReturnOrGeneric', + messageId: 'invalidVoidUnionConstituent', line: 1, column: 56, }, ], }, + { + code: 'declare function test(): number | void;', + errors: [ + { + messageId: 'invalidVoidUnionConstituent', + line: 1, + column: 35, + }, + ], + }, + { + code: 'declare function test(): T;', + errors: [ + { + messageId: 'invalidVoidUnionConstituent', + line: 1, + column: 42, + }, + ], + }, { code: 'type IntersectionType = string & number & void;', errors: [ @@ -394,7 +414,7 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, { code: 'type invalidVoidUnion = void | Map;', errors: [ { - messageId: 'invalidVoidNotReturnOrGeneric', + messageId: 'invalidVoidUnionConstituent', line: 1, column: 25, }, From 891b0879ba9c64a4722b8c0bf9e599a725b6d6df Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 29 Oct 2022 06:25:11 -0700 Subject: [PATCH 04/76] fix(typescript-estree): don't allow single-run unless we're in type-aware linting mode (#5893) Co-authored-by: Josh Goldberg --- .../src/parseSettings/inferSingleRun.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts index 723f857ece9..5d765a22ce9 100644 --- a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts +++ b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts @@ -15,6 +15,16 @@ import type { TSESTreeOptions } from '../parser-options'; * @returns Whether this is part of a single run, rather than a long-running process. */ export function inferSingleRun(options: TSESTreeOptions | undefined): boolean { + if ( + // single-run implies type-aware linting - no projects means we can't be in single-run mode + options?.project == null || + // programs passed via options means the user should be managing the programs, so we shouldn't + // be creating our own single-run programs accidentally + options?.programs != null + ) { + return false; + } + // Allow users to explicitly inform us of their intent to perform a single run (or not) with TSESTREE_SINGLE_RUN if (process.env.TSESTREE_SINGLE_RUN === 'false') { return false; From 8ed72192c274249d26628fb125796e71318b857a Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Sun, 30 Oct 2022 12:25:18 +0900 Subject: [PATCH 05/76] fix(eslint-plugin): [no-extra-parens] handle type assertion in extends clause (#5901) * fix(eslint-plugin): [no-extra-parens] handle type assertion in extends clause * Add test cases * Handle class expression * Add test cases --- .../src/rules/no-extra-parens.ts | 26 +++++++++++++-- .../tests/rules/no-extra-parens.test.ts | 32 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-extra-parens.ts b/packages/eslint-plugin/src/rules/no-extra-parens.ts index 3a4a5973074..a44276a0a76 100644 --- a/packages/eslint-plugin/src/rules/no-extra-parens.ts +++ b/packages/eslint-plugin/src/rules/no-extra-parens.ts @@ -141,8 +141,30 @@ export default util.createRule({ }, BinaryExpression: binaryExp, CallExpression: callExp, - // ClassDeclaration - // ClassExpression + ClassDeclaration(node) { + if (node.superClass?.type === AST_NODE_TYPES.TSAsExpression) { + return rules.ClassDeclaration({ + ...node, + superClass: { + ...node.superClass, + type: AST_NODE_TYPES.SequenceExpression as any, + }, + }); + } + return rules.ClassDeclaration(node); + }, + ClassExpression(node) { + if (node.superClass?.type === AST_NODE_TYPES.TSAsExpression) { + return rules.ClassExpression({ + ...node, + superClass: { + ...node.superClass, + type: AST_NODE_TYPES.SequenceExpression as any, + }, + }); + } + return rules.ClassExpression(node); + }, ConditionalExpression(node) { // reduces the precedence of the node so the rule thinks it needs to be wrapped if (util.isTypeAssertion(node.test)) { diff --git a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts index 6a9e87111aa..369f55101f2 100644 --- a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts +++ b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts @@ -141,6 +141,10 @@ t.true((me.get as SinonStub).calledWithExactly('/foo', other)); t.true((me.get).calledWithExactly('/foo', other)); (requestInit.headers as Headers).get('Cookie'); ( requestInit.headers).get('Cookie'); +class Foo {} +class Foo extends (Bar as any) {} +const foo = class {}; +const foo = class extends (Bar as any) {} `, parserOptions: { ecmaFeatures: { @@ -254,6 +258,10 @@ new a((1)); a<(A)>((1)); async function f(arg: Promise) { await (arg); } async function f(arg: any) { await ((arg as Promise)); } +class Foo extends ((Bar as any)) {} +class Foo extends (Bar) {} +const foo = class extends ((Bar as any)) {} +const foo = class extends (Bar) {} `, output: ` a = b * c; @@ -267,6 +275,10 @@ new a(1); a<(A)>(1); async function f(arg: Promise) { await arg; } async function f(arg: any) { await (arg as Promise); } +class Foo extends (Bar as any) {} +class Foo extends Bar {} +const foo = class extends (Bar as any) {} +const foo = class extends Bar {} `, errors: [ { @@ -324,6 +336,26 @@ async function f(arg: any) { await (arg as Promise); } line: 12, column: 37, }, + { + messageId: 'unexpected', + line: 13, + column: 20, + }, + { + messageId: 'unexpected', + line: 14, + column: 19, + }, + { + messageId: 'unexpected', + line: 15, + column: 28, + }, + { + messageId: 'unexpected', + line: 16, + column: 27, + }, ], }), ...batchedSingleLineTests({ From 54141946ac2a25799bb622d47d9a3fd1fb316ef9 Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" <53356952+typescript-eslint[bot]@users.noreply.github.com> Date: Sun, 30 Oct 2022 23:03:00 -0400 Subject: [PATCH 06/76] chore: update sponsors (#5905) Co-authored-by: typescript-eslint[bot] --- packages/website/data/sponsors.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/website/data/sponsors.json b/packages/website/data/sponsors.json index faef97d207f..a4aa0623e04 100644 --- a/packages/website/data/sponsors.json +++ b/packages/website/data/sponsors.json @@ -39,6 +39,14 @@ "totalDonations": 120000, "website": "https://blog.coinbase.com/engineering-and-security/home" }, + { + "id": "Sentry", + "image": "https://images.opencollective.com/sentry/9620d33/logo.png", + "name": "Sentry", + "tier": "sponsor", + "totalDonations": 114800, + "website": "https://sentry.io/welcome/" + }, { "id": "n8n.io - n8n GmbH", "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", @@ -79,14 +87,6 @@ "totalDonations": 54000, "website": "https://www.future-processing.com/" }, - { - "id": "Sentry", - "image": "https://images.opencollective.com/sentry/9620d33/logo.png", - "name": "Sentry", - "tier": "supporter", - "totalDonations": 50000, - "website": "https://sentry.io/welcome/" - }, { "id": "Whitebox", "image": "https://images.opencollective.com/whiteboxinc/ef0d11d/logo.png", From 1f14c03d2696ce02537c08aba683bdd587de5e6b Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 31 Oct 2022 03:53:04 -0700 Subject: [PATCH 07/76] docs(eslint-plugin): [consistent-type-imports] make a note about `parserOptions.emitDecoratorMetadata` (#5904) * docs(eslint-plugin): [consistent-type-imports] make a note about `parserOptions.emitDecoratorMetadata` * Update consistent-type-imports.md * Update consistent-type-imports.md * Update consistent-type-imports.md * Update consistent-type-imports.md --- .../eslint-plugin/docs/rules/consistent-type-imports.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 6e6912d34cf..745930d0d54 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -48,6 +48,12 @@ type T = import('Foo').Foo; const x: import('Bar') = 1; ``` +## Usage with `emitDecoratorMetadata` + +The `emitDecoratorMetadata` compiler option changes the code the TypeScript emits. In short - it causes TypeScript to create references to value imports when they are used in a type-only location. If you are using `emitDecoratorMetadata` then our tooling will require additional information in order for the rule to work correctly. + +If you are using [type-aware linting](https://typescript-eslint.io/docs/linting/typed-linting), then you just need to ensure that the `tsconfig.json` you've configured for `parserOptions.project` has `emitDecoratorMetadata` turned on. Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on [by setting `parserOptions.emitDecoratorMetadata` to `true`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionsemitdecoratormetadata). + ## When Not To Use It - If you specifically want to use both import kinds for stylistic reasons, you can disable this rule. From 0520d53536af411d66ce2ce0dd478365e67adbac Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 31 Oct 2022 05:03:38 -0700 Subject: [PATCH 08/76] feat(utils): add `RuleTester` API for top-level dependency constraints (#5896) * feat(utils): add `RuleTester` API for top-level dependency constraints * Apply suggestions from code review Co-authored-by: Josh Goldberg * address comments * oops Co-authored-by: Josh Goldberg --- .../eslint-utils/rule-tester/RuleTester.ts | 89 +++++++++++++++--- packages/utils/src/ts-eslint/RuleTester.ts | 21 ++--- .../rule-tester/RuleTester.test.ts | 91 ++++++++++++++++++- 3 files changed, 175 insertions(+), 26 deletions(-) diff --git a/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts b/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts index e81d23d0206..54a645ccf25 100644 --- a/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts +++ b/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts @@ -1,9 +1,13 @@ import type * as TSESLintParserType from '@typescript-eslint/parser'; +import assert from 'assert'; import { version as eslintVersion } from 'eslint/package.json'; import * as path from 'path'; import * as semver from 'semver'; -import * as TSESLint from '../../ts-eslint'; +import type { ParserOptions } from '../../ts-eslint/ParserOptions'; +import type { RuleModule } from '../../ts-eslint/Rule'; +import type { RuleTesterTestFrameworkFunction } from '../../ts-eslint/RuleTester'; +import * as BaseRuleTester from '../../ts-eslint/RuleTester'; import { deepMerge } from '../deepMerge'; import type { DependencyConstraint } from './dependencyConstraints'; import { satisfiesAllDependencyConstraints } from './dependencyConstraints'; @@ -11,18 +15,28 @@ import { satisfiesAllDependencyConstraints } from './dependencyConstraints'; const TS_ESLINT_PARSER = '@typescript-eslint/parser'; const ERROR_MESSAGE = `Do not set the parser at the test level unless you want to use a parser other than ${TS_ESLINT_PARSER}`; -type RuleTesterConfig = Omit & { +type RuleTesterConfig = Omit & { parser: typeof TS_ESLINT_PARSER; + /** + * Constraints that must pass in the current environment for any tests to run + */ + dependencyConstraints?: DependencyConstraint; }; interface InvalidTestCase< TMessageIds extends string, TOptions extends Readonly, -> extends TSESLint.InvalidTestCase { +> extends BaseRuleTester.InvalidTestCase { + /** + * Constraints that must pass in the current environment for the test to run + */ dependencyConstraints?: DependencyConstraint; } interface ValidTestCase> - extends TSESLint.ValidTestCase { + extends BaseRuleTester.ValidTestCase { + /** + * Constraints that must pass in the current environment for the test to run + */ dependencyConstraints?: DependencyConstraint; } interface RunTests< @@ -36,24 +50,42 @@ interface RunTests< type AfterAll = (fn: () => void) => void; -class RuleTester extends TSESLint.RuleTester { +function isDescribeWithSkip( + value: unknown, +): value is RuleTesterTestFrameworkFunction & { + skip: RuleTesterTestFrameworkFunction; +} { + return ( + typeof value === 'object' && + value != null && + 'skip' in value && + typeof (value as Record).skip === 'function' + ); +} + +class RuleTester extends BaseRuleTester.RuleTester { readonly #baseOptions: RuleTesterConfig; - static #afterAll: AfterAll; + static #afterAll: AfterAll | undefined; /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. */ static get afterAll(): AfterAll { return ( - this.#afterAll || + this.#afterAll ?? (typeof afterAll === 'function' ? afterAll : (): void => {}) ); } - static set afterAll(value) { + static set afterAll(value: AfterAll | undefined) { this.#afterAll = value; } + private get staticThis(): typeof RuleTester { + // the cast here is due to https://github.com/microsoft/TypeScript/issues/3841 + return this.constructor as typeof RuleTester; + } + constructor(baseOptions: RuleTesterConfig) { super({ ...baseOptions, @@ -73,8 +105,7 @@ class RuleTester extends TSESLint.RuleTester { // make sure that the parser doesn't hold onto file handles between tests // on linux (i.e. our CI env), there can be very a limited number of watch handles available - // the cast here is due to https://github.com/microsoft/TypeScript/issues/3841 - (this.constructor as typeof RuleTester).afterAll(() => { + this.staticThis.afterAll(() => { try { // instead of creating a hard dependency, just use a soft require // a bit weird, but if they're using this tooling, it'll be installed @@ -85,11 +116,11 @@ class RuleTester extends TSESLint.RuleTester { } }); } - private getFilename(testOptions?: TSESLint.ParserOptions): string { + private getFilename(testOptions?: ParserOptions): string { const resolvedOptions = deepMerge( this.#baseOptions.parserOptions, testOptions, - ) as TSESLint.ParserOptions; + ) as ParserOptions; const filename = `file.ts${resolvedOptions.ecmaFeatures?.jsx ? 'x' : ''}`; if (resolvedOptions.project) { return path.join( @@ -107,9 +138,41 @@ class RuleTester extends TSESLint.RuleTester { // This is a lot more explicit run>( name: string, - rule: TSESLint.RuleModule, + rule: RuleModule, testsReadonly: RunTests, ): void { + if ( + this.#baseOptions.dependencyConstraints && + !satisfiesAllDependencyConstraints( + this.#baseOptions.dependencyConstraints, + ) + ) { + if (isDescribeWithSkip(this.staticThis.describe)) { + // for frameworks like mocha or jest that have a "skip" version of their function + // we can provide a nice skipped test! + this.staticThis.describe.skip(name, () => { + this.staticThis.it( + 'All tests skipped due to unsatisfied constructor dependency constraints', + () => {}, + ); + }); + } else { + // otherwise just declare an empty test + this.staticThis.describe(name, () => { + this.staticThis.it( + 'All tests skipped due to unsatisfied constructor dependency constraints', + () => { + // some frameworks error if there are no assertions + assert.equal(true, true); + }, + ); + }); + } + + // don't run any tests because we don't match the base constraint + return; + } + const tests = { // standardize the valid tests as objects valid: testsReadonly.valid.map(test => { diff --git a/packages/utils/src/ts-eslint/RuleTester.ts b/packages/utils/src/ts-eslint/RuleTester.ts index 7002fc538cd..6c0b98b795f 100644 --- a/packages/utils/src/ts-eslint/RuleTester.ts +++ b/packages/utils/src/ts-eslint/RuleTester.ts @@ -125,6 +125,10 @@ interface TestCaseError { // readonly message?: string | RegExp; } +/** + * @param text a string describing the rule + * @param callback the test callback + */ type RuleTesterTestFrameworkFunction = ( text: string, callback: () => void, @@ -166,31 +170,26 @@ declare class RuleTesterBase { /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. - * @param text a string describing the rule - * @param callback the test callback */ - static describe?: RuleTesterTestFrameworkFunction; + static get describe(): RuleTesterTestFrameworkFunction; + static set describe(value: RuleTesterTestFrameworkFunction | undefined); /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. - * @param text a string describing the test case - * @param callback the test callback */ - static it?: RuleTesterTestFrameworkFunction; + static get it(): RuleTesterTestFrameworkFunction; + static set it(value: RuleTesterTestFrameworkFunction | undefined); /** * If you supply a value to this property, the rule tester will call this instead of using the version defined on * the global namespace. - * @param text a string describing the test case - * @param callback the test callback */ - static itOnly?: RuleTesterTestFrameworkFunction; + static get itOnly(): RuleTesterTestFrameworkFunction; + static set itOnly(value: RuleTesterTestFrameworkFunction | undefined); /** * Define a rule for one particular run of tests. - * @param name The name of the rule to define. - * @param rule The rule definition. */ defineRule>( name: string, diff --git a/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts b/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts index cab7666196a..2e620332942 100644 --- a/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts +++ b/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts @@ -73,8 +73,8 @@ RuleTester.itOnly = jest.fn(); /* eslint-enable jest/prefer-spy-on */ const mockedAfterAll = jest.mocked(RuleTester.afterAll); -const _mockedDescribe = jest.mocked(RuleTester.describe); -const _mockedIt = jest.mocked(RuleTester.it); +const mockedDescribe = jest.mocked(RuleTester.describe); +const mockedIt = jest.mocked(RuleTester.it); const _mockedItOnly = jest.mocked(RuleTester.itOnly); const runSpy = jest.spyOn(BaseRuleTester.prototype, 'run'); const mockedParserClearCaches = jest.mocked(parser.clearCaches); @@ -715,5 +715,92 @@ describe('RuleTester', () => { } `); }); + + describe('constructor constraints', () => { + it('skips all tests if a constructor constraint is not satisifed', () => { + const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser', + dependencyConstraints: { + 'totally-real-dependency': '999', + }, + }); + + ruleTester.run('my-rule', NOOP_RULE, { + invalid: [ + { + code: 'failing - major', + errors: [], + }, + ], + valid: [ + { + code: 'passing - major', + }, + ], + }); + + // trigger the describe block + expect(mockedDescribe.mock.calls.length).toBeGreaterThanOrEqual(1); + mockedDescribe.mock.lastCall?.[1](); + expect(mockedDescribe.mock.calls).toMatchInlineSnapshot(` + [ + [ + "my-rule", + [Function], + ], + ] + `); + expect(mockedIt.mock.lastCall).toMatchInlineSnapshot(` + [ + "All tests skipped due to unsatisfied constructor dependency constraints", + [Function], + ] + `); + }); + + it('does not skip all tests if a constructor constraint is satisifed', () => { + const ruleTester = new RuleTester({ + parser: '@typescript-eslint/parser', + dependencyConstraints: { + 'totally-real-dependency': '10', + }, + }); + + ruleTester.run('my-rule', NOOP_RULE, { + invalid: [ + { + code: 'valid', + errors: [], + }, + ], + valid: [ + { + code: 'valid', + }, + ], + }); + + // trigger the describe block + expect(mockedDescribe.mock.calls.length).toBeGreaterThanOrEqual(1); + mockedDescribe.mock.lastCall?.[1](); + expect(mockedDescribe.mock.calls).toMatchInlineSnapshot(` + [ + [ + "my-rule", + [Function], + ], + [ + "valid", + [Function], + ], + [ + "invalid", + [Function], + ], + ] + `); + // expect(mockedIt.mock.lastCall).toMatchInlineSnapshot(`undefined`); + }); + }); }); }); From 5c316c12f09d58aee6ee634a8055533f361f1589 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 31 Oct 2022 05:58:30 -0700 Subject: [PATCH 09/76] fix(ast-spec): add TSQualifiedName to TypeNode union (#5906) * fix(ast-spec): add TSQualifiedName to TypeNode union * fix rule with missing type --- packages/ast-spec/src/unions/TypeNode.ts | 2 ++ packages/eslint-plugin/src/rules/sort-type-constituents.ts | 1 + .../src/rules/sort-type-union-intersection-members.ts | 1 + .../tests/rules/sort-type-constituents.test.ts | 6 +++++- .../rules/sort-type-union-intersection-members.test.ts | 6 +++++- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/ast-spec/src/unions/TypeNode.ts b/packages/ast-spec/src/unions/TypeNode.ts index 461281cd4ce..f1859d7d347 100644 --- a/packages/ast-spec/src/unions/TypeNode.ts +++ b/packages/ast-spec/src/unions/TypeNode.ts @@ -25,6 +25,7 @@ import type { TSOptionalType } from '../type/TSOptionalType/spec'; import type { TSPrivateKeyword } from '../type/TSPrivateKeyword/spec'; import type { TSProtectedKeyword } from '../type/TSProtectedKeyword/spec'; import type { TSPublicKeyword } from '../type/TSPublicKeyword/spec'; +import type { TSQualifiedName } from '../type/TSQualifiedName/spec'; import type { TSReadonlyKeyword } from '../type/TSReadonlyKeyword/spec'; import type { TSRestType } from '../type/TSRestType/spec'; import type { TSStaticKeyword } from '../type/TSStaticKeyword/spec'; @@ -71,6 +72,7 @@ export type TypeNode = | TSPrivateKeyword | TSProtectedKeyword | TSPublicKeyword + | TSQualifiedName | TSReadonlyKeyword | TSRestType | TSStaticKeyword diff --git a/packages/eslint-plugin/src/rules/sort-type-constituents.ts b/packages/eslint-plugin/src/rules/sort-type-constituents.ts index 92b5e44c6f9..1abeddcf823 100644 --- a/packages/eslint-plugin/src/rules/sort-type-constituents.ts +++ b/packages/eslint-plugin/src/rules/sort-type-constituents.ts @@ -60,6 +60,7 @@ function getGroup(node: TSESTree.TypeNode): Group { case AST_NODE_TYPES.TSIndexedAccessType: case AST_NODE_TYPES.TSInferType: case AST_NODE_TYPES.TSTypeReference: + case AST_NODE_TYPES.TSQualifiedName: return Group.named; case AST_NODE_TYPES.TSMappedType: diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index 2a83b4b0525..1fbf91b9ae8 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -60,6 +60,7 @@ function getGroup(node: TSESTree.TypeNode): Group { case AST_NODE_TYPES.TSIndexedAccessType: case AST_NODE_TYPES.TSInferType: case AST_NODE_TYPES.TSTypeReference: + case AST_NODE_TYPES.TSQualifiedName: return Group.named; case AST_NODE_TYPES.TSMappedType: 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 b9989c2cf87..2587375060e 100644 --- a/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts +++ b/packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts @@ -45,6 +45,8 @@ const valid = (operator: '|' | '&'): TSESLint.ValidTestCase[] => [ type T = ${operator} A ${operator} B + ${operator} C.D + ${operator} D.E ${operator} intrinsic ${operator} number[] ${operator} string[] @@ -220,6 +222,8 @@ type T = ${operator} readonly number[] ${operator} string[] ${operator} number[] + ${operator} D.E + ${operator} C.D ${operator} B ${operator} A ${operator} undefined @@ -229,7 +233,7 @@ type T = `, output: ` type T = - A ${operator} B ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined; + A ${operator} B ${operator} C.D ${operator} D.E ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined; `, errors: [ { diff --git a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts index 38ae67f1804..a24959d8b6a 100644 --- a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts +++ b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts @@ -45,6 +45,8 @@ const valid = (operator: '|' | '&'): TSESLint.ValidTestCase[] => [ type T = ${operator} A ${operator} B + ${operator} C.D + ${operator} D.E ${operator} intrinsic ${operator} number[] ${operator} string[] @@ -220,6 +222,8 @@ type T = ${operator} readonly number[] ${operator} string[] ${operator} number[] + ${operator} D.E + ${operator} C.D ${operator} B ${operator} A ${operator} undefined @@ -229,7 +233,7 @@ type T = `, output: ` type T = - A ${operator} B ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined; + A ${operator} B ${operator} C.D ${operator} D.E ${operator} number[] ${operator} string[] ${operator} any ${operator} string ${operator} readonly number[] ${operator} readonly string[] ${operator} 'a' ${operator} 'b' ${operator} "a" ${operator} "b" ${operator} (() => string) ${operator} (() => void) ${operator} { a: string } ${operator} { b: string } ${operator} [1, 2, 3] ${operator} [1, 2, 4] ${operator} null ${operator} undefined; `, errors: [ { From 1e5e9ea4cac25947c3a8748647a4fb4d329c4b25 Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" Date: Mon, 31 Oct 2022 17:35:31 +0000 Subject: [PATCH 10/76] chore: publish v5.42.0 --- CHANGELOG.md | 22 ++++++++++++++++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 6 ++++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 4 ++++ packages/eslint-plugin-internal/package.json | 6 +++--- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 12 +++++++++++ packages/eslint-plugin/package.json | 8 +++---- packages/experimental-utils/CHANGELOG.md | 4 ++++ packages/experimental-utils/package.json | 4 ++-- packages/parser/CHANGELOG.md | 10 +++++++++ packages/parser/package.json | 8 +++---- packages/scope-manager/CHANGELOG.md | 10 +++++++++ packages/scope-manager/package.json | 8 +++---- packages/shared-fixtures/CHANGELOG.md | 4 ++++ packages/shared-fixtures/package.json | 2 +- packages/type-utils/CHANGELOG.md | 4 ++++ packages/type-utils/package.json | 8 +++---- packages/types/CHANGELOG.md | 4 ++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 10 +++++++++ packages/typescript-estree/package.json | 8 +++---- packages/utils/CHANGELOG.md | 6 ++++++ packages/utils/package.json | 10 ++++----- packages/visitor-keys/CHANGELOG.md | 4 ++++ packages/visitor-keys/package.json | 4 ++-- packages/website-eslint/CHANGELOG.md | 4 ++++ packages/website-eslint/package.json | 16 +++++++------- packages/website/CHANGELOG.md | 15 +++++++++++++ packages/website/package.json | 8 +++---- 32 files changed, 174 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0304329f3aa..f4685ce8dae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Bug Fixes + +- **ast-spec:** add TSQualifiedName to TypeNode union ([#5906](https://github.com/typescript-eslint/typescript-eslint/issues/5906)) ([5c316c1](https://github.com/typescript-eslint/typescript-eslint/commit/5c316c12f09d58aee6ee634a8055533f361f1589)) +- **eslint-plugin:** [no-extra-parens] handle type assertion in extends clause ([#5901](https://github.com/typescript-eslint/typescript-eslint/issues/5901)) ([8ed7219](https://github.com/typescript-eslint/typescript-eslint/commit/8ed72192c274249d26628fb125796e71318b857a)) +- **eslint-plugin:** enable react/jsx-curly-brace-presence lint rule in website package ([#5894](https://github.com/typescript-eslint/typescript-eslint/issues/5894)) ([344322a](https://github.com/typescript-eslint/typescript-eslint/commit/344322add846d03c6c9981e486b09e6ba1196555)) +- **typescript-estree:** don't allow single-run unless we're in type-aware linting mode ([#5893](https://github.com/typescript-eslint/typescript-eslint/issues/5893)) ([891b087](https://github.com/typescript-eslint/typescript-eslint/commit/891b0879ba9c64a4722b8c0bf9e599a725b6d6df)) + +### Features + +- **eslint-plugin:** [member-ordering] add natural sort order ([#5662](https://github.com/typescript-eslint/typescript-eslint/issues/5662)) ([1eaae09](https://github.com/typescript-eslint/typescript-eslint/commit/1eaae09ecca359f366b94f6a04665403f48b05c7)) +- **eslint-plugin:** [no-invalid-void-type] better report message for void used as a constituent inside a function return type ([#5274](https://github.com/typescript-eslint/typescript-eslint/issues/5274)) ([d806bda](https://github.com/typescript-eslint/typescript-eslint/commit/d806bda82343712a24e3c78b9b34d4345dd1de3b)) +- **scope-manager:** ignore ECMA version ([#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881)) ([3b8d449](https://github.com/typescript-eslint/typescript-eslint/commit/3b8d449696c319690536a18a48ef32749dc2f559)) +- **typescript-estree:** clarify docs and error for program project without matching TSConfig ([#5762](https://github.com/typescript-eslint/typescript-eslint/issues/5762)) ([67744db](https://github.com/typescript-eslint/typescript-eslint/commit/67744db31f61acab14b5fe027fbc2844ba198c97)) +- **utils:** add `RuleTester` API for top-level dependency constraints ([#5896](https://github.com/typescript-eslint/typescript-eslint/issues/5896)) ([0520d53](https://github.com/typescript-eslint/typescript-eslint/commit/0520d53536af411d66ce2ce0dd478365e67adbac)) +- **website:** Add a happy message to playground output pane when no errors or AST ([#5868](https://github.com/typescript-eslint/typescript-eslint/issues/5868)) ([#5873](https://github.com/typescript-eslint/typescript-eslint/issues/5873)) ([c4e0d86](https://github.com/typescript-eslint/typescript-eslint/commit/c4e0d8678e0398f3ab85510f40ad6f97832b9e6d)) + +### Reverts + +- Revert "feat(scope-manager): ignore ECMA version" (#5888) ([2ee81df](https://github.com/typescript-eslint/typescript-eslint/commit/2ee81df5a365d82ef4b3dfc124d4ec39c7bcb725)), closes [#5888](https://github.com/typescript-eslint/typescript-eslint/issues/5888) [#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 9e451c6323f..47974603d99 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.41.0", + "version": "5.42.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 5d890f335a6..4b069d345df 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Bug Fixes + +- **ast-spec:** add TSQualifiedName to TypeNode union ([#5906](https://github.com/typescript-eslint/typescript-eslint/issues/5906)) ([5c316c1](https://github.com/typescript-eslint/typescript-eslint/commit/5c316c12f09d58aee6ee634a8055533f361f1589)) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 35df9004ba6..4b35b75dff2 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.41.0", + "version": "5.42.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index eb09c888159..150635d9f22 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 489a40472ef..e21f2c82fa4 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.41.0", + "version": "5.42.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,8 +14,8 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/utils": "5.41.0", + "@typescript-eslint/scope-manager": "5.42.0", + "@typescript-eslint/utils": "5.42.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index cf95068ce8e..758874fd110 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 cbe14473287..feeedacebe6 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.41.0", + "version": "5.42.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.41.0", + "@typescript-eslint/utils": "5.42.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.41.0" + "@typescript-eslint/parser": "5.42.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 7b5a3d1fbc6..609763b480e 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Bug Fixes + +- **ast-spec:** add TSQualifiedName to TypeNode union ([#5906](https://github.com/typescript-eslint/typescript-eslint/issues/5906)) ([5c316c1](https://github.com/typescript-eslint/typescript-eslint/commit/5c316c12f09d58aee6ee634a8055533f361f1589)) +- **eslint-plugin:** [no-extra-parens] handle type assertion in extends clause ([#5901](https://github.com/typescript-eslint/typescript-eslint/issues/5901)) ([8ed7219](https://github.com/typescript-eslint/typescript-eslint/commit/8ed72192c274249d26628fb125796e71318b857a)) + +### Features + +- **eslint-plugin:** [member-ordering] add natural sort order ([#5662](https://github.com/typescript-eslint/typescript-eslint/issues/5662)) ([1eaae09](https://github.com/typescript-eslint/typescript-eslint/commit/1eaae09ecca359f366b94f6a04665403f48b05c7)) +- **eslint-plugin:** [no-invalid-void-type] better report message for void used as a constituent inside a function return type ([#5274](https://github.com/typescript-eslint/typescript-eslint/issues/5274)) ([d806bda](https://github.com/typescript-eslint/typescript-eslint/commit/d806bda82343712a24e3c78b9b34d4345dd1de3b)) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index eb1c777d115..f3afe646a16 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.41.0", + "version": "5.42.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,9 +44,9 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/type-utils": "5.41.0", - "@typescript-eslint/utils": "5.41.0", + "@typescript-eslint/scope-manager": "5.42.0", + "@typescript-eslint/type-utils": "5.42.0", + "@typescript-eslint/utils": "5.42.0", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 5b2bc9b5d9b..7334d6b80b4 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 8056c69d658..618afe32e04 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.41.0", + "version": "5.42.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.41.0" + "@typescript-eslint/utils": "5.42.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 b8064f16b73..689b11e8227 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Features + +- **scope-manager:** ignore ECMA version ([#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881)) ([3b8d449](https://github.com/typescript-eslint/typescript-eslint/commit/3b8d449696c319690536a18a48ef32749dc2f559)) + +### Reverts + +- Revert "feat(scope-manager): ignore ECMA version" (#5888) ([2ee81df](https://github.com/typescript-eslint/typescript-eslint/commit/2ee81df5a365d82ef4b3dfc124d4ec39c7bcb725)), closes [#5888](https://github.com/typescript-eslint/typescript-eslint/issues/5888) [#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 66e27e0d0a7..8ef9a0cf359 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.41.0", + "version": "5.42.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.41.0", - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/scope-manager": "5.42.0", + "@typescript-eslint/types": "5.42.0", + "@typescript-eslint/typescript-estree": "5.42.0", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index 66b6e6b4f53..a4601cd80b3 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Features + +- **scope-manager:** ignore ECMA version ([#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881)) ([3b8d449](https://github.com/typescript-eslint/typescript-eslint/commit/3b8d449696c319690536a18a48ef32749dc2f559)) + +### Reverts + +- Revert "feat(scope-manager): ignore ECMA version" (#5888) ([2ee81df](https://github.com/typescript-eslint/typescript-eslint/commit/2ee81df5a365d82ef4b3dfc124d4ec39c7bcb725)), closes [#5888](https://github.com/typescript-eslint/typescript-eslint/issues/5888) [#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 5bc61a61f3b..34ffe2f86e9 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.41.0", + "version": "5.42.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -38,12 +38,12 @@ "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" }, "dependencies": { - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/visitor-keys": "5.41.0" + "@typescript-eslint/types": "5.42.0", + "@typescript-eslint/visitor-keys": "5.42.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/typescript-estree": "5.42.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index ba001fbfa5d..6011551b73e 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 864ddbf70bb..5c8bb352ba3 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.41.0", + "version": "5.42.0", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 09b3607c201..09af50ebb31 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/type-utils + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) ### Bug Fixes diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index bdc68f60358..6150b2d27c9 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.41.0", + "version": "5.42.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.41.0", - "@typescript-eslint/utils": "5.41.0", + "@typescript-eslint/typescript-estree": "5.42.0", + "@typescript-eslint/utils": "5.42.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.41.0", + "@typescript-eslint/parser": "5.42.0", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index e7cfbe3fb88..48a98e9a16f 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/types + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 78c880438fb..d2347b6a48c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.41.0", + "version": "5.42.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 cb369c72bf4..78cf8e7aefc 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Bug Fixes + +- **typescript-estree:** don't allow single-run unless we're in type-aware linting mode ([#5893](https://github.com/typescript-eslint/typescript-eslint/issues/5893)) ([891b087](https://github.com/typescript-eslint/typescript-eslint/commit/891b0879ba9c64a4722b8c0bf9e599a725b6d6df)) + +### Features + +- **typescript-estree:** clarify docs and error for program project without matching TSConfig ([#5762](https://github.com/typescript-eslint/typescript-eslint/issues/5762)) ([67744db](https://github.com/typescript-eslint/typescript-eslint/commit/67744db31f61acab14b5fe027fbc2844ba198c97)) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 52de436db7b..1df5908ca03 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.41.0", + "version": "5.42.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.41.0", - "@typescript-eslint/visitor-keys": "5.41.0", + "@typescript-eslint/types": "5.42.0", + "@typescript-eslint/visitor-keys": "5.42.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.41.0", + "@typescript-eslint/shared-fixtures": "5.42.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index ea1b24da025..97a2797ea8a 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Features + +- **utils:** add `RuleTester` API for top-level dependency constraints ([#5896](https://github.com/typescript-eslint/typescript-eslint/issues/5896)) ([0520d53](https://github.com/typescript-eslint/typescript-eslint/commit/0520d53536af411d66ce2ce0dd478365e67adbac)) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **Note:** Version bump only for package @typescript-eslint/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 21b80b4a9fa..2de743ab01d 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.41.0", + "version": "5.42.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.41.0", - "@typescript-eslint/types": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", + "@typescript-eslint/scope-manager": "5.42.0", + "@typescript-eslint/types": "5.42.0", + "@typescript-eslint/typescript-estree": "5.42.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.41.0", + "@typescript-eslint/parser": "5.42.0", "typescript": "*" }, "funding": { diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 65df1dacb42..21700ddd1a3 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 9898d07c851..2068a094820 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.41.0", + "version": "5.42.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.41.0", + "@typescript-eslint/types": "5.42.0", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index 2129728bf18..5c65303053e 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **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 f094f70c3be..5384c756758 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.41.0", + "version": "5.42.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.41.0", - "@typescript-eslint/utils": "5.41.0" + "@typescript-eslint/types": "5.42.0", + "@typescript-eslint/utils": "5.42.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.41.0", - "@typescript-eslint/parser": "5.41.0", - "@typescript-eslint/scope-manager": "5.41.0", - "@typescript-eslint/typescript-estree": "5.41.0", - "@typescript-eslint/visitor-keys": "5.41.0", + "@typescript-eslint/eslint-plugin": "5.42.0", + "@typescript-eslint/parser": "5.42.0", + "@typescript-eslint/scope-manager": "5.42.0", + "@typescript-eslint/typescript-estree": "5.42.0", + "@typescript-eslint/visitor-keys": "5.42.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 38d0670bfbc..472da3ec4f2 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/CHANGELOG.md @@ -3,6 +3,21 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) + +### Bug Fixes + +- **eslint-plugin:** enable react/jsx-curly-brace-presence lint rule in website package ([#5894](https://github.com/typescript-eslint/typescript-eslint/issues/5894)) ([344322a](https://github.com/typescript-eslint/typescript-eslint/commit/344322add846d03c6c9981e486b09e6ba1196555)) + +### Features + +- **scope-manager:** ignore ECMA version ([#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881)) ([3b8d449](https://github.com/typescript-eslint/typescript-eslint/commit/3b8d449696c319690536a18a48ef32749dc2f559)) +- **website:** Add a happy message to playground output pane when no errors or AST ([#5868](https://github.com/typescript-eslint/typescript-eslint/issues/5868)) ([#5873](https://github.com/typescript-eslint/typescript-eslint/issues/5873)) ([c4e0d86](https://github.com/typescript-eslint/typescript-eslint/commit/c4e0d8678e0398f3ab85510f40ad6f97832b9e6d)) + +### Reverts + +- Revert "feat(scope-manager): ignore ECMA version" (#5888) ([2ee81df](https://github.com/typescript-eslint/typescript-eslint/commit/2ee81df5a365d82ef4b3dfc124d4ec39c7bcb725)), closes [#5888](https://github.com/typescript-eslint/typescript-eslint/issues/5888) [#5881](https://github.com/typescript-eslint/typescript-eslint/issues/5881) + # [5.41.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.40.1...v5.41.0) (2022-10-24) **Note:** Version bump only for package website diff --git a/packages/website/package.json b/packages/website/package.json index 9469e3450a7..c2ef8addd0e 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.41.0", + "version": "5.42.0", "private": true, "scripts": { "build": "docusaurus build", @@ -21,8 +21,8 @@ "@docusaurus/remark-plugin-npm2yarn": "~2.1.0", "@docusaurus/theme-common": "~2.1.0", "@mdx-js/react": "1.6.22", - "@typescript-eslint/parser": "5.41.0", - "@typescript-eslint/website-eslint": "5.41.0", + "@typescript-eslint/parser": "5.42.0", + "@typescript-eslint/website-eslint": "5.42.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.41.0", + "@typescript-eslint/eslint-plugin": "5.42.0", "copy-webpack-plugin": "^11.0.0", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.29.4", From 2089e5ab6f7697d0d86848950c7a2e015811f71f Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" <53356952+typescript-eslint[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:19:52 -0700 Subject: [PATCH 11/76] chore: update contributors (#5909) Co-authored-by: typescript-eslint[bot] --- CONTRIBUTORS.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3d6d37b2190..9d9b15f70f2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -10,83 +10,83 @@ Thanks goes to these wonderful people:
Brad Zacher

Armano

Josh Goldberg
-
Reyad Attiyat
+
Oleksandr T.
+
Michaël De Boey
+
Reyad Attiyat

Patricio Trevino

Sosuke Suzuki

Joshua Chen
-
Nicholas C. Zakas
-
Jed Fox
+
Nicholas C. Zakas

YeonJuan
+
Jed Fox

Rafael Santana

Ben Lichtman
-
Nikita
-
Taeheon Kim
+
Nikita
+
Taeheon Kim

Scott O'Hara

Retsam

Kai Cataldo
-
Rasmus Eneman
-
Toru Nagashima
+
Rasmus Eneman
+
Rebecca Stevens
+
Toru Nagashima

Yosuke Ota

JounQin
+ +
Lucas Azzola

Danny Fritz

Ika
- -
mackie

Simen Bekkhus
+ +
Kanitkorn Sujautra

cherryblossom

Zzzen
+
Anix
+
Daniil Dubrava
-
Anix
-
Pete Gonzalez

ldrick

Susisu
+
Bryan Mishkin

Gavin Barron
+
Kevin Partington
-
Kevin Partington

Lucas Duailibe

Niles Salter
+
Pavel Birukov
+
Shahar Dawn Or

SHIMA RYUHEI
-
koooge
+
koooge

thomas michael wallace

ulrichb

Juan García
-
Bryan Mishkin

Daniel Cassidy
-
Daniel Nixon

Denys Kniazevych
-
Dimitri Mitropoulos

Ian MacLeod

Jonathan Delgado
- -
Philipp A.

Pig Fang
-
Tadhg McDonald-Jensen
-
Thomas den Hollander
-
Yasar Siddiqui
+
Thomas den Hollander
+
Yasar Siddiqui

Yusuke Tanaka
-
Bence Dányi
-
Eric Wang
-
Soobin Bak
+
zz
From e88f4fa1d0127ba0ddeff578ec67f2e66a1de68b Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 1 Nov 2022 21:57:02 -0700 Subject: [PATCH 12/76] fix(ast-spec): correct misnamed ExportNamedDeclaration AST type (#5913) --- .../ast-spec/src/declaration/ExportNamedDeclaration/spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts index 061c53f4b46..b9b158eddb4 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts @@ -46,7 +46,7 @@ export interface ExportNamedDeclarationWithoutSourceWithMultiple extends ExportNamedDeclarationBase { // this will always be empty array assertions: ImportAttribute[]; - declaration: NamedExportDeclarations; + declaration: null; source: null; specifiers: ExportSpecifier[]; } @@ -55,7 +55,7 @@ export interface ExportNamedDeclarationWithoutSourceWithSingle extends ExportNamedDeclarationBase { // this will always be empty array assertions: ImportAttribute[]; - declaration: null; + declaration: NamedExportDeclarations; source: null; // this will always be empty array specifiers: ExportSpecifier[]; From c874e500abca75f069bb6a176660a66e90783519 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 1 Nov 2022 22:12:14 -0700 Subject: [PATCH 13/76] chore(deps): update docusaurus to ~2.2.0 (#5911) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- packages/website/package.json | 12 +- yarn.lock | 376 +++++++++++++++++----------------- 2 files changed, 194 insertions(+), 194 deletions(-) diff --git a/packages/website/package.json b/packages/website/package.json index c2ef8addd0e..7ca8f69a3d7 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -15,11 +15,11 @@ }, "dependencies": { "@babel/runtime": "^7.18.3", - "@docusaurus/core": "~2.1.0", - "@docusaurus/plugin-pwa": "~2.1.0", - "@docusaurus/preset-classic": "~2.1.0", - "@docusaurus/remark-plugin-npm2yarn": "~2.1.0", - "@docusaurus/theme-common": "~2.1.0", + "@docusaurus/core": "~2.2.0", + "@docusaurus/plugin-pwa": "~2.2.0", + "@docusaurus/preset-classic": "~2.2.0", + "@docusaurus/remark-plugin-npm2yarn": "~2.2.0", + "@docusaurus/theme-common": "~2.2.0", "@mdx-js/react": "1.6.22", "@typescript-eslint/parser": "5.42.0", "@typescript-eslint/website-eslint": "5.42.0", @@ -43,7 +43,7 @@ }, "devDependencies": { "@axe-core/playwright": "^4.4.5", - "@docusaurus/module-type-aliases": "~2.1.0", + "@docusaurus/module-type-aliases": "~2.2.0", "@playwright/test": "^1.27.1", "@types/react": "^18.0.9", "@types/react-helmet": "^6.1.5", diff --git a/yarn.lock b/yarn.lock index 1e719261af6..543fa9bbc68 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1536,10 +1536,10 @@ "@docsearch/css" "3.1.1" algoliasearch "^4.0.0" -"@docusaurus/core@2.1.0", "@docusaurus/core@~2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.1.0.tgz#4aedc306f4c4cd2e0491b641bf78941d4b480ab6" - integrity sha512-/ZJ6xmm+VB9Izbn0/s6h6289cbPy2k4iYFwWDhjiLsVqwa/Y0YBBcXvStfaHccudUC3OfP+26hMk7UCjc50J6Q== +"@docusaurus/core@2.2.0", "@docusaurus/core@~2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.2.0.tgz#64c9ee31502c23b93c869f8188f73afaf5fd4867" + integrity sha512-Vd6XOluKQqzG12fEs9prJgDtyn6DPok9vmUWDR2E6/nV5Fl9SVkhEQOBxwObjk3kQh7OY7vguFaLh0jqdApWsA== dependencies: "@babel/core" "^7.18.6" "@babel/generator" "^7.18.7" @@ -1551,13 +1551,13 @@ "@babel/runtime" "^7.18.6" "@babel/runtime-corejs3" "^7.18.6" "@babel/traverse" "^7.18.8" - "@docusaurus/cssnano-preset" "2.1.0" - "@docusaurus/logger" "2.1.0" - "@docusaurus/mdx-loader" "2.1.0" + "@docusaurus/cssnano-preset" "2.2.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/mdx-loader" "2.2.0" "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-common" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-common" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" "@slorber/static-site-generator-webpack-plugin" "^4.0.7" "@svgr/webpack" "^6.2.1" autoprefixer "^10.4.7" @@ -1613,33 +1613,33 @@ webpack-merge "^5.8.0" webpackbar "^5.0.2" -"@docusaurus/cssnano-preset@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.1.0.tgz#5b42107769b7cbc61655496090bc262d7788d6ab" - integrity sha512-pRLewcgGhOies6pzsUROfmPStDRdFw+FgV5sMtLr5+4Luv2rty5+b/eSIMMetqUsmg3A9r9bcxHk9bKAKvx3zQ== +"@docusaurus/cssnano-preset@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.2.0.tgz#fc05044659051ae74ab4482afcf4a9936e81d523" + integrity sha512-mAAwCo4n66TMWBH1kXnHVZsakW9VAXJzTO4yZukuL3ro4F+JtkMwKfh42EG75K/J/YIFQG5I/Bzy0UH/hFxaTg== dependencies: cssnano-preset-advanced "^5.3.8" postcss "^8.4.14" postcss-sort-media-queries "^4.2.1" tslib "^2.4.0" -"@docusaurus/logger@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.1.0.tgz#86c97e948f578814d3e61fc2b2ad283043cbe87a" - integrity sha512-uuJx2T6hDBg82joFeyobywPjSOIfeq05GfyKGHThVoXuXsu1KAzMDYcjoDxarb9CoHCI/Dor8R2MoL6zII8x1Q== +"@docusaurus/logger@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.2.0.tgz#ea2f7feda7b8675485933b87f06d9c976d17423f" + integrity sha512-DF3j1cA5y2nNsu/vk8AG7xwpZu6f5MKkPPMaaIbgXLnWGfm6+wkOeW7kNrxnM95YOhKUkJUophX69nGUnLsm0A== dependencies: chalk "^4.1.2" tslib "^2.4.0" -"@docusaurus/mdx-loader@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.1.0.tgz#3fca9576cc73a22f8e7d9941985590b9e47a8526" - integrity sha512-i97hi7hbQjsD3/8OSFhLy7dbKGH8ryjEzOfyhQIn2CFBYOY3ko0vMVEf3IY9nD3Ld7amYzsZ8153RPkcnXA+Lg== +"@docusaurus/mdx-loader@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.2.0.tgz#fd558f429e5d9403d284bd4214e54d9768b041a0" + integrity sha512-X2bzo3T0jW0VhUU+XdQofcEeozXOTmKQMvc8tUnWRdTnCvj4XEcBVdC3g+/jftceluiwSTNRAX4VBOJdNt18jA== dependencies: "@babel/parser" "^7.18.8" "@babel/traverse" "^7.18.8" - "@docusaurus/logger" "2.1.0" - "@docusaurus/utils" "2.1.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/utils" "2.2.0" "@mdx-js/mdx" "^1.6.22" escape-html "^1.0.3" file-loader "^6.2.0" @@ -1654,13 +1654,13 @@ url-loader "^4.1.1" webpack "^5.73.0" -"@docusaurus/module-type-aliases@2.1.0", "@docusaurus/module-type-aliases@~2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.1.0.tgz#322f8fd5b436af2154c0dddfa173435730e66261" - integrity sha512-Z8WZaK5cis3xEtyfOT817u9xgGUauT0PuuVo85ysnFRX8n7qLN1lTPCkC+aCmFm/UcV8h/W5T4NtIsst94UntQ== +"@docusaurus/module-type-aliases@2.2.0", "@docusaurus/module-type-aliases@~2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.2.0.tgz#1e23e54a1bbb6fde1961e4fa395b1b69f4803ba5" + integrity sha512-wDGW4IHKoOr9YuJgy7uYuKWrDrSpsUSDHLZnWQYM9fN7D5EpSmYHjFruUpKWVyxLpD/Wh0rW8hYZwdjJIQUQCQ== dependencies: "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/types" "2.1.0" + "@docusaurus/types" "2.2.0" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -1668,18 +1668,18 @@ react-helmet-async "*" react-loadable "npm:@docusaurus/react-loadable@5.5.2" -"@docusaurus/plugin-content-blog@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.1.0.tgz#32b1a7cd4b0026f4a76fce4edc5cfdd0edb1ec42" - integrity sha512-xEp6jlu92HMNUmyRBEeJ4mCW1s77aAEQO4Keez94cUY/Ap7G/r0Awa6xSLff7HL0Fjg8KK1bEbDy7q9voIavdg== - dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/logger" "2.1.0" - "@docusaurus/mdx-loader" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-common" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" +"@docusaurus/plugin-content-blog@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.2.0.tgz#dc55982e76771f4e678ac10e26d10e1da2011dc1" + integrity sha512-0mWBinEh0a5J2+8ZJXJXbrCk1tSTNf7Nm4tYAl5h2/xx+PvH/Bnu0V+7mMljYm/1QlDYALNIIaT/JcoZQFUN3w== + dependencies: + "@docusaurus/core" "2.2.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/mdx-loader" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-common" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" cheerio "^1.0.0-rc.12" feed "^4.2.2" fs-extra "^10.1.0" @@ -1690,18 +1690,18 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-docs@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.1.0.tgz#3fcdf258c13dde27268ce7108a102b74ca4c279b" - integrity sha512-Rup5pqXrXlKGIC4VgwvioIhGWF7E/NNSlxv+JAxRYpik8VKlWsk9ysrdHIlpX+KJUCO9irnY21kQh2814mlp/Q== - dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/logger" "2.1.0" - "@docusaurus/mdx-loader" "2.1.0" - "@docusaurus/module-type-aliases" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" +"@docusaurus/plugin-content-docs@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.2.0.tgz#0fcb85226fcdb80dc1e2d4a36ef442a650dcc84d" + integrity sha512-BOazBR0XjzsHE+2K1wpNxz5QZmrJgmm3+0Re0EVPYFGW8qndCWGNtXW/0lGKhecVPML8yyFeAmnUCIs7xM2wPw== + dependencies: + "@docusaurus/core" "2.2.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/mdx-loader" "2.2.0" + "@docusaurus/module-type-aliases" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" "@types/react-router-config" "^5.0.6" combine-promises "^1.1.0" fs-extra "^10.1.0" @@ -1712,65 +1712,65 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-pages@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.1.0.tgz#714d24f71d49dbfed888f50c15e975c2154c3ce8" - integrity sha512-SwZdDZRlObHNKXTnFo7W2aF6U5ZqNVI55Nw2GCBryL7oKQSLeI0lsrMlMXdzn+fS7OuBTd3MJBO1T4Zpz0i/+g== - dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/mdx-loader" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" +"@docusaurus/plugin-content-pages@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.2.0.tgz#e3f40408787bbe229545dd50595f87e1393bc3ae" + integrity sha512-+OTK3FQHk5WMvdelz8v19PbEbx+CNT6VSpx7nVOvMNs5yJCKvmqBJBQ2ZSxROxhVDYn+CZOlmyrC56NSXzHf6g== + dependencies: + "@docusaurus/core" "2.2.0" + "@docusaurus/mdx-loader" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" fs-extra "^10.1.0" tslib "^2.4.0" webpack "^5.73.0" -"@docusaurus/plugin-debug@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.1.0.tgz#b3145affb40e25cf342174638952a5928ddaf7dc" - integrity sha512-8wsDq3OIfiy6440KLlp/qT5uk+WRHQXIXklNHEeZcar+Of0TZxCNe2FBpv+bzb/0qcdP45ia5i5WmR5OjN6DPw== +"@docusaurus/plugin-debug@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.2.0.tgz#b38741d2c492f405fee01ee0ef2e0029cedb689a" + integrity sha512-p9vOep8+7OVl6r/NREEYxf4HMAjV8JMYJ7Bos5fCFO0Wyi9AZEo0sCTliRd7R8+dlJXZEgcngSdxAUo/Q+CJow== dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" + "@docusaurus/core" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" fs-extra "^10.1.0" react-json-view "^1.21.3" tslib "^2.4.0" -"@docusaurus/plugin-google-analytics@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.1.0.tgz#c9a7269817b38e43484d38fad9996e39aac4196c" - integrity sha512-4cgeqIly/wcFVbbWP03y1QJJBgH8W+Bv6AVbWnsXNOZa1yB3AO6hf3ZdeQH9x20v9T2pREogVgAH0rSoVnNsgg== +"@docusaurus/plugin-google-analytics@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.2.0.tgz#63c7137eff5a1208d2059fea04b5207c037d7954" + integrity sha512-+eZVVxVeEnV5nVQJdey9ZsfyEVMls6VyWTIj8SmX0k5EbqGvnIfET+J2pYEuKQnDIHxy+syRMoRM6AHXdHYGIg== dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" + "@docusaurus/core" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" tslib "^2.4.0" -"@docusaurus/plugin-google-gtag@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.1.0.tgz#e4f351dcd98b933538d55bb742650a2a36ca9a32" - integrity sha512-/3aDlv2dMoCeiX2e+DTGvvrdTA+v3cKQV3DbmfsF4ENhvc5nKV23nth04Z3Vq0Ci1ui6Sn80TkhGk/tiCMW2AA== +"@docusaurus/plugin-google-gtag@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.2.0.tgz#7b086d169ac5fe9a88aca10ab0fd2bf00c6c6b12" + integrity sha512-6SOgczP/dYdkqUMGTRqgxAS1eTp6MnJDAQMy8VCF1QKbWZmlkx4agHDexihqmYyCujTYHqDAhm1hV26EET54NQ== dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" + "@docusaurus/core" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" tslib "^2.4.0" -"@docusaurus/plugin-pwa@~2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-pwa/-/plugin-pwa-2.1.0.tgz#e6deb53a4c4b10de85c73886a75497a48bedd258" - integrity sha512-SOhEbv9sECaD/c9Ym2Bq6ruK56PAxV9Ftj6Hk2rKFdrASBv3ruri2iCT5YPKMpXqmzWd84GnE2pusMW2s1w2Sw== +"@docusaurus/plugin-pwa@~2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-pwa/-/plugin-pwa-2.2.0.tgz#2aca00d268efbca8f3cf1c3e260b801e6f7f8af5" + integrity sha512-j1ldskYXkKYmWB6V1I0Lv2o9EUhSdGI6pCo0RFGaLijJKLlA9R+F5j+0kWvoyirXM7LRGknkXYYkc50i25R5Sw== dependencies: "@babel/core" "^7.18.6" "@babel/preset-env" "^7.18.6" - "@docusaurus/core" "2.1.0" - "@docusaurus/theme-common" "2.1.0" - "@docusaurus/theme-translations" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" + "@docusaurus/core" "2.2.0" + "@docusaurus/theme-common" "2.2.0" + "@docusaurus/theme-translations" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" babel-loader "^8.2.5" clsx "^1.2.1" core-js "^3.23.3" @@ -1782,38 +1782,38 @@ workbox-precaching "^6.5.3" workbox-window "^6.5.3" -"@docusaurus/plugin-sitemap@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.1.0.tgz#b316bb9a42a1717845e26bd4e2d3071748a54b47" - integrity sha512-2Y6Br8drlrZ/jN9MwMBl0aoi9GAjpfyfMBYpaQZXimbK+e9VjYnujXlvQ4SxtM60ASDgtHIAzfVFBkSR/MwRUw== - dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/logger" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-common" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" +"@docusaurus/plugin-sitemap@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.2.0.tgz#876da60937886032d63143253d420db6a4b34773" + integrity sha512-0jAmyRDN/aI265CbWZNZuQpFqiZuo+5otk2MylU9iVrz/4J7gSc+ZJ9cy4EHrEsW7PV8s1w18hIEsmcA1YgkKg== + dependencies: + "@docusaurus/core" "2.2.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-common" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" fs-extra "^10.1.0" sitemap "^7.1.1" tslib "^2.4.0" -"@docusaurus/preset-classic@~2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.1.0.tgz#45b23c8ec10c96ded9ece128fac3a39b10bcbc56" - integrity sha512-NQMnaq974K4BcSMXFSJBQ5itniw6RSyW+VT+6i90kGZzTwiuKZmsp0r9lC6BYAvvVMQUNJQwrETmlu7y2XKW7w== - dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/plugin-content-blog" "2.1.0" - "@docusaurus/plugin-content-docs" "2.1.0" - "@docusaurus/plugin-content-pages" "2.1.0" - "@docusaurus/plugin-debug" "2.1.0" - "@docusaurus/plugin-google-analytics" "2.1.0" - "@docusaurus/plugin-google-gtag" "2.1.0" - "@docusaurus/plugin-sitemap" "2.1.0" - "@docusaurus/theme-classic" "2.1.0" - "@docusaurus/theme-common" "2.1.0" - "@docusaurus/theme-search-algolia" "2.1.0" - "@docusaurus/types" "2.1.0" +"@docusaurus/preset-classic@~2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.2.0.tgz#bece5a043eeb74430f7c6c7510000b9c43669eb7" + integrity sha512-yKIWPGNx7BT8v2wjFIWvYrS+nvN04W+UameSFf8lEiJk6pss0kL6SG2MRvyULiI3BDxH+tj6qe02ncpSPGwumg== + dependencies: + "@docusaurus/core" "2.2.0" + "@docusaurus/plugin-content-blog" "2.2.0" + "@docusaurus/plugin-content-docs" "2.2.0" + "@docusaurus/plugin-content-pages" "2.2.0" + "@docusaurus/plugin-debug" "2.2.0" + "@docusaurus/plugin-google-analytics" "2.2.0" + "@docusaurus/plugin-google-gtag" "2.2.0" + "@docusaurus/plugin-sitemap" "2.2.0" + "@docusaurus/theme-classic" "2.2.0" + "@docusaurus/theme-common" "2.2.0" + "@docusaurus/theme-search-algolia" "2.2.0" + "@docusaurus/types" "2.2.0" "@docusaurus/react-loadable@5.5.2", "react-loadable@npm:@docusaurus/react-loadable@5.5.2": version "5.5.2" @@ -1823,32 +1823,32 @@ "@types/react" "*" prop-types "^15.6.2" -"@docusaurus/remark-plugin-npm2yarn@~2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/remark-plugin-npm2yarn/-/remark-plugin-npm2yarn-2.1.0.tgz#45d933002880e55ac70ac33a21894243e8af7643" - integrity sha512-crlbE7XN4m6f5PMW+1K0w1/r6YsJPBHPAnxBu+dwcObBYFKeNnmtci8mBOX/Ey1eeV9wO1yFwaSWKEn1EAbcbQ== +"@docusaurus/remark-plugin-npm2yarn@~2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/remark-plugin-npm2yarn/-/remark-plugin-npm2yarn-2.2.0.tgz#12d433eda8986c475277dd7fb8624b10c8a976ea" + integrity sha512-CFiwzk+0QrlBjkcx4cNV8LQZHgo15aQ3piO0Iao0vGXLc7eupGigDLuE7q3Phc10ELweO+P2gRQTjlBqIQTC+Q== dependencies: npm-to-yarn "^1.0.1" tslib "^2.4.0" unist-util-visit "^2.0.3" -"@docusaurus/theme-classic@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.1.0.tgz#d957a907ea8dd035c1cf911d0fbe91d8f24aef3f" - integrity sha512-xn8ZfNMsf7gaSy9+ClFnUu71o7oKgMo5noYSS1hy3svNifRTkrBp6+MReLDsmIaj3mLf2e7+JCBYKBFbaGzQng== - dependencies: - "@docusaurus/core" "2.1.0" - "@docusaurus/mdx-loader" "2.1.0" - "@docusaurus/module-type-aliases" "2.1.0" - "@docusaurus/plugin-content-blog" "2.1.0" - "@docusaurus/plugin-content-docs" "2.1.0" - "@docusaurus/plugin-content-pages" "2.1.0" - "@docusaurus/theme-common" "2.1.0" - "@docusaurus/theme-translations" "2.1.0" - "@docusaurus/types" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-common" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" +"@docusaurus/theme-classic@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.2.0.tgz#a048bb1bc077dee74b28bec25f4b84b481863742" + integrity sha512-kjbg/qJPwZ6H1CU/i9d4l/LcFgnuzeiGgMQlt6yPqKo0SOJIBMPuz7Rnu3r/WWbZFPi//o8acclacOzmXdUUEg== + dependencies: + "@docusaurus/core" "2.2.0" + "@docusaurus/mdx-loader" "2.2.0" + "@docusaurus/module-type-aliases" "2.2.0" + "@docusaurus/plugin-content-blog" "2.2.0" + "@docusaurus/plugin-content-docs" "2.2.0" + "@docusaurus/plugin-content-pages" "2.2.0" + "@docusaurus/theme-common" "2.2.0" + "@docusaurus/theme-translations" "2.2.0" + "@docusaurus/types" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-common" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" "@mdx-js/react" "^1.6.22" clsx "^1.2.1" copy-text-to-clipboard "^3.0.1" @@ -1863,17 +1863,17 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-common@2.1.0", "@docusaurus/theme-common@~2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.1.0.tgz#dff4d5d1e29efc06125dc06f7b259f689bb3f24d" - integrity sha512-vT1otpVPbKux90YpZUnvknsn5zvpLf+AW1W0EDcpE9up4cDrPqfsh0QoxGHFJnobE2/qftsBFC19BneN4BH8Ag== - dependencies: - "@docusaurus/mdx-loader" "2.1.0" - "@docusaurus/module-type-aliases" "2.1.0" - "@docusaurus/plugin-content-blog" "2.1.0" - "@docusaurus/plugin-content-docs" "2.1.0" - "@docusaurus/plugin-content-pages" "2.1.0" - "@docusaurus/utils" "2.1.0" +"@docusaurus/theme-common@2.2.0", "@docusaurus/theme-common@~2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.2.0.tgz#2303498d80448aafdd588b597ce9d6f4cfa930e4" + integrity sha512-R8BnDjYoN90DCL75gP7qYQfSjyitXuP9TdzgsKDmSFPNyrdE3twtPNa2dIN+h+p/pr+PagfxwWbd6dn722A1Dw== + dependencies: + "@docusaurus/mdx-loader" "2.2.0" + "@docusaurus/module-type-aliases" "2.2.0" + "@docusaurus/plugin-content-blog" "2.2.0" + "@docusaurus/plugin-content-docs" "2.2.0" + "@docusaurus/plugin-content-pages" "2.2.0" + "@docusaurus/utils" "2.2.0" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -1883,19 +1883,19 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-search-algolia@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.1.0.tgz#e7cdf64b6f7a15b07c6dcf652fd308cfdaabb0ee" - integrity sha512-rNBvi35VvENhucslEeVPOtbAzBdZY/9j55gdsweGV5bYoAXy4mHB6zTGjealcB4pJ6lJY4a5g75fXXMOlUqPfg== +"@docusaurus/theme-search-algolia@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.2.0.tgz#77fd9f7a600917e6024fe3ac7fb6cfdf2ce84737" + integrity sha512-2h38B0tqlxgR2FZ9LpAkGrpDWVdXZ7vltfmTdX+4RsDs3A7khiNsmZB+x/x6sA4+G2V2CvrsPMlsYBy5X+cY1w== dependencies: "@docsearch/react" "^3.1.1" - "@docusaurus/core" "2.1.0" - "@docusaurus/logger" "2.1.0" - "@docusaurus/plugin-content-docs" "2.1.0" - "@docusaurus/theme-common" "2.1.0" - "@docusaurus/theme-translations" "2.1.0" - "@docusaurus/utils" "2.1.0" - "@docusaurus/utils-validation" "2.1.0" + "@docusaurus/core" "2.2.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/plugin-content-docs" "2.2.0" + "@docusaurus/theme-common" "2.2.0" + "@docusaurus/theme-translations" "2.2.0" + "@docusaurus/utils" "2.2.0" + "@docusaurus/utils-validation" "2.2.0" algoliasearch "^4.13.1" algoliasearch-helper "^3.10.0" clsx "^1.2.1" @@ -1905,18 +1905,18 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-translations@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.1.0.tgz#ce9a2955afd49bff364cfdfd4492b226f6dd3b6e" - integrity sha512-07n2akf2nqWvtJeMy3A+7oSGMuu5F673AovXVwY0aGAux1afzGCiqIFlYW3EP0CujvDJAEFSQi/Tetfh+95JNg== +"@docusaurus/theme-translations@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.2.0.tgz#5fbd4693679806f80c26eeae1381e1f2c23d83e7" + integrity sha512-3T140AG11OjJrtKlY4pMZ5BzbGRDjNs2co5hJ6uYJG1bVWlhcaFGqkaZ5lCgKflaNHD7UHBHU9Ec5f69jTdd6w== dependencies: fs-extra "^10.1.0" tslib "^2.4.0" -"@docusaurus/types@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.1.0.tgz#01e13cd9adb268fffe87b49eb90302d5dc3edd6b" - integrity sha512-BS1ebpJZnGG6esKqsjtEC9U9qSaPylPwlO7cQ1GaIE7J/kMZI3FITnNn0otXXu7c7ZTqhb6+8dOrG6fZn6fqzQ== +"@docusaurus/types@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.2.0.tgz#02c577a4041ab7d058a3c214ccb13647e21a9857" + integrity sha512-b6xxyoexfbRNRI8gjblzVOnLr4peCJhGbYGPpJ3LFqpi5nsFfoK4mmDLvWdeah0B7gmJeXabN7nQkFoqeSdmOw== dependencies: "@types/history" "^4.7.11" "@types/react" "*" @@ -1927,30 +1927,30 @@ webpack "^5.73.0" webpack-merge "^5.8.0" -"@docusaurus/utils-common@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.1.0.tgz#248434751096f8c6c644ed65eed2a5a070a227f8" - integrity sha512-F2vgmt4yRFgRQR2vyEFGTWeyAdmgKbtmu3sjHObF0tjjx/pN0Iw/c6eCopaH34E6tc9nO0nvp01pwW+/86d1fg== +"@docusaurus/utils-common@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.2.0.tgz#a401c1b93a8697dd566baf6ac64f0fdff1641a78" + integrity sha512-qebnerHp+cyovdUseDQyYFvMW1n1nv61zGe5JJfoNQUnjKuApch3IVsz+/lZ9a38pId8kqehC1Ao2bW/s0ntDA== dependencies: tslib "^2.4.0" -"@docusaurus/utils-validation@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.1.0.tgz#c8cf1d8454d924d9a564fefa86436268f43308e3" - integrity sha512-AMJzWYKL3b7FLltKtDXNLO9Y649V2BXvrnRdnW2AA+PpBnYV78zKLSCz135cuWwRj1ajNtP4onbXdlnyvCijGQ== +"@docusaurus/utils-validation@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.2.0.tgz#04d4d103137ad0145883971d3aa497f4a1315f25" + integrity sha512-I1hcsG3yoCkasOL5qQAYAfnmVoLei7apugT6m4crQjmDGxq+UkiRrq55UqmDDyZlac/6ax/JC0p+usZ6W4nVyg== dependencies: - "@docusaurus/logger" "2.1.0" - "@docusaurus/utils" "2.1.0" + "@docusaurus/logger" "2.2.0" + "@docusaurus/utils" "2.2.0" joi "^17.6.0" js-yaml "^4.1.0" tslib "^2.4.0" -"@docusaurus/utils@2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.1.0.tgz#b77b45b22e61eb6c2dcad8a7e96f6db0409b655f" - integrity sha512-fPvrfmAuC54n8MjZuG4IysaMdmvN5A/qr7iFLbSGSyDrsbP4fnui6KdZZIa/YOLIPLec8vjZ8RIITJqF18mx4A== +"@docusaurus/utils@2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.2.0.tgz#3d6f9b7a69168d5c92d371bf21c556a4f50d1da6" + integrity sha512-oNk3cjvx7Tt1Lgh/aeZAmFpGV2pDr5nHKrBVx6hTkzGhrnMuQqLt6UPlQjdYQ3QHXwyF/ZtZMO1D5Pfi0lu7SA== dependencies: - "@docusaurus/logger" "2.1.0" + "@docusaurus/logger" "2.2.0" "@svgr/webpack" "^6.2.1" file-loader "^6.2.0" fs-extra "^10.1.0" From f11183cfe31e4e2c29d122516a9884c85a2617e0 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 1 Nov 2022 22:12:25 -0700 Subject: [PATCH 14/76] chore(eslint-plugin-internal): [plugin-test-formatting] support random object literal tests (#5895) * chore(eslint-plugin-internal): [plugin-test-formatting] support random object literal tests * update test column --- packages/eslint-plugin-internal/package.json | 1 + .../src/rules/plugin-test-formatting.ts | 109 +- .../rules/plugin-test-formatting.test.ts | 211 +- packages/eslint-plugin/tests/RuleTester.ts | 5 + .../tests/rules/member-ordering.test.ts | 3256 +++++++++-------- ...habetically-case-insensitive-order.test.ts | 289 +- ...mber-ordering-alphabetically-order.test.ts | 2299 ++++++------ 7 files changed, 3225 insertions(+), 2945 deletions(-) diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index e21f2c82fa4..1603397279a 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -15,6 +15,7 @@ "dependencies": { "@types/prettier": "*", "@typescript-eslint/scope-manager": "5.42.0", + "@typescript-eslint/type-utils": "5.42.0", "@typescript-eslint/utils": "5.42.0", "prettier": "*" } diff --git a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts index 15386398048..8cd85cce8e9 100644 --- a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts +++ b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts @@ -1,5 +1,6 @@ +import { getContextualType } from '@typescript-eslint/type-utils'; import type { TSESTree } from '@typescript-eslint/utils'; -import { AST_NODE_TYPES } from '@typescript-eslint/utils'; +import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils'; import { format, resolveConfig } from 'prettier'; import { createRule } from '../util'; @@ -108,6 +109,7 @@ export default createRule({ docs: { description: `Enforces that eslint-plugin test snippets are correctly formatted`, recommended: 'error', + requiresTypeChecking: true, }, fixable: 'code', schema: [ @@ -146,6 +148,11 @@ export default createRule({ ], create(context, [{ formatWithPrettier }]) { const sourceCode = context.getSourceCode(); + const { program, esTreeNodeToTSNodeMap } = + ESLintUtils.getParserServices(context); + const checker = program.getTypeChecker(); + + const checkedObjects = new Set(); function prettierFormat( code: string, @@ -448,6 +455,12 @@ export default createRule({ test: TSESTree.ObjectExpression, isErrorTest = true, ): void { + if (checkedObjects.has(test)) { + return; + } + + checkedObjects.add(test); + for (const prop of test.properties) { if ( prop.type !== AST_NODE_TYPES.Property || @@ -478,33 +491,99 @@ export default createRule({ } } - const invalidTestsSelectorPath = [ - AST_NODE_TYPES.CallExpression, - AST_NODE_TYPES.ObjectExpression, - 'Property[key.name = "invalid"]', - AST_NODE_TYPES.ArrayExpression, - AST_NODE_TYPES.ObjectExpression, - ]; - return { // valid 'CallExpression > ObjectExpression > Property[key.name = "valid"] > ArrayExpression': checkValidTest, // invalid - errors - [invalidTestsSelectorPath.join(' > ')]: checkInvalidTest, - // invalid - suggestions [[ - ...invalidTestsSelectorPath, - 'Property[key.name = "errors"]', - AST_NODE_TYPES.ArrayExpression, + AST_NODE_TYPES.CallExpression, AST_NODE_TYPES.ObjectExpression, - 'Property[key.name = "suggestions"]', + 'Property[key.name = "invalid"]', AST_NODE_TYPES.ArrayExpression, AST_NODE_TYPES.ObjectExpression, ].join(' > ')]: checkInvalidTest, // special case for our batchedSingleLineTests utility 'CallExpression[callee.name = "batchedSingleLineTests"] > ObjectExpression': checkInvalidTest, + + /** + * generic, type-aware handling for any old object + * this is a fallback to handle random variables people declare or object + * literals that are passed via array maps, etc + */ + ObjectExpression(node): void { + if (checkedObjects.has(node)) { + return; + } + + const type = getContextualType( + checker, + esTreeNodeToTSNodeMap.get(node), + ); + if (!type) { + return; + } + + const typeString = checker.typeToString(type); + if (/^RunTests\b/.test(typeString)) { + checkedObjects.add(node); + + for (const prop of node.properties) { + if ( + prop.type === AST_NODE_TYPES.SpreadElement || + prop.computed || + prop.key.type !== AST_NODE_TYPES.Identifier || + prop.value.type !== AST_NODE_TYPES.ArrayExpression + ) { + continue; + } + + switch (prop.key.name) { + case 'valid': + checkValidTest(prop.value); + break; + + case 'invalid': + for (const element of prop.value.elements) { + if (element.type === AST_NODE_TYPES.ObjectExpression) { + checkInvalidTest(element); + } + } + break; + } + } + return; + } + + if (/^ValidTestCase\b/.test(typeString)) { + checkInvalidTest(node); + return; + } + + if (/^InvalidTestCase\b/.test(typeString)) { + checkInvalidTest(node); + for (const testProp of node.properties) { + if ( + testProp.type === AST_NODE_TYPES.SpreadElement || + testProp.computed || + testProp.key.type !== AST_NODE_TYPES.Identifier || + testProp.key.name !== 'errors' || + testProp.value.type !== AST_NODE_TYPES.ArrayExpression + ) { + continue; + } + + for (const errorElement of testProp.value.elements) { + if (errorElement.type !== AST_NODE_TYPES.ObjectExpression) { + continue; + } + + checkInvalidTest(errorElement); + } + } + } + }, }; }, }); diff --git a/packages/eslint-plugin-internal/tests/rules/plugin-test-formatting.test.ts b/packages/eslint-plugin-internal/tests/rules/plugin-test-formatting.test.ts index 81be2118f6c..f5745996d38 100644 --- a/packages/eslint-plugin-internal/tests/rules/plugin-test-formatting.test.ts +++ b/packages/eslint-plugin-internal/tests/rules/plugin-test-formatting.test.ts @@ -1,9 +1,11 @@ import rule from '../../src/rules/plugin-test-formatting'; -import { RuleTester } from '../RuleTester'; +import { getFixturesRootDir, RuleTester } from '../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', parserOptions: { + project: './tsconfig.json', + tsconfigRootDir: getFixturesRootDir(), sourceType: 'module', }, }); @@ -132,6 +134,44 @@ ${CODE_INDENT}const a = 1; ${CODE_INDENT}const b = 1; ${PARENT_INDENT}\``, + + // random, unannotated variables aren't checked + ` +const test1 = { + code: 'const badlyFormatted = "code"', +}; +const test2 = { + valid: [ + 'const badlyFormatted = "code"', + { + code: 'const badlyFormatted = "code"', + }, + ], + invalid: [ + { + code: 'const badlyFormatted = "code"', + errors: [], + }, + ], +}; + `, + + // TODO - figure out how to handle this pattern + ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test = [ + { + code: 'const badlyFormatted = "code1"', + }, + { + code: 'const badlyFormatted = "code2"', + }, +].map>(test => ({ + code: test.code, + errors: [], +})); + `, ], invalid: [ // Literal @@ -506,5 +546,174 @@ foo }, ], }, + + // annotated variables are checked + { + code: ` +const test: RunTests = { + valid: [ + 'const badlyFormatted = "code"', + { + code: 'const badlyFormatted = "code"', + }, + ], + invalid: [ + { + code: 'const badlyFormatted = "code"', + errors: [], + }, + ], +}; + `, + output: ` +const test: RunTests = { + valid: [ + "const badlyFormatted = 'code';", + { + code: "const badlyFormatted = 'code';", + }, + ], + invalid: [ + { + code: "const badlyFormatted = 'code';", + errors: [], + }, + ], +}; + `, + errors: [ + { + messageId: 'invalidFormatting', + }, + { + messageId: 'invalidFormatting', + }, + { + messageId: 'invalidFormattingErrorTest', + }, + ], + }, + { + code: ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test: TSESLint.RunTests<'', []> = { + valid: [ + 'const badlyFormatted = "code"', + { + code: 'const badlyFormatted = "code"', + }, + ], + invalid: [ + { + code: 'const badlyFormatted = "code"', + errors: [], + }, + ], +}; + `, + output: ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test: TSESLint.RunTests<'', []> = { + valid: [ + "const badlyFormatted = 'code';", + { + code: "const badlyFormatted = 'code';", + }, + ], + invalid: [ + { + code: "const badlyFormatted = 'code';", + errors: [], + }, + ], +}; + `, + errors: [ + { + messageId: 'invalidFormatting', + }, + { + messageId: 'invalidFormatting', + }, + { + messageId: 'invalidFormattingErrorTest', + }, + ], + }, + { + code: ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test: TSESLint.ValidTestCase<[]> = { + code: 'const badlyFormatted = "code"', +}; + `, + output: ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test: TSESLint.ValidTestCase<[]> = { + code: "const badlyFormatted = 'code';", +}; + `, + errors: [ + { + messageId: 'invalidFormattingErrorTest', + }, + ], + }, + { + code: ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test: TSESLint.InvalidTestCase<'', []> = { + code: 'const badlyFormatted = "code1"', + errors: [ + { + code: 'const badlyFormatted = "code2"', + // shouldn't get fixed as per rule ignoring output + output: 'const badlyFormatted = "code3"', + suggestions: [ + { + messageId: '', + // shouldn't get fixed as per rule ignoring output + output: 'const badlyFormatted = "code4"', + }, + ], + }, + ], +}; + `, + output: ` +import { TSESLint } from '@typescript-eslint/utils'; + +const test: TSESLint.InvalidTestCase<'', []> = { + code: "const badlyFormatted = 'code1';", + errors: [ + { + code: "const badlyFormatted = 'code2';", + // shouldn't get fixed as per rule ignoring output + output: 'const badlyFormatted = "code3"', + suggestions: [ + { + messageId: '', + // shouldn't get fixed as per rule ignoring output + output: 'const badlyFormatted = "code4"', + }, + ], + }, + ], +}; + `, + errors: [ + { + messageId: 'invalidFormattingErrorTest', + }, + { + messageId: 'invalidFormattingErrorTest', + }, + ], + }, ], }); diff --git a/packages/eslint-plugin/tests/RuleTester.ts b/packages/eslint-plugin/tests/RuleTester.ts index 7479d99f29a..7c46b9a12f5 100644 --- a/packages/eslint-plugin/tests/RuleTester.ts +++ b/packages/eslint-plugin/tests/RuleTester.ts @@ -6,5 +6,10 @@ function getFixturesRootDir(): string { } const { batchedSingleLineTests, RuleTester, noFormat } = ESLintUtils; +export { + RunTests, + ValidTestCase, + InvalidTestCase, +} from '@typescript-eslint/utils/dist/eslint-utils/rule-tester/RuleTester'; export { batchedSingleLineTests, getFixturesRootDir, noFormat, RuleTester }; diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index 68bbfa7eff6..538cfa733db 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -1,130 +1,129 @@ -import type { TSESLint } from '@typescript-eslint/utils'; - import type { MessageIds, Options } from '../../src/rules/member-ordering'; import rule from '../../src/rules/member-ordering'; +import type { RunTests } from '../RuleTester'; import { RuleTester } from '../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); -const grouped: TSESLint.RunTests = { +const grouped: RunTests = { valid: [ ` // no accessibility === public interface Foo { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - new(); - G(); - H(); - I(); - J(); - K(); - L(); + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + new (); + G(); + H(); + I(); + J(); + K(); + L(); } - `, + `, { code: ` // no accessibility === public interface Foo { - A: string; - J(); - K(); - D: string; - E: string; - F: string; - new(); - G(); - H(); - [Z: string]: any; - B: string; - C: string; - I(); - L(); + A: string; + J(); + K(); + D: string; + E: string; + F: string; + new (); + G(); + H(); + [Z: string]: any; + B: string; + C: string; + I(); + L(); } - `, + `, options: [{ default: 'never' }], }, { code: ` // no accessibility === public interface Foo { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - new(); - G(); - H(); - I(); - J(); - K(); - L(); + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + new (); + G(); + H(); + I(); + J(); + K(); + L(); } - `, + `, options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` interface X { (): void; - a: unknown; + a: unknown; b(): void; } - `, + `, options: [{ default: ['call-signature', 'field', 'method'] }], }, { code: ` // no accessibility === public interface Foo { - A: string; - J(); - K(); - D: string; - [Z: string]: any; - E: string; - F: string; - new(); - G(); - B: string; - C: string; - H(); - I(); - L(); + A: string; + J(); + K(); + D: string; + [Z: string]: any; + E: string; + F: string; + new (); + G(); + B: string; + C: string; + H(); + I(); + L(); } - `, + `, options: [{ interfaces: 'never' }], }, { code: ` // no accessibility === public interface Foo { - [Z: string]: any; - G(); - H(); - I(); - J(); - K(); - L(); - new(); - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; + [Z: string]: any; + G(); + H(); + I(); + J(); + K(); + L(); + new (); + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; } - `, + `, options: [ { interfaces: ['signature', 'method', 'constructor', 'field'] }, ], @@ -133,22 +132,22 @@ interface Foo { code: ` // no accessibility === public interface Foo { - G(); - H(); - I(); - J(); - K(); - L(); - new(); - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - [Z: string]: any; + G(); + H(); + I(); + J(); + K(); + L(); + new (); + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + [Z: string]: any; } - `, + `, options: [ { default: ['signature', 'field', 'constructor', 'method'], @@ -160,23 +159,23 @@ interface Foo { code: ` // no accessibility === public interface Foo { - G(); - H(); - I(); - new(); - [Z: string]: any; - D: string; - E: string; - F: string; - G?: string; - J(); - K(); - L(); - A: string; - B: string; - C: string; + G(); + H(); + I(); + new (); + [Z: string]: any; + D: string; + E: string; + F: string; + G?: string; + J(); + K(); + L(); + A: string; + B: string; + C: string; } - `, + `, options: [ { default: [ @@ -191,22 +190,22 @@ interface Foo { code: ` // no accessibility === public interface Foo { - G(); - H(); - I(); - J(); - K(); - L(); - [Z: string]: any; - D: string; - E: string; - F: string; - new(); - A: string; - B: string; - C: string; + G(); + H(); + I(); + J(); + K(); + L(); + [Z: string]: any; + D: string; + E: string; + F: string; + new (); + A: string; + B: string; + C: string; } - `, + `, options: [ { default: ['method', 'public-constructor', 'protected-static-field'], @@ -216,147 +215,147 @@ interface Foo { ` // no accessibility === public type Foo = { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - new(); - G(); - H(); - I(); - J(); - K(); - L(); -} - `, + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + new (); + G(); + H(); + I(); + J(); + K(); + L(); +}; + `, { code: ` // no accessibility === public type Foo = { - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - [Z: string]: any; - G(); - H(); - I(); - J(); - K(); - L(); -} - `, + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + [Z: string]: any; + G(); + H(); + I(); + J(); + K(); + L(); +}; + `, options: [{ default: 'never' }], }, { code: ` // no accessibility === public type Foo = { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); -} - `, + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); +}; + `, options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` // no accessibility === public type Foo = { - [Z: string]: any; - new(); - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); -} - `, + [Z: string]: any; + new (); + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); +}; + `, options: [{ default: ['field', 'method'] }], }, { code: ` // no accessibility === public type Foo = { - G(); - H(); - [Z: string]: any; - K(); - L(); - A: string; - B: string; - I(); - J(); - C: string; - D: string; - E: string; - F: string; -} - `, + G(); + H(); + [Z: string]: any; + K(); + L(); + A: string; + B: string; + I(); + J(); + C: string; + D: string; + E: string; + F: string; +}; + `, options: [{ typeLiterals: 'never' }], }, { code: ` // no accessibility === public type Foo = { - G(); - H(); - I(); - J(); - K(); - L(); - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - [Z: string]: any; -} - `, + G(); + H(); + I(); + J(); + K(); + L(); + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + [Z: string]: any; +}; + `, options: [{ typeLiterals: ['method', 'field', 'signature'] }], }, { code: ` // no accessibility === public type Foo = { - G(); - H(); - I(); - J(); - K(); - L(); - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - [Z: string]: any; -} - `, + G(); + H(); + I(); + J(); + K(); + L(); + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + [Z: string]: any; +}; + `, options: [ { typeLiterals: ['method', 'constructor', 'field', 'signature'] }, ], @@ -365,21 +364,21 @@ type Foo = { code: ` // no accessibility === public type Foo = { - G(); - H(); - I(); - J(); - K(); - L(); - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - [Z: string]: any; -} - `, + G(); + H(); + I(); + J(); + K(); + L(); + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + [Z: string]: any; +}; + `, options: [ { default: ['signature', 'field', 'constructor', 'method'], @@ -391,21 +390,21 @@ type Foo = { code: ` // no accessibility === public type Foo = { - [Z: string]: any; - D: string; - E: string; - F: string; - A: string; - B: string; - C: string; - G(); - H(); - I(); - J(); - K(); - L(); -} - `, + [Z: string]: any; + D: string; + E: string; + F: string; + A: string; + B: string; + C: string; + G(); + H(); + I(); + J(); + K(); + L(); +}; + `, options: [ { default: [ @@ -419,182 +418,182 @@ type Foo = { }, ` class Foo { - [Z: string]: any; - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} + [Z: string]: any; + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} } - `, + `, { code: ` class Foo { - [Z: string]: any; - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} + [Z: string]: any; + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} } - `, + `, options: [{ default: 'never' }], }, { code: ` class Foo { - [Z: string]: any; - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} + [Z: string]: any; + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} } - `, + `, options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` class Foo { - [Z: string]: any; - constructor() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} + [Z: string]: any; + constructor() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} } - `, + `, options: [{ default: ['field', 'method'] }], }, { code: ` class Foo { - public static G() {} - protected K() {} - private L() {} - private static I() {} - public J() {} - public D: string = ""; - [Z: string]: any; - protected static H() {} - public static A: string; - protected static B: string = ""; - constructor() {} - private static C: string = ""; - protected E: string = ""; - private F: string = ""; + public static G() {} + protected K() {} + private L() {} + private static I() {} + public J() {} + public D: string = ''; + [Z: string]: any; + protected static H() {} + public static A: string; + protected static B: string = ''; + constructor() {} + private static C: string = ''; + protected E: string = ''; + private F: string = ''; } - `, + `, options: [{ classes: 'never' }], }, { code: ` class Foo { - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - [Z: string]: any; - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + [Z: string]: any; + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} } - `, + `, options: [{ classes: ['method', 'field'] }], }, { code: ` class Foo { - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - constructor() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - [Z: string]: any; + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + constructor() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + [Z: string]: any; } - `, + `, options: [{ classes: ['method', 'constructor', 'field', 'signature'] }], }, { code: ` class Foo { - private required: boolean; - private typeChecker: (data: any) => boolean; - constructor(validator: (data: any) => boolean) { - this.typeChecker = validator; - } - check(data: any): boolean { - return this.typeChecker(data); - } + private required: boolean; + private typeChecker: (data: any) => boolean; + constructor(validator: (data: any) => boolean) { + this.typeChecker = validator; + } + check(data: any): boolean { + return this.typeChecker(data); + } } - `, + `, options: [{ classes: ['field', 'constructor', 'method'] }], }, { code: ` class Foo { - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - constructor() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - [Z: string]: any; + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + constructor() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + [Z: string]: any; } - `, + `, options: [ { default: ['signature', 'field', 'constructor', 'method'], @@ -605,22 +604,22 @@ class Foo { { code: ` class Foo { - public J() {} - public static G() {} - protected static H() {} - private static I() {} - protected K() {} - private L() {} - [Z: string]: any; - constructor() {} - public D: string = ""; - public static A: string; - private static C: string = ""; - private F: string = ""; - protected static B: string = ""; - protected E: string = ""; + public J() {} + public static G() {} + protected static H() {} + private static I() {} + protected K() {} + private L() {} + [Z: string]: any; + constructor() {} + public D: string = ''; + public static A: string; + private static C: string = ''; + private F: string = ''; + protected static B: string = ''; + protected E: string = ''; } - `, + `, options: [ { classes: [ @@ -637,22 +636,22 @@ class Foo { { code: ` class Foo { - public static G() {} - private static I() {} - protected static H() {} - public J() {} - private L() {} - protected K() {} - [Z: string]: any; - constructor() {} - public D: string = ""; - public static A: string; - protected static B: string = ""; - protected E: string = ""; - private static C: string = ""; - private F: string = ""; + public static G() {} + private static I() {} + protected static H() {} + public J() {} + private L() {} + protected K() {} + [Z: string]: any; + constructor() {} + public D: string = ''; + public static A: string; + protected static B: string = ''; + protected E: string = ''; + private static C: string = ''; + private F: string = ''; } - `, + `, options: [ { classes: [ @@ -672,22 +671,22 @@ class Foo { { code: ` class Foo { - public J() {} - public static G() {} - public D: string = ""; - public static A: string = ""; - constructor() {} - protected K() {} - private L() {} - protected static H() {} - private static I() {} - protected static B: string = ""; - private static C: string = ""; - protected E: string = ""; - private F: string = ""; - [Z: string]: any; + public J() {} + public static G() {} + public D: string = ''; + public static A: string = ''; + constructor() {} + protected K() {} + private L() {} + protected static H() {} + private static I() {} + protected static B: string = ''; + private static C: string = ''; + protected E: string = ''; + private F: string = ''; + [Z: string]: any; } - `, + `, options: [ { default: [ @@ -704,22 +703,22 @@ class Foo { { code: ` class Foo { - public J() {} - public static G() {} - protected static H() {} - private static I() {} - protected K() {} - private L() {} - constructor() {} - [Z: string]: any; - public static A: string; - private F: string = ""; - protected static B: string = ""; - public D: string = ""; - private static C: string = ""; - protected E: string = ""; + public J() {} + public static G() {} + protected static H() {} + private static I() {} + protected K() {} + private L() {} + constructor() {} + [Z: string]: any; + public static A: string; + private F: string = ''; + protected static B: string = ''; + public D: string = ''; + private static C: string = ''; + protected E: string = ''; } - `, + `, options: [ { classes: [ @@ -738,22 +737,22 @@ class Foo { { code: ` class Foo { - private L() {} - private static I() {} - protected static H() {} - protected static B: string = ""; - public static G() {} - public J() {} - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - [Z: string]: any; + private L() {} + private static I() {} + protected static H() {} + protected static B: string = ''; + public static G() {} + public J() {} + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} + [Z: string]: any; } - `, + `, options: [ { classes: ['private-instance-method', 'protected-static-field'], @@ -763,22 +762,22 @@ class Foo { { code: ` class Foo { - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - [Z: string]: any; + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} + [Z: string]: any; } - `, + `, options: [ { default: ['public-instance-method', 'protected-static-field'], @@ -788,22 +787,22 @@ class Foo { { code: ` class Foo { - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - [Z: string]: any; + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} + [Z: string]: any; } - `, + `, options: [ { classes: ['public-instance-method', 'protected-static-field'], @@ -813,22 +812,22 @@ class Foo { { code: ` class Foo { - [Z: string]: any; - public D: string = ""; - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - private constructor() {} - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; + [Z: string]: any; + public D: string = ''; + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + private constructor() {} + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; } - `, + `, options: [ { default: [ @@ -847,22 +846,22 @@ class Foo { { code: ` class Foo { - public constructor() {} - public D: string = ""; - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - [Z: string]: any; - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; + public constructor() {} + public D: string = ''; + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + [Z: string]: any; + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; } - `, + `, options: [ { default: [ @@ -880,146 +879,146 @@ class Foo { }, ` const foo = class Foo { - [Z: string]: any; - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} -} - `, + [Z: string]: any; + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} +}; + `, { code: ` const foo = class Foo { - constructor() {} - public static A: string; - protected static B: string = ""; - private static I() {} - public J() {} - private F: string = ""; - [Z: string]: any; - public static G() {} - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - protected static H() {} - protected K() {} - private L() {} -} - `, + constructor() {} + public static A: string; + protected static B: string = ''; + private static I() {} + public J() {} + private F: string = ''; + [Z: string]: any; + public static G() {} + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + protected static H() {} + protected K() {} + private L() {} +}; + `, options: [{ default: 'never' }], }, { code: ` const foo = class Foo { - [Z: string]: any; - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} -} - `, + [Z: string]: any; + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} +}; + `, options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` const foo = class Foo { - constructor() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - [Z: string]: any; - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} -} - `, + constructor() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + [Z: string]: any; + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} +}; + `, options: [{ default: ['field', 'method'] }], }, { code: ` const foo = class Foo { - private L() {} - protected static H() {} - constructor() {} - private static I() {} - public J() {} - private static C: string = ""; - [Z: string]: any; - public D: string = ""; - protected K() {} - public static G() {} - public static A: string; - protected static B: string = ""; - protected E: string = ""; - private F: string = ""; -} - `, + private L() {} + protected static H() {} + constructor() {} + private static I() {} + public J() {} + private static C: string = ''; + [Z: string]: any; + public D: string = ''; + protected K() {} + public static G() {} + public static A: string; + protected static B: string = ''; + protected E: string = ''; + private F: string = ''; +}; + `, options: [{ classExpressions: 'never' }], }, { code: ` const foo = class Foo { - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - [Z: string]: any; -} - `, + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + [Z: string]: any; +}; + `, options: [{ classExpressions: ['method', 'field'] }], }, { code: ` const foo = class Foo { - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - [Z: string]: any; - constructor() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; -} - `, + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + [Z: string]: any; + constructor() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; +}; + `, options: [ { classExpressions: ['method', 'signature', 'constructor', 'field'] }, ], @@ -1027,22 +1026,22 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - [Z: string]: any; - constructor() {} - public static A: string; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; -} - `, + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + [Z: string]: any; + constructor() {} + public static A: string; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; +}; + `, options: [ { default: ['field', 'constructor', 'method'], @@ -1053,23 +1052,22 @@ const foo = class Foo { { code: ` const foo = class Foo { - [Z: string]: any; - private L() {} - private static I() {} - protected static H() {} - protected static B: string = ""; - public static G() {} - public J() {} - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - -} - `, + [Z: string]: any; + private L() {} + private static I() {} + protected static H() {} + protected static B: string = ''; + public static G() {} + public J() {} + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} +}; + `, options: [ { classExpressions: [ @@ -1082,23 +1080,22 @@ const foo = class Foo { { code: ` const foo = class Foo { - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - [Z: string]: any; - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - -} - `, + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + [Z: string]: any; + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} +}; + `, options: [ { default: ['public-instance-method', 'protected-static-field'], @@ -1108,23 +1105,22 @@ const foo = class Foo { { code: ` const foo = class Foo { - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - [Z: string]: any; - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - -} - `, + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + [Z: string]: any; + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} +}; + `, options: [ { classExpressions: [ @@ -1137,22 +1133,22 @@ const foo = class Foo { { code: ` const foo = class Foo { - public D: string = ""; - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - [Z: string]: any; - private constructor() {} - protected static B: string = ""; - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; -} - `, + public D: string = ''; + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + [Z: string]: any; + private constructor() {} + protected static B: string = ''; + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; +}; + `, options: [ { default: [ @@ -1176,22 +1172,22 @@ const foo = class Foo { { code: ` const foo = class Foo { - public constructor() {} - public D: string = ""; - private L() {} - private static I() {} - protected static H() {} - public static G() {} - public J() {} - protected static B: string = ""; - protected K() {} - [Z: string]: any; - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; -} - `, + public constructor() {} + public D: string = ''; + private L() {} + private static I() {} + protected static H() {} + public static G() {} + public J() {} + protected static B: string = ''; + protected K() {} + [Z: string]: any; + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; +}; + `, options: [ { default: [ @@ -1214,36 +1210,36 @@ const foo = class Foo { }, ` class Foo { - [Z: string]: any; - A: string; - constructor () {} - J() {} - K = () => {} + [Z: string]: any; + A: string; + constructor() {} + J() {} + K = () => {}; } - `, + `, { code: ` class Foo { - J() {} - K = () => {} - constructor () {} - A: string; - [Z: string]: any; + J() {} + K = () => {}; + constructor() {} + A: string; + [Z: string]: any; } - `, + `, options: [{ default: ['method', 'constructor', 'field', 'signature'] }], }, { code: ` class Foo { - J() {} - K = () => {} - constructor () {} - [Z: string]: any; - A: string; - L: () => {} + J() {} + K = () => {}; + constructor() {} + [Z: string]: any; + A: string; + L: () => {}; } - `, + `, options: [{ default: ['method', 'constructor', 'signature', 'field'] }], }, { @@ -1253,7 +1249,7 @@ class Foo { m() {} f = 1; } - `, + `, options: [{ default: ['static-initialization', 'method', 'field'] }], }, { @@ -1263,7 +1259,7 @@ class Foo { f = 1; static {} } - `, + `, options: [{ default: ['method', 'field', 'static-initialization'] }], }, { @@ -1273,108 +1269,110 @@ class Foo { static {} m() {} } - `, + `, options: [{ default: ['field', 'static-initialization', 'method'] }], }, ` interface Foo { - [Z: string]: any; - A: string; - K: () => {}; - J(); + [Z: string]: any; + A: string; + K: () => {}; + J(); } - `, + `, { code: ` interface Foo { - [Z: string]: any; - J(); - K: () => {} - A: string; + [Z: string]: any; + J(); + K: () => {}; + A: string; } - `, + `, options: [{ default: ['signature', 'method', 'constructor', 'field'] }], }, ` type Foo = { - [Z: string]: any; - A: string; - K: () => {} - J(); -} - `, + [Z: string]: any; + A: string; + K: () => {}; + J(); +}; + `, { code: ` type Foo = { - J(); - [Z: string]: any; - K: () => {} - A: string; -} - `, + J(); + [Z: string]: any; + K: () => {}; + A: string; +}; + `, options: [{ default: ['method', 'constructor', 'signature', 'field'] }], }, { code: ` abstract class Foo { - B: string; - abstract A: () => {} + B: string; + abstract A: () => {}; } - `, + `, }, { code: ` interface Foo { - [A:string]: number; - public B: string; + [A: string]: number; + B: string; } - `, + `, }, { code: ` abstract class Foo { - [Z: string]: any; - private static C: string; - B: string; - private D: string; - protected static F(): {}; - public E(): {}; - public abstract A(): void; - protected abstract G(): void; + [Z: string]: any; + private static C: string; + B: string; + private D: string; + protected static F(): {}; + public E(): {}; + public abstract A(): void; + protected abstract G(): void; } - `, + `, }, { code: ` abstract class Foo { - protected typeChecker: (data: any) => boolean; - public abstract required: boolean; - abstract verify(): void; + protected typeChecker: (data: any) => boolean; + public abstract required: boolean; + abstract verify(): void; } - `, + `, options: [{ classes: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` class Foo { - @Dec() B: string; - @Dec() A: string; - constructor() {} - D: string; - C: string; - E(): void; - F(): void; -} `, + @Dec() B: string; + @Dec() A: string; + constructor() {} + D: string; + C: string; + E(): void; + F(): void; +} + `, options: [{ default: ['decorated-field', 'field'] }], }, { code: ` class Foo { - A: string; - B: string; - @Dec() private C: string; - private D: string; -} `, + A: string; + B: string; + @Dec() private C: string; + private D: string; +} + `, options: [ { default: ['public-field', 'private-decorated-field', 'private-field'], @@ -1384,12 +1382,13 @@ class Foo { { code: ` class Foo { - constructor() {} - @Dec() public A(): void; - @Dec() private B: string; - private C(): void; - private D: string; -} `, + constructor() {} + @Dec() public A(): void; + @Dec() private B: string; + private C(): void; + private D: string; +} + `, options: [ { default: [ @@ -1403,12 +1402,13 @@ class Foo { { code: ` class Foo { - @Dec() private A(): void; - @Dec() private B: string; - constructor() {} - private C(): void; - private D: string; -} `, + @Dec() private A(): void; + @Dec() private B: string; + constructor() {} + private C(): void; + private D: string; +} + `, options: [ { default: [ @@ -1423,9 +1423,10 @@ class Foo { { code: ` class Foo { - public A: string; - @Dec() private B: string; -} `, + public A: string; + @Dec() private B: string; +} + `, options: [ { default: ['private-decorated-field', 'public-instance-field'], @@ -1437,12 +1438,13 @@ class Foo { { code: ` class Foo { - public A(): string; - @Dec() public B(): string; - public C(): string; + public A(): string; + @Dec() public B(): string; + public C(): string; - d: string; -} `, + d: string; +} + `, options: [ { default: ['public-method', 'field'], @@ -1452,14 +1454,15 @@ class Foo { { code: ` class Foo { - A: string; - constructor() {} - get B() {} - set B() {} - get C() {} - set C() {} - D(): void; -} `, + A: string; + constructor() {} + get B() {} + set B() {} + get C() {} + set C() {} + D(): void; +} + `, options: [ { default: ['field', 'constructor', ['get', 'set'], 'method'], @@ -1469,10 +1472,11 @@ class Foo { { code: ` class Foo { - A: string; - constructor() {} - B(): void; -} `, + A: string; + constructor() {} + B(): void; +} + `, options: [ { default: ['field', 'constructor', [], 'method'], @@ -1482,13 +1486,14 @@ class Foo { { code: ` class Foo { - A: string; - constructor() {} - @Dec() private B: string; - private C(): void; - set D() {} - E(): void; -} `, + A: string; + constructor() {} + @Dec() private B: string; + private C(): void; + set D() {} + E(): void; +} + `, options: [ { default: [ @@ -1503,14 +1508,15 @@ class Foo { { code: ` class Foo { - A: string; - constructor() {} - get B() {} - get C() {} - set B() {} - set C() {} - D(): void; -} `, + A: string; + constructor() {} + get B() {} + get C() {} + set B() {} + set C() {} + D(): void; +} + `, options: [ { default: ['field', 'constructor', ['get'], ['set'], 'method'], @@ -1523,22 +1529,22 @@ class Foo { code: ` // no accessibility === public interface Foo { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -1547,18 +1553,18 @@ interface Foo { rank: 'method', }, line: 17, - column: 5, + column: 3, }, ], }, { code: ` interface X { - a: unknown; + a: unknown; (): void; b(): void; } - `, + `, options: [{ default: ['call-signature', 'field', 'method'] }], errors: [ { @@ -1576,22 +1582,22 @@ interface X { code: ` // no accessibility === public interface Foo { - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); - [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); + [Z: string]: any; } - `, + `, options: [{ default: ['signature', 'method', 'constructor', 'field'] }], errors: [ { @@ -1601,7 +1607,7 @@ interface Foo { rank: 'field', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1610,7 +1616,7 @@ interface Foo { rank: 'field', }, line: 11, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1619,7 +1625,7 @@ interface Foo { rank: 'field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1628,7 +1634,7 @@ interface Foo { rank: 'field', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1637,7 +1643,7 @@ interface Foo { rank: 'field', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1646,7 +1652,7 @@ interface Foo { rank: 'field', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1655,7 +1661,7 @@ interface Foo { rank: 'field', }, line: 16, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1664,7 +1670,7 @@ interface Foo { rank: 'field', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -1672,22 +1678,22 @@ interface Foo { code: ` // no accessibility === public interface Foo { - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); - [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); + [Z: string]: any; } - `, + `, options: [ { interfaces: ['method', 'signature', 'constructor', 'field'] }, ], @@ -1699,7 +1705,7 @@ interface Foo { rank: 'field', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1708,7 +1714,7 @@ interface Foo { rank: 'field', }, line: 11, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1717,7 +1723,7 @@ interface Foo { rank: 'field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1726,7 +1732,7 @@ interface Foo { rank: 'field', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1735,7 +1741,7 @@ interface Foo { rank: 'field', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1744,7 +1750,7 @@ interface Foo { rank: 'field', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1753,7 +1759,7 @@ interface Foo { rank: 'field', }, line: 16, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1762,7 +1768,7 @@ interface Foo { rank: 'field', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -1770,22 +1776,22 @@ interface Foo { code: ` // no accessibility === public interface Foo { - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); - [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); + [Z: string]: any; } - `, + `, options: [ { default: ['field', 'method', 'constructor', 'signature'], @@ -1800,7 +1806,7 @@ interface Foo { rank: 'field', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1809,7 +1815,7 @@ interface Foo { rank: 'field', }, line: 11, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1818,7 +1824,7 @@ interface Foo { rank: 'field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1827,7 +1833,7 @@ interface Foo { rank: 'field', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1836,7 +1842,7 @@ interface Foo { rank: 'field', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1845,7 +1851,7 @@ interface Foo { rank: 'field', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1854,7 +1860,7 @@ interface Foo { rank: 'field', }, line: 16, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1863,7 +1869,7 @@ interface Foo { rank: 'field', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -1871,22 +1877,22 @@ interface Foo { code: ` // no accessibility === public interface Foo { - [Z: string]: any; - new(); - A: string; - G(); - B: string; - H(); - C: string; - I(); - D: string; - J(); - E: string; - K(); - F: string; - L(); + [Z: string]: any; + new (); + A: string; + G(); + B: string; + H(); + C: string; + I(); + D: string; + J(); + E: string; + K(); + F: string; + L(); } - `, + `, options: [ { interfaces: ['signature', 'constructor', 'field', 'method'], @@ -1900,7 +1906,7 @@ interface Foo { rank: 'method', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1909,7 +1915,7 @@ interface Foo { rank: 'method', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1918,7 +1924,7 @@ interface Foo { rank: 'method', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1927,7 +1933,7 @@ interface Foo { rank: 'method', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -1936,7 +1942,7 @@ interface Foo { rank: 'method', }, line: 16, - column: 5, + column: 3, }, ], }, @@ -1944,22 +1950,22 @@ interface Foo { code: ` // no accessibility === public type Foo = { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); -} - `, + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); +}; + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -1968,7 +1974,7 @@ type Foo = { rank: 'method', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -1976,22 +1982,22 @@ type Foo = { code: ` // no accessibility === public type Foo = { - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - [Z: string]: any; - new(); -} - `, + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + [Z: string]: any; + new (); +}; + `, options: [{ default: ['method', 'constructor', 'signature', 'field'] }], errors: [ { @@ -2001,7 +2007,7 @@ type Foo = { rank: 'field', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2010,7 +2016,7 @@ type Foo = { rank: 'field', }, line: 11, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2019,7 +2025,7 @@ type Foo = { rank: 'field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2028,7 +2034,7 @@ type Foo = { rank: 'field', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2037,7 +2043,7 @@ type Foo = { rank: 'field', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2046,7 +2052,7 @@ type Foo = { rank: 'field', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2055,7 +2061,7 @@ type Foo = { rank: 'field', }, line: 16, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2064,7 +2070,7 @@ type Foo = { rank: 'field', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -2072,22 +2078,22 @@ type Foo = { code: ` // no accessibility === public type Foo = { - [Z: string]: any; - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); -} - `, + [Z: string]: any; + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); +}; + `, options: [ { typeLiterals: ['method', 'constructor', 'signature', 'field'] }, ], @@ -2099,7 +2105,7 @@ type Foo = { rank: 'signature', }, line: 11, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2108,7 +2114,7 @@ type Foo = { rank: 'signature', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2117,7 +2123,7 @@ type Foo = { rank: 'signature', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2126,7 +2132,7 @@ type Foo = { rank: 'signature', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2135,7 +2141,7 @@ type Foo = { rank: 'signature', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2144,7 +2150,7 @@ type Foo = { rank: 'signature', }, line: 16, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2153,7 +2159,7 @@ type Foo = { rank: 'signature', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -2161,22 +2167,22 @@ type Foo = { code: ` // no accessibility === public type Foo = { - A: string; - B: string; - C: string; - D: string; - E: string; - F: string; - G(); - H(); - I(); - J(); - K(); - L(); - new(); - [Z: string]: any; -} - `, + A: string; + B: string; + C: string; + D: string; + E: string; + F: string; + G(); + H(); + I(); + J(); + K(); + L(); + new (); + [Z: string]: any; +}; + `, options: [ { default: ['field', 'method', 'constructor', 'signature'], @@ -2191,7 +2197,7 @@ type Foo = { rank: 'field', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2200,7 +2206,7 @@ type Foo = { rank: 'field', }, line: 11, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2209,7 +2215,7 @@ type Foo = { rank: 'field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2218,7 +2224,7 @@ type Foo = { rank: 'field', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2227,7 +2233,7 @@ type Foo = { rank: 'field', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2236,7 +2242,7 @@ type Foo = { rank: 'field', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2245,7 +2251,7 @@ type Foo = { rank: 'field', }, line: 16, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2254,7 +2260,7 @@ type Foo = { rank: 'field', }, line: 17, - column: 5, + column: 3, }, ], }, @@ -2262,22 +2268,22 @@ type Foo = { code: ` // no accessibility === public type Foo = { - new(); - [Z: string]: any; - A: string; - G(); - B: string; - H(); - C: string; - I(); - D: string; - J(); - E: string; - K(); - F: string; - L(); -} - `, + new (); + [Z: string]: any; + A: string; + G(); + B: string; + H(); + C: string; + I(); + D: string; + J(); + E: string; + K(); + F: string; + L(); +}; + `, options: [ { typeLiterals: ['constructor', 'signature', 'field', 'method'], @@ -2291,7 +2297,7 @@ type Foo = { rank: 'method', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2300,7 +2306,7 @@ type Foo = { rank: 'method', }, line: 10, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2309,7 +2315,7 @@ type Foo = { rank: 'method', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2318,7 +2324,7 @@ type Foo = { rank: 'method', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2327,29 +2333,29 @@ type Foo = { rank: 'method', }, line: 16, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - [Z: string]: any; - public static A: string = ""; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public J() {} - protected K() {} - private L() {} - public static G() {} - protected static H() {} - private static I() {} + [Z: string]: any; + public static A: string = ''; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public J() {} + protected K() {} + private L() {} + public static G() {} + protected static H() {} + private static I() {} } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -2358,7 +2364,7 @@ class Foo { rank: 'public instance method', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2367,7 +2373,7 @@ class Foo { rank: 'public instance method', }, line: 15, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2376,29 +2382,29 @@ class Foo { rank: 'public instance method', }, line: 16, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - constructor() {} - public static A: string = ""; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - public J() {} - protected K() {} - private L() {} - public static G() {} - protected static H() {} - private static I() {} - [Z: string]: any; + constructor() {} + public static A: string = ''; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + public J() {} + protected K() {} + private L() {} + public static G() {} + protected static H() {} + private static I() {} + [Z: string]: any; } - `, + `, options: [{ default: ['field', 'constructor', 'method', 'signature'] }], errors: [ { @@ -2408,7 +2414,7 @@ class Foo { rank: 'constructor', }, line: 4, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2417,7 +2423,7 @@ class Foo { rank: 'constructor', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2426,7 +2432,7 @@ class Foo { rank: 'constructor', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2435,7 +2441,7 @@ class Foo { rank: 'constructor', }, line: 7, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2444,7 +2450,7 @@ class Foo { rank: 'constructor', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2453,28 +2459,28 @@ class Foo { rank: 'constructor', }, line: 9, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - constructor() {} - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - public static G() {} - public static A: string; - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} + constructor() {} + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + public static G() {} + public static A: string; + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} } - `, + `, options: [{ default: ['field', 'method'] }], errors: [ { @@ -2484,28 +2490,28 @@ class Foo { rank: 'method', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - public static A: string; - public static G() {} - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + public static A: string; + public static G() {} + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} } - `, + `, options: [{ default: ['method', 'field'] }], errors: [ { @@ -2515,28 +2521,28 @@ class Foo { rank: 'field', }, line: 9, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - public static G() {} - protected static H() {} - protected static B: string = ""; - private static I() {} - public J() {} - protected K() {} - private L() {} - public static A: string; - constructor() {} - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; + public static G() {} + protected static H() {} + protected static B: string = ''; + private static I() {} + public J() {} + protected K() {} + private L() {} + public static A: string; + constructor() {} + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; } - `, + `, options: [{ classes: ['method', 'constructor', 'field'] }], errors: [ { @@ -2546,7 +2552,7 @@ class Foo { rank: 'field', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2555,7 +2561,7 @@ class Foo { rank: 'field', }, line: 7, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2564,7 +2570,7 @@ class Foo { rank: 'field', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2573,7 +2579,7 @@ class Foo { rank: 'field', }, line: 9, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2582,28 +2588,28 @@ class Foo { rank: 'field', }, line: 11, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - public static A: string; - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - constructor() {} - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; + public static A: string; + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + constructor() {} + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; } - `, + `, options: [ { default: ['field', 'constructor', 'method'], @@ -2618,7 +2624,7 @@ class Foo { rank: 'field', }, line: 4, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2627,7 +2633,7 @@ class Foo { rank: 'field', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2636,7 +2642,7 @@ class Foo { rank: 'field', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2645,7 +2651,7 @@ class Foo { rank: 'field', }, line: 7, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2654,7 +2660,7 @@ class Foo { rank: 'field', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2663,7 +2669,7 @@ class Foo { rank: 'field', }, line: 9, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2672,30 +2678,30 @@ class Foo { rank: 'field', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - private L() {} - public J() {} - public static G() {} - protected static H() {} - private static I() {} - protected K() {} - constructor() {} - public D: string = ""; - private static C: string = ""; - public static A: string; - private static C: string = ""; - protected static B: string = ""; - private F: string = ""; - protected static B: string = ""; - protected E: string = ""; + private L() {} + public J() {} + public static G() {} + protected static H() {} + private static I() {} + protected K() {} + constructor() {} + public D: string = ''; + private static C: string = ''; + public static A: string; + private static C: string = ''; + protected static B: string = ''; + private F: string = ''; + protected static B: string = ''; + protected E: string = ''; } - `, + `, options: [ { classes: [ @@ -2715,7 +2721,7 @@ class Foo { rank: 'private field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2724,28 +2730,28 @@ class Foo { rank: 'protected field', }, line: 15, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - public static G() {} - private static I() {} - public J() {} - protected static H() {} - private L() {} - protected K() {} - public D: string = ""; - constructor() {} - public static A: string; - protected static B: string = ""; - protected E: string = ""; - private static C: string = ""; - private F: string = ""; + public static G() {} + private static I() {} + public J() {} + protected static H() {} + private L() {} + protected K() {} + public D: string = ''; + constructor() {} + public static A: string; + protected static B: string = ''; + protected E: string = ''; + private static C: string = ''; + private F: string = ''; } - `, + `, options: [ { classes: [ @@ -2768,7 +2774,7 @@ class Foo { rank: 'public instance method', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2777,28 +2783,28 @@ class Foo { rank: 'public field', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - public J() {} - public static G() {} - public D: string = ""; - public static A: string = ""; - private L() {} - constructor() {} - protected K() {} - protected static H() {} - private static I() {} - protected static B: string = ""; - private static C: string = ""; - protected E: string = ""; - private F: string = ""; + public J() {} + public static G() {} + public D: string = ''; + public static A: string = ''; + private L() {} + constructor() {} + protected K() {} + protected static H() {} + private static I() {} + protected static B: string = ''; + private static C: string = ''; + protected E: string = ''; + private F: string = ''; } - `, + `, options: [ { default: [ @@ -2818,28 +2824,28 @@ class Foo { rank: 'method', }, line: 8, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - public J() {} - private static I() {} - public static G() {} - protected static H() {} - protected K() {} - private L() {} - constructor() {} - public static A: string; - private F: string = ""; - protected static B: string = ""; - public D: string = ""; - private static C: string = ""; - protected E: string = ""; + public J() {} + private static I() {} + public static G() {} + protected static H() {} + protected K() {} + private L() {} + constructor() {} + public static A: string; + private F: string = ''; + protected static B: string = ''; + public D: string = ''; + private static C: string = ''; + protected E: string = ''; } - `, + `, options: [ { classes: [ @@ -2861,7 +2867,7 @@ class Foo { rank: 'private static method', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2870,28 +2876,28 @@ class Foo { rank: 'private static method', }, line: 6, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - private static I() {} - protected static H() {} - protected static B: string = ""; - public static G() {} - public J() {} - protected K() {} - private static C: string = ""; - private L() {} - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} + private static I() {} + protected static H() {} + protected static B: string = ''; + public static G() {} + public J() {} + protected K() {} + private static C: string = ''; + private L() {} + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} } - `, + `, options: [ { classes: ['private-instance-method', 'protected-static-field'], @@ -2905,29 +2911,28 @@ class Foo { rank: 'protected static field', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - private L() {} - private static I() {} - protected static H() {} - public static G() {} - protected static B: string = ""; - public J() {} - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - + private L() {} + private static I() {} + protected static H() {} + public static G() {} + protected static B: string = ''; + public J() {} + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} } - `, + `, options: [ { default: ['public-instance-method', 'protected-static-field'], @@ -2941,28 +2946,28 @@ class Foo { rank: 'protected static field', }, line: 8, - column: 5, + column: 3, }, ], }, { code: ` const foo = class Foo { - public static A: string = ""; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} - public J() {} - protected K() {} - private L() {} - public static G() {} - protected static H() {} - private static I() {} -} - `, + public static A: string = ''; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} + public J() {} + protected K() {} + private L() {} + public static G() {} + protected static H() {} + private static I() {} +}; + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -2971,7 +2976,7 @@ const foo = class Foo { rank: 'public instance method', }, line: 13, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2980,7 +2985,7 @@ const foo = class Foo { rank: 'public instance method', }, line: 14, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -2989,29 +2994,29 @@ const foo = class Foo { rank: 'public instance method', }, line: 15, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - [Z: string]: any; - constructor() {} - public static A: string = ""; - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - public J() {} - protected K() {} - private L() {} - public static G() {} - protected static H() {} - private static I() {} -} - `, + [Z: string]: any; + constructor() {} + public static A: string = ''; + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + public J() {} + protected K() {} + private L() {} + public static G() {} + protected static H() {} + private static I() {} +}; + `, options: [{ default: ['signature', 'field', 'constructor', 'method'] }], errors: [ { @@ -3021,7 +3026,7 @@ const foo = class { rank: 'constructor', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3030,7 +3035,7 @@ const foo = class { rank: 'constructor', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3039,7 +3044,7 @@ const foo = class { rank: 'constructor', }, line: 7, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3048,7 +3053,7 @@ const foo = class { rank: 'constructor', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3057,7 +3062,7 @@ const foo = class { rank: 'constructor', }, line: 9, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3066,29 +3071,29 @@ const foo = class { rank: 'constructor', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - constructor() {} - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - [Z: string]: any; - public static G() {} - public static A: string; - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} -} - `, + constructor() {} + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + [Z: string]: any; + public static G() {} + public static A: string; + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} +}; + `, options: [{ default: ['field', 'method'] }], errors: [ { @@ -3098,28 +3103,28 @@ const foo = class { rank: 'method', }, line: 11, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - public static A: string; - public static G() {} - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; - constructor() {} -} - `, + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + public static A: string; + public static G() {} + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; + constructor() {} +}; + `, options: [{ default: ['method', 'field'] }], errors: [ { @@ -3129,29 +3134,29 @@ const foo = class { rank: 'field', }, line: 9, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - public static G() {} - protected static H() {} - protected static B: string = ""; - private static I() {} - public J() {} - protected K() {} - private L() {} - public static A: string; - constructor() {} - [Z: string]: any; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; -} - `, + public static G() {} + protected static H() {} + protected static B: string = ''; + private static I() {} + public J() {} + protected K() {} + private L() {} + public static A: string; + constructor() {} + [Z: string]: any; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; +}; + `, options: [{ classExpressions: ['method', 'constructor', 'field'] }], errors: [ { @@ -3161,7 +3166,7 @@ const foo = class { rank: 'field', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3170,7 +3175,7 @@ const foo = class { rank: 'field', }, line: 7, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3179,7 +3184,7 @@ const foo = class { rank: 'field', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3188,7 +3193,7 @@ const foo = class { rank: 'field', }, line: 9, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3197,28 +3202,28 @@ const foo = class { rank: 'field', }, line: 11, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - public static A: string; - public static G() {} - protected static H() {} - private static I() {} - public J() {} - protected K() {} - private L() {} - constructor() {} - protected static B: string = ""; - private static C: string = ""; - public D: string = ""; - protected E: string = ""; - private F: string = ""; -} - `, + public static A: string; + public static G() {} + protected static H() {} + private static I() {} + public J() {} + protected K() {} + private L() {} + constructor() {} + protected static B: string = ''; + private static C: string = ''; + public D: string = ''; + protected E: string = ''; + private F: string = ''; +}; + `, options: [ { default: ['field', 'constructor', 'method'], @@ -3233,7 +3238,7 @@ const foo = class { rank: 'field', }, line: 4, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3242,7 +3247,7 @@ const foo = class { rank: 'field', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3251,7 +3256,7 @@ const foo = class { rank: 'field', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3260,7 +3265,7 @@ const foo = class { rank: 'field', }, line: 7, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3269,7 +3274,7 @@ const foo = class { rank: 'field', }, line: 8, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3278,7 +3283,7 @@ const foo = class { rank: 'field', }, line: 9, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3287,30 +3292,30 @@ const foo = class { rank: 'field', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - private L() {} - public J() {} - public static G() {} - protected static H() {} - private static I() {} - protected K() {} - constructor() {} - public D: string = ""; - private static C: string = ""; - public static A: string; - private static C: string = ""; - protected static B: string = ""; - private F: string = ""; - protected static B: string = ""; - protected E: string = ""; -} - `, + private L() {} + public J() {} + public static G() {} + protected static H() {} + private static I() {} + protected K() {} + constructor() {} + public D: string = ''; + private static C: string = ''; + public static A: string; + private static C: string = ''; + protected static B: string = ''; + private F: string = ''; + protected static B: string = ''; + protected E: string = ''; +}; + `, options: [ { classExpressions: [ @@ -3330,7 +3335,7 @@ const foo = class { rank: 'private field', }, line: 12, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3339,28 +3344,28 @@ const foo = class { rank: 'protected field', }, line: 15, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - public static G() {} - private static I() {} - public J() {} - protected static H() {} - private L() {} - protected K() {} - public D: string = ""; - constructor() {} - public static A: string; - protected static B: string = ""; - protected E: string = ""; - private static C: string = ""; - private F: string = ""; -} - `, + public static G() {} + private static I() {} + public J() {} + protected static H() {} + private L() {} + protected K() {} + public D: string = ''; + constructor() {} + public static A: string; + protected static B: string = ''; + protected E: string = ''; + private static C: string = ''; + private F: string = ''; +}; + `, options: [ { classExpressions: [ @@ -3383,7 +3388,7 @@ const foo = class { rank: 'public instance method', }, line: 6, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3392,28 +3397,28 @@ const foo = class { rank: 'public field', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - public J() {} - public static G() {} - public D: string = ""; - public static A: string = ""; - private L() {} - constructor() {} - protected K() {} - protected static H() {} - private static I() {} - protected static B: string = ""; - private static C: string = ""; - protected E: string = ""; - private F: string = ""; -} - `, + public J() {} + public static G() {} + public D: string = ''; + public static A: string = ''; + private L() {} + constructor() {} + protected K() {} + protected static H() {} + private static I() {} + protected static B: string = ''; + private static C: string = ''; + protected E: string = ''; + private F: string = ''; +}; + `, options: [ { default: [ @@ -3433,28 +3438,28 @@ const foo = class { rank: 'method', }, line: 8, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - public J() {} - private static I() {} - public static G() {} - protected static H() {} - protected K() {} - private L() {} - constructor() {} - public static A: string; - private F: string = ""; - protected static B: string = ""; - public D: string = ""; - private static C: string = ""; - protected E: string = ""; -} - `, + public J() {} + private static I() {} + public static G() {} + protected static H() {} + protected K() {} + private L() {} + constructor() {} + public static A: string; + private F: string = ''; + protected static B: string = ''; + public D: string = ''; + private static C: string = ''; + protected E: string = ''; +}; + `, options: [ { classExpressions: [ @@ -3476,7 +3481,7 @@ const foo = class { rank: 'private static method', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3485,29 +3490,28 @@ const foo = class { rank: 'private static method', }, line: 6, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - private static I() {} - protected static H() {} - protected static B: string = ""; - public static G() {} - public J() {} - protected K() {} - private static C: string = ""; - private L() {} - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - -} - `, + private static I() {} + protected static H() {} + protected static B: string = ''; + public static G() {} + public J() {} + protected K() {} + private static C: string = ''; + private L() {} + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} +}; + `, options: [ { classExpressions: [ @@ -3524,29 +3528,28 @@ const foo = class { rank: 'protected static field', }, line: 10, - column: 5, + column: 3, }, ], }, { code: ` const foo = class { - private L() {} - private static I() {} - protected static H() {} - public static G() {} - protected static B: string = ""; - public J() {} - protected K() {} - private static C: string = ""; - private F: string = ""; - protected E: string = ""; - public static A: string; - public D: string = ""; - constructor() {} - -} - `, + private L() {} + private static I() {} + protected static H() {} + public static G() {} + protected static B: string = ''; + public J() {} + protected K() {} + private static C: string = ''; + private F: string = ''; + protected E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} +}; + `, options: [ { default: ['public-instance-method', 'protected-static-field'], @@ -3560,20 +3563,20 @@ const foo = class { rank: 'protected static field', }, line: 8, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - K = () => {} - A: string; - constructor () {} - [Z: string]: any; - J() {} + K = () => {}; + A: string; + constructor() {} + [Z: string]: any; + J() {} } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -3582,7 +3585,7 @@ class Foo { rank: 'public instance method', }, line: 4, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3591,7 +3594,7 @@ class Foo { rank: 'public instance method', }, line: 5, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3600,20 +3603,20 @@ class Foo { rank: 'public instance method', }, line: 6, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - J() {} - constructor () {} - K = () => {} - A: string; - [Z: string]: any; + J() {} + constructor() {} + K = () => {}; + A: string; + [Z: string]: any; } - `, + `, options: [{ default: ['method', 'constructor', 'field', 'signature'] }], errors: [ { @@ -3623,20 +3626,20 @@ class Foo { rank: 'constructor', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - J() {} - constructor () {} - K = () => {} - L: () => {} - A: string; + J() {} + constructor() {} + K = () => {}; + L: () => {}; + A: string; } - `, + `, options: [{ default: ['method', 'constructor', 'field'] }], errors: [ { @@ -3646,18 +3649,18 @@ class Foo { rank: 'constructor', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` interface Foo { - K: () => {} - J(); - A: string; + K: () => {}; + J(); + A: string; } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -3666,18 +3669,18 @@ interface Foo { rank: 'method', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` type Foo = { - K: () => {} - J(); - A: string; -} - `, + K: () => {}; + J(); + A: string; +}; + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -3686,18 +3689,18 @@ type Foo = { rank: 'method', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` type Foo = { - A: string; - K: () => {} - J(); -} - `, + A: string; + K: () => {}; + J(); +}; + `, options: [{ default: ['method', 'constructor', 'field'] }], errors: [ { @@ -3707,17 +3710,17 @@ type Foo = { rank: 'field', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` abstract class Foo { - abstract A(): void; - B: string; + abstract A(): void; + B: string; } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -3726,17 +3729,17 @@ abstract class Foo { rank: 'public abstract method', }, line: 4, - column: 5, + column: 3, }, ], }, { code: ` abstract class Foo { - abstract A: () => {}; - B: string; + abstract A: () => {}; + B: string; } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -3745,20 +3748,20 @@ abstract class Foo { rank: 'public abstract field', }, line: 4, - column: 5, + column: 3, }, ], }, { code: ` abstract class Foo { - abstract A: () => {}; - B: string; - public C() {}; - private D() {}; - abstract E() {}; + abstract A: () => {}; + B: string; + public C() {} + private D() {} + abstract E() {} } - `, + `, errors: [ { messageId: 'incorrectGroupOrder', @@ -3767,19 +3770,19 @@ abstract class Foo { rank: 'public abstract field', }, line: 4, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - C: number; - [A:string]: number; - public static D(): {}; - private static [B:string]: number; + C: number; + [A: string]: number; + public static D(): {}; + private static [B: string]: number; } - `, + `, options: [ { default: [ @@ -3799,18 +3802,18 @@ class Foo { rank: 'signature', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` abstract class Foo { - abstract B: string; - abstract A(): void; - public C(): {}; + abstract B: string; + abstract A(): void; + public C(): {}; } - `, + `, options: [{ default: ['method', 'constructor', 'field'] }], errors: [ { @@ -3820,7 +3823,7 @@ abstract class Foo { rank: 'field', }, line: 4, - column: 5, + column: 3, }, { messageId: 'incorrectGroupOrder', @@ -3829,7 +3832,7 @@ abstract class Foo { rank: 'field', }, line: 5, - column: 5, + column: 3, }, ], }, @@ -3837,13 +3840,14 @@ abstract class Foo { code: ` // no accessibility === public class Foo { - B: string; - @Dec() A: string = ""; - C: string = ""; - constructor() {} - D() {} - E() {} -} `, + B: string; + @Dec() A: string = ''; + C: string = ''; + constructor() {} + D() {} + E() {} +} + `, options: [{ default: ['decorated-field', 'field'] }], errors: [ { @@ -3853,18 +3857,19 @@ class Foo { rank: 'field', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - A() {} + A() {} - @Decorator() - B() {} -} `, + @Decorator() + B() {} +} + `, options: [{ default: ['decorated-method', 'method'] }], errors: [ { @@ -3874,16 +3879,17 @@ class Foo { rank: 'method', }, line: 5, // Symbol starts at the line with decorator - column: 5, + column: 3, }, ], }, { code: ` class Foo { - @Decorator() C() {} - A() {} -} `, + @Decorator() C() {} + A() {} +} + `, options: [{ default: ['public-method', 'decorated-method'] }], errors: [ { @@ -3893,19 +3899,20 @@ class Foo { rank: 'decorated method', }, line: 4, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - A(): void; - B(): void; - private C() {} - constructor() {} - @Dec() private D() {} -} `, + A(): void; + B(): void; + private C() {} + constructor() {} + @Dec() private D() {} +} + `, options: [ { classes: ['public-method', 'decorated-method', 'private-method'], @@ -3919,21 +3926,22 @@ class Foo { rank: 'private method', }, line: 7, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - A: string; - get B() {} - constructor() {} - set B() {} - get C() {} - set C() {} - D(): void; -} `, + A: string; + get B() {} + constructor() {} + set B() {} + get C() {} + set C() {} + D(): void; +} + `, options: [ { default: ['field', 'constructor', ['get', 'set'], 'method'], @@ -3947,20 +3955,21 @@ class Foo { rank: 'get, set', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - A: string; - private C(): void; - constructor() {} - @Dec() private B: string; - set D() {} - E(): void; -} `, + A: string; + private C(): void; + constructor() {} + @Dec() private B: string; + set D() {} + E(): void; +} + `, options: [ { default: [ @@ -3979,21 +3988,22 @@ class Foo { rank: 'private decorated field, public set, private method', }, line: 5, - column: 5, + column: 3, }, ], }, { code: ` class Foo { - A: string; - constructor() {} - get B() {} - set B() {} - get C() {} - set C() {} - D(): void; -} `, + A: string; + constructor() {} + get B() {} + set B() {} + get C() {} + set C() {} + D(): void; +} + `, options: [ { default: ['field', 'constructor', 'get', ['set'], 'method'], @@ -4007,7 +4017,7 @@ class Foo { rank: 'set', }, line: 7, - column: 5, + column: 3, }, ], }, @@ -4018,7 +4028,7 @@ class Foo { m() {} f = 1; } - `, + `, options: [{ default: ['method', 'field', 'static-initialization'] }], errors: [ { @@ -4048,7 +4058,7 @@ class Foo { f = 1; static {} } - `, + `, options: [{ default: ['static-initialization', 'method', 'field'] }], errors: [ { @@ -4069,7 +4079,7 @@ class Foo { static {} m() {} } - `, + `, options: [{ default: ['static-initialization', 'field', 'method'] }], errors: [ { @@ -4090,7 +4100,7 @@ class Foo { f = 1; m() {} } - `, + `, options: [{ default: ['field', 'static-initialization', 'method'] }], errors: [ { @@ -4113,7 +4123,7 @@ class Foo { @dec md() {} } - `, + `, options: [ { default: ['decorated-method', 'static-initialization', 'method'] }, ], diff --git a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts index 3eecfc999c9..07db08e0e86 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts @@ -1,23 +1,22 @@ -import type { TSESLint } from '@typescript-eslint/utils'; - import type { MessageIds, Options } from '../../../src/rules/member-ordering'; import rule, { defaultOrder } from '../../../src/rules/member-ordering'; +import type { RunTests } from '../../RuleTester'; import { RuleTester } from '../../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); -const sortedCiWithoutGrouping: TSESLint.RunTests = { +const sortedCiWithoutGrouping: RunTests = { valid: [ // default option + interface + lower/upper case { code: ` interface Foo { - a : b; - B : b; + a: b; + B: b; } - `, + `, options: [ { default: { @@ -32,10 +31,10 @@ interface Foo { { code: ` type Foo = { - a : b; - B : b; -} - `, + a: b; + B: b; +}; + `, options: [ { default: { @@ -50,10 +49,10 @@ type Foo = { { code: ` class Foo { - public static a : string; - public static B : string; + public static a: string; + public static B: string; } - `, + `, options: [ { default: { @@ -68,10 +67,10 @@ class Foo { { code: ` const foo = class Foo { - public static a : string; - public static B : string; -} - `, + public static a: string; + public static B: string; +}; + `, options: [ { default: { @@ -86,11 +85,11 @@ const foo = class Foo { { code: ` class Foo { - public static a : string; - @Dec() static B : string; - public static c : string; + public static a: string; + @Dec() static B: string; + public static c: string; } - `, + `, options: [ { default: { @@ -106,11 +105,11 @@ class Foo { { code: ` interface Foo { - c : string; - B : string; - a : string; + c: string; + B: string; + a: string; } - `, + `, options: [ { default: { @@ -141,10 +140,10 @@ interface Foo { { code: ` interface Foo { - B : b; - a : b; + B: b; + a: b; } - `, + `, options: [ { default: { @@ -168,10 +167,10 @@ interface Foo { { code: ` type Foo = { - B : b; - a : b; -} - `, + B: b; + a: b; +}; + `, options: [ { default: { @@ -195,10 +194,10 @@ type Foo = { { code: ` class Foo { - public static B : string; - public static a : string; + public static B: string; + public static a: string; } - `, + `, options: [ { default: { @@ -222,10 +221,10 @@ class Foo { { code: ` const foo = class Foo { - public static B : string; - public static a : string; -} - `, + public static B: string; + public static a: string; +}; + `, options: [ { default: { @@ -247,27 +246,27 @@ const foo = class Foo { ], }; -const sortedCiWithGrouping: TSESLint.RunTests = { +const sortedCiWithGrouping: RunTests = { valid: [ // default option + interface + default order + alphabetically { code: ` interface Foo { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - a : x; - B : x; - c : x; + a: x; + B: x; + c: x; - new () : Bar; + new (): Bar; - a() : void; - B() : void; - c() : void; + a(): void; + B(): void; + c(): void; } - `, + `, options: [ { default: { @@ -282,20 +281,20 @@ interface Foo { { code: ` interface Foo { - new () : Bar; + new (): Bar; - a() : void; - B() : void; - c() : void; + a(): void; + B(): void; + c(): void; - a : x; - B : x; - c : x; + a: x; + B: x; + c: x; - [a: string] : number; - () : Baz; + [a: string]: number; + (): Baz; } - `, + `, options: [ { default: { @@ -310,21 +309,21 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - a : x; - B : x; - c : x; + a: x; + B: x; + c: x; - new () : Bar; + new (): Bar; - a() : void; - B() : void; - c() : void; -} - `, + a(): void; + B(): void; + c(): void; +}; + `, options: [ { default: { @@ -339,21 +338,21 @@ type Foo = { { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - new () : Bar; + new (): Bar; - a() : void; - B() : void; - c() : void; + a(): void; + B(): void; + c(): void; - a : x; - B : x; - c : x; + a: x; + B: x; + c: x; - () : Baz; -} - `, + (): Baz; +}; + `, options: [ { default: { @@ -369,16 +368,16 @@ type Foo = { code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected E: string = ""; - private f: string = ""; + public d: string = ''; + protected E: string = ''; + private f: string = ''; constructor() {} } - `, + `, options: [ { default: { @@ -393,20 +392,20 @@ class Foo { code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; @Dec() public d: string; @Dec() protected E: string; @Dec() private f: string; - public g: string = ""; - protected h: string = ""; - private i: string = ""; + public g: string = ''; + protected h: string = ''; + private i: string = ''; constructor() {} } - `, + `, options: [ { default: { @@ -423,15 +422,15 @@ class Foo { class Foo { constructor() {} - public d: string = ""; - protected E: string = ""; - private f: string = ""; + public d: string = ''; + protected E: string = ''; + private f: string = ''; public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; } - `, + `, options: [ { default: { @@ -447,16 +446,16 @@ class Foo { code: ` const foo = class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected E: string = ""; - private f: string = ""; + public d: string = ''; + protected E: string = ''; + private f: string = ''; constructor() {} -} - `, +}; + `, options: [ { default: { @@ -473,15 +472,15 @@ const foo = class Foo { const foo = class Foo { constructor() {} - public d: string = ""; - protected E: string = ""; - private f: string = ""; + public d: string = ''; + protected E: string = ''; + private f: string = ''; public static a: string; - protected static b: string = ""; - private static c: string = ""; -} - `, + protected static b: string = ''; + private static c: string = ''; +}; + `, options: [ { default: { @@ -499,7 +498,7 @@ class Foo { static {} static {} } - `, + `, options: [ { default: { @@ -515,21 +514,21 @@ class Foo { { code: ` interface Foo { - [a: string] : number; + [a: string]: number; - a : x; - B : x; - c : x; + a: x; + B: x; + c: x; - c() : void; - B() : void; - a() : void; + c(): void; + B(): void; + a(): void; - () : Baz; + (): Baz; - new () : Bar; + new (): Bar; } - `, + `, options: [ { default: { @@ -560,21 +559,21 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - a : x; - B : x; - c : x; + a: x; + B: x; + c: x; - c() : void; - B() : void; - a() : void; + c(): void; + B(): void; + a(): void; - () : Baz; + (): Baz; - new () : Bar; -} - `, + new (): Bar; +}; + `, options: [ { default: { @@ -605,15 +604,15 @@ type Foo = { { code: ` class Foo { - public static c: string = ""; - public static B: string = ""; + public static c: string = ''; + public static B: string = ''; public static a: string; constructor() {} - public d: string = ""; + public d: string = ''; } - `, + `, options: [ { default: { @@ -637,15 +636,15 @@ class Foo { { code: ` const foo = class Foo { - public static c: string = ""; - public static B: string = ""; + public static c: string = ''; + public static B: string = ''; public static a: string; constructor() {} - public d: string = ""; -} - `, + public d: string = ''; +}; + `, options: [ { default: { diff --git a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts index afa1a5df810..b7b5da85910 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts @@ -1,16 +1,12 @@ -import type { TSESLint } from '@typescript-eslint/utils'; - import type { MessageIds, Options } from '../../../src/rules/member-ordering'; import rule, { defaultOrder } from '../../../src/rules/member-ordering'; +import type { RunTests } from '../../RuleTester'; import { RuleTester } from '../../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); -const sortedWithoutGroupingDefaultOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithoutGroupingDefaultOption: RunTests = { valid: [ // default option + interface + multiple types { @@ -20,7 +16,7 @@ interface Foo { a(): Foo; b(): Foo; } - `, + `, options: [ { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, ], @@ -30,10 +26,10 @@ interface Foo { { code: ` interface Foo { - A : b; - a : b; + A: b; + a: b; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -41,10 +37,10 @@ interface Foo { { code: ` interface Foo { - a1 : b; - aa : b; + a1: b; + aa: b; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -52,11 +48,11 @@ interface Foo { { code: ` interface Foo { - a : Foo; - 'b.c' : Foo; - "b.d" : Foo; + a: Foo; + 'b.c': Foo; + 'b.d': Foo; } - `, + `, options: [{ default: { order: 'alphabetically' } }], }, @@ -64,13 +60,13 @@ interface Foo { { code: ` type Foo = { - a : b; - [a: string] : number; - b() : void; - () : Baz; - new () : Bar; -} - `, + a: b; + [a: string]: number; + b(): void; + (): Baz; + new (): Bar; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -78,10 +74,10 @@ type Foo = { { code: ` type Foo = { - A : b; - a : b; -} - `, + A: b; + a: b; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -89,10 +85,10 @@ type Foo = { { code: ` type Foo = { - a1 : b; - aa : b; -} - `, + a1: b; + aa: b; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -100,11 +96,11 @@ type Foo = { { code: ` type Foo = { - a : Foo; - 'b.c' : Foo; - "b.d" : Foo; -} - `, + a: Foo; + 'b.c': Foo; + 'b.d': Foo; +}; + `, options: [{ default: { order: 'alphabetically' } }], }, @@ -112,17 +108,17 @@ type Foo = { { code: ` class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; constructor() {} @Dec() d: string; - public e : string = ""; - @Dec() f : string = ""; - protected g : string = ""; - private h : string = ""; + public e: string = ''; + @Dec() f: string = ''; + protected g: string = ''; + private h: string = ''; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -130,10 +126,10 @@ class Foo { { code: ` class Foo { - public static A : string; - public static a : string; + public static A: string; + public static a: string; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -141,10 +137,10 @@ class Foo { { code: ` class Foo { - public static a1 : string; - public static aa : string; + public static a1: string; + public static aa: string; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -152,15 +148,15 @@ class Foo { { code: ` const foo = class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; - private f : string = ""; -} - `, + public d: string = ''; + protected e: string = ''; + private f: string = ''; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -168,10 +164,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static A : string; - public static a : string; -} - `, + public static A: string; + public static a: string; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -179,10 +175,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static a1 : string; - public static aa : string; -} - `, + public static a1: string; + public static aa: string; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -190,11 +186,11 @@ const foo = class Foo { { code: ` class Foo { - public static a : string; - @Dec() static b : string; - public static c : string; + public static a: string; + @Dec() static b: string; + public static c: string; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -217,13 +213,13 @@ class Foo { { code: ` interface Foo { - b() : void; - a : b; - [a: string] : number; - new () : Bar; - () : Baz; + b(): void; + a: b; + [a: string]: number; + new (): Bar; + (): Baz; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -247,11 +243,11 @@ interface Foo { { code: ` interface Foo { - "b.d" : Foo; - 'b.c' : Foo; - a : Foo; + 'b.d': Foo; + 'b.c': Foo; + a: Foo; } - `, + `, options: [{ default: { order: 'alphabetically' } }], errors: [ { @@ -275,11 +271,11 @@ interface Foo { { code: ` interface Foo { - c : string; - b : string; - a : string; + c: string; + b: string; + a: string; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -303,13 +299,13 @@ interface Foo { { code: ` type Foo = { - b() : void; - a : b; - [a: string] : number; - new () : Bar; - () : Baz; -} - `, + b(): void; + a: b; + [a: string]: number; + new (): Bar; + (): Baz; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -333,11 +329,11 @@ type Foo = { { code: ` type Foo = { - "b.d" : Foo; - 'b.c' : Foo; - a : Foo; -} - `, + 'b.d': Foo; + 'b.c': Foo; + a: Foo; +}; + `, options: [{ default: { order: 'alphabetically' } }], errors: [ { @@ -361,11 +357,11 @@ type Foo = { { code: ` type Foo = { - c : string; - b : string; - a : string; -} - `, + c: string; + b: string; + a: string; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -389,15 +385,15 @@ type Foo = { { code: ` class Foo { - protected static b : string = ""; - public static a : string; - private static c : string = ""; + protected static b: string = ''; + public static a: string; + private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -418,7 +414,7 @@ class Foo { public static b: string; public static a: string; } - `, + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -442,15 +438,15 @@ class Foo { { code: ` const foo = class Foo { - protected static b : string = ""; - public static a : string; - private static c : string = ""; + protected static b: string = ''; + public static a: string; + private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; - private f : string = ""; -} - `, + public d: string = ''; + protected e: string = ''; + private f: string = ''; +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -470,8 +466,8 @@ const foo = class Foo { public static c: string; public static b: string; public static a: string; -} - `, +}; + `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -493,22 +489,19 @@ const foo = class Foo { ], }; -const sortedWithoutGroupingClassesOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithoutGroupingClassesOption: RunTests = { valid: [ // classes option + interface + multiple types --> Only member group order is checked (default config) { code: ` interface Foo { - [a: string] : number; - () : Baz; - c : b; - new () : Bar; - b() : void; + [a: string]: number; + (): Baz; + c: b; + new (): Bar; + b(): void; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -516,10 +509,10 @@ interface Foo { { code: ` interface Foo { - a : b; - A : b; + a: b; + A: b; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -527,10 +520,10 @@ interface Foo { { code: ` interface Foo { - aa : b; - a1 : b; + aa: b; + a1: b; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -538,13 +531,13 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; - () : Baz; - c : b; - new () : Bar; - b() : void; -} - `, + [a: string]: number; + (): Baz; + c: b; + new (): Bar; + b(): void; +}; + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -552,10 +545,10 @@ type Foo = { { code: ` type Foo = { - a : b; - A : b; -} - `, + a: b; + A: b; +}; + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -563,10 +556,10 @@ type Foo = { { code: ` type Foo = { - aa : b; - a1 : b; -} - `, + aa: b; + a1: b; +}; + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -574,16 +567,16 @@ type Foo = { { code: ` class Foo { - public static a : string; - protected static b : string = ""; - @Dec() private static c : string = ""; + public static a: string; + protected static b: string = ''; + @Dec() private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; + public d: string = ''; + protected e: string = ''; @Dec() - private f : string = ""; + private f: string = ''; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -591,10 +584,10 @@ class Foo { { code: ` class Foo { - public static A : string; - public static a : string; + public static A: string; + public static a: string; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -602,10 +595,10 @@ class Foo { { code: ` class Foo { - public static a1 : string; - public static aa : string; + public static a1: string; + public static aa: string; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -613,15 +606,15 @@ class Foo { { code: ` const foo = class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} -} - `, +}; + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -629,10 +622,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static a : string; - public static A : string; -} - `, + public static a: string; + public static A: string; +}; + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, @@ -640,10 +633,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static aa : string; - public static a1 : string; -} - `, + public static aa: string; + public static a1: string; +}; + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], }, ], @@ -652,15 +645,15 @@ const foo = class Foo { { code: ` class Foo { - protected static b : string = ""; - public static a : string; - private static c : string = ""; + protected static b: string = ''; + public static a: string; + private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -681,7 +674,7 @@ class Foo { public static b: string; public static a: string; } - `, + `, options: [{ classes: { memberTypes: 'never', order: 'alphabetically' } }], errors: [ { @@ -703,7 +696,7 @@ class Foo { ], }; -const sortedWithoutGroupingClassExpressionsOption: TSESLint.RunTests< +const sortedWithoutGroupingClassExpressionsOption: RunTests< MessageIds, Options > = { @@ -712,13 +705,13 @@ const sortedWithoutGroupingClassExpressionsOption: TSESLint.RunTests< { code: ` interface Foo { - [a: string] : number; - () : Baz; - c : b; - new () : Bar; - b() : void; + [a: string]: number; + (): Baz; + c: b; + new (): Bar; + b(): void; } - `, + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -728,10 +721,10 @@ interface Foo { { code: ` interface Foo { - a : b; - A : b; + a: b; + A: b; } - `, + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -741,10 +734,10 @@ interface Foo { { code: ` interface Foo { - aa : b; - a1 : b; + aa: b; + a1: b; } - `, + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -754,13 +747,13 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; - () : Baz; - c : b; - new () : Bar; - b() : void; -} - `, + [a: string]: number; + (): Baz; + c: b; + new (): Bar; + b(): void; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -770,10 +763,10 @@ type Foo = { { code: ` type Foo = { - a : b; - A : b; -} - `, + a: b; + A: b; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -783,10 +776,10 @@ type Foo = { { code: ` type Foo = { - aa : b; - a1 : b; -} - `, + aa: b; + a1: b; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -796,15 +789,15 @@ type Foo = { { code: ` class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -814,10 +807,10 @@ class Foo { { code: ` class Foo { - public static a : string; - public static A : string; + public static a: string; + public static A: string; } - `, + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -827,10 +820,10 @@ class Foo { { code: ` class Foo { - public static aa : string; - public static a1 : string; + public static aa: string; + public static a1: string; } - `, + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -840,15 +833,15 @@ class Foo { { code: ` const foo = class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; - private f : string = ""; -} - `, + public d: string = ''; + protected e: string = ''; + private f: string = ''; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -858,10 +851,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static A : string; - public static a : string; -} - `, + public static A: string; + public static a: string; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -871,10 +864,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static a1 : string; - public static aa : string; -} - `, + public static a1: string; + public static aa: string; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -885,15 +878,15 @@ const foo = class Foo { { code: ` const foo = class Foo { - protected static b : string = ""; - public static a : string; - private static c : string = ""; + protected static b: string = ''; + public static a: string; + private static c: string = ''; constructor() {} - public d : string = ""; - protected e : string = ""; - private f : string = ""; -} - `, + public d: string = ''; + protected e: string = ''; + private f: string = ''; +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -915,8 +908,8 @@ const foo = class Foo { public static c: string; public static b: string; public static a: string; -} - `, +}; + `, options: [ { classExpressions: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -940,22 +933,19 @@ const foo = class Foo { ], }; -const sortedWithoutGroupingInterfacesOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithoutGroupingInterfacesOption: RunTests = { valid: [ // interfaces option + interface + multiple types { code: ` interface Foo { - [a: string] : number; - a : b; - b() : void; - () : Baz; - new () : Bar; + [a: string]: number; + a: b; + b(): void; + (): Baz; + new (): Bar; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -965,10 +955,10 @@ interface Foo { { code: ` interface Foo { - A : b; - a : b; + A: b; + a: b; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -978,10 +968,10 @@ interface Foo { { code: ` interface Foo { - a1 : b; - aa : b; + a1: b; + aa: b; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -991,13 +981,13 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; - () : Baz; - c : b; - new () : Bar; - b() : void; -} - `, + [a: string]: number; + (): Baz; + c: b; + new (): Bar; + b(): void; +}; + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1007,10 +997,10 @@ type Foo = { { code: ` type Foo = { - a : b; - A : b; -} - `, + a: b; + A: b; +}; + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1020,10 +1010,10 @@ type Foo = { { code: ` type Foo = { - aa : b; - a1 : b; -} - `, + aa: b; + a1: b; +}; + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1033,15 +1023,15 @@ type Foo = { { code: ` class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1051,10 +1041,10 @@ class Foo { { code: ` class Foo { - public static a : string; - public static A : string; + public static a: string; + public static A: string; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1064,10 +1054,10 @@ class Foo { { code: ` class Foo { - public static aa : string; - public static a1 : string; + public static aa: string; + public static a1: string; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1077,15 +1067,15 @@ class Foo { { code: ` const foo = class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} -} - `, +}; + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1095,10 +1085,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static a : string; - public static A : string; -} - `, + public static a: string; + public static A: string; +}; + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1108,10 +1098,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static aa : string; - public static a1 : string; -} - `, + public static aa: string; + public static a1: string; +}; + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1122,13 +1112,13 @@ const foo = class Foo { { code: ` interface Foo { - b() : void; - a : b; - [a: string] : number; - new () : Bar; - () : Baz; + b(): void; + a: b; + [a: string]: number; + new (): Bar; + (): Baz; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1154,11 +1144,11 @@ interface Foo { { code: ` interface Foo { - c : string; - b : string; - a : string; + c: string; + b: string; + a: string; } - `, + `, options: [ { interfaces: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1182,22 +1172,19 @@ interface Foo { ], }; -const sortedWithoutGroupingTypeLiteralsOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithoutGroupingTypeLiteralsOption: RunTests = { valid: [ // typeLiterals option + interface + multiple types --> Only member group order is checked (default config) { code: ` interface Foo { - [a: string] : number; - () : Baz; - c : b; - new () : Bar; - b() : void; + [a: string]: number; + (): Baz; + c: b; + new (): Bar; + b(): void; } - `, + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1207,10 +1194,10 @@ interface Foo { { code: ` interface Foo { - a : b; - A : b; + a: b; + A: b; } - `, + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1220,10 +1207,10 @@ interface Foo { { code: ` interface Foo { - aa : b; - a1 : b; + aa: b; + a1: b; } - `, + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1233,13 +1220,13 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; - a : b; - b() : void; - () : Baz; - new () : Bar; -} - `, + [a: string]: number; + a: b; + b(): void; + (): Baz; + new (): Bar; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1249,10 +1236,10 @@ type Foo = { { code: ` type Foo = { - A : b; - a : b; -} - `, + A: b; + a: b; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1262,10 +1249,10 @@ type Foo = { { code: ` type Foo = { - a1 : b; - aa : b; -} - `, + a1: b; + aa: b; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1275,15 +1262,15 @@ type Foo = { { code: ` class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1293,10 +1280,10 @@ class Foo { { code: ` class Foo { - public static a : string; - public static A : string; + public static a: string; + public static A: string; } - `, + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1306,10 +1293,10 @@ class Foo { { code: ` class Foo { - public static aa : string; - public static a1 : string; + public static aa: string; + public static a1: string; } - `, + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1319,15 +1306,15 @@ class Foo { { code: ` const foo = class Foo { - public static a : string; - protected static b : string = ""; - private static c : string = ""; - public d : string = ""; - protected e : string = ""; - private f : string = ""; + public static a: string; + protected static b: string = ''; + private static c: string = ''; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} -} - `, +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1337,10 +1324,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static a : string; - public static A : string; -} - `, + public static a: string; + public static A: string; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1350,10 +1337,10 @@ const foo = class Foo { { code: ` const foo = class Foo { - public static aa : string; - public static a1 : string; -} - `, + public static aa: string; + public static a1: string; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1364,13 +1351,13 @@ const foo = class Foo { { code: ` type Foo = { - b() : void; - a : b; - [a: string] : number; - new () : Bar; - () : Baz; -} - `, + b(): void; + a: b; + [a: string]: number; + new (): Bar; + (): Baz; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1396,11 +1383,11 @@ type Foo = { { code: ` type Foo = { - c : string; - b : string; - a : string; -} - `, + c: string; + b: string; + a: string; +}; + `, options: [ { typeLiterals: { memberTypes: 'never', order: 'alphabetically' } }, ], @@ -1424,145 +1411,144 @@ type Foo = { ], }; -const sortedWithGroupingDefaultOption: TSESLint.RunTests = - { - valid: [ - // default option + interface + default order + alphabetically - { - code: ` +const sortedWithGroupingDefaultOption: RunTests = { + valid: [ + // default option + interface + default order + alphabetically + { + code: ` interface Foo { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - new () : Bar; + new (): Bar; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; } - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - }, + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + }, - // default option + interface + custom order + alphabetically - { - code: ` + // default option + interface + custom order + alphabetically + { + code: ` interface Foo { - new () : Bar; + new (): Bar; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - [a: string] : number; - () : Baz; + [a: string]: number; + (): Baz; } - `, - options: [ - { - default: { - memberTypes: ['constructor', 'method', 'field'], - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: ['constructor', 'method', 'field'], + order: 'alphabetically', }, - ], - }, + }, + ], + }, - // default option + type literal + default order + alphabetically - { - code: ` + // default option + type literal + default order + alphabetically + { + code: ` type Foo = { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - new () : Bar; + new (): Bar; - a() : void; - b() : void; - c() : void; -} - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - }, + a(): void; + b(): void; + c(): void; +}; + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + }, - // default option + type literal + custom order + alphabetically - { - code: ` + // default option + type literal + custom order + alphabetically + { + code: ` type Foo = { - [a: string] : number; + [a: string]: number; - new () : Bar; + new (): Bar; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - () : Baz; -} - `, - options: [ - { - default: { - memberTypes: ['constructor', 'method', 'field'], - order: 'alphabetically', - }, + (): Baz; +}; + `, + options: [ + { + default: { + memberTypes: ['constructor', 'method', 'field'], + order: 'alphabetically', }, - ], - }, + }, + ], + }, - // default option + class + default order + alphabetically - { - code: ` + // default option + class + default order + alphabetically + { + code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - }, + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + }, - // default option + class + defaultOrder + alphabetically - { - code: ` + // default option + class + defaultOrder + alphabetically + { + code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} @@ -1570,20 +1556,20 @@ class Foo { set g() {} } - `, - options: [ - { - default: { - memberTypes: defaultOrder, - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: defaultOrder, + order: 'alphabetically', }, - ], - }, + }, + ], + }, - // default option + class + custom + alphabetically - { - code: ` + // default option + class + custom + alphabetically + { + code: ` class Foo { get a() {} @@ -1595,141 +1581,141 @@ class Foo { @Bar set d() {} } - `, - options: [ - { - default: { - memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'], - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'], + order: 'alphabetically', }, - ], - }, + }, + ], + }, - // default option + class + decorators + default order + alphabetically - { - code: ` + // default option + class + decorators + default order + alphabetically + { + code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; @Dec() public d: string; @Dec() protected e: string; @Dec() private f: string; - public g: string = ""; - protected h: string = ""; - private i: string = ""; + public g: string = ''; + protected h: string = ''; + private i: string = ''; constructor() {} } - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - }, + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + }, - // default option + class + custom order + alphabetically - { - code: ` + // default option + class + custom order + alphabetically + { + code: ` class Foo { constructor() {} - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; } - `, - options: [ - { - default: { - memberTypes: ['constructor', 'instance-field', 'static-field'], - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: ['constructor', 'instance-field', 'static-field'], + order: 'alphabetically', }, - ], - }, + }, + ], + }, - // default option + class expression + default order + alphabetically - { - code: ` + // default option + class expression + default order + alphabetically + { + code: ` const foo = class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} -} - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - }, +}; + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + }, - // default option + class expression + custom order + alphabetically - { - code: ` + // default option + class expression + custom order + alphabetically + { + code: ` const foo = class Foo { constructor() {} - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; public static a: string; - protected static b: string = ""; - private static c: string = ""; -} - `, - options: [ - { - default: { - memberTypes: ['constructor', 'instance-field', 'static-field'], - order: 'alphabetically', - }, + protected static b: string = ''; + private static c: string = ''; +}; + `, + options: [ + { + default: { + memberTypes: ['constructor', 'instance-field', 'static-field'], + order: 'alphabetically', }, - ], - }, + }, + ], + }, - // default option + static blocks; should always be valid - { - code: ` + // default option + static blocks; should always be valid + { + code: ` class Foo { static {} static {} } - `, - options: [ - { - default: { - memberTypes: 'never', - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: 'never', + order: 'alphabetically', }, - ], - }, - ], - invalid: [ - // default option + class + wrong order within group and wrong group order + alphabetically - { - code: ` + }, + ], + }, + ], + invalid: [ + // default option + class + wrong order within group and wrong group order + alphabetically + { + code: ` class FooTestGetter { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; get h() {} @@ -1737,29 +1723,29 @@ class FooTestGetter { constructor() {} } - `, - options: [ - { - default: { - memberTypes: defaultOrder, - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: defaultOrder, + order: 'alphabetically', }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'constructor', - rank: 'public instance get', - }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'constructor', + rank: 'public instance get', }, - ], - }, + }, + ], + }, - // default option + class + custom + alphabetically - { - code: ` + // default option + class + custom + alphabetically + { + code: ` class Foo { @Bar get a() {} @@ -1771,44 +1757,44 @@ class Foo { set d() {} } - `, - options: [ - { - default: { - memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'], - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'], + order: 'alphabetically', }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'b', - rank: 'decorated get', - }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'b', + rank: 'decorated get', }, - { - messageId: 'incorrectGroupOrder', - data: { - name: 'd', - rank: 'decorated set', - }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'd', + rank: 'decorated set', }, - ], - }, + }, + ], + }, - // default option + class + wrong order within group and wrong group order + alphabetically - { - code: ` + // default option + class + wrong order within group and wrong group order + alphabetically + { + code: ` class FooTestGetter { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; set g() {} @@ -1816,489 +1802,341 @@ class FooTestGetter { get h() {} } - `, - options: [ - { - default: { - memberTypes: defaultOrder, - order: 'alphabetically', - }, + `, + options: [ + { + default: { + memberTypes: defaultOrder, + order: 'alphabetically', }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'constructor', - rank: 'public instance set', - }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'constructor', + rank: 'public instance set', }, - { - messageId: 'incorrectGroupOrder', - data: { - name: 'h', - rank: 'public instance set', - }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'h', + rank: 'public instance set', }, - ], - }, + }, + ], + }, - // default option + interface + wrong order within group and wrong group order + alphabetically - { - code: ` + // default option + interface + wrong order within group and wrong group order + alphabetically + { + code: ` interface Foo { - [a: string] : number; + [a: string]: number; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - c() : void; - b() : void; - a() : void; + c(): void; + b(): void; + a(): void; - () : Baz; + (): Baz; - new () : Bar; + new (): Bar; } - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'call', - rank: 'field', - }, + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'call', + rank: 'field', }, - { - messageId: 'incorrectGroupOrder', - data: { - name: 'new', - rank: 'method', - }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'new', + rank: 'method', }, - ], - }, + }, + ], + }, - // default option + type literal + wrong order within group and wrong group order + alphabetically - { - code: ` + // default option + type literal + wrong order within group and wrong group order + alphabetically + { + code: ` type Foo = { - [a: string] : number; + [a: string]: number; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - c() : void; - b() : void; - a() : void; + c(): void; + b(): void; + a(): void; - () : Baz; + (): Baz; - new () : Bar; -} - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'call', - rank: 'field', - }, - }, - { - messageId: 'incorrectGroupOrder', - data: { - name: 'new', - rank: 'method', - }, - }, - ], - }, - - // default option + class + wrong order within group and wrong group order + alphabetically - { - code: ` -class Foo { - public static c: string = ""; - public static b: string = ""; - public static a: string; - - constructor() {} - - public d: string = ""; -} - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'd', - rank: 'public constructor', - }, - }, - ], - }, - - // default option + class expression + wrong order within group and wrong group order + alphabetically - { - code: ` -const foo = class Foo { - public static c: string = ""; - public static b: string = ""; - public static a: string; - - constructor() {} - - public d: string = ""; -} - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'd', - rank: 'public constructor', - }, - }, - ], - }, - // default option + class + decorators + custom order + wrong order within group and wrong group order + alphabetically - { - code: ` -class Foo { - @Dec() a1: string; - @Dec() - a3: string; - @Dec() - a2: string; - - constructor() {} - - b1: string; - b2: string; - - public c(): void; - @Dec() d(): void -} - `, - options: [ - { - default: { - memberTypes: [ - 'decorated-field', - 'field', - 'constructor', - 'decorated-method', - ], - order: 'alphabetically', - }, - }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'b1', - rank: 'constructor', - }, + new (): Bar; +}; + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'call', + rank: 'field', }, - { - messageId: 'incorrectGroupOrder', - data: { - name: 'b2', - rank: 'constructor', - }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'new', + rank: 'method', }, - ], - }, - ], - }; - -const sortedWithGroupingClassesOption: TSESLint.RunTests = - { - valid: [ - // classes option + interface + alphabetically --> Default order applies - { - code: ` -interface Foo { - [a: string] : number; - - () : Baz; - - c : x; - b : x; - a : x; - - new () : Bar; - - c() : void; - b() : void; - a() : void; -} - `, - options: [{ classes: { order: 'alphabetically' } }], - }, - - // classes option + type literal + alphabetically --> Default order applies - { - code: ` -type Foo = { - [a: string] : number; - - () : Baz; - - c : x; - b : x; - a : x; - - new () : Bar; - - c() : void; - b() : void; - a() : void; -} - `, - options: [{ classes: { order: 'alphabetically' } }], - }, + }, + ], + }, - // classes option + class + default order + alphabetically - { - code: ` + // default option + class + wrong order within group and wrong group order + alphabetically + { + code: ` class Foo { + public static c: string = ''; + public static b: string = ''; public static a: string; - protected static b: string = ""; - private static c: string = ""; - - public d: string = ""; - protected e: string = ""; - private f: string = ""; - - constructor() {} -} - `, - options: [ - { classes: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - }, - - // classes option + class + custom order + alphabetically - { - code: ` -class Foo { - constructor() {} - public d: string = ""; - protected e: string = ""; - private f: string = ""; + constructor() {} - public static a: string; - protected static b: string = ""; - private static c: string = ""; + public d: string = ''; } - `, - options: [ - { - classes: { - memberTypes: ['constructor', 'instance-field', 'static-field'], - order: 'alphabetically', - }, + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'd', + rank: 'public constructor', }, - ], - }, + }, + ], + }, - // classes option + class expression + alphabetically --> Default order applies - { - code: ` + // default option + class expression + wrong order within group and wrong group order + alphabetically + { + code: ` const foo = class Foo { + public static c: string = ''; + public static b: string = ''; public static a: string; - protected static b: string = ""; - private static c: string = ""; - - public d: string = ""; - protected e: string = ""; - private f: string = ""; constructor() {} -} - `, - options: [{ classes: { order: 'alphabetically' } }], - }, - ], - invalid: [ - // default option + class + wrong order within group and wrong group order + alphabetically - { - code: ` + + public d: string = ''; +}; + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'd', + rank: 'public constructor', + }, + }, + ], + }, + // default option + class + decorators + custom order + wrong order within group and wrong group order + alphabetically + { + code: ` class Foo { - public static c: string = ""; - public static b: string = ""; - public static a: string; + @Dec() a1: string; + @Dec() + a3: string; + @Dec() + a2: string; constructor() {} - public d: string = ""; + b1: string; + b2: string; + + public c(): void; + @Dec() d(): void; } - `, - options: [ - { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, - ], - errors: [ - { - messageId: 'incorrectGroupOrder', - data: { - name: 'd', - rank: 'public constructor', - }, + `, + options: [ + { + default: { + memberTypes: [ + 'decorated-field', + 'field', + 'constructor', + 'decorated-method', + ], + order: 'alphabetically', }, - ], - }, - ], - }; + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'b1', + rank: 'constructor', + }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'b2', + rank: 'constructor', + }, + }, + ], + }, + ], +}; -const sortedWithGroupingClassExpressionsOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithGroupingClassesOption: RunTests = { valid: [ - // classExpressions option + interface + alphabetically --> Default order applies + // classes option + interface + alphabetically --> Default order applies { code: ` interface Foo { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - c : x; - b : x; - a : x; + c: x; + b: x; + a: x; - new () : Bar; + new (): Bar; - c() : void; - b() : void; - a() : void; + c(): void; + b(): void; + a(): void; } - `, - options: [{ classExpressions: { order: 'alphabetically' } }], + `, + options: [{ classes: { order: 'alphabetically' } }], }, - // classExpressions option + type literal + alphabetically --> Default order applies + // classes option + type literal + alphabetically --> Default order applies { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - c : x; - b : x; - a : x; + c: x; + b: x; + a: x; - new () : Bar; + new (): Bar; - c() : void; - b() : void; - a() : void; -} - `, - options: [{ classExpressions: { order: 'alphabetically' } }], + c(): void; + b(): void; + a(): void; +}; + `, + options: [{ classes: { order: 'alphabetically' } }], }, - // classExpressions option + class + alphabetically --> Default order applies + // classes option + class + default order + alphabetically { code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, - options: [{ classExpressions: { order: 'alphabetically' } }], + `, + options: [ + { classes: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], }, - // classExpressions option + class expression + default order + alphabetically + // classes option + class + custom order + alphabetically { code: ` -const foo = class Foo { - public static a: string; - protected static b: string = ""; - private static c: string = ""; +class Foo { + constructor() {} - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; - constructor() {} + public static a: string; + protected static b: string = ''; + private static c: string = ''; } - `, + `, options: [ { - classExpressions: { - memberTypes: defaultOrder, + classes: { + memberTypes: ['constructor', 'instance-field', 'static-field'], order: 'alphabetically', }, }, ], }, - // classExpressions option + class expression + custom order + alphabetically + // classes option + class expression + alphabetically --> Default order applies { code: ` const foo = class Foo { - constructor() {} + public static a: string; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; - public static a: string; - protected static b: string = ""; - private static c: string = ""; -} - `, - options: [ - { - classExpressions: { - memberTypes: ['constructor', 'instance-field', 'static-field'], - order: 'alphabetically', - }, - }, - ], + constructor() {} +}; + `, + options: [{ classes: { order: 'alphabetically' } }], }, ], invalid: [ - // default option + class expression + wrong order within group and wrong group order + alphabetically + // default option + class + wrong order within group and wrong group order + alphabetically { code: ` -const foo = class Foo { - public static c: string = ""; - public static b: string = ""; +class Foo { + public static c: string = ''; + public static b: string = ''; public static a: string; constructor() {} - public d: string = ""; + public d: string = ''; } - `, + `, options: [ { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, ], @@ -2315,30 +2153,172 @@ const foo = class Foo { ], }; -const sortedWithGroupingInterfacesOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithGroupingClassExpressionsOption: RunTests = + { + valid: [ + // classExpressions option + interface + alphabetically --> Default order applies + { + code: ` +interface Foo { + [a: string]: number; + + (): Baz; + + c: x; + b: x; + a: x; + + new (): Bar; + + c(): void; + b(): void; + a(): void; +} + `, + options: [{ classExpressions: { order: 'alphabetically' } }], + }, + + // classExpressions option + type literal + alphabetically --> Default order applies + { + code: ` +type Foo = { + [a: string]: number; + + (): Baz; + + c: x; + b: x; + a: x; + + new (): Bar; + + c(): void; + b(): void; + a(): void; +}; + `, + options: [{ classExpressions: { order: 'alphabetically' } }], + }, + + // classExpressions option + class + alphabetically --> Default order applies + { + code: ` +class Foo { + public static a: string; + protected static b: string = ''; + private static c: string = ''; + + public d: string = ''; + protected e: string = ''; + private f: string = ''; + + constructor() {} +} + `, + options: [{ classExpressions: { order: 'alphabetically' } }], + }, + + // classExpressions option + class expression + default order + alphabetically + { + code: ` +const foo = class Foo { + public static a: string; + protected static b: string = ''; + private static c: string = ''; + + public d: string = ''; + protected e: string = ''; + private f: string = ''; + + constructor() {} +}; + `, + options: [ + { + classExpressions: { + memberTypes: defaultOrder, + order: 'alphabetically', + }, + }, + ], + }, + + // classExpressions option + class expression + custom order + alphabetically + { + code: ` +const foo = class Foo { + constructor() {} + + public d: string = ''; + protected e: string = ''; + private f: string = ''; + + public static a: string; + protected static b: string = ''; + private static c: string = ''; +}; + `, + options: [ + { + classExpressions: { + memberTypes: ['constructor', 'instance-field', 'static-field'], + order: 'alphabetically', + }, + }, + ], + }, + ], + invalid: [ + // default option + class expression + wrong order within group and wrong group order + alphabetically + { + code: ` +const foo = class Foo { + public static c: string = ''; + public static b: string = ''; + public static a: string; + + constructor() {} + + public d: string = ''; +}; + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'd', + rank: 'public constructor', + }, + }, + ], + }, + ], + }; + +const sortedWithGroupingInterfacesOption: RunTests = { valid: [ // interfaces option + interface + default order + alphabetically { code: ` interface Foo { - [a: string] : number; + [a: string]: number; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; - new () : Bar; + new (): Bar; - () : Baz; + (): Baz; } - `, + `, options: [ { interfaces: { @@ -2353,20 +2333,20 @@ interface Foo { { code: ` interface Foo { - new () : Bar; + new (): Bar; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - [a: string] : number; - () : Baz; + [a: string]: number; + (): Baz; } - `, + `, options: [ { interfaces: { @@ -2381,21 +2361,21 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - c : x; - b : x; - a : x; + c: x; + b: x; + a: x; - new () : Bar; + new (): Bar; - c() : void; - b() : void; - a() : void; -} - `, + c(): void; + b(): void; + a(): void; +}; + `, options: [{ interfaces: { order: 'alphabetically' } }], }, @@ -2404,16 +2384,16 @@ type Foo = { code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, + `, options: [{ interfaces: { order: 'alphabetically' } }], }, @@ -2422,16 +2402,16 @@ class Foo { code: ` const foo = class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} -} - `, +}; + `, options: [{ interfaces: { order: 'alphabetically' } }], }, ], @@ -2440,21 +2420,21 @@ const foo = class Foo { { code: ` interface Foo { - [a: string] : number; + [a: string]: number; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - c() : void; - b() : void; - a() : void; + c(): void; + b(): void; + a(): void; - () : Baz; + (): Baz; - new () : Bar; + new (): Bar; } - `, + `, options: [ { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, ], @@ -2478,30 +2458,27 @@ interface Foo { ], }; -const sortedWithGroupingTypeLiteralsOption: TSESLint.RunTests< - MessageIds, - Options -> = { +const sortedWithGroupingTypeLiteralsOption: RunTests = { valid: [ // typeLiterals option + interface + alphabetically --> Default order applies { code: ` interface Foo { - [a: string] : number; + [a: string]: number; - () : Baz; + (): Baz; - c : x; - b : x; - a : x; + c: x; + b: x; + a: x; - new () : Bar; + new (): Bar; - c() : void; - b() : void; - a() : void; + c(): void; + b(): void; + a(): void; } - `, + `, options: [{ typeLiterals: { order: 'alphabetically' } }], }, @@ -2509,21 +2486,21 @@ interface Foo { { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; - new () : Bar; + new (): Bar; - () : Baz; -} - `, + (): Baz; +}; + `, options: [ { typeLiterals: { @@ -2538,20 +2515,20 @@ type Foo = { { code: ` type Foo = { - new () : Bar; + new (): Bar; - a() : void; - b() : void; - c() : void; + a(): void; + b(): void; + c(): void; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - [a: string] : number; - () : Baz; -} - `, + [a: string]: number; + (): Baz; +}; + `, options: [ { typeLiterals: { @@ -2567,16 +2544,16 @@ type Foo = { code: ` class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} } - `, + `, options: [{ typeLiterals: { order: 'alphabetically' } }], }, @@ -2585,16 +2562,16 @@ class Foo { code: ` const foo = class Foo { public static a: string; - protected static b: string = ""; - private static c: string = ""; + protected static b: string = ''; + private static c: string = ''; - public d: string = ""; - protected e: string = ""; - private f: string = ""; + public d: string = ''; + protected e: string = ''; + private f: string = ''; constructor() {} -} - `, +}; + `, options: [{ typeLiterals: { order: 'alphabetically' } }], }, ], @@ -2603,21 +2580,21 @@ const foo = class Foo { { code: ` type Foo = { - [a: string] : number; + [a: string]: number; - a : x; - b : x; - c : x; + a: x; + b: x; + c: x; - c() : void; - b() : void; - a() : void; + c(): void; + b(): void; + a(): void; - () : Baz; + (): Baz; - new () : Bar; -} - `, + new (): Bar; +}; + `, options: [ { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, ], @@ -2667,7 +2644,7 @@ class Foo { ], }; -const sortedWithoutGrouping = { +const sortedWithoutGrouping: RunTests = { valid: [ ...sortedWithoutGroupingDefaultOption.valid, ...sortedWithoutGroupingClassesOption.valid, @@ -2684,7 +2661,7 @@ const sortedWithoutGrouping = { ], }; -const sortedWithGrouping = { +const sortedWithGrouping: RunTests = { valid: [ ...sortedWithGroupingDefaultOption.valid, ...sortedWithGroupingClassesOption.valid, From 2d9a33cfb2db53d76246a59253daaf2abb19ee57 Mon Sep 17 00:00:00 2001 From: Sviatoslav Miller Date: Thu, 3 Nov 2022 01:42:34 +0300 Subject: [PATCH 15/76] fix(eslint-plugin): isTypeReadonly stack overflow (#5875) (#5876) Co-authored-by: Josh Goldberg --- .../prefer-readonly-parameter-types.test.ts | 21 ++++++++++++++++++ packages/type-utils/src/isTypeReadonly.ts | 2 +- .../type-utils/tests/isTypeReadonly.test.ts | 22 ++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts b/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts index b6b499b0efd..7cd0527b2cf 100644 --- a/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts @@ -380,6 +380,27 @@ ruleTester.run('prefer-readonly-parameter-types', rule, { }, ], }, + { + name: 'circular readonly types (Bug: #5875)', + code: ` + interface Obj1 { + readonly [K: string]: Obj2; + } + + interface Obj2 { + readonly [K: string]: Obj1; + } + + function foo(event: Obj1): void {} + `, + options: [ + { + checkParameterProperties: true, + ignoreInferredTypes: false, + ...readonlynessOptionsDefaults, + }, + ], + }, ], invalid: [ // arrays diff --git a/packages/type-utils/src/isTypeReadonly.ts b/packages/type-utils/src/isTypeReadonly.ts index cac7690ea3a..7ba2b300089 100644 --- a/packages/type-utils/src/isTypeReadonly.ts +++ b/packages/type-utils/src/isTypeReadonly.ts @@ -113,7 +113,7 @@ function isTypeReadonlyObject( return Readonlyness.Mutable; } - if (indexInfo.type === type) { + if (indexInfo.type === type || seenTypes.has(indexInfo.type)) { return Readonlyness.Readonly; } diff --git a/packages/type-utils/tests/isTypeReadonly.test.ts b/packages/type-utils/tests/isTypeReadonly.test.ts index 77d9f65b2f9..382091a2375 100644 --- a/packages/type-utils/tests/isTypeReadonly.test.ts +++ b/packages/type-utils/tests/isTypeReadonly.test.ts @@ -139,6 +139,11 @@ describe('isTypeReadonly', () => { it('handles circular readonly PropertySignature inside a readonly IndexSignature', () => runTests('interface Test { readonly [key: string]: Test };')); + + it('handles circular readonly PropertySignature inside interdependent objects', () => + runTests( + 'interface Test1 { readonly [key: string]: Test } interface Test { readonly [key: string]: Test1 }', + )); }); describe('is not readonly', () => { @@ -156,8 +161,23 @@ describe('isTypeReadonly', () => { describe('is not readonly circular', () => { const runTests = runTestIsNotReadonly; - it('handles circular mutable PropertySignature inside a readonly IndexSignature', () => + it('handles circular mutable PropertySignature', () => runTests('interface Test { [key: string]: Test };')); + + it.each([ + [ + 'interface Test1 { [key: string]: Test } interface Test { readonly [key: string]: Test1 }', + ], + [ + 'interface Test1 { readonly [key: string]: Test } interface Test { [key: string]: Test1 }', + ], + [ + 'interface Test1 { [key: string]: Test } interface Test { [key: string]: Test1 }', + ], + ])( + 'handles circular mutable PropertySignature inside interdependent objects', + runTests, + ); }); }); From 9c130ccbb05935d0969af6a97b7fb590abdf83d9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 3 Nov 2022 13:43:35 +0000 Subject: [PATCH 16/76] docs: add maintainer guide (take two) (#5874) * docs: add maintainer guide * Went over docs again * Also updated .github/replies.yml * Added docs/MAITENANCE.md too * Apply suggestions from code review Co-authored-by: Joshua Chen * Tweaked issues ordering and intro * Split up releases and versions; reworked * Apply suggestions from code review Co-authored-by: Brad Zacher * Update docs/maintenance/RELEASES.md * Ran Prettier on RELEASES.md * Update docs/development/architecture/PACKAGES.md Co-authored-by: Brad Zacher Co-authored-by: Joshua Chen --- .cspell.json | 1 + .github/replies.yml | 19 ++++ docs/MAINTENANCE.md | 12 +++ docs/maintenance/ISSUES.md | 103 ++++++++++++++++++++++ docs/maintenance/RELEASES.md | 88 ++++++++++++++++++ docs/maintenance/VERSIONING.md | 72 +++++++++++++++ packages/website/sidebars/sidebar.base.js | 14 +++ 7 files changed, 309 insertions(+) create mode 100644 docs/MAINTENANCE.md create mode 100644 docs/maintenance/ISSUES.md create mode 100644 docs/maintenance/RELEASES.md create mode 100644 docs/maintenance/VERSIONING.md diff --git a/.cspell.json b/.cspell.json index c9be4caedb7..f6bb6c5cd87 100644 --- a/.cspell.json +++ b/.cspell.json @@ -106,6 +106,7 @@ "transpiled", "transpiles", "transpiling", + "triaging", "tsconfigs", "tsutils", "tsvfs", diff --git a/.github/replies.yml b/.github/replies.yml index 0522dfc445c..64f02ca54ed 100644 --- a/.github/replies.yml +++ b/.github/replies.yml @@ -17,6 +17,25 @@ replies: \ If you need it sooner, please try the `canary` tag on NPM. name: Fix Has Been Merged + - body: | + Thanks for the report @!\ + This might be a valid issue, but we can't tell because you haven't filled in enough information.\ + Please fill in the rest of the issue template so we can take a look.\ + Thanks! + name: Needs More Info + - body: | + Thanks for the report @!\ + I can't reproduce the issue using the repository you provided.\ + Could you please comment with instructions on how to reproduce the issue?\ + Thanks! + name: Needs Full Reproduction + - body: | + Thanks for the report @!\ + I can't reproduce the issue using the code you provided.\ + Could you please create an isolated reproduction in our playground (https://typescript-eslint.io/play) and comment back when you've got one?\ + We prefer an isolated reproduction so that we as volunteer maintainers can quickly reproduce the issue and more easily find the cause.\ + Thanks! + name: Needs Playground Reproduction - body: | With any issue opened in this project — it either has visible progress in the form of an attached PR, or it has no progress.\ \ diff --git a/docs/MAINTENANCE.md b/docs/MAINTENANCE.md new file mode 100644 index 00000000000..75f1030c015 --- /dev/null +++ b/docs/MAINTENANCE.md @@ -0,0 +1,12 @@ +--- +id: maintenance +sidebar_label: Maintenance Guide +title: Maintenance Guide +--- + +This is the maintainers guide to working on typescript-eslint. +It's intended for use by contributors who have been given access to at least triage issues and pull requests. +We keep it in the open for visibility into our processes. + +> If you're reading this as a new maintainer: welcome! +> We're happy to have you! ❤️‍🔥 diff --git a/docs/maintenance/ISSUES.md b/docs/maintenance/ISSUES.md new file mode 100644 index 00000000000..55d1cee6e62 --- /dev/null +++ b/docs/maintenance/ISSUES.md @@ -0,0 +1,103 @@ +--- +id: issues +sidebar_label: Issue Management +title: Issue Management +--- + +This document serves as a guide for how you might manage 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. +It's imperative we give them a positive, uplifting experience. + +:::tip +If you're ever unsure on any part of issue management, don't hesitate to loop in a maintainer that has more context to help! +::: + +## Issue Flow + +:::note +We include a set of common responses to issues in [`.github/replies.yml`](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/replies.yml), intended to be used with the [Refined Saved Replies](https://github.com/JoshuaKGoldberg/refined-saved-replies) extension. +Don't treat these as exact responses you must use: they're just a starting copy+paste helper. +Please do adopt your specific responses to your personal tone and to match the thread for non-straightforward issues. +::: + +[Issues pending triage](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aopen+is%3Aissue+label%3Atriage) are searchable the `triage` label. +That label is added automatically when a new issue is created. +Most issues go through the following review flow when created or updated: + +1. A maintainer ensures the issue is valid: + - If the poster didn't fill out an appropriate template with enough information: + - Add the `please fill out the template` and `awaiting response` labels + - Ask the poster for more information using a _Needs More Info_ response + - If it's a duplicate of an issue that already exists: + - Add the `duplicate` label and remove the `bug` label + - If it's an obvious duplicate, post a _Clearly Duplicate Issue_ response + - If it's not an obvious duplicate, link to the existing issue and explain why + - If the code is working as intended: + - Add the `working as intended` label and remove the `bug` and `triage` labels + - If the behavior is due to the user doing something wrong, such as an incorrect config: + - Add the `fix: user error` label + - [This issue search has some examples of closing comments](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aissue+sort%3Aupdated-desc+label%3A%22fix%3A+user+error%22+is%3Aclosed) + - If the behavior is otherwise expected, [this issue search has some examples of closing comments](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aissue+sort%3Aupdated-desc+label%3A%22working+as+intended%22+-label%3A%22fix%3A+user+error%22+is%3Aclosed+) + - You needn't go into too much detail in your comment - just enough to explain it +2. If the report is valid, add the `accepting prs` label and remove the `triage` label +3. If you know the rough steps for a fix, consider writing a comment with links to codebase to help someone put together a fix +4. If you think that the fix is relatively straightforward, consider also adding the `good first issue` label + +Whenever an issue is waiting for the reporter to provide more information, it should be given the `awaiting response` label. +When more information is provided: + +- If you have time to go through the triage flow again, do so +- If you don't have time, add the `triage` label and remove the `awaiting response` label + +:::tip +If your link is both a "permalink" (includes a commit hash instead of a branch name) and has a line number/line range then GitHub will embed the code in your comment. +When viewing a file in GitHub pressing `y` will update the URL to a "permalink" with the current commit hash, then you can select the relevant lines and paste that URL into the comment. +::: + +### Determining Whether Code is Working As Intended + +As you become more familiar with the codebase and how everything works, this will be easier to do intuitively, but to begin with, this will likely involve investigating the documentation, code, and tests to determine if it's a bug or working as intended. +In general, if there is a passing test or documented example that is the same as or similar to the repro code — that indicates it's working as intended. +If you can't find anything that matches, use your best judgement based on the spirit of the code. + +### Looking for Duplicates + +It's worth noting that, occasionally, a user will intentionally raise a duplicate issue because they feel the original issue was closed when it shouldn't have been. +If this is the case, you should read the original issue to gather context, understand the reason for it being closed, and determine if the new issue raises any new or relevant point that requires addressing. + +## Skipping Steps + +As you become more familiar with the codebase and how it's supposed to behave you'll be able to skip steps or do things out of order as you see fit. +For example, you may be able to identify if a bug report is "working as intended", or you might recognize an issue as a duplicate without having a completely filled-out issue. +In such cases you can forgo the back-and-forth and just skip to the closing steps. + +## Specific Issue Types + +### 🐛 Bug Reports + +#### 🐞 "Simple" Bugs + +A simple bug is a bug that can be reproduced in a single TS file plus an ESLint config (and possibly a TSConfig) - i.e. an issue reproducible on https://typescript-eslint.io/play. +The vast majority of bug reports fall into this category. + +If you cannot reproduce the issue as described using the issue's provided playground reproduction, it has not provided enough information. +Consider using a specific response like the _Needs Playground Reproduction_ response. + +#### 🦟 "Complex" Bugs + +A complex bug is a bug that requires multiple files to reproduce. +This is the rarer case, but does happen when people are using library types or if there are issues when types are imported. + +These bugs should be reported with a link to a GitHub repository that can be checked out to reproduce the issue. +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 + +TODO: This will be filled out... soon! + +### 🚀 New Rules + +TODO: This will be filled out... soon! diff --git a/docs/maintenance/RELEASES.md b/docs/maintenance/RELEASES.md new file mode 100644 index 00000000000..211294d488b --- /dev/null +++ b/docs/maintenance/RELEASES.md @@ -0,0 +1,88 @@ +--- +id: releases +sidebar_label: Releases +title: Releases +--- + +## Canary + +We release a canary version for each commit to `main` that passes all required checks. This release is performed automatically by the [`publish_canary_version` step](https://github.com/typescript-eslint/typescript-eslint/blob/5feb2dba9da2bd5e233451b7b0f1c99414b5aef9/.github/workflows/ci.yml#L234-L263). + +This release is goes to the `canary` tag on npm and it is versioned as an incremental canary patch release on top of the current `latest` version. I.e. if the current version is `5.6.1`, then the first canary version will be `5.6.2-alpha.0`, the second `5.6.2-alpha.1`, and so on. + +## Latest + +We release a latest version every Monday at 1pm US Eastern time using the latest commit to `main` at that time. This release is performed automatically by a Github action located in a private repository. This release goes to the standard `latest` tag on npm. + +See the [versioning](#versioning) section below for how the version number is calculated. + +If there have been no commits that impact public-facing packages then a patch-level release shall be released. + +Latest releases shall only ever be "minor" or "patch" releases. + +## Major Releases + +We currently do not have a set schedule around when major releases shall be performed; instead they are done as the need arises. + +We keep a backlog of breaking issues as a milestone on GitHub that is named in the form `${major}.0.0`. +When we do do a major release, we release a release candidate version to the `rc-v${major}` tag on npm for each commit to the major branch. + +### Major Release Steps + +Our releases go through three groups of steps: + +1. [Pre-Release Preparation] +1. [Merging Breaking Changes] +1. [Releasing the Version] + +#### 1. Pre-Release Preparation + +1. Create a milestone by the name of the release [example: [Milestone 6.0.0](https://github.com/typescript-eslint/typescript-eslint/milestone/8)]. +1. If an issue for changes to recommended rule configs doesn't yet exist, create one [example: [Changes to the `recommended` sets for 5.0.0](https://github.com/typescript-eslint/typescript-eslint/issues/5900)]. +1. Add any breaking changes intended for the release to that milestone. +1. Create two new branches off `main` in the project repository (not a personal fork): + - `v${major}` + - `v${major}-canary-auto-release` +1. Raise a PR from `v${major}-canary-auto-release` to `main` modifying the [`ci.yml` workflow](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/workflows/ci.yml) [example: [chore: add auto-canary release for v6](https://github.com/typescript-eslint/typescript-eslint/pull/5883)]: + - Under `pushes:` at the beginning of the file, add an `- v${major}` list item. + - Add a `publish_canary_version_v${major}` step the same as `publish_canary_version` except: + - Add the condition: `if: github.ref == 'refs/heads/v${major}'`. + - Its publish command should be `npx lerna publish premajor --loglevel=verbose --canary --exact --force-publish --yes --dist-tag rc-v${major}`. + - Merge this into `main` once reviewed and rebase the `v${major}` branch. + +#### 2. Merging Breaking Changes + +1. Send a PR from `v${major}` to `main` [example: [v6.0.0](https://github.com/typescript-eslint/typescript-eslint/pull/5886)]. +1. Change all [breaking change PRs](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aissue+is%3Aopen+label%3A%22breaking+change%22) to target the `v${major}` branch. + - To signify these changes as breaking, the first line of the PR description must read as `BREAKING CHANGE:`, and second line should briefly summarize the changes. + - It is important to note that when merged the commit message must also include `BREAKING CHANGE:` as the first line in order for lerna to recognize it as a breaking change in the release notes. If you miss this it just means more manual work when writing the release documentation. +1. Wait until all required PRs have been merged +1. Let the release wait for **at least 1 week** to allow time for early adopters to help test it and discuss the changes. + - Promote it on the [`@tseslint`](https://twitter.com/tseslint) twitter to get some additional attention. +1. Once discussions have settled, rebase merge the PR on top of `main`. + +:::note +_Non_-breaking changes can be merged to `main` or the major branch. +They don't need any special treatment. +::: + +#### 3. Releasing the Version + +1. Discuss with the maintainers to be ready for an [out-of-band](#out-of-band) release. Doing this manually helps ensure someone is on-hand to action any issues that might arise from the major release. +1. Prepare the release notes. Lerna will automatically generate the release notes on GitHub, however this will be disorganized and unhelpful for users. We need to reorganize the release notes so that breaking changes are placed at the top to make them most visible. If any migrations are required, we must list the steps to make it easy for users. + +- Example release notes: [`v5.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v5.0.0), [`v4.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0), [`v3.0.0`](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v3.0.0) + +1. Finally, tweet the release on the `@tseslint` twitter with a link to the GitHub release. Make sure you include additional information about the highlights of the release! + +## Out-of-Band + +We will do releases "out-of-band" (outside the [latest](#latest) schedule) for rare emergencies. +We assess need on a case-by-case basis though generally an emergency is defined as a critical regression specifically introduced in the latest release. + +These releases are done manually by a maintainer with the required access privileges. + +## Back-Porting Releases + +We **_do not_** back port releases to previously released major/minor versions. +We only ever release forward. diff --git a/docs/maintenance/VERSIONING.md b/docs/maintenance/VERSIONING.md new file mode 100644 index 00000000000..514215d1136 --- /dev/null +++ b/docs/maintenance/VERSIONING.md @@ -0,0 +1,72 @@ +--- +id: versioning +sidebar_label: Versioning +title: Versioning +--- + +We follow [semantic versioning (semver)](https://semver.org). +This page exists to help set guidelines around when what we consider to fall within each of the semver categories. + +All of the packages in this project are published with the same version number to make it easier to coordinate both releases and installations. + +When considering whether a change should be counted as "breaking" we first need to consider what package(s) it impacts. For example breaking changes for the parser packages have a different standard to those for the ESLint plugins. This is because not only do they have _very_ different API surfaces, they also are consumed in very different ways. + +Please note that the lists provided below are non-exhaustive and are intended to serve as examples to help guide maintainers when planning and reviewing changes. + +## Internal packages + +Any packages in this project that are not part of our public API surface (such as `eslint-plugin-internal` or `website`) shall not be considered when calculating new package versions. + +## `ast-spec` and `visitor-keys` + +A change to the AST **_shall_** be considered breaking if it: + +- Removes or renames an existing AST Node. +- Removes or renames an existing property on an AST Node. +- Changes a type in a non-refining way (i.e. `string` to `number`). + +A change to the AST **_shall not_** be considered breaking if it: + +- Adds a new property to the AST. +- Adds a new node type to the AST. +- Adds a new node type to an existing union type. +- Refines a type to be more specific (i.e. `string` to `'literal' | 'union'`). +- Removes a type from a union that was erroneously added and did not match the runtime AST. + +## `eslint-plugin` and `eslint-plugin-tslint` + +A change to the plugins **_shall_** be considered breaking if it will require the user to change their config. More specifically: + +- Removes or renames an option. +- Changes the default option of a rule. +- Changes a rule's schema to be stricter. +- Consumes type information to a rule that did not previously consume it. +- Removes or renames a rule. +- Changes any of the recommended configurations. +- Changes the default behavior of a rule in such a way that causes new reports in a large set of cases in an average codebase. + +A change to the plugins **_shall not_** be considered breaking if it: + +- Adds an option that by default does not remove existing functionality. +- Adds a rule. +- Deprecates a rule. +- Adds additional checks to an existing rule that causes new reports in a small-to-medium set of cases in an average codebase. +- Refactors a rule's code in a way that does not introduce additional reports. +- Changes to a rule's description or other metadata. +- Adds a fixer or suggestion fixer. +- Removes a fixer or suggestion fixer. +- Fixes incorrect behavior in a rule that may or may not introduce additional reports. + +### `parser`, `typescript-estree`, `scope-manager`, `types`, `type-utils`, `utils` + +A change to these packages **_shall_** be considered breaking if it: + +- Changes the API surface in a backwards-incompatible way (remove or rename functions, types, etc). + +A change to these packages **_shall not_** be considered breaking if it: + +- Adds to the API surface (add functions, types, etc). +- Deprecates parts of the API surface. +- Adds **_optional_** arguments to functions or properties to input types. +- Adds additional properties to output types. +- Adds documentation in the form of JSDoc comments. diff --git a/packages/website/sidebars/sidebar.base.js b/packages/website/sidebars/sidebar.base.js index 339ea39e95c..fbdc1f28e6b 100644 --- a/packages/website/sidebars/sidebar.base.js +++ b/packages/website/sidebars/sidebar.base.js @@ -52,5 +52,19 @@ module.exports = { 'development/custom-rules', ], }, + { + collapsible: false, + items: [ + 'maintenance/issues', + 'maintenance/releases', + 'maintenance/versioning', + ], + label: 'Maintenance', + link: { + id: 'maintenance', + type: 'doc', + }, + type: 'category', + }, ], }; From bdb6bed8a37c07a86af0544013b56f6c4f293cf2 Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" <53356952+typescript-eslint[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 01:49:59 +0000 Subject: [PATCH 17/76] chore: update sponsors (#5933) Co-authored-by: typescript-eslint[bot] --- packages/website/data/sponsors.json | 80 +++++++++++++++++------------ 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/packages/website/data/sponsors.json b/packages/website/data/sponsors.json index a4aa0623e04..fd44d68e52b 100644 --- a/packages/website/data/sponsors.json +++ b/packages/website/data/sponsors.json @@ -12,7 +12,7 @@ "image": "https://images.opencollective.com/nx/0efbe42/logo.png", "name": "Nx (by Nrwl)", "tier": "sponsor", - "totalDonations": 525000, + "totalDonations": 550000, "website": "https://nx.dev" }, { @@ -20,7 +20,7 @@ "image": "https://images.opencollective.com/eslint/96b09dc/logo.png", "name": "ESLint", "tier": "sponsor", - "totalDonations": 200000, + "totalDonations": 215000, "website": "https://eslint.org/" }, { @@ -28,7 +28,7 @@ "image": "https://images.opencollective.com/airbnb/d327d66/logo.png", "name": "Airbnb", "tier": "sponsor", - "totalDonations": 135800, + "totalDonations": 140800, "website": "https://www.airbnb.com/" }, { @@ -39,6 +39,14 @@ "totalDonations": 120000, "website": "https://blog.coinbase.com/engineering-and-security/home" }, + { + "id": "n8n.io - n8n GmbH", + "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", + "name": "n8n.io - n8n GmbH", + "tier": "sponsor", + "totalDonations": 115000, + "website": "https://n8n.io" + }, { "id": "Sentry", "image": "https://images.opencollective.com/sentry/9620d33/logo.png", @@ -47,28 +55,20 @@ "totalDonations": 114800, "website": "https://sentry.io/welcome/" }, - { - "id": "n8n.io - n8n GmbH", - "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", - "name": "n8n.io - n8n GmbH", - "tier": "sponsor", - "totalDonations": 110000, - "website": "https://n8n.io" - }, { "id": "GitBook", "image": "https://images.opencollective.com/gitbook/d35a8e7/logo.png", "name": "GitBook", "tier": "sponsor", - "totalDonations": 100000, + "totalDonations": 110000, "website": "https://www.gitbook.com" }, { "id": "Codecademy", "image": "https://images.opencollective.com/codecademy/d56a48d/logo.png", "name": "Codecademy", - "tier": "supporter", - "totalDonations": 90000, + "tier": "sponsor", + "totalDonations": 100000, "website": "https://codecademy.com" }, { @@ -87,6 +87,14 @@ "totalDonations": 54000, "website": "https://www.future-processing.com/" }, + { + "id": "Sourcegraph", + "image": "https://images.opencollective.com/sourcegraph/67e40ff/logo.png", + "name": "Sourcegraph", + "tier": "supporter", + "totalDonations": 50000, + "website": "https://about.sourcegraph.com" + }, { "id": "Whitebox", "image": "https://images.opencollective.com/whiteboxinc/ef0d11d/logo.png", @@ -95,14 +103,6 @@ "totalDonations": 40000, "website": "https://whitebox.com" }, - { - "id": "Sourcegraph", - "image": "https://images.opencollective.com/sourcegraph/67e40ff/logo.png", - "name": "Sourcegraph", - "tier": "contributor", - "totalDonations": 40000, - "website": "https://about.sourcegraph.com" - }, { "id": "Monito", "image": "https://images.opencollective.com/monito/50fc878/logo.png", @@ -111,12 +111,20 @@ "totalDonations": 30000, "website": "https://www.monito.com" }, + { + "id": "Codiga", + "image": "https://images.opencollective.com/codiga/1065f9f/logo.png", + "name": "Codiga", + "tier": "contributor", + "totalDonations": 30000, + "website": "https://www.codiga.io" + }, { "id": "STORIS", "image": "https://images.opencollective.com/storis/dfb0e13/logo.png", "name": "STORIS", "tier": "contributor", - "totalDonations": 25500, + "totalDonations": 27000, "website": "https://www.storis.com/" }, { @@ -135,20 +143,12 @@ "totalDonations": 22000, "website": "https://twitter.com/nevir" }, - { - "id": "Codiga", - "image": "https://images.opencollective.com/codiga/1065f9f/logo.png", - "name": "Codiga", - "tier": "contributor", - "totalDonations": 20000, - "website": "https://www.codiga.io" - }, { "id": "David Johnston", "image": "https://images.opencollective.com/blacksheepcode/976d69a/avatar.png", "name": "David Johnston", "tier": "contributor", - "totalDonations": 14500, + "totalDonations": 15000, "website": "https://blacksheepcode.com" }, { @@ -167,6 +167,14 @@ "totalDonations": 10000, "website": "http://gian.xyz" }, + { + "id": "Evil Martians", + "image": "https://images.opencollective.com/evilmartians/707ab4d/logo.png", + "name": "Evil Martians", + "tier": "contributor", + "totalDonations": 10000, + "website": "https://evilmartians.com/" + }, { "id": "The Guardian", "image": "https://images.opencollective.com/gdndevelopers/0b72bf0/logo.png", @@ -175,6 +183,14 @@ "totalDonations": 10000, "website": "https://www.theguardian.com/" }, + { + "id": "Balsa", + "image": "https://images.opencollective.com/balsa/77de498/logo.png", + "name": "Balsa", + "tier": "contributor", + "totalDonations": 10000, + "website": "https://balsa.com" + }, { "id": "Laserhub", "image": "https://images.opencollective.com/laserhub/bae6275/logo.png", From b8b24c211695c00317c93e1da1bf80b6d9c6837c Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" Date: Mon, 7 Nov 2022 17:28:33 +0000 Subject: [PATCH 18/76] chore: publish v5.42.1 --- CHANGELOG.md | 7 +++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 6 ++++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 4 ++++ packages/eslint-plugin-internal/package.json | 8 ++++---- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 6 ++++++ packages/eslint-plugin/package.json | 8 ++++---- packages/experimental-utils/CHANGELOG.md | 4 ++++ packages/experimental-utils/package.json | 4 ++-- packages/parser/CHANGELOG.md | 4 ++++ packages/parser/package.json | 8 ++++---- packages/scope-manager/CHANGELOG.md | 4 ++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 4 ++++ packages/shared-fixtures/package.json | 2 +- packages/type-utils/CHANGELOG.md | 6 ++++++ packages/type-utils/package.json | 8 ++++---- packages/types/CHANGELOG.md | 4 ++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 4 ++++ packages/typescript-estree/package.json | 8 ++++---- packages/utils/CHANGELOG.md | 4 ++++ packages/utils/package.json | 10 +++++----- packages/visitor-keys/CHANGELOG.md | 4 ++++ packages/visitor-keys/package.json | 4 ++-- packages/website-eslint/CHANGELOG.md | 4 ++++ packages/website-eslint/package.json | 16 ++++++++-------- packages/website/CHANGELOG.md | 4 ++++ packages/website/package.json | 8 ++++---- 32 files changed, 125 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4685ce8dae..c4db2f119aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +### Bug Fixes + +- **ast-spec:** correct misnamed ExportNamedDeclaration AST type ([#5913](https://github.com/typescript-eslint/typescript-eslint/issues/5913)) ([e88f4fa](https://github.com/typescript-eslint/typescript-eslint/commit/e88f4fa1d0127ba0ddeff578ec67f2e66a1de68b)) +- **eslint-plugin:** isTypeReadonly stack overflow ([#5875](https://github.com/typescript-eslint/typescript-eslint/issues/5875)) ([#5876](https://github.com/typescript-eslint/typescript-eslint/issues/5876)) ([2d9a33c](https://github.com/typescript-eslint/typescript-eslint/commit/2d9a33cfb2db53d76246a59253daaf2abb19ee57)) + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 47974603d99..0b0cd5d3c7d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.42.0", + "version": "5.42.1", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 4b069d345df..12b5e0818ea 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +### Bug Fixes + +- **ast-spec:** correct misnamed ExportNamedDeclaration AST type ([#5913](https://github.com/typescript-eslint/typescript-eslint/issues/5913)) ([e88f4fa](https://github.com/typescript-eslint/typescript-eslint/commit/e88f4fa1d0127ba0ddeff578ec67f2e66a1de68b)) + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Bug Fixes diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index 4b35b75dff2..bc441599d3a 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.42.0", + "version": "5.42.1", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index 150635d9f22..52726f2a2fa 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 1603397279a..899b0c144f9 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.42.0", + "version": "5.42.1", "private": true, "main": "dist/index.js", "scripts": { @@ -14,9 +14,9 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.42.0", - "@typescript-eslint/type-utils": "5.42.0", - "@typescript-eslint/utils": "5.42.0", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/type-utils": "5.42.1", + "@typescript-eslint/utils": "5.42.1", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 758874fd110..105df78c12f 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index feeedacebe6..143cda6b820 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.42.0", + "version": "5.42.1", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.42.0", + "@typescript-eslint/utils": "5.42.1", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.42.0" + "@typescript-eslint/parser": "5.42.1" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 609763b480e..8c5ef968f8a 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +### Bug Fixes + +- **eslint-plugin:** isTypeReadonly stack overflow ([#5875](https://github.com/typescript-eslint/typescript-eslint/issues/5875)) ([#5876](https://github.com/typescript-eslint/typescript-eslint/issues/5876)) ([2d9a33c](https://github.com/typescript-eslint/typescript-eslint/commit/2d9a33cfb2db53d76246a59253daaf2abb19ee57)) + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index f3afe646a16..baf09fbe480 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.42.0", + "version": "5.42.1", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,9 +44,9 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.42.0", - "@typescript-eslint/type-utils": "5.42.0", - "@typescript-eslint/utils": "5.42.0", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/type-utils": "5.42.1", + "@typescript-eslint/utils": "5.42.1", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 7334d6b80b4..90849052a8b 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 618afe32e04..a8beecad680 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.42.0", + "version": "5.42.1", "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.42.0" + "@typescript-eslint/utils": "5.42.1" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 689b11e8227..f289c94422c 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/parser + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Features diff --git a/packages/parser/package.json b/packages/parser/package.json index 8ef9a0cf359..3cab6296e24 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", - "@typescript-eslint/types": "5.42.0", - "@typescript-eslint/typescript-estree": "5.42.0", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/typescript-estree": "5.42.1", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index a4601cd80b3..a05c850fb59 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Features diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 34ffe2f86e9..805f5263089 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.42.0", + "version": "5.42.1", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -38,12 +38,12 @@ "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" }, "dependencies": { - "@typescript-eslint/types": "5.42.0", - "@typescript-eslint/visitor-keys": "5.42.0" + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.42.0", + "@typescript-eslint/typescript-estree": "5.42.1", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 6011551b73e..ab596d7e657 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index 5c8bb352ba3..ca455a0baa7 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.42.0", + "version": "5.42.1", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 09af50ebb31..05d63922d7b 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-utils/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +### Bug Fixes + +- **eslint-plugin:** isTypeReadonly stack overflow ([#5875](https://github.com/typescript-eslint/typescript-eslint/issues/5875)) ([#5876](https://github.com/typescript-eslint/typescript-eslint/issues/5876)) ([2d9a33c](https://github.com/typescript-eslint/typescript-eslint/commit/2d9a33cfb2db53d76246a59253daaf2abb19ee57)) + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **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 6150b2d27c9..d7c59969f23 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", - "@typescript-eslint/utils": "5.42.0", + "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/utils": "5.42.1", "debug": "^4.3.4", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.42.0", + "@typescript-eslint/parser": "5.42.1", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 48a98e9a16f..e40007997a1 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/types + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index d2347b6a48c..8d07f4e7f4c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.42.0", + "version": "5.42.1", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 78cf8e7aefc..157724f1c61 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Bug Fixes diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 1df5908ca03..ded0c0f77d6 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", - "@typescript-eslint/visitor-keys": "5.42.0", + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1", "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.42.0", + "@typescript-eslint/shared-fixtures": "5.42.1", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 97a2797ea8a..0f90a7ba84d 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/utils + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Features diff --git a/packages/utils/package.json b/packages/utils/package.json index 2de743ab01d..6fce0515843 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", - "@typescript-eslint/types": "5.42.0", - "@typescript-eslint/typescript-estree": "5.42.0", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/typescript-estree": "5.42.1", "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.42.0", + "@typescript-eslint/parser": "5.42.1", "typescript": "*" }, "funding": { diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 21700ddd1a3..c3f21858ae0 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 2068a094820..285fb30b312 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", + "@typescript-eslint/types": "5.42.1", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index 5c65303053e..08eac0b5451 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) **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 5384c756758..7f0d3551d71 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", - "@typescript-eslint/utils": "5.42.0" + "@typescript-eslint/types": "5.42.1", + "@typescript-eslint/utils": "5.42.1" }, "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.42.0", - "@typescript-eslint/parser": "5.42.0", - "@typescript-eslint/scope-manager": "5.42.0", - "@typescript-eslint/typescript-estree": "5.42.0", - "@typescript-eslint/visitor-keys": "5.42.0", + "@typescript-eslint/eslint-plugin": "5.42.1", + "@typescript-eslint/parser": "5.42.1", + "@typescript-eslint/scope-manager": "5.42.1", + "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/visitor-keys": "5.42.1", "eslint": "*", "rollup": "^2.75.4", "rollup-plugin-terser": "^7.0.2", diff --git a/packages/website/CHANGELOG.md b/packages/website/CHANGELOG.md index 472da3ec4f2..45dc82b46b2 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) + +**Note:** Version bump only for package website + # [5.42.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.41.0...v5.42.0) (2022-10-31) ### Bug Fixes diff --git a/packages/website/package.json b/packages/website/package.json index 7ca8f69a3d7..b59791a71e9 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.42.0", + "version": "5.42.1", "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.42.0", - "@typescript-eslint/website-eslint": "5.42.0", + "@typescript-eslint/parser": "5.42.1", + "@typescript-eslint/website-eslint": "5.42.1", "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.42.0", + "@typescript-eslint/eslint-plugin": "5.42.1", "copy-webpack-plugin": "^11.0.0", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.29.4", From 923d486c8c9c9096deac425e7a6cb0b6457eacbd Mon Sep 17 00:00:00 2001 From: Omri Luzon Date: Mon, 7 Nov 2022 23:00:38 +0200 Subject: [PATCH 19/76] feat(eslint-plugin): [prefer-optional-chain] support suggesting `!foo || !foo.bar` as a valid match for the rule (#5594) * feat/issue5245-negated-or-optional-chaining---fixed * Not supported mixing with TSNonNullExpression * complex computed properties * CR fix comment on unsupported cases and remove TODO comments * CR: Remove unreachable uncovered check --- .../docs/rules/prefer-optional-chain.md | 12 +- .../src/rules/prefer-optional-chain.ts | 350 ++++++++++++++---- .../tests/rules/prefer-optional-chain.test.ts | 175 +++++++++ 3 files changed, 455 insertions(+), 82 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md index cff46dfdf49..4a9ada8b08f 100644 --- a/packages/eslint-plugin/docs/rules/prefer-optional-chain.md +++ b/packages/eslint-plugin/docs/rules/prefer-optional-chain.md @@ -1,5 +1,5 @@ --- -description: 'Enforce using concise optional chain expressions instead of chained logical ands.' +description: 'Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects.' --- > 🛑 This file is source code, not the primary documentation location! 🛑 @@ -23,9 +23,15 @@ foo && foo.a && foo.a.b && foo.a.b.c; foo && foo['a'] && foo['a'].b && foo['a'].b.c; foo && foo.a && foo.a.b && foo.a.b.method && foo.a.b.method(); +// With empty objects (((foo || {}).a || {}).b || {}).c; (((foo || {})['a'] || {}).b || {}).c; +// With negated `or`s +!foo || !foo.bar; +!foo || !foo[bar]; +!foo || !foo.bar || !foo.bar.baz || !foo.bar.baz(); + // this rule also supports converting chained strict nullish checks: foo && foo.a != null && @@ -43,6 +49,10 @@ foo?.['a']?.b?.c; foo?.a?.b?.method?.(); foo?.a?.b?.c?.d?.e; + +!foo?.bar; +!foo?.[bar]; +!foo?.bar?.baz?.(); ``` diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index dc9b514e353..89eb72094b6 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -35,7 +35,7 @@ export default util.createRule({ type: 'suggestion', docs: { description: - 'Enforce using concise optional chain expressions instead of chained logical ands', + 'Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects', recommended: 'strict', }, hasSuggestions: true, @@ -111,6 +111,81 @@ export default util.createRule({ ], }); }, + [[ + 'LogicalExpression[operator="||"] > UnaryExpression[operator="!"] > Identifier', + 'LogicalExpression[operator="||"] > UnaryExpression[operator="!"] > MemberExpression', + 'LogicalExpression[operator="||"] > UnaryExpression[operator="!"] > ChainExpression > MemberExpression', + ].join(',')]( + initialIdentifierOrNotEqualsExpr: + | TSESTree.Identifier + | TSESTree.MemberExpression, + ): void { + // selector guarantees this cast + const initialExpression = ( + initialIdentifierOrNotEqualsExpr.parent!.type === + AST_NODE_TYPES.ChainExpression + ? initialIdentifierOrNotEqualsExpr.parent.parent + : initialIdentifierOrNotEqualsExpr.parent + )!.parent as TSESTree.LogicalExpression; + + if ( + initialExpression.left.type !== AST_NODE_TYPES.UnaryExpression || + initialExpression.left.argument !== initialIdentifierOrNotEqualsExpr + ) { + // the node(identifier or member expression) is not the deepest left node + return; + } + + // walk up the tree to figure out how many logical expressions we can include + let previous: TSESTree.LogicalExpression = initialExpression; + let current: TSESTree.Node = initialExpression; + let previousLeftText = getText(initialIdentifierOrNotEqualsExpr); + let optionallyChainedCode = previousLeftText; + let expressionCount = 1; + while (current.type === AST_NODE_TYPES.LogicalExpression) { + if ( + current.right.type !== AST_NODE_TYPES.UnaryExpression || + !isValidChainTarget( + current.right.argument, + // only allow unary '!' with identifiers for the first chain - !foo || !foo() + expressionCount === 1, + ) + ) { + break; + } + const { rightText, shouldBreak } = breakIfInvalid({ + rightNode: current.right.argument, + previousLeftText, + }); + if (shouldBreak) { + break; + } + + ({ + expressionCount, + previousLeftText, + optionallyChainedCode, + previous, + current, + } = normalizeRepeatingPatterns( + rightText, + expressionCount, + previousLeftText, + optionallyChainedCode, + previous, + current, + )); + } + + reportIfMoreThanOne({ + expressionCount, + previous, + optionallyChainedCode, + sourceCode, + context, + shouldHandleChainedAnds: false, + }); + }, [[ 'LogicalExpression[operator="&&"] > Identifier', 'LogicalExpression[operator="&&"] > MemberExpression', @@ -155,94 +230,76 @@ export default util.createRule({ ) { break; } - - const leftText = previousLeftText; - const rightText = getText(current.right); - // can't just use startsWith because of cases like foo && fooBar.baz; - const matchRegex = new RegExp( - `^${ - // escape regex characters - leftText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - }[^a-zA-Z0-9_$]`, - ); - if ( - !matchRegex.test(rightText) && - // handle redundant cases like foo.bar && foo.bar - leftText !== rightText - ) { + const { rightText, shouldBreak } = breakIfInvalid({ + rightNode: current.right, + previousLeftText, + }); + if (shouldBreak) { break; } - // omit weird doubled up expression that make no sense like foo.bar && foo.bar - if (rightText !== leftText) { - expressionCount += 1; - previousLeftText = rightText; - - /* - Diff the left and right text to construct the fix string - There are the following cases: - 1) - rightText === 'foo.bar.baz.buzz' - leftText === 'foo.bar.baz' - diff === '.buzz' - 2) - rightText === 'foo.bar.baz.buzz()' - leftText === 'foo.bar.baz' - diff === '.buzz()' - 3) - rightText === 'foo.bar.baz.buzz()' - leftText === 'foo.bar.baz.buzz' - diff === '()' - 4) - rightText === 'foo.bar.baz[buzz]' - leftText === 'foo.bar.baz' - diff === '[buzz]' - 5) - rightText === 'foo.bar.baz?.buzz' - leftText === 'foo.bar.baz' - diff === '?.buzz' - */ - const diff = rightText.replace(leftText, ''); - if (diff.startsWith('?')) { - // item was "pre optional chained" - optionallyChainedCode += diff; - } else { - const needsDot = diff.startsWith('(') || diff.startsWith('['); - optionallyChainedCode += `?${needsDot ? '.' : ''}${diff}`; - } - } - - previous = current; - current = util.nullThrows( - current.parent, - util.NullThrowsReasons.MissingParent, - ); + ({ + expressionCount, + previousLeftText, + optionallyChainedCode, + previous, + current, + } = normalizeRepeatingPatterns( + rightText, + expressionCount, + previousLeftText, + optionallyChainedCode, + previous, + current, + )); } - if (expressionCount > 1) { - if (previous.right.type === AST_NODE_TYPES.BinaryExpression) { - // case like foo && foo.bar !== someValue - optionallyChainedCode += ` ${ - previous.right.operator - } ${sourceCode.getText(previous.right.right)}`; - } - - context.report({ - node: previous, - messageId: 'preferOptionalChain', - suggest: [ - { - messageId: 'optionalChainSuggest', - fix: (fixer): TSESLint.RuleFix[] => [ - fixer.replaceText(previous, optionallyChainedCode), - ], - }, - ], - }); - } + reportIfMoreThanOne({ + expressionCount, + previous, + optionallyChainedCode, + sourceCode, + context, + shouldHandleChainedAnds: true, + }); }, }; + interface BreakIfInvalidResult { + leftText: string; + rightText: string; + shouldBreak: boolean; + } + + interface BreakIfInvalidOptions { + previousLeftText: string; + rightNode: ValidChainTarget; + } + + function breakIfInvalid({ + previousLeftText, + rightNode, + }: BreakIfInvalidOptions): BreakIfInvalidResult { + let shouldBreak = false; + + const rightText = getText(rightNode); + // can't just use startsWith because of cases like foo && fooBar.baz; + const matchRegex = new RegExp( + `^${ + // escape regex characters + previousLeftText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + }[^a-zA-Z0-9_$]`, + ); + if ( + !matchRegex.test(rightText) && + // handle redundant cases like foo.bar && foo.bar + previousLeftText !== rightText + ) { + shouldBreak = true; + } + return { shouldBreak, leftText: previousLeftText, rightText }; + } + function getText(node: ValidChainTarget): string { if (node.type === AST_NODE_TYPES.BinaryExpression) { return getText( @@ -299,6 +356,11 @@ export default util.createRule({ return getText(node.expression); } + if (node.object.type === AST_NODE_TYPES.TSNonNullExpression) { + // Not supported mixing with TSNonNullExpression + return ''; + } + return getMemberExpressionText(node); } @@ -389,6 +451,132 @@ const ALLOWED_NON_COMPUTED_PROP_TYPES: ReadonlySet = new Set([ AST_NODE_TYPES.Identifier, ]); +interface ReportIfMoreThanOneOptions { + expressionCount: number; + previous: TSESTree.LogicalExpression; + optionallyChainedCode: string; + sourceCode: Readonly; + context: Readonly< + TSESLint.RuleContext< + 'preferOptionalChain' | 'optionalChainSuggest', + never[] + > + >; + shouldHandleChainedAnds: boolean; +} + +function reportIfMoreThanOne({ + expressionCount, + previous, + optionallyChainedCode, + sourceCode, + context, + shouldHandleChainedAnds, +}: ReportIfMoreThanOneOptions): void { + if (expressionCount > 1) { + if ( + shouldHandleChainedAnds && + previous.right.type === AST_NODE_TYPES.BinaryExpression + ) { + // case like foo && foo.bar !== someValue + optionallyChainedCode += ` ${ + previous.right.operator + } ${sourceCode.getText(previous.right.right)}`; + } + + context.report({ + node: previous, + messageId: 'preferOptionalChain', + suggest: [ + { + messageId: 'optionalChainSuggest', + fix: (fixer): TSESLint.RuleFix[] => [ + fixer.replaceText( + previous, + `${shouldHandleChainedAnds ? '' : '!'}${optionallyChainedCode}`, + ), + ], + }, + ], + }); + } +} + +interface NormalizedPattern { + expressionCount: number; + previousLeftText: string; + optionallyChainedCode: string; + previous: TSESTree.LogicalExpression; + current: TSESTree.Node; +} + +function normalizeRepeatingPatterns( + rightText: string, + expressionCount: number, + previousLeftText: string, + optionallyChainedCode: string, + previous: TSESTree.Node, + current: TSESTree.Node, +): NormalizedPattern { + const leftText = previousLeftText; + // omit weird doubled up expression that make no sense like foo.bar && foo.bar + if (rightText !== previousLeftText) { + expressionCount += 1; + previousLeftText = rightText; + + /* + Diff the left and right text to construct the fix string + There are the following cases: + + 1) + rightText === 'foo.bar.baz.buzz' + leftText === 'foo.bar.baz' + diff === '.buzz' + + 2) + rightText === 'foo.bar.baz.buzz()' + leftText === 'foo.bar.baz' + diff === '.buzz()' + + 3) + rightText === 'foo.bar.baz.buzz()' + leftText === 'foo.bar.baz.buzz' + diff === '()' + + 4) + rightText === 'foo.bar.baz[buzz]' + leftText === 'foo.bar.baz' + diff === '[buzz]' + + 5) + rightText === 'foo.bar.baz?.buzz' + leftText === 'foo.bar.baz' + diff === '?.buzz' + */ + const diff = rightText.replace(leftText, ''); + if (diff.startsWith('?')) { + // item was "pre optional chained" + optionallyChainedCode += diff; + } else { + const needsDot = diff.startsWith('(') || diff.startsWith('['); + optionallyChainedCode += `?${needsDot ? '.' : ''}${diff}`; + } + } + + previous = current as TSESTree.LogicalExpression; + current = util.nullThrows( + current.parent, + util.NullThrowsReasons.MissingParent, + ); + return { + expressionCount, + previousLeftText, + optionallyChainedCode, + previous, + current, + }; +} + function isValidChainTarget( node: TSESTree.Node, allowIdentifier: boolean, diff --git a/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts b/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts index 0358c065870..58b309edcc8 100644 --- a/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts @@ -65,6 +65,16 @@ const baseCases = [ 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()', @@ -147,6 +157,14 @@ const baseCases = [ ruleTester.run('prefer-optional-chain', rule, { valid: [ + '!a || !b;', + '!a || a.b;', + '!a && a.b;', + '!a && !a.b;', + '!a.b || a.b?.();', + '!a.b || a.b();', + '!foo() || !foo().bar;', + 'foo || {};', 'foo || ({} as any);', '(foo || {})?.bar;', @@ -180,6 +198,17 @@ ruleTester.run('prefer-optional-chain', rule, { 'foo && foo[bar as string] && foo[bar as string].baz;', 'foo && foo[1 + 2] && foo[1 + 2].baz;', 'foo && foo[typeof bar] && foo[typeof bar].baz;', + '!foo || !foo[bar as string] || !foo[bar as string].baz;', + '!foo || !foo[1 + 2] || !foo[1 + 2].baz;', + '!foo || !foo[typeof bar] || !foo[typeof bar].baz;', + // currently do not handle 'this' as the first part of a chain + 'this && this.foo;', + '!this || !this.foo;', + // intentionally do not handle mixed TSNonNullExpression in properties + '!entity.__helper!.__initialized || options.refresh;', + '!foo!.bar || !foo!.bar.baz;', + '!foo!.bar!.baz || !foo!.bar!.baz!.paz;', + '!foo.bar!.baz || !foo.bar!.baz!.paz;', ], invalid: [ ...baseCases, @@ -447,6 +476,22 @@ foo?.bar(/* comment */a, }, ], }, + // case with this keyword at the start of expression + { + code: 'this.bar && this.bar.baz;', + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: 'this.bar?.baz;', + }, + ], + }, + ], + }, // other weird cases { code: 'foo && foo?.();', @@ -1144,5 +1189,135 @@ foo?.bar(/* comment */a, }, ], }, + { + code: '(this || {}).foo;', + errors: [ + { + messageId: 'optionalChainSuggest', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: 'this?.foo;', + }, + ], + }, + ], + }, + ...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;', + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: '!this.bar?.baz;', + }, + ], + }, + ], + }, + { + code: '!a.b || !a.b();', + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: '!a.b?.();', + }, + ], + }, + ], + }, + { + code: '!foo.bar || !foo.bar.baz;', + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: '!foo.bar?.baz;', + }, + ], + }, + ], + }, + { + code: '!foo[bar] || !foo[bar]?.[baz];', + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: '!foo[bar]?.[baz];', + }, + ], + }, + ], + }, + { + code: '!foo || !foo?.bar.baz;', + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: '!foo?.bar.baz;', + }, + ], + }, + ], + }, + // two errors + { + code: noFormat`(!foo || !foo.bar || !foo.bar.baz) && (!baz || !baz.bar || !baz.bar.foo);`, + output: null, + errors: [ + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: noFormat`(!foo?.bar?.baz) && (!baz || !baz.bar || !baz.bar.foo);`, + }, + ], + }, + { + messageId: 'preferOptionalChain', + suggestions: [ + { + messageId: 'optionalChainSuggest', + output: noFormat`(!foo || !foo.bar || !foo.bar.baz) && (!baz?.bar?.foo);`, + }, + ], + }, + ], + }, ], }); From c759da169390ba490eee9ef773cc9edc88a32817 Mon Sep 17 00:00:00 2001 From: eliasm307 <13420359+eliasm307@users.noreply.github.com> Date: Mon, 7 Nov 2022 22:15:57 +0100 Subject: [PATCH 20/76] feat(eslint-plugin): [naming-convention] add support for "override" and "async" modifiers (#5310) (#5610) * feat(eslint-plugin): [naming-convention] add support for "override" and "async" modifiers (#5310) * apply pr feedback ie remove test case util, split tests by type, remove abstract getter change, remove override for variable selector in docs * remove async parameter logic which is impossible Co-authored-by: Josh Goldberg --- .../docs/rules/naming-convention.md | 23 +- .../rules/naming-convention-utils/enums.ts | 4 + .../rules/naming-convention-utils/schema.ts | 21 +- .../src/rules/naming-convention.ts | 49 ++ .../naming-convention.test.ts | 446 ++++++++++++++++++ 5 files changed, 530 insertions(+), 13 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index 50bd1751518..ef273df8f16 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -171,7 +171,8 @@ If these are provided, the identifier must start with one of the provided values - `unused` - matches anything that is not used. - `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it). - `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public). - - `readonly`, `static`, `abstract`, `protected`, `private` - matches any member explicitly declared with the given modifier. + - `readonly`, `static`, `abstract`, `protected`, `private`, `override` - matches any member explicitly declared with the given modifier. + - `async` - matches any method, function, or function variable which is async via the `async` keyword (e.g. does not match functions that return promises without using `async` keyword) - `types` allows you to specify which types to match. This option supports simple, primitive types only (`boolean`, `string`, `number`, `array`, `function`). - The name must match _one_ of the types. - **_NOTE - Using this option will require that you lint with type information._** @@ -194,16 +195,16 @@ There are two types of selectors, individual selectors, and grouped selectors. Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors. - `variable` - matches any `var` / `let` / `const` variable name. - - Allowed `modifiers`: `const`, `destructured`, `global`, `exported`, `unused`. + - Allowed `modifiers`: `const`, `destructured`, `global`, `exported`, `unused`, `async`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `function` - matches any named function declaration or named function expression. - - Allowed `modifiers`: `global`, `exported`, `unused`. + - Allowed `modifiers`: `global`, `exported`, `unused`, `async`. - Allowed `types`: none. - `parameter` - matches any function parameter. Does not match parameter properties. - Allowed `modifiers`: `destructured`, `unused`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values. - - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`. + - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`, `override`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values. - Allowed `modifiers`: `public`, `requiresQuotes`. @@ -215,16 +216,16 @@ Individual Selectors match specific, well-defined sets. There is no overlap betw - Allowed `modifiers`: `private`, `protected`, `public`, `readonly`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors. - - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`. + - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`, `override`, `async`. - Allowed `types`: none. - `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors. - - Allowed `modifiers`: `public`, `requiresQuotes`. + - Allowed `modifiers`: `public`, `requiresQuotes`, `async`. - Allowed `types`: none. - `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors. - Allowed `modifiers`: `public`, `requiresQuotes`. - Allowed `types`: none. - `accessor` - matches any accessor. - - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`. + - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`, `override`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `enumMember` - matches any enum member. - Allowed `modifiers`: `requiresQuotes`. @@ -253,19 +254,19 @@ Group Selectors are provided for convenience, and essentially bundle up sets of - Allowed `modifiers`: all modifiers. - Allowed `types`: none. - `variableLike` - matches the same as `variable`, `function` and `parameter`. - - Allowed `modifiers`: `unused`. + - Allowed `modifiers`: `unused`, `async`. - Allowed `types`: none. - `memberLike` - matches the same as `property`, `parameterProperty`, `method`, `accessor`, `enumMember`. - - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`. + - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`. - Allowed `types`: none. - `typeLike` - matches the same as `class`, `interface`, `typeAlias`, `enum`, `typeParameter`. - Allowed `modifiers`: `abstract`, `unused`. - Allowed `types`: none. - `property` - matches the same as `classProperty`, `objectLiteralProperty`, `typeProperty`. - - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`. + - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`. - - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`. + - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`. - Allowed `types`: none. ## FAQ diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts index c9460305847..bc2547ffa3f 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts @@ -102,6 +102,10 @@ enum Modifiers { unused = 1 << 10, // properties that require quoting requiresQuotes = 1 << 11, + // class members that are overridden + override = 1 << 12, + // class methods, object function properties, or functions that are async via the `async` keyword + async = 1 << 13, // make sure TypeModifiers starts at Modifiers + 1 or else sorting won't work } diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts index fab1d1bc2b6..179b6dd7f43 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/schema.ts @@ -170,15 +170,21 @@ const SCHEMA: JSONSchema.JSONSchema4 = { selectorsSchema(), ...selectorSchema('default', false, util.getEnumNames(Modifiers)), - ...selectorSchema('variableLike', false, ['unused']), + ...selectorSchema('variableLike', false, ['unused', 'async']), ...selectorSchema('variable', true, [ 'const', 'destructured', 'exported', 'global', 'unused', + 'async', + ]), + ...selectorSchema('function', false, [ + 'exported', + 'global', + 'unused', + 'async', ]), - ...selectorSchema('function', false, ['exported', 'global', 'unused']), ...selectorSchema('parameter', true, ['destructured', 'unused']), ...selectorSchema('memberLike', false, [ @@ -189,6 +195,8 @@ const SCHEMA: JSONSchema.JSONSchema4 = { 'readonly', 'requiresQuotes', 'static', + 'override', + 'async', ]), ...selectorSchema('classProperty', true, [ 'abstract', @@ -198,6 +206,7 @@ const SCHEMA: JSONSchema.JSONSchema4 = { 'readonly', 'requiresQuotes', 'static', + 'override', ]), ...selectorSchema('objectLiteralProperty', true, [ 'public', @@ -222,6 +231,8 @@ const SCHEMA: JSONSchema.JSONSchema4 = { 'readonly', 'requiresQuotes', 'static', + 'override', + 'async', ]), ...selectorSchema('classMethod', false, [ @@ -231,10 +242,13 @@ const SCHEMA: JSONSchema.JSONSchema4 = { 'public', 'requiresQuotes', 'static', + 'override', + 'async', ]), ...selectorSchema('objectLiteralMethod', false, [ 'public', 'requiresQuotes', + 'async', ]), ...selectorSchema('typeMethod', false, ['public', 'requiresQuotes']), ...selectorSchema('method', false, [ @@ -244,6 +258,8 @@ const SCHEMA: JSONSchema.JSONSchema4 = { 'public', 'requiresQuotes', 'static', + 'override', + 'async', ]), ...selectorSchema('accessor', true, [ 'abstract', @@ -252,6 +268,7 @@ const SCHEMA: JSONSchema.JSONSchema4 = { 'public', 'requiresQuotes', 'static', + 'override', ]), ...selectorSchema('enumMember', false, ['requiresQuotes']), diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 2984c49f5a2..05f3dd0f2a6 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -138,6 +138,9 @@ export default util.createRule({ if ('readonly' in node && node.readonly) { modifiers.add(Modifiers.readonly); } + if ('override' in node && node.override) { + modifiers.add(Modifiers.override); + } if ( node.type === AST_NODE_TYPES.TSAbstractPropertyDefinition || node.type === AST_NODE_TYPES.TSAbstractMethodDefinition @@ -182,6 +185,34 @@ export default util.createRule({ ); } + function isAsyncMemberOrProperty( + propertyOrMemberNode: + | TSESTree.PropertyNonComputedName + | TSESTree.TSMethodSignatureNonComputedName + | TSESTree.PropertyDefinitionNonComputedName + | TSESTree.TSAbstractPropertyDefinitionNonComputedName + | TSESTree.MethodDefinitionNonComputedName + | TSESTree.TSAbstractMethodDefinitionNonComputedName, + ): boolean { + return Boolean( + 'value' in propertyOrMemberNode && + propertyOrMemberNode.value && + 'async' in propertyOrMemberNode.value && + propertyOrMemberNode.value.async, + ); + } + + function isAsyncVariableIdentifier(id: TSESTree.Identifier): boolean { + return Boolean( + id.parent && + (('async' in id.parent && id.parent.async) || + ('init' in id.parent && + id.parent.init && + 'async' in id.parent.init && + id.parent.init.async)), + ); + } + return { // #region variable @@ -219,6 +250,10 @@ export default util.createRule({ modifiers.add(Modifiers.unused); } + if (isAsyncVariableIdentifier(id)) { + modifiers.add(Modifiers.async); + } + validator(id, modifiers); }); }, @@ -254,6 +289,10 @@ export default util.createRule({ modifiers.add(Modifiers.unused); } + if (node.async) { + modifiers.add(Modifiers.async); + } + validator(node.id, modifiers); }, @@ -360,6 +399,11 @@ export default util.createRule({ | TSESTree.TSMethodSignatureNonComputedName, ): void { const modifiers = new Set([Modifiers.public]); + + if (isAsyncMemberOrProperty(node)) { + modifiers.add(Modifiers.async); + } + handleMember(validators.objectLiteralMethod, node, modifiers); }, @@ -376,6 +420,11 @@ export default util.createRule({ | TSESTree.TSAbstractMethodDefinitionNonComputedName, ): void { const modifiers = getMemberModifiers(node); + + if (isAsyncMemberOrProperty(node)) { + modifiers.add(Modifiers.async); + } + handleMember(validators.classMethod, node, modifiers); }, diff --git a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts index 4c496b6c127..9917aec3cb7 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention/naming-convention.test.ts @@ -768,6 +768,105 @@ ruleTester.run('naming-convention', rule, { }, ], }, + { + code: ` + const obj = { + Bar() { + return 42; + }, + async async_bar() { + return 42; + }, + }; + class foo { + public Bar() { + return 42; + } + public async async_bar() { + return 42; + } + } + abstract class foo { + public abstract Bar() { + return 42; + } + public abstract async async_bar() { + return 42; + } + } + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: ['method', 'objectLiteralMethod'], + format: ['snake_case'], + modifiers: ['async'], + }, + { + selector: 'method', + format: ['PascalCase'], + }, + ], + }, + { + code: ` + const async_bar1 = async () => {}; + async function async_bar2() {} + const async_bar3 = async function async_bar4() {}; + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: 'method', + format: ['PascalCase'], + }, + { + selector: ['variable'], + format: ['snake_case'], + modifiers: ['async'], + }, + ], + }, + { + code: ` + class foo extends bar { + public someAttribute = 1; + public override some_attribute_override = 1; + public someMethod() { + return 42; + } + public override some_method_override2() { + return 42; + } + } + abstract class foo extends bar { + public abstract someAttribute: string; + public abstract override some_attribute_override: string; + public abstract someMethod(): string; + public abstract override some_method_override2(): string; + } + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: ['memberLike'], + modifiers: ['override'], + format: ['snake_case'], + }, + ], + }, ], invalid: [ { @@ -1526,5 +1625,352 @@ ruleTester.run('naming-convention', rule, { // 6, not 7 because 'foo' is valid errors: Array(6).fill({ messageId: 'doesNotMatchFormat' }), }, + { + code: ` + class foo { + public Bar() { + return 42; + } + public async async_bar() { + return 42; + } + // ❌ error + public async asyncBar() { + return 42; + } + // ❌ error + public AsyncBar2 = async () => { + return 42; + }; + // ❌ error + public AsyncBar3 = async function () { + return 42; + }; + } + abstract class foo { + public abstract Bar(): number; + public abstract async async_bar(): number; + // ❌ error + public abstract async ASYNC_BAR(): number; + } + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: 'method', + format: ['PascalCase'], + }, + { + selector: ['method', 'objectLiteralMethod'], + format: ['snake_case'], + modifiers: ['async'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Class Method', + name: 'asyncBar', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Class Method', + name: 'AsyncBar2', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Class Method', + name: 'AsyncBar3', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Class Method', + name: 'ASYNC_BAR', + formats: 'snake_case', + }, + }, + ], + }, + { + code: ` + const obj = { + Bar() { + return 42; + }, + async async_bar() { + return 42; + }, + // ❌ error + async AsyncBar() { + return 42; + }, + // ❌ error + AsyncBar2: async () => { + return 42; + }, + // ❌ error + AsyncBar3: async function () { + return 42; + }, + }; + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: 'method', + format: ['PascalCase'], + }, + { + selector: ['method', 'objectLiteralMethod'], + format: ['snake_case'], + modifiers: ['async'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Object Literal Method', + name: 'AsyncBar', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Object Literal Method', + name: 'AsyncBar2', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Object Literal Method', + name: 'AsyncBar3', + formats: 'snake_case', + }, + }, + ], + }, + { + code: ` + const syncbar1 = () => {}; + function syncBar2() {} + const syncBar3 = function syncBar4() {}; + + // ❌ error + const AsyncBar1 = async () => {}; + const async_bar1 = async () => {}; + const async_bar3 = async function async_bar4() {}; + async function async_bar2() {} + // ❌ error + const asyncBar5 = async function async_bar6() {}; + `, + parserOptions, + options: [ + { + selector: 'variableLike', + format: ['camelCase'], + }, + { + selector: ['variableLike'], + modifiers: ['async'], + format: ['snake_case'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Variable', + name: 'AsyncBar1', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Variable', + name: 'asyncBar5', + formats: 'snake_case', + }, + }, + ], + }, + { + code: ` + const syncbar1 = () => {}; + function syncBar2() {} + const syncBar3 = function syncBar4() {}; + + const async_bar1 = async () => {}; + // ❌ error + async function asyncBar2() {} + const async_bar3 = async function async_bar4() {}; + async function async_bar2() {} + // ❌ error + const async_bar3 = async function ASYNC_BAR4() {}; + `, + parserOptions, + options: [ + { + selector: 'variableLike', + format: ['camelCase'], + }, + { + selector: ['variableLike'], + modifiers: ['async'], + format: ['snake_case'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Function', + name: 'asyncBar2', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Function', + name: 'ASYNC_BAR4', + formats: 'snake_case', + }, + }, + ], + }, + { + code: ` + class foo extends bar { + public someAttribute = 1; + public override some_attribute_override = 1; + // ❌ error + public override someAttributeOverride = 1; + } + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: ['memberLike'], + modifiers: ['override'], + format: ['snake_case'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Class Property', + name: 'someAttributeOverride', + formats: 'snake_case', + }, + }, + ], + }, + { + code: ` + class foo extends bar { + public override some_method_override() { + return 42; + } + // ❌ error + public override someMethodOverride() { + return 42; + } + } + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: ['memberLike'], + modifiers: ['override'], + format: ['snake_case'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Class Method', + name: 'someMethodOverride', + formats: 'snake_case', + }, + }, + ], + }, + { + code: ` + class foo extends bar { + public get someGetter(): string; + public override get some_getter_override(): string; + // ❌ error + public override get someGetterOverride(): string; + public set someSetter(val: string); + public override set some_setter_override(val: string); + // ❌ error + public override set someSetterOverride(val: string); + } + `, + parserOptions, + options: [ + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: ['memberLike'], + modifiers: ['override'], + format: ['snake_case'], + }, + ], + errors: [ + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Accessor', + name: 'someGetterOverride', + formats: 'snake_case', + }, + }, + { + messageId: 'doesNotMatchFormat', + data: { + type: 'Accessor', + name: 'someSetterOverride', + formats: 'snake_case', + }, + }, + ], + }, ], }); From 75dcdf164d206c5530ba7cc095c4599ec90abe35 Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Mon, 7 Nov 2022 17:49:40 -0600 Subject: [PATCH 21/76] feat(eslint-plugin): [consistent-type-imports] support fixing to inline types (#5050) * feat(eslint-plugin): [consistent-type-imports] support fixing to inline types * first pass fix to simpler fixer * cleanup pass 2 * add test for default import * add some docs * add moar test cases * add failing test * use aImportIsOnlyTypes instead of inlineTypes message * wip * fix for default import inline * fix another case with as * simplify by using existing typeOverValue func * add some commentse * add another test for two imports from same source * better doc with link to 4.5 * fix lint * cleanup comments * Update packages/eslint-plugin/docs/rules/consistent-type-imports.md Co-authored-by: Josh Goldberg * Update packages/eslint-plugin/docs/rules/consistent-type-imports.md Co-authored-by: Josh Goldberg * Update packages/eslint-plugin/docs/rules/consistent-type-imports.md Co-authored-by: Josh Goldberg * Update packages/eslint-plugin/src/rules/consistent-type-imports.ts Co-authored-by: Josh Goldberg * Update packages/eslint-plugin/src/rules/consistent-type-imports.ts Co-authored-by: Josh Goldberg * fix changelog formatting * Update packages/eslint-plugin/docs/rules/consistent-type-imports.md Co-authored-by: Josh Goldberg * try single quotest * cleanup not valid comment anymore * Update packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts Co-authored-by: Josh Goldberg * Update packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts Co-authored-by: Josh Goldberg * rm comment * improve documentation with feedback * add tabs Co-authored-by: Josh Goldberg Co-authored-by: Josh Goldberg --- .../docs/rules/consistent-type-imports.md | 40 +- .../src/rules/consistent-type-imports.ts | 169 +++++++-- .../rules/consistent-type-imports.test.ts | 359 ++++++++++++++++++ 3 files changed, 536 insertions(+), 32 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 745930d0d54..4ea1f755994 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -15,7 +15,7 @@ This allows transpilers to drop imports without knowing the types of the depende This option defines the expected import kind for type-only imports. Valid values for `prefer` are: -- `type-imports` will enforce that you always use `import type Foo from '...'` except referenced by metadata of decorators. It is default. +- `type-imports` will enforce that you always use `import type Foo from '...'` except referenced by metadata of decorators. It is the default. - `no-type-imports` will enforce that you always use `import Foo from '...'`. Examples of **correct** code with `{prefer: 'type-imports'}`, and **incorrect** code with `{prefer: 'no-type-imports'}`. @@ -36,6 +36,44 @@ type T = Foo; const x: Bar = 1; ``` +### `fixStyle` + +This option defines the expected type modifier to be added when an import is detected as used only in the type position. Valid values for `fixStyle` are: + +- `separate-type-imports` will add the type keyword after the import keyword `import type { A } from '...'`. It is the default. +- `inline-type-imports` will inline the type keyword `import { type A } from '...'` and is only available in TypeScript 4.5 and onwards. See [documentation here](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names 'TypeScript 4.5 documentation on type modifiers and import names'). + + + +#### ❌ Incorrect + +```ts +import { Foo } from 'Foo'; +import Bar from 'Bar'; +type T = Foo; +const x: Bar = 1; +``` + +#### ✅ With `separate-type-imports` + +```ts +import type { Foo } from 'Foo'; +import type Bar from 'Bar'; +type T = Foo; +const x: Bar = 1; +``` + +#### ✅ With `inline-type-imports` + +```ts +import { type Foo } from 'Foo'; +import type Bar from 'Bar'; +type T = Foo; +const x: Bar = 1; +``` + + + ### `disallowTypeAnnotations` If `true`, type imports in type annotations (`import()`) are not allowed. diff --git a/packages/eslint-plugin/src/rules/consistent-type-imports.ts b/packages/eslint-plugin/src/rules/consistent-type-imports.ts index 1817018fe7b..a812116f2f8 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-imports.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-imports.ts @@ -4,11 +4,13 @@ import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils'; import * as util from '../util'; type Prefer = 'type-imports' | 'no-type-imports'; +type FixStyle = 'separate-type-imports' | 'inline-type-imports'; type Options = [ { prefer?: Prefer; disallowTypeAnnotations?: boolean; + fixStyle?: FixStyle; }, ]; @@ -19,6 +21,8 @@ interface SourceImports { typeOnlyNamedImport: TSESTree.ImportDeclaration | null; // ImportDeclaration for value-only import only with named imports. valueOnlyNamedImport: TSESTree.ImportDeclaration | null; + // ImportDeclaration for value-only import only with default imports and/or named imports. + valueImport: TSESTree.ImportDeclaration | null; } interface ReportValueImport { node: TSESTree.ImportDeclaration; @@ -79,6 +83,9 @@ export default util.createRule({ disallowTypeAnnotations: { type: 'boolean', }, + fixStyle: { + enum: ['separate-type-imports', 'inline-type-imports'], + }, }, additionalProperties: false, }, @@ -90,12 +97,14 @@ export default util.createRule({ { prefer: 'type-imports', disallowTypeAnnotations: true, + fixStyle: 'separate-type-imports', }, ], create(context, [option]) { const prefer = option.prefer ?? 'type-imports'; const disallowTypeAnnotations = option.disallowTypeAnnotations !== false; + const fixStyle = option.fixStyle ?? 'separate-type-imports'; const sourceCode = context.getSourceCode(); const sourceImportsMap: { [key: string]: SourceImports } = {}; @@ -106,13 +115,15 @@ export default util.createRule({ // prefer type imports ImportDeclaration(node): void { const source = node.source.value; + // sourceImports is the object containing all the specifics for a particular import source, type or value const sourceImports = sourceImportsMap[source] ?? (sourceImportsMap[source] = { source, - reportValueImports: [], - typeOnlyNamedImport: null, - valueOnlyNamedImport: null, + reportValueImports: [], // if there is a mismatch where type importKind but value specifiers + typeOnlyNamedImport: null, // if only type imports + valueOnlyNamedImport: null, // if only value imports with named specifiers + valueImport: null, // if only value imports }); if (node.importKind === 'type') { if ( @@ -122,6 +133,7 @@ export default util.createRule({ specifier.type === AST_NODE_TYPES.ImportSpecifier, ) ) { + // definitely import type { TypeX } sourceImports.typeOnlyNamedImport = node; } } else { @@ -133,6 +145,15 @@ export default util.createRule({ ) ) { sourceImports.valueOnlyNamedImport = node; + sourceImports.valueImport = node; + } else if ( + !sourceImports.valueImport && + node.specifiers.some( + specifier => + specifier.type === AST_NODE_TYPES.ImportDefaultSpecifier, + ) + ) { + sourceImports.valueImport = node; } } @@ -243,14 +264,15 @@ export default util.createRule({ 'Program:exit'(): void { for (const sourceImports of Object.values(sourceImportsMap)) { if (sourceImports.reportValueImports.length === 0) { + // nothing to fix. value specifiers and type specifiers are correctly written continue; } for (const report of sourceImports.reportValueImports) { if ( report.valueSpecifiers.length === 0 && - report.unusedSpecifiers.length === 0 + report.unusedSpecifiers.length === 0 && + report.node.importKind !== 'type' ) { - // import is all type-only, convert the entire import to `import type` context.report({ node: report.node, messageId: 'typeOverValue', @@ -265,12 +287,13 @@ export default util.createRule({ } else { const isTypeImport = report.node.importKind === 'type'; - // we have a mixed type/value import, so we need to split them out into multiple exports + // we have a mixed type/value import or just value imports, so we need to split them out into multiple imports if separate-type-imports is configured const importNames = ( isTypeImport - ? report.valueSpecifiers + ? report.valueSpecifiers // import type { A } from 'roo'; // WHERE A is used in value position : report.typeSpecifiers - ).map(specifier => `"${specifier.local.name}"`); + ) // import { A, B } from 'roo'; // WHERE A is used in type position and B is in value position + .map(specifier => `"${specifier.local.name}"`); const message = ((): { messageId: MessageIds; @@ -294,12 +317,12 @@ export default util.createRule({ if (isTypeImport) { return { messageId: 'someImportsInDecoMeta', - data: { typeImports }, + data: { typeImports }, // typeImports are all the value specifiers that are in the type position }; } else { return { messageId: 'someImportsAreOnlyTypes', - data: { typeImports }, + data: { typeImports }, // typeImports are all the type specifiers in the value position }; } } @@ -310,12 +333,14 @@ export default util.createRule({ ...message, *fix(fixer) { if (isTypeImport) { + // take all the valueSpecifiers and put them on a new line yield* fixToValueImportDeclaration( fixer, report, sourceImports, ); } else { + // take all the typeSpecifiers and put them on a new line yield* fixToTypeImportDeclaration( fixer, report, @@ -396,12 +421,12 @@ export default util.createRule({ } /** - * Returns information for fixing named specifiers. + * Returns information for fixing named specifiers, type or value */ function getFixesNamedSpecifiers( fixer: TSESLint.RuleFixer, node: TSESTree.ImportDeclaration, - typeNamedSpecifiers: TSESTree.ImportSpecifier[], + subsetNamedSpecifiers: TSESTree.ImportSpecifier[], allNamedSpecifiers: TSESTree.ImportSpecifier[], ): { typeNamedSpecifiersText: string; @@ -415,12 +440,12 @@ export default util.createRule({ } const typeNamedSpecifiersTexts: string[] = []; const removeTypeNamedSpecifiers: TSESLint.RuleFix[] = []; - if (typeNamedSpecifiers.length === allNamedSpecifiers.length) { + if (subsetNamedSpecifiers.length === allNamedSpecifiers.length) { // import Foo, {Type1, Type2} from 'foo' // import DefType, {Type1, Type2} from 'foo' const openingBraceToken = util.nullThrows( sourceCode.getTokenBefore( - typeNamedSpecifiers[0], + subsetNamedSpecifiers[0], util.isOpeningBraceToken, ), util.NullThrowsReasons.MissingToken('{', node.type), @@ -451,20 +476,20 @@ export default util.createRule({ ), ); } else { - const typeNamedSpecifierGroups: TSESTree.ImportSpecifier[][] = []; + const namedSpecifierGroups: TSESTree.ImportSpecifier[][] = []; let group: TSESTree.ImportSpecifier[] = []; for (const namedSpecifier of allNamedSpecifiers) { - if (typeNamedSpecifiers.includes(namedSpecifier)) { + if (subsetNamedSpecifiers.includes(namedSpecifier)) { group.push(namedSpecifier); } else if (group.length) { - typeNamedSpecifierGroups.push(group); + namedSpecifierGroups.push(group); group = []; } } if (group.length) { - typeNamedSpecifierGroups.push(group); + namedSpecifierGroups.push(group); } - for (const namedSpecifiers of typeNamedSpecifierGroups) { + for (const namedSpecifiers of namedSpecifierGroups) { const { removeRange, textRange } = getNamedSpecifierRanges( namedSpecifiers, allNamedSpecifiers, @@ -541,7 +566,53 @@ export default util.createRule({ if (!util.isCommaToken(before) && !util.isOpeningBraceToken(before)) { insertText = `,${insertText}`; } - return fixer.insertTextBefore(closingBraceToken, `${insertText}`); + return fixer.insertTextBefore(closingBraceToken, insertText); + } + + /** + * insert type keyword to named import node. + * e.g. + * import ADefault, { Already, type Type1, type Type2 } from 'foo' + * ^^^^ insert + */ + function* fixInsertTypeKeywordInNamedSpecifierList( + fixer: TSESLint.RuleFixer, + typeSpecifiers: TSESTree.ImportSpecifier[], + ): IterableIterator { + for (const spec of typeSpecifiers) { + const insertText = sourceCode.text.slice(...spec.range); + yield fixer.replaceTextRange(spec.range, `type ${insertText}`); + } + } + + function* fixInlineTypeImportDeclaration( + fixer: TSESLint.RuleFixer, + report: ReportValueImport, + sourceImports: SourceImports, + ): IterableIterator { + const { node } = report; + // For a value import, will only add an inline type to named specifiers + const { namedSpecifiers } = classifySpecifier(node); + const typeNamedSpecifiers = namedSpecifiers.filter(specifier => + report.typeSpecifiers.includes(specifier), + ); + + if (sourceImports.valueImport) { + // add import named type specifiers to its value import + // import ValueA, { type A } + // ^^^^ insert + const { namedSpecifiers: valueImportNamedSpecifiers } = + classifySpecifier(sourceImports.valueImport); + if ( + sourceImports.valueOnlyNamedImport || + valueImportNamedSpecifiers.length + ) { + yield* fixInsertTypeKeywordInNamedSpecifierList( + fixer, + typeNamedSpecifiers, + ); + } + } } function* fixToTypeImportDeclaration( @@ -567,13 +638,31 @@ export default util.createRule({ // import Type from 'foo' yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, true); return; + } else if ( + fixStyle === 'inline-type-imports' && + !report.typeSpecifiers.includes(defaultSpecifier) && + namedSpecifiers.length > 0 && + !namespaceSpecifier + ) { + // if there is a default specifier but it isn't a type specifier, then just add the inline type modifier to the named specifiers + // import AValue, {BValue, Type1, Type2} from 'foo' + yield* fixInlineTypeImportDeclaration(fixer, report, sourceImports); + return; } - } else { + } else if (!namespaceSpecifier) { if ( + fixStyle === 'inline-type-imports' && + namedSpecifiers.some(specifier => + report.typeSpecifiers.includes(specifier), + ) + ) { + // import {AValue, Type1, Type2} from 'foo' + yield* fixInlineTypeImportDeclaration(fixer, report, sourceImports); + return; + } else if ( namedSpecifiers.every(specifier => report.typeSpecifiers.includes(specifier), - ) && - !namespaceSpecifier + ) ) { // import {Type1, Type2} from 'foo' yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false); @@ -606,12 +695,25 @@ export default util.createRule({ afterFixes.push(insertTypeNamedSpecifiers); } } else { - yield fixer.insertTextBefore( - node, - `import type {${ - fixesNamedSpecifiers.typeNamedSpecifiersText - }} from ${sourceCode.getText(node.source)};\n`, - ); + // The import is both default and named. Insert named on new line because can't mix default type import and named type imports + if (fixStyle === 'inline-type-imports') { + yield fixer.insertTextBefore( + node, + `import {${typeNamedSpecifiers + .map(spec => { + const insertText = sourceCode.text.slice(...spec.range); + return `type ${insertText}`; + }) + .join(', ')}} from ${sourceCode.getText(node.source)};\n`, + ); + } else { + yield fixer.insertTextBefore( + node, + `import type {${ + fixesNamedSpecifiers.typeNamedSpecifiersText + }} from ${sourceCode.getText(node.source)};\n`, + ); + } } } @@ -736,8 +838,6 @@ export default util.createRule({ closingBraceToken.range[1], ); if (node.specifiers.length > 1) { - // import type Foo from 'foo' - // import type {...} from 'foo' // <- insert yield fixer.insertTextAfter( node, `\nimport type${specifiersText} from ${sourceCode.getText( @@ -794,6 +894,9 @@ export default util.createRule({ } } + // we have some valueSpecifiers intermixed in types that need to be put on their own line + // import type { Type1, A } from 'foo' + // import type { A } from 'foo' const valueNamedSpecifiers = namedSpecifiers.filter(specifier => report.valueSpecifiers.includes(specifier), ); @@ -819,6 +922,8 @@ export default util.createRule({ afterFixes.push(insertTypeNamedSpecifiers); } } else { + // some are types. + // Add new value import and later remove those value specifiers from import type yield fixer.insertTextBefore( node, `import {${ @@ -862,6 +967,8 @@ export default util.createRule({ fixer: TSESLint.RuleFixer, node: TSESTree.ImportSpecifier, ): IterableIterator { + // import { type Foo } from 'foo' + // ^^^^ remove const typeToken = util.nullThrows( sourceCode.getFirstToken(node, isTypeToken), util.NullThrowsReasons.MissingToken('type', node.type), diff --git a/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts b/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts index b1389b26e6b..ee01b29c1b0 100644 --- a/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts +++ b/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts @@ -118,11 +118,80 @@ ruleTester.run('consistent-type-imports', rule, { `, options: [{ prefer: 'no-type-imports' }], }, + ` + import { type A } from 'foo'; + type T = A; + `, ` import { type A, B } from 'foo'; type T = A; const b = B; `, + ` + import { type A, type B } from 'foo'; + type T = A; + type Z = B; + `, + ` + import { B } from 'foo'; + import { type A } from 'foo'; + type T = A; + const b = B; + `, + { + code: ` + import { B, type A } from 'foo'; + type T = A; + const b = B; + `, + options: [{ fixStyle: 'inline-type-imports' }], + }, + { + code: ` + import { B } from 'foo'; + import type A from 'baz'; + type T = A; + const b = B; + `, + options: [{ fixStyle: 'inline-type-imports' }], + }, + { + code: ` + import { type B } from 'foo'; + import type { A } from 'foo'; + type T = A; + const b = B; + `, + options: [{ fixStyle: 'inline-type-imports' }], + }, + { + code: ` + import { B, type C } from 'foo'; + import type A from 'baz'; + type T = A; + type Z = C; + const b = B; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + }, + { + code: ` + import { B } from 'foo'; + import type { A } from 'foo'; + type T = A; + const b = B; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + }, + { + code: ` + import { B } from 'foo'; + import { A } from 'foo'; + type T = A; + const b = B; + `, + options: [{ prefer: 'no-type-imports', fixStyle: 'inline-type-imports' }], + }, // exports ` import Type from 'foo'; @@ -512,6 +581,24 @@ export type Y = { }, ], }, + { + code: ` + import Foo from 'foo'; + let foo: Foo; + `, + output: ` + import type Foo from 'foo'; + let foo: Foo; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'typeOverValue', + line: 2, + column: 9, + }, + ], + }, { code: ` import { A, B } from 'foo'; @@ -1833,5 +1920,277 @@ const b = B; }, ], }, + + // inline-type-imports + { + code: ` + import { A, B } from 'foo'; + let foo: A; + let bar: B; + `, + output: ` + import { type A, type B } from 'foo'; + let foo: A; + let bar: B; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'typeOverValue', + line: 2, + column: 9, + }, + ], + }, + { + code: ` + import { A, B } from 'foo'; + + let foo: A; + B(); + `, + output: ` + import { type A, B } from 'foo'; + + let foo: A; + B(); + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'aImportIsOnlyTypes', + line: 2, + column: 9, + }, + ], + }, + { + code: ` + import { A, B } from 'foo'; + type T = A; + B(); + `, + output: ` + import { type A, B } from 'foo'; + type T = A; + B(); + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'aImportIsOnlyTypes', + line: 2, + column: 9, + }, + ], + }, + { + code: ` + import { A } from 'foo'; + import { B } from 'foo'; + type T = A; + type U = B; + `, + output: ` + import { type A } from 'foo'; + import { type B } from 'foo'; + type T = A; + type U = B; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'typeOverValue', + line: 2, + column: 9, + }, + { + messageId: 'typeOverValue', + line: 3, + column: 9, + }, + ], + }, + { + code: ` + import { A } from 'foo'; + import B from 'foo'; + type T = A; + type U = B; + `, + output: ` + import { type A } from 'foo'; + import type B from 'foo'; + type T = A; + type U = B; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'typeOverValue', + line: 2, + column: 9, + }, + { + messageId: 'typeOverValue', + line: 3, + column: 9, + }, + ], + }, + { + code: ` +import A, { B, C } from 'foo'; +type T = B; +type U = C; +A(); + `, + output: ` +import A, { type B, type C } from 'foo'; +type T = B; +type U = C; +A(); + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'someImportsAreOnlyTypes', + line: 2, + column: 1, + }, + ], + }, + { + code: ` +import A, { B, C } from 'foo'; +type T = B; +type U = C; +type V = A; + `, + output: ` +import {type B, type C} from 'foo'; +import type A from 'foo'; +type T = B; +type U = C; +type V = A; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'typeOverValue', + line: 2, + column: 1, + }, + ], + }, + { + code: ` +import A, { B, C as D } from 'foo'; +type T = B; +type U = D; +type V = A; + `, + output: ` +import {type B, type C as D} from 'foo'; +import type A from 'foo'; +type T = B; +type U = D; +type V = A; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'typeOverValue', + line: 2, + column: 1, + }, + ], + }, + { + code: ` + import { /* comment */ A, B } from 'foo'; + type T = A; + `, + output: ` + import { /* comment */ type A, B } from 'foo'; + type T = A; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'aImportIsOnlyTypes', + line: 2, + column: 9, + }, + ], + }, + { + code: ` + import { B, /* comment */ A } from 'foo'; + type T = A; + `, + output: ` + import { B, /* comment */ type A } from 'foo'; + type T = A; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'aImportIsOnlyTypes', + line: 2, + column: 9, + }, + ], + }, + { + code: ` +import { A, B, C } from 'foo'; +import type { D } from 'deez'; + +const foo: A = B(); +let bar: C; +let baz: D; + `, + output: ` +import { type A, B, type C } from 'foo'; +import type { D } from 'deez'; + +const foo: A = B(); +let bar: C; +let baz: D; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'someImportsAreOnlyTypes', + line: 2, + column: 1, + }, + ], + }, + { + code: ` +import { A, B, type C } from 'foo'; +import type { D } from 'deez'; +const foo: A = B(); +let bar: C; +let baz: D; + `, + output: ` +import { type A, B, type C } from 'foo'; +import type { D } from 'deez'; +const foo: A = B(); +let bar: C; +let baz: D; + `, + options: [{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }], + errors: [ + { + messageId: 'aImportIsOnlyTypes', + line: 2, + column: 1, + }, + ], + }, ], }); From 832cec666d135fbf7e48142dcd5e0ee1013c4f53 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 10 Nov 2022 13:18:19 -0800 Subject: [PATCH 22/76] chore(deps): update dependency lerna to v6.0.3 (#5936) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 828 +++++++++++++++++++++++++-------------------------- 2 files changed, 415 insertions(+), 415 deletions(-) diff --git a/package.json b/package.json index 77e222ad7a8..4726e08400f 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "jest-diff": "^29.0.3", "jest-snapshot": "^29.0.3", "jest-specific-snapshot": "^5.0.0", - "lerna": "6.0.1", + "lerna": "6.0.3", "lint-staged": "^13.0.0", "make-dir": "^3.1.0", "markdownlint-cli": "^0.32.0", diff --git a/yarn.lock b/yarn.lock index 543fa9bbc68..d77fd4dcba5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2288,39 +2288,39 @@ resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b" integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A== -"@lerna/add@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/add/-/add-6.0.1.tgz#6d71084fe7918c96c909bebdc5c27ed6006e09d6" - integrity sha512-cCQIlMODhi3KYyTDOp2WWL4Kj2dKK+MmCiaSf+USrbSWPVVXQGn5Eb11XOMUfYYq3Ula75sWL2urtYwuu8IbmA== - dependencies: - "@lerna/bootstrap" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/filter-options" "6.0.1" - "@lerna/npm-conf" "6.0.1" - "@lerna/validation-error" "6.0.1" +"@lerna/add@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/add/-/add-6.0.3.tgz#341927d00b79ad2a2c0e9aec239b203e5a04fa12" + integrity sha512-EM9hJExG6bV4Hg+XpHTg5nGCuZl3pUEdbYLtyXfMUj/7fpCrUkxB0oESIVhFINVbxHm2pdnUfOxPDHwFSyWBig== + dependencies: + "@lerna/bootstrap" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/filter-options" "6.0.3" + "@lerna/npm-conf" "6.0.3" + "@lerna/validation-error" "6.0.3" dedent "^0.7.0" npm-package-arg "8.1.1" p-map "^4.0.0" pacote "^13.6.1" semver "^7.3.4" -"@lerna/bootstrap@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/bootstrap/-/bootstrap-6.0.1.tgz#2af0b790b9ce426b78f12543159c8506d77afc28" - integrity sha512-a3DWchHFOiRmDN24VTdmTxKvAqw6Msp8pDCWXq4rgOQSFxqyYECd8BYvmy8dTW6LcC4EG0HqTGRguuEaKCasOw== - dependencies: - "@lerna/command" "6.0.1" - "@lerna/filter-options" "6.0.1" - "@lerna/has-npm-version" "6.0.1" - "@lerna/npm-install" "6.0.1" - "@lerna/package-graph" "6.0.1" - "@lerna/pulse-till-done" "6.0.1" - "@lerna/rimraf-dir" "6.0.1" - "@lerna/run-lifecycle" "6.0.1" - "@lerna/run-topologically" "6.0.1" - "@lerna/symlink-binary" "6.0.1" - "@lerna/symlink-dependencies" "6.0.1" - "@lerna/validation-error" "6.0.1" +"@lerna/bootstrap@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/bootstrap/-/bootstrap-6.0.3.tgz#806fae9955f25ef5468dd7752c5d5469e3253fa7" + integrity sha512-51eT07tAiH1oca9dNrrLXXH6PJZFY4zKEYDqLkx+zMCG/LsIUnzEfy4JBe1GXbFasXfM24pG8wLKoj1sj1CR3A== + dependencies: + "@lerna/command" "6.0.3" + "@lerna/filter-options" "6.0.3" + "@lerna/has-npm-version" "6.0.3" + "@lerna/npm-install" "6.0.3" + "@lerna/package-graph" "6.0.3" + "@lerna/pulse-till-done" "6.0.3" + "@lerna/rimraf-dir" "6.0.3" + "@lerna/run-lifecycle" "6.0.3" + "@lerna/run-topologically" "6.0.3" + "@lerna/symlink-binary" "6.0.3" + "@lerna/symlink-dependencies" "6.0.3" + "@lerna/validation-error" "6.0.3" "@npmcli/arborist" "5.3.0" dedent "^0.7.0" get-port "^5.1.1" @@ -2332,100 +2332,100 @@ p-waterfall "^2.1.1" semver "^7.3.4" -"@lerna/changed@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/changed/-/changed-6.0.1.tgz#58614a0c65bfab77fefd142d5edc8282e057ea83" - integrity sha512-b0KzqpNv25ZxH9M/7jtDQaXWUBhVzBVJ8DQ4PjjeoulOCQ+mA9tNQr8UVmeU1UZiaNtNz6Hcy55vyvVvNe07VA== +"@lerna/changed@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/changed/-/changed-6.0.3.tgz#9dfd7ff944b2409c7762a5e376607ea6e5533585" + integrity sha512-VhKl/vVnrY12z2q1it2FkPkRwC3kyZh++kWMNDbMuUqH1kDHuw7KWJjPw6H4LDpoFWj4Q0hPcNRXxJpNiRWD1g== dependencies: - "@lerna/collect-updates" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/listable" "6.0.1" - "@lerna/output" "6.0.1" + "@lerna/collect-updates" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/listable" "6.0.3" + "@lerna/output" "6.0.3" -"@lerna/check-working-tree@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/check-working-tree/-/check-working-tree-6.0.1.tgz#ad71d53941b5c85523499b283e5f44b52eca6276" - integrity sha512-9Ti1EuE3IiJUvvAtFk+Xr9Uw6KehT78ghnI4f/hi4uew5q0Mf2+DMaBNexbhOTpRFBeIq4ucDFhiN091pNkUNw== +"@lerna/check-working-tree@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/check-working-tree/-/check-working-tree-6.0.3.tgz#32fb77c5832926f7a66fd1a77bb81a5f46f4fbc5" + integrity sha512-ulAilI5AHvSVluH4QdcRPBbGH6lKU6OARfJFIgFYm8KoPyMESygYIBKBKuTUuyzfp5DOsASq2NiumBW4rpC7hg== dependencies: - "@lerna/collect-uncommitted" "6.0.1" - "@lerna/describe-ref" "6.0.1" - "@lerna/validation-error" "6.0.1" + "@lerna/collect-uncommitted" "6.0.3" + "@lerna/describe-ref" "6.0.3" + "@lerna/validation-error" "6.0.3" -"@lerna/child-process@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/child-process/-/child-process-6.0.1.tgz#2141f643a4ed7d38fa9270a80403467a353a3b39" - integrity sha512-5smM8Or/RQkHysNFrUYdrCYlhpr3buNpCYU7T2DPYzOWRPm+X5rCvt/dDOcS3UgYT2jEyS86S5Y7pK2X7eXtmg== +"@lerna/child-process@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/child-process/-/child-process-6.0.3.tgz#691040e5e3f64dfe7ef4f4b4d5e6d560e1bef8fc" + integrity sha512-WfFwWdtGA0wvbyq7FB78Gvkd5mVjCGhRoLQY0FIGPQrmZBv3uy7kz5KbRKJlEmoIhVUnFbbV1xURxdqLzNrxoA== dependencies: chalk "^4.1.0" execa "^5.0.0" strong-log-transformer "^2.1.0" -"@lerna/clean@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/clean/-/clean-6.0.1.tgz#e59f94140e577cbb66f76f78794b97778f78a246" - integrity sha512-ZaWPzzYNkJM7Ib2GWPLSELVBf5nRCGOGBtR9DSLKAore0Me876JLgi4h2R+Y2PVyCvT1kmoQKAclnjxdZbCONA== - dependencies: - "@lerna/command" "6.0.1" - "@lerna/filter-options" "6.0.1" - "@lerna/prompt" "6.0.1" - "@lerna/pulse-till-done" "6.0.1" - "@lerna/rimraf-dir" "6.0.1" +"@lerna/clean@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/clean/-/clean-6.0.3.tgz#f3519ef27a59b04b0f0f3553b53990d3fbe3ea48" + integrity sha512-4H+leVVVhwnc/GBOkFBIrLBia+MRm2ETZyXdCNckCJZ/e5tm6XHJLprGMSP2QwhJ0H20r+ciiQGzo3TGjQAEwQ== + dependencies: + "@lerna/command" "6.0.3" + "@lerna/filter-options" "6.0.3" + "@lerna/prompt" "6.0.3" + "@lerna/pulse-till-done" "6.0.3" + "@lerna/rimraf-dir" "6.0.3" p-map "^4.0.0" p-map-series "^2.1.0" p-waterfall "^2.1.1" -"@lerna/cli@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/cli/-/cli-6.0.1.tgz#8a92386702cff815f36104792ad5dc14f11a61a8" - integrity sha512-AuAnUXkBGdts/rmHltrkZucYy11OwYPb/4HM3zxLeq4O30w2ocZIytkOtSkuVKOMPWBZR8b37fNuZBzvxe5OmA== +"@lerna/cli@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/cli/-/cli-6.0.3.tgz#a5115e1af70817a8afc08a646d3a7ae80a179801" + integrity sha512-4J3dOmDGxl32FJJryE65wXR//FOMFRM0osURnr+sylzStpaEwYO24GN1oVl0YIlnGVBuPIBDpr7n0uyjvfn+2A== dependencies: - "@lerna/global-options" "6.0.1" + "@lerna/global-options" "6.0.3" dedent "^0.7.0" npmlog "^6.0.2" yargs "^16.2.0" -"@lerna/collect-uncommitted@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/collect-uncommitted/-/collect-uncommitted-6.0.1.tgz#b93f5acfa9c63fffe41bfaaac02a0efad9180b00" - integrity sha512-qPqwmIlSlf8XBJnqMc+6pz6qXQ0Pfjil70FB2IPvoWbfrLvMI6K3I/AXeub9X5fj5HYqNs1XtwhWHJcMFpJddw== +"@lerna/collect-uncommitted@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/collect-uncommitted/-/collect-uncommitted-6.0.3.tgz#645d24f60d2a47edebef7645cf65c6064cecc025" + integrity sha512-kMKL+U6fIMIHMENez6HrZEYZum+YObhmPzRr/5kkuaYqKPw2up/z1dHYQ/+w+tvzavGP15VKAWy/tZ0WsMuTWw== dependencies: - "@lerna/child-process" "6.0.1" + "@lerna/child-process" "6.0.3" chalk "^4.1.0" npmlog "^6.0.2" -"@lerna/collect-updates@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/collect-updates/-/collect-updates-6.0.1.tgz#7b4be193ee51a72ccedc20acf845fe32fdee9ee2" - integrity sha512-OwRcLqD1N5znlZM/Ctf031RDkodHVO62byiD35AbHGoGM2EI2TSYyIbqnJ8QsQJMB05/KhIBndL8Mpcdle7/rg== +"@lerna/collect-updates@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/collect-updates/-/collect-updates-6.0.3.tgz#fbfde0ec93b59c7868f49dc985a06d472e4f6dd1" + integrity sha512-qLuCHaHlVHu/tkdnncG6bQZHz9IFfZ6i7lexWfFnQnZ/aLEY7dVnFUde1jbsTFNMhJesKEbXJshXRcTcplDH6Q== dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/describe-ref" "6.0.1" + "@lerna/child-process" "6.0.3" + "@lerna/describe-ref" "6.0.3" minimatch "^3.0.4" npmlog "^6.0.2" slash "^3.0.0" -"@lerna/command@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/command/-/command-6.0.1.tgz#a429e724237bc3c4a735e8eaef9816f2203cb7dc" - integrity sha512-V9w8M7pMU7KztxaL0+fetTSQYTa12bhTl86ll9VjlgYZ5qUAXk9E42Y8hbVThyYtHEhkRnIMinkWsmH/9YKU/A== - dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/package-graph" "6.0.1" - "@lerna/project" "6.0.1" - "@lerna/validation-error" "6.0.1" - "@lerna/write-log-file" "6.0.1" +"@lerna/command@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/command/-/command-6.0.3.tgz#5c82c388cb2e2a401f1b00bf7454a15458a6c91e" + integrity sha512-iFkIQKLy+Ef2Kf20wOKBdkCA5J64Wjgr3XC62ZdrlDkx6wydfcfJMiXx2bhRqNKMe1cHxlBKGoRKzy8J+tBrHw== + dependencies: + "@lerna/child-process" "6.0.3" + "@lerna/package-graph" "6.0.3" + "@lerna/project" "6.0.3" + "@lerna/validation-error" "6.0.3" + "@lerna/write-log-file" "6.0.3" clone-deep "^4.0.1" dedent "^0.7.0" execa "^5.0.0" is-ci "^2.0.0" npmlog "^6.0.2" -"@lerna/conventional-commits@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/conventional-commits/-/conventional-commits-6.0.1.tgz#72dd55aadc7c20eca5af3d03cdcfb613964dafc4" - integrity sha512-6oIGEZKy1GpooW28C0aEDkZ/rVkqpX44knP8Jyb5//1054QogqPhGC5q6J0lZxyhun8dQkpF6XTHlIintI8xow== +"@lerna/conventional-commits@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/conventional-commits/-/conventional-commits-6.0.3.tgz#34ecf027b41b1d5182886b6b4c7b674d22897dd7" + integrity sha512-TZof9i0u9TK/Q7LEErjMQAMLf++MjO9NYG81sAuUaNKHMchUOmlFKtJmbT4/JjmgnBX5W0pCUF6DBxr/Bdjj9g== dependencies: - "@lerna/validation-error" "6.0.1" + "@lerna/validation-error" "6.0.3" conventional-changelog-angular "^5.0.12" conventional-changelog-core "^4.2.4" conventional-recommended-bump "^6.1.0" @@ -2436,24 +2436,24 @@ pify "^5.0.0" semver "^7.3.4" -"@lerna/create-symlink@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/create-symlink/-/create-symlink-6.0.1.tgz#5a9f75f8e5c0d83c39d70240f51284cc5d6770ad" - integrity sha512-ZmLx9SP5De6u1xkD7Z6gMMFuyLKCb+2bodreFe7ryOVP3cOLbmNOmgMgj+gtUgIwIv7BDwX3qFWlPY6B3VW3hQ== +"@lerna/create-symlink@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/create-symlink/-/create-symlink-6.0.3.tgz#e651eb4c304e921bb7f83cbeae7a1af6329f284d" + integrity sha512-myCpuQZ4yYJ5sD+xZiyQHfONBIWlQnM3crIlAvObRYs1U+HwniO9YWk0HcW9dyzplwaYo+Vn55mdi67pTdsdDg== dependencies: cmd-shim "^5.0.0" fs-extra "^9.1.0" npmlog "^6.0.2" -"@lerna/create@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/create/-/create-6.0.1.tgz#7905cef9196cb6a1caff5d7cd78a46fc7ea635a9" - integrity sha512-VuTdvBJDzvAaMBYoKTRMBQC+nfwnihxdA/ekUqBD+W8MMsqPLCGCneyl7JK9RaSSib/10LyRDEmfo79UAndcgQ== +"@lerna/create@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/create/-/create-6.0.3.tgz#525b2e5702a61cee7f44928fdf889474dfa6a615" + integrity sha512-mq3D5laUMe6DWhCoWS0mYJw9PZez/8up81860lk5m7Zojk1Ataa08ZWtGhBgP+p77piNRvmjN89hhjkWiXG6ng== dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/npm-conf" "6.0.1" - "@lerna/validation-error" "6.0.1" + "@lerna/child-process" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/npm-conf" "6.0.3" + "@lerna/validation-error" "6.0.3" dedent "^0.7.0" fs-extra "^9.1.0" init-package-json "^3.0.2" @@ -2467,218 +2467,218 @@ validate-npm-package-name "^4.0.0" yargs-parser "20.2.4" -"@lerna/describe-ref@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/describe-ref/-/describe-ref-6.0.1.tgz#e9277bcc3c1c839fc7305b808f9dd02a5404aaf8" - integrity sha512-PcTVt4qgAXUPBtWHyqixtwE/eXe56+DFRnfTcJlb4x5F7LJ+7VNpdR/81qfP89Xj10U5IjELXbXmriz1KMwhfw== +"@lerna/describe-ref@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/describe-ref/-/describe-ref-6.0.3.tgz#f7e5603d686b8f58d836ddc0fb8612fceae9fe39" + integrity sha512-3gj6r9PK+c5SfHQr2j8MQ3qb6xQTrX8KvvGhe3YDW8h3jxx9SAGao8zuvzjI3tVpLx7ZSbxmHqMpyUmnLh5kuw== dependencies: - "@lerna/child-process" "6.0.1" + "@lerna/child-process" "6.0.3" npmlog "^6.0.2" -"@lerna/diff@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/diff/-/diff-6.0.1.tgz#e8c5d541d74a9aa13a4ac6745f2f0d9531207fd1" - integrity sha512-/pGXH9txA8wX1YJ/KOBXzx0Z2opADBW4HKPCxxHAu+6dTGMbKABDljVT5Np3UpfIrAGDE5fTuf0aGL4vkKUWrg== +"@lerna/diff@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/diff/-/diff-6.0.3.tgz#6d9bbde092a605e7aa2b9ab69ce6104eec5a0935" + integrity sha512-9syquyKF2oxg0fF736RWT2cf3Oyk4eRXRUNzT0hF0DL/8frQ98H+gF3ftIFVzz1bfPbXtubzBbLDi29bGEG3bQ== dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/validation-error" "6.0.1" + "@lerna/child-process" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/validation-error" "6.0.3" npmlog "^6.0.2" -"@lerna/exec@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/exec/-/exec-6.0.1.tgz#d2d0785c46b7ceb3758fe75bb6d95d177a0a0ec3" - integrity sha512-x9puoI3091Alp45w7XOGRxThOw45p+tWGPR5TBCEQiiH7f8eF9Dc4WX5HXf31ooK6NmD40eKPYhBgy8oQnJY9w== - dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/filter-options" "6.0.1" - "@lerna/profiler" "6.0.1" - "@lerna/run-topologically" "6.0.1" - "@lerna/validation-error" "6.0.1" +"@lerna/exec@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/exec/-/exec-6.0.3.tgz#01de1eed611879c73b3ec2b2385256a709ef7bd0" + integrity sha512-4xKTXPQe3/0hrwCao7evcQfaacfROhVkR2zfnQEA+rkKRiV6ILWdvu9jCxI7DMkzoh4DgABVuGAv84CeraunMg== + dependencies: + "@lerna/child-process" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/filter-options" "6.0.3" + "@lerna/profiler" "6.0.3" + "@lerna/run-topologically" "6.0.3" + "@lerna/validation-error" "6.0.3" p-map "^4.0.0" -"@lerna/filter-options@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/filter-options/-/filter-options-6.0.1.tgz#4dbd29a31fb2ac228f72c51b223f17623d1f2c71" - integrity sha512-6KxbBI/2skRl/yQdjugQ1PWrSLq19650z8mltF0HT7B686fj7LlDNtESFOtY6iZ8IPqKBkIavOP0DPmJZd7Szw== +"@lerna/filter-options@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/filter-options/-/filter-options-6.0.3.tgz#9362a2b517be5bc9851678bc7a972e3697d02aaf" + integrity sha512-6WjtXo1nNfOIYxjysGgjnCUqAbIqvoIIyQznLQYPsKN/6NN4U7sXr0P3nbaEgBZ2NHeV+seLWA/wraJ1zDaD4Q== dependencies: - "@lerna/collect-updates" "6.0.1" - "@lerna/filter-packages" "6.0.1" + "@lerna/collect-updates" "6.0.3" + "@lerna/filter-packages" "6.0.3" dedent "^0.7.0" npmlog "^6.0.2" -"@lerna/filter-packages@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/filter-packages/-/filter-packages-6.0.1.tgz#07f10dc78e852bbba44843b785ebc16f386cedaa" - integrity sha512-2bKhexeF07Urs2b0xYX2OgYUN0EzmS2FSgvw0KT6He48PGOkqgJjU7PIiWdPyOvZdukwm07qXTmJZulAHftceA== +"@lerna/filter-packages@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/filter-packages/-/filter-packages-6.0.3.tgz#db19b3d5f430ca2ae5bacb5b7e140798a905c3c9" + integrity sha512-UlLgondhCpy7mzZWpOoUy8OlLux8YIqw07Obba0TvVLzrVIGIPIeXhqleRchUGVRV1vfQJ2d3vCTx31s1e/V4g== dependencies: - "@lerna/validation-error" "6.0.1" + "@lerna/validation-error" "6.0.3" multimatch "^5.0.0" npmlog "^6.0.2" -"@lerna/get-npm-exec-opts@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/get-npm-exec-opts/-/get-npm-exec-opts-6.0.1.tgz#c766588d030c0ec7170650808957998e8ad70831" - integrity sha512-y2T+ODP8HNzHQn1ldrrPW+n823fGsN2sY0r78yURFxYZnxA9ZINyQ6IAejo5LqHrYN8Qhr++0RHo2tUisIHdKg== +"@lerna/get-npm-exec-opts@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/get-npm-exec-opts/-/get-npm-exec-opts-6.0.3.tgz#d92a6461a626b79167fd2bc11bae38ee6154b965" + integrity sha512-zmKmHkXzmFQIBh2k9rCwzSkearKD+Pz1GypdJ0hAehemnabtW5QQKoGFsGh+7i5mOP0JBUl5kXTYTnwRGOWmYQ== dependencies: npmlog "^6.0.2" -"@lerna/get-packed@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/get-packed/-/get-packed-6.0.1.tgz#d31c10ec10658eeee4306886c100cd9600d6dd78" - integrity sha512-Z/5J5vbjdeGqZcPvUSiszvyizHdsTRiFlpPORWK3YfIsHllUB7QZnVHLg92UnSJrpPE0O1gH+k6ByhhR+3qEdA== +"@lerna/get-packed@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/get-packed/-/get-packed-6.0.3.tgz#c5b016a5cbd9a9472b76a3d879b229982248dacf" + integrity sha512-NX/Ifi/A7iTXasfBioyv/nQ8+IC4gE1SEAuE39/ExGviOM3Jkk5EmeCqwAbhZyhYkxoDBQDJJvagQ5DobpfS7g== dependencies: fs-extra "^9.1.0" ssri "^9.0.1" tar "^6.1.0" -"@lerna/github-client@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/github-client/-/github-client-6.0.1.tgz#081d13c2debf312d0e5a2bb2fad6e0c69e1501d6" - integrity sha512-UA7V3XUunJnrfCL2eyW9QsCjBWShv4dCRGUITXmpQJrNIMZIqVbBJzqN9LVHDNc/hEVZGt0EjtHWdpFCgD4ypg== +"@lerna/github-client@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/github-client/-/github-client-6.0.3.tgz#3b6f0016a962d5790396a5b9b80f8b73aae46709" + integrity sha512-wMOKH3FIDdE5T8UF88gvhUEBEFD9IUseFHqYt19hgzQyZxAx/hQQE2lqAEosYThPXqtKntIPKQGAfl0gquAMFQ== dependencies: - "@lerna/child-process" "6.0.1" + "@lerna/child-process" "6.0.3" "@octokit/plugin-enterprise-rest" "^6.0.1" "@octokit/rest" "^19.0.3" git-url-parse "^13.1.0" npmlog "^6.0.2" -"@lerna/gitlab-client@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/gitlab-client/-/gitlab-client-6.0.1.tgz#1863b621a1530bc482113cac8791247664dedb2a" - integrity sha512-yyaBKf/OqBAau6xDk1tnMjfkxRpC/j3OwUyXFFGfJFSulWRHpbHoFSfvIgOn/hkjAr9FfHC7TXItRg8qdm38Wg== +"@lerna/gitlab-client@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/gitlab-client/-/gitlab-client-6.0.3.tgz#59b592572dc640f1aa4d89a1393e29478e45ddc8" + integrity sha512-dBZiTsiHJ1j3tkW9JKSqCCZCk6aBiYaU9R/dSnpoPb6ZRthgoMGxtnfdk/1CKZlDargAu12XLJmcXLi7+UbyPg== dependencies: node-fetch "^2.6.1" npmlog "^6.0.2" -"@lerna/global-options@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/global-options/-/global-options-6.0.1.tgz#83061d85759c105120ff55716959642ba6eb0eea" - integrity sha512-vzjDI3Bg2NR+cSgfjHWax2bF1HmQYjJF2tmZlT/hJbwhaVMIEnhzHnJ9Yycmm98cdV77xEMlbmk5YD7xgFdG2w== +"@lerna/global-options@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/global-options/-/global-options-6.0.3.tgz#e878d45b3ed4b14efecd37306f5e876779d8e2c8" + integrity sha512-XE22Mogzjh8w1rr07hALq40kmPuCr25cQ+K0OwYEiPsyH1dpOM7PSkP4qdT1l2UlWNM64LjgJtnjZ9hsx282VQ== -"@lerna/has-npm-version@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/has-npm-version/-/has-npm-version-6.0.1.tgz#ed27a27cad2090069feb3108b105ceec765bec5e" - integrity sha512-ol1onJaauMXK0cQsfRX2rvbhNRyNBY9Ne5trrRjfMROa7Tnr8c3I4+aKQs7m4z1JdWaGBV4xBH+NSZ/esPuaWA== +"@lerna/has-npm-version@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/has-npm-version/-/has-npm-version-6.0.3.tgz#db16127ead4819d6cec97cf0597e392def886ee3" + integrity sha512-azZJkKPUWmfZf4AR40t9L6+utZaaCcZcXHOw/vHhmpn9GpZuc8Ck5cM5+8w9bgMglz0YwvTTWvutY2/mCnN5jA== dependencies: - "@lerna/child-process" "6.0.1" + "@lerna/child-process" "6.0.3" semver "^7.3.4" -"@lerna/import@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/import/-/import-6.0.1.tgz#9e869d6bbe82446ee3620c4310ca6232881b7952" - integrity sha512-GrTtIWUCnDf+FqRjenV2OKWU+khoZj0h/etgfXus45PBO2+V/SkkzIY4xof23XphiydUYrSrYtwx2i1aEmk3Wg== - dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/prompt" "6.0.1" - "@lerna/pulse-till-done" "6.0.1" - "@lerna/validation-error" "6.0.1" +"@lerna/import@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/import/-/import-6.0.3.tgz#d881cd2c4420cb91a701fc4fb43da3e70cb9335f" + integrity sha512-AWSwoS9e5udSrJ7E15rR+8V7Hnhli4+3IHh658bpvcGvsIntL7hBZucqWiKRMOmrsafncaBpLkfFgdiyGwy1Pw== + dependencies: + "@lerna/child-process" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/prompt" "6.0.3" + "@lerna/pulse-till-done" "6.0.3" + "@lerna/validation-error" "6.0.3" dedent "^0.7.0" fs-extra "^9.1.0" p-map-series "^2.1.0" -"@lerna/info@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/info/-/info-6.0.1.tgz#68395061ffbd81c7716d60b99b5220c90ade2862" - integrity sha512-QEW7JtJjoR1etUrcft7BnrwPZFHE2JPmt2DoSvSmLISLyy+HlmdXHK+p6Ej3g1ql8gS0GWCacgwmlRZ27CDp5A== +"@lerna/info@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/info/-/info-6.0.3.tgz#b22af49db401580d8e46bf99be07de5c71fab000" + integrity sha512-fqFGejIjjHN9obKUiWgmkknDJliyyRDbv/g6TMvQptxwiGfFBjR55TSPdKyUi9XslIQL5HWMYU7NWzZPiilk/A== dependencies: - "@lerna/command" "6.0.1" - "@lerna/output" "6.0.1" + "@lerna/command" "6.0.3" + "@lerna/output" "6.0.3" envinfo "^7.7.4" -"@lerna/init@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/init/-/init-6.0.1.tgz#babee56707bd19b3c1b82967e3360d1083c04cf9" - integrity sha512-zOMrSij09LSAVUUujpD3y32wkHp8dQ+/dVCp4USlfcGfI+kIPc5prkYCGDO8dEcqkze0pMfDMF23pVNvAf9g7w== +"@lerna/init@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/init/-/init-6.0.3.tgz#48e259c90712792bd5cdc21fa5602ae7083b143d" + integrity sha512-PmEmIJNNpXkGtEINBO5wfFrOlipAwY/4k674mbBWAfVJX+Affyx8yMcnMM28oDnFwe8gi12w5oRI0JcxcjpCFg== dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/project" "6.0.1" + "@lerna/child-process" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/project" "6.0.3" fs-extra "^9.1.0" p-map "^4.0.0" write-json-file "^4.3.0" -"@lerna/link@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/link/-/link-6.0.1.tgz#a94cf3aead92538835d955c6de281c65097f3471" - integrity sha512-VXZ77AWsJCycTu219ZLUHyRzMd5hgivLk5ZyBD1s/emArFvdEmGLscj2RXn3P3w/951b+DNG2Zbi6nek0iJ6DA== +"@lerna/link@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/link/-/link-6.0.3.tgz#364387ba44a347e3dde41d4925d04e42aeb583d9" + integrity sha512-jVTk8QWoVb+gPSkLm6XLtEKdOyqH4WwpOatSZ5zMgiRfjGDiwxCc3dB994JFPJ5FEnr9qCwqXFKjIqef7POIyQ== dependencies: - "@lerna/command" "6.0.1" - "@lerna/package-graph" "6.0.1" - "@lerna/symlink-dependencies" "6.0.1" - "@lerna/validation-error" "6.0.1" + "@lerna/command" "6.0.3" + "@lerna/package-graph" "6.0.3" + "@lerna/symlink-dependencies" "6.0.3" + "@lerna/validation-error" "6.0.3" p-map "^4.0.0" slash "^3.0.0" -"@lerna/list@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/list/-/list-6.0.1.tgz#ab6d056c5d7b99ca0ed6a17d48bf907afd9d970a" - integrity sha512-M9Vneh866E1nlpU88rcUMLR+XTVi3VY0fLPr1OqXdYF+eTe6RkEHUQj8HIk94Rnt02HsWc4+FO31T4i5sf+PaA== +"@lerna/list@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/list/-/list-6.0.3.tgz#83c3fd2b6e4a31e804737a472df15e414819ed66" + integrity sha512-5cQHJ2GAeN2/GV6uMJ4CVIQa3YOcmuNGqzr0DWwatR+5tire6dxFu5uY9Kjn2PYjmFUlwFwVgZzqRrSKPPPiVw== dependencies: - "@lerna/command" "6.0.1" - "@lerna/filter-options" "6.0.1" - "@lerna/listable" "6.0.1" - "@lerna/output" "6.0.1" + "@lerna/command" "6.0.3" + "@lerna/filter-options" "6.0.3" + "@lerna/listable" "6.0.3" + "@lerna/output" "6.0.3" -"@lerna/listable@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/listable/-/listable-6.0.1.tgz#444e81f6642c198d116e9e6b86d96d10ddf2e147" - integrity sha512-+xEByVX0sbnBW3EBu3XCg71Bz9/dahncmCjNK0kVnZLnQZzfULCndaQeSt+f9KO0VCs8h1tnXdo2uLPm4lThnw== +"@lerna/listable@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/listable/-/listable-6.0.3.tgz#9460d5efce0850985a9ade03b277184c22d744be" + integrity sha512-7EDzDMc22A/U4O1tCfLzb7MoFQVwwfv6E4F8JSilRupd7mp+2tMi7kvrwS5Dk5imNlHia4e5T0fVWXDUnIO2Sg== dependencies: - "@lerna/query-graph" "6.0.1" + "@lerna/query-graph" "6.0.3" chalk "^4.1.0" columnify "^1.6.0" -"@lerna/log-packed@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/log-packed/-/log-packed-6.0.1.tgz#20fe38b5f18e65392b42bf84cfdda0afc0b62330" - integrity sha512-HTJdZzfBbb5jyk/QU2O6o+yaWRwLoaPruhK+Q3ESTzQ2mlNCr0CI4UKWDcWURWx0EsVsYqsoUHuPZInpIHqCnA== +"@lerna/log-packed@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/log-packed/-/log-packed-6.0.3.tgz#2bcd152613de9abb938e5acde0d62d9a7f1645da" + integrity sha512-MCGAaaywfs8Z0eeG4mhP1u1ma+ORO8c9gGgtpX0LkjJ9HlE23BkCznC8VrJSVTqChtU4tkVp/38hhwEzZmcPFA== dependencies: byte-size "^7.0.0" columnify "^1.6.0" has-unicode "^2.0.1" npmlog "^6.0.2" -"@lerna/npm-conf@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/npm-conf/-/npm-conf-6.0.1.tgz#fa242a36ef687c7b5207a9d9a85b9e7a4f38bdc5" - integrity sha512-VjxODCnl6QJGoQ8z8AWEID1GO9CtCr2yRyn6NoRdBOTYmzI5KhBBM+nWmyMSOUe0EZI+K5j04/GRzKHg2KXTAQ== +"@lerna/npm-conf@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/npm-conf/-/npm-conf-6.0.3.tgz#94f7c23fe19e5406913e08f160e244a89e309204" + integrity sha512-lX4nAJgScfDmmdPVM9rOO6AzwCY9UPjuNpY6ZpMYkg/FIr1dch5+MFjexpan4VL2KRBNMWUYpDk3U/e2V+7k/A== dependencies: config-chain "^1.1.12" pify "^5.0.0" -"@lerna/npm-dist-tag@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/npm-dist-tag/-/npm-dist-tag-6.0.1.tgz#4718bdedd82f375ba619319070b694f1113e627b" - integrity sha512-jJKDgnhj6xGqSWGcbwdcbPtoo2m4mHRwqu8iln9e3TMOEyUO9aA4uvd0/18tEAsboOMiLUhhcQ8709iKv21ZEA== +"@lerna/npm-dist-tag@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/npm-dist-tag/-/npm-dist-tag-6.0.3.tgz#7dda3da557c1c9a729c2942de5eda26e83497dfa" + integrity sha512-wjbVPZQq1bdfikldEJ6TICikKhVh8gOWPsqR0iTj5iCDRUAiQM5HscrCApTIrB/hASyKV2xG60ruCpMG2Qo6AQ== dependencies: - "@lerna/otplease" "6.0.1" + "@lerna/otplease" "6.0.3" npm-package-arg "8.1.1" npm-registry-fetch "^13.3.0" npmlog "^6.0.2" -"@lerna/npm-install@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/npm-install/-/npm-install-6.0.1.tgz#5d6f0c62b34f2bfeb8f20b81b08f01ca0d3ed60b" - integrity sha512-saDJSyhhl/wxgZSzRx2/pr0wsMR+hZpdhLGd1lZgo5XzLq3ogK+BxPFz3AK3xhRnNaMq96gDQ3xmeetoV53lwQ== +"@lerna/npm-install@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/npm-install/-/npm-install-6.0.3.tgz#6ea619ddbbe2c995477209ebf8d21fd46dd87ff5" + integrity sha512-mBypvdtt1feL7L6f8++/tChn/5bM+KbYX06WXjW3yUT81o9geg6p7aaZoxfP6A8ff5XVsTFFL7j86MwPxTsTQQ== dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/get-npm-exec-opts" "6.0.1" + "@lerna/child-process" "6.0.3" + "@lerna/get-npm-exec-opts" "6.0.3" fs-extra "^9.1.0" npm-package-arg "8.1.1" npmlog "^6.0.2" signal-exit "^3.0.3" write-pkg "^4.0.0" -"@lerna/npm-publish@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/npm-publish/-/npm-publish-6.0.1.tgz#ffbca4be5b971df978a60917460ee8f28b1c62b7" - integrity sha512-hgzF9fOfp010z7PJtqNLxNXiHr6u4UDVwiX8g22rhJKBh9Ekrq7N9NS3mF0l+RcleRU/jJKYtZ0Ci3fICaaRUg== +"@lerna/npm-publish@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/npm-publish/-/npm-publish-6.0.3.tgz#6c34b566c65fb6131a2bf91e518b58be65ffda41" + integrity sha512-RpjnUy7wWIWu7DJB2NQJ8rNgKz+yPoIXpzYOktIjb7gUrL+Ks4KjfbrgGuYk2nWFUEAzJlsOSJ8ggAQUoNIL9Q== dependencies: - "@lerna/otplease" "6.0.1" - "@lerna/run-lifecycle" "6.0.1" + "@lerna/otplease" "6.0.3" + "@lerna/run-lifecycle" "6.0.3" fs-extra "^9.1.0" libnpmpublish "^6.0.4" npm-package-arg "8.1.1" @@ -2686,85 +2686,85 @@ pify "^5.0.0" read-package-json "^5.0.1" -"@lerna/npm-run-script@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/npm-run-script/-/npm-run-script-6.0.1.tgz#3a255aa6f37a5e2369a37a8ddcb2709f84019ed1" - integrity sha512-K+D4LEoVRuBoKRImprkVRHIORu0xouX+c6yI1B93KWHKJ60H8qCeB0gQkA30pFALx3qG07bXVnFmfK9SGQXD3Q== +"@lerna/npm-run-script@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/npm-run-script/-/npm-run-script-6.0.3.tgz#5a2054d8c9317d5cfe7f2437ad835ae3e9efae03" + integrity sha512-+IEo8BYBdyEzgdqHCw3sr4ZxAM9g7SoSdo+oskXyrwD8zScH+OadAZz+DukCad8kXlaSPWSNEc42biP2o611Ew== dependencies: - "@lerna/child-process" "6.0.1" - "@lerna/get-npm-exec-opts" "6.0.1" + "@lerna/child-process" "6.0.3" + "@lerna/get-npm-exec-opts" "6.0.3" npmlog "^6.0.2" -"@lerna/otplease@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/otplease/-/otplease-6.0.1.tgz#da5467c603565940c1f91e65d077abf25d96df7f" - integrity sha512-RrP8GtfE9yz37GuuCFqddR3mVIQc1ulUpAaaDNK4AOTb7gM0aCsTN7V2gCGBk1zdIsBuvNvNqt5jpWm4U6/EAA== +"@lerna/otplease@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/otplease/-/otplease-6.0.3.tgz#0523f396c83b4f2c3141824569b5827903489808" + integrity sha512-bNQn6IRrMJ8D6yF9v52KHiWD/XDB7ZkN2ziQjPwwOBcbzoVrDRCar91HQK7ygudPgmyjQNQZOrZqGlSTrh/wqA== dependencies: - "@lerna/prompt" "6.0.1" + "@lerna/prompt" "6.0.3" -"@lerna/output@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/output/-/output-6.0.1.tgz#5e301ad0bed607ee139cf207fd75ed1e5fac7908" - integrity sha512-4jZ3fgaCbnsTZ353/lXE/3w20Cge6G3iUoESVip+JE2yhZ8rWgPISG8RFR0YGEtSgq2yC9AgGnGlvmOnAc4SAQ== +"@lerna/output@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/output/-/output-6.0.3.tgz#582f6785193f2bb3d4e059f5276bcc7bfd8e01b5" + integrity sha512-/x7Bv4MVRwBJM6UVbfUYE1wjTGNUEnpFCHNc15MCUU3VY9O/Y1ZYq7iZHkYGMT9BmNeMS64fHBkDEwoqoJn/vA== dependencies: npmlog "^6.0.2" -"@lerna/pack-directory@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/pack-directory/-/pack-directory-6.0.1.tgz#4a0bf61b7cb1b1b3f1fb95afec987a7c63ff9f95" - integrity sha512-vNgS5Rs7s6khOYuHE5nTds0VDfHBH8YNGvV1s0yGAg/Zkivi7bOTs8jDQFiYhQX3HOTC1/85BLhGQ3zcDHlrew== +"@lerna/pack-directory@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/pack-directory/-/pack-directory-6.0.3.tgz#90b7e89420ffad96807b001455bee38ae04e449e" + integrity sha512-LVs/q6Dn1kXIxHA80e/Jo9AmAsesPs7TbBAxZ40lHXhJFvvFgx0r2bY+r3eV+77sziGmyKVBorgcbkEfFehfZw== dependencies: - "@lerna/get-packed" "6.0.1" - "@lerna/package" "6.0.1" - "@lerna/run-lifecycle" "6.0.1" - "@lerna/temp-write" "6.0.1" + "@lerna/get-packed" "6.0.3" + "@lerna/package" "6.0.3" + "@lerna/run-lifecycle" "6.0.3" + "@lerna/temp-write" "6.0.3" npm-packlist "^5.1.1" npmlog "^6.0.2" tar "^6.1.0" -"@lerna/package-graph@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/package-graph/-/package-graph-6.0.1.tgz#db72ab9ed45933d1518de7f7389a6c79e6059336" - integrity sha512-OMppRWpfSaI6HO/Tc5FVpNefgOsCc3/DzaMLme6QTTpbEwD3EhvQ3Xx0MgsGMPdmZhWp/WOoAJsVRnLa+l03gg== +"@lerna/package-graph@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/package-graph/-/package-graph-6.0.3.tgz#cc6452c9935569104ccf1ae600d48f325ca523b3" + integrity sha512-Xf4FxCpCFB2vSI+D/LR3k+ueSmam5Tx7LRbGiZnzdfXPvPqukZfcAXHLZbSzuJiv5NKVyG/VJjZk4SCogjrFTQ== dependencies: - "@lerna/prerelease-id-from-version" "6.0.1" - "@lerna/validation-error" "6.0.1" + "@lerna/prerelease-id-from-version" "6.0.3" + "@lerna/validation-error" "6.0.3" npm-package-arg "8.1.1" npmlog "^6.0.2" semver "^7.3.4" -"@lerna/package@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/package/-/package-6.0.1.tgz#cb950e574b1ea3ef5cd8cf62b3c4308f6c869122" - integrity sha512-vCwyiLVJ4K3SR6KZleglq1dUXIiYGmk3b+NrFWP/Z3dhVE0C+RqgxSsAS4aaUNMSO2KSI0dBdce7BT/D+FdpIQ== +"@lerna/package@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/package/-/package-6.0.3.tgz#7211f7e3d1e1b4a22c666b9abd2ebb4edebc9cfa" + integrity sha512-UbaZSRT3lTmncmPCws0V6XcZhc0GLRm8LtspxyLeDjhyP0EabKAbaB3HVCelPn69CM81UtP8CLkTh+NpUNH2Aw== dependencies: load-json-file "^6.2.0" npm-package-arg "8.1.1" write-pkg "^4.0.0" -"@lerna/prerelease-id-from-version@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/prerelease-id-from-version/-/prerelease-id-from-version-6.0.1.tgz#a47980aa6c78deaa36430d03b6300bc889960b50" - integrity sha512-aZBs/FinztKjNXlk0cW99FpABynZzZwlmJuW4h9nMrQPgWoaDAERfImbefIH/lcpxdRuuGtClyZUFBOSq8ppfg== +"@lerna/prerelease-id-from-version@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/prerelease-id-from-version/-/prerelease-id-from-version-6.0.3.tgz#17f50960fb7df1b3f8eb4e36b86c5917f1e0fab4" + integrity sha512-mgDo6L93mlcg7GDgWZfRGxHmR5xFPQSMQJZeyU/5VY6sCbTnwTDSpYOoce6m71E4v15iJ/G5EKIchq8yVUIBBw== dependencies: semver "^7.3.4" -"@lerna/profiler@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/profiler/-/profiler-6.0.1.tgz#2b7a043e6999823ad97a7ddaea0ed7f338032f92" - integrity sha512-vZrgF5pDhYWY/Gx7MjtyOgTVMA6swDV2+xPZwkvRD1Z0XpWEIn5d79zRN/1SBpdMNozC7Lj++1oEbCGNWhy/ow== +"@lerna/profiler@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/profiler/-/profiler-6.0.3.tgz#cc9ba5ce9bd78fcc47ad105380877341cba17b3b" + integrity sha512-tkFZEAALPtPOzcEZlH554SHH4rMORmpWH45mF3Py3mpy+HpQXLZmYlxot+wr3jPXkXQzwaIgDe0DMYJhhC8T9A== dependencies: fs-extra "^9.1.0" npmlog "^6.0.2" upath "^2.0.1" -"@lerna/project@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/project/-/project-6.0.1.tgz#0d4a6dbca1943478d554d4a3a610968caf9b303a" - integrity sha512-/n2QuAEgImbwUqrJND15FxYu29p/mLTUpL/8cSg6IUlOQRFyXteESRyl8A2Ex7Wj00FMbtB13vgbmTdkTgKL0A== +"@lerna/project@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/project/-/project-6.0.3.tgz#40f59c9c0063b1098c3af85d2b8a7aa9e321a4ff" + integrity sha512-YBSWZRnRlwAwDuLKx7M7f1HyiqDY/dH+eMadHgasWgFJ5yHhtkwMCZTNgHvMAXTdN6iGb/A6mkPAN5zWhcDYBw== dependencies: - "@lerna/package" "6.0.1" - "@lerna/validation-error" "6.0.1" + "@lerna/package" "6.0.3" + "@lerna/validation-error" "6.0.3" cosmiconfig "^7.0.0" dedent "^0.7.0" dot-prop "^6.0.1" @@ -2777,38 +2777,38 @@ resolve-from "^5.0.0" write-json-file "^4.3.0" -"@lerna/prompt@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/prompt/-/prompt-6.0.1.tgz#2a744b168ce4a29b7c66d500258a3f65b3f028e2" - integrity sha512-faR7oVdHBO3QTJ6o9kUEDPpyjCftd/CCa1rAC6q8f3vlLfCPrTym0qT+DcOBFGpDQh4m2dmGfJZgpXIVi6bMbg== +"@lerna/prompt@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/prompt/-/prompt-6.0.3.tgz#251ad1c80a15dbdfca0153cf02044ec455e471a4" + integrity sha512-M/3poJp9Nqr2xJ2nB9gE6qsCwxJqvVyEnM5mMPUzRpfCvAtVa6Rhx/x60I20GSogb8/J9Zapav3MNoX2rdv2UQ== dependencies: inquirer "^8.2.4" npmlog "^6.0.2" -"@lerna/publish@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/publish/-/publish-6.0.1.tgz#9448a35a87e2c986c8919114698f3a314a9a2574" - integrity sha512-xIleRwCuPHtShNSPc6RDH33Z+EO1E4O0LOhPq5qTwanNPYh5eL6bDHBsox44BbMD9dhhI4PUrqIGTu3AoKdDxg== - dependencies: - "@lerna/check-working-tree" "6.0.1" - "@lerna/child-process" "6.0.1" - "@lerna/collect-updates" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/describe-ref" "6.0.1" - "@lerna/log-packed" "6.0.1" - "@lerna/npm-conf" "6.0.1" - "@lerna/npm-dist-tag" "6.0.1" - "@lerna/npm-publish" "6.0.1" - "@lerna/otplease" "6.0.1" - "@lerna/output" "6.0.1" - "@lerna/pack-directory" "6.0.1" - "@lerna/prerelease-id-from-version" "6.0.1" - "@lerna/prompt" "6.0.1" - "@lerna/pulse-till-done" "6.0.1" - "@lerna/run-lifecycle" "6.0.1" - "@lerna/run-topologically" "6.0.1" - "@lerna/validation-error" "6.0.1" - "@lerna/version" "6.0.1" +"@lerna/publish@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/publish/-/publish-6.0.3.tgz#029b30d6bb877102beca153d81e305939bfcf859" + integrity sha512-Vv9aDQEQv+5NRfaIpZpBqXcgfXkb18kpIUqBI4bAnqC/t168Gn/UzOxxjVkl5wuAKJ2sj8tDoZTEIb/DVoV53Q== + dependencies: + "@lerna/check-working-tree" "6.0.3" + "@lerna/child-process" "6.0.3" + "@lerna/collect-updates" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/describe-ref" "6.0.3" + "@lerna/log-packed" "6.0.3" + "@lerna/npm-conf" "6.0.3" + "@lerna/npm-dist-tag" "6.0.3" + "@lerna/npm-publish" "6.0.3" + "@lerna/otplease" "6.0.3" + "@lerna/output" "6.0.3" + "@lerna/pack-directory" "6.0.3" + "@lerna/prerelease-id-from-version" "6.0.3" + "@lerna/prompt" "6.0.3" + "@lerna/pulse-till-done" "6.0.3" + "@lerna/run-lifecycle" "6.0.3" + "@lerna/run-topologically" "6.0.3" + "@lerna/validation-error" "6.0.3" + "@lerna/version" "6.0.3" fs-extra "^9.1.0" libnpmaccess "^6.0.3" npm-package-arg "8.1.1" @@ -2819,99 +2819,99 @@ pacote "^13.6.1" semver "^7.3.4" -"@lerna/pulse-till-done@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/pulse-till-done/-/pulse-till-done-6.0.1.tgz#d23985aea1ba25bb33cf74b39f36f2b7a5d21791" - integrity sha512-DK5Ylh/O7Vzn9ObEggvoHdLxc1hiXsDZ4fUvSmi50kc5QrMrk+xo6OyPgIaDBhYxj6lm3TQ1KkvWnRgiEynKAg== +"@lerna/pulse-till-done@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/pulse-till-done/-/pulse-till-done-6.0.3.tgz#d3ec687799023b8baccc6af003cce738a114ea9c" + integrity sha512-/HjvHtaDCr0qJuhJT6PuwoHFvPsZMB7f/GnEYGIzS0+ovwOTrbULD6ESo2lWcsFnxJ3tWv2OPIKEiHkJ0y1PCg== dependencies: npmlog "^6.0.2" -"@lerna/query-graph@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/query-graph/-/query-graph-6.0.1.tgz#f72b55f0ee4662d06167e639e975019e5c004c59" - integrity sha512-X8Z63Ax5a9nXgNBG+IAXEdCL4MG88akr7L4mBvKiTPrK5VgP46YzuZSaSoPI8bU67MlWBkSYQWAJJ5t0HEtKTw== +"@lerna/query-graph@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/query-graph/-/query-graph-6.0.3.tgz#302498ac354cb7a58f5447822d8524582fd0143f" + integrity sha512-Se3G4ZIckjleki/BWUEInITfLTuNIYkqeStq50KEz74xhQ9jQs7ZLAOWc/Qxn3EPngCTLe8WqhLVeHFOfxgjvw== dependencies: - "@lerna/package-graph" "6.0.1" + "@lerna/package-graph" "6.0.3" -"@lerna/resolve-symlink@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/resolve-symlink/-/resolve-symlink-6.0.1.tgz#30c3ccf4c730451754ce7aa002772f26dd757c20" - integrity sha512-btosycLN+2lpqou6pz0Oeq4XIKHDIn0NvdnuCBLxtuBOBNIkdlx5QWKCtZ31GYKbCUt55w1DSGL64kfVuejVQQ== +"@lerna/resolve-symlink@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/resolve-symlink/-/resolve-symlink-6.0.3.tgz#9dd4b2903e4a0bb11b000fb220efd11ce5909f28" + integrity sha512-9HkEl7kMQ4sZ3/+FEOhBt2rYoQP2cXQlhV7TNIej6SGaR0VtKe98ciM9bQAdkc/rOZtyZLc2cFBoUd10NEjzoA== dependencies: fs-extra "^9.1.0" npmlog "^6.0.2" read-cmd-shim "^3.0.0" -"@lerna/rimraf-dir@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/rimraf-dir/-/rimraf-dir-6.0.1.tgz#e52ba283a4c39ade75792c23d0c6dcec65dcbbf4" - integrity sha512-rBFkwrxEQWFfZV5IMiPfGVubOquvOTNsPJPUf5tZoPAqKHXVQi5iYZGB65VG8JA7eFenZxh5mVErX2gtWFh1Ew== +"@lerna/rimraf-dir@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/rimraf-dir/-/rimraf-dir-6.0.3.tgz#be12f791a7cf1d455d25ae0cdc70d45767ee343f" + integrity sha512-jyC/PVL3rqC83l5Wphog8pSOmDbe5CIAHn9TeHvV8f/zdJnNE3zKXWTNjvyLgB1aPneQ4i2V+3BgdfpeDVAtHQ== dependencies: - "@lerna/child-process" "6.0.1" + "@lerna/child-process" "6.0.3" npmlog "^6.0.2" path-exists "^4.0.0" rimraf "^3.0.2" -"@lerna/run-lifecycle@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/run-lifecycle/-/run-lifecycle-6.0.1.tgz#ab94838cf7daa1edd6228be0a161b38ec1a42a0b" - integrity sha512-gC7rnV3mrgFFIM8GlHc3d22ovYHoExu9CuIAxN26CVrMq7iEYxWoxYvweqVANsCHR7CVbs+dsDx8/TP1pQG8wg== +"@lerna/run-lifecycle@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/run-lifecycle/-/run-lifecycle-6.0.3.tgz#84dad555d56c3aa668e1cbdf2a5b98f8baabcc64" + integrity sha512-qnFOyp9de81FA2HSBuXtW7LSklF+T6WtFkYH9q3kOJY/EghZlgzFmQYFHgJ/xVYxNu75QDuv6fsfJu4EtrR7ag== dependencies: - "@lerna/npm-conf" "6.0.1" + "@lerna/npm-conf" "6.0.3" "@npmcli/run-script" "^4.1.7" npmlog "^6.0.2" p-queue "^6.6.2" -"@lerna/run-topologically@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/run-topologically/-/run-topologically-6.0.1.tgz#dcf26259e57b224d4aad2e3b259555ecd2f226ea" - integrity sha512-p4J9RvOUyDUjQ21tDh7Durci9YnuBu3T8WXD8xu5ZwcxVnawK1h5B8kP4V1R5L/jwNqkXsAnlLwikPVGQ5Iptw== +"@lerna/run-topologically@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/run-topologically/-/run-topologically-6.0.3.tgz#37d7ec11bafeb9be3f93a56a012444fec5982efc" + integrity sha512-nN0kcOO1TzWlxg5byM1V12tm4+lvchbawc1mNje1KsujdzE4gSwD84ub4SFRNkUUBmsPvTGysorhtXckQfqQWw== dependencies: - "@lerna/query-graph" "6.0.1" + "@lerna/query-graph" "6.0.3" p-queue "^6.6.2" -"@lerna/run@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/run/-/run-6.0.1.tgz#20d3c77fa8faad01b915214b95477ae5390c8b45" - integrity sha512-F1vvpaevsWCjaQs3NlBegH54izm3cO3Qbg/cRRzPZMK4Jo7gE1ddL7+zCIq0zGt6aeVqRGBOtUMk4SvNGkzI4w== - dependencies: - "@lerna/command" "6.0.1" - "@lerna/filter-options" "6.0.1" - "@lerna/npm-run-script" "6.0.1" - "@lerna/output" "6.0.1" - "@lerna/profiler" "6.0.1" - "@lerna/run-topologically" "6.0.1" - "@lerna/timer" "6.0.1" - "@lerna/validation-error" "6.0.1" +"@lerna/run@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/run/-/run-6.0.3.tgz#604c49708a348c72683c6cf1575d2e9b7ff9e07b" + integrity sha512-eiMF/Pfld/ngH+Emkwyxqf40WWEK6bQE2KhRtu0xyuSIFycFlZJursd72ylTnvZAX3Qx4P4drdHaFnfWyuglcw== + dependencies: + "@lerna/command" "6.0.3" + "@lerna/filter-options" "6.0.3" + "@lerna/npm-run-script" "6.0.3" + "@lerna/output" "6.0.3" + "@lerna/profiler" "6.0.3" + "@lerna/run-topologically" "6.0.3" + "@lerna/timer" "6.0.3" + "@lerna/validation-error" "6.0.3" fs-extra "^9.1.0" p-map "^4.0.0" -"@lerna/symlink-binary@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/symlink-binary/-/symlink-binary-6.0.1.tgz#b9278650c3360cc518e0d313d9999cd740a2c054" - integrity sha512-TcwxDMgU9w+hGl0EeYihPytVRKV0KTeZZW4Bq6NEtjTCIIuKWxZjcY5ocxW22i6BClBvfFAJqkf+e+i3Nixlhg== +"@lerna/symlink-binary@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/symlink-binary/-/symlink-binary-6.0.3.tgz#5f40b6e8e9f2230adefd87165c3e81420d25be25" + integrity sha512-bRrPPuZoYvEDc8eTGwhTLQwRmtjYfD/hBVElqhfAlUTPcuA36VrQwBkmhGAUKcIDmEHTVk6IHNiFb/JwuiOSYA== dependencies: - "@lerna/create-symlink" "6.0.1" - "@lerna/package" "6.0.1" + "@lerna/create-symlink" "6.0.3" + "@lerna/package" "6.0.3" fs-extra "^9.1.0" p-map "^4.0.0" -"@lerna/symlink-dependencies@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/symlink-dependencies/-/symlink-dependencies-6.0.1.tgz#28c01b3f910c1d13b1d447d27c47f5c76efd0096" - integrity sha512-ImyqjLjMBu0ORGO9gYHr9oDgN/5QeeGuELtYNweLS5vMNSH1dokQW9fqZSrgfCJPbxeCizBcDTi/Knqg17ebkA== +"@lerna/symlink-dependencies@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/symlink-dependencies/-/symlink-dependencies-6.0.3.tgz#552cd9a4dc81ad925d583c392022ae9321c065d0" + integrity sha512-4DmKLZkJ9oyQ8DXdXCMT6fns6w6G/7h9D2pXGNOYa/IFtjb4mKDMBfJ61XhmvTlxrEzjEc9CnqMeO7BQBXWt8A== dependencies: - "@lerna/create-symlink" "6.0.1" - "@lerna/resolve-symlink" "6.0.1" - "@lerna/symlink-binary" "6.0.1" + "@lerna/create-symlink" "6.0.3" + "@lerna/resolve-symlink" "6.0.3" + "@lerna/symlink-binary" "6.0.3" fs-extra "^9.1.0" p-map "^4.0.0" p-map-series "^2.1.0" -"@lerna/temp-write@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/temp-write/-/temp-write-6.0.1.tgz#84f8aa3f74b6150706a70430c68815517f5301cf" - integrity sha512-9eklYncDnwTnGF9o14GOrZU05ZK5n6/x5XYRQHbuLfK5T9pmOiUyl6sO1613cZygUMaWHHi7BLtBPiw2CklqXQ== +"@lerna/temp-write@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/temp-write/-/temp-write-6.0.3.tgz#b08e329ca122a24f4f9687f1f928b2022724baf5" + integrity sha512-ws+EHk7Bp4hR6liusGk8K+ybnh9iOSkCnHD6d+avwa2lMYtX28v93kle/Y5JbTghjumgDUF9/C+EQg51zIVQmw== dependencies: graceful-fs "^4.1.15" is-stream "^2.0.0" @@ -2919,37 +2919,37 @@ temp-dir "^1.0.0" uuid "^8.3.2" -"@lerna/timer@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/timer/-/timer-6.0.1.tgz#eb10242c48a1246e1bf216af305974fbd6332d39" - integrity sha512-FLoga8iprKmRkh9jO+LP4Bm7MZLO4wNHM4LML4Dlh9CPwcIOWTteI8wSgRXvEJpt33IRIoPOUnfL3iHh8WwaYA== +"@lerna/timer@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/timer/-/timer-6.0.3.tgz#73bb3e301c76c8fabcb35831b1d398f272287f5a" + integrity sha512-Ywfu3cGi0pV9vN4ki8oTu+qdJArMwrW3MiXL3/2fospKRdGL7sGCuXlS9Byd+aduMvmMwKbnX0EW+6R7Np+qSg== -"@lerna/validation-error@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/validation-error/-/validation-error-6.0.1.tgz#afcf6b193eae86d64df9561afb7698696257304f" - integrity sha512-kjAxfFY1pDltwoCTvMQCbnpBwMXBFuvE4hdi8qePhBQ1Lf0PlTOI4ZqMFIkaTud+oujzysDXraTJbYTjc+C+zw== +"@lerna/validation-error@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/validation-error/-/validation-error-6.0.3.tgz#9e0cc7fdb2117f82db9a73eaf287f6b46521f2c9" + integrity sha512-cWYKMFne/euWnW4w7ry+RvDkj8iVNYMrbRF86Px/609GXFOoOwEROJyvTlRp1BgCmC2/3KzidyBletN/R3JHEA== dependencies: npmlog "^6.0.2" -"@lerna/version@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/version/-/version-6.0.1.tgz#988675be8ea29f1548cb4554c257c2cc94b78084" - integrity sha512-d/addeHVsRFWx3fb/XZIh6f23KuEC9Fn3ytpaMzA8rlLF3Nob1opIR98ZfUz7Nf+skpIV1QiIbXdJTZzIKvd9g== - dependencies: - "@lerna/check-working-tree" "6.0.1" - "@lerna/child-process" "6.0.1" - "@lerna/collect-updates" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/conventional-commits" "6.0.1" - "@lerna/github-client" "6.0.1" - "@lerna/gitlab-client" "6.0.1" - "@lerna/output" "6.0.1" - "@lerna/prerelease-id-from-version" "6.0.1" - "@lerna/prompt" "6.0.1" - "@lerna/run-lifecycle" "6.0.1" - "@lerna/run-topologically" "6.0.1" - "@lerna/temp-write" "6.0.1" - "@lerna/validation-error" "6.0.1" +"@lerna/version@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/version/-/version-6.0.3.tgz#de44ecf9598e77e22b5088bd3a62b76a87bcf683" + integrity sha512-ssQhsK51IBMabB+RpQPIRn93iozwMRpvfh2vVIVdTs76j8r/1ljIs3gLXPDzLo9RbyLcou+VKi3c/7coCAwsdw== + dependencies: + "@lerna/check-working-tree" "6.0.3" + "@lerna/child-process" "6.0.3" + "@lerna/collect-updates" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/conventional-commits" "6.0.3" + "@lerna/github-client" "6.0.3" + "@lerna/gitlab-client" "6.0.3" + "@lerna/output" "6.0.3" + "@lerna/prerelease-id-from-version" "6.0.3" + "@lerna/prompt" "6.0.3" + "@lerna/run-lifecycle" "6.0.3" + "@lerna/run-topologically" "6.0.3" + "@lerna/temp-write" "6.0.3" + "@lerna/validation-error" "6.0.3" "@nrwl/devkit" ">=14.8.6 < 16" chalk "^4.1.0" dedent "^0.7.0" @@ -2964,10 +2964,10 @@ slash "^3.0.0" write-json-file "^4.3.0" -"@lerna/write-log-file@6.0.1": - version "6.0.1" - resolved "https://registry.yarnpkg.com/@lerna/write-log-file/-/write-log-file-6.0.1.tgz#4335d5e08686f8250ebae9d7f56b64452bd90cd3" - integrity sha512-fJGDE8rlE35DwKSqV8M1VV2xw/vQlgwTwURjNOMvd1Ar23Aa9CkJC4XAwc9uUgIku34IsWUM8MNbw9ClSsJaqw== +"@lerna/write-log-file@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@lerna/write-log-file/-/write-log-file-6.0.3.tgz#21f4c2fcf6a41a3420c46a571dd52fb5c8a64242" + integrity sha512-xZFC9IgGkvuv1MUIC7EKD5ltlljgLlz7isbfQ2QHAqOmGJG6jPqa0Yo38pGe8wEDtGSVgtlUGkx7iHK22MawEA== dependencies: npmlog "^6.0.2" write-file-atomic "^4.0.1" @@ -9529,28 +9529,28 @@ latest-version@^5.1.0: dependencies: package-json "^6.3.0" -lerna@6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/lerna/-/lerna-6.0.1.tgz#7b14f05d1e17dc628478d33f225a579a6088d317" - integrity sha512-aNodtj1jyuEqzYmkYh+vTfRuzLkG3RZkvYxFCuLeXXzIYD5pjMHtf+1q4m03SPsZt+cElhhwkgjdg6GjihraBw== - dependencies: - "@lerna/add" "6.0.1" - "@lerna/bootstrap" "6.0.1" - "@lerna/changed" "6.0.1" - "@lerna/clean" "6.0.1" - "@lerna/cli" "6.0.1" - "@lerna/command" "6.0.1" - "@lerna/create" "6.0.1" - "@lerna/diff" "6.0.1" - "@lerna/exec" "6.0.1" - "@lerna/import" "6.0.1" - "@lerna/info" "6.0.1" - "@lerna/init" "6.0.1" - "@lerna/link" "6.0.1" - "@lerna/list" "6.0.1" - "@lerna/publish" "6.0.1" - "@lerna/run" "6.0.1" - "@lerna/version" "6.0.1" +lerna@6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/lerna/-/lerna-6.0.3.tgz#0364eadeedbdf5ade375d8a6f0a87bb9003f6019" + integrity sha512-DzRCTZGoDI502daViNK1Ha+HPAVvTp72xshDOQ6o6SWCDTvnxFI3hGF6CBqGWnOoPwEOlQowHEIcPw5PjoMz8A== + dependencies: + "@lerna/add" "6.0.3" + "@lerna/bootstrap" "6.0.3" + "@lerna/changed" "6.0.3" + "@lerna/clean" "6.0.3" + "@lerna/cli" "6.0.3" + "@lerna/command" "6.0.3" + "@lerna/create" "6.0.3" + "@lerna/diff" "6.0.3" + "@lerna/exec" "6.0.3" + "@lerna/import" "6.0.3" + "@lerna/info" "6.0.3" + "@lerna/init" "6.0.3" + "@lerna/link" "6.0.3" + "@lerna/list" "6.0.3" + "@lerna/publish" "6.0.3" + "@lerna/run" "6.0.3" + "@lerna/version" "6.0.3" "@nrwl/devkit" ">=14.8.6 < 16" import-local "^3.0.2" inquirer "^8.2.4" From 0e1e71dcb3e4ce60b563ab54e56cee48871314f9 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Fri, 11 Nov 2022 15:44:07 -0500 Subject: [PATCH 23/76] chore: enable `eslint-plugin/require-meta-docs-description` rule (#5969) chore: enable eslint-plugin/require-meta-docs-description rule --- .eslintrc.js | 5 +++++ .../src/rules/no-poorly-typed-ts-props.ts | 2 +- .../src/rules/no-typescript-default-import.ts | 2 +- .../src/rules/no-typescript-estree-import.ts | 2 +- .../src/rules/plugin-test-formatting.ts | 2 +- .../src/rules/prefer-ast-types-enum.ts | 2 +- packages/eslint-plugin-tslint/src/rules/config.ts | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index da7ff36fd3b..6dfb0c35362 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -257,6 +257,11 @@ module.exports = { './packages/eslint-plugin/src/rules/**/*.ts', ], rules: { + 'eslint-plugin/require-meta-docs-description': [ + 'error', + { pattern: '^(Enforce|Require|Disallow) .+[^. ]$' }, + ], + // specifically for rules - default exports makes the tooling easier 'import/no-default-export': 'off', }, diff --git a/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts b/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts index 6811c935bba..0c671d8432f 100644 --- a/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts +++ b/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts @@ -35,7 +35,7 @@ export default createRule({ type: 'problem', docs: { description: - "Enforces rules don't use TS API properties with known bad type definitions", + "Enforce that rules don't use TS API properties with known bad type definitions", recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts b/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts index 34b911451e7..fd7279c3823 100644 --- a/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts +++ b/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts @@ -20,7 +20,7 @@ export default createRule({ type: 'problem', docs: { description: - "Enforces that packages rules don't do `import ts from 'typescript';`", + "Enforce that packages rules don't do `import ts from 'typescript';`", recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts b/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts index 022fd98b7ca..28f7439472b 100644 --- a/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts +++ b/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts @@ -15,7 +15,7 @@ export default createRule({ meta: { type: 'problem', docs: { - description: `Enforces that eslint-plugin rules don't require anything from ${TSESTREE_NAME} or ${TYPES_NAME}`, + description: `Enforce that eslint-plugin rules don't require anything from ${TSESTREE_NAME} or ${TYPES_NAME}`, recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts index 8cd85cce8e9..f86d4946836 100644 --- a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts +++ b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts @@ -107,7 +107,7 @@ export default createRule({ meta: { type: 'problem', docs: { - description: `Enforces that eslint-plugin test snippets are correctly formatted`, + description: `Enforce that eslint-plugin test snippets are correctly formatted`, recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts b/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts index 4b74cbe09b9..4099e2f02be 100755 --- a/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts +++ b/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts @@ -15,7 +15,7 @@ export default createRule({ docs: { recommended: 'error', description: - 'Ensures consistent usage of `AST_NODE_TYPES`, `AST_TOKEN_TYPES` and `DefinitionType` enums.', + 'Enforce consistent usage of `AST_NODE_TYPES`, `AST_TOKEN_TYPES` and `DefinitionType` enums', }, messages: { preferEnum: 'Prefer {{ enumName }}.{{ literal }} over raw literal', diff --git a/packages/eslint-plugin-tslint/src/rules/config.ts b/packages/eslint-plugin-tslint/src/rules/config.ts index 5f20bcd4430..9fcfa844da1 100644 --- a/packages/eslint-plugin-tslint/src/rules/config.ts +++ b/packages/eslint-plugin-tslint/src/rules/config.ts @@ -64,7 +64,7 @@ export default createRule({ meta: { docs: { description: - 'Wraps a TSLint configuration and lints the whole source using TSLint', + 'Wraps a TSLint configuration and lints the whole source using TSLint', // eslint-disable-line eslint-plugin/require-meta-docs-description recommended: false, }, fixable: 'code', From 0eb78b348ca25a3493446bad30950d50fb9ebef2 Mon Sep 17 00:00:00 2001 From: Anna Aneychik Date: Fri, 11 Nov 2022 21:53:19 +0100 Subject: [PATCH 24/76] docs(eslint-plugin): [sort-type-union-intersection-members] fix link to new rule (#5970) docs(eslint-plugin): [sort-type-union-intersection-members] correct link to new rule --- .../docs/rules/sort-type-union-intersection-members.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md index dbaf1807edf..edaa195df6b 100644 --- a/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md +++ b/packages/eslint-plugin/docs/rules/sort-type-union-intersection-members.md @@ -8,7 +8,7 @@ description: 'Enforce members of a type union/intersection to be sorted alphabet :::danger Deprecated -This rule has been renamed to [`sort-type-union-intersection-members`](./sort-type-union-intersection-members.md). +This rule has been renamed to [`sort-type-constituents`](./sort-type-constituents.md). ::: Sorting union (`|`) and intersection (`&`) types can help: From 1b8f9ce5bc1f8d6fa7b0413e5c8d94e419fd8538 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Sat, 12 Nov 2022 07:58:17 -0500 Subject: [PATCH 25/76] docs: use consistent auto-fixable rule emoji (#5966) --- packages/website/src/theme/MDXComponents/RuleAttributes.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/website/src/theme/MDXComponents/RuleAttributes.tsx b/packages/website/src/theme/MDXComponents/RuleAttributes.tsx index c7632e25a9f..e0351d743c7 100644 --- a/packages/website/src/theme/MDXComponents/RuleAttributes.tsx +++ b/packages/website/src/theme/MDXComponents/RuleAttributes.tsx @@ -62,7 +62,7 @@ export function RuleAttributes({ name }: { name: string }): React.ReactNode { . ), - emoji: '🛠', + emoji: '🔧', }); } From 91d71bcf6b2f822116d25b281e289fe1d5005401 Mon Sep 17 00:00:00 2001 From: vaishnav <84540554+vaishnav-mk@users.noreply.github.com> Date: Sat, 12 Nov 2022 17:48:47 +0300 Subject: [PATCH 26/76] docs(naming-conventions): Alphabetizing inline lists (#5940) Co-authored-by: Josh Goldberg --- .../docs/rules/naming-convention.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/naming-convention.md b/packages/eslint-plugin/docs/rules/naming-convention.md index ef273df8f16..f5922ba3653 100644 --- a/packages/eslint-plugin/docs/rules/naming-convention.md +++ b/packages/eslint-plugin/docs/rules/naming-convention.md @@ -149,7 +149,7 @@ The `leadingUnderscore` / `trailingUnderscore` options control whether leading/t The `prefix` / `suffix` options control which prefix/suffix strings must exist for the identifier. Accepts an array of strings. -If these are provided, the identifier must start with one of the provided values. For example, if you provide `{ prefix: ['IFace', 'Class', 'Type'] }`, then the following names are valid: `IFaceFoo`, `ClassBar`, `TypeBaz`, but the name `Bang` is not valid, as it contains none of the prefixes. +If these are provided, the identifier must start with one of the provided values. For example, if you provide `{ prefix: ['Class', 'IFace', 'Type'] }`, then the following names are valid: `ClassBar`, `IFaceFoo`, `TypeBaz`, but the name `Bang` is not valid, as it contains none of the prefixes. **Note:** As [documented above](#format-options), the prefix is trimmed before format is validated, therefore PascalCase must be used to allow variables such as `isEnabled` using the prefix `is`. @@ -157,11 +157,11 @@ If these are provided, the identifier must start with one of the provided values - `selector` allows you to specify what types of identifiers to target. - Accepts one or array of selectors to define an option block that applies to one or multiple selectors. - - For example, if you provide `{ selector: ['variable', 'function'] }`, then it will apply the same option to variable and function nodes. + - For example, if you provide `{ selector: ['function', 'variable'] }`, then it will apply the same option to variable and function nodes. - See [Allowed Selectors, Modifiers and Types](#allowed-selectors-modifiers-and-types) below for the complete list of allowed selectors. -- `modifiers` allows you to specify which modifiers to granularly apply to, such as the accessibility (`private`/`public`/`protected`), or if the thing is `static`, etc. +- `modifiers` allows you to specify which modifiers to granularly apply to, such as the accessibility (`private`/`protected`/`public`), or if the thing is `static`, etc. - The name must match _all_ of the modifiers. - - For example, if you provide `{ modifiers: ['private', 'static', 'readonly'] }`, then it will only match something that is `private static readonly`, and something that is just `private` will not match. + - For example, if you provide `{ modifiers: ['private','readonly','static'] }`, then it will only match something that is `private static readonly`, and something that is just `private` will not match. - The following `modifiers` are allowed: - `const` - matches a variable declared as being `const` (`const x = 1`). - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`). @@ -171,9 +171,9 @@ If these are provided, the identifier must start with one of the provided values - `unused` - matches anything that is not used. - `requiresQuotes` - matches any name that requires quotes as it is not a valid identifier (i.e. has a space, a dash, etc in it). - `public` - matches any member that is either explicitly declared as `public`, or has no visibility modifier (i.e. implicitly public). - - `readonly`, `static`, `abstract`, `protected`, `private`, `override` - matches any member explicitly declared with the given modifier. + - `abstract`,`override`,`private`,`protected`,`readonly`,`static` - matches any member explicitly declared with the given modifier. - `async` - matches any method, function, or function variable which is async via the `async` keyword (e.g. does not match functions that return promises without using `async` keyword) -- `types` allows you to specify which types to match. This option supports simple, primitive types only (`boolean`, `string`, `number`, `array`, `function`). +- `types` allows you to specify which types to match. This option supports simple, primitive types only (`array`,`boolean`,`function`,`number`,`string`). - The name must match _one_ of the types. - **_NOTE - Using this option will require that you lint with type information._** - For example, this lets you do things like enforce that `boolean` variables are prefixed with a verb. @@ -194,39 +194,39 @@ There are two types of selectors, individual selectors, and grouped selectors. Individual Selectors match specific, well-defined sets. There is no overlap between each of the individual selectors. -- `variable` - matches any `var` / `let` / `const` variable name. - - Allowed `modifiers`: `const`, `destructured`, `global`, `exported`, `unused`, `async`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. +- `variable` - matches any `let` / `const` / `var` variable name. + - Allowed `modifiers`: `async`, `const`, `destructured`, `exported`, `global`, `unused`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `function` - matches any named function declaration or named function expression. - - Allowed `modifiers`: `global`, `exported`, `unused`, `async`. + - Allowed `modifiers`: `async`, `exported`, `global`, `unused`. - Allowed `types`: none. - `parameter` - matches any function parameter. Does not match parameter properties. - Allowed `modifiers`: `destructured`, `unused`. - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. - `classProperty` - matches any class property. Does not match properties that have direct function expression or arrow function expression values. - - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`, `override`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. + - Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `objectLiteralProperty` - matches any object literal property. Does not match properties that have direct function expression or arrow function expression values. - Allowed `modifiers`: `public`, `requiresQuotes`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `typeProperty` - matches any object type property. Does not match properties that have direct function expression or arrow function expression values. - Allowed `modifiers`: `public`, `readonly`, `requiresQuotes`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `parameterProperty` - matches any parameter property. - Allowed `modifiers`: `private`, `protected`, `public`, `readonly`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `classMethod` - matches any class method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors. - - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`, `override`, `async`. + - Allowed `modifiers`: `abstract`, `async`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`. - Allowed `types`: none. - `objectLiteralMethod` - matches any object literal method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors. - - Allowed `modifiers`: `public`, `requiresQuotes`, `async`. + - Allowed `modifiers`: `async`, `public`, `requiresQuotes`. - Allowed `types`: none. - `typeMethod` - matches any object type method. Also matches properties that have direct function expression or arrow function expression values. Does not match accessors. - Allowed `modifiers`: `public`, `requiresQuotes`. - Allowed `types`: none. - `accessor` - matches any accessor. - - Allowed `modifiers`: `abstract`, `private`, `protected`, `public`, `requiresQuotes`, `static`, `override`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. + - Allowed `modifiers`: `abstract`, `override`, `private`, `protected`, `public`, `requiresQuotes`, `static`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `enumMember` - matches any enum member. - Allowed `modifiers`: `requiresQuotes`. - Allowed `types`: none. @@ -253,20 +253,20 @@ Group Selectors are provided for convenience, and essentially bundle up sets of - `default` - matches everything. - Allowed `modifiers`: all modifiers. - Allowed `types`: none. -- `variableLike` - matches the same as `variable`, `function` and `parameter`. - - Allowed `modifiers`: `unused`, `async`. +- `variableLike` - matches the same as `function`, `parameter` and `variable`. + - Allowed `modifiers`: `async`, `unused`. - Allowed `types`: none. -- `memberLike` - matches the same as `property`, `parameterProperty`, `method`, `accessor`, `enumMember`. - - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`. +- `memberLike` - matches the same as `accessor`, `enumMember`, `method`, `parameterProperty`, `property`. + - Allowed `modifiers`: `abstract`, `async`, `override`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`. - Allowed `types`: none. -- `typeLike` - matches the same as `class`, `interface`, `typeAlias`, `enum`, `typeParameter`. +- `typeLike` - matches the same as `class`, `enum`, `interface`, `typeAlias`, `typeParameter`. - Allowed `modifiers`: `abstract`, `unused`. - Allowed `types`: none. - `property` - matches the same as `classProperty`, `objectLiteralProperty`, `typeProperty`. - - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`. - - Allowed `types`: `boolean`, `string`, `number`, `function`, `array`. + - Allowed `modifiers`: `abstract`, `async`, `override`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`. + - Allowed `types`: `array`, `boolean`, `function`, `number`, `string`. - `method` - matches the same as `classMethod`, `objectLiteralMethod`, `typeMethod`. - - Allowed `modifiers`: `private`, `protected`, `public`, `static`, `readonly`, `abstract`, `requiresQuotes`, `override`, `async`. + - Allowed `modifiers`: `abstract`, `async`, `override`, `private`, `protected`, `public`, `readonly`, `requiresQuotes`, `static`. - Allowed `types`: none. ## FAQ From 769e8c8b9a51cd3448e47d13c7b0dab0468ee23c Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Mon, 14 Nov 2022 08:41:32 +0900 Subject: [PATCH 27/76] fix(eslint-plugin): [no-shadow] handle false positives on generics and parameters (#5902) * fix(eslint-plugin): [no-shadow] handle false positives on generics and parameters * Update packages/eslint-plugin/src/rules/no-shadow.ts Co-authored-by: Josh Goldberg --- packages/eslint-plugin/src/rules/no-shadow.ts | 5 +- .../tests/rules/no-shadow/no-shadow.test.ts | 75 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-shadow.ts b/packages/eslint-plugin/src/rules/no-shadow.ts index 1f746a3201c..7d8eff0b9e2 100644 --- a/packages/eslint-plugin/src/rules/no-shadow.ts +++ b/packages/eslint-plugin/src/rules/no-shadow.ts @@ -147,8 +147,9 @@ export default util.createRule({ return false; } - const id = variable.identifiers[0]; - return util.isFunctionType(id.parent); + return variable.defs.every( + def => def.node.type === AST_NODE_TYPES.TSFunctionType, + ); } function isGenericOfStaticMethod( diff --git a/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts b/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts index 1097f466a18..1616051f0e3 100644 --- a/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts +++ b/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts @@ -12,6 +12,25 @@ const ruleTester = new RuleTester({ ruleTester.run('no-shadow TS tests', rule, { valid: [ + 'function foo any>(arg: T) {}', + 'function foo any>(arg: T) {}', + 'function foo any>(arg: T) {}', + 'function foo any>(fn: T, args: any[]) {}', + 'function foo any>(fn: T, args: any[]) {}', + 'function foo any>(fn: T, ...args: any[]) {}', + 'function foo any>(fn: T, args: any[]) {}', + 'function foo any>(fn: T, args: any[]) {}', + 'function foo any>(fn: T, args: any) {}', + ` +function foo any>( + fn: T, + ...args: any[] +) {} + `, + ` +type Args = 1; +function foo void>(arg: T) {} + `, // nested conditional types ` export type ArrayInput = Func extends (arg0: Array) => any @@ -375,6 +394,22 @@ type T = 1; }, { code: ` +type T = 1; +function foo(arg: T) {} + `, + errors: [ + { + messageId: 'noShadow', + data: { + name: 'T', + shadowedLine: 2, + shadowedColumn: 6, + }, + }, + ], + }, + { + code: ` function foo() { return function () {}; } @@ -392,6 +427,22 @@ function foo() { }, { code: ` +type T = string; +function foo void>(arg: T) {} + `, + errors: [ + { + messageId: 'noShadow', + data: { + name: 'T', + shadowedLine: 2, + shadowedColumn: 6, + }, + }, + ], + }, + { + code: ` const x = 1; { type x = string; @@ -703,5 +754,29 @@ let y; }, ], }, + { + code: ` +function foo any>(fn: T, args: any[]) {} + `, + options: [ + { + ignoreTypeValueShadow: false, + builtinGlobals: true, + }, + ], + globals: { + args: 'writable', + }, + errors: [ + { + messageId: 'noShadowGlobal', + data: { + name: 'args', + shadowedLine: 2, + shadowedColumn: 5, + }, + }, + ], + }, ], }); From f25a94fa75e497a6b9ec29a008bcc89818eed60d Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Mon, 14 Nov 2022 09:12:04 +0900 Subject: [PATCH 28/76] fix(eslint-plugin): [promise-function-async] handle keyword token (#5907) Co-authored-by: Josh Goldberg --- .../src/rules/promise-function-async.ts | 5 +- .../rules/promise-function-async.test.ts | 82 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index ba3c3d9478f..4387bc52c9b 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -175,7 +175,10 @@ export default util.createRule({ } // if current token is a keyword like `static` or `public` then skip it - while (keyToken.type === AST_TOKEN_TYPES.Keyword) { + while ( + keyToken.type === AST_TOKEN_TYPES.Keyword && + keyToken.range[0] < method.key.range[0] + ) { keyToken = sourceCode.getTokenAfter(keyToken)!; } diff --git a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts index 69b604c811c..ccf99b6afcb 100644 --- a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts +++ b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts @@ -102,6 +102,13 @@ const invalidAsyncModifiers = { constructor() {} } `, + ` +class Foo { + async catch(arg: Promise) { + return arg; + } +} + `, { code: ` function returnsAny(): any { @@ -670,5 +677,80 @@ class Test { } `, }, + // https://github.com/typescript-eslint/typescript-eslint/issues/5729 + { + code: ` +class Foo { + catch() { + return Promise.resolve(1); + } + + public default() { + return Promise.resolve(2); + } + + @decorator + private case() { + return Promise.resolve(3); + } +} + `, + output: ` +class Foo { + async catch() { + return Promise.resolve(1); + } + + public async default() { + return Promise.resolve(2); + } + + @decorator + private async case() { + return Promise.resolve(3); + } +} + `, + errors: [ + { + line: 3, + column: 3, + messageId, + }, + { + line: 7, + column: 3, + messageId, + }, + { + line: 12, + column: 3, + messageId, + }, + ], + }, + { + code: ` +const foo = { + catch() { + return Promise.resolve(1); + }, +}; + `, + output: ` +const foo = { + async catch() { + return Promise.resolve(1); + }, +}; + `, + errors: [ + { + line: 3, + column: 3, + messageId, + }, + ], + }, ], }); From ceddb34eeab5d4acb95725e723fd86d431ac3d65 Mon Sep 17 00:00:00 2001 From: Cparros <65684072+cparros@users.noreply.github.com> Date: Mon, 14 Nov 2022 08:57:39 -0700 Subject: [PATCH 29/76] chore(website): [prefer-nullish-coalescing] explicit notice for strictNullChecks (#5988) --- .../eslint-plugin/docs/rules/prefer-nullish-coalescing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md index 5be277ecc73..d2fc95f4066 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -11,6 +11,10 @@ Because the nullish coalescing operator _only_ coalesces when the original value This rule reports when an `||` operator can be safely replaced with a `??`. +:::caution +This rule will not work as expected if [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) is not enabled. +::: + ## Options ### `ignoreTernaryTests` From 8af1b4d970438b27ea041717bddadc41af8fc72a Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" Date: Mon, 14 Nov 2022 17:32:30 +0000 Subject: [PATCH 30/76] chore: publish v5.43.0 --- CHANGELOG.md | 13 +++++++++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 4 ++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 4 ++++ packages/eslint-plugin-internal/package.json | 8 ++++---- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 13 +++++++++++++ packages/eslint-plugin/package.json | 8 ++++---- packages/experimental-utils/CHANGELOG.md | 4 ++++ packages/experimental-utils/package.json | 4 ++-- packages/parser/CHANGELOG.md | 4 ++++ packages/parser/package.json | 8 ++++---- packages/scope-manager/CHANGELOG.md | 4 ++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 4 ++++ packages/shared-fixtures/package.json | 2 +- packages/type-utils/CHANGELOG.md | 4 ++++ packages/type-utils/package.json | 8 ++++---- packages/types/CHANGELOG.md | 4 ++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 4 ++++ packages/typescript-estree/package.json | 8 ++++---- packages/utils/CHANGELOG.md | 4 ++++ packages/utils/package.json | 10 +++++----- packages/visitor-keys/CHANGELOG.md | 4 ++++ packages/visitor-keys/package.json | 4 ++-- packages/website-eslint/CHANGELOG.md | 4 ++++ packages/website-eslint/package.json | 16 ++++++++-------- packages/website/CHANGELOG.md | 4 ++++ packages/website/package.json | 8 ++++---- 32 files changed, 134 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4db2f119aa..b400022f227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +### Bug Fixes + +- **eslint-plugin:** [no-shadow] handle false positives on generics and parameters ([#5902](https://github.com/typescript-eslint/typescript-eslint/issues/5902)) ([769e8c8](https://github.com/typescript-eslint/typescript-eslint/commit/769e8c8b9a51cd3448e47d13c7b0dab0468ee23c)) +- **eslint-plugin:** [promise-function-async] handle keyword token ([#5907](https://github.com/typescript-eslint/typescript-eslint/issues/5907)) ([f25a94f](https://github.com/typescript-eslint/typescript-eslint/commit/f25a94fa75e497a6b9ec29a008bcc89818eed60d)) + +### Features + +- **eslint-plugin:** [consistent-type-imports] support fixing to inline types ([#5050](https://github.com/typescript-eslint/typescript-eslint/issues/5050)) ([75dcdf1](https://github.com/typescript-eslint/typescript-eslint/commit/75dcdf164d206c5530ba7cc095c4599ec90abe35)) +- **eslint-plugin:** [naming-convention] add support for "override" and "async" modifiers ([#5310](https://github.com/typescript-eslint/typescript-eslint/issues/5310)) ([#5610](https://github.com/typescript-eslint/typescript-eslint/issues/5610)) ([c759da1](https://github.com/typescript-eslint/typescript-eslint/commit/c759da169390ba490eee9ef773cc9edc88a32817)) +- **eslint-plugin:** [prefer-optional-chain] support suggesting `!foo || !foo.bar` as a valid match for the rule ([#5594](https://github.com/typescript-eslint/typescript-eslint/issues/5594)) ([923d486](https://github.com/typescript-eslint/typescript-eslint/commit/923d486c8c9c9096deac425e7a6cb0b6457eacbd)) + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 0b0cd5d3c7d..e213821c090 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.42.1", + "version": "5.43.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 12b5e0818ea..33f54422348 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/ast-spec + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) ### Bug Fixes diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index bc441599d3a..19a595262da 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.42.1", + "version": "5.43.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index 52726f2a2fa..3cb70bba497 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 899b0c144f9..b9047517e16 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.42.1", + "version": "5.43.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,9 +14,9 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.42.1", - "@typescript-eslint/type-utils": "5.42.1", - "@typescript-eslint/utils": "5.42.1", + "@typescript-eslint/scope-manager": "5.43.0", + "@typescript-eslint/type-utils": "5.43.0", + "@typescript-eslint/utils": "5.43.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 105df78c12f..77d0a23e05a 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 143cda6b820..d69678024c8 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.42.1", + "version": "5.43.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.42.1", + "@typescript-eslint/utils": "5.43.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.42.1" + "@typescript-eslint/parser": "5.43.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 8c5ef968f8a..9b989e2c870 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +### Bug Fixes + +- **eslint-plugin:** [no-shadow] handle false positives on generics and parameters ([#5902](https://github.com/typescript-eslint/typescript-eslint/issues/5902)) ([769e8c8](https://github.com/typescript-eslint/typescript-eslint/commit/769e8c8b9a51cd3448e47d13c7b0dab0468ee23c)) +- **eslint-plugin:** [promise-function-async] handle keyword token ([#5907](https://github.com/typescript-eslint/typescript-eslint/issues/5907)) ([f25a94f](https://github.com/typescript-eslint/typescript-eslint/commit/f25a94fa75e497a6b9ec29a008bcc89818eed60d)) + +### Features + +- **eslint-plugin:** [consistent-type-imports] support fixing to inline types ([#5050](https://github.com/typescript-eslint/typescript-eslint/issues/5050)) ([75dcdf1](https://github.com/typescript-eslint/typescript-eslint/commit/75dcdf164d206c5530ba7cc095c4599ec90abe35)) +- **eslint-plugin:** [naming-convention] add support for "override" and "async" modifiers ([#5310](https://github.com/typescript-eslint/typescript-eslint/issues/5310)) ([#5610](https://github.com/typescript-eslint/typescript-eslint/issues/5610)) ([c759da1](https://github.com/typescript-eslint/typescript-eslint/commit/c759da169390ba490eee9ef773cc9edc88a32817)) +- **eslint-plugin:** [prefer-optional-chain] support suggesting `!foo || !foo.bar` as a valid match for the rule ([#5594](https://github.com/typescript-eslint/typescript-eslint/issues/5594)) ([923d486](https://github.com/typescript-eslint/typescript-eslint/commit/923d486c8c9c9096deac425e7a6cb0b6457eacbd)) + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index baf09fbe480..b4778013b7a 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.42.1", + "version": "5.43.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,9 +44,9 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.42.1", - "@typescript-eslint/type-utils": "5.42.1", - "@typescript-eslint/utils": "5.42.1", + "@typescript-eslint/scope-manager": "5.43.0", + "@typescript-eslint/type-utils": "5.43.0", + "@typescript-eslint/utils": "5.43.0", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 90849052a8b..dbf41b97191 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 a8beecad680..901b63d2f30 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.42.1", + "version": "5.43.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.42.1" + "@typescript-eslint/utils": "5.43.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 f289c94422c..c6013137c08 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/parser + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 3cab6296e24..23ac485be0f 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.42.1", + "version": "5.43.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.42.1", - "@typescript-eslint/types": "5.42.1", - "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/scope-manager": "5.43.0", + "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/typescript-estree": "5.43.0", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index a05c850fb59..4707e539d1b 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 805f5263089..bc611e14e68 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.42.1", + "version": "5.43.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -38,12 +38,12 @@ "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" }, "dependencies": { - "@typescript-eslint/types": "5.42.1", - "@typescript-eslint/visitor-keys": "5.42.1" + "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/visitor-keys": "5.43.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/typescript-estree": "5.43.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index ab596d7e657..a96e2e63278 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 ca455a0baa7..cec6cebc648 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.42.1", + "version": "5.43.0", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 05d63922d7b..86867d3cdde 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/type-utils + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) ### Bug Fixes diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index d7c59969f23..f72272dd349 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.42.1", + "version": "5.43.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.42.1", - "@typescript-eslint/utils": "5.42.1", + "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/utils": "5.43.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.42.1", + "@typescript-eslint/parser": "5.43.0", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index e40007997a1..cede80aabc0 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/types + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 8d07f4e7f4c..8b591cd2e0f 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.42.1", + "version": "5.43.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 157724f1c61..c7f8b17bab4 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index ded0c0f77d6..f28d6d17f76 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.42.1", + "version": "5.43.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.42.1", - "@typescript-eslint/visitor-keys": "5.42.1", + "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/visitor-keys": "5.43.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.42.1", + "@typescript-eslint/shared-fixtures": "5.43.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 0f90a7ba84d..3a925cebcb9 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/utils + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **Note:** Version bump only for package @typescript-eslint/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 6fce0515843..ad353bce00e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.42.1", + "version": "5.43.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.42.1", - "@typescript-eslint/types": "5.42.1", - "@typescript-eslint/typescript-estree": "5.42.1", + "@typescript-eslint/scope-manager": "5.43.0", + "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/typescript-estree": "5.43.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.42.1", + "@typescript-eslint/parser": "5.43.0", "typescript": "*" }, "funding": { diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index c3f21858ae0..9ebb6b77f0b 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 285fb30b312..62a83136687 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.42.1", + "version": "5.43.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.42.1", + "@typescript-eslint/types": "5.43.0", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index 08eac0b5451..5ea048243ae 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **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 7f0d3551d71..0baf89601da 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.42.1", + "version": "5.43.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.42.1", - "@typescript-eslint/utils": "5.42.1" + "@typescript-eslint/types": "5.43.0", + "@typescript-eslint/utils": "5.43.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.42.1", - "@typescript-eslint/parser": "5.42.1", - "@typescript-eslint/scope-manager": "5.42.1", - "@typescript-eslint/typescript-estree": "5.42.1", - "@typescript-eslint/visitor-keys": "5.42.1", + "@typescript-eslint/eslint-plugin": "5.43.0", + "@typescript-eslint/parser": "5.43.0", + "@typescript-eslint/scope-manager": "5.43.0", + "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/visitor-keys": "5.43.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 45dc82b46b2..6e050be87af 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) + +**Note:** Version bump only for package website + ## [5.42.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.0...v5.42.1) (2022-11-07) **Note:** Version bump only for package website diff --git a/packages/website/package.json b/packages/website/package.json index b59791a71e9..5232068f58a 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.42.1", + "version": "5.43.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.42.1", - "@typescript-eslint/website-eslint": "5.42.1", + "@typescript-eslint/parser": "5.43.0", + "@typescript-eslint/website-eslint": "5.43.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.42.1", + "@typescript-eslint/eslint-plugin": "5.43.0", "copy-webpack-plugin": "^11.0.0", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.29.4", From 6a735e142ef67f3af6497f922cf83706867eb6b7 Mon Sep 17 00:00:00 2001 From: Omri Luzon Date: Tue, 15 Nov 2022 18:27:49 +0200 Subject: [PATCH 31/76] feat(eslint-plugin): [keyword-spacing] Support spacing in import-type syntax (#5977) * feat/issue5362-keyword-spacing---support-import-type-syntax * uncomment * Update packages/eslint-plugin/tests/rules/keyword-spacing.test.ts Co-authored-by: Josh Goldberg --- .../src/rules/keyword-spacing.ts | 32 ++++++++++++++++ .../tests/rules/keyword-spacing.test.ts | 38 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/packages/eslint-plugin/src/rules/keyword-spacing.ts b/packages/eslint-plugin/src/rules/keyword-spacing.ts index bcb90573836..6af42e5c2fb 100644 --- a/packages/eslint-plugin/src/rules/keyword-spacing.ts +++ b/packages/eslint-plugin/src/rules/keyword-spacing.ts @@ -1,3 +1,4 @@ +import type { TSESTree } from '@typescript-eslint/utils'; import { AST_TOKEN_TYPES } from '@typescript-eslint/utils'; import * as util from '../util'; @@ -50,6 +51,37 @@ export default util.createRule({ // make sure to reset the type afterward so we don't permanently mutate the AST asToken.type = oldTokenType; }, + 'ImportDeclaration[importKind=type]'( + node: TSESTree.ImportDeclaration, + ): void { + const typeToken = sourceCode.getFirstToken(node, { skip: 1 })!; + const punctuatorToken = sourceCode.getTokenAfter(typeToken)!; + const spacesBetweenTypeAndPunctuator = + punctuatorToken.range[0] - typeToken.range[1]; + if (context.options[0].after && spacesBetweenTypeAndPunctuator === 0) { + context.report({ + loc: punctuatorToken.loc, + messageId: 'expectedBefore', + data: { value: punctuatorToken.value }, + fix(fixer) { + return fixer.insertTextBefore(punctuatorToken, ' '); + }, + }); + } + if (!context.options[0].after && spacesBetweenTypeAndPunctuator > 0) { + context.report({ + loc: punctuatorToken.loc, + messageId: 'unexpectedBefore', + data: { value: punctuatorToken.value }, + fix(fixer) { + return fixer.removeRange([ + typeToken.range[1], + typeToken.range[1] + spacesBetweenTypeAndPunctuator, + ]); + }, + }); + } + }, }; }, }); diff --git a/packages/eslint-plugin/tests/rules/keyword-spacing.test.ts b/packages/eslint-plugin/tests/rules/keyword-spacing.test.ts index c2694829b35..b8a1a72d2ca 100644 --- a/packages/eslint-plugin/tests/rules/keyword-spacing.test.ts +++ b/packages/eslint-plugin/tests/rules/keyword-spacing.test.ts @@ -114,6 +114,16 @@ ruleTester.run('keyword-spacing', rule, { options: [{ overrides: { as: {} } }], parserOptions: { ecmaVersion: 6, sourceType: 'module' }, }, + { + code: 'import type { foo } from "foo";', + options: [{ overrides: { as: {} } }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + }, + { + code: "import type * as Foo from 'foo'", + options: [{ overrides: { as: {} } }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + }, ], invalid: [ //---------------------------------------------------------------------- @@ -152,5 +162,33 @@ ruleTester.run('keyword-spacing', rule, { parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: expectedAfter('as'), }, + { + code: 'import type{ foo } from "foo";', + output: 'import type { foo } from "foo";', + options: [{ after: true, before: true }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ messageId: 'expectedBefore', data: { value: '{' } }], + }, + { + code: 'import type { foo } from"foo";', + output: 'import type{ foo } from"foo";', + options: [{ after: false, before: true }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ messageId: 'unexpectedBefore', data: { value: '{' } }], + }, + { + code: 'import type* as foo from "foo";', + output: 'import type * as foo from "foo";', + options: [{ after: true, before: true }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ messageId: 'expectedBefore', data: { value: '*' } }], + }, + { + code: 'import type * as foo from"foo";', + output: 'import type* as foo from"foo";', + options: [{ after: false, before: true }], + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ messageId: 'unexpectedBefore', data: { value: '*' } }], + }, ], }); From 5baad0893f9a90633d57fffac69af7523bd1501e Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Wed, 16 Nov 2022 03:47:08 +0900 Subject: [PATCH 32/76] fix(eslint-plugin): [no-unnecessary-condition] handle index signature type (#5912) fix(eslint-plugin): [no-unnecessary-condition] handle mapped type --- .../src/rules/no-unnecessary-condition.ts | 7 ++- .../rules/no-unnecessary-condition.test.ts | 49 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts index 51d42f82926..030ed4fe188 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts @@ -554,7 +554,12 @@ export default createRule({ type, property.name, ); - return propType && isNullableType(propType, { allowUndefined: true }); + + if (propType) { + return isNullableType(propType, { allowUndefined: true }); + } + + return !!checker.getIndexInfoOfType(type, ts.IndexKind.String); }); return ( !isOwnNullable && isNullableType(prevType, { allowUndefined: true }) diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts index f8401399a20..af8b189f899 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts @@ -527,6 +527,24 @@ if (x) { tsconfigRootDir: path.join(rootPath, 'unstrict'), }, }, + ` +interface Foo { + [key: string]: [string] | undefined; +} + +type OptionalFoo = Foo | undefined; +declare const foo: OptionalFoo; +foo?.test?.length; + `, + ` +interface Foo { + [key: number]: [string] | undefined; +} + +type OptionalFoo = Foo | undefined; +declare const foo: OptionalFoo; +foo?.[1]?.length; + `, ], invalid: [ // Ensure that it's checking in all the right places @@ -1548,5 +1566,36 @@ if (x) { tsconfigRootDir: path.join(rootPath, 'unstrict'), }, }, + { + code: ` +interface Foo { + test: string; + [key: string]: [string] | undefined; +} + +type OptionalFoo = Foo | undefined; +declare const foo: OptionalFoo; +foo?.test?.length; + `, + output: ` +interface Foo { + test: string; + [key: string]: [string] | undefined; +} + +type OptionalFoo = Foo | undefined; +declare const foo: OptionalFoo; +foo?.test.length; + `, + errors: [ + { + messageId: 'neverOptionalChain', + line: 9, + endLine: 9, + column: 10, + endColumn: 12, + }, + ], + }, ], }); From 0fb44ba3f46cef0a35fbd1eb862808cd106287d0 Mon Sep 17 00:00:00 2001 From: Jonathan Flower Date: Tue, 15 Nov 2022 13:52:47 -0500 Subject: [PATCH 33/76] docs(website): help troubleshoot issues with multiple parsers (#5612) * Help troubleshoot issues with multiple parsers This might not be a perfect fit for the typescript-eslint docs, since this is specific to Vue. However, I expect the issue effects other custom parsers as well. Including multiple parsers like this is counter intuitive because it seems like a mistake to include two "parser"s. It would have been a huge help to me to have found this in the troubleshooting guide. more info: https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser devs running into this issue: https://github.com/vuejs/vue-eslint-parser/issues/45#issuecomment-988625895 https://stackoverflow.com/questions/66597732/eslint-vue-3-parsing-error-expected-eslint * fix typos * grouping vue related questions * Apply suggestions from code review * More syntax highlighting Co-authored-by: Josh Goldberg --- docs/linting/TROUBLESHOOTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/linting/TROUBLESHOOTING.md b/docs/linting/TROUBLESHOOTING.md index e477267c476..8c8319a1aaf 100644 --- a/docs/linting/TROUBLESHOOTING.md +++ b/docs/linting/TROUBLESHOOTING.md @@ -86,6 +86,21 @@ module.exports = { }; ``` +## I am running into errors when parsing TypeScript in my .vue files + +If you are running into issues parsing .vue files, it might be because parsers like [`vue-eslint-parser`](https://www.npmjs.com/package/vue-eslint-parser) are required to parse `.vue` files. In this case you can move `@typescript-eslint/parser` inside `parserOptions` and use `vue-eslint-parser` as the top level parser. + +```diff +- "parser": "@typescript-eslint/parser", ++ "parser": "vue-eslint-parser", + "parserOptions": { ++ "parser": "@typescript-eslint/parser", + "sourceType": "module" + } +``` + +The `parserOptions.parser` option can also specify an object to specify multiple parsers. See the [`vue-eslint-parser` usage guide](https://eslint.vuejs.org/user-guide/#usage) for more details. + ## One of my lint rules isn't working correctly on a pure JavaScript file This is to be expected - ESLint rules do not check file extensions on purpose, as it causes issues in environments that use non-standard extensions (for example, a `.vue` and a `.md` file can both contain TypeScript code to be linted). From 2778ff0c3db011148be93ed3bea5ce07af3c81ef Mon Sep 17 00:00:00 2001 From: Omri Luzon Date: Wed, 16 Nov 2022 03:50:21 +0200 Subject: [PATCH 34/76] fix(eslint-plugin): [prefer-optional-chain] handle binary expressions in negated or (#5992) * fix/issue5991-fix-prefer-optional-chain-BinaryExpression-in-negated-or * CR --- packages/eslint-plugin/src/rules/prefer-optional-chain.ts | 1 + .../eslint-plugin/tests/rules/prefer-optional-chain.test.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index 89eb72094b6..73fbcc27af3 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -400,6 +400,7 @@ export default util.createRule({ case AST_NODE_TYPES.Literal: case AST_NODE_TYPES.TemplateLiteral: + case AST_NODE_TYPES.BinaryExpression: propertyText = sourceCode.getText(node.property); break; diff --git a/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts b/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts index 58b309edcc8..e1a1467d80f 100644 --- a/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-optional-chain.test.ts @@ -198,6 +198,8 @@ ruleTester.run('prefer-optional-chain', rule, { 'foo && foo[bar as string] && foo[bar as string].baz;', 'foo && foo[1 + 2] && foo[1 + 2].baz;', 'foo && foo[typeof bar] && foo[typeof bar].baz;', + '!foo[1 + 1] || !foo[1 + 2];', + '!foo[1 + 1] || !foo[1 + 1].foo;', '!foo || !foo[bar as string] || !foo[bar as string].baz;', '!foo || !foo[1 + 2] || !foo[1 + 2].baz;', '!foo || !foo[typeof bar] || !foo[typeof bar].baz;', From 81236b21b289d595d738591ee2c9374f2011bdf7 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 00:44:24 -0500 Subject: [PATCH 35/76] chore: reduce issue+pr lock delay to 7 days (#5974) --- .github/workflows/lock.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index fc8cea8a8ac..a7ef3bd4965 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -17,9 +17,9 @@ jobs: - uses: dessant/lock-threads@v3 with: github-token: ${{ github.token }} - issue-inactive-days: '30' + issue-inactive-days: '7' issue-lock-reason: 'resolved' issue-comment: '' - pr-inactive-days: '30' + pr-inactive-days: '7' pr-lock-reason: 'resolved' pr-comment: '' From 88d0316e60ee18bca5b74b87ad6efa6c1c418fb9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 00:47:27 -0500 Subject: [PATCH 36/76] chore(website): fix TSLint.md link casing in PACKAGES.md (#5976) --- docs/development/architecture/PACKAGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/architecture/PACKAGES.md b/docs/development/architecture/PACKAGES.md index f798e35b2e4..74ca39b3ae4 100644 --- a/docs/development/architecture/PACKAGES.md +++ b/docs/development/architecture/PACKAGES.md @@ -66,7 +66,7 @@ Any custom rules you write generally will be as well. [`@typescript-eslint/eslint-plugin-tslint`] is a separate ESLint plugin that allows running TSLint rules within ESLint to help you migrate from TSLint to ESLint. :::caution -**TSLint is deprecated.** It is in your best interest to migrate off it. See [Linting > Troubleshooting & FAQs > What About TSLint?](../../linting/troubleshooting/TSLINT.md). +**TSLint is deprecated.** It is in your best interest to migrate off it. See [Linting > Troubleshooting & FAQs > What About TSLint?](../../linting/troubleshooting/TSLint.md). ::: [`@typescript-eslint/eslint-plugin-tslint`]: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin-tslint From 88b1ac7b4167c0ebb694dcefbe297a985cfb4df1 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 00:49:42 -0500 Subject: [PATCH 37/76] docs(website): mention cross-file caching issues in FAQs (#5978) --- docs/linting/TROUBLESHOOTING.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/linting/TROUBLESHOOTING.md b/docs/linting/TROUBLESHOOTING.md index 8c8319a1aaf..5001a0a16fa 100644 --- a/docs/linting/TROUBLESHOOTING.md +++ b/docs/linting/TROUBLESHOOTING.md @@ -220,6 +220,25 @@ For example: See [this issue comment](https://github.com/typescript-eslint/typescript-eslint/issues/4102#issuecomment-963265514) for more details. +## Changes to one file are not reflected when linting other files in my IDE + +> tl;dr: Restart your ESLint server to force an update. + +ESLint currently does not have any way of telling parsers such as ours when an arbitrary file is changed on disk. +That means if you change file A that is imported by file B, it won't update lint caches for file B -- even if file B's text contents have changed. +Sometimes the only solution is to restart your ESLint editor extension altogether. + +See [this issue comment](https://github.com/typescript-eslint/typescript-eslint/issues/5845#issuecomment-1283248238 'GitHub issue 5845, comment 1283248238: details on ESLint cross-file caching') for more information. + +:::tip +[VS Code's ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) provides an `ESLint: Restart ESLint Server` action. +::: + +### I get `no-unsafe-*` complaints for cross-file changes + +See [Changes to one file are not reflected in linting other files in my IDE](#changes-to-one-file-are-not-reflected-in-linting-other-files-in-my-ide). +Rules such as [`no-unsafe-argument`](https://typescript-eslint.io/rules/no-unsafe-argument), [`no-unsafe-assignment`](https://typescript-eslint.io/rules/no-unsafe-assignment), and [`no-unsafe-call`](https://typescript-eslint.io/rules/no-unsafe-call) are often impacted. + ## My linting feels really slow 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. From dd9b3faf645d3db878dc270b5fdc33f75923f6f2 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 01:06:37 -0500 Subject: [PATCH 38/76] chore(eslint-plugin): switch generate-rules-lists to generate-breaking-changes (#5929) --- packages/eslint-plugin/package.json | 6 +- .../tools/generate-breaking-changes.ts | 156 ++++++++++++++++++ .../tools/generate-rules-lists.ts | 147 ----------------- packages/eslint-plugin/tsconfig.json | 9 +- yarn.lock | 5 + 5 files changed, 173 insertions(+), 150 deletions(-) create mode 100644 packages/eslint-plugin/tools/generate-breaking-changes.ts delete mode 100644 packages/eslint-plugin/tools/generate-rules-lists.ts diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index b4778013b7a..0e2ab6e436a 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -37,8 +37,8 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "generate:configs": "../../node_modules/.bin/ts-node --files --transpile-only tools/generate-configs.ts", - "generate:rules-lists": "../../node_modules/.bin/ts-node --files --transpile-only tools/generate-rules-lists.ts", + "generate:breaking-changes": "../../node_modules/.bin/ts-node tools/generate-breaking-changes.ts", + "generate:configs": "../../node_modules/.bin/ts-node tools/generate-configs.ts", "lint": "eslint . --ignore-path ../../.eslintignore", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" @@ -61,7 +61,9 @@ "@types/natural-compare-lite": "^1.4.0", "@types/prettier": "*", "chalk": "^5.0.1", + "cross-fetch": "^3.1.5", "json-schema": "*", + "markdown-table": "^3.0.2", "marked": "^4.0.15", "prettier": "*", "title-case": "^3.0.3", diff --git a/packages/eslint-plugin/tools/generate-breaking-changes.ts b/packages/eslint-plugin/tools/generate-breaking-changes.ts new file mode 100644 index 00000000000..9b1ecafff4c --- /dev/null +++ b/packages/eslint-plugin/tools/generate-breaking-changes.ts @@ -0,0 +1,156 @@ +// eslint-disable-next-line @typescript-eslint/consistent-type-imports +type RulesFile = typeof import('../src/rules'); + +interface RulesObject { + default: RulesFile; +} + +async function main(): Promise { + const { + default: { default: rules }, + } = + // @ts-expect-error -- We don't support ESM imports of local code yet. + (await import('../dist/rules/index.js')) as RulesObject; + const { markdownTable } = await import('markdown-table'); + const { fetch } = await import('cross-fetch'); + + const newRuleNames = await getNewRulesAsOfMajorVersion('5.0.0'); + + console.log(`## Table Key + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ColumnDescriptionEmojis
StatusBeing added, deprecated, or removed +
    +
  • 🆕 = newly added to TypeScript-ESLint
  • +
  • 🙅 = deprecated in the next major
  • +
  • ➖️ = to be removed from the plugin in the next version
  • +
+
ExtExtension rule? +
    +
  • ☑️ = yes
  • +
+
RRecommended +
    +
  • ➕ = add to recommended this version
  • +
  • ⚠️ = recommended as warning
  • +
  • 🛑 = recommended as an error
  • +
  • ➖️ = remove from recommended this version
  • +
+
RWTRecommended-requiring-type-checking +
    +
  • ➕ = add to recommended-with-typechecking this version
  • +
  • ⚠️ = recommended as warning
  • +
  • 🛑 = recommended as an error
  • +
  • ➖️ = remove from recommended this version
  • +
+
StrictStrict +
    +
  • ➕ = add to strict this version
  • +
  • ⚠️ = recommended as warning
  • +
  • ➖️ = remove from strict this version
  • +
+
+ +## Recommendations Table + +> Hint: search for 🆕 to find newly added rules, and ➕ or ➖ to see config changes. +`); + + console.log( + markdownTable([ + ['Rule', 'Status', 'Ext', 'R', 'RWT', 'Strict', 'Comment'], + ...Object.entries(rules).map(([ruleName, { meta }]) => { + const { deprecated } = meta; + const { extendsBaseRule, recommended, requiresTypeChecking } = + meta.docs!; + + return [ + `[\`${ruleName}\`](https://typescript-eslint.io/rules/${ruleName})`, + newRuleNames.has(ruleName) ? '🆕' : deprecated ? '🙅' : '', + extendsBaseRule ? '☑️' : '', + recommended && + ['error', 'warn'].includes(recommended) && + !requiresTypeChecking + ? '🛑' + : '', + recommended && + ['error', 'warn'].includes(recommended) && + requiresTypeChecking + ? '🛑' + : '', + recommended === 'strict' ? '⚠️' : '', + meta.type === 'layout' ? 'layout 💩' : '(todo)', + ]; + }), + ]), + ); + + // Annotate which rules are new since version 5.0.0 + async function getNewRulesAsOfMajorVersion( + oldVersion: string, + ): Promise> { + // 1. Get the current list of rules (already done) + const newRuleNames = Object.keys(rules); + + // 2. Use some CDN thing for the 5.X version of typescript-eslint + const oldUrl = `https://unpkg.com/@typescript-eslint/eslint-plugin@${oldVersion}/dist/configs/all.js`; + const oldFileText = await (await fetch(oldUrl)).text(); + const oldObjectText = oldFileText.substring( + oldFileText.indexOf('{'), + oldFileText.lastIndexOf('}') + 1, + ); + // Normally we wouldn't condone using the 'eval' API... + // But this is an internal-only script and it's the easiest way to convert + // the JS raw text into a runtime object. 🤷 + let oldRulesObject!: { rules: RulesFile }; + eval('oldRulesObject = ' + oldObjectText); + const oldRuleNames = new Set(Object.keys(oldRulesObject.rules)); + + // 3. Get the keys that exist in (1) (new version) and not (2) (old version) + return new Set( + newRuleNames.filter( + newRuleName => !oldRuleNames.has(`@typescript-eslint/${newRuleName}`), + ), + ); + } + + await getNewRulesAsOfMajorVersion('5.0.0'); +} + +main().catch(error => { + console.error(error); +}); diff --git a/packages/eslint-plugin/tools/generate-rules-lists.ts b/packages/eslint-plugin/tools/generate-rules-lists.ts deleted file mode 100644 index ce806cc2e8d..00000000000 --- a/packages/eslint-plugin/tools/generate-rules-lists.ts +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env ts-node - -import type { TSESLint } from '@typescript-eslint/utils'; -import fs from 'fs'; -import path from 'path'; -import prettier from 'prettier'; - -import rules from '../src/rules'; - -interface RuleDetails { - name: string; - description: string; - recommended: TSESLint.RuleRecommendation; - fixable: boolean; - requiresTypeChecking: boolean; - extendsBaseRule: boolean; -} - -type RuleColumn = [ - string, - string, - ':lock:' | ':white_check_mark:' | '', - ':wrench:' | '', - ':thought_balloon:' | '', -]; - -const emojiKey = { - recommended: ':white_check_mark:', - strict: ':lock:', - fixable: ':wrench:', - requiresTypeChecking: ':thought_balloon:', -} as const; - -const staticElements = { - rulesListKey: [ - `**Key**: ${emojiKey.recommended} = recommended`, - `${emojiKey.strict} = strict`, - `${emojiKey.fixable} = fixable`, - `${emojiKey.requiresTypeChecking} = requires type information`, - ].join(', '), - listHeaderRow: [ - 'Name', - 'Description', - `${emojiKey.recommended}${emojiKey.strict}`, - emojiKey.fixable, - emojiKey.requiresTypeChecking, - ], - listSpacerRow: Array(5).fill('-'), -}; - -const returnEmojiIfTrue = ( - key: TKey, - obj: { [K in TKey]?: unknown }, -): typeof emojiKey[TKey] | '' => (obj[key] ? emojiKey[key] : ''); - -const createRuleLink = (ruleName: string, basePath: string): string => - `[\`@typescript-eslint/${ruleName}\`](${basePath}${ruleName}.md)`; - -const buildRuleRow = (rule: RuleDetails, basePath: string): RuleColumn => [ - createRuleLink(rule.name, basePath), - rule.description, - rule.recommended === 'strict' - ? emojiKey.strict - : returnEmojiIfTrue('recommended', rule), - returnEmojiIfTrue('fixable', rule), - returnEmojiIfTrue('requiresTypeChecking', rule), -]; - -const buildRulesTable = ( - rules: RuleDetails[], - basePath: string, -): string[][] => [ - staticElements.listHeaderRow, - staticElements.listSpacerRow, - ...rules - .sort(({ name: ruleNameA }, { name: ruleNameB }) => - ruleNameA.localeCompare(ruleNameB), - ) - .map(item => buildRuleRow(item, basePath)), -]; - -const generateRulesListMarkdown = ( - rules: RuleDetails[], - basePath: string, -): string => - [ - '', - staticElements.rulesListKey, - '', - ...buildRulesTable(rules, basePath).map(column => - [...column, ' '].join('|'), - ), - '', - ].join('\n'); - -const updateRulesList = ( - listName: 'base' | 'extension', - rules: RuleDetails[], - markdown: string, - basePath: string, -): string => { - const listBeginMarker = ``; - const listEndMarker = ``; - - const listStartIndex = markdown.indexOf(listBeginMarker); - const listEndIndex = markdown.indexOf(listEndMarker); - - if (listStartIndex === -1 || listEndIndex === -1) { - throw new Error(`cannot find start or end of ${listName} list`); - } - - return [ - markdown.substring(0, listStartIndex - 1), - listBeginMarker, - '', - generateRulesListMarkdown(rules, basePath), // - markdown.substring(listEndIndex), - ].join('\n'); -}; - -const rulesDetails: RuleDetails[] = Object.entries(rules) - .filter(([, rule]) => rule.meta.deprecated !== true) - .map(([name, rule]) => ({ - name, - description: rule.meta.docs?.description ?? '', - recommended: rule.meta.docs?.recommended ?? false, - fixable: !!rule.meta.fixable, - requiresTypeChecking: rule.meta.docs?.requiresTypeChecking ?? false, - extendsBaseRule: !!rule.meta.docs?.extendsBaseRule ?? false, - })); - -const baseRules = rulesDetails.filter(rule => !rule.extendsBaseRule); -const extensionRules = rulesDetails.filter(rule => rule.extendsBaseRule); - -function updateFile(file: string, basePath: string): void { - let readme = fs.readFileSync(file, 'utf8'); - - readme = updateRulesList('base', baseRules, readme, basePath); - readme = updateRulesList('extension', extensionRules, readme, basePath); - - readme = prettier.format(readme, { parser: 'markdown' }); - - fs.writeFileSync(file, readme, 'utf8'); -} - -updateFile(path.resolve(__dirname, '../README.md'), './docs/rules/'); -updateFile(path.resolve(__dirname, '../docs/rules/README.md'), './'); diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json index 7801773b539..53deb3aa1bb 100644 --- a/packages/eslint-plugin/tsconfig.json +++ b/packages/eslint-plugin/tsconfig.json @@ -10,5 +10,12 @@ { "path": "../parser/tsconfig.build.json" }, { "path": "../scope-manager/tsconfig.build.json" }, { "path": "../type-utils/tsconfig.build.json" } - ] + ], + "ts-node": { + "compilerOptions": { + "module": "ESNext" + }, + "files": true, + "transpileOnly": true + } } diff --git a/yarn.lock b/yarn.lock index d77fd4dcba5..2a5699732e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9923,6 +9923,11 @@ markdown-it@13.0.1: mdurl "^1.0.1" uc.micro "^1.0.5" +markdown-table@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-3.0.2.tgz#9b59eb2c1b22fe71954a65ff512887065a7bb57c" + integrity sha512-y8j3a5/DkJCmS5x4dMCQL+OR0+2EAq3DOtio1COSHsmW2BGXnNCK3v12hJt1LrUz5iZH5g0LmuYOjDdI+czghA== + markdownlint-cli@^0.32.0: version "0.32.2" resolved "https://registry.yarnpkg.com/markdownlint-cli/-/markdownlint-cli-0.32.2.tgz#b7b5c5808039aef4022aef603efaa607caf8e0de" From ac7669ec6c1226dd6a5647ff0e69d02afeabd816 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 15 Nov 2022 23:52:58 -0800 Subject: [PATCH 39/76] docs(eslint-plugin): [no-shadow] add FAQ about enum members (#5986) Co-authored-by: Joshua Chen Co-authored-by: Josh Goldberg --- .../eslint-plugin/docs/rules/no-shadow.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/no-shadow.md b/packages/eslint-plugin/docs/rules/no-shadow.md index 3adb286e317..1dfadba55aa 100644 --- a/packages/eslint-plugin/docs/rules/no-shadow.md +++ b/packages/eslint-plugin/docs/rules/no-shadow.md @@ -78,3 +78,24 @@ Examples of **correct** code with `{ ignoreFunctionTypeParameterNameValueShadow: const test = 1; type Func = (test: string) => typeof test; ``` + +## FAQ + +### Why does the rule report on enum members that share the same name as a variable in a parent scope? + +Reporting on this case isn't a bug - it is completely intentional and correct reporting! The rule reports due to a relatively unknown feature of enums - enum members create a variable within the enum scope so that they can be referenced within the enum without a qualifier. + +To illustrate this with an example: + +```ts +const A = 2; +enum Test { + A = 1, + B = A, +} + +console.log(Test.B); +// what should be logged? +``` + +Naively looking at the above code, it might look like the log should output `2`, because the outer variable `A`'s value is `2` - however, the code instead outputs `1`, which is the value of `Test.A`. This is because the unqualified code `B = A` is equivalent to the fully-qualified code `B = Test.A`. Due to this behavior, the enum member has **shadowed** the outer variable declaration. From e7085763fbaf66b05eece2d133e1c72a9869a57f Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 08:56:01 -0500 Subject: [PATCH 40/76] chore(eslint-plugin): fix odd consistent-indexed-object-style docs phrasing (#5948) --- .../eslint-plugin/docs/rules/consistent-indexed-object-style.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md index 529d0719655..d8d805df692 100644 --- a/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md +++ b/packages/eslint-plugin/docs/rules/consistent-indexed-object-style.md @@ -6,7 +6,7 @@ description: 'Require or disallow the `Record` type.' > > See **https://typescript-eslint.io/rules/consistent-indexed-object-style** for documentation. -TypeScript supports defining object show keys can be flexible using an index signature. TypeScript also has a builtin type named `Record` to create an empty object defining only an index signature. For example, the following types are equal: +TypeScript supports defining arbitrary object keys using an index signature. TypeScript also has a builtin type named `Record` to create an empty object defining only an index signature. For example, the following types are equal: ```ts interface Foo { From 49f623f5d35754abb1a98f2ce4485914963d80c0 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 09:10:34 -0500 Subject: [PATCH 41/76] chore(website): revert "chore(website): fix TSLint.md link casing in PACKAGES.md" (#6001) Revert "chore(website): fix TSLint.md link casing in PACKAGES.md (#5976)" This reverts commit 88d0316e60ee18bca5b74b87ad6efa6c1c418fb9. --- docs/development/architecture/PACKAGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/architecture/PACKAGES.md b/docs/development/architecture/PACKAGES.md index 74ca39b3ae4..f798e35b2e4 100644 --- a/docs/development/architecture/PACKAGES.md +++ b/docs/development/architecture/PACKAGES.md @@ -66,7 +66,7 @@ Any custom rules you write generally will be as well. [`@typescript-eslint/eslint-plugin-tslint`] is a separate ESLint plugin that allows running TSLint rules within ESLint to help you migrate from TSLint to ESLint. :::caution -**TSLint is deprecated.** It is in your best interest to migrate off it. See [Linting > Troubleshooting & FAQs > What About TSLint?](../../linting/troubleshooting/TSLint.md). +**TSLint is deprecated.** It is in your best interest to migrate off it. See [Linting > Troubleshooting & FAQs > What About TSLint?](../../linting/troubleshooting/TSLINT.md). ::: [`@typescript-eslint/eslint-plugin-tslint`]: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin-tslint From 530e0e618cdf4bb956149bf8a8484848e1b9a1f5 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 16 Nov 2022 11:44:33 -0800 Subject: [PATCH 42/76] fix(typescript-estree): don't consider a cached program unless it's specified in the current `parserOptions.project` config (#5999) --- .../non-nullable-type-assertion-style.test.ts | 117 ++++++++++-------- .../src/create-program/createWatchProgram.ts | 10 ++ 2 files changed, 77 insertions(+), 50 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts b/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts index 4b0750c8c84..365de88c36a 100644 --- a/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts +++ b/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts @@ -1,14 +1,11 @@ -import path from 'path'; - import rule from '../../src/rules/non-nullable-type-assertion-style'; -import { RuleTester } from '../RuleTester'; +import { getFixturesRootDir, RuleTester } from '../RuleTester'; -const rootDir = path.resolve(__dirname, '../fixtures/'); const ruleTester = new RuleTester({ parserOptions: { sourceType: 'module', - tsconfigRootDir: rootDir, - project: './tsconfig.noUncheckedIndexedAccess.json', + tsconfigRootDir: getFixturesRootDir(), + project: './tsconfig.json', }, parser: '@typescript-eslint/parser', }); @@ -62,35 +59,6 @@ const x = 1 as 1; declare function foo(): T; const bar = foo() as number; `, - ` -function first(array: ArrayLike): T | null { - return array.length > 0 ? (array[0] as T) : null; -} - `, - ` -function first(array: ArrayLike): T | null { - return array.length > 0 ? (array[0] as T) : null; -} - `, - ` -function first(array: ArrayLike): T | null { - return array.length > 0 ? (array[0] as T) : null; -} - `, - ` -function first( - array: ArrayLike, -): T | null { - return array.length > 0 ? (array[0] as T) : null; -} - `, - ` -type A = 'a' | 'A'; -type B = 'b' | 'B'; -function first(array: ArrayLike): T | null { - return array.length > 0 ? (array[0] as T) : null; -} - `, ], invalid: [ @@ -229,24 +197,73 @@ declare const x: T; const y = x!; `, }, - { - code: ` -function first(array: ArrayLike): T | null { + ], +}); + +const ruleTesterWithNoUncheckedIndexAccess = new RuleTester({ + parserOptions: { + sourceType: 'module', + tsconfigRootDir: getFixturesRootDir(), + project: './tsconfig.noUncheckedIndexedAccess.json', + }, + parser: '@typescript-eslint/parser', +}); + +ruleTesterWithNoUncheckedIndexAccess.run( + 'non-nullable-type-assertion-style - noUncheckedIndexedAccess', + rule, + { + valid: [ + ` +function first(array: ArrayLike): T | null { return array.length > 0 ? (array[0] as T) : null; } `, - errors: [ - { - column: 30, - line: 3, - messageId: 'preferNonNullAssertion', - }, - ], - output: ` + ` +function first(array: ArrayLike): T | null { + return array.length > 0 ? (array[0] as T) : null; +} + `, + ` +function first(array: ArrayLike): T | null { + return array.length > 0 ? (array[0] as T) : null; +} + `, + ` +function first( + array: ArrayLike, +): T | null { + return array.length > 0 ? (array[0] as T) : null; +} + `, + ` +type A = 'a' | 'A'; +type B = 'b' | 'B'; +function first(array: ArrayLike): T | null { + return array.length > 0 ? (array[0] as T) : null; +} + `, + ], + invalid: [ + { + code: ` +function first(array: ArrayLike): T | null { + return array.length > 0 ? (array[0] as T) : null; +} + `, + errors: [ + { + column: 30, + line: 3, + messageId: 'preferNonNullAssertion', + }, + ], + output: ` function first(array: ArrayLike): T | null { return array.length > 0 ? (array[0]!) : null; } - `, - }, - ], -}); + `, + }, + ], + }, +); diff --git a/packages/typescript-estree/src/create-program/createWatchProgram.ts b/packages/typescript-estree/src/create-program/createWatchProgram.ts index 0e32f8ec1e5..d17835fff3c 100644 --- a/packages/typescript-estree/src/create-program/createWatchProgram.ts +++ b/packages/typescript-estree/src/create-program/createWatchProgram.ts @@ -159,11 +159,21 @@ function getProgramsForProjects(parseSettings: ParseSettings): ts.Program[] { ); } + const currentProjectsFromSettings = new Set(parseSettings.projects); + /* * before we go into the process of attempting to find and update every program * see if we know of a program that contains this file */ for (const [tsconfigPath, existingWatch] of knownWatchProgramMap.entries()) { + if (!currentProjectsFromSettings.has(tsconfigPath)) { + // the current parser run doesn't specify this tsconfig in parserOptions.project + // so we don't want to consider it for caching purposes. + // + // if we did consider it we might return a program for a project + // that wasn't specified in the current parser run (which is obv bad!). + continue; + } let fileList = programFileListCache.get(tsconfigPath); let updatedProgram: ts.Program | null = null; if (!fileList) { From 5f7ce69e8ab6d746143b055abfed2065d14468df Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 18:16:06 -0500 Subject: [PATCH 43/76] chore(website): explained and auto-balanced homepage sponsors list (#5996) --- .github/SPONSORSHIPS.md | 20 +++++++++-- packages/website/data/sponsors.json | 25 ------------- .../FinancialContributors/Sponsors/index.tsx | 21 ++++++----- .../Sponsors/styles.module.css | 36 +++++++++++-------- .../FinancialContributors/index.tsx | 10 ++++-- tools/generate-sponsors.ts | 36 +++---------------- 6 files changed, 59 insertions(+), 89 deletions(-) diff --git a/.github/SPONSORSHIPS.md b/.github/SPONSORSHIPS.md index 15638be935c..48d8ae5fc74 100644 --- a/.github/SPONSORSHIPS.md +++ b/.github/SPONSORSHIPS.md @@ -15,6 +15,23 @@ Sponsoring TypeScript ESLint helps keep our development process running reliably - Fix bugs and add new features to existing rules - Write more advanced rules to solve more areas of application correctness +### Sponsorship Benefits + +In addition to benefitting the TypeScript ecosystem, sponsoring us on Open Collective helps promote your company and development brand. +Our top sponsors may have their link, logo, and/or name featured on the homepage of [typescript-eslint.io](https://typescript-eslint.io). + +At present, sponsors must have given at least $100 to be featured on the homepage. +Placement tiers are based on total donations: + +- Platinum sponsors: Top 6 donators +- Gold supporters: The next 10 donators +- Silver supporters: The next 18 donators + +You can always view all financial contributors on [opencollective.com/typescript-eslint](https://opencollective.com/typescript-eslint). + +> Got an idea for how to make sponsorship work for you? +> Let us know at `typescripteslint@gmail.com`! + ## Sponsorship Limitations ### Project Direction @@ -25,7 +42,6 @@ If you have a need to push forward an area of work in TypeScript ESLint more urg ### Website Placement -Our top sponsors may have their link, logo, and/or name featured on the homepage of https://typescript-eslint.io. We are inclusive by default and allow all organizations that newly meet a monetary threshold to be added. However, at our discretion, we may remove organizations we feel we cannot promote in good conscience. Organizations would most commonly be removed if their core charter and/or repeated organization-wide intentional activities: @@ -35,5 +51,3 @@ Organizations would most commonly be removed if their core charter and/or repeat - Finance and/or promote other organizations that match these issues If you disagree with a choice made by the maintenance team, or would like a refund for your sponsorship, please let us know by emailing `typescripteslint@gmail.com`. - -> You can always view all financial contributors on [opencollective.com/typescript-eslint](https://opencollective.com/typescript-eslint). diff --git a/packages/website/data/sponsors.json b/packages/website/data/sponsors.json index fd44d68e52b..49d7576bf77 100644 --- a/packages/website/data/sponsors.json +++ b/packages/website/data/sponsors.json @@ -3,7 +3,6 @@ "id": "Indeed", "image": "https://images.opencollective.com/indeed/4b8725e/logo.png", "name": "Indeed", - "tier": "sponsor", "totalDonations": 1005000, "website": "https://Indeed.com" }, @@ -11,7 +10,6 @@ "id": "Nx (by Nrwl)", "image": "https://images.opencollective.com/nx/0efbe42/logo.png", "name": "Nx (by Nrwl)", - "tier": "sponsor", "totalDonations": 550000, "website": "https://nx.dev" }, @@ -19,7 +17,6 @@ "id": "ESLint", "image": "https://images.opencollective.com/eslint/96b09dc/logo.png", "name": "ESLint", - "tier": "sponsor", "totalDonations": 215000, "website": "https://eslint.org/" }, @@ -27,7 +24,6 @@ "id": "Airbnb", "image": "https://images.opencollective.com/airbnb/d327d66/logo.png", "name": "Airbnb", - "tier": "sponsor", "totalDonations": 140800, "website": "https://www.airbnb.com/" }, @@ -35,7 +31,6 @@ "id": "Coinbase", "image": "https://images.opencollective.com/coinbase/a202856/logo.png", "name": "Coinbase", - "tier": "sponsor", "totalDonations": 120000, "website": "https://blog.coinbase.com/engineering-and-security/home" }, @@ -43,7 +38,6 @@ "id": "n8n.io - n8n GmbH", "image": "https://images.opencollective.com/n8n/dca2f0c/logo.png", "name": "n8n.io - n8n GmbH", - "tier": "sponsor", "totalDonations": 115000, "website": "https://n8n.io" }, @@ -51,7 +45,6 @@ "id": "Sentry", "image": "https://images.opencollective.com/sentry/9620d33/logo.png", "name": "Sentry", - "tier": "sponsor", "totalDonations": 114800, "website": "https://sentry.io/welcome/" }, @@ -59,7 +52,6 @@ "id": "GitBook", "image": "https://images.opencollective.com/gitbook/d35a8e7/logo.png", "name": "GitBook", - "tier": "sponsor", "totalDonations": 110000, "website": "https://www.gitbook.com" }, @@ -67,7 +59,6 @@ "id": "Codecademy", "image": "https://images.opencollective.com/codecademy/d56a48d/logo.png", "name": "Codecademy", - "tier": "sponsor", "totalDonations": 100000, "website": "https://codecademy.com" }, @@ -75,7 +66,6 @@ "id": "EY Doberman", "image": "https://images.opencollective.com/ey-doberman/b269462/logo.png", "name": "EY Doberman", - "tier": "supporter", "totalDonations": 80400, "website": "https://doberman.co" }, @@ -83,7 +73,6 @@ "id": "Future Processing", "image": "https://images.opencollective.com/future-processing/1410d26/logo.png", "name": "Future Processing", - "tier": "supporter", "totalDonations": 54000, "website": "https://www.future-processing.com/" }, @@ -91,7 +80,6 @@ "id": "Sourcegraph", "image": "https://images.opencollective.com/sourcegraph/67e40ff/logo.png", "name": "Sourcegraph", - "tier": "supporter", "totalDonations": 50000, "website": "https://about.sourcegraph.com" }, @@ -99,7 +87,6 @@ "id": "Whitebox", "image": "https://images.opencollective.com/whiteboxinc/ef0d11d/logo.png", "name": "Whitebox", - "tier": "contributor", "totalDonations": 40000, "website": "https://whitebox.com" }, @@ -107,7 +94,6 @@ "id": "Monito", "image": "https://images.opencollective.com/monito/50fc878/logo.png", "name": "Monito", - "tier": "contributor", "totalDonations": 30000, "website": "https://www.monito.com" }, @@ -115,7 +101,6 @@ "id": "Codiga", "image": "https://images.opencollective.com/codiga/1065f9f/logo.png", "name": "Codiga", - "tier": "contributor", "totalDonations": 30000, "website": "https://www.codiga.io" }, @@ -123,7 +108,6 @@ "id": "STORIS", "image": "https://images.opencollective.com/storis/dfb0e13/logo.png", "name": "STORIS", - "tier": "contributor", "totalDonations": 27000, "website": "https://www.storis.com/" }, @@ -131,7 +115,6 @@ "id": "revo.js", "image": "https://images.opencollective.com/revojsro/82623a7/logo.png", "name": "revo.js", - "tier": "contributor", "totalDonations": 23000, "website": "https://revojs.ro" }, @@ -139,7 +122,6 @@ "id": "Ian MacLeod", "image": "https://images.opencollective.com/nevir/35c52ef/avatar.png", "name": "Ian MacLeod", - "tier": "contributor", "totalDonations": 22000, "website": "https://twitter.com/nevir" }, @@ -147,7 +129,6 @@ "id": "David Johnston", "image": "https://images.opencollective.com/blacksheepcode/976d69a/avatar.png", "name": "David Johnston", - "tier": "contributor", "totalDonations": 15000, "website": "https://blacksheepcode.com" }, @@ -155,7 +136,6 @@ "id": "Joe Alden", "image": "https://images.opencollective.com/joealden/44a6738/avatar.png", "name": "Joe Alden", - "tier": "contributor", "totalDonations": 14000, "website": "https://joealden.com" }, @@ -163,7 +143,6 @@ "id": "Gianfranco Palumbo", "image": "https://images.opencollective.com/gianpaj/5d62d25/avatar.png", "name": "Gianfranco Palumbo", - "tier": "contributor", "totalDonations": 10000, "website": "http://gian.xyz" }, @@ -171,7 +150,6 @@ "id": "Evil Martians", "image": "https://images.opencollective.com/evilmartians/707ab4d/logo.png", "name": "Evil Martians", - "tier": "contributor", "totalDonations": 10000, "website": "https://evilmartians.com/" }, @@ -179,7 +157,6 @@ "id": "The Guardian", "image": "https://images.opencollective.com/gdndevelopers/0b72bf0/logo.png", "name": "The Guardian", - "tier": "contributor", "totalDonations": 10000, "website": "https://www.theguardian.com/" }, @@ -187,7 +164,6 @@ "id": "Balsa", "image": "https://images.opencollective.com/balsa/77de498/logo.png", "name": "Balsa", - "tier": "contributor", "totalDonations": 10000, "website": "https://balsa.com" }, @@ -195,7 +171,6 @@ "id": "Laserhub", "image": "https://images.opencollective.com/laserhub/bae6275/logo.png", "name": "Laserhub", - "tier": "contributor", "totalDonations": 10000, "website": "https://laserhub.com/" } diff --git a/packages/website/src/components/FinancialContributors/Sponsors/index.tsx b/packages/website/src/components/FinancialContributors/Sponsors/index.tsx index c175cdc2615..dfcdad8c7b9 100644 --- a/packages/website/src/components/FinancialContributors/Sponsors/index.tsx +++ b/packages/website/src/components/FinancialContributors/Sponsors/index.tsx @@ -1,36 +1,35 @@ -import sponsors from '@site/data/sponsors.json'; import clsx from 'clsx'; import React from 'react'; import { Sponsor } from '../Sponsor'; -import type { SponsorIncludeOptions } from '../types'; +import type { SponsorData, SponsorIncludeOptions } from '../types'; import styles from './styles.module.css'; interface SponsorsProps { className: string; include?: SponsorIncludeOptions; expanded?: boolean; - tier?: string; + sponsors: SponsorData[]; title: string; + tier: string; } export function Sponsors({ className, include, - tier, title, + tier, + sponsors, }: SponsorsProps): JSX.Element { return (

{title}

    - {sponsors - .filter(sponsor => sponsor.tier === tier) - .map(sponsor => ( -
  • - -
  • - ))} + {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 e740c76f8bd..08e99b16488 100644 --- a/packages/website/src/components/FinancialContributors/Sponsors/styles.module.css +++ b/packages/website/src/components/FinancialContributors/Sponsors/styles.module.css @@ -15,7 +15,7 @@ .sponsorsTier li { list-style: none; margin: 5px; - max-width: 120px; + max-width: 130px; } .sponsorsTier img { @@ -29,40 +29,42 @@ border: none; } -.tier-sponsor { +.tier-platinum-sponsor { gap: 32px 16px; } -.tier-sponsor img { +.tier-platinum-sponsor img { display: inline-block; - max-height: 120px; - max-width: 120px; - width: 120px; + max-height: 130px; + max-width: 130px; + width: 130px; } -.tier-supporter, -.tier-contributor { +.tier-gold-supporter, +.tier-silver-supporter { align-items: center; } -.tier-supporter { +.tier-gold-supporter { font-size: 0.95rem; line-height: 1; - gap: 24px; - padding-top: 16px; + gap: 12px; + padding-top: 12px; } -.tier-supporter img { +.tier-gold-supporter img { max-height: 75px; max-width: 75px; width: 75px; } -.tier-contributor { - gap: 4px 24px; +.tier-silver-supporter { + gap: 4px 16px; + margin: auto; + max-width: 75%; } -.tier-contributor img { +.tier-silver-supporter img { max-height: 45px; max-width: 45px; width: 45px; @@ -81,4 +83,8 @@ width: auto; padding: 0 60px; } + + .tier-gold-supporter { + margin-bottom: 0; + } } diff --git a/packages/website/src/components/FinancialContributors/index.tsx b/packages/website/src/components/FinancialContributors/index.tsx index 609de140c9a..f952a5a4235 100644 --- a/packages/website/src/components/FinancialContributors/index.tsx +++ b/packages/website/src/components/FinancialContributors/index.tsx @@ -1,4 +1,5 @@ import Link from '@docusaurus/Link'; +import sponsors from '@site/data/sponsors.json'; import clsx from 'clsx'; import React from 'react'; @@ -16,19 +17,22 @@ export function FinancialContributors(): JSX.Element {
diff --git a/tools/generate-sponsors.ts b/tools/generate-sponsors.ts index eadeb1bb450..cbec8141ddc 100644 --- a/tools/generate-sponsors.ts +++ b/tools/generate-sponsors.ts @@ -92,10 +92,6 @@ interface MemberAccount { website: string; } -interface MemberAccountAndTier extends MemberAccount { - tier?: Tier; -} - const excludedNames = new Set([ 'Guest', // Apparent anonymous donor equivalent without an avatar 'Josh Goldberg', // Team member 💖 @@ -121,13 +117,12 @@ async function main(): Promise { ]); const accountsById = account.orders.nodes.reduce< - Record + Record >((accumulator, account) => { const name = account.fromAccount.name || account.fromAccount.id; accumulator[name] = { ...accumulator[name], ...account.fromAccount, - tier: account.tier, }; return accumulator; }, {}); @@ -145,7 +140,7 @@ async function main(): Promise { const allSponsorsConfig = collective.members.nodes .map(member => { const name = member.account.name || member.account.id; - const fromAccount: MemberAccountAndTier = { + const fromAccount = { ...member.account, ...accountsById[name], }; @@ -156,14 +151,13 @@ async function main(): Promise { id: name, image: fromAccount.imageUrl, name: fromAccount.name, - tier: getReportedTierSlug(totalDonations, website), totalDonations, twitterHandle: fromAccount.twitterHandle, website, }; }) - .filter(({ id, tier }) => { - if (uniqueNames.has(id) || !tier) { + .filter(({ id, totalDonations, website }) => { + if (uniqueNames.has(id) || totalDonations < 10000 || !website) { return false; } @@ -196,28 +190,6 @@ async function stringifyObject( }); } -function getReportedTierSlug( - totalDonations: number, - website: string, -): string | undefined { - if (!website) { - return undefined; - } - - if (totalDonations >= 1_000_00) { - return 'sponsor'; - } - if (totalDonations >= 500_00) { - return 'supporter'; - } - - if (totalDonations >= 100_00) { - return 'contributor'; - } - - return undefined; -} - main().catch(error => { console.error(error); process.exitCode = 1; From 4d46e6512c4e26f87620623b0614d19e41fe0ca9 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 16 Nov 2022 16:03:32 -0800 Subject: [PATCH 44/76] tests: add dependency constraints to eslint-plugin tests (#5916) --- .../rules/consistent-type-exports.test.ts | 21 +++++ .../rules/consistent-type-imports.test.ts | 13 +++ .../tests/rules/member-ordering.test.ts | 27 ++++++ ...habetically-case-insensitive-order.test.ts | 3 + ...mber-ordering-alphabetically-order.test.ts | 3 + .../rules/method-signature-style.test.ts | 44 ++++++++-- .../tests/rules/no-empty-function.test.ts | 6 ++ .../tests/rules/no-magic-numbers.test.ts | 3 + .../no-redundant-type-constituents.test.ts | 29 +++++-- .../tests/rules/no-shadow/no-shadow.test.ts | 15 ++++ .../tests/rules/no-type-alias.test.ts | 54 ++++++++++++ .../no-unnecessary-type-arguments.test.ts | 10 ++- .../no-unused-vars/no-unused-vars.test.ts | 57 +++++++++--- .../non-nullable-type-assertion-style.test.ts | 3 + .../restrict-template-expressions.test.ts | 5 ++ .../eslint-utils/rule-tester/RuleTester.ts | 19 ++-- .../rule-tester/RuleTester.test.ts | 87 ++----------------- 17 files changed, 287 insertions(+), 112 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts b/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts index 518050bebcf..e5f7bfbc2d3 100644 --- a/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts +++ b/packages/eslint-plugin/tests/rules/consistent-type-exports.test.ts @@ -266,6 +266,9 @@ export { type T, T }; type T = 1; export type { T, T }; `, + dependencyConstraints: { + typescript: '4.5', + }, errors: [ { messageId: 'typeOverValue', @@ -283,6 +286,9 @@ export { type/* */T, type /* */T, T }; type T = 1; export type { /* */T, /* */T, T }; `, + dependencyConstraints: { + typescript: '4.5', + }, errors: [ { messageId: 'typeOverValue', @@ -303,6 +309,9 @@ const x = 1; export type { T, T }; export { x }; `, + dependencyConstraints: { + typescript: '4.5', + }, errors: [ { messageId: 'singleExportIsType', @@ -322,6 +331,9 @@ type T = 1; const x = 1; export { type T, x }; `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ fixMixedExportsWithInlineTypeSpecifier: true }], errors: [ { @@ -340,6 +352,9 @@ export { type T, T }; type T = 1; export type { T, T }; `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ fixMixedExportsWithInlineTypeSpecifier: true }], errors: [ { @@ -362,6 +377,9 @@ export { export type { AnalyzeOptions, Definition as Foo, BlockScope as BScope } from '@typescript-eslint/scope-manager'; export { CatchScope as CScope } from '@typescript-eslint/scope-manager'; `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ fixMixedExportsWithInlineTypeSpecifier: false }], errors: [ { @@ -388,6 +406,9 @@ export { CatchScope as CScope, } from '@typescript-eslint/scope-manager'; `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ fixMixedExportsWithInlineTypeSpecifier: true }], errors: [ { diff --git a/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts b/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts index ee01b29c1b0..2d41b0c3f98 100644 --- a/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts +++ b/packages/eslint-plugin/tests/rules/consistent-type-imports.test.ts @@ -7,6 +7,10 @@ const ruleTester = new RuleTester({ ecmaVersion: 2020, sourceType: 'module', }, + // type-only imports were first added in TS3.8 + dependencyConstraints: { + typescript: '3.8', + }, }); const withMetaParserOptions = { @@ -191,6 +195,9 @@ ruleTester.run('consistent-type-imports', rule, { const b = B; `, options: [{ prefer: 'no-type-imports', fixStyle: 'inline-type-imports' }], + dependencyConstraints: { + typescript: '4.5', + }, }, // exports ` @@ -1891,6 +1898,9 @@ import { A, B } from 'foo'; type T = A; const b = B; `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ prefer: 'no-type-imports' }], errors: [ { @@ -1911,6 +1921,9 @@ import { B, type C } from 'foo'; type T = A | C; const b = B; `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ prefer: 'type-imports' }], errors: [ { diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index 538cfa733db..cfff3691476 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -29,6 +29,9 @@ interface Foo { } `, { + dependencyConstraints: { + typescript: '4.5', + }, code: ` // no accessibility === public interface Foo { @@ -1250,6 +1253,9 @@ class Foo { f = 1; } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['static-initialization', 'method', 'field'] }], }, { @@ -1260,6 +1266,9 @@ class Foo { static {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['method', 'field', 'static-initialization'] }], }, { @@ -1270,6 +1279,9 @@ class Foo { m() {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['field', 'static-initialization', 'method'] }], }, ` @@ -4029,6 +4041,9 @@ class Foo { f = 1; } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['method', 'field', 'static-initialization'] }], errors: [ { @@ -4059,6 +4074,9 @@ class Foo { static {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['static-initialization', 'method', 'field'] }], errors: [ { @@ -4080,6 +4098,9 @@ class Foo { m() {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['static-initialization', 'field', 'method'] }], errors: [ { @@ -4101,6 +4122,9 @@ class Foo { m() {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [{ default: ['field', 'static-initialization', 'method'] }], errors: [ { @@ -4124,6 +4148,9 @@ class Foo { md() {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [ { default: ['decorated-method', 'static-initialization', 'method'] }, ], diff --git a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts index 07db08e0e86..fd10c55fe91 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-case-insensitive-order.test.ts @@ -499,6 +499,9 @@ class Foo { static {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [ { default: { diff --git a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts index b7b5da85910..338b3a50ee9 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering/member-ordering-alphabetically-order.test.ts @@ -1694,6 +1694,9 @@ class Foo { static {} } `, + dependencyConstraints: { + typescript: '4.4', + }, options: [ { default: { diff --git a/packages/eslint-plugin/tests/rules/method-signature-style.test.ts b/packages/eslint-plugin/tests/rules/method-signature-style.test.ts index d2a88e9c02b..d9db8f5d6eb 100644 --- a/packages/eslint-plugin/tests/rules/method-signature-style.test.ts +++ b/packages/eslint-plugin/tests/rules/method-signature-style.test.ts @@ -32,22 +32,42 @@ interface Test { 'f!': (/* b */ x: any /* c */) => void; } `, - ` + { + code: ` interface Test { get f(): number; } - `, - ` + `, + dependencyConstraints: { + typescript: '4.3', + }, + }, + { + code: ` interface Test { set f(value: number): void; } - `, + `, + dependencyConstraints: { + typescript: '4.3', + }, + }, 'type Test = { readonly f: (a: string) => number };', "type Test = { ['f']?: (a: boolean) => void };", 'type Test = { readonly f?: (a?: T) => T };', "type Test = { readonly ['f']?: (a: T, b: T) => T };", - 'type Test = { get f(): number };', - 'type Test = { set f(value: number): void };', + { + code: 'type Test = { get f(): number };', + dependencyConstraints: { + typescript: '4.3', + }, + }, + { + code: 'type Test = { set f(value: number): void };', + dependencyConstraints: { + typescript: '4.3', + }, + }, ...batchedSingleLineTests({ options: ['method'], code: noFormat` @@ -56,15 +76,23 @@ interface Test { interface Test { f(a: T): T } interface Test { ['f'](a: T, b: T): T } interface Test { 'f!'(/* b */ x: any /* c */): void } - interface Test { get f(): number } - interface Test { set f(value: number): void } type Test = { readonly f(a: string): number } type Test = { ['f']?(a: boolean): void } type Test = { readonly f?(a?: T): T } type Test = { readonly ['f']?(a: T, b: T): T } + `, + }), + ...batchedSingleLineTests({ + options: ['method'], + code: noFormat` + interface Test { get f(): number } + interface Test { set f(value: number): void } type Test = { get f(): number } type Test = { set f(value: number): void } `, + dependencyConstraints: { + typescript: '4.3', + }, }), ], invalid: [ diff --git a/packages/eslint-plugin/tests/rules/no-empty-function.test.ts b/packages/eslint-plugin/tests/rules/no-empty-function.test.ts index 7d29b0fa5a2..7f35c79852c 100644 --- a/packages/eslint-plugin/tests/rules/no-empty-function.test.ts +++ b/packages/eslint-plugin/tests/rules/no-empty-function.test.ts @@ -78,6 +78,9 @@ class Foo extends Base { override foo() {} } `, + dependencyConstraints: { + typescript: '4.3', + }, options: [{ allow: ['overrideMethods'] }], }, ], @@ -206,6 +209,9 @@ class Foo extends Base { override foo() {} } `, + dependencyConstraints: { + typescript: '4.3', + }, errors: [ { messageId: 'unexpected', diff --git a/packages/eslint-plugin/tests/rules/no-magic-numbers.test.ts b/packages/eslint-plugin/tests/rules/no-magic-numbers.test.ts index 3be7590742a..d6aa21a799e 100644 --- a/packages/eslint-plugin/tests/rules/no-magic-numbers.test.ts +++ b/packages/eslint-plugin/tests/rules/no-magic-numbers.test.ts @@ -536,6 +536,9 @@ type Foo = { [K in keyof Other]: \`\${K & number}\`; }; `, + dependencyConstraints: { + typescript: '4.1', + }, options: [{ ignoreTypeIndexes: true }], errors: [ { diff --git a/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts b/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts index 454fb255f0e..29259f4b3f0 100644 --- a/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts +++ b/packages/eslint-plugin/tests/rules/no-redundant-type-constituents.test.ts @@ -154,11 +154,21 @@ ruleTester.run('no-redundant-type-constituents', rule, { type B = string; type T = B & null; `, - 'type T = `${string}` & null;', - ` - type B = \`\${string}\`; - type T = B & null; - `, + { + code: 'type T = `${string}` & null;', + dependencyConstraints: { + typescript: '4.1', + }, + }, + { + code: ` + type B = \`\${string}\`; + type T = B & null; + `, + dependencyConstraints: { + typescript: '4.1', + }, + }, ], invalid: [ @@ -442,6 +452,9 @@ ruleTester.run('no-redundant-type-constituents', rule, { }, { code: 'type T = `a${number}c` | string;', + dependencyConstraints: { + typescript: '4.1', + }, errors: [ { column: 10, @@ -458,6 +471,9 @@ ruleTester.run('no-redundant-type-constituents', rule, { type B = \`a\${number}c\`; type T = B | string; `, + dependencyConstraints: { + typescript: '4.1', + }, errors: [ { column: 18, @@ -471,6 +487,9 @@ ruleTester.run('no-redundant-type-constituents', rule, { }, { code: 'type T = `${number}` | string;', + dependencyConstraints: { + typescript: '4.1', + }, errors: [ { column: 10, diff --git a/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts b/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts index 1616051f0e3..d55e85b3d8f 100644 --- a/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts +++ b/packages/eslint-plugin/tests/rules/no-shadow/no-shadow.test.ts @@ -220,6 +220,9 @@ import { type foo } from './foo'; // 'foo' is already declared in the upper scope function doThing(foo: number) {} `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ ignoreTypeValueShadow: true }], }, { @@ -545,6 +548,9 @@ function doThing(foo: number) {} import { type foo } from './foo'; function doThing(foo: number) {} `, + dependencyConstraints: { + typescript: '4.5', + }, options: [{ ignoreTypeValueShadow: false }], errors: [ { @@ -672,6 +678,9 @@ declare module 'baz' { } } `, + dependencyConstraints: { + typescript: '4.5', + }, errors: [ { messageId: 'noShadow', @@ -692,6 +701,9 @@ declare module 'bar' { export type Foo = string; } `, + dependencyConstraints: { + typescript: '4.5', + }, errors: [ { messageId: 'noShadow', @@ -714,6 +726,9 @@ declare module 'bar' { } } `, + dependencyConstraints: { + typescript: '4.5', + }, errors: [ { messageId: 'noShadow', diff --git a/packages/eslint-plugin/tests/rules/no-type-alias.test.ts b/packages/eslint-plugin/tests/rules/no-type-alias.test.ts index 6a307454f51..ed2c00c9991 100644 --- a/packages/eslint-plugin/tests/rules/no-type-alias.test.ts +++ b/packages/eslint-plugin/tests/rules/no-type-alias.test.ts @@ -133,62 +133,107 @@ ruleTester.run('no-type-alias', rule, { }, { code: 'type Foo = `a-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'always' }], }, { code: 'type Foo = `a-${number}` | `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'always' }], }, { code: 'type Foo = `a-${number}` | `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions-and-intersections' }], }, { code: 'type Foo = `a-${number}` | `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions' }], }, { code: 'type Foo = `a-${number}` | `b-${number}` | `c-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'always' }], }, { code: 'type Foo = `a-${number}` | `b-${number}` | `c-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions-and-intersections' }], }, { code: 'type Foo = `a-${number}` | `b-${number}` | `c-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions' }], }, { code: 'type Foo = `a-${number}` & `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'always' }], }, { code: 'type Foo = `a-${number}` & `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions-and-intersections' }], }, { code: 'type Foo = `a-${number}` & `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-intersections' }], }, { code: 'type Foo = `a-${number}` & `b-${number}` & `c-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'always' }], }, { code: 'type Foo = `a-${number}` & `b-${number}` & `c-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions-and-intersections' }], }, { code: 'type Foo = `a-${number}` & `b-${number}` & `c-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-intersections' }], }, { code: 'type Foo = `a-${number}` | (`b-${number}` & `c-${number}`);', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'always' }], }, { code: 'type Foo = `a-${number}` | (`b-${number}` & `c-${number}`);', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'in-unions-and-intersections' }], }, { @@ -3402,6 +3447,9 @@ type Foo = { }, { code: 'type Foo = `foo-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, errors: [ { messageId: 'noTypeAlias', @@ -3415,6 +3463,9 @@ type Foo = { }, { code: 'type Foo = `a-${number}` | `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'never' }], errors: [ { @@ -3439,6 +3490,9 @@ type Foo = { }, { code: 'type Foo = `a-${number}` & `b-${number}`;', + dependencyConstraints: { + typescript: '4.1', + }, options: [{ allowAliases: 'never' }], errors: [ { diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-type-arguments.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-type-arguments.test.ts index 512407474e6..abedc24d274 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-type-arguments.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-type-arguments.test.ts @@ -127,11 +127,17 @@ class Foo extends Bar {} interface Bar {} class Foo implements Bar {} `, - ` + { + code: ` import { F } from './missing'; function bar() {} bar>(); - `, + `, + dependencyConstraints: { + // TS 4.5 improved type resolution for unresolved generics + typescript: '4.5', + }, + }, ` type A = T; type B = A; diff --git a/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts b/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts index 715d2e94385..ee2191a3f4c 100644 --- a/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unused-vars/no-unused-vars.test.ts @@ -402,7 +402,8 @@ export const map: { [name in Foo]: Bar } = { }; `, // 4.1 remapped mapped type - noFormat` + { + code: noFormat` type Foo = 'a' | 'b' | 'c'; type Bar = number; @@ -411,7 +412,11 @@ export const map: { [name in Foo as string]: Bar } = { b: 2, c: 3, }; - `, + `, + dependencyConstraints: { + typescript: '4.1', + }, + }, ` import { Nullable } from 'nullable'; class A { @@ -747,6 +752,9 @@ function foo(value: T): T { } export type Foo = typeof foo; `, + dependencyConstraints: { + typescript: '4.7', + }, }, // https://github.com/typescript-eslint/typescript-eslint/issues/2331 { @@ -922,7 +930,8 @@ export declare namespace Foo { } } `, - noFormat` + { + code: noFormat` class Foo { value: T; } @@ -930,7 +939,11 @@ class Bar { foo = Foo; } new Bar(); - `, + `, + dependencyConstraints: { + typescript: '4.7', + }, + }, { code: ` declare namespace A { @@ -946,21 +959,36 @@ declare function A(A: string): string; filename: 'foo.d.ts', }, // 4.1 template literal types - noFormat` + { + code: noFormat` type Color = 'red' | 'blue'; type Quantity = 'one' | 'two'; export type SeussFish = \`\${Quantity | Color} fish\`; - `, - noFormat` + `, + dependencyConstraints: { + typescript: '4.1', + }, + }, + { + code: noFormat` type VerticalAlignment = "top" | "middle" | "bottom"; type HorizontalAlignment = "left" | "center" | "right"; export declare function setAlignment(value: \`\${VerticalAlignment}-\${HorizontalAlignment}\`): void; - `, - noFormat` + `, + dependencyConstraints: { + typescript: '4.1', + }, + }, + { + code: noFormat` type EnthusiasticGreeting = \`\${Uppercase} - \${Lowercase} - \${Capitalize} - \${Uncapitalize}\`; export type HELLO = EnthusiasticGreeting<"heLLo">; - `, + `, + dependencyConstraints: { + typescript: '4.1', + }, + }, // https://github.com/typescript-eslint/typescript-eslint/issues/2714 { code: ` @@ -1028,7 +1056,8 @@ export class Foo { } } `, - ` + { + code: ` function foo() {} export class Foo { @@ -1038,7 +1067,11 @@ export class Foo { foo(); } } - `, + `, + dependencyConstraints: { + typescript: '4.4', + }, + }, ], invalid: [ diff --git a/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts b/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts index 365de88c36a..6826230b4fd 100644 --- a/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts +++ b/packages/eslint-plugin/tests/rules/non-nullable-type-assertion-style.test.ts @@ -207,6 +207,9 @@ const ruleTesterWithNoUncheckedIndexAccess = new RuleTester({ project: './tsconfig.noUncheckedIndexedAccess.json', }, parser: '@typescript-eslint/parser', + dependencyConstraints: { + typescript: '4.1', + }, }); ruleTesterWithNoUncheckedIndexAccess.run( diff --git a/packages/eslint-plugin/tests/rules/restrict-template-expressions.test.ts b/packages/eslint-plugin/tests/rules/restrict-template-expressions.test.ts index b0322b290ab..7e80bdbdf5d 100644 --- a/packages/eslint-plugin/tests/rules/restrict-template-expressions.test.ts +++ b/packages/eslint-plugin/tests/rules/restrict-template-expressions.test.ts @@ -358,6 +358,11 @@ ruleTester.run('restrict-template-expressions', rule, { return \`arg = \${arg}\`; } `, + dependencyConstraints: { + // TS 4.5 improved type printing to print the type T as `T` + // before that it was printed as `any` + typescript: '4.5', + }, errors: [ { messageId: 'invalidType', diff --git a/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts b/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts index 54a645ccf25..7350de3a975 100644 --- a/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts +++ b/packages/utils/src/eslint-utils/rule-tester/RuleTester.ts @@ -87,8 +87,11 @@ class RuleTester extends BaseRuleTester.RuleTester { } constructor(baseOptions: RuleTesterConfig) { + // eslint will hard-error if you include non-standard top-level properties + const { dependencyConstraints: _, ...baseOptionsSafeForESLint } = + baseOptions; super({ - ...baseOptions, + ...baseOptionsSafeForESLint, parserOptions: { ...baseOptions.parserOptions, warnOnUnsupportedTypeScriptVersion: @@ -204,14 +207,16 @@ class RuleTester extends BaseRuleTester.RuleTester { single test case. Hugely helps with the string-based valid test cases as it means they don't need to be made objects! + Also removes dependencyConstraints, which we support but ESLint core doesn't. */ - const addFilename = < + const normalizeTest = < T extends | ValidTestCase | InvalidTestCase, - >( - test: T, - ): T => { + >({ + dependencyConstraints: _, + ...test + }: T): Omit => { if (test.parser === TS_ESLINT_PARSER) { throw new Error(ERROR_MESSAGE); } @@ -223,8 +228,8 @@ class RuleTester extends BaseRuleTester.RuleTester { } return test; }; - tests.valid = tests.valid.map(addFilename); - tests.invalid = tests.invalid.map(addFilename); + tests.valid = tests.valid.map(normalizeTest); + tests.invalid = tests.invalid.map(normalizeTest); const hasOnly = ((): boolean => { for (const test of allTestsIterator) { diff --git a/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts b/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts index 2e620332942..57ac48b38c1 100644 --- a/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts +++ b/packages/utils/tests/eslint-utils/rule-tester/RuleTester.test.ts @@ -365,56 +365,32 @@ describe('RuleTester', () => { "invalid": [ { "code": "failing - major", - "dependencyConstraints": { - "totally-real-dependency": "999", - }, "errors": [], "filename": "file.ts", - "only": false, }, { "code": "failing - major.minor", - "dependencyConstraints": { - "totally-real-dependency": "999.0", - }, "errors": [], "filename": "file.ts", - "only": false, }, { "code": "failing - major.minor.patch", - "dependencyConstraints": { - "totally-real-dependency": "999.0.0", - }, "errors": [], "filename": "file.ts", - "only": false, }, ], "valid": [ { "code": "passing - major", - "dependencyConstraints": { - "totally-real-dependency": "10", - }, "filename": "file.ts", - "only": true, }, { "code": "passing - major.minor", - "dependencyConstraints": { - "totally-real-dependency": "10.0", - }, "filename": "file.ts", - "only": true, }, { "code": "passing - major.minor.patch", - "dependencyConstraints": { - "totally-real-dependency": "10.0.0", - }, "filename": "file.ts", - "only": true, }, ], } @@ -485,61 +461,28 @@ describe('RuleTester', () => { "invalid": [ { "code": "failing - major", - "dependencyConstraints": { - "totally-real-dependency": { - "range": "^999", - }, - }, "errors": [], "filename": "file.ts", - "only": false, }, { "code": "failing - major.minor", - "dependencyConstraints": { - "totally-real-dependency": { - "range": ">=999.0", - }, - }, "errors": [], "filename": "file.ts", - "only": false, }, { "code": "failing with options", - "dependencyConstraints": { - "totally-real-dependency-prerelease": { - "options": { - "includePrerelease": false, - }, - "range": "^10", - }, - }, "errors": [], "filename": "file.ts", - "only": false, }, ], "valid": [ { "code": "passing - major", - "dependencyConstraints": { - "totally-real-dependency": { - "range": "^10", - }, - }, "filename": "file.ts", - "only": true, }, { "code": "passing - major.minor", - "dependencyConstraints": { - "totally-real-dependency": { - "range": "<999", - }, - }, "filename": "file.ts", - "only": true, }, ], } @@ -595,49 +538,34 @@ describe('RuleTester', () => { "code": "no constraints is always run", "errors": [], "filename": "file.ts", - "only": true, }, { "code": "empty object is always run", - "dependencyConstraints": {}, "errors": [], "filename": "file.ts", - "only": true, }, { "code": "failing constraint", - "dependencyConstraints": { - "totally-real-dependency": "99999", - }, "errors": [], "filename": "file.ts", - "only": false, }, ], "valid": [ { "code": "string based is always run", "filename": "file.ts", - "only": true, }, { "code": "no constraints is always run", "filename": "file.ts", - "only": true, }, { "code": "empty object is always run", - "dependencyConstraints": {}, "filename": "file.ts", - "only": true, }, { "code": "passing constraint", - "dependencyConstraints": { - "totally-real-dependency": "10", - }, "filename": "file.ts", - "only": true, }, ], } @@ -690,11 +618,13 @@ describe('RuleTester', () => { expect(runSpy.mock.lastCall?.[2]).toMatchInlineSnapshot(` { "invalid": [ + { + "code": "failing", + "errors": [], + "filename": "file.ts", + }, { "code": "passing", - "dependencyConstraints": { - "totally-real-dependency": "10", - }, "errors": [], "filename": "file.ts", }, @@ -704,11 +634,12 @@ describe('RuleTester', () => { "code": "always passing string test", "filename": "file.ts", }, + { + "code": "failing", + "filename": "file.ts", + }, { "code": "passing", - "dependencyConstraints": { - "totally-real-dependency": "10", - }, "filename": "file.ts", }, ], From ab88f77acaee15a24d882131d77ac420899133db Mon Sep 17 00:00:00 2001 From: kmin-jeong <53456037+kmin-jeong@users.noreply.github.com> Date: Thu, 17 Nov 2022 15:30:04 +0900 Subject: [PATCH 45/76] chore(webpage): add id to homepage in h2 (#5951) * feat: add webpage id in h2 * fix: use Heading tag * fix:fix end typo * fix: add import heading * fix: separate className and Heading tag * fix: separate div className * fix:fix import * fix: add

tag * fix:fix id name and space * fix: use regex with - * fix: add replace regex about comma * fix:remove not use start --- packages/website/src/pages/index.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/website/src/pages/index.tsx b/packages/website/src/pages/index.tsx index 72939ebfce3..8dc318973cd 100644 --- a/packages/website/src/pages/index.tsx +++ b/packages/website/src/pages/index.tsx @@ -1,6 +1,7 @@ import Link from '@docusaurus/Link'; import useBaseUrl from '@docusaurus/useBaseUrl'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import Heading from '@theme/Heading'; import Layout from '@theme/Layout'; import clsx from 'clsx'; import React from 'react'; @@ -108,8 +109,15 @@ const features: FeatureItem[] = [ function Feature({ title, description }: FeatureItem): JSX.Element { return (

-

{title}

- {description} +
+ + {title} + +
+

{description}

Get Started @@ -161,7 +169,9 @@ function Home(): JSX.Element { ))}
-

Financial Contributors

+ + Financial Contributors +
From 97d3e56709ee19fdec39fd8b99d080db90b306e9 Mon Sep 17 00:00:00 2001 From: lsdsjy Date: Fri, 18 Nov 2022 01:17:21 +0800 Subject: [PATCH 46/76] feat(eslint-plugin): [adjacent-overload-signatures] check BlockStatement nodes (#5998) * fix(eslint-plugin): [adjacent-overload-signatures] check BlockStatement nodes * fix: test cases Co-authored-by: Josh Goldberg --- .../src/rules/adjacent-overload-signatures.ts | 5 +- .../adjacent-overload-signatures.test.ts | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts index 81877d08b39..5f5ddfc0aad 100644 --- a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts +++ b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts @@ -8,7 +8,8 @@ type RuleNode = | TSESTree.Program | TSESTree.TSModuleBlock | TSESTree.TSTypeLiteral - | TSESTree.TSInterfaceBody; + | TSESTree.TSInterfaceBody + | TSESTree.BlockStatement; type Member = | TSESTree.ClassElement | TSESTree.ProgramStatement @@ -121,6 +122,7 @@ export default util.createRule({ case AST_NODE_TYPES.Program: case AST_NODE_TYPES.TSModuleBlock: case AST_NODE_TYPES.TSInterfaceBody: + case AST_NODE_TYPES.BlockStatement: return node.body; case AST_NODE_TYPES.TSTypeLiteral: @@ -172,6 +174,7 @@ export default util.createRule({ TSModuleBlock: checkBodyForOverloadMethods, TSTypeLiteral: checkBodyForOverloadMethods, TSInterfaceBody: checkBodyForOverloadMethods, + BlockStatement: checkBodyForOverloadMethods, }; }, }); diff --git a/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts b/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts index 12cf859a84a..9a20771b4af 100644 --- a/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts +++ b/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts @@ -250,12 +250,64 @@ class Test { '#private'(): void; '#private'(arg: number): void {} +} + `, + // block statement + ` +function wrap() { + function foo(s: string); + function foo(n: number); + function foo(sn: string | number) {} +} + `, + ` +if (true) { + function foo(s: string); + function foo(n: number); + function foo(sn: string | number) {} } `, ], invalid: [ { code: ` +function wrap() { + function foo(s: string); + function foo(n: number); + type bar = number; + function foo(sn: string | number) {} +} + `, + errors: [ + { + messageId: 'adjacentSignature', + data: { name: 'foo' }, + line: 6, + column: 3, + }, + ], + }, + { + code: ` +if (true) { + function foo(s: string); + function foo(n: number); + let a = 1; + function foo(sn: string | number) {} + foo(a); +} + `, + errors: [ + { + messageId: 'adjacentSignature', + data: { name: 'foo' }, + line: 6, + column: 3, + }, + ], + }, + { + code: ` export function foo(s: string); export function foo(n: number); export function bar(): void {} From 4d744ea10ba03c66eebcb63e8722e9f0165fbeed Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Fri, 18 Nov 2022 08:37:53 +0900 Subject: [PATCH 47/76] feat: update to TypeScript 4.9 (#5716) * feat: update typescript to 4.9.1 * fix: add patch file for 4.9.1-beta * feat(typescript-estree): update version range * feat: run `generate-lib` script * chore: update patch for typescript * fix: run `lint-fix` * feat: update to typescript 4.9.2-rc * chore: run patch-package * chore: update `@types/node` --- package.json | 8 +++---- packages/scope-manager/src/lib/dom.ts | 18 +++++++++----- packages/scope-manager/src/lib/es2019.intl.ts | 11 +++++++++ packages/scope-manager/src/lib/es2019.ts | 2 ++ packages/scope-manager/src/lib/index.ts | 2 ++ packages/scope-manager/src/lib/webworker.ts | 6 +++++ .../src/referencer/Referencer.ts | 2 +- packages/types/src/lib.ts | 1 + .../src/parseSettings/warnAboutTSVersion.ts | 4 ++-- ...+4.8.3.patch => typescript+4.9.2-rc.patch} | 24 +++++++++---------- yarn.lock | 16 ++++++------- 11 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 packages/scope-manager/src/lib/es2019.intl.ts rename patches/{typescript+4.8.3.patch => typescript+4.9.2-rc.patch} (83%) diff --git a/package.json b/package.json index 4726e08400f..d739fdb0e90 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@types/lodash": "^4.14.182", "@types/marked": "^4.0.3", "@types/ncp": "^2.0.5", - "@types/node": "^18.0.0", + "@types/node": "^18.11.9", "@types/prettier": "^2.6.0", "@types/rimraf": "^3.0.2", "@types/semver": "^7.3.9", @@ -104,11 +104,11 @@ "tmp": "^0.2.1", "ts-node": "^10.7.0", "tslint": "^6.1.3", - "typescript": ">=3.3.1 <4.9.0" + "typescript": ">=3.3.1 <4.8.3 || 4.9.2-rc" }, "resolutions": { - "typescript": "~4.8.3", - "@types/node": "^18.0.0", + "typescript": "~4.9.2-rc", + "@types/node": "^18.11.9", "//": "Pin jest to v29 across the repo", "@jest/create-cache-key-function": "^29", "@jest/reporters": "^29", diff --git a/packages/scope-manager/src/lib/dom.ts b/packages/scope-manager/src/lib/dom.ts index dd8523bc66e..d13afa2b57b 100644 --- a/packages/scope-manager/src/lib/dom.ts +++ b/packages/scope-manager/src/lib/dom.ts @@ -66,7 +66,7 @@ export const dom = { DeviceMotionEventInit: TYPE, DeviceMotionEventRotationRateInit: TYPE, DeviceOrientationEventInit: TYPE, - DisplayMediaStreamConstraints: TYPE, + DisplayMediaStreamOptions: TYPE, DocumentTimelineOptions: TYPE, DoubleRange: TYPE, DragEventInit: TYPE, @@ -143,7 +143,6 @@ export const dom = { MediaMetadataInit: TYPE, MediaPositionState: TYPE, MediaQueryListEventInit: TYPE, - MediaRecorderErrorEventInit: TYPE, MediaRecorderOptions: TYPE, MediaSessionActionDetails: TYPE, MediaStreamAudioSourceOptions: TYPE, @@ -184,6 +183,7 @@ export const dom = { PeriodicWaveConstraints: TYPE, PeriodicWaveOptions: TYPE, PermissionDescriptor: TYPE, + PictureInPictureEventInit: TYPE, PointerEventInit: TYPE, PopStateEventInit: TYPE, PositionOptions: TYPE, @@ -243,6 +243,7 @@ export const dom = { RTCStats: TYPE, RTCTrackEventInit: TYPE, RTCTransportStats: TYPE, + ReadableStreamGetReaderOptions: TYPE, ReadableStreamReadDoneResult: TYPE, ReadableStreamReadValueResult: TYPE, ReadableWritablePair: TYPE, @@ -284,6 +285,8 @@ export const dom = { TransitionEventInit: TYPE, UIEventInit: TYPE, ULongRange: TYPE, + UnderlyingByteSource: TYPE, + UnderlyingDefaultSource: TYPE, UnderlyingSink: TYPE, UnderlyingSource: TYPE, ValidityStateFlags: TYPE, @@ -350,10 +353,13 @@ export const dom = { CSSConditionRule: TYPE_VALUE, CSSCounterStyleRule: TYPE_VALUE, CSSFontFaceRule: TYPE_VALUE, + CSSFontPaletteValuesRule: TYPE_VALUE, CSSGroupingRule: TYPE_VALUE, CSSImportRule: TYPE_VALUE, CSSKeyframeRule: TYPE_VALUE, CSSKeyframesRule: TYPE_VALUE, + CSSLayerBlockRule: TYPE_VALUE, + CSSLayerStatementRule: TYPE_VALUE, CSSMediaRule: TYPE_VALUE, CSSNamespaceRule: TYPE_VALUE, CSSPageRule: TYPE_VALUE, @@ -449,6 +455,7 @@ export const dom = { EXT_frag_depth: TYPE, EXT_sRGB: TYPE, EXT_shader_texture_lod: TYPE, + EXT_texture_compression_bptc: TYPE, EXT_texture_compression_rgtc: TYPE, EXT_texture_filter_anisotropic: TYPE, ElementEventMap: TYPE, @@ -641,7 +648,6 @@ export const dom = { MediaQueryListEvent: TYPE_VALUE, MediaRecorderEventMap: TYPE, MediaRecorder: TYPE_VALUE, - MediaRecorderErrorEvent: TYPE_VALUE, MediaSession: TYPE_VALUE, MediaSourceEventMap: TYPE, MediaSource: TYPE_VALUE, @@ -724,6 +730,7 @@ export const dom = { PermissionStatusEventMap: TYPE, PermissionStatus: TYPE_VALUE, Permissions: TYPE_VALUE, + PictureInPictureEvent: TYPE_VALUE, PictureInPictureWindowEventMap: TYPE, PictureInPictureWindow: TYPE_VALUE, Plugin: TYPE_VALUE, @@ -1123,8 +1130,6 @@ export const dom = { TimerHandler: TYPE, Transferable: TYPE, Uint32List: TYPE, - UvmEntries: TYPE, - UvmEntry: TYPE, VibratePattern: TYPE, WindowProxy: TYPE, XMLHttpRequestBodyInit: TYPE, @@ -1227,7 +1232,6 @@ export const dom = { RTCIceCandidateType: TYPE, RTCIceComponent: TYPE, RTCIceConnectionState: TYPE, - RTCIceCredentialType: TYPE, RTCIceGathererState: TYPE, RTCIceGatheringState: TYPE, RTCIceProtocol: TYPE, @@ -1243,6 +1247,8 @@ export const dom = { RTCSignalingState: TYPE, RTCStatsIceCandidatePairState: TYPE, RTCStatsType: TYPE, + ReadableStreamReaderMode: TYPE, + ReadableStreamType: TYPE, ReadyState: TYPE, RecordingState: TYPE, ReferrerPolicy: TYPE, diff --git a/packages/scope-manager/src/lib/es2019.intl.ts b/packages/scope-manager/src/lib/es2019.intl.ts new file mode 100644 index 00000000000..64b46f40ebb --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.intl.ts @@ -0,0 +1,11 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE: +// npx nx generate-lib @typescript-eslint/scope-manager + +import type { ImplicitLibVariableOptions } from '../variable'; +import { TYPE_VALUE } from './base-config'; + +export const es2019_intl = { + Intl: TYPE_VALUE, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.ts b/packages/scope-manager/src/lib/es2019.ts index 43e55a27a3a..cd6d33c1f5d 100644 --- a/packages/scope-manager/src/lib/es2019.ts +++ b/packages/scope-manager/src/lib/es2019.ts @@ -6,6 +6,7 @@ import type { ImplicitLibVariableOptions } from '../variable'; import { es2018 } from './es2018'; import { es2019_array } from './es2019.array'; +import { es2019_intl } from './es2019.intl'; import { es2019_object } from './es2019.object'; import { es2019_string } from './es2019.string'; import { es2019_symbol } from './es2019.symbol'; @@ -16,4 +17,5 @@ export const es2019 = { ...es2019_object, ...es2019_string, ...es2019_symbol, + ...es2019_intl, } as Record; diff --git a/packages/scope-manager/src/lib/index.ts b/packages/scope-manager/src/lib/index.ts index 989857ba152..dfee880fa16 100644 --- a/packages/scope-manager/src/lib/index.ts +++ b/packages/scope-manager/src/lib/index.ts @@ -38,6 +38,7 @@ import { es2018_regexp } from './es2018.regexp'; import { es2019 } from './es2019'; import { es2019_array } from './es2019.array'; import { es2019_full } from './es2019.full'; +import { es2019_intl } from './es2019.intl'; import { es2019_object } from './es2019.object'; import { es2019_string } from './es2019.string'; import { es2019_symbol } from './es2019.symbol'; @@ -124,6 +125,7 @@ const lib = { 'es2019.object': es2019_object, 'es2019.string': es2019_string, 'es2019.symbol': es2019_symbol, + 'es2019.intl': es2019_intl, 'es2020.bigint': es2020_bigint, 'es2020.date': es2020_date, 'es2020.promise': es2020_promise, diff --git a/packages/scope-manager/src/lib/webworker.ts b/packages/scope-manager/src/lib/webworker.ts index e44ce52113c..ccbb3efd3c4 100644 --- a/packages/scope-manager/src/lib/webworker.ts +++ b/packages/scope-manager/src/lib/webworker.ts @@ -88,6 +88,7 @@ export const webworker = { QueuingStrategyInit: TYPE, RTCEncodedAudioFrameMetadata: TYPE, RTCEncodedVideoFrameMetadata: TYPE, + ReadableStreamGetReaderOptions: TYPE, ReadableStreamReadDoneResult: TYPE, ReadableStreamReadValueResult: TYPE, ReadableWritablePair: TYPE, @@ -108,6 +109,8 @@ export const webworker = { TextDecoderOptions: TYPE, TextEncoderEncodeIntoResult: TYPE, Transformer: TYPE, + UnderlyingByteSource: TYPE, + UnderlyingDefaultSource: TYPE, UnderlyingSink: TYPE, UnderlyingSource: TYPE, VideoColorSpaceInit: TYPE, @@ -157,6 +160,7 @@ export const webworker = { EXT_frag_depth: TYPE, EXT_sRGB: TYPE, EXT_shader_texture_lod: TYPE, + EXT_texture_compression_bptc: TYPE, EXT_texture_compression_rgtc: TYPE, EXT_texture_filter_anisotropic: TYPE, ErrorEvent: TYPE_VALUE, @@ -431,6 +435,8 @@ export const webworker = { PremultiplyAlpha: TYPE, PushEncryptionKeyName: TYPE, RTCEncodedVideoFrameType: TYPE, + ReadableStreamReaderMode: TYPE, + ReadableStreamType: TYPE, ReferrerPolicy: TYPE, RequestCache: TYPE, RequestCredentials: TYPE, diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts index a69209e86c6..93b0270ebfb 100644 --- a/packages/scope-manager/src/referencer/Referencer.ts +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -675,7 +675,7 @@ class Referencer extends Visitor { member.id.type === AST_NODE_TYPES.Literal && typeof member.id.value === 'string' ) { - const name = member.id as TSESTree.StringLiteral; + const name = member.id; this.currentScope().defineLiteralIdentifier( name, new TSEnumMemberDefinition(name, member), diff --git a/packages/types/src/lib.ts b/packages/types/src/lib.ts index 0d92717fcb5..880bafe5b5e 100644 --- a/packages/types/src/lib.ts +++ b/packages/types/src/lib.ts @@ -46,6 +46,7 @@ type Lib = | 'es2019.object' | 'es2019.string' | 'es2019.symbol' + | 'es2019.intl' | 'es2020.bigint' | 'es2020.date' | 'es2020.promise' diff --git a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts index 6bd890bdae9..343e324307a 100644 --- a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts +++ b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts @@ -6,13 +6,13 @@ import type { ParseSettings } from './index'; * This needs to be kept in sync with the top-level README.md in the * typescript-eslint monorepo */ -const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <4.9.0'; +const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <5.0.0'; /* * The semver package will ignore prerelease ranges, and we don't want to explicitly document every one * List them all separately here, so we can automatically create the full string */ -const SUPPORTED_PRERELEASE_RANGES: string[] = []; +const SUPPORTED_PRERELEASE_RANGES: string[] = ['4.9.2-rc']; const ACTIVE_TYPESCRIPT_VERSION = ts.version; const isRunningSupportedTypeScriptVersion = semver.satisfies( ACTIVE_TYPESCRIPT_VERSION, diff --git a/patches/typescript+4.8.3.patch b/patches/typescript+4.9.2-rc.patch similarity index 83% rename from patches/typescript+4.8.3.patch rename to patches/typescript+4.9.2-rc.patch index a33162f7dec..520a9fde936 100644 --- a/patches/typescript+4.8.3.patch +++ b/patches/typescript+4.9.2-rc.patch @@ -1,18 +1,18 @@ diff --git a/node_modules/typescript/lib/typescript.d.ts b/node_modules/typescript/lib/typescript.d.ts -index 0fd60ae..02f4fe7 100644 +index 54e4c65..aa00912 100644 --- a/node_modules/typescript/lib/typescript.d.ts +++ b/node_modules/typescript/lib/typescript.d.ts -@@ -425,8 +425,8 @@ declare namespace ts { - JSDocFunctionType = 317, - JSDocVariadicType = 318, - JSDocNamepathType = 319, +@@ -428,8 +428,8 @@ declare namespace ts { + JSDocFunctionType = 320, + JSDocVariadicType = 321, + JSDocNamepathType = 322, + /** @deprecated This was only added in 4.7 */ - JSDoc = 320, + JSDoc = 323, - /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 320, - JSDocText = 321, - JSDocTypeLiteral = 322, -@@ -4374,7 +4374,13 @@ declare namespace ts { + JSDocComment = 323, + JSDocText = 324, + JSDocTypeLiteral = 325, +@@ -4395,7 +4395,13 @@ declare namespace ts { function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; @@ -26,7 +26,7 @@ index 0fd60ae..02f4fe7 100644 function getModifiers(node: HasModifiers): readonly Modifier[] | undefined; /** * Gets the JSDoc parameter tags for the node if present. -@@ -4834,7 +4840,13 @@ declare namespace ts { +@@ -4857,7 +4863,13 @@ declare namespace ts { } declare namespace ts { function setTextRange(range: T, location: TextRange | undefined): T; @@ -40,7 +40,7 @@ index 0fd60ae..02f4fe7 100644 function canHaveDecorators(node: Node): node is HasDecorators; } declare namespace ts { -@@ -7924,7 +7936,7 @@ declare namespace ts { +@@ -7958,7 +7970,7 @@ declare namespace ts { * const decorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined; * ``` */ diff --git a/yarn.lock b/yarn.lock index 2a5699732e8..3dcb81cfb59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4124,10 +4124,10 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@12.20.24", "@types/node@^17.0.5", "@types/node@^18.0.0": - version "18.8.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.8.3.tgz#ce750ab4017effa51aed6a7230651778d54e327c" - integrity sha512-0os9vz6BpGwxGe9LOhgP/ncvYN5Tx1fNcd2TM3rD/aCGBkysb+ZWpXEocG24h6ZzOi13+VB8HndAQFezsSOw1w== +"@types/node@*", "@types/node@12.20.24", "@types/node@^17.0.5", "@types/node@^18.11.9": + version "18.11.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.9.tgz#02d013de7058cea16d36168ef2fc653464cfbad4" + integrity sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg== "@types/normalize-package-data@^2.4.0": version "2.4.1" @@ -13627,10 +13627,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, "typescript@>=3.3.1 <4.9.0", "typescript@^3 || ^4", typescript@next, typescript@~4.8.3, typescript@~4.8.4: - version "4.8.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" - integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== +typescript@*, "typescript@>=3.3.1 <4.8.3 || 4.9.2-rc", "typescript@^3 || ^4", typescript@next, typescript@~4.8.4, typescript@~4.9.2-rc: + version "4.9.2-rc" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.2-rc.tgz#3525dbeb8458a8c98ce7d60724e4a9380d7b46e7" + integrity sha512-Ly9UUxJBfiiFjfegI1gsW9FI8Xhw1cuwRMBJ4wdYg+UXZR4VnZvD1OnBDj/iQ2U+tWbWEjYqJ5xx1Cwr4Vsa4w== ua-parser-js@^0.7.30: version "0.7.31" From a40a311bb52a2b1cfac43851b201f8cfc96c8d5d Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 18 Nov 2022 10:17:28 +1030 Subject: [PATCH 48/76] chore: bump TS from 4.9RC to 4.9 --- package.json | 4 +-- .../scope-manager/src/lib/dom.iterable.ts | 1 + packages/scope-manager/src/lib/dom.ts | 10 +++++- .../src/lib/webworker.iterable.ts | 2 ++ packages/scope-manager/src/lib/webworker.ts | 34 ++++++++++++++++++- .../src/parseSettings/warnAboutTSVersion.ts | 2 +- ...+4.9.2-rc.patch => typescript+4.9.3.patch} | 0 yarn.lock | 8 ++--- 8 files changed, 52 insertions(+), 9 deletions(-) rename patches/{typescript+4.9.2-rc.patch => typescript+4.9.3.patch} (100%) diff --git a/package.json b/package.json index d739fdb0e90..f7c782af36e 100644 --- a/package.json +++ b/package.json @@ -104,10 +104,10 @@ "tmp": "^0.2.1", "ts-node": "^10.7.0", "tslint": "^6.1.3", - "typescript": ">=3.3.1 <4.8.3 || 4.9.2-rc" + "typescript": ">=3.3.1 <5.0.0" }, "resolutions": { - "typescript": "~4.9.2-rc", + "typescript": "~4.9.3", "@types/node": "^18.11.9", "//": "Pin jest to v29 across the repo", "@jest/create-cache-key-function": "^29", diff --git a/packages/scope-manager/src/lib/dom.iterable.ts b/packages/scope-manager/src/lib/dom.iterable.ts index d294d684ddc..1d43661478b 100644 --- a/packages/scope-manager/src/lib/dom.iterable.ts +++ b/packages/scope-manager/src/lib/dom.iterable.ts @@ -13,6 +13,7 @@ export const dom_iterable = { CSSRuleList: TYPE, CSSStyleDeclaration: TYPE, Cache: TYPE, + CanvasPath: TYPE, CanvasPathDrawingStyles: TYPE, DOMRectList: TYPE, DOMStringList: TYPE, diff --git a/packages/scope-manager/src/lib/dom.ts b/packages/scope-manager/src/lib/dom.ts index d13afa2b57b..1087a238dfc 100644 --- a/packages/scope-manager/src/lib/dom.ts +++ b/packages/scope-manager/src/lib/dom.ts @@ -292,7 +292,7 @@ export const dom = { ValidityStateFlags: TYPE, VideoColorSpaceInit: TYPE, VideoConfiguration: TYPE, - VideoFrameMetadata: TYPE, + VideoFrameCallbackMetadata: TYPE, WaveShaperOptions: TYPE, WebGLContextAttributes: TYPE, WebGLContextEventInit: TYPE, @@ -351,6 +351,7 @@ export const dom = { CDATASection: TYPE_VALUE, CSSAnimation: TYPE_VALUE, CSSConditionRule: TYPE_VALUE, + CSSContainerRule: TYPE_VALUE, CSSCounterStyleRule: TYPE_VALUE, CSSFontFaceRule: TYPE_VALUE, CSSFontPaletteValuesRule: TYPE_VALUE, @@ -458,6 +459,7 @@ export const dom = { EXT_texture_compression_bptc: TYPE, EXT_texture_compression_rgtc: TYPE, EXT_texture_filter_anisotropic: TYPE, + EXT_texture_norm16: TYPE, ElementEventMap: TYPE, Element: TYPE_VALUE, ElementCSSInlineStyle: TYPE, @@ -689,6 +691,7 @@ export const dom = { NonElementParentNode: TYPE, NotificationEventMap: TYPE, Notification: TYPE_VALUE, + OES_draw_buffers_indexed: TYPE, OES_element_index_uint: TYPE, OES_fbo_render_mipmap: TYPE, OES_standard_derivatives: TYPE, @@ -701,6 +704,9 @@ export const dom = { OfflineAudioCompletionEvent: TYPE_VALUE, OfflineAudioContextEventMap: TYPE, OfflineAudioContext: TYPE_VALUE, + OffscreenCanvasEventMap: TYPE, + OffscreenCanvas: TYPE_VALUE, + OffscreenCanvasRenderingContext2D: TYPE_VALUE, OscillatorNode: TYPE_VALUE, OverconstrainedError: TYPE_VALUE, PageTransitionEvent: TYPE_VALUE, @@ -1118,6 +1124,7 @@ export const dom = { MessageEventSource: TYPE, MutationRecordType: TYPE, NamedCurve: TYPE, + OffscreenRenderingContext: TYPE, OnBeforeUnloadEventHandler: TYPE, OnErrorEventHandler: TYPE, PerformanceEntryList: TYPE, @@ -1208,6 +1215,7 @@ export const dom = { NavigationTimingType: TYPE, NotificationDirection: TYPE, NotificationPermission: TYPE, + OffscreenRenderingContextId: TYPE, OrientationLockType: TYPE, OrientationType: TYPE, OscillatorType: TYPE, diff --git a/packages/scope-manager/src/lib/webworker.iterable.ts b/packages/scope-manager/src/lib/webworker.iterable.ts index e4b0fb8b940..5ff03255ece 100644 --- a/packages/scope-manager/src/lib/webworker.iterable.ts +++ b/packages/scope-manager/src/lib/webworker.iterable.ts @@ -8,6 +8,8 @@ import { TYPE } from './base-config'; export const webworker_iterable = { Cache: TYPE, + CanvasPath: TYPE, + CanvasPathDrawingStyles: TYPE, DOMStringList: TYPE, FileList: TYPE, FontFaceSet: TYPE, diff --git a/packages/scope-manager/src/lib/webworker.ts b/packages/scope-manager/src/lib/webworker.ts index ccbb3efd3c4..bddb6bf9aa4 100644 --- a/packages/scope-manager/src/lib/webworker.ts +++ b/packages/scope-manager/src/lib/webworker.ts @@ -132,9 +132,23 @@ export const webworker = { ByteLengthQueuingStrategy: TYPE_VALUE, Cache: TYPE_VALUE, CacheStorage: TYPE_VALUE, + CanvasCompositing: TYPE, + CanvasDrawImage: TYPE, + CanvasDrawPath: TYPE, + CanvasFillStrokeStyles: TYPE, + CanvasFilters: TYPE, CanvasGradient: TYPE_VALUE, + CanvasImageData: TYPE, + CanvasImageSmoothing: TYPE, CanvasPath: TYPE, + CanvasPathDrawingStyles: TYPE, CanvasPattern: TYPE_VALUE, + CanvasRect: TYPE, + CanvasShadowStyles: TYPE, + CanvasState: TYPE, + CanvasText: TYPE, + CanvasTextDrawingStyles: TYPE, + CanvasTransform: TYPE, Client: TYPE_VALUE, Clients: TYPE_VALUE, CloseEvent: TYPE_VALUE, @@ -163,6 +177,7 @@ export const webworker = { EXT_texture_compression_bptc: TYPE, EXT_texture_compression_rgtc: TYPE, EXT_texture_filter_anisotropic: TYPE, + EXT_texture_norm16: TYPE, ErrorEvent: TYPE_VALUE, Event: TYPE_VALUE, EventListener: TYPE, @@ -225,6 +240,7 @@ export const webworker = { NotificationEventMap: TYPE, Notification: TYPE_VALUE, NotificationEvent: TYPE_VALUE, + OES_draw_buffers_indexed: TYPE, OES_element_index_uint: TYPE, OES_fbo_render_mipmap: TYPE, OES_standard_derivatives: TYPE, @@ -234,7 +250,9 @@ export const webworker = { OES_texture_half_float_linear: TYPE, OES_vertex_array_object: TYPE, OVR_multiview2: TYPE, - OffscreenCanvas: TYPE, + OffscreenCanvasEventMap: TYPE, + OffscreenCanvas: TYPE_VALUE, + OffscreenCanvasRenderingContext2D: TYPE_VALUE, Path2D: TYPE_VALUE, PerformanceEventMap: TYPE, Performance: TYPE_VALUE, @@ -392,6 +410,7 @@ export const webworker = { Int32List: TYPE, MessageEventSource: TYPE, NamedCurve: TYPE, + OffscreenRenderingContext: TYPE, OnErrorEventHandler: TYPE, PerformanceEntryList: TYPE, PushMessageDataInit: TYPE, @@ -406,6 +425,16 @@ export const webworker = { VibratePattern: TYPE, XMLHttpRequestBodyInit: TYPE, BinaryType: TYPE, + CanvasDirection: TYPE, + CanvasFillRule: TYPE, + CanvasFontKerning: TYPE, + CanvasFontStretch: TYPE, + CanvasFontVariantCaps: TYPE, + CanvasLineCap: TYPE, + CanvasLineJoin: TYPE, + CanvasTextAlign: TYPE, + CanvasTextBaseline: TYPE, + CanvasTextRendering: TYPE, ClientTypes: TYPE, ColorGamut: TYPE, ColorSpaceConversion: TYPE, @@ -415,12 +444,14 @@ export const webworker = { FontFaceLoadStatus: TYPE, FontFaceSetLoadStatus: TYPE, FrameType: TYPE, + GlobalCompositeOperation: TYPE, HdrMetadataType: TYPE, IDBCursorDirection: TYPE, IDBRequestReadyState: TYPE, IDBTransactionDurability: TYPE, IDBTransactionMode: TYPE, ImageOrientation: TYPE, + ImageSmoothingQuality: TYPE, KeyFormat: TYPE, KeyType: TYPE, KeyUsage: TYPE, @@ -429,6 +460,7 @@ export const webworker = { MediaEncodingType: TYPE, NotificationDirection: TYPE, NotificationPermission: TYPE, + OffscreenRenderingContextId: TYPE, PermissionName: TYPE, PermissionState: TYPE, PredefinedColorSpace: TYPE, diff --git a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts index 343e324307a..ad9a74157d6 100644 --- a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts +++ b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts @@ -12,7 +12,7 @@ const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <5.0.0'; * The semver package will ignore prerelease ranges, and we don't want to explicitly document every one * List them all separately here, so we can automatically create the full string */ -const SUPPORTED_PRERELEASE_RANGES: string[] = ['4.9.2-rc']; +const SUPPORTED_PRERELEASE_RANGES: string[] = []; const ACTIVE_TYPESCRIPT_VERSION = ts.version; const isRunningSupportedTypeScriptVersion = semver.satisfies( ACTIVE_TYPESCRIPT_VERSION, diff --git a/patches/typescript+4.9.2-rc.patch b/patches/typescript+4.9.3.patch similarity index 100% rename from patches/typescript+4.9.2-rc.patch rename to patches/typescript+4.9.3.patch diff --git a/yarn.lock b/yarn.lock index 3dcb81cfb59..07d19a8fc38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13627,10 +13627,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, "typescript@>=3.3.1 <4.8.3 || 4.9.2-rc", "typescript@^3 || ^4", typescript@next, typescript@~4.8.4, typescript@~4.9.2-rc: - version "4.9.2-rc" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.2-rc.tgz#3525dbeb8458a8c98ce7d60724e4a9380d7b46e7" - integrity sha512-Ly9UUxJBfiiFjfegI1gsW9FI8Xhw1cuwRMBJ4wdYg+UXZR4VnZvD1OnBDj/iQ2U+tWbWEjYqJ5xx1Cwr4Vsa4w== +typescript@*, "typescript@>=3.3.1 <5.0.0", "typescript@^3 || ^4", typescript@next, typescript@~4.8.4, typescript@~4.9.3: + version "4.9.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db" + integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA== ua-parser-js@^0.7.30: version "0.7.31" From 20d7caee35ab84ae6381fdf04338c9e2b9e2bc48 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Fri, 18 Nov 2022 09:33:47 +0900 Subject: [PATCH 49/76] feat: support parsing `satisfies` operators (#5717) Co-authored-by: Josh Goldberg Co-authored-by: Brad Zacher --- .prettierignore | 3 + README.md | 2 +- package.json | 12 +- packages/ast-spec/src/ast-node-types.ts | 1 + .../fixtures/array-array/fixture.ts | 1 + .../array-array/snapshots/1-TSESTree-AST.shot | 149 ++++++++++++++++ .../snapshots/2-TSESTree-Tokens.shot | 166 ++++++++++++++++++ .../array-array/snapshots/3-Babel-AST.shot | 149 ++++++++++++++++ .../array-array/snapshots/4-Babel-Tokens.shot | 166 ++++++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../arrow-func-no-parentheses/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 68 +++++++ .../snapshots/2-TSESTree-Tokens.shot | 66 +++++++ .../snapshots/3-Babel-AST.shot | 68 +++++++ .../snapshots/4-Babel-Tokens.shot | 66 +++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../arrow-func-with-parentheses/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 87 +++++++++ .../snapshots/2-TSESTree-Tokens.shot | 116 ++++++++++++ .../snapshots/3-Babel-AST.shot | 87 +++++++++ .../snapshots/4-Babel-Tokens.shot | 116 ++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 93 ++++++++++ .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/chained-satisfies/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 91 ++++++++++ .../snapshots/2-TSESTree-Tokens.shot | 66 +++++++ .../snapshots/3-Babel-AST.shot | 91 ++++++++++ .../snapshots/4-Babel-Tokens.shot | 66 +++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../conditional-no-parentheses/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 84 +++++++++ .../snapshots/2-TSESTree-Tokens.shot | 86 +++++++++ .../snapshots/3-Babel-AST.shot | 84 +++++++++ .../snapshots/4-Babel-Tokens.shot | 86 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../conditional-with-parentheses/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 84 +++++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++++ .../snapshots/3-Babel-AST.shot | 84 +++++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/identifier-keyword/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 53 ++++++ .../snapshots/2-TSESTree-Tokens.shot | 46 +++++ .../snapshots/3-Babel-AST.shot | 53 ++++++ .../snapshots/4-Babel-Tokens.shot | 46 +++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../identifier-object-type/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 104 +++++++++++ .../snapshots/2-TSESTree-Tokens.shot | 86 +++++++++ .../snapshots/3-Babel-AST.shot | 104 +++++++++++ .../snapshots/4-Babel-Tokens.shot | 86 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixtures/identifier-tuple-type/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 115 ++++++++++++ .../snapshots/2-TSESTree-Tokens.shot | 106 +++++++++++ .../snapshots/3-Babel-AST.shot | 115 ++++++++++++ .../snapshots/4-Babel-Tokens.shot | 106 +++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../logical-no-parentheses/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 74 ++++++++ .../snapshots/2-TSESTree-Tokens.shot | 66 +++++++ .../snapshots/3-Babel-AST.shot | 74 ++++++++ .../snapshots/4-Babel-Tokens.shot | 66 +++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../logical-with-parentheses/fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 74 ++++++++ .../snapshots/2-TSESTree-Tokens.shot | 86 +++++++++ .../snapshots/3-Babel-AST.shot | 74 ++++++++ .../snapshots/4-Babel-Tokens.shot | 86 +++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 128 ++++++++++++++ .../snapshots/2-TSESTree-Tokens.shot | 146 +++++++++++++++ .../snapshots/3-Babel-AST.shot | 128 ++++++++++++++ .../snapshots/4-Babel-Tokens.shot | 146 +++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../fixture.ts | 1 + .../snapshots/1-TSESTree-AST.shot | 128 ++++++++++++++ .../snapshots/2-TSESTree-Tokens.shot | 146 +++++++++++++++ .../snapshots/3-Babel-AST.shot | 128 ++++++++++++++ .../snapshots/4-Babel-Tokens.shot | 146 +++++++++++++++ .../snapshots/5-AST-Alignment-AST.shot | 6 + .../snapshots/6-AST-Alignment-Tokens.shot | 6 + .../expression/TSSatisfiesExpression/spec.ts | 10 ++ packages/ast-spec/src/expression/spec.ts | 1 + packages/ast-spec/src/unions/Expression.ts | 2 + packages/ast-spec/src/unions/Node.ts | 2 + .../tests/fixtures-with-differences-ast.shot | 1 + packages/typescript-estree/src/convert.ts | 8 + .../src/ts-estree/estree-to-ts-node-types.ts | 1 + .../src/ts-estree/ts-nodes.ts | 1 + .../tests/ast-alignment/fixtures-to-test.ts | 5 + packages/visitor-keys/src/visitor-keys.ts | 1 + yarn.lock | 118 ++++++++++++- 106 files changed, 5467 insertions(+), 11 deletions(-) create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/fixture.ts create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/1-TSESTree-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/2-TSESTree-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/3-Babel-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/4-Babel-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/5-AST-Alignment-AST.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/6-AST-Alignment-Tokens.shot create mode 100644 packages/ast-spec/src/expression/TSSatisfiesExpression/spec.ts diff --git a/.prettierignore b/.prettierignore index 637f32f77bf..88af276a1b2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,6 +12,9 @@ packages/eslint-plugin/src/configs/*.json CONTRIBUTORS.md packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts +# prettier doesn't yet support satisfies +packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/ + # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/README.md b/README.md index bddf59d198b..93bee2f66dc 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ The latest version under the `canary` tag **(latest commit to `main`)** is: ### Supported TypeScript Version -**The version range of TypeScript currently supported by this parser is `>=3.3.1 <4.9.0`.** +**The version range of TypeScript currently supported by this parser is `>=3.3.1 <5.0.0`.** These versions are what we test against. diff --git a/package.json b/package.json index f7c782af36e..e13d754021e 100644 --- a/package.json +++ b/package.json @@ -49,10 +49,11 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "devDependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/eslint-parser": "^7.18.2", - "@babel/parser": "^7.18.0", - "@babel/types": "^7.18.2", + "@babel/code-frame": "^7.18.6", + "@babel/core": "^7.20.2", + "@babel/eslint-parser": "^7.19.1", + "@babel/parser": "^7.20.3", + "@babel/types": "^7.20.2", "@nrwl/nx-cloud": "14.7.0", "@nrwl/workspace": "14.8.4", "@swc/core": "^1.3.1", @@ -109,7 +110,7 @@ "resolutions": { "typescript": "~4.9.3", "@types/node": "^18.11.9", - "//": "Pin jest to v29 across the repo", + "//": "Stub out unnecessary swc packages to improve install size and speed", "@jest/create-cache-key-function": "^29", "@jest/reporters": "^29", "@jest/test-result": "^29", @@ -121,7 +122,6 @@ "jest-snapshot": "^29", "jest-util": "^29", "pretty-format": "^29", - "//": "Stub out unnecessary swc packages to improve install size and speed", "@swc/core-android-arm-eabi": "npm:dummypkg-a@1.0.0", "@swc/core-android-arm64": "npm:dummypkg-a@1.0.0", "@swc/core-freebsd-x64": "npm:dummypkg-a@1.0.0", diff --git a/packages/ast-spec/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts index ff90dd1ee18..dbed6723fed 100644 --- a/packages/ast-spec/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -145,6 +145,7 @@ export enum AST_NODE_TYPES { TSQualifiedName = 'TSQualifiedName', TSReadonlyKeyword = 'TSReadonlyKeyword', TSRestType = 'TSRestType', + TSSatisfiesExpression = 'TSSatisfiesExpression', TSStaticKeyword = 'TSStaticKeyword', TSStringKeyword = 'TSStringKeyword', TSSymbolKeyword = 'TSSymbolKeyword', diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts new file mode 100644 index 00000000000..917317da825 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts @@ -0,0 +1 @@ +[1,2,3] satisfies [1, 2, 3]; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..8c0e41971ea --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,149 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression array-array TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ArrayExpression { + type: "ArrayExpression", + elements: Array [ + Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [3, 4], + loc: { + start: { column: 3, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Literal { + type: "Literal", + raw: "3", + value: 3, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ], + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + typeAnnotation: TSTupleType { + type: "TSTupleType", + elementTypes: Array [ + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "3", + value: 3, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + + range: [18, 27], + loc: { + start: { column: 18, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..1bde181188c --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,166 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression array-array TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "[", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [2, 3], + loc: { + start: { column: 2, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [3, 4], + loc: { + start: { column: 3, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "3", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "3", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..d7f5aec514e --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot @@ -0,0 +1,149 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression array-array Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ArrayExpression { + type: "ArrayExpression", + elements: Array [ + Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [3, 4], + loc: { + start: { column: 3, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Literal { + type: "Literal", + raw: "3", + value: 3, + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ], + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + typeAnnotation: TSTupleType { + type: "TSTupleType", + elementTypes: Array [ + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "3", + value: 3, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + + range: [18, 27], + loc: { + start: { column: 18, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..02abe5d8cba --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,166 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression array-array Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "[", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [2, 3], + loc: { + start: { column: 2, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [3, 4], + loc: { + start: { column: 3, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "3", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "3", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..3cf7cab2487 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression array-array AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..263f9da8e6c --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression array-array AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts new file mode 100644 index 00000000000..8478834cb78 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts @@ -0,0 +1 @@ +() => 1 satisfies number diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..57067f8fbff --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-no-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: ArrowFunctionExpression { + type: "ArrowFunctionExpression", + async: false, + body: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [6, 24], + loc: { + start: { column: 6, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + expression: true, + generator: false, + id: null, + params: Array [], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..09102ae267b --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-no-parentheses TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [3, 5], + loc: { + start: { column: 3, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..1ef0e54b35d --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-no-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: ArrowFunctionExpression { + type: "ArrowFunctionExpression", + async: false, + body: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [6, 24], + loc: { + start: { column: 6, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + expression: true, + generator: false, + id: null, + params: Array [], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..24cc5b2042e --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-no-parentheses Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [3, 5], + loc: { + start: { column: 3, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [18, 24], + loc: { + start: { column: 18, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..4697cea82c6 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-no-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..7fd90338cb4 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-no-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts new file mode 100644 index 00000000000..15624b9aaf3 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts @@ -0,0 +1 @@ +(() => 1) satisfies () => number diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..7fa95a22000 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ArrowFunctionExpression { + type: "ArrowFunctionExpression", + async: false, + body: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + expression: true, + generator: false, + id: null, + params: Array [], + + range: [1, 8], + loc: { + start: { column: 1, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + typeAnnotation: TSFunctionType { + type: "TSFunctionType", + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [23, 32], + loc: { + start: { column: 23, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [20, 32], + loc: { + start: { column: 20, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b590cfdea64 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parentheses TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [2, 3], + loc: { + start: { column: 2, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [4, 6], + loc: { + start: { column: 4, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [10, 19], + loc: { + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [23, 25], + loc: { + start: { column: 23, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..71627f35b04 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ArrowFunctionExpression { + type: "ArrowFunctionExpression", + async: false, + body: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + expression: true, + generator: false, + id: null, + params: Array [], + + range: [1, 8], + loc: { + start: { column: 1, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + typeAnnotation: TSFunctionType { + type: "TSFunctionType", + parameters: Array [], + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [23, 32], + loc: { + start: { column: 23, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [20, 32], + loc: { + start: { column: 20, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..58d8821988a --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parentheses Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [2, 3], + loc: { + start: { column: 2, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [4, 6], + loc: { + start: { column: 4, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [10, 19], + loc: { + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=>", + + range: [23, 25], + loc: { + start: { column: 23, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b45b591c63d --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ExpressionStatement { + type: 'ExpressionStatement', + expression: TSSatisfiesExpression { + type: 'TSSatisfiesExpression', + expression: ArrowFunctionExpression { + type: 'ArrowFunctionExpression', + async: false, + body: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + expression: true, + generator: false, + id: null, + params: Array [], + + range: [1, 8], + loc: { + start: { column: 1, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + typeAnnotation: TSFunctionType { + type: 'TSFunctionType', +- params: Array [], +- returnType: TSTypeAnnotation { ++ parameters: Array [], ++ typeAnnotation: TSTypeAnnotation { + type: 'TSTypeAnnotation', + typeAnnotation: TSNumberKeyword { + type: 'TSNumberKeyword', + + range: [26, 32], + loc: { + start: { column: 26, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [23, 32], + loc: { + start: { column: 23, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [20, 32], + loc: { + start: { column: 20, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..f3d317fb4b7 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/fixture.ts new file mode 100644 index 00000000000..65dcd3629bd --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/fixture.ts @@ -0,0 +1 @@ +foo satisfies bar satisfies baz; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..508caf4b944 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression chained-satisfies TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + name: "bar", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + typeAnnotation: TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + name: "baz", + + range: [28, 31], + loc: { + start: { column: 28, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [28, 31], + loc: { + start: { column: 28, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..dd0ebe5a72f --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression chained-satisfies TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "bar", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [18, 27], + loc: { + start: { column: 18, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "baz", + + range: [28, 31], + loc: { + start: { column: 28, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..190d8d14fd0 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/3-Babel-AST.shot @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression chained-satisfies Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + name: "bar", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + typeAnnotation: TSTypeReference { + type: "TSTypeReference", + typeName: Identifier { + type: "Identifier", + name: "baz", + + range: [28, 31], + loc: { + start: { column: 28, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [28, 31], + loc: { + start: { column: 28, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..5afc144ecef --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression chained-satisfies Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "bar", + + range: [14, 17], + loc: { + start: { column: 14, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [18, 27], + loc: { + start: { column: 18, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "baz", + + range: [28, 31], + loc: { + start: { column: 28, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..0d7d689095e --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression chained-satisfies AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..b7cbaaf6bb8 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/chained-satisfies/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression chained-satisfies AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts new file mode 100644 index 00000000000..6ead32331fa --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts @@ -0,0 +1 @@ +foo ? 1 : 0 satisfies number; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..5674f78acdf --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-no-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: ConditionalExpression { + type: "ConditionalExpression", + alternate: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Literal { + type: "Literal", + raw: "0", + value: 0, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [10, 28], + loc: { + start: { column: 10, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + consequent: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + test: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..579fa0c0615 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-no-parentheses TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "0", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..9c3ff77da55 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-no-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: ConditionalExpression { + type: "ConditionalExpression", + alternate: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Literal { + type: "Literal", + raw: "0", + value: 0, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [10, 28], + loc: { + start: { column: 10, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + consequent: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + test: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..d9c69f96e5e --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-no-parentheses Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "0", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a35b55978ba --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-no-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..220450772c1 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-no-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/fixture.ts new file mode 100644 index 00000000000..5c71ca2d0e6 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/fixture.ts @@ -0,0 +1 @@ +(foo ? 1 : 0) satisfies number; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..2194d921890 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-with-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ConditionalExpression { + type: "ConditionalExpression", + alternate: Literal { + type: "Literal", + raw: "0", + value: 0, + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + consequent: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + test: Identifier { + type: "Identifier", + name: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + + range: [1, 12], + loc: { + start: { column: 1, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [24, 30], + loc: { + start: { column: 24, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..09ed0254895 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-with-parentheses TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "0", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [14, 23], + loc: { + start: { column: 14, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [24, 30], + loc: { + start: { column: 24, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..39a9e9951ad --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-with-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ConditionalExpression { + type: "ConditionalExpression", + alternate: Literal { + type: "Literal", + raw: "0", + value: 0, + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + consequent: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + test: Identifier { + type: "Identifier", + name: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + + range: [1, 12], + loc: { + start: { column: 1, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [24, 30], + loc: { + start: { column: 24, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..7ca2b46ad24 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-with-parentheses Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "?", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "0", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [14, 23], + loc: { + start: { column: 14, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [24, 30], + loc: { + start: { column: 24, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..45e35dfc272 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-with-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..36442e7ebdc --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression conditional-with-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/fixture.ts new file mode 100644 index 00000000000..2ce6678d398 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/fixture.ts @@ -0,0 +1 @@ +foo satisfies boolean; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..7b7bb15a5af --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-keyword TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSBooleanKeyword { + type: "TSBooleanKeyword", + + range: [14, 21], + loc: { + start: { column: 14, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..3563bcb2809 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-keyword TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "boolean", + + range: [14, 21], + loc: { + start: { column: 14, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..8be9fb16653 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/3-Babel-AST.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-keyword Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSBooleanKeyword { + type: "TSBooleanKeyword", + + range: [14, 21], + loc: { + start: { column: 14, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..2559a7666c6 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-keyword Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "boolean", + + range: [14, 21], + loc: { + start: { column: 14, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..c167cbcb46b --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-keyword AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..7dad93b1da3 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-keyword/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-keyword AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/fixture.ts new file mode 100644 index 00000000000..cdcca67f637 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/fixture.ts @@ -0,0 +1 @@ +foo satisfies { prop: 'value' }; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..6197262c7a0 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-object-type TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "'value'", + value: "value", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [16, 29], + loc: { + start: { column: 16, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + + range: [14, 31], + loc: { + start: { column: 14, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..99673ea1ecf --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-object-type TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + String { + type: "String", + value: "'value'", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..a2861a34b1f --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/3-Babel-AST.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-object-type Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "'value'", + value: "value", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [16, 29], + loc: { + start: { column: 16, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + + range: [14, 31], + loc: { + start: { column: 14, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..34926c2bea7 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-object-type Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + String { + type: "String", + value: "'value'", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..8e025552275 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-object-type AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..bfb99b63e1c --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-object-type/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-object-type AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/fixture.ts new file mode 100644 index 00000000000..266a2ad0836 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/fixture.ts @@ -0,0 +1 @@ +foo satisfies [1, 2, 3]; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..57c80c5a805 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,115 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-tuple-type TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSTupleType { + type: "TSTupleType", + elementTypes: Array [ + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "3", + value: 3, + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [14, 23], + loc: { + start: { column: 14, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..07ece3eadee --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-tuple-type TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "3", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..7201de5d38f --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/3-Babel-AST.shot @@ -0,0 +1,115 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-tuple-type Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + typeAnnotation: TSTupleType { + type: "TSTupleType", + elementTypes: Array [ + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "2", + value: 2, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "3", + value: 3, + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [14, 23], + loc: { + start: { column: 14, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..8a62c8d0380 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-tuple-type Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [4, 13], + loc: { + start: { column: 4, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "[", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "2", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "3", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "]", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..eb993d611eb --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-tuple-type AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..3f0aa9841e8 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/identifier-tuple-type/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression identifier-tuple-type AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts new file mode 100644 index 00000000000..09a4c612e30 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts @@ -0,0 +1 @@ +foo === 1 satisfies number; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..f80151c9032 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-no-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: BinaryExpression { + type: "BinaryExpression", + left: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + operator: "===", + right: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [20, 26], + loc: { + start: { column: 20, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [8, 26], + loc: { + start: { column: 8, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..5391022e27f --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-no-parentheses TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "===", + + range: [4, 7], + loc: { + start: { column: 4, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [10, 19], + loc: { + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [20, 26], + loc: { + start: { column: 20, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..60189a70358 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-no-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: BinaryExpression { + type: "BinaryExpression", + left: Identifier { + type: "Identifier", + name: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + operator: "===", + right: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + typeAnnotation: TSNumberKeyword { + type: "TSNumberKeyword", + + range: [20, 26], + loc: { + start: { column: 20, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [8, 26], + loc: { + start: { column: 8, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..cac159f58dc --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-no-parentheses Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "foo", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "===", + + range: [4, 7], + loc: { + start: { column: 4, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [10, 19], + loc: { + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "number", + + range: [20, 26], + loc: { + start: { column: 20, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a21b35204c9 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-no-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..6a3c807848a --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-no-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/fixture.ts new file mode 100644 index 00000000000..a93f5746e7c --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/fixture.ts @@ -0,0 +1 @@ +(foo === 1) satisfies boolean; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..4401893b67e --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-with-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: BinaryExpression { + type: "BinaryExpression", + left: Identifier { + type: "Identifier", + name: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + operator: "===", + right: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [1, 10], + loc: { + start: { column: 1, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + typeAnnotation: TSBooleanKeyword { + type: "TSBooleanKeyword", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..7034fce1187 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-with-parentheses TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "===", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "boolean", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..fb10fc5442e --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-with-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: BinaryExpression { + type: "BinaryExpression", + left: Identifier { + type: "Identifier", + name: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + operator: "===", + right: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [1, 10], + loc: { + start: { column: 1, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + typeAnnotation: TSBooleanKeyword { + type: "TSBooleanKeyword", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..4c73b5cc818 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-with-parentheses Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [1, 4], + loc: { + start: { column: 1, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "===", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "boolean", + + range: [22, 29], + loc: { + start: { column: 22, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..28594822212 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-with-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..b6881fd10cf --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-with-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression logical-with-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts new file mode 100644 index 00000000000..ec7b71c8e2b --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts @@ -0,0 +1 @@ +({ prop: 'string' }) satisfies { prop: string }; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..1ed0e662a99 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,128 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-inner-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ObjectExpression { + type: "ObjectExpression", + properties: Array [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: "'string'", + value: "string", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [3, 17], + loc: { + start: { column: 3, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + + range: [1, 19], + loc: { + start: { column: 1, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSStringKeyword { + type: "TSStringKeyword", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [37, 45], + loc: { + start: { column: 37, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [33, 45], + loc: { + start: { column: 33, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [31, 47], + loc: { + start: { column: 31, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [0, 47], + loc: { + start: { column: 0, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..99f068a424b --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,146 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-inner-parentheses TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + String { + type: "String", + value: "'string'", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [21, 30], + loc: { + start: { column: 21, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c5868aaf0d1 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,128 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-inner-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ObjectExpression { + type: "ObjectExpression", + properties: Array [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: "'string'", + value: "string", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [3, 17], + loc: { + start: { column: 3, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + + range: [1, 19], + loc: { + start: { column: 1, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSStringKeyword { + type: "TSStringKeyword", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [37, 45], + loc: { + start: { column: 37, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + + range: [33, 45], + loc: { + start: { column: 33, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + ], + + range: [31, 47], + loc: { + start: { column: 31, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [0, 47], + loc: { + start: { column: 0, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..128fc9c6128 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,146 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-inner-parentheses Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + String { + type: "String", + value: "'string'", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [21, 30], + loc: { + start: { column: 21, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [33, 37], + loc: { + start: { column: 33, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [37, 38], + loc: { + start: { column: 37, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [39, 45], + loc: { + start: { column: 39, line: 1 }, + end: { column: 45, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..bad308efe92 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-inner-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..92a052f3254 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-inner-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/fixture.ts new file mode 100644 index 00000000000..b7726f7f140 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/fixture.ts @@ -0,0 +1 @@ +({ prop: 'string' } satisfies { prop: string }); diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..9100755681a --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,128 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-outer-parentheses TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ObjectExpression { + type: "ObjectExpression", + properties: Array [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: "'string'", + value: "string", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [3, 17], + loc: { + start: { column: 3, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + + range: [1, 19], + loc: { + start: { column: 1, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [32, 36], + loc: { + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSStringKeyword { + type: "TSStringKeyword", + + range: [38, 44], + loc: { + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + + range: [36, 44], + loc: { + start: { column: 36, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + + range: [32, 44], + loc: { + start: { column: 32, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + ], + + range: [30, 46], + loc: { + start: { column: 30, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + + range: [1, 46], + loc: { + start: { column: 1, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..388f2790bb0 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,146 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-outer-parentheses TSESTree - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + String { + type: "String", + value: "'string'", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [32, 36], + loc: { + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [36, 37], + loc: { + start: { column: 36, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [38, 44], + loc: { + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [45, 46], + loc: { + start: { column: 45, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..16adf4fa64a --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/3-Babel-AST.shot @@ -0,0 +1,128 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-outer-parentheses Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExpressionStatement { + type: "ExpressionStatement", + expression: TSSatisfiesExpression { + type: "TSSatisfiesExpression", + expression: ObjectExpression { + type: "ObjectExpression", + properties: Array [ + Property { + type: "Property", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + kind: "init", + method: false, + shorthand: false, + value: Literal { + type: "Literal", + raw: "'string'", + value: "string", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + + range: [3, 17], + loc: { + start: { column: 3, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + + range: [1, 19], + loc: { + start: { column: 1, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeAnnotation: TSTypeLiteral { + type: "TSTypeLiteral", + members: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [32, 36], + loc: { + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + typeAnnotation: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSStringKeyword { + type: "TSStringKeyword", + + range: [38, 44], + loc: { + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + + range: [36, 44], + loc: { + start: { column: 36, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + + range: [32, 44], + loc: { + start: { column: 32, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + ], + + range: [30, 46], + loc: { + start: { column: 30, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + + range: [1, 46], + loc: { + start: { column: 1, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + + range: [0, 48], + loc: { + start: { column: 0, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..bdca107f453 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,146 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-outer-parentheses Babel - Tokens 1`] = ` +Array [ + Punctuator { + type: "Punctuator", + value: "(", + + range: [0, 1], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [1, 2], + loc: { + start: { column: 1, line: 1 }, + end: { column: 2, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [3, 7], + loc: { + start: { column: 3, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + String { + type: "String", + value: "'string'", + + range: [9, 17], + loc: { + start: { column: 9, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "satisfies", + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [32, 36], + loc: { + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [36, 37], + loc: { + start: { column: 36, line: 1 }, + end: { column: 37, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "string", + + range: [38, 44], + loc: { + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [45, 46], + loc: { + start: { column: 45, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [46, 47], + loc: { + start: { column: 46, line: 1 }, + end: { column: 47, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..982ccda73a2 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-outer-parentheses AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..c113b8be7e9 --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-outer-parentheses/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures expression TSSatisfiesExpression object-object-outer-parentheses AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/spec.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/spec.ts new file mode 100644 index 00000000000..1297ade3eba --- /dev/null +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/spec.ts @@ -0,0 +1,10 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; +import type { Expression } from '../../unions/Expression'; +import type { TypeNode } from '../../unions/TypeNode'; + +export interface TSSatisfiesExpression extends BaseNode { + type: AST_NODE_TYPES.TSSatisfiesExpression; + expression: Expression; + typeAnnotation: TypeNode; +} diff --git a/packages/ast-spec/src/expression/spec.ts b/packages/ast-spec/src/expression/spec.ts index 9ed4a0cc756..f753672d472 100644 --- a/packages/ast-spec/src/expression/spec.ts +++ b/packages/ast-spec/src/expression/spec.ts @@ -23,6 +23,7 @@ export * from './TSAsExpression/spec'; export * from './TSEmptyBodyFunctionExpression/spec'; export * from './TSInstantiationExpression/spec'; export * from './TSNonNullExpression/spec'; +export * from './TSSatisfiesExpression/spec'; export * from './TSTypeAssertion/spec'; export * from './TaggedTemplateExpression/spec'; export * from './TemplateLiteral/spec'; diff --git a/packages/ast-spec/src/unions/Expression.ts b/packages/ast-spec/src/unions/Expression.ts index 36220bc0391..1c0ee899ec3 100644 --- a/packages/ast-spec/src/unions/Expression.ts +++ b/packages/ast-spec/src/unions/Expression.ts @@ -25,6 +25,7 @@ import type { ThisExpression } from '../expression/ThisExpression/spec'; import type { TSAsExpression } from '../expression/TSAsExpression/spec'; import type { TSInstantiationExpression } from '../expression/TSInstantiationExpression/spec'; import type { TSNonNullExpression } from '../expression/TSNonNullExpression/spec'; +import type { TSSatisfiesExpression } from '../expression/TSSatisfiesExpression/spec'; import type { TSTypeAssertion } from '../expression/TSTypeAssertion/spec'; import type { UnaryExpression } from '../expression/UnaryExpression/spec'; import type { UpdateExpression } from '../expression/UpdateExpression/spec'; @@ -72,6 +73,7 @@ export type Expression = | TSAsExpression | TSInstantiationExpression | TSNonNullExpression + | TSSatisfiesExpression | TSTypeAssertion | UnaryExpression | UpdateExpression diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts index 6505270427b..3656a3d677a 100644 --- a/packages/ast-spec/src/unions/Node.ts +++ b/packages/ast-spec/src/unions/Node.ts @@ -53,6 +53,7 @@ import type { TSAsExpression } from '../expression/TSAsExpression/spec'; import type { TSEmptyBodyFunctionExpression } from '../expression/TSEmptyBodyFunctionExpression/spec'; import type { TSInstantiationExpression } from '../expression/TSInstantiationExpression/spec'; import type { TSNonNullExpression } from '../expression/TSNonNullExpression/spec'; +import type { TSSatisfiesExpression } from '../expression/TSSatisfiesExpression/spec'; import type { TSTypeAssertion } from '../expression/TSTypeAssertion/spec'; import type { UnaryExpression } from '../expression/UnaryExpression/spec'; import type { UpdateExpression } from '../expression/UpdateExpression/spec'; @@ -305,6 +306,7 @@ export type Node = | TSQualifiedName | TSReadonlyKeyword | TSRestType + | TSSatisfiesExpression | TSStaticKeyword | TSStringKeyword | TSSymbolKeyword diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index 9d3e5d88ccc..beff8134d6e 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -24,5 +24,6 @@ Set { "declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts", "declaration/TSTypeAliasDeclaration/fixtures/type-param-many/fixture.ts", "declaration/TSTypeAliasDeclaration/fixtures/type-param-one/fixture.ts", + "expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts", } `; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 30c33050d42..ca53cc45a44 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2954,6 +2954,14 @@ export class Converter { }); } + case SyntaxKind.SatisfiesExpression: { + return this.createNode(node, { + type: AST_NODE_TYPES.TSSatisfiesExpression, + expression: this.convertChild(node.expression), + typeAnnotation: this.convertChild(node.type), + }); + } + default: return this.deeplyCopy(node); } diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 3b80ab0a958..12ff9392cb0 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -185,6 +185,7 @@ export interface EstreeToTsNodeTypes { [AST_NODE_TYPES.TSInterfaceHeritage]: ts.ExpressionWithTypeArguments; [AST_NODE_TYPES.TSIntersectionType]: ts.IntersectionTypeNode; [AST_NODE_TYPES.TSInstantiationExpression]: ts.ExpressionWithTypeArguments; + [AST_NODE_TYPES.TSSatisfiesExpression]: ts.SatisfiesExpression; [AST_NODE_TYPES.TSLiteralType]: ts.LiteralTypeNode; [AST_NODE_TYPES.TSMappedType]: ts.MappedTypeNode; [AST_NODE_TYPES.TSMethodSignature]: diff --git a/packages/typescript-estree/src/ts-estree/ts-nodes.ts b/packages/typescript-estree/src/ts-estree/ts-nodes.ts index 28c30ea8bc3..873f98e5a15 100644 --- a/packages/typescript-estree/src/ts-estree/ts-nodes.ts +++ b/packages/typescript-estree/src/ts-estree/ts-nodes.ts @@ -180,6 +180,7 @@ export type TSNode = | ts.UnparsedSource | ts.JsonMinusNumericLiteral | ts.TemplateLiteralTypeNode + | ts.SatisfiesExpression // JSDoc: Unsupported | ts.JSDoc diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index 6abab590b77..9c4d8a44bcc 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -477,6 +477,11 @@ tester.addFixturePatternConfig('typescript/expressions', { * @see https://github.com/babel/babel/issues/14613 */ 'instantiation-expression', + /** + * TS 4.9 `satisfies` operator has not been implemented in Babel yet. + * @see https://github.com/babel/babel/pull/14211 + */ + 'satisfies-expression', ], }); diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index a1898e92246..cb3e614df53 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -127,6 +127,7 @@ const additionalKeys: AdditionalKeys = { TSQualifiedName: ['left', 'right'], TSReadonlyKeyword: [], TSRestType: ['typeAnnotation'], + TSSatisfiesExpression: ['typeAnnotation', 'expression'], TSStaticKeyword: [], TSStringKeyword: [], TSSymbolKeyword: [], diff --git a/yarn.lock b/yarn.lock index 07d19a8fc38..fd624953978 100644 --- a/yarn.lock +++ b/yarn.lock @@ -153,7 +153,7 @@ dependencies: axe-core "^4.4.3" -"@babel/code-frame@*", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.8.3": +"@babel/code-frame@*", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.8.3": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== @@ -165,6 +165,11 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.19.3.tgz#707b939793f867f5a73b2666e6d9a3396eb03151" integrity sha512-prBHMK4JYYK+wDjJF1q99KK4JLL+egWS4nmNqdlMUgCExMZ+iZW0hGhyC3VEbsPjvaN0TBhW//VIFwBrk8sEiw== +"@babel/compat-data@^7.20.0": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.1.tgz#f2e6ef7790d8c8dbf03d379502dcc246dcce0b30" + integrity sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ== + "@babel/core@*", "@babel/core@^7.11.1", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.15.5", "@babel/core@^7.18.6": version "7.19.3" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.19.3.tgz#2519f62a51458f43b682d61583c3810e7dcee64c" @@ -208,7 +213,28 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/eslint-parser@*", "@babel/eslint-parser@^7.18.2": +"@babel/core@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.2.tgz#8dc9b1620a673f92d3624bd926dc49a52cf25b92" + integrity sha512-w7DbG8DtMrJcFOi4VrLm+8QM4az8Mo+PuLBKLp2zrYRCow8W/f9xiXm5sN53C8HksCyDQwCKha9JiDoIyPjT2g== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.20.2" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-module-transforms" "^7.20.2" + "@babel/helpers" "^7.20.1" + "@babel/parser" "^7.20.2" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.1" + semver "^6.3.0" + +"@babel/eslint-parser@*", "@babel/eslint-parser@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.19.1.tgz#4f68f6b0825489e00a24b41b6a1ae35414ecd2f4" integrity sha512-AqNf2QWt1rtu2/1rLswy6CDP7H9Oh3mMhk177Y67Rg8d7RD9WfOLLv8CGn6tisFvS2htm86yIe1yLF6I1UDaGQ== @@ -226,6 +252,15 @@ "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" +"@babel/generator@^7.20.1", "@babel/generator@^7.20.2": + version "7.20.4" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.4.tgz#4d9f8f0c30be75fd90a0562099a26e5839602ab8" + integrity sha512-luCf7yk/cm7yab6CAW1aiFnmEfBJplb/JojV56MYEK7ziWfGmFlTfmL9Ehwfy4gFhbjBfWO1wj7/TuSbVNEEtA== + dependencies: + "@babel/types" "^7.20.2" + "@jridgewell/gen-mapping" "^0.3.2" + jsesc "^2.5.1" + "@babel/helper-annotate-as-pure@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb" @@ -251,6 +286,16 @@ browserslist "^4.21.3" semver "^6.3.0" +"@babel/helper-compilation-targets@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" + integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== + dependencies: + "@babel/compat-data" "^7.20.0" + "@babel/helper-validator-option" "^7.18.6" + browserslist "^4.21.3" + semver "^6.3.0" + "@babel/helper-create-class-features-plugin@^7.18.6": version "7.18.9" resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz#d802ee16a64a9e824fcbf0a2ffc92f19d58550ce" @@ -339,6 +384,20 @@ "@babel/traverse" "^7.19.0" "@babel/types" "^7.19.0" +"@babel/helper-module-transforms@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" + integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" + "@babel/helper-optimise-call-expression@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe" @@ -384,6 +443,13 @@ dependencies: "@babel/types" "^7.18.6" +"@babel/helper-simple-access@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" + integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== + dependencies: + "@babel/types" "^7.20.2" + "@babel/helper-skip-transparent-expression-wrappers@^7.18.9": version "7.18.9" resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.18.9.tgz#778d87b3a758d90b471e7b9918f34a9a02eb5818" @@ -403,6 +469,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz#181f22d28ebe1b3857fa575f5c290b1aaf659b56" integrity sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw== +"@babel/helper-string-parser@^7.19.4": + version "7.19.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" + integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== + "@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" @@ -432,6 +503,15 @@ "@babel/traverse" "^7.19.0" "@babel/types" "^7.19.0" +"@babel/helpers@^7.20.1": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.1.tgz#2ab7a0fcb0a03b5bf76629196ed63c2d7311f4c9" + integrity sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg== + dependencies: + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.0" + "@babel/highlight@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" @@ -441,11 +521,16 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@*", "@babel/parser@^7.1.0", "@babel/parser@^7.12.7", "@babel/parser@^7.14.7", "@babel/parser@^7.18.0", "@babel/parser@^7.18.10", "@babel/parser@^7.18.8", "@babel/parser@^7.19.3": +"@babel/parser@*", "@babel/parser@^7.1.0", "@babel/parser@^7.12.7", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.18.8", "@babel/parser@^7.19.3": version "7.19.3" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.19.3.tgz#8dd36d17c53ff347f9e55c328710321b49479a9a" integrity sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ== +"@babel/parser@^7.20.1", "@babel/parser@^7.20.2", "@babel/parser@^7.20.3": + version "7.20.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.3.tgz#5358cf62e380cf69efcb87a7bb922ff88bfac6e2" + integrity sha512-OP/s5a94frIPXwjzEcv5S/tpQfc6XhxYUnmWpgdqMWGgYCuErA3SzozaRAMQgSZWKeTJxht9aWAkUY+0UzvOFg== + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz#da5b8f9a580acdfbe53494dba45ea389fb09a4d2" @@ -1207,7 +1292,23 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.12.7", "@babel/types@^7.15.6", "@babel/types@^7.18.10", "@babel/types@^7.18.2", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.19.3", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": +"@babel/traverse@^7.20.1": + version "7.20.1" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.1.tgz#9b15ccbf882f6d107eeeecf263fbcdd208777ec8" + integrity sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.20.1" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.19.0" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.20.1" + "@babel/types" "^7.20.0" + debug "^4.1.0" + globals "^11.1.0" + +"@babel/types@^7.0.0", "@babel/types@^7.12.7", "@babel/types@^7.15.6", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.19.3", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.19.3" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.19.3.tgz#fc420e6bbe54880bce6779ffaf315f5e43ec9624" integrity sha512-hGCaQzIY22DJlDh9CH7NOxgKkFjBk0Cw9xDO1Xmh2151ti7wiGfQ3LauXzL4HP1fmFlTX6XjpRETTpUcv7wQLw== @@ -1216,6 +1317,15 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" +"@babel/types@^7.20.0", "@babel/types@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.2.tgz#67ac09266606190f496322dbaff360fdaa5e7842" + integrity sha512-FnnvsNWgZCr232sqtXggapvlkk/tuwR/qhGzcmxI0GXLCjmPYQPzio2FbdlWuY6y1sHFfQKk+rRbUZ9VStQMog== + dependencies: + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" + to-fast-properties "^2.0.0" + "@bcherny/json-schema-ref-parser@9.0.9": version "9.0.9" resolved "https://registry.yarnpkg.com/@bcherny/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz#09899d405bc708c0acac0066ae8db5b94d465ca4" From bf6c54299d233990ed33b7cefb54811f396aee49 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 18 Nov 2022 16:11:05 +1030 Subject: [PATCH 50/76] chore: add back dropped comment from bad merge --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e13d754021e..0f7046a8aed 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "resolutions": { "typescript": "~4.9.3", "@types/node": "^18.11.9", - "//": "Stub out unnecessary swc packages to improve install size and speed", + "//": "Pin jest to v29 across the repo", "@jest/create-cache-key-function": "^29", "@jest/reporters": "^29", "@jest/test-result": "^29", @@ -122,6 +122,7 @@ "jest-snapshot": "^29", "jest-util": "^29", "pretty-format": "^29", + "//": "Stub out unnecessary swc packages to improve install size and speed", "@swc/core-android-arm-eabi": "npm:dummypkg-a@1.0.0", "@swc/core-android-arm64": "npm:dummypkg-a@1.0.0", "@swc/core-freebsd-x64": "npm:dummypkg-a@1.0.0", From 4d34f5d087b150b5a69346fccaf503af6b3bdaea Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 18 Nov 2022 00:58:04 -0500 Subject: [PATCH 51/76] docs(website): pruning flow for issues and PRs (#6002) --- .github/replies.yml | 9 ++++++ docs/maintenance/ISSUES.md | 14 ++++++++-- docs/maintenance/PULL_REQUESTS.md | 34 +++++++++++++++++++++++ packages/website/sidebars/sidebar.base.js | 1 + 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 docs/maintenance/PULL_REQUESTS.md diff --git a/.github/replies.yml b/.github/replies.yml index 64f02ca54ed..3edf22c3ca1 100644 --- a/.github/replies.yml +++ b/.github/replies.yml @@ -1,4 +1,7 @@ replies: + - body: | + 👋 Hey @{{ author }}! Just checking in, is this still something you have time for? No worries if not - I just don't want to leave it hanging. + name: Checking In - body: | Thanks for posting! This is a duplicate of #. Before filing an issue, please [use our issue search](https://github.com/typescript-eslint/typescript-eslint/issues) to check for open and closed issues that already address what you're looking for. name: Clearly Duplicate Issue @@ -52,6 +55,12 @@ replies: If this issue is important to you — consider being that champion. If not — please use the subscribe function and wait patiently for someone else to implement this. name: Progress - Nice + - body: | + Closing this issue as it's been stale for ~6 weeks without activity. Feel free to reopen @{{ author }} if you have time - but no worries if not! If anybody wants to drive it forward, please do either post here or in a new issue with the info we asked about. Thanks! 😊 + name: Pruning Stale Issue + - body: | + Closing this PR as it's been stale for ~6 weeks without activity. Feel free to reopen @{{ author }} if you have time - but no worries if not! If anybody wants to drive it forward, please do post your own PR - and if you use this as a start, consider adding `Co-authored-by: @{{ author }}` at the end of your PR description. Thanks! 😊 + name: Pruning Stale PR - body: | As per [our contributing guidelines](https://github.com/typescript-eslint/typescript-eslint/blob/master/CONTRIBUTING.md#addressing-feedback-and-beyond) this PR is in the queue of PRs to reviewed, and will be reviewed when we are able. \ diff --git a/docs/maintenance/ISSUES.md b/docs/maintenance/ISSUES.md index 55d1cee6e62..3b73d5af1a2 100644 --- a/docs/maintenance/ISSUES.md +++ b/docs/maintenance/ISSUES.md @@ -1,7 +1,7 @@ --- id: issues -sidebar_label: Issue Management -title: Issue Management +sidebar_label: Issues +title: Issues --- This document serves as a guide for how you might manage issues, also known as issue triaging. @@ -101,3 +101,13 @@ TODO: This will be filled out... soon! ### 🚀 New Rules TODO: This will be filled out... soon! + +## Pruning Old Issues + +Every so often, we like to [search for open issues `awaiting response`](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aopen+is%3Aissue+label%3A%22awaiting+response%22) to find ones that might have been forgotten. +Our flow for issues that have been waiting for >=1 month is: + +1. Ping the author with a message like the _Checking In_ template +2. Add the `stale` label to the issue +3. Wait 2 weeks +4. If they still haven't responded, close the issue with a message like the _Pruning Stale Issue_ template diff --git a/docs/maintenance/PULL_REQUESTS.md b/docs/maintenance/PULL_REQUESTS.md new file mode 100644 index 00000000000..37c6b40256c --- /dev/null +++ b/docs/maintenance/PULL_REQUESTS.md @@ -0,0 +1,34 @@ +--- +id: pull-requests +title: Pull Requests +--- + +This document serves as a guide for how you might review pull requests. + +Use your best judgement when reviewing PRs, 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. +It's imperative we give them a positive, uplifting experience. + +:::tip +If you're ever unsure on any part of PR reviews, don't hesitate to loop in a maintainer that has more context to help! +::: + +## PR Flow + +:::note +We include a set of common responses to PRs in [`.github/replies.yml`](https://github.com/typescript-eslint/typescript-eslint/blob/main/.github/replies.yml), intended to be used with the [Refined Saved Replies](https://github.com/JoshuaKGoldberg/refined-saved-replies) extension. +Don't treat these as exact responses you must use: they're just a starting copy+paste helper. +Please do adopt your specific responses to your personal tone and to match the thread for non-straightforward PRs. +::: + +TODO: This will be filled out... soon! + +## Pruning Old PRs + +Every so often, we like to [search for open PRs `awaiting response`](https://github.com/typescript-eslint/typescript-eslint/pulls?q=is%3Aopen+is%3Apr+label%3A%22awaiting+response%22) to find ones that might have been forgotten. +Our flow for PRs that have been waiting for >=1 month is: + +1. Ping the author with a message like the _Checking In_ template +2. Add the `stale` label to the PR +3. Wait 2 weeks +4. If they still haven't responded, close the PR with a message like the _Pruning Stale PR_ template diff --git a/packages/website/sidebars/sidebar.base.js b/packages/website/sidebars/sidebar.base.js index fbdc1f28e6b..81b219c541c 100644 --- a/packages/website/sidebars/sidebar.base.js +++ b/packages/website/sidebars/sidebar.base.js @@ -56,6 +56,7 @@ module.exports = { collapsible: false, items: [ 'maintenance/issues', + 'maintenance/pull-requests', 'maintenance/releases', 'maintenance/versioning', ], From 7a1070759cd3cb967fa0b668863e51ae2bfcd3d0 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 18 Nov 2022 00:59:28 -0500 Subject: [PATCH 52/76] chore: add discussion template for RFCs (#6023) --- .github/DISCUSSION_TEMPLATE/rfcs.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/DISCUSSION_TEMPLATE/rfcs.yml diff --git a/.github/DISCUSSION_TEMPLATE/rfcs.yml b/.github/DISCUSSION_TEMPLATE/rfcs.yml new file mode 100644 index 00000000000..0e0b99abf05 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/rfcs.yml @@ -0,0 +1,24 @@ +body: + - attributes: + label: RFC + value: | + Suggested changes... + id: rfc + type: textarea + - attributes: + label: Additional Info + value: | + Any additional info... + id: additional + type: textarea + - attributes: + label: Before you submit your RFC, please confirm the following. If any of these required steps are not taken, we may not be able to review your RFC. Help us to help you! + options: + - label: I have [searched for related discussions](https://github.com/typescript-eslint/typescript-eslint/discussions) and [searched for related issues](https://github.com/typescript-eslint/typescript-eslint/issues) and found none that match my proposal. + required: true + - label: I have [read the FAQ](https://typescript-eslint.io/docs/linting/troubleshooting) and my problem is not listed. + required: true + id: required-checks + type: checkboxes +labels: ['rfc'] +title: Your Title Here From a4f85b8cfe38ba8ea2a2ac4a56d9b11a81a8a15a Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Sat, 19 Nov 2022 02:02:06 +0900 Subject: [PATCH 53/76] fix(eslint-plugin): [no-empty-interface] disable autofix for declaration merging with class (#5920) * fix(eslint-plugin): [no-empty-interface] disable autofix for declaration merging with class * fix comment * fix lint * Apply review --- .../src/rules/no-empty-interface.ts | 31 ++++--- .../tests/rules/no-empty-interface.test.ts | 88 +++++++++++++++++++ 2 files changed, 109 insertions(+), 10 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-empty-interface.ts b/packages/eslint-plugin/src/rules/no-empty-interface.ts index 4e037e9cc8a..d74034114bb 100644 --- a/packages/eslint-plugin/src/rules/no-empty-interface.ts +++ b/packages/eslint-plugin/src/rules/no-empty-interface.ts @@ -1,4 +1,5 @@ import type { TSESLint } from '@typescript-eslint/utils'; +import { AST_NODE_TYPES } from '@typescript-eslint/utils'; import * as util from '../util'; @@ -73,29 +74,39 @@ export default util.createRule({ )}${typeParam} = ${sourceCode.getText(extend[0])}`, ); }; + const scope = context.getScope(); - // Check if interface is within ambient declaration - let useAutoFix = true; - if (util.isDefinitionFile(filename)) { - const scope = context.getScope(); - if (scope.type === 'tsModule' && scope.block.declare) { - useAutoFix = false; - } - } + const mergedWithClassDeclaration = scope.set + .get(node.id.name) + ?.defs?.some( + def => def.node.type === AST_NODE_TYPES.ClassDeclaration, + ); + + const isInAmbientDeclaration = !!( + util.isDefinitionFile(filename) && + scope.type === 'tsModule' && + scope.block.declare + ); + + const useAutoFix = !( + isInAmbientDeclaration || mergedWithClassDeclaration + ); context.report({ node: node.id, messageId: 'noEmptyWithSuper', ...(useAutoFix ? { fix } - : { + : !mergedWithClassDeclaration + ? { suggest: [ { messageId: 'noEmptyWithSuper', fix, }, ], - }), + } + : null), }); } } diff --git a/packages/eslint-plugin/tests/rules/no-empty-interface.test.ts b/packages/eslint-plugin/tests/rules/no-empty-interface.test.ts index 0d7f73342b5..893deaf01d6 100644 --- a/packages/eslint-plugin/tests/rules/no-empty-interface.test.ts +++ b/packages/eslint-plugin/tests/rules/no-empty-interface.test.ts @@ -34,6 +34,18 @@ interface Bar extends Foo {} `, options: [{ allowSingleExtends: true }], }, + { + code: ` +interface Foo { + props: string; +} + +interface Bar extends Foo {} + +class Bar {} + `, + options: [{ allowSingleExtends: true }], + }, ], invalid: [ { @@ -58,6 +70,82 @@ interface Bar extends Foo {} }, { code: ` +interface Foo { + props: string; +} + +interface Bar extends Foo {} + +class Baz {} + `, + output: ` +interface Foo { + props: string; +} + +type Bar = Foo + +class Baz {} + `, + options: [{ allowSingleExtends: false }], + errors: [ + { + messageId: 'noEmptyWithSuper', + line: 6, + column: 11, + }, + ], + }, + { + code: ` +interface Foo { + props: string; +} + +interface Bar extends Foo {} + +class Bar {} + `, + options: [{ allowSingleExtends: false }], + errors: [ + { + messageId: 'noEmptyWithSuper', + line: 6, + column: 11, + }, + ], + output: null, + }, + { + code: ` +interface Foo { + props: string; +} + +interface Bar extends Foo {} + +const bar = class Bar {}; + `, + output: ` +interface Foo { + props: string; +} + +type Bar = Foo + +const bar = class Bar {}; + `, + options: [{ allowSingleExtends: false }], + errors: [ + { + messageId: 'noEmptyWithSuper', + line: 6, + column: 11, + }, + ], + }, + { + code: ` interface Foo { name: string; } From fa862dc6eb27d969fd6c772addb03e574405719d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 20 Nov 2022 08:52:54 +0000 Subject: [PATCH 54/76] chore(deps): update dependency jest-specific-snapshot to v6 (#6042) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Brad Zacher --- package.json | 2 +- .../tests/ast-alignment/parse.ts | 1 - yarn.lock | 162 +++--------------- 3 files changed, 27 insertions(+), 138 deletions(-) diff --git a/package.json b/package.json index 0f7046a8aed..aa76fc54295 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "jest": "^29.0.3", "jest-diff": "^29.0.3", "jest-snapshot": "^29.0.3", - "jest-specific-snapshot": "^5.0.0", + "jest-specific-snapshot": "^6.0.0", "lerna": "6.0.3", "lint-staged": "^13.0.0", "make-dir": "^3.1.0", diff --git a/packages/typescript-estree/tests/ast-alignment/parse.ts b/packages/typescript-estree/tests/ast-alignment/parse.ts index ee3b3066cce..b4d5ea1c8f9 100644 --- a/packages/typescript-estree/tests/ast-alignment/parse.ts +++ b/packages/typescript-estree/tests/ast-alignment/parse.ts @@ -29,7 +29,6 @@ function parseWithBabelParser(text: string, jsx = true): File { [ 'estree', { - // @ts-expect-error -- this isn't exposed in the types yet classFeatures: true, }, ], diff --git a/yarn.lock b/yarn.lock index fd624953978..f771e6ece9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -160,31 +160,26 @@ dependencies: "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.18.8", "@babel/compat-data@^7.19.3": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.19.3.tgz#707b939793f867f5a73b2666e6d9a3396eb03151" - integrity sha512-prBHMK4JYYK+wDjJF1q99KK4JLL+egWS4nmNqdlMUgCExMZ+iZW0hGhyC3VEbsPjvaN0TBhW//VIFwBrk8sEiw== - -"@babel/compat-data@^7.20.0": +"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.18.8", "@babel/compat-data@^7.19.3", "@babel/compat-data@^7.20.0": version "7.20.1" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.1.tgz#f2e6ef7790d8c8dbf03d379502dcc246dcce0b30" integrity sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ== -"@babel/core@*", "@babel/core@^7.11.1", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.15.5", "@babel/core@^7.18.6": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.19.3.tgz#2519f62a51458f43b682d61583c3810e7dcee64c" - integrity sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ== +"@babel/core@*", "@babel/core@^7.11.1", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.15.5", "@babel/core@^7.18.6", "@babel/core@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.2.tgz#8dc9b1620a673f92d3624bd926dc49a52cf25b92" + integrity sha512-w7DbG8DtMrJcFOi4VrLm+8QM4az8Mo+PuLBKLp2zrYRCow8W/f9xiXm5sN53C8HksCyDQwCKha9JiDoIyPjT2g== dependencies: "@ampproject/remapping" "^2.1.0" "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.19.3" - "@babel/helper-compilation-targets" "^7.19.3" - "@babel/helper-module-transforms" "^7.19.0" - "@babel/helpers" "^7.19.0" - "@babel/parser" "^7.19.3" + "@babel/generator" "^7.20.2" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-module-transforms" "^7.20.2" + "@babel/helpers" "^7.20.1" + "@babel/parser" "^7.20.2" "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.3" - "@babel/types" "^7.19.3" + "@babel/traverse" "^7.20.1" + "@babel/types" "^7.20.2" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" @@ -213,27 +208,6 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/core@^7.20.2": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.2.tgz#8dc9b1620a673f92d3624bd926dc49a52cf25b92" - integrity sha512-w7DbG8DtMrJcFOi4VrLm+8QM4az8Mo+PuLBKLp2zrYRCow8W/f9xiXm5sN53C8HksCyDQwCKha9JiDoIyPjT2g== - dependencies: - "@ampproject/remapping" "^2.1.0" - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.20.2" - "@babel/helper-compilation-targets" "^7.20.0" - "@babel/helper-module-transforms" "^7.20.2" - "@babel/helpers" "^7.20.1" - "@babel/parser" "^7.20.2" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.1" - "@babel/types" "^7.20.2" - convert-source-map "^1.7.0" - debug "^4.1.0" - gensync "^1.0.0-beta.2" - json5 "^2.2.1" - semver "^6.3.0" - "@babel/eslint-parser@*", "@babel/eslint-parser@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.19.1.tgz#4f68f6b0825489e00a24b41b6a1ae35414ecd2f4" @@ -243,16 +217,7 @@ eslint-visitor-keys "^2.1.0" semver "^6.3.0" -"@babel/generator@^7.12.5", "@babel/generator@^7.18.7", "@babel/generator@^7.19.3", "@babel/generator@^7.7.2": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.19.3.tgz#d7f4d1300485b4547cb6f94b27d10d237b42bf59" - integrity sha512-fqVZnmp1ncvZU757UzDheKZpfPgatqY59XtW2/j/18H7u76akb8xqvjw82f+i2UKd/ksYsSick/BCLQUUtJ/qQ== - dependencies: - "@babel/types" "^7.19.3" - "@jridgewell/gen-mapping" "^0.3.2" - jsesc "^2.5.1" - -"@babel/generator@^7.20.1", "@babel/generator@^7.20.2": +"@babel/generator@^7.12.5", "@babel/generator@^7.18.7", "@babel/generator@^7.20.1", "@babel/generator@^7.20.2", "@babel/generator@^7.7.2": version "7.20.4" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.20.4.tgz#4d9f8f0c30be75fd90a0562099a26e5839602ab8" integrity sha512-luCf7yk/cm7yab6CAW1aiFnmEfBJplb/JojV56MYEK7ziWfGmFlTfmL9Ehwfy4gFhbjBfWO1wj7/TuSbVNEEtA== @@ -276,17 +241,7 @@ "@babel/helper-explode-assignable-expression" "^7.18.6" "@babel/types" "^7.18.9" -"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.19.0", "@babel/helper-compilation-targets@^7.19.3": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.19.3.tgz#a10a04588125675d7c7ae299af86fa1b2ee038ca" - integrity sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg== - dependencies: - "@babel/compat-data" "^7.19.3" - "@babel/helper-validator-option" "^7.18.6" - browserslist "^4.21.3" - semver "^6.3.0" - -"@babel/helper-compilation-targets@^7.20.0": +"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.19.0", "@babel/helper-compilation-targets@^7.19.3", "@babel/helper-compilation-targets@^7.20.0": version "7.20.0" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz#6bf5374d424e1b3922822f1d9bdaa43b1a139d0a" integrity sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ== @@ -370,21 +325,7 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.18.6", "@babel/helper-module-transforms@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.19.0.tgz#309b230f04e22c58c6a2c0c0c7e50b216d350c30" - integrity sha512-3HBZ377Fe14RbLIA+ac3sY4PTgpxHVkFrESaWhoI5PuyXPBBX8+C34qblV9G89ZtycGJCmCI/Ut+VUDK4bltNQ== - dependencies: - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-simple-access" "^7.18.6" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/helper-validator-identifier" "^7.18.6" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.0" - "@babel/types" "^7.19.0" - -"@babel/helper-module-transforms@^7.20.2": +"@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.18.6", "@babel/helper-module-transforms@^7.19.0", "@babel/helper-module-transforms@^7.20.2": version "7.20.2" resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.2.tgz#ac53da669501edd37e658602a21ba14c08748712" integrity sha512-zvBKyJXRbmK07XhMuujYoJ48B5yvvmM6+wcpv6Ivj4Yg6qO7NOZOSnvZN9CRl1zz1Z4cKf8YejmCMh8clOoOeA== @@ -436,14 +377,7 @@ "@babel/traverse" "^7.18.9" "@babel/types" "^7.18.9" -"@babel/helper-simple-access@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz#d6d8f51f4ac2978068df934b569f08f29788c7ea" - integrity sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g== - dependencies: - "@babel/types" "^7.18.6" - -"@babel/helper-simple-access@^7.20.2": +"@babel/helper-simple-access@^7.18.6", "@babel/helper-simple-access@^7.20.2": version "7.20.2" resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== @@ -464,11 +398,6 @@ dependencies: "@babel/types" "^7.18.6" -"@babel/helper-string-parser@^7.18.10": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz#181f22d28ebe1b3857fa575f5c290b1aaf659b56" - integrity sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw== - "@babel/helper-string-parser@^7.19.4": version "7.19.4" resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" @@ -494,16 +423,7 @@ "@babel/traverse" "^7.18.9" "@babel/types" "^7.18.9" -"@babel/helpers@^7.12.5", "@babel/helpers@^7.19.0": - version "7.19.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.19.0.tgz#f30534657faf246ae96551d88dd31e9d1fa1fc18" - integrity sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg== - dependencies: - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.19.0" - "@babel/types" "^7.19.0" - -"@babel/helpers@^7.20.1": +"@babel/helpers@^7.12.5", "@babel/helpers@^7.20.1": version "7.20.1" resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.20.1.tgz#2ab7a0fcb0a03b5bf76629196ed63c2d7311f4c9" integrity sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg== @@ -521,12 +441,7 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@*", "@babel/parser@^7.1.0", "@babel/parser@^7.12.7", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.18.8", "@babel/parser@^7.19.3": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.19.3.tgz#8dd36d17c53ff347f9e55c328710321b49479a9a" - integrity sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ== - -"@babel/parser@^7.20.1", "@babel/parser@^7.20.2", "@babel/parser@^7.20.3": +"@babel/parser@*", "@babel/parser@^7.1.0", "@babel/parser@^7.12.7", "@babel/parser@^7.14.7", "@babel/parser@^7.18.10", "@babel/parser@^7.18.8", "@babel/parser@^7.20.1", "@babel/parser@^7.20.2", "@babel/parser@^7.20.3": version "7.20.3" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.3.tgz#5358cf62e380cf69efcb87a7bb922ff88bfac6e2" integrity sha512-OP/s5a94frIPXwjzEcv5S/tpQfc6XhxYUnmWpgdqMWGgYCuErA3SzozaRAMQgSZWKeTJxht9aWAkUY+0UzvOFg== @@ -1276,23 +1191,7 @@ "@babel/parser" "^7.18.10" "@babel/types" "^7.18.10" -"@babel/traverse@^7.12.9", "@babel/traverse@^7.18.8", "@babel/traverse@^7.18.9", "@babel/traverse@^7.19.0", "@babel/traverse@^7.19.3", "@babel/traverse@^7.7.2": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.19.3.tgz#3a3c5348d4988ba60884e8494b0592b2f15a04b4" - integrity sha512-qh5yf6149zhq2sgIXmwjnsvmnNQC2iw70UFjp4olxucKrWd/dvlUsBI88VSLUsnMNF7/vnOiA+nk1+yLoCqROQ== - dependencies: - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.19.3" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.19.0" - "@babel/helper-hoist-variables" "^7.18.6" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.19.3" - "@babel/types" "^7.19.3" - debug "^4.1.0" - globals "^11.1.0" - -"@babel/traverse@^7.20.1": +"@babel/traverse@^7.12.9", "@babel/traverse@^7.18.8", "@babel/traverse@^7.18.9", "@babel/traverse@^7.20.1", "@babel/traverse@^7.7.2": version "7.20.1" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.1.tgz#9b15ccbf882f6d107eeeecf263fbcdd208777ec8" integrity sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA== @@ -1308,16 +1207,7 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.12.7", "@babel/types@^7.15.6", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.19.3", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": - version "7.19.3" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.19.3.tgz#fc420e6bbe54880bce6779ffaf315f5e43ec9624" - integrity sha512-hGCaQzIY22DJlDh9CH7NOxgKkFjBk0Cw9xDO1Xmh2151ti7wiGfQ3LauXzL4HP1fmFlTX6XjpRETTpUcv7wQLw== - dependencies: - "@babel/helper-string-parser" "^7.18.10" - "@babel/helper-validator-identifier" "^7.19.1" - to-fast-properties "^2.0.0" - -"@babel/types@^7.20.0", "@babel/types@^7.20.2": +"@babel/types@^7.0.0", "@babel/types@^7.12.7", "@babel/types@^7.15.6", "@babel/types@^7.18.10", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.19.3", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.20.2" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.2.tgz#67ac09266606190f496322dbaff360fdaa5e7842" integrity sha512-FnnvsNWgZCr232sqtXggapvlkk/tuwR/qhGzcmxI0GXLCjmPYQPzio2FbdlWuY6y1sHFfQKk+rRbUZ9VStQMog== @@ -9288,7 +9178,7 @@ jest-runtime@^29.1.2: slash "^3.0.0" strip-bom "^4.0.0" -jest-snapshot@*, jest-snapshot@^27.0.2, jest-snapshot@^29, jest-snapshot@^29.0.3, jest-snapshot@^29.1.2: +jest-snapshot@*, jest-snapshot@^28.0.0, jest-snapshot@^29, jest-snapshot@^29.0.3, jest-snapshot@^29.1.2: version "29.1.2" resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-29.1.2.tgz#7dd277e88c45f2d2ff5888de1612e63c7ceb575b" integrity sha512-rYFomGpVMdBlfwTYxkUp3sjD6usptvZcONFYNqVlaz4EpHPnDvlWjvmOQ9OCSNKqYZqLM2aS3wq01tWujLg7gg== @@ -9318,12 +9208,12 @@ jest-snapshot@*, jest-snapshot@^27.0.2, jest-snapshot@^29, jest-snapshot@^29.0.3 pretty-format "^29.1.2" semver "^7.3.5" -jest-specific-snapshot@*, jest-specific-snapshot@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/jest-specific-snapshot/-/jest-specific-snapshot-5.0.0.tgz#48f72d5613af7f3e30df75b6b3534db6bab32ea0" - integrity sha512-V65vuPxZQExD3tGbv+Du5tbG1E3H3Dq/HFbsCEkPJP27w5vr/nATQJl61Dx5doBfu54OrJak0JaeYVSeZubDKg== +jest-specific-snapshot@*, jest-specific-snapshot@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/jest-specific-snapshot/-/jest-specific-snapshot-6.0.0.tgz#8373589825234fbbeef1bf054f5a6720a15a54f3" + integrity sha512-IiAfq0bmuXNwRkfCO3mLTCMhZJBdU05y/zEUKRk0KDhW6WQ7ZL0xTgjjtMrfLb0h+o/i+1/N68Ls3NrIFTykiA== dependencies: - jest-snapshot "^27.0.2" + jest-snapshot "^28.0.0" jest-util@28.1.1, jest-util@^29, jest-util@^29.1.2: version "29.1.2" From e2d1263dee9775469b095c40ee0fd501d375f9e4 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 21 Nov 2022 08:43:23 -0500 Subject: [PATCH 55/76] chore: switched repo lint to use nx run-many (#6038) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: switched repo lint to use nx run-many * chore: replace eslint CLI usage with dedicated Nx executor * chore: remove unneeded nested .eslintignore files * chore: npm alias, try without cd to root Co-authored-by: “JamesHenry” --- nx.json | 2 +- package.json | 2 +- packages/ast-spec/package.json | 2 +- packages/ast-spec/project.json | 11 ++++++++++- packages/eslint-plugin-internal/package.json | 2 +- packages/eslint-plugin-internal/project.json | 11 ++++++++++- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin-tslint/project.json | 11 ++++++++++- packages/eslint-plugin/package.json | 2 +- packages/eslint-plugin/project.json | 11 ++++++++++- packages/experimental-utils/package.json | 2 +- packages/experimental-utils/project.json | 11 ++++++++++- packages/parser/package.json | 2 +- packages/parser/project.json | 11 ++++++++++- packages/scope-manager/package.json | 2 +- packages/scope-manager/project.json | 3 +-- packages/type-utils/package.json | 2 +- packages/type-utils/project.json | 11 ++++++++++- packages/types/package.json | 2 +- packages/types/project.json | 11 ++++++++++- packages/typescript-estree/package.json | 2 +- packages/typescript-estree/project.json | 11 ++++++++++- packages/utils/package.json | 2 +- packages/utils/project.json | 11 ++++++++++- packages/visitor-keys/package.json | 2 +- packages/visitor-keys/project.json | 11 ++++++++++- packages/website/package.json | 2 +- packages/website/project.json | 11 ++++++++++- 28 files changed, 136 insertions(+), 29 deletions(-) diff --git a/nx.json b/nx.json index d5b11cdfb5a..ed1f57517e1 100644 --- a/nx.json +++ b/nx.json @@ -18,7 +18,7 @@ "default": { "runner": "@nrwl/nx-cloud", "options": { - "cacheableOperations": ["build", "test", "package", "prebuild"], + "cacheableOperations": ["build", "lint", "package", "prebuild", "test"], "accessToken": "YjFjNTBhOWUtY2JmNy00ZDhiLWE5N2UtZjliNDAwNmIzOTdjfHJlYWQtd3JpdGU=", "canTrackAnalytics": false, "showUsageWarnings": true, diff --git a/package.json b/package.json index aa76fc54295..bddf6b4fe48 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "lint-fix": "eslint . --fix", "lint-markdown-fix": "yarn lint-markdown --fix", "lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore", - "lint": "cross-env NODE_OPTIONS=\"--max-old-space-size=16384\" eslint .", + "lint": "nx run-many --target=lint --all --parallel", "postinstall": "yarn patch-package && yarn husky install && yarn build", "pre-commit": "yarn lint-staged", "start": "nx run website:start", diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index 19a595262da..e2045437054 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -34,7 +34,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf .rollup.cache && rimraf coverage", "clean-fixtures": "rimraf -g \"./src/**/fixtures/**/snapshots\"", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/ast-spec", "test": "jest", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/ast-spec/project.json b/packages/ast-spec/project.json index 24256b3e4d0..b892bb3fae0 100644 --- a/packages/ast-spec/project.json +++ b/packages/ast-spec/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/ast-spec/**/*.ts"] + } + } + } } diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index b9047517e16..62373f12d54 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -8,7 +8,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/eslint-plugin-internal", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/eslint-plugin-internal/project.json b/packages/eslint-plugin-internal/project.json index 24256b3e4d0..803b12f5322 100644 --- a/packages/eslint-plugin-internal/project.json +++ b/packages/eslint-plugin-internal/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/eslint-plugin-internal/**/*.ts"] + } + } + } } diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index d69678024c8..e852bcd509e 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -33,7 +33,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/eslint-plugin-tslint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/eslint-plugin-tslint/project.json b/packages/eslint-plugin-tslint/project.json index 24256b3e4d0..6f6c19ca7c5 100644 --- a/packages/eslint-plugin-tslint/project.json +++ b/packages/eslint-plugin-tslint/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/eslint-plugin-tslint/**/*.ts"] + } + } + } } diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 0e2ab6e436a..28562d7650a 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -39,7 +39,7 @@ "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "generate:breaking-changes": "../../node_modules/.bin/ts-node tools/generate-breaking-changes.ts", "generate:configs": "../../node_modules/.bin/ts-node tools/generate-configs.ts", - "lint": "eslint . --ignore-path ../../.eslintignore", + "lint": "nx lint @typescript-eslint/eslint-plugin", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/eslint-plugin/project.json b/packages/eslint-plugin/project.json index 24256b3e4d0..d3a8c23a138 100644 --- a/packages/eslint-plugin/project.json +++ b/packages/eslint-plugin/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/eslint-plugin/**/*.ts"] + } + } + } } diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 901b63d2f30..9b89e1965ef 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/experimental-utils", "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { diff --git a/packages/experimental-utils/project.json b/packages/experimental-utils/project.json index 24256b3e4d0..415df390d35 100644 --- a/packages/experimental-utils/project.json +++ b/packages/experimental-utils/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/experimental-utils/**/*.ts"] + } + } + } } diff --git a/packages/parser/package.json b/packages/parser/package.json index 23ac485be0f..7bf78fe1f59 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -37,7 +37,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/parser", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/parser/project.json b/packages/parser/project.json index 24256b3e4d0..10eb8732ea1 100644 --- a/packages/parser/project.json +++ b/packages/parser/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/parser/**/*.ts"] + } + } + } } diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index bc611e14e68..996299712b6 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -33,7 +33,7 @@ "clean-fixtures": "cd ../../ && nx clean-fixtures @typescript-eslint/scope-manager", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "generate:lib": "cd ../../ && nx generate-lib @typescript-eslint/scope-manager", - "lint": "cd ../../ && nx lint @typescript-eslint/scope-manager", + "lint": "nx lint @typescript-eslint/scope-manager", "test": "cd ../../ && nx test @typescript-eslint/scope-manager --code-coverage", "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" }, diff --git a/packages/scope-manager/project.json b/packages/scope-manager/project.json index 1868938a6ac..efaf69f925c 100644 --- a/packages/scope-manager/project.json +++ b/packages/scope-manager/project.json @@ -55,8 +55,7 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/scope-manager/**/*.{ts,js}"], - "ignorePath": ".eslintignore" + "lintFilePatterns": ["packages/scope-manager/**/*.ts"] } }, "test": { diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index f72272dd349..9ecfc33fe5c 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/type-utils", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/type-utils/project.json b/packages/type-utils/project.json index 24256b3e4d0..efc70d52332 100644 --- a/packages/type-utils/project.json +++ b/packages/type-utils/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/type-utils/**/*.ts"] + } + } + } } diff --git a/packages/types/package.json b/packages/types/package.json index 8b591cd2e0f..72d9efb088c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -36,7 +36,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "generate:lib": "../../node_modules/.bin/ts-node --files --transpile-only ../scope-manager/tools/generate-lib.ts", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/types", "typecheck": "tsc -p tsconfig.json --noEmit" }, "nx": { diff --git a/packages/types/project.json b/packages/types/project.json index 3719aa0608b..968c1ed0e23 100644 --- a/packages/types/project.json +++ b/packages/types/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": ["@typescript-eslint/ast-spec"] + "implicitDependencies": ["@typescript-eslint/ast-spec"], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/types/**/*.ts"] + } + } + } } diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index f28d6d17f76..4df72039108 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -37,7 +37,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/typescript-estree", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/typescript-estree/project.json b/packages/typescript-estree/project.json index edfec5ab524..61848afaa64 100644 --- a/packages/typescript-estree/project.json +++ b/packages/typescript-estree/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": ["@typescript-eslint/types"] + "implicitDependencies": ["@typescript-eslint/types"], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/typescript-estree/**/*.ts"] + } + } + } } diff --git a/packages/utils/package.json b/packages/utils/package.json index ad353bce00e..c357e13fe3e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/utils", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/utils/project.json b/packages/utils/project.json index 24256b3e4d0..7ef570436b4 100644 --- a/packages/utils/project.json +++ b/packages/utils/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/utils/**/*.ts"] + } + } + } } diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 62a83136687..554d8b95736 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path='../../.eslintignore'", + "lint": "nx lint @typescript-eslint/visitor-keys", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/visitor-keys/project.json b/packages/visitor-keys/project.json index 24256b3e4d0..c7e3401148e 100644 --- a/packages/visitor-keys/project.json +++ b/packages/visitor-keys/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/visitor-keys/**/*.ts"] + } + } + } } diff --git a/packages/website/package.json b/packages/website/package.json index 5232068f58a..ca83be0a26f 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -6,7 +6,7 @@ "build": "docusaurus build", "clear": "docusaurus clear", "format": "prettier --write \"./**/*.{md,mdx,ts,js,tsx,jsx}\" --ignore-path ../../.prettierignore", - "lint": "eslint . --ignore-path ../../.eslintignore", + "lint": "nx lint website", "serve": "docusaurus serve", "start": "docusaurus start", "swizzle": "docusaurus swizzle", diff --git a/packages/website/project.json b/packages/website/project.json index 24256b3e4d0..a9f414356b1 100644 --- a/packages/website/project.json +++ b/packages/website/project.json @@ -1,5 +1,14 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", "type": "library", - "implicitDependencies": [] + "implicitDependencies": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/website/**/*.ts"] + } + } + } } From 426c2f9f7e5a8b7cb82927467aa34464dab25f20 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 21 Nov 2022 19:42:43 +0400 Subject: [PATCH 56/76] chore: remove unnecessary project names from nx commands (#6054) --- packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/package.json | 2 +- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/experimental-utils/package.json | 2 +- packages/parser/package.json | 2 +- packages/scope-manager/package.json | 14 +++++++------- packages/type-utils/package.json | 2 +- packages/types/package.json | 2 +- packages/typescript-estree/package.json | 2 +- packages/utils/package.json | 2 +- packages/visitor-keys/package.json | 2 +- packages/website/package.json | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index e2045437054..15b7f40de48 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -34,7 +34,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf .rollup.cache && rimraf coverage", "clean-fixtures": "rimraf -g \"./src/**/fixtures/**/snapshots\"", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/ast-spec", + "lint": "nx lint", "test": "jest", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 62373f12d54..4c317f8b0f2 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -8,7 +8,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/eslint-plugin-internal", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index e852bcd509e..78715448e44 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -33,7 +33,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/eslint-plugin-tslint", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 28562d7650a..95a7f2a2b87 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -39,7 +39,7 @@ "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "generate:breaking-changes": "../../node_modules/.bin/ts-node tools/generate-breaking-changes.ts", "generate:configs": "../../node_modules/.bin/ts-node tools/generate-configs.ts", - "lint": "nx lint @typescript-eslint/eslint-plugin", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 9b89e1965ef..fa4775116f4 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/experimental-utils", + "lint": "nx lint", "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { diff --git a/packages/parser/package.json b/packages/parser/package.json index 7bf78fe1f59..f83abd5ce3f 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -37,7 +37,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/parser", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 996299712b6..1849dab5710 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -28,14 +28,14 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "cd ../../ && nx build @typescript-eslint/scope-manager", - "clean": "cd ../../ && nx clean @typescript-eslint/scope-manager", - "clean-fixtures": "cd ../../ && nx clean-fixtures @typescript-eslint/scope-manager", + "build": "nx build", + "clean": "nx clean", + "clean-fixtures": "nx clean-fixtures", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "generate:lib": "cd ../../ && nx generate-lib @typescript-eslint/scope-manager", - "lint": "nx lint @typescript-eslint/scope-manager", - "test": "cd ../../ && nx test @typescript-eslint/scope-manager --code-coverage", - "typecheck": "cd ../../ && nx typecheck @typescript-eslint/scope-manager" + "generate:lib": "nx generate-lib", + "lint": "nx lint", + "test": "nx test --code-coverage", + "typecheck": "nx typecheck" }, "dependencies": { "@typescript-eslint/types": "5.43.0", diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index 9ecfc33fe5c..1bde3fa7291 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/type-utils", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/types/package.json b/packages/types/package.json index 72d9efb088c..95b3e310549 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -36,7 +36,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "generate:lib": "../../node_modules/.bin/ts-node --files --transpile-only ../scope-manager/tools/generate-lib.ts", - "lint": "nx lint @typescript-eslint/types", + "lint": "nx lint", "typecheck": "tsc -p tsconfig.json --noEmit" }, "nx": { diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 4df72039108..8b6a4b63236 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -37,7 +37,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/typescript-estree", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index c357e13fe3e..8057615f782 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/utils", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 554d8b95736..36a76506596 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -34,7 +34,7 @@ "clean": "tsc -b tsconfig.build.json --clean", "postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", - "lint": "nx lint @typescript-eslint/visitor-keys", + "lint": "nx lint", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" }, diff --git a/packages/website/package.json b/packages/website/package.json index ca83be0a26f..fa0c1c3c2af 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -6,7 +6,7 @@ "build": "docusaurus build", "clear": "docusaurus clear", "format": "prettier --write \"./**/*.{md,mdx,ts,js,tsx,jsx}\" --ignore-path ../../.prettierignore", - "lint": "nx lint website", + "lint": "nx lint", "serve": "docusaurus serve", "start": "docusaurus start", "swizzle": "docusaurus swizzle", From 01159d204154e31acf86162268ff27d95b7fc783 Mon Sep 17 00:00:00 2001 From: "typescript-eslint[bot]" Date: Mon, 21 Nov 2022 17:20:05 +0000 Subject: [PATCH 57/76] chore: publish v5.44.0 --- CHANGELOG.md | 16 ++++++++++++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 6 ++++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 4 ++++ packages/eslint-plugin-internal/package.json | 8 ++++---- packages/eslint-plugin-tslint/CHANGELOG.md | 4 ++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 14 ++++++++++++++ packages/eslint-plugin/package.json | 8 ++++---- packages/experimental-utils/CHANGELOG.md | 4 ++++ packages/experimental-utils/package.json | 4 ++-- packages/parser/CHANGELOG.md | 4 ++++ packages/parser/package.json | 8 ++++---- packages/scope-manager/CHANGELOG.md | 6 ++++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 4 ++++ packages/shared-fixtures/package.json | 2 +- packages/type-utils/CHANGELOG.md | 4 ++++ packages/type-utils/package.json | 8 ++++---- packages/types/CHANGELOG.md | 6 ++++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 11 +++++++++++ packages/typescript-estree/package.json | 8 ++++---- packages/utils/CHANGELOG.md | 4 ++++ packages/utils/package.json | 10 +++++----- packages/visitor-keys/CHANGELOG.md | 6 ++++++ packages/visitor-keys/package.json | 4 ++-- packages/website-eslint/CHANGELOG.md | 4 ++++ packages/website-eslint/package.json | 16 ++++++++-------- packages/website/CHANGELOG.md | 4 ++++ packages/website/package.json | 8 ++++---- 32 files changed, 153 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b400022f227..b6e1fb0f529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Bug Fixes + +- **eslint-plugin:** [no-empty-interface] disable autofix for declaration merging with class ([#5920](https://github.com/typescript-eslint/typescript-eslint/issues/5920)) ([a4f85b8](https://github.com/typescript-eslint/typescript-eslint/commit/a4f85b8cfe38ba8ea2a2ac4a56d9b11a81a8a15a)) +- **eslint-plugin:** [no-unnecessary-condition] handle index signature type ([#5912](https://github.com/typescript-eslint/typescript-eslint/issues/5912)) ([5baad08](https://github.com/typescript-eslint/typescript-eslint/commit/5baad0893f9a90633d57fffac69af7523bd1501e)) +- **eslint-plugin:** [prefer-optional-chain] handle binary expressions in negated or ([#5992](https://github.com/typescript-eslint/typescript-eslint/issues/5992)) ([2778ff0](https://github.com/typescript-eslint/typescript-eslint/commit/2778ff0c3db011148be93ed3bea5ce07af3c81ef)) +- **typescript-estree:** don't consider a cached program unless it's specified in the current `parserOptions.project` config ([#5999](https://github.com/typescript-eslint/typescript-eslint/issues/5999)) ([530e0e6](https://github.com/typescript-eslint/typescript-eslint/commit/530e0e618cdf4bb956149bf8a8484848e1b9a1f5)) + +### Features + +- **eslint-plugin:** [adjacent-overload-signatures] check BlockStatement nodes ([#5998](https://github.com/typescript-eslint/typescript-eslint/issues/5998)) ([97d3e56](https://github.com/typescript-eslint/typescript-eslint/commit/97d3e56709ee19fdec39fd8b99d080db90b306e9)) +- **eslint-plugin:** [keyword-spacing] Support spacing in import-type syntax ([#5977](https://github.com/typescript-eslint/typescript-eslint/issues/5977)) ([6a735e1](https://github.com/typescript-eslint/typescript-eslint/commit/6a735e142ef67f3af6497f922cf83706867eb6b7)) +- support parsing `satisfies` operators ([#5717](https://github.com/typescript-eslint/typescript-eslint/issues/5717)) ([20d7cae](https://github.com/typescript-eslint/typescript-eslint/commit/20d7caee35ab84ae6381fdf04338c9e2b9e2bc48)) +- update to TypeScript 4.9 ([#5716](https://github.com/typescript-eslint/typescript-eslint/issues/5716)) ([4d744ea](https://github.com/typescript-eslint/typescript-eslint/commit/4d744ea10ba03c66eebcb63e8722e9f0165fbeed)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) ### Bug Fixes diff --git a/lerna.json b/lerna.json index e213821c090..112f88b34a7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.43.0", + "version": "5.44.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index 33f54422348..98f5cb54d73 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Features + +- support parsing `satisfies` operators ([#5717](https://github.com/typescript-eslint/typescript-eslint/issues/5717)) ([20d7cae](https://github.com/typescript-eslint/typescript-eslint/commit/20d7caee35ab84ae6381fdf04338c9e2b9e2bc48)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 15b7f40de48..a0c4f5d5362 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.43.0", + "version": "5.44.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index 3cb70bba497..73d97608e26 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 4c317f8b0f2..0b9495a98c3 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.43.0", + "version": "5.44.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,9 +14,9 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/type-utils": "5.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/scope-manager": "5.44.0", + "@typescript-eslint/type-utils": "5.44.0", + "@typescript-eslint/utils": "5.44.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 77d0a23e05a..98f50504104 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 78715448e44..fbd344b1d47 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.43.0", + "version": "5.44.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/utils": "5.44.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.43.0" + "@typescript-eslint/parser": "5.44.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 9b989e2c870..5346de33f1c 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Bug Fixes + +- **eslint-plugin:** [no-empty-interface] disable autofix for declaration merging with class ([#5920](https://github.com/typescript-eslint/typescript-eslint/issues/5920)) ([a4f85b8](https://github.com/typescript-eslint/typescript-eslint/commit/a4f85b8cfe38ba8ea2a2ac4a56d9b11a81a8a15a)) +- **eslint-plugin:** [no-unnecessary-condition] handle index signature type ([#5912](https://github.com/typescript-eslint/typescript-eslint/issues/5912)) ([5baad08](https://github.com/typescript-eslint/typescript-eslint/commit/5baad0893f9a90633d57fffac69af7523bd1501e)) +- **eslint-plugin:** [prefer-optional-chain] handle binary expressions in negated or ([#5992](https://github.com/typescript-eslint/typescript-eslint/issues/5992)) ([2778ff0](https://github.com/typescript-eslint/typescript-eslint/commit/2778ff0c3db011148be93ed3bea5ce07af3c81ef)) +- **typescript-estree:** don't consider a cached program unless it's specified in the current `parserOptions.project` config ([#5999](https://github.com/typescript-eslint/typescript-eslint/issues/5999)) ([530e0e6](https://github.com/typescript-eslint/typescript-eslint/commit/530e0e618cdf4bb956149bf8a8484848e1b9a1f5)) + +### Features + +- **eslint-plugin:** [adjacent-overload-signatures] check BlockStatement nodes ([#5998](https://github.com/typescript-eslint/typescript-eslint/issues/5998)) ([97d3e56](https://github.com/typescript-eslint/typescript-eslint/commit/97d3e56709ee19fdec39fd8b99d080db90b306e9)) +- **eslint-plugin:** [keyword-spacing] Support spacing in import-type syntax ([#5977](https://github.com/typescript-eslint/typescript-eslint/issues/5977)) ([6a735e1](https://github.com/typescript-eslint/typescript-eslint/commit/6a735e142ef67f3af6497f922cf83706867eb6b7)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) ### Bug Fixes diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 95a7f2a2b87..4e6dde4cf87 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.43.0", + "version": "5.44.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,9 +44,9 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/type-utils": "5.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/scope-manager": "5.44.0", + "@typescript-eslint/type-utils": "5.44.0", + "@typescript-eslint/utils": "5.44.0", "debug": "^4.3.4", "ignore": "^5.2.0", "natural-compare-lite": "^1.4.0", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index dbf41b97191..4d40a307fdf 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 fa4775116f4..890423ff65c 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.43.0", + "version": "5.44.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.43.0" + "@typescript-eslint/utils": "5.44.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 c6013137c08..52366c06677 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/parser + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index f83abd5ce3f..11e72b17903 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.43.0", + "version": "5.44.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.43.0", - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/scope-manager": "5.44.0", + "@typescript-eslint/types": "5.44.0", + "@typescript-eslint/typescript-estree": "5.44.0", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index 4707e539d1b..6c427dbabce 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Features + +- update to TypeScript 4.9 ([#5716](https://github.com/typescript-eslint/typescript-eslint/issues/5716)) ([4d744ea](https://github.com/typescript-eslint/typescript-eslint/commit/4d744ea10ba03c66eebcb63e8722e9f0165fbeed)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 1849dab5710..f58510fe87f 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.43.0", + "version": "5.44.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -38,12 +38,12 @@ "typecheck": "nx typecheck" }, "dependencies": { - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/visitor-keys": "5.43.0" + "@typescript-eslint/types": "5.44.0", + "@typescript-eslint/visitor-keys": "5.44.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/typescript-estree": "5.44.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index a96e2e63278..b50beb1e1a7 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 cec6cebc648..539146e0b43 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.43.0", + "version": "5.44.0", "private": true } diff --git a/packages/type-utils/CHANGELOG.md b/packages/type-utils/CHANGELOG.md index 86867d3cdde..974d40d5d77 100644 --- a/packages/type-utils/CHANGELOG.md +++ b/packages/type-utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/type-utils + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 1bde3fa7291..be4ef3f95ed 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/type-utils", - "version": "5.43.0", + "version": "5.44.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.43.0", - "@typescript-eslint/utils": "5.43.0", + "@typescript-eslint/typescript-estree": "5.44.0", + "@typescript-eslint/utils": "5.44.0", "debug": "^4.3.4", "tsutils": "^3.21.0" }, "devDependencies": { - "@typescript-eslint/parser": "5.43.0", + "@typescript-eslint/parser": "5.44.0", "typescript": "*" }, "peerDependencies": { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index cede80aabc0..e721c00a5ce 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Features + +- update to TypeScript 4.9 ([#5716](https://github.com/typescript-eslint/typescript-eslint/issues/5716)) ([4d744ea](https://github.com/typescript-eslint/typescript-eslint/commit/4d744ea10ba03c66eebcb63e8722e9f0165fbeed)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 95b3e310549..0cc513232d4 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.43.0", + "version": "5.44.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 c7f8b17bab4..f6309d7faef 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/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.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Bug Fixes + +- **typescript-estree:** don't consider a cached program unless it's specified in the current `parserOptions.project` config ([#5999](https://github.com/typescript-eslint/typescript-eslint/issues/5999)) ([530e0e6](https://github.com/typescript-eslint/typescript-eslint/commit/530e0e618cdf4bb956149bf8a8484848e1b9a1f5)) + +### Features + +- support parsing `satisfies` operators ([#5717](https://github.com/typescript-eslint/typescript-eslint/issues/5717)) ([20d7cae](https://github.com/typescript-eslint/typescript-eslint/commit/20d7caee35ab84ae6381fdf04338c9e2b9e2bc48)) +- update to TypeScript 4.9 ([#5716](https://github.com/typescript-eslint/typescript-eslint/issues/5716)) ([4d744ea](https://github.com/typescript-eslint/typescript-eslint/commit/4d744ea10ba03c66eebcb63e8722e9f0165fbeed)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 8b6a4b63236..b16ecb687b7 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.43.0", + "version": "5.44.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.43.0", - "@typescript-eslint/visitor-keys": "5.43.0", + "@typescript-eslint/types": "5.44.0", + "@typescript-eslint/visitor-keys": "5.44.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.43.0", + "@typescript-eslint/shared-fixtures": "5.44.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 3a925cebcb9..0fbb0378b1b 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/utils + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **Note:** Version bump only for package @typescript-eslint/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 8057615f782..8064fe758bd 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/utils", - "version": "5.43.0", + "version": "5.44.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.43.0", - "@typescript-eslint/types": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", + "@typescript-eslint/scope-manager": "5.44.0", + "@typescript-eslint/types": "5.44.0", + "@typescript-eslint/typescript-estree": "5.44.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.43.0", + "@typescript-eslint/parser": "5.44.0", "typescript": "*" }, "funding": { diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 9ebb6b77f0b..65c9d29a574 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +### Features + +- support parsing `satisfies` operators ([#5717](https://github.com/typescript-eslint/typescript-eslint/issues/5717)) ([20d7cae](https://github.com/typescript-eslint/typescript-eslint/commit/20d7caee35ab84ae6381fdf04338c9e2b9e2bc48)) + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 36a76506596..39da7ca6633 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.43.0", + "version": "5.44.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.43.0", + "@typescript-eslint/types": "5.44.0", "eslint-visitor-keys": "^3.3.0" }, "devDependencies": { diff --git a/packages/website-eslint/CHANGELOG.md b/packages/website-eslint/CHANGELOG.md index 5ea048243ae..f5490b2af6a 100644 --- a/packages/website-eslint/CHANGELOG.md +++ b/packages/website-eslint/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package @typescript-eslint/website-eslint + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **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 0baf89601da..59d872c683b 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/website-eslint", - "version": "5.43.0", + "version": "5.44.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.43.0", - "@typescript-eslint/utils": "5.43.0" + "@typescript-eslint/types": "5.44.0", + "@typescript-eslint/utils": "5.44.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.43.0", - "@typescript-eslint/parser": "5.43.0", - "@typescript-eslint/scope-manager": "5.43.0", - "@typescript-eslint/typescript-estree": "5.43.0", - "@typescript-eslint/visitor-keys": "5.43.0", + "@typescript-eslint/eslint-plugin": "5.44.0", + "@typescript-eslint/parser": "5.44.0", + "@typescript-eslint/scope-manager": "5.44.0", + "@typescript-eslint/typescript-estree": "5.44.0", + "@typescript-eslint/visitor-keys": "5.44.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 6e050be87af..76a67a30561 100644 --- a/packages/website/CHANGELOG.md +++ b/packages/website/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.44.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.43.0...v5.44.0) (2022-11-21) + +**Note:** Version bump only for package website + # [5.43.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.42.1...v5.43.0) (2022-11-14) **Note:** Version bump only for package website diff --git a/packages/website/package.json b/packages/website/package.json index fa0c1c3c2af..fb681231463 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "5.43.0", + "version": "5.44.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.43.0", - "@typescript-eslint/website-eslint": "5.43.0", + "@typescript-eslint/parser": "5.44.0", + "@typescript-eslint/website-eslint": "5.44.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.43.0", + "@typescript-eslint/eslint-plugin": "5.44.0", "copy-webpack-plugin": "^11.0.0", "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.29.4", From b1f4dad16fa00ff4c3e1528c48f0216c452ba6d1 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 22 Nov 2022 02:27:33 -0500 Subject: [PATCH 58/76] docs(website): add version to header, and documented branch flow (#6055) --- packages/website/README.md | 11 ++++++++++- packages/website/docusaurusConfig.ts | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/website/README.md b/packages/website/README.md index fd7bb57cb42..7f4c12e2372 100644 --- a/packages/website/README.md +++ b/packages/website/README.md @@ -1,5 +1,7 @@ # Website +[![Netlify Status](https://api.netlify.com/api/v1/badges/128d21c7-b2fe-45ad-b141-9878fcf5de3a/deploy-status)](https://app.netlify.com/sites/typescript-eslint/deploys) + This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. ## Installation @@ -26,4 +28,11 @@ This command generates static content into the `build` directory and can be serv ## Deployment -The website is deployed automatically using Netlify. Each pull request into the `main` branch will have a unique preview deployment generated for it. +### Production + +The website is deployed from the `website` branch automatically using Netlify. +That branch gets updated from the `main` branch whenever a new stable version is released (generally weekly). + +### Pull Requests + +Each pull request into the `main` branch will have a unique preview deployment generated for it. diff --git a/packages/website/docusaurusConfig.ts b/packages/website/docusaurusConfig.ts index 0ef589b005a..7ac111820f2 100644 --- a/packages/website/docusaurusConfig.ts +++ b/packages/website/docusaurusConfig.ts @@ -8,6 +8,7 @@ import type { UserThemeConfig as AlgoliaThemeConfig } from '@docusaurus/theme-se import type { Config } from '@docusaurus/types'; import tabsPlugin from 'remark-docusaurus-tabs'; +import { version } from './package.json'; import { generatedRuleDocs } from './plugins/generated-rule-docs'; import { rulesMeta } from './rulesMeta'; @@ -91,6 +92,11 @@ const themeConfig: ThemeCommonConfig & AlgoliaThemeConfig = { label: 'Blog', position: 'left', }, + { + position: 'right', + value: `v${version}`, + type: 'html', + }, { to: 'play', activeBasePath: 'play', From 44027db379e6e074a16cda2755ef554c2b0a4c5a Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 23 Nov 2022 09:01:51 +1030 Subject: [PATCH 59/76] fix(scope-manager): add support for TS4.9 satisfies expression (#6059) feat(scope-manager): add support for TS4.9 satisfies expression --- .prettierignore | 1 + .../src/referencer/Referencer.ts | 9 +- .../fixtures/type-assertion/satisfies.ts | 4 + .../fixtures/type-assertion/satisfies.ts.shot | 84 +++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts create mode 100644 packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot diff --git a/.prettierignore b/.prettierignore index 88af276a1b2..bb855f41157 100644 --- a/.prettierignore +++ b/.prettierignore @@ -14,6 +14,7 @@ packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts # prettier doesn't yet support satisfies packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/ +packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts index 93b0270ebfb..e7b41127ba4 100644 --- a/packages/scope-manager/src/referencer/Referencer.ts +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -301,7 +301,10 @@ class Referencer extends Visitor { } protected visitTypeAssertion( - node: TSESTree.TSAsExpression | TSESTree.TSTypeAssertion, + node: + | TSESTree.TSAsExpression + | TSESTree.TSTypeAssertion + | TSESTree.TSSatisfiesExpression, ): void { this.visit(node.expression); this.visitType(node.typeAnnotation); @@ -724,6 +727,10 @@ class Referencer extends Visitor { this.close(node); } + protected TSSatisfiesExpression(node: TSESTree.TSSatisfiesExpression): void { + this.visitTypeAssertion(node); + } + protected TSTypeAliasDeclaration( node: TSESTree.TSTypeAliasDeclaration, ): void { diff --git a/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts new file mode 100644 index 00000000000..69dae24ecf2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts @@ -0,0 +1,4 @@ +const x = 1; +type T = 1; + +x satisfies T; diff --git a/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot new file mode 100644 index 00000000000..9d6dcc03ce1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-assertion satisfies 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$2, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isRead: true, + isTypeReference: false, + isValueReference: true, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isRead: true, + isTypeReference: true, + isValueReference: false, + isWrite: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "x" => Variable$2, + "T" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + ], + }, + ], +} +`; From 361f8bcebe588fc7410a53e002c55118b0bfee85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 26 Oct 2022 01:59:38 +0200 Subject: [PATCH 60/76] fix(utils): removed `TRuleListener` generic from the `createRule` (#5036) * refactor(utils)!: removed `TRuleListener` generic from the `createRule` * refactor!: removed `TRuleListener` generic from the `CLIEngine` and `RuleCreateFunction` * chore: document and refactor 'extra' to 'parserSettings' (#5834) * chore(website): fix renamed Sponsorship docs link (#5882) * docs: Mention wide globs performance implications in monorepos docs and parser README (#5864) * docs: Mention wide globs performance implications in monorepos docs and parser readme * Update docs/linting/typed-linting/MONOREPOS.md Co-authored-by: Josh Goldberg Co-authored-by: Josh Goldberg Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com> --- .../utils/src/eslint-utils/RuleCreator.ts | 27 ++++++++----------- packages/utils/src/ts-eslint/CLIEngine.ts | 6 ++--- packages/utils/src/ts-eslint/Rule.ts | 4 +-- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/packages/utils/src/eslint-utils/RuleCreator.ts b/packages/utils/src/eslint-utils/RuleCreator.ts index dedf3043121..527ae36307b 100644 --- a/packages/utils/src/eslint-utils/RuleCreator.ts +++ b/packages/utils/src/eslint-utils/RuleCreator.ts @@ -16,28 +16,25 @@ export type NamedCreateRuleMeta = { export interface RuleCreateAndOptions< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends RuleListener, > { create: ( context: Readonly>, optionsWithDefault: Readonly, - ) => TRuleListener; + ) => RuleListener; defaultOptions: Readonly; } export interface RuleWithMeta< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends RuleListener, -> extends RuleCreateAndOptions { +> extends RuleCreateAndOptions { meta: RuleMetaData; } export interface RuleWithMetaAndName< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends RuleListener, -> extends RuleCreateAndOptions { +> extends RuleCreateAndOptions { meta: NamedCreateRuleMeta; name: string; } @@ -54,15 +51,15 @@ export function RuleCreator(urlCreator: (ruleName: string) => string) { return function createNamedRule< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends RuleListener = RuleListener, >({ name, meta, ...rule - }: Readonly< - RuleWithMetaAndName - >): RuleModule { - return createRule({ + }: Readonly>): RuleModule< + TMessageIds, + TOptions + > { + return createRule({ meta: { ...meta, docs: { @@ -84,20 +81,18 @@ export function RuleCreator(urlCreator: (ruleName: string) => string) { function createRule< TOptions extends readonly unknown[], TMessageIds extends string, - TRuleListener extends RuleListener = RuleListener, >({ create, defaultOptions, meta, -}: Readonly>): RuleModule< +}: Readonly>): RuleModule< TMessageIds, - TOptions, - TRuleListener + TOptions > { return { create( context: Readonly>, - ): TRuleListener { + ): RuleListener { const optionsWithDefault = applyDefault(defaultOptions, context.options); return create(context, optionsWithDefault); }, diff --git a/packages/utils/src/ts-eslint/CLIEngine.ts b/packages/utils/src/ts-eslint/CLIEngine.ts index 9ad4f5c76ed..65629fbbec7 100644 --- a/packages/utils/src/ts-eslint/CLIEngine.ts +++ b/packages/utils/src/ts-eslint/CLIEngine.ts @@ -4,7 +4,7 @@ import { CLIEngine as ESLintCLIEngine } from 'eslint'; import type { Linter } from './Linter'; -import type { RuleListener, RuleMetaData, RuleModule } from './Rule'; +import type { RuleMetaData, RuleModule } from './Rule'; declare class CLIEngineBase { /** @@ -72,9 +72,7 @@ declare class CLIEngineBase { getRules< TMessageIds extends string = string, TOptions extends readonly unknown[] = unknown[], - // for extending base rules - TRuleListener extends RuleListener = RuleListener, - >(): Map>; + >(): Map>; //////////////////// // static members // diff --git a/packages/utils/src/ts-eslint/Rule.ts b/packages/utils/src/ts-eslint/Rule.ts index ff305386321..7fe34067c95 100644 --- a/packages/utils/src/ts-eslint/Rule.ts +++ b/packages/utils/src/ts-eslint/Rule.ts @@ -453,9 +453,7 @@ interface RuleModule< type RuleCreateFunction< TMessageIds extends string = never, TOptions extends readonly unknown[] = unknown[], - // for extending base rules - TRuleListener extends RuleListener = RuleListener, -> = (context: Readonly>) => TRuleListener; +> = (context: Readonly>) => RuleListener; export { ReportDescriptor, From 2b69b659d87b58468e413801d31086ae0eeafff4 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 26 Oct 2022 02:42:06 +0200 Subject: [PATCH 61/76] feat: create TSTypeQuery node when TSImportType has isTypeOf (#3076) * feat: update TSImportType node * fix: update visitor keys * chore: document and refactor 'extra' to 'parserSettings' (#5834) * chore(website): fix renamed Sponsorship docs link (#5882) * docs: Mention wide globs performance implications in monorepos docs and parser README (#5864) * docs: Mention wide globs performance implications in monorepos docs and parser readme * Update docs/linting/typed-linting/MONOREPOS.md Co-authored-by: Josh Goldberg Co-authored-by: Josh Goldberg Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com> --- .../ast-spec/src/type/TSImportType/spec.ts | 3 +- .../ast-spec/src/type/TSTypeQuery/spec.ts | 3 +- .../src/referencer/TypeVisitor.ts | 9 +- .../typescript/basics/type-import-type.src.ts | 2 +- packages/typescript-estree/src/convert.ts | 21 ++++- .../src/ts-estree/estree-to-ts-node-types.ts | 2 +- .../tests/ast-alignment/fixtures-to-test.ts | 5 - .../tests/ast-alignment/utils.ts | 22 +++++ ...e-parameters-in-type-reference.src.ts.shot | 23 +++-- .../basics/type-import-type.src.ts.shot | 91 +++++++++++-------- packages/visitor-keys/src/visitor-keys.ts | 2 +- 11 files changed, 117 insertions(+), 66 deletions(-) diff --git a/packages/ast-spec/src/type/TSImportType/spec.ts b/packages/ast-spec/src/type/TSImportType/spec.ts index b2eea1a78e0..fb2d33bfe11 100644 --- a/packages/ast-spec/src/type/TSImportType/spec.ts +++ b/packages/ast-spec/src/type/TSImportType/spec.ts @@ -6,8 +6,7 @@ import type { TypeNode } from '../../unions/TypeNode'; export interface TSImportType extends BaseNode { type: AST_NODE_TYPES.TSImportType; - isTypeOf: boolean; - parameter: TypeNode; + argument: TypeNode; qualifier: EntityName | null; typeParameters: TSTypeParameterInstantiation | null; } diff --git a/packages/ast-spec/src/type/TSTypeQuery/spec.ts b/packages/ast-spec/src/type/TSTypeQuery/spec.ts index 634c307ad2c..bc9cb7e68d0 100644 --- a/packages/ast-spec/src/type/TSTypeQuery/spec.ts +++ b/packages/ast-spec/src/type/TSTypeQuery/spec.ts @@ -2,9 +2,10 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; import type { TSTypeParameterInstantiation } from '../../special/spec'; import type { EntityName } from '../../unions/EntityName'; +import type { TSImportType } from '../TSImportType/spec'; export interface TSTypeQuery extends BaseNode { type: AST_NODE_TYPES.TSTypeQuery; - exprName: EntityName; + exprName: EntityName | TSImportType; typeParameters?: TSTypeParameterInstantiation; } diff --git a/packages/scope-manager/src/referencer/TypeVisitor.ts b/packages/scope-manager/src/referencer/TypeVisitor.ts index 70d4f86d55a..367fe3d3f23 100644 --- a/packages/scope-manager/src/referencer/TypeVisitor.ts +++ b/packages/scope-manager/src/referencer/TypeVisitor.ts @@ -260,7 +260,10 @@ class TypeVisitor extends Visitor { // a type query `typeof foo` is a special case that references a _non-type_ variable, protected TSTypeQuery(node: TSESTree.TSTypeQuery): void { - let entityName: TSESTree.Identifier | TSESTree.ThisExpression; + let entityName: + | TSESTree.Identifier + | TSESTree.ThisExpression + | TSESTree.TSImportType; if (node.exprName.type === AST_NODE_TYPES.TSQualifiedName) { let iter = node.exprName; while (iter.left.type === AST_NODE_TYPES.TSQualifiedName) { @@ -269,6 +272,10 @@ class TypeVisitor extends Visitor { entityName = iter.left; } else { entityName = node.exprName; + + if (node.exprName.type === AST_NODE_TYPES.TSImportType) { + this.visit(node.exprName); + } } if (entityName.type === AST_NODE_TYPES.Identifier) { this.#referencer.currentScope().referenceValue(entityName); diff --git a/packages/shared-fixtures/fixtures/typescript/basics/type-import-type.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/type-import-type.src.ts index 00e3ba6afc1..5166c214216 100644 --- a/packages/shared-fixtures/fixtures/typescript/basics/type-import-type.src.ts +++ b/packages/shared-fixtures/fixtures/typescript/basics/type-import-type.src.ts @@ -1,2 +1,2 @@ type A = typeof import('A'); -type B = import("B").X; +type B = import('B').X; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index ca53cc45a44..015e1bbc636 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2730,11 +2730,15 @@ export class Converter { return result; } - case SyntaxKind.ImportType: - return this.createNode(node, { + case SyntaxKind.ImportType: { + const range = getRange(node, this.ast); + if (node.isTypeOf) { + const token = findNextToken(node.getFirstToken()!, node, this.ast)!; + range[0] = token.getStart(this.ast); + } + const result = this.createNode(node, { type: AST_NODE_TYPES.TSImportType, - isTypeOf: !!node.isTypeOf, - parameter: this.convertChild(node.argument), + argument: this.convertChild(node.argument), qualifier: this.convertChild(node.qualifier), typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters( @@ -2742,7 +2746,16 @@ export class Converter { node, ) : null, + range: range, }); + if (node.isTypeOf) { + return this.createNode(node, { + type: AST_NODE_TYPES.TSTypeQuery, + exprName: result, + }); + } + return result; + } case SyntaxKind.EnumDeclaration: { const result = this.createNode(node, { diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 12ff9392cb0..7561d6e9142 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -226,7 +226,7 @@ export interface EstreeToTsNodeTypes { | ts.CallExpression | ts.TypeQueryNode; [AST_NODE_TYPES.TSTypePredicate]: ts.TypePredicateNode; - [AST_NODE_TYPES.TSTypeQuery]: ts.TypeQueryNode; + [AST_NODE_TYPES.TSTypeQuery]: ts.TypeQueryNode | ts.ImportTypeNode; [AST_NODE_TYPES.TSTypeReference]: ts.TypeReferenceNode; [AST_NODE_TYPES.TSUnionType]: ts.UnionTypeNode; [AST_NODE_TYPES.UpdateExpression]: diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index 9c4d8a44bcc..ac87ee62178 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -341,11 +341,6 @@ tester.addFixturePatternConfig('typescript/basics', { * @see https://github.com/babel/babel/issues/12884 */ 'interface-with-extends-member-expression', - /** - * @see https://github.com/typescript-eslint/typescript-eslint/issues/2998 - */ - 'type-import-type', - 'type-import-type-with-type-parameters-in-type-reference', /** * Not yet supported in Babel * Directive field is not added to module and namespace diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 717a74837b5..d92e70541aa 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -292,6 +292,28 @@ export function preprocessBabylonAST(ast: File): any { delete node.loc.start.index; } }, + TSImportType(node: any) { + if (!node.typeParameters) { + node.typeParameters = null; + } + if (!node.qualifier) { + node.qualifier = null; + } + /** + * https://github.com/babel/babel/issues/12833 + */ + if (node.argument) { + node.argument = { + type: AST_NODE_TYPES.TSLiteralType, + literal: node.argument, + loc: { + start: { ...node.argument.loc.start }, + end: { ...node.argument.loc.end }, + }, + range: [...node.argument.range], + }; + } + }, TSTypePredicate(node: any) { if (node.loc?.start?.index) { delete node.loc.start.index; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src.ts.shot index 3d1549888bc..2e2104b59f3 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type-with-type-parameters-in-type-reference.src.ts.shot @@ -84,18 +84,7 @@ Object { }, "params": Array [ Object { - "isTypeOf": false, - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "parameter": Object { + "argument": Object { "literal": Object { "loc": Object { "end": Object { @@ -131,6 +120,16 @@ Object { ], "type": "TSLiteralType", }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, "qualifier": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type.src.ts.shot index 1afe1ff0424..010427ef271 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-import-type.src.ts.shot @@ -38,19 +38,27 @@ Object { ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { - "isTypeOf": true, - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "parameter": Object { - "literal": Object { + "exprName": Object { + "argument": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 26, + ], + "raw": "'A'", + "type": "Literal", + "value": "A", + }, "loc": Object { "end": Object { "column": 26, @@ -65,33 +73,41 @@ Object { 23, 26, ], - "raw": "'A'", - "type": "Literal", - "value": "A", + "type": "TSLiteralType", }, "loc": Object { "end": Object { - "column": 26, + "column": 27, "line": 1, }, "start": Object { - "column": 23, + "column": 16, "line": 1, }, }, + "qualifier": null, "range": Array [ - 23, - 26, + 16, + 27, ], - "type": "TSLiteralType", + "type": "TSImportType", + "typeParameters": null, + }, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, }, - "qualifier": null, "range": Array [ 9, 27, ], - "type": "TSImportType", - "typeParameters": null, + "type": "TSTypeQuery", }, }, Object { @@ -129,18 +145,7 @@ Object { ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { - "isTypeOf": false, - "loc": Object { - "end": Object { - "column": 25, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "parameter": Object { + "argument": Object { "literal": Object { "loc": Object { "end": Object { @@ -156,7 +161,7 @@ Object { 45, 48, ], - "raw": "\\"B\\"", + "raw": "'B'", "type": "Literal", "value": "B", }, @@ -176,6 +181,16 @@ Object { ], "type": "TSLiteralType", }, + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, "qualifier": Object { "loc": Object { "end": Object { @@ -542,7 +557,7 @@ Object { 48, ], "type": "String", - "value": "\\"B\\"", + "value": "'B'", }, Object { "loc": Object { diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index cb3e614df53..888246f09d5 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -96,7 +96,7 @@ const additionalKeys: AdditionalKeys = { TSExternalModuleReference: ['expression'], TSFunctionType: ['typeParameters', 'params', 'returnType'], TSImportEqualsDeclaration: ['id', 'moduleReference'], - TSImportType: ['parameter', 'qualifier', 'typeParameters'], + TSImportType: ['argument', 'qualifier', 'typeParameters'], TSIndexedAccessType: ['indexType', 'objectType'], TSIndexSignature: ['parameters', 'typeAnnotation'], TSInferType: ['typeParameter'], From f2330f79739eb93e3c290ccc6e810a01e097eda0 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 25 Oct 2022 23:13:43 -0400 Subject: [PATCH 62/76] feat(scope-manager): ignore ECMA version (#5889) * feat(scope-manager): ignore ECMA version * chore: document and refactor 'extra' to 'parserSettings' (#5834) * chore(website): fix renamed Sponsorship docs link (#5882) * Remove much more * Fix WebLinter lint * docs: Mention wide globs performance implications in monorepos docs and parser README (#5864) * docs: Mention wide globs performance implications in monorepos docs and parser readme * Update docs/linting/typed-linting/MONOREPOS.md Co-authored-by: Josh Goldberg * chore: add auto-canary release for v6 (#5883) Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com> --- packages/parser/src/parser.ts | 1 - packages/parser/tests/lib/parser.ts | 8 --- packages/scope-manager/README.md | 12 +---- packages/scope-manager/src/ScopeManager.ts | 9 ++-- packages/scope-manager/src/analyze.ts | 35 ++----------- .../src/referencer/Referencer.ts | 17 ++----- .../get-declared-variables.test.ts | 1 - .../tests/eslint-scope/implied-strict.test.ts | 30 +---------- .../eslint-scope/map-ecma-version.test.ts | 51 ------------------- packages/scope-manager/tests/fixtures.test.ts | 1 - .../src/components/linter/WebLinter.ts | 4 -- 11 files changed, 18 insertions(+), 151 deletions(-) delete mode 100644 packages/scope-manager/tests/eslint-scope/map-ecma-version.test.ts diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 0e4b7780c17..e7223e93332 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -105,7 +105,6 @@ function parseForESLint( jsx: validateBoolean(options.ecmaFeatures.jsx), }); const analyzeOptions: AnalyzeOptions = { - ecmaVersion: options.ecmaVersion === 'latest' ? 1e8 : options.ecmaVersion, globalReturn: options.ecmaFeatures.globalReturn, jsxPragma: options.jsxPragma, jsxFragmentName: options.jsxFragmentName, diff --git a/packages/parser/tests/lib/parser.ts b/packages/parser/tests/lib/parser.ts index 7f2f193e11d..e554c4bfde7 100644 --- a/packages/parser/tests/lib/parser.ts +++ b/packages/parser/tests/lib/parser.ts @@ -19,11 +19,6 @@ describe('parser', () => { expect(() => parseForESLint(code, null)).not.toThrow(); }); - it("parseForESLint() should work if options.ecmaVersion is `'latest'`", () => { - const code = 'const valid = true;'; - expect(() => parseForESLint(code, { ecmaVersion: 'latest' })).not.toThrow(); - }); - it('parseAndGenerateServices() should be called with options', () => { const code = 'const valid = true;'; const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices'); @@ -33,7 +28,6 @@ describe('parser', () => { range: false, tokens: false, sourceType: 'module' as const, - ecmaVersion: 2018, ecmaFeatures: { globalReturn: false, jsx: false, @@ -84,7 +78,6 @@ describe('parser', () => { range: false, tokens: false, sourceType: 'module' as const, - ecmaVersion: 2018, ecmaFeatures: { globalReturn: false, jsx: false, @@ -104,7 +97,6 @@ describe('parser', () => { parseForESLint(code, config); expect(spy).toHaveBeenCalledTimes(1); expect(spy).toHaveBeenLastCalledWith(expect.anything(), { - ecmaVersion: 2018, globalReturn: false, lib: ['dom.iterable'], jsxPragma: 'Foo', diff --git a/packages/scope-manager/README.md b/packages/scope-manager/README.md index b0a745f3fa5..3d9ef751032 100644 --- a/packages/scope-manager/README.md +++ b/packages/scope-manager/README.md @@ -36,13 +36,6 @@ interface AnalyzeOptions { */ childVisitorKeys?: Record | null; - /** - * Which ECMAScript version is considered. - * Defaults to `2018`. - * `'latest'` is converted to 1e8 at parser. - */ - ecmaVersion?: EcmaVersion | 1e8; - /** * Whether the whole script is executed under node.js environment. * When enabled, the scope manager adds a function scope immediately following the global scope. @@ -51,7 +44,7 @@ interface AnalyzeOptions { globalReturn?: boolean; /** - * Implied strict mode (if ecmaVersion >= 5). + * Implied strict mode. * Defaults to `false`. */ impliedStrict?: boolean; @@ -76,7 +69,7 @@ interface AnalyzeOptions { * This automatically defines a type variable for any types provided by the configured TS libs. * For more information, see https://www.typescriptlang.org/tsconfig#lib * - * Defaults to the lib for the provided `ecmaVersion`. + * Defaults to ['esnext']. */ lib?: Lib[]; @@ -105,7 +98,6 @@ const ast = parse(code, { range: true, }); const scope = analyze(ast, { - ecmaVersion: 2020, sourceType: 'module', }); ``` diff --git a/packages/scope-manager/src/ScopeManager.ts b/packages/scope-manager/src/ScopeManager.ts index 5368cca1dc3..d8beafba4aa 100644 --- a/packages/scope-manager/src/ScopeManager.ts +++ b/packages/scope-manager/src/ScopeManager.ts @@ -28,9 +28,11 @@ interface ScopeManagerOptions { globalReturn?: boolean; sourceType?: 'module' | 'script'; impliedStrict?: boolean; - ecmaVersion?: number; } +/** + * @see https://eslint.org/docs/latest/developer-guide/scope-manager-interface#scopemanager-interface + */ class ScopeManager { public currentScope: Scope | null; public readonly declaredVariables: WeakMap; @@ -77,12 +79,13 @@ class ScopeManager { public isImpliedStrict(): boolean { return this.#options.impliedStrict === true; } + public isStrictModeSupported(): boolean { - return this.#options.ecmaVersion != null && this.#options.ecmaVersion >= 5; + return true; } public isES6(): boolean { - return this.#options.ecmaVersion != null && this.#options.ecmaVersion >= 6; + return true; } /** diff --git a/packages/scope-manager/src/analyze.ts b/packages/scope-manager/src/analyze.ts index e227d1e45ad..1cb1d989209 100644 --- a/packages/scope-manager/src/analyze.ts +++ b/packages/scope-manager/src/analyze.ts @@ -1,7 +1,6 @@ -import type { EcmaVersion, Lib, TSESTree } from '@typescript-eslint/types'; +import type { Lib, TSESTree } from '@typescript-eslint/types'; import { visitorKeys } from '@typescript-eslint/visitor-keys'; -import { lib as TSLibraries } from './lib'; import type { ReferencerOptions } from './referencer'; import { Referencer } from './referencer'; import { ScopeManager } from './ScopeManager'; @@ -16,13 +15,6 @@ interface AnalyzeOptions { */ childVisitorKeys?: ReferencerOptions['childVisitorKeys']; - /** - * Which ECMAScript version is considered. - * Defaults to `2018`. - * `'latest'` is converted to 1e8 at parser. - */ - ecmaVersion?: EcmaVersion | 1e8; - /** * Whether the whole script is executed under node.js environment. * When enabled, the scope manager adds a function scope immediately following the global scope. @@ -31,7 +23,7 @@ interface AnalyzeOptions { globalReturn?: boolean; /** - * Implied strict mode (if ecmaVersion >= 5). + * Implied strict mode. * Defaults to `false`. */ impliedStrict?: boolean; @@ -54,7 +46,7 @@ interface AnalyzeOptions { /** * The lib used by the project. * This automatically defines a type variable for any types provided by the configured TS libs. - * Defaults to the lib for the provided `ecmaVersion`. + * Defaults to ['esnext']. * * https://www.typescriptlang.org/tsconfig#lib */ @@ -74,7 +66,6 @@ interface AnalyzeOptions { const DEFAULT_OPTIONS: Required = { childVisitorKeys: visitorKeys, - ecmaVersion: 2018, globalReturn: false, impliedStrict: false, jsxPragma: 'React', @@ -84,21 +75,6 @@ const DEFAULT_OPTIONS: Required = { emitDecoratorMetadata: false, }; -/** - * Convert ecmaVersion to lib. - * `'latest'` is converted to 1e8 at parser. - */ -function mapEcmaVersion(version: EcmaVersion | 1e8 | undefined): Lib { - if (version == null || version === 3 || version === 5) { - return 'es5'; - } - - const year = version > 2000 ? version : 2015 + (version - 6); - const lib = `es${year}`; - - return lib in TSLibraries ? (lib as Lib) : year > 2020 ? 'esnext' : 'es5'; -} - /** * Takes an AST and returns the analyzed scopes. */ @@ -106,12 +82,9 @@ function analyze( tree: TSESTree.Node, providedOptions?: AnalyzeOptions, ): ScopeManager { - const ecmaVersion = - providedOptions?.ecmaVersion ?? DEFAULT_OPTIONS.ecmaVersion; const options: Required = { childVisitorKeys: providedOptions?.childVisitorKeys ?? DEFAULT_OPTIONS.childVisitorKeys, - ecmaVersion, globalReturn: providedOptions?.globalReturn ?? DEFAULT_OPTIONS.globalReturn, impliedStrict: providedOptions?.impliedStrict ?? DEFAULT_OPTIONS.impliedStrict, @@ -122,7 +95,7 @@ function analyze( jsxFragmentName: providedOptions?.jsxFragmentName ?? DEFAULT_OPTIONS.jsxFragmentName, sourceType: providedOptions?.sourceType ?? DEFAULT_OPTIONS.sourceType, - lib: providedOptions?.lib ?? [mapEcmaVersion(ecmaVersion)], + lib: providedOptions?.lib ?? ['esnext'], emitDecoratorMetadata: providedOptions?.emitDecoratorMetadata ?? DEFAULT_OPTIONS.emitDecoratorMetadata, diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts index e7b41127ba4..420d4d4aa89 100644 --- a/packages/scope-manager/src/referencer/Referencer.ts +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -374,9 +374,7 @@ class Referencer extends Visitor { } protected BlockStatement(node: TSESTree.BlockStatement): void { - if (this.scopeManager.isES6()) { - this.scopeManager.nestBlockScope(node); - } + this.scopeManager.nestBlockScope(node); this.visitChildren(node); @@ -490,7 +488,7 @@ class Referencer extends Visitor { protected ImportDeclaration(node: TSESTree.ImportDeclaration): void { assert( - this.scopeManager.isES6() && this.scopeManager.isModule(), + this.scopeManager.isModule(), 'ImportDeclaration should appear when the mode is ES6 and in the module context.', ); @@ -582,14 +580,11 @@ class Referencer extends Visitor { this.scopeManager.nestFunctionScope(node, false); } - if (this.scopeManager.isES6() && this.scopeManager.isModule()) { + if (this.scopeManager.isModule()) { this.scopeManager.nestModuleScope(node); } - if ( - this.scopeManager.isStrictModeSupported() && - this.scopeManager.isImpliedStrict() - ) { + if (this.scopeManager.isImpliedStrict()) { this.currentScope().isStrict = true; } @@ -604,9 +599,7 @@ class Referencer extends Visitor { protected SwitchStatement(node: TSESTree.SwitchStatement): void { this.visit(node.discriminant); - if (this.scopeManager.isES6()) { - this.scopeManager.nestSwitchScope(node); - } + this.scopeManager.nestSwitchScope(node); for (const switchCase of node.cases) { this.visit(switchCase); diff --git a/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts b/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts index 23e02b9af0c..82611eb5147 100644 --- a/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts +++ b/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts @@ -12,7 +12,6 @@ describe('ScopeManager.prototype.getDeclaredVariables', () => { expectedNamesList: string[][], ): void { const scopeManager = analyze(ast, { - ecmaVersion: 6, sourceType: 'module', }); diff --git a/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts b/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts index 34151be8c3d..893da6048c2 100644 --- a/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts +++ b/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts @@ -8,7 +8,7 @@ import { } from '../util'; describe('impliedStrict option', () => { - it('ensures all user scopes are strict if ecmaVersion >= 5', () => { + it('ensures all user scopes are strict', () => { const { scopeManager } = parseAndAnalyze( ` function foo() { @@ -18,7 +18,6 @@ describe('impliedStrict option', () => { } `, { - ecmaVersion: 5, impliedStrict: true, }, ); @@ -42,38 +41,12 @@ describe('impliedStrict option', () => { expect(scope.isStrict).toBeTruthy(); }); - it('ensures impliedStrict option is only effective when ecmaVersion option >= 5', () => { - const { scopeManager } = parseAndAnalyze( - ` - function foo() {} - `, - { - ecmaVersion: 3, - impliedStrict: true, - }, - ); - - expect(scopeManager.scopes).toHaveLength(2); - - let scope = scopeManager.scopes[0]; - - expectToBeGlobalScope(scope); - expect(scope.block.type).toBe(AST_NODE_TYPES.Program); - expect(scope.isStrict).toBeFalsy(); - - scope = scopeManager.scopes[1]; - expectToBeFunctionScope(scope); - expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionDeclaration); - expect(scope.isStrict).toBeFalsy(); - }); - it('omits a nodejs global scope when ensuring all user scopes are strict', () => { const { scopeManager } = parseAndAnalyze( ` function foo() {} `, { - ecmaVersion: 5, globalReturn: true, impliedStrict: true, }, @@ -100,7 +73,6 @@ describe('impliedStrict option', () => { it('omits a module global scope when ensuring all user scopes are strict', () => { const { scopeManager } = parseAndAnalyze('function foo() {}', { - ecmaVersion: 6, impliedStrict: true, sourceType: 'module', }); diff --git a/packages/scope-manager/tests/eslint-scope/map-ecma-version.test.ts b/packages/scope-manager/tests/eslint-scope/map-ecma-version.test.ts deleted file mode 100644 index becca474ff3..00000000000 --- a/packages/scope-manager/tests/eslint-scope/map-ecma-version.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { EcmaVersion, Lib, TSESTree } from '@typescript-eslint/types'; - -import { analyze } from '../../src/analyze'; -import { Referencer } from '../../src/referencer'; - -jest.mock('../../src/referencer'); -jest.mock('../../src/ScopeManager'); - -describe('ecma version mapping', () => { - it("should map to 'esnext' when unsuported and new", () => { - expectMapping(2042, 'esnext'); - expectMapping(42, 'esnext'); - }); - - it("should map to 'es5' when unsuported and old", () => { - expectMapping(2002, 'es5'); - expectMapping(2, 'es5'); - }); - - it("should map to 'es{year}' when supported and >= 6", () => { - expectMapping(2015, 'es2015'); - expectMapping(6, 'es2015'); - expectMapping(2020, 'es2020'); - expectMapping(11, 'es2020'); - }); - - it("should map to 'es5' when 5 or 3", () => { - expectMapping(5, 'es5'); - expectMapping(3, 'es5'); - }); - - it("should map to 'es2018' when undefined", () => { - expectMapping(undefined, 'es2018'); - }); - - it("should map to 'esnext' when 'latest'", () => { - // `'latest'` is converted to 1e8 at parser. - expectMapping(1e8, 'esnext'); - }); -}); - -const fakeNode = {} as unknown as TSESTree.Node; - -function expectMapping(ecmaVersion: number | undefined, lib: Lib): void { - (Referencer as jest.Mock).mockClear(); - analyze(fakeNode, { ecmaVersion: ecmaVersion as EcmaVersion }); - expect(Referencer).toHaveBeenCalledWith( - expect.objectContaining({ lib: [lib] }), - expect.any(Object), - ); -} diff --git a/packages/scope-manager/tests/fixtures.test.ts b/packages/scope-manager/tests/fixtures.test.ts index fa86c1544c7..ac6b39c860e 100644 --- a/packages/scope-manager/tests/fixtures.test.ts +++ b/packages/scope-manager/tests/fixtures.test.ts @@ -42,7 +42,6 @@ const ALLOWED_OPTIONS: Map = new Map< keyof AnalyzeOptions, ALLOWED_VALUE >([ - ['ecmaVersion', ['number']], ['globalReturn', ['boolean']], ['impliedStrict', ['boolean']], ['jsxPragma', ['string']], diff --git a/packages/website/src/components/linter/WebLinter.ts b/packages/website/src/components/linter/WebLinter.ts index 378e34ed136..acd3c569ff3 100644 --- a/packages/website/src/components/linter/WebLinter.ts +++ b/packages/website/src/components/linter/WebLinter.ts @@ -111,10 +111,6 @@ export class WebLinter { ); const scopeManager = this.lintUtils.analyze(ast, { - ecmaVersion: - eslintOptions.ecmaVersion === 'latest' - ? 1e8 - : eslintOptions.ecmaVersion, globalReturn: eslintOptions.ecmaFeatures?.globalReturn ?? false, sourceType: eslintOptions.sourceType ?? 'script', }); From 844875cbe933195ff25ba218f82ede3ebde9a0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Garc=C3=ADa?= <82288753+juank1809@users.noreply.github.com> Date: Tue, 25 Oct 2022 22:29:28 -0500 Subject: [PATCH 63/76] feat: remove semantically invalid properties from TSEnumDeclaration, TSInterfaceDeclaration and TSModuleDeclaration (#4863) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: remove invalid properties from ast nodes * chore: remove invalid code in scope-manager and typescript-estree * chore: re-write snapshots that were using invalid properties * feat: remove modifiers union from ast types Co-authored-by: Juan García Co-authored-by: Josh Goldberg --- .../src/declaration/TSEnumDeclaration/spec.ts | 3 - .../TSInterfaceDeclaration/spec.ts | 4 - .../declaration/TSModuleDeclaration/spec.ts | 3 - packages/ast-spec/src/index.ts | 1 - packages/ast-spec/src/unions/Modifier.ts | 16 --- .../src/referencer/TypeVisitor.ts | 1 - packages/typescript-estree/src/convert.ts | 85 ++---------- .../basics/abstract-interface.src.ts.shot | 1 - .../enum-with-keywords.src.ts.shot | 121 ------------------ .../interface-implements.src.ts.shot | 37 ------ 10 files changed, 12 insertions(+), 260 deletions(-) delete mode 100644 packages/ast-spec/src/unions/Modifier.ts diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts index 9a0df845c5d..1152c894f4a 100644 --- a/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts @@ -2,7 +2,6 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; import type { TSEnumMember } from '../../element/TSEnumMember/spec'; import type { Identifier } from '../../expression/Identifier/spec'; -import type { Modifier } from '../../unions/Modifier'; export interface TSEnumDeclaration extends BaseNode { type: AST_NODE_TYPES.TSEnumDeclaration; @@ -30,6 +29,4 @@ export interface TSEnumDeclaration extends BaseNode { * The enum members. */ members: TSEnumMember[]; - // TODO(#4759) - breaking change remove this - modifiers?: Modifier[]; } diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts index a75c769daf9..18ad9a74155 100644 --- a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts @@ -7,8 +7,6 @@ import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDe export interface TSInterfaceDeclaration extends BaseNode { type: AST_NODE_TYPES.TSInterfaceDeclaration; - // TODO(#4759) - breaking change remove this - abstract?: boolean; /** * The body of the interface */ @@ -26,8 +24,6 @@ export interface TSInterfaceDeclaration extends BaseNode { * The name of this interface */ id: Identifier; - // TODO(#4759) - breaking change remove this - implements?: TSInterfaceHeritage[]; /** * The generic type parameters declared for the interface. * This is `undefined` if there are no generic type parameters declared. diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts index e077d1648e1..79166ff38f9 100644 --- a/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts @@ -3,7 +3,6 @@ import type { BaseNode } from '../../base/BaseNode'; import type { Identifier } from '../../expression/Identifier/spec'; import type { TSModuleBlock } from '../../special/TSModuleBlock/spec'; import type { Literal } from '../../unions/Literal'; -import type { Modifier } from '../../unions/Modifier'; export interface TSModuleDeclaration extends BaseNode { type: AST_NODE_TYPES.TSModuleDeclaration; @@ -49,6 +48,4 @@ export interface TSModuleDeclaration extends BaseNode { */ // TODO(#5020) - make this `false` if it is not `declare`d declare?: boolean; - // TODO(#4759) - breaking change remove this - modifiers?: Modifier[]; } diff --git a/packages/ast-spec/src/index.ts b/packages/ast-spec/src/index.ts index ba9ee680000..3994016c2e0 100644 --- a/packages/ast-spec/src/index.ts +++ b/packages/ast-spec/src/index.ts @@ -26,7 +26,6 @@ export * from './unions/JSXTagNameExpression'; export * from './unions/LeftHandSideExpression'; export * from './unions/Literal'; export * from './unions/LiteralExpression'; -export * from './unions/Modifier'; export * from './unions/Node'; export * from './unions/ObjectLiteralElement'; export * from './unions/Parameter'; diff --git a/packages/ast-spec/src/unions/Modifier.ts b/packages/ast-spec/src/unions/Modifier.ts deleted file mode 100644 index f2501e6585c..00000000000 --- a/packages/ast-spec/src/unions/Modifier.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { TSAbstractKeyword } from '../type/TSAbstractKeyword/spec'; -import type { TSAsyncKeyword } from '../type/TSAsyncKeyword/spec'; -import type { TSPrivateKeyword } from '../type/TSPrivateKeyword/spec'; -import type { TSProtectedKeyword } from '../type/TSProtectedKeyword/spec'; -import type { TSPublicKeyword } from '../type/TSPublicKeyword/spec'; -import type { TSReadonlyKeyword } from '../type/TSReadonlyKeyword/spec'; -import type { TSStaticKeyword } from '../type/TSStaticKeyword/spec'; - -export type Modifier = - | TSAbstractKeyword - | TSAsyncKeyword - | TSPrivateKeyword - | TSProtectedKeyword - | TSPublicKeyword - | TSReadonlyKeyword - | TSStaticKeyword; diff --git a/packages/scope-manager/src/referencer/TypeVisitor.ts b/packages/scope-manager/src/referencer/TypeVisitor.ts index 367fe3d3f23..899297ee12c 100644 --- a/packages/scope-manager/src/referencer/TypeVisitor.ts +++ b/packages/scope-manager/src/referencer/TypeVisitor.ts @@ -187,7 +187,6 @@ class TypeVisitor extends Visitor { } node.extends?.forEach(this.visit, this); - node.implements?.forEach(this.visit, this); this.visit(node.body); if (node.typeParameters) { diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 015e1bbc636..b2d5a671986 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -696,62 +696,6 @@ export class Converter { : node.elements.map(element => this.convertChild(element)); } - /** - * Applies the given TS modifiers to the given result object. - * - * This method adds not standardized `modifiers` property in nodes - * - * @param result - * @param modifiers original ts.Nodes from the node.modifiers array - * @returns the current result object will be mutated - */ - private applyModifiersToResult( - result: TSESTree.TSEnumDeclaration | TSESTree.TSModuleDeclaration, - modifiers: Iterable | undefined, - ): void { - if (!modifiers) { - return; - } - - const remainingModifiers: TSESTree.Modifier[] = []; - /** - * Some modifiers are explicitly handled by applying them as - * boolean values on the result node. As well as adding them - * to the result, we remove them from the array, so that they - * are not handled twice. - */ - for (const modifier of modifiers) { - switch (modifier.kind) { - /** - * Ignore ExportKeyword and DefaultKeyword, they are handled - * via the fixExports utility function - */ - case SyntaxKind.ExportKeyword: - case SyntaxKind.DefaultKeyword: - break; - case SyntaxKind.ConstKeyword: - (result as any).const = true; - break; - case SyntaxKind.DeclareKeyword: - result.declare = true; - break; - default: - remainingModifiers.push( - this.convertChild(modifier) as TSESTree.Modifier, - ); - break; - } - } - /** - * If there are still valid modifiers available which have - * not been explicitly handled above, we just convert and - * add the modifiers array to the result node. - */ - if (remainingModifiers.length > 0) { - result.modifiers = remainingModifiers; - } - } - /** * Uses the provided range location to adjust the location data of the given Node * @param result The node that will have its location data mutated @@ -2674,7 +2618,6 @@ export class Converter { if (interfaceHeritageClauses.length > 0) { const interfaceExtends: TSESTree.TSInterfaceHeritage[] = []; - const interfaceImplements: TSESTree.TSInterfaceHeritage[] = []; for (const heritageClause of interfaceHeritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { @@ -2683,27 +2626,14 @@ export class Converter { this.convertChild(n, node) as TSESTree.TSInterfaceHeritage, ); } - } else { - for (const n of heritageClause.types) { - interfaceImplements.push( - this.convertChild(n, node) as TSESTree.TSInterfaceHeritage, - ); - } } } - if (interfaceExtends.length) { + if (interfaceExtends.length > 0) { result.extends = interfaceExtends; } - - if (interfaceImplements.length) { - result.implements = interfaceImplements; - } } - if (hasModifier(SyntaxKind.AbstractKeyword, node)) { - result.abstract = true; - } if (hasModifier(SyntaxKind.DeclareKeyword, node)) { result.declare = true; } @@ -2764,7 +2694,14 @@ export class Converter { members: node.members.map(el => this.convertChild(el)), }); // apply modifiers first... - this.applyModifiersToResult(result, getModifiers(node)); + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { + result.declare = true; + } + + if (hasModifier(SyntaxKind.ConstKeyword, node)) { + result.const = true; + } + // ...then check for exports return this.fixExports(node, result); } @@ -2792,7 +2729,9 @@ export class Converter { result.body = this.convertChild(node.body); } // apply modifiers first... - this.applyModifiersToResult(result, getModifiers(node)); + if (hasModifier(SyntaxKind.DeclareKeyword, node)) { + result.declare = true; + } if (node.flags & ts.NodeFlags.GlobalAugmentation) { result.global = true; } diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-interface.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-interface.src.ts.shot index 5d96c992f86..bc674bcb4d1 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-interface.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-interface.src.ts.shot @@ -6,7 +6,6 @@ Object { Object { "assertions": Array [], "declaration": Object { - "abstract": true, "body": Object { "body": Array [], "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot index f21c928657d..5bb1a9402e3 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/enum-with-keywords.src.ts.shot @@ -35,127 +35,6 @@ Object { }, }, "members": Array [], - "modifiers": Array [ - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 14, - ], - "type": "TSPrivateKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "range": Array [ - 15, - 21, - ], - "type": "TSPublicKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "range": Array [ - 22, - 31, - ], - "type": "TSProtectedKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 32, - "line": 1, - }, - }, - "range": Array [ - 32, - 38, - ], - "type": "TSStaticKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 39, - "line": 1, - }, - }, - "range": Array [ - 39, - 47, - ], - "type": "TSReadonlyKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 56, - "line": 1, - }, - "start": Object { - "column": 48, - "line": 1, - }, - }, - "range": Array [ - 48, - 56, - ], - "type": "TSAbstractKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 62, - "line": 1, - }, - "start": Object { - "column": 57, - "line": 1, - }, - }, - "range": Array [ - 57, - 62, - ], - "type": "TSAsyncKeyword", - }, - ], "range": Array [ 7, 72, diff --git a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-implements.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-implements.src.ts.shot index 748c52a5a1f..65868666d64 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-implements.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/errorRecovery/interface-implements.src.ts.shot @@ -40,43 +40,6 @@ Object { ], "type": "Identifier", }, - "implements": Array [ - Object { - "expression": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "name": "e", - "range": Array [ - 23, - 24, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 24, - ], - "type": "TSInterfaceHeritage", - }, - ], "loc": Object { "end": Object { "column": 27, From b82df5eaed437727566cde2b53410001505f1b13 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 26 Oct 2022 10:20:33 -0400 Subject: [PATCH 64/76] fix(eslint-plugin): remove valid-typeof disable in eslint-recommended (#5381) --- packages/eslint-plugin/src/configs/eslint-recommended.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-plugin/src/configs/eslint-recommended.ts b/packages/eslint-plugin/src/configs/eslint-recommended.ts index 71443e1f52e..4753d3fc729 100644 --- a/packages/eslint-plugin/src/configs/eslint-recommended.ts +++ b/packages/eslint-plugin/src/configs/eslint-recommended.ts @@ -28,7 +28,6 @@ export = { 'prefer-const': 'error', // ts provides better types with const 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply - 'valid-typeof': 'off', // ts(2367) }, }, ], From df541751c6510f5d15d863f515cff3748fd9e688 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 26 Oct 2022 10:43:12 -0400 Subject: [PATCH 65/76] feat(utils): remove (ts-)eslint-scope types (#5256) * chore(utils)\!: remove (ts-)eslint-scope types * Remove eslint-scope dep * More file deletions --- packages/utils/src/index.ts | 3 +- .../utils/src/ts-eslint-scope/Definition.ts | 41 ---- packages/utils/src/ts-eslint-scope/Options.ts | 21 -- .../src/ts-eslint-scope/PatternVisitor.ts | 39 ---- packages/utils/src/ts-eslint-scope/README.md | 3 - .../utils/src/ts-eslint-scope/Reference.ts | 43 ---- .../utils/src/ts-eslint-scope/Referencer.ts | 82 -------- packages/utils/src/ts-eslint-scope/Scope.ts | 197 ------------------ .../utils/src/ts-eslint-scope/ScopeManager.ts | 62 ------ .../utils/src/ts-eslint-scope/Variable.ts | 23 -- packages/utils/src/ts-eslint-scope/analyze.ts | 22 -- packages/utils/src/ts-eslint-scope/index.ts | 13 -- yarn.lock | 2 +- 13 files changed, 2 insertions(+), 549 deletions(-) delete mode 100644 packages/utils/src/ts-eslint-scope/Definition.ts delete mode 100644 packages/utils/src/ts-eslint-scope/Options.ts delete mode 100644 packages/utils/src/ts-eslint-scope/PatternVisitor.ts delete mode 100644 packages/utils/src/ts-eslint-scope/README.md delete mode 100644 packages/utils/src/ts-eslint-scope/Reference.ts delete mode 100644 packages/utils/src/ts-eslint-scope/Referencer.ts delete mode 100644 packages/utils/src/ts-eslint-scope/Scope.ts delete mode 100644 packages/utils/src/ts-eslint-scope/ScopeManager.ts delete mode 100644 packages/utils/src/ts-eslint-scope/Variable.ts delete mode 100644 packages/utils/src/ts-eslint-scope/analyze.ts delete mode 100644 packages/utils/src/ts-eslint-scope/index.ts diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 31328386269..c2c366379a0 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -2,7 +2,6 @@ import * as ASTUtils from './ast-utils'; import * as ESLintUtils from './eslint-utils'; import * as JSONSchema from './json-schema'; import * as TSESLint from './ts-eslint'; -import * as TSESLintScope from './ts-eslint-scope'; -export { ASTUtils, ESLintUtils, JSONSchema, TSESLint, TSESLintScope }; +export { ASTUtils, ESLintUtils, JSONSchema, TSESLint }; export * from './ts-estree'; diff --git a/packages/utils/src/ts-eslint-scope/Definition.ts b/packages/utils/src/ts-eslint-scope/Definition.ts deleted file mode 100644 index 3e35ecc9fc2..00000000000 --- a/packages/utils/src/ts-eslint-scope/Definition.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { - Definition as ESLintDefinition, - ParameterDefinition as ESLintParameterDefinition, -} from 'eslint-scope/lib/definition'; - -import type { TSESTree } from '../ts-estree'; - -interface Definition { - type: string; - name: TSESTree.BindingName; - node: TSESTree.Node; - parent?: TSESTree.Node | null; - index?: number | null; - kind?: string | null; - rest?: boolean; -} -interface DefinitionConstructor { - new ( - type: string, - name: TSESTree.BindingName | TSESTree.PropertyName, - node: TSESTree.Node, - parent?: TSESTree.Node | null, - index?: number | null, - kind?: string | null, - ): Definition; -} -const Definition = ESLintDefinition as DefinitionConstructor; - -// eslint-disable-next-line @typescript-eslint/no-empty-interface -interface ParameterDefinition extends Definition {} -const ParameterDefinition = - ESLintParameterDefinition as DefinitionConstructor & { - new ( - name: TSESTree.Node, - node: TSESTree.Node, - index?: number | null, - rest?: boolean, - ): ParameterDefinition; - }; - -export { Definition, ParameterDefinition }; diff --git a/packages/utils/src/ts-eslint-scope/Options.ts b/packages/utils/src/ts-eslint-scope/Options.ts deleted file mode 100644 index 0b1600ae1cb..00000000000 --- a/packages/utils/src/ts-eslint-scope/Options.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { TSESTree } from '../ts-estree'; - -type PatternVisitorCallback = ( - pattern: TSESTree.Identifier, - info: { - rest: boolean; - topLevel: boolean; - assignments: TSESTree.AssignmentPattern[]; - }, -) => void; - -interface PatternVisitorOptions { - processRightHandNodes?: boolean; -} - -interface Visitor { - visitChildren(node?: T): void; - visit(node?: T): void; -} - -export { PatternVisitorCallback, PatternVisitorOptions, Visitor }; diff --git a/packages/utils/src/ts-eslint-scope/PatternVisitor.ts b/packages/utils/src/ts-eslint-scope/PatternVisitor.ts deleted file mode 100644 index 75840211e28..00000000000 --- a/packages/utils/src/ts-eslint-scope/PatternVisitor.ts +++ /dev/null @@ -1,39 +0,0 @@ -import ESLintPatternVisitor from 'eslint-scope/lib/pattern-visitor'; - -import type { TSESTree } from '../ts-estree'; -import type { - PatternVisitorCallback, - PatternVisitorOptions, - Visitor, -} from './Options'; -import type { ScopeManager } from './ScopeManager'; - -interface PatternVisitor extends Visitor { - options: PatternVisitorOptions; - scopeManager: ScopeManager; - parent?: TSESTree.Node; - rightHandNodes: TSESTree.Node[]; - - Identifier(pattern: TSESTree.Node): void; - Property(property: TSESTree.Node): void; - ArrayPattern(pattern: TSESTree.Node): void; - AssignmentPattern(pattern: TSESTree.Node): void; - RestElement(pattern: TSESTree.Node): void; - MemberExpression(node: TSESTree.Node): void; - SpreadElement(node: TSESTree.Node): void; - ArrayExpression(node: TSESTree.Node): void; - AssignmentExpression(node: TSESTree.Node): void; - CallExpression(node: TSESTree.Node): void; -} -const PatternVisitor = ESLintPatternVisitor as { - new ( - options: PatternVisitorOptions, - rootPattern: TSESTree.BaseNode, - callback: PatternVisitorCallback, - ): PatternVisitor; - - // static methods - isPattern(node: TSESTree.Node): boolean; -}; - -export { PatternVisitor }; diff --git a/packages/utils/src/ts-eslint-scope/README.md b/packages/utils/src/ts-eslint-scope/README.md deleted file mode 100644 index 6cabba14fbf..00000000000 --- a/packages/utils/src/ts-eslint-scope/README.md +++ /dev/null @@ -1,3 +0,0 @@ -These will need to be removed in the next major as `eslint-scope` v6+ no longer export their internals. - -Issue: https://github.com/typescript-eslint/typescript-eslint/issues/4041 diff --git a/packages/utils/src/ts-eslint-scope/Reference.ts b/packages/utils/src/ts-eslint-scope/Reference.ts deleted file mode 100644 index d2dd6554977..00000000000 --- a/packages/utils/src/ts-eslint-scope/Reference.ts +++ /dev/null @@ -1,43 +0,0 @@ -import ESLintReference from 'eslint-scope/lib/reference'; - -import type { TSESTree } from '../ts-estree'; -import type { Scope } from './Scope'; -import type { Variable } from './Variable'; - -export type ReferenceFlag = 0x1 | 0x2 | 0x3; - -interface Reference { - identifier: TSESTree.Identifier; - from: Scope; - resolved: Variable | null; - writeExpr: TSESTree.Node | null; - init: boolean; - - partial: boolean; - __maybeImplicitGlobal: boolean; - tainted?: boolean; - typeMode?: boolean; - - isWrite(): boolean; - isRead(): boolean; - isWriteOnly(): boolean; - isReadOnly(): boolean; - isReadWrite(): boolean; -} -const Reference = ESLintReference as { - new ( - identifier: TSESTree.Identifier, - scope: Scope, - flag?: ReferenceFlag, - writeExpr?: TSESTree.Node | null, - maybeImplicitGlobal?: boolean, - partial?: boolean, - init?: boolean, - ): Reference; - - READ: 0x1; - WRITE: 0x2; - RW: 0x3; -}; - -export { Reference }; diff --git a/packages/utils/src/ts-eslint-scope/Referencer.ts b/packages/utils/src/ts-eslint-scope/Referencer.ts deleted file mode 100644 index 3bd6b27b20d..00000000000 --- a/packages/utils/src/ts-eslint-scope/Referencer.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import ESLintReferencer from 'eslint-scope/lib/referencer'; - -import type { TSESTree } from '../ts-estree'; -import type { - PatternVisitorCallback, - PatternVisitorOptions, - Visitor, -} from './Options'; -import type { Scope } from './Scope'; -import type { ScopeManager } from './ScopeManager'; - -interface Referencer extends Visitor { - isInnerMethodDefinition: boolean; - options: any; - scopeManager: SM; - parent?: TSESTree.Node; - - currentScope(): Scope; - close(node: TSESTree.Node): void; - pushInnerMethodDefinition(isInnerMethodDefinition: boolean): boolean; - popInnerMethodDefinition(isInnerMethodDefinition: boolean): void; - - referencingDefaultValue( - pattern: any, - assignments: any, - maybeImplicitGlobal: any, - init: boolean, - ): void; - visitPattern( - node: TSESTree.Node, - options: PatternVisitorOptions, - callback: PatternVisitorCallback, - ): void; - visitFunction(node: TSESTree.Node): void; - visitClass(node: TSESTree.Node): void; - visitProperty(node: TSESTree.Node): void; - visitForIn(node: TSESTree.Node): void; - visitVariableDeclaration( - variableTargetScope: any, - type: any, - node: TSESTree.Node, - index: any, - ): void; - - AssignmentExpression(node: TSESTree.Node): void; - CatchClause(node: TSESTree.Node): void; - Program(node: TSESTree.Program): void; - Identifier(node: TSESTree.Identifier): void; - UpdateExpression(node: TSESTree.Node): void; - MemberExpression(node: TSESTree.Node): void; - Property(node: TSESTree.Node): void; - MethodDefinition(node: TSESTree.Node): void; - BreakStatement(): void; - ContinueStatement(): void; - LabeledStatement(node: TSESTree.Node): void; - ForStatement(node: TSESTree.Node): void; - ClassExpression(node: TSESTree.Node): void; - ClassDeclaration(node: TSESTree.Node): void; - CallExpression(node: TSESTree.Node): void; - BlockStatement(node: TSESTree.Node): void; - ThisExpression(): void; - WithStatement(node: TSESTree.Node): void; - VariableDeclaration(node: TSESTree.Node): void; - SwitchStatement(node: TSESTree.Node): void; - FunctionDeclaration(node: TSESTree.Node): void; - FunctionExpression(node: TSESTree.Node): void; - ForOfStatement(node: TSESTree.Node): void; - ForInStatement(node: TSESTree.Node): void; - ArrowFunctionExpression(node: TSESTree.Node): void; - ImportDeclaration(node: TSESTree.Node): void; - visitExportDeclaration(node: TSESTree.Node): void; - ExportDeclaration(node: TSESTree.Node): void; - ExportNamedDeclaration(node: TSESTree.Node): void; - ExportSpecifier(node: TSESTree.Node): void; - MetaProperty(): void; -} -const Referencer = ESLintReferencer as { - new (options: any, scopeManager: SM): Referencer; -}; - -export { Referencer }; diff --git a/packages/utils/src/ts-eslint-scope/Scope.ts b/packages/utils/src/ts-eslint-scope/Scope.ts deleted file mode 100644 index e0f3320043a..00000000000 --- a/packages/utils/src/ts-eslint-scope/Scope.ts +++ /dev/null @@ -1,197 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-interface, @typescript-eslint/no-explicit-any */ - -import { - BlockScope as ESLintBlockScope, - CatchScope as ESLintCatchScope, - ClassScope as ESLintClassScope, - ForScope as ESLintForScope, - FunctionExpressionNameScope as ESLintFunctionExpressionNameScope, - FunctionScope as ESLintFunctionScope, - GlobalScope as ESLintGlobalScope, - ModuleScope as ESLintModuleScope, - Scope as ESLintScope, - SwitchScope as ESLintSwitchScope, - WithScope as ESLintWithScope, -} from 'eslint-scope/lib/scope'; - -import type { TSESTree } from '../ts-estree'; -import type { Definition } from './Definition'; -import type { Reference, ReferenceFlag } from './Reference'; -import type { ScopeManager } from './ScopeManager'; -import type { Variable } from './Variable'; - -type ScopeType = - | 'block' - | 'catch' - | 'class' - | 'for' - | 'function' - | 'function-expression-name' - | 'global' - | 'module' - | 'switch' - | 'with' - | 'TDZ' - | 'enum' - | 'empty-function'; - -interface Scope { - type: ScopeType; - isStrict: boolean; - upper: Scope | null; - childScopes: Scope[]; - variableScope: Scope; - block: TSESTree.Node; - variables: Variable[]; - set: Map; - references: Reference[]; - through: Reference[]; - thisFound?: boolean; - taints: Map; - functionExpressionScope: boolean; - __left: Reference[]; - - __shouldStaticallyClose(scopeManager: ScopeManager): boolean; - __shouldStaticallyCloseForGlobal(ref: any): boolean; - __staticCloseRef(ref: any): void; - __dynamicCloseRef(ref: any): void; - __globalCloseRef(ref: any): void; - __close(scopeManager: ScopeManager): Scope; - __isValidResolution(ref: any, variable: any): variable is Variable; - __resolve(ref: Reference): boolean; - __delegateToUpperScope(ref: any): void; - __addDeclaredVariablesOfNode(variable: any, node: TSESTree.Node): void; - __defineGeneric( - name: string, - set: Map, - variables: Variable[], - node: TSESTree.Identifier, - def: Definition, - ): void; - - __define(node: TSESTree.Node, def: Definition): void; - - __referencing( - node: TSESTree.Node, - assign?: ReferenceFlag, - writeExpr?: TSESTree.Node, - maybeImplicitGlobal?: any, - partial?: any, - init?: any, - ): void; - - __detectEval(): void; - __detectThis(): void; - __isClosed(): boolean; - /** - * returns resolved {Reference} - * @method Scope#resolve - * @param {Espree.Identifier} ident - identifier to be resolved. - * @returns {Reference} reference - */ - resolve(ident: TSESTree.Node): Reference; - - /** - * returns this scope is static - * @method Scope#isStatic - * @returns {boolean} static - */ - isStatic(): boolean; - - /** - * returns this scope has materialized arguments - * @method Scope#isArgumentsMaterialized - * @returns {boolean} arguments materialized - */ - isArgumentsMaterialized(): boolean; - - /** - * returns this scope has materialized `this` reference - * @method Scope#isThisMaterialized - * @returns {boolean} this materialized - */ - isThisMaterialized(): boolean; - - isUsedName(name: any): boolean; -} -interface ScopeConstructor { - new ( - scopeManager: ScopeManager, - type: ScopeType, - upperScope: Scope | null, - block: TSESTree.Node | null, - isMethodDefinition: boolean, - ): Scope; -} -const Scope = ESLintScope as ScopeConstructor; - -interface ScopeChildConstructorWithUpperScope { - new ( - scopeManager: ScopeManager, - upperScope: Scope, - block: TSESTree.Node | null, - ): T; -} - -interface GlobalScope extends Scope {} -const GlobalScope = ESLintGlobalScope as ScopeConstructor & { - new (scopeManager: ScopeManager, block: TSESTree.Node | null): GlobalScope; -}; - -interface ModuleScope extends Scope {} -const ModuleScope = ESLintModuleScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface FunctionExpressionNameScope extends Scope {} -const FunctionExpressionNameScope = - ESLintFunctionExpressionNameScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface CatchScope extends Scope {} -const CatchScope = ESLintCatchScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface WithScope extends Scope {} -const WithScope = ESLintWithScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface BlockScope extends Scope {} -const BlockScope = ESLintBlockScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface SwitchScope extends Scope {} -const SwitchScope = ESLintSwitchScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface FunctionScope extends Scope {} -const FunctionScope = ESLintFunctionScope as ScopeConstructor & { - new ( - scopeManager: ScopeManager, - upperScope: Scope, - block: TSESTree.Node | null, - isMethodDefinition: boolean, - ): FunctionScope; -}; - -interface ForScope extends Scope {} -const ForScope = ESLintForScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -interface ClassScope extends Scope {} -const ClassScope = ESLintClassScope as ScopeConstructor & - ScopeChildConstructorWithUpperScope; - -export { - ScopeType, - Scope, - GlobalScope, - ModuleScope, - FunctionExpressionNameScope, - CatchScope, - WithScope, - BlockScope, - SwitchScope, - FunctionScope, - ForScope, - ClassScope, -}; diff --git a/packages/utils/src/ts-eslint-scope/ScopeManager.ts b/packages/utils/src/ts-eslint-scope/ScopeManager.ts deleted file mode 100644 index c7bbb2425c9..00000000000 --- a/packages/utils/src/ts-eslint-scope/ScopeManager.ts +++ /dev/null @@ -1,62 +0,0 @@ -import ESLintScopeManager from 'eslint-scope/lib/scope-manager'; - -import type { EcmaVersion } from '../ts-eslint'; -import type { TSESTree } from '../ts-estree'; -import type { Scope } from './Scope'; -import type { Variable } from './Variable'; - -interface ScopeManagerOptions { - directive?: boolean; - optimistic?: boolean; - ignoreEval?: boolean; - nodejsScope?: boolean; - sourceType?: 'module' | 'script'; - impliedStrict?: boolean; - ecmaVersion?: EcmaVersion; -} - -interface ScopeManager { - __options: ScopeManagerOptions; - __currentScope: Scope; - __nodeToScope: WeakMap; - __declaredVariables: WeakMap; - - scopes: Scope[]; - globalScope: Scope; - - __useDirective(): boolean; - __isOptimistic(): boolean; - __ignoreEval(): boolean; - __isNodejsScope(): boolean; - isModule(): boolean; - isImpliedStrict(): boolean; - isStrictModeSupported(): boolean; - - // Returns appropriate scope for this node. - __get(node: TSESTree.Node): Scope | undefined; - getDeclaredVariables(node: TSESTree.Node): Variable[]; - acquire(node: TSESTree.Node, inner?: boolean): Scope | null; - acquireAll(node: TSESTree.Node): Scope | null; - release(node: TSESTree.Node, inner?: boolean): Scope | null; - attach(): void; - detach(): void; - - __nestScope(scope: T): T; - __nestGlobalScope(node: TSESTree.Node): Scope; - __nestBlockScope(node: TSESTree.Node): Scope; - __nestFunctionScope(node: TSESTree.Node, isMethodDefinition: boolean): Scope; - __nestForScope(node: TSESTree.Node): Scope; - __nestCatchScope(node: TSESTree.Node): Scope; - __nestWithScope(node: TSESTree.Node): Scope; - __nestClassScope(node: TSESTree.Node): Scope; - __nestSwitchScope(node: TSESTree.Node): Scope; - __nestModuleScope(node: TSESTree.Node): Scope; - __nestFunctionExpressionNameScope(node: TSESTree.Node): Scope; - - __isES6(): boolean; -} -const ScopeManager = ESLintScopeManager as { - new (options: ScopeManagerOptions): ScopeManager; -}; - -export { ScopeManager, ScopeManagerOptions }; diff --git a/packages/utils/src/ts-eslint-scope/Variable.ts b/packages/utils/src/ts-eslint-scope/Variable.ts deleted file mode 100644 index 192c9f89550..00000000000 --- a/packages/utils/src/ts-eslint-scope/Variable.ts +++ /dev/null @@ -1,23 +0,0 @@ -import ESLintVariable from 'eslint-scope/lib/variable'; - -import type { TSESTree } from '../ts-estree'; -import type { Definition } from './Definition'; -import type { Reference } from './Reference'; -import type { Scope } from './Scope'; - -interface Variable { - name: string; - identifiers: TSESTree.Identifier[]; - references: Reference[]; - defs: Definition[]; - eslintUsed?: boolean; - stack?: unknown; - tainted?: boolean; - scope?: Scope; -} - -const Variable = ESLintVariable as { - new (): Variable; -}; - -export { Variable }; diff --git a/packages/utils/src/ts-eslint-scope/analyze.ts b/packages/utils/src/ts-eslint-scope/analyze.ts deleted file mode 100644 index 1543f93fa1a..00000000000 --- a/packages/utils/src/ts-eslint-scope/analyze.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { analyze as ESLintAnalyze } from 'eslint-scope'; - -import type { EcmaVersion } from '../ts-eslint'; -import type { TSESTree } from '../ts-estree'; -import type { ScopeManager } from './ScopeManager'; - -interface AnalysisOptions { - optimistic?: boolean; - directive?: boolean; - ignoreEval?: boolean; - nodejsScope?: boolean; - impliedStrict?: boolean; - fallback?: string | ((node: TSESTree.Node) => string[]); - sourceType?: 'script' | 'module'; - ecmaVersion?: EcmaVersion; -} -const analyze = ESLintAnalyze as ( - ast: TSESTree.Node, - options?: AnalysisOptions, -) => ScopeManager; - -export { analyze, AnalysisOptions }; diff --git a/packages/utils/src/ts-eslint-scope/index.ts b/packages/utils/src/ts-eslint-scope/index.ts deleted file mode 100644 index 870c34fce1b..00000000000 --- a/packages/utils/src/ts-eslint-scope/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { version as ESLintVersion } from 'eslint-scope'; - -export * from './analyze'; -export * from './Definition'; -export * from './Options'; -export * from './PatternVisitor'; -export * from './Reference'; -export * from './Referencer'; -export * from './Scope'; -export * from './ScopeManager'; -export * from './Variable'; - -export const version: string = ESLintVersion; diff --git a/yarn.lock b/yarn.lock index f771e6ece9f..7cafafcd627 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6969,7 +6969,7 @@ eslint-plugin-simple-import-sort@^8.0.0: resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-8.0.0.tgz#9d9a2372b0606e999ea841b10458a370a6ccc160" integrity sha512-bXgJQ+lqhtQBCuWY/FUWdB27j4+lqcvXv5rUARkzbeWLwea+S5eBZEQrhnO+WgX3ZoJHVj0cn943iyXwByHHQw== -eslint-scope@5.1.1, eslint-scope@^5.1.1: +eslint-scope@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== From 6d32734b1312f60ee7d12d4bb19fc1cf52e7f0a5 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 26 Oct 2022 11:15:24 -0400 Subject: [PATCH 66/76] fix(eslint-plugin): [explicit-module-boundary-types] remove shouldTrackReferences option from schema (#5399) --- .../src/rules/explicit-module-boundary-types.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index e7552e0cbd8..b891cbec6cb 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -22,7 +22,6 @@ type Options = [ allowedNames?: string[]; allowHigherOrderFunctions?: boolean; allowTypedFunctionExpressions?: boolean; - shouldTrackReferences?: boolean; }, ]; type MessageIds = @@ -85,10 +84,6 @@ export default util.createRule({ 'Whether to ignore type annotations on the variable of a function expresion.', type: 'boolean', }, - // DEPRECATED - To be removed in next major - shouldTrackReferences: { - type: 'boolean', - }, }, additionalProperties: false, }, From 426d6b647e6df3e312d1cef3e28dadaef6675fd3 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 27 Oct 2022 00:59:29 -0400 Subject: [PATCH 67/76] feat(typescript-estree): deprecate createDefaultProgram (#5890) * chore(typescript-estree): deprecate createDefaultProgram * Apply suggestions from code review Co-authored-by: Brad Zacher * More updates to comments and name * One more comment line removal * Fix lint complaints Co-authored-by: Brad Zacher --- packages/parser/README.md | 10 ++-------- packages/typescript-estree/README.md | 11 +++-------- .../src/create-program/createDefaultProgram.ts | 4 ++++ .../src/create-program/createProjectProgram.ts | 3 ++- .../src/parseSettings/createParseSettings.ts | 4 +++- packages/typescript-estree/src/parseSettings/index.ts | 6 ++++-- packages/typescript-estree/src/parser-options.ts | 11 +++-------- packages/typescript-estree/src/parser.ts | 4 +++- packages/typescript-estree/tests/lib/parse.test.ts | 10 +++++----- .../typescript-estree/tests/lib/semanticInfo.test.ts | 2 +- packages/website/src/components/linter/config.ts | 2 +- 11 files changed, 31 insertions(+), 36 deletions(-) diff --git a/packages/parser/README.md b/packages/parser/README.md index b32ed30beab..703749c998b 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -168,7 +168,7 @@ This option allows you to provide a path to your project's `tsconfig.json`. **Th - TypeScript will ignore files with duplicate filenames in the same folder (for example, `src/file.ts` and `src/file.js`). TypeScript purposely ignore all but one of the files, only keeping the one file with the highest priority extension (the extension priority order (from highest to lowest) is `.ts`, `.tsx`, `.d.ts`, `.js`, `.jsx`). For more info see #955. -- Note that if this setting is specified and `createDefaultProgram` is not, you must only lint files that are included in the projects as defined by the provided `tsconfig.json` files. If your existing configuration does not include all of the files you would like to lint, you can create a separate `tsconfig.eslint.json` as follows: +- Note that if this setting is specified, you must only lint files that are included in the projects as defined by the provided `tsconfig.json` files. If your existing configuration does not include all of the files you would like to lint, you can create a separate `tsconfig.eslint.json` as follows: ```jsonc { @@ -217,18 +217,12 @@ Default `true`. This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported -### `parserOptions.createDefaultProgram` - -Default `false`. - -This option allows you to request that when the `project` setting is specified, files will be allowed when not included in the projects defined by the provided `tsconfig.json` files. **Using this option will incur significant performance costs. This option is primarily included for backwards-compatibility.** See the **`project`** section above for more information. - ### `parserOptions.programs` Default `undefined`. This option allows you to programmatically provide an array of one or more instances of a TypeScript Program object that will provide type information to rules. -This will override any programs that would have been computed from `parserOptions.project` or `parserOptions.createDefaultProgram`. +This will override any programs that would have been computed from `parserOptions.project`. All linted files must be part of the provided program(s). ### `parserOptions.moduleResolver` diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index cb1d0d0312c..f2da0d9cdf1 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -207,15 +207,10 @@ interface ParseAndGenerateServicesOptions extends ParseOptions { programs?: Program[]; /** - *************************************************************************************** - * IT IS RECOMMENDED THAT YOU DO NOT USE THIS OPTION, AS IT CAUSES PERFORMANCE ISSUES. * - *************************************************************************************** - * - * When passed with `project`, this allows the parser to create a catch-all, default program. - * This means that if the parser encounters a file not included in any of the provided `project`s, - * it will not error, but will instead parse the file and its dependencies in a new program. + * @deprecated - this flag will be removed in the next major. + * Do not rely on the behavior provided by this flag. */ - createDefaultProgram?: boolean; + DEPRECATED__createDefaultProgram?: boolean; /** * ESLint (and therefore typescript-eslint) is used in both "single run"/one-time contexts, diff --git a/packages/typescript-estree/src/create-program/createDefaultProgram.ts b/packages/typescript-estree/src/create-program/createDefaultProgram.ts index a2de81399d2..bfcc3066b17 100644 --- a/packages/typescript-estree/src/create-program/createDefaultProgram.ts +++ b/packages/typescript-estree/src/create-program/createDefaultProgram.ts @@ -14,6 +14,9 @@ const log = debug('typescript-eslint:typescript-estree:createDefaultProgram'); /** * @param parseSettings Internal settings for parsing the file * @returns If found, returns the source file corresponding to the code and the containing program + * @deprecated + * This is a legacy option that comes with severe performance penalties. + * Please do not use it. */ function createDefaultProgram( parseSettings: ParseSettings, @@ -66,4 +69,5 @@ function createDefaultProgram( return ast && { ast, program }; } +// eslint-disable-next-line deprecation/deprecation -- will be cleaned up with the next major export { createDefaultProgram }; diff --git a/packages/typescript-estree/src/create-program/createProjectProgram.ts b/packages/typescript-estree/src/create-program/createProjectProgram.ts index 326100d3578..315e3b05c2f 100644 --- a/packages/typescript-estree/src/create-program/createProjectProgram.ts +++ b/packages/typescript-estree/src/create-program/createProjectProgram.ts @@ -36,7 +36,8 @@ function createProjectProgram( ); // The file was either matched within the tsconfig, or we allow creating a default program - if (astAndProgram || parseSettings.createDefaultProgram) { + // eslint-disable-next-line deprecation/deprecation -- will be cleaned up with the next major + if (astAndProgram || parseSettings.DEPRECATED__createDefaultProgram) { return astAndProgram; } diff --git a/packages/typescript-estree/src/parseSettings/createParseSettings.ts b/packages/typescript-estree/src/parseSettings/createParseSettings.ts index b1cde9d4c9a..7a0965ae51c 100644 --- a/packages/typescript-estree/src/parseSettings/createParseSettings.ts +++ b/packages/typescript-estree/src/parseSettings/createParseSettings.ts @@ -28,7 +28,9 @@ export function createParseSettings( code: enforceString(code), comment: options.comment === true, comments: [], - createDefaultProgram: options.createDefaultProgram === true, + DEPRECATED__createDefaultProgram: + // eslint-disable-next-line deprecation/deprecation -- will be cleaned up with the next major + options.DEPRECATED__createDefaultProgram === true, debugLevel: options.debugLevel === true ? new Set(['typescript-eslint']) diff --git a/packages/typescript-estree/src/parseSettings/index.ts b/packages/typescript-estree/src/parseSettings/index.ts index 0a9734d1b24..02479d5bd2b 100644 --- a/packages/typescript-estree/src/parseSettings/index.ts +++ b/packages/typescript-estree/src/parseSettings/index.ts @@ -25,9 +25,11 @@ export interface MutableParseSettings { comments: TSESTree.Comment[]; /** - * Whether to create a TypeScript program if one is not provided. + * @deprecated + * This is a legacy option that comes with severe performance penalties. + * Please do not use it. */ - createDefaultProgram: boolean; + DEPRECATED__createDefaultProgram: boolean; /** * Which debug areas should be logged. diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts index cec95c3b413..8a4054f9237 100644 --- a/packages/typescript-estree/src/parser-options.ts +++ b/packages/typescript-estree/src/parser-options.ts @@ -144,15 +144,10 @@ interface ParseAndGenerateServicesOptions extends ParseOptions { programs?: ts.Program[]; /** - *************************************************************************************** - * IT IS RECOMMENDED THAT YOU DO NOT USE THIS OPTION, AS IT CAUSES PERFORMANCE ISSUES. * - *************************************************************************************** - * - * When passed with `project`, this allows the parser to create a catch-all, default program. - * This means that if the parser encounters a file not included in any of the provided `project`s, - * it will not error, but will instead parse the file and its dependencies in a new program. + * @deprecated - this flag will be removed in the next major. + * Do not rely on the behavior provided by this flag. */ - createDefaultProgram?: boolean; + DEPRECATED__createDefaultProgram?: boolean; /** * ESLint (and therefore typescript-eslint) is used in both "single run"/one-time contexts, diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index c5504ba961a..478cfa490c9 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -44,7 +44,9 @@ function getProgramAndAST( useProvidedPrograms(parseSettings.programs, parseSettings)) || (shouldProvideParserServices && createProjectProgram(parseSettings)) || (shouldProvideParserServices && - parseSettings.createDefaultProgram && + // eslint-disable-next-line deprecation/deprecation -- will be cleaned up with the next major + parseSettings.DEPRECATED__createDefaultProgram && + // eslint-disable-next-line deprecation/deprecation -- will be cleaned up with the next major createDefaultProgram(parseSettings)) || createIsolatedProgram(parseSettings) ); diff --git a/packages/typescript-estree/tests/lib/parse.test.ts b/packages/typescript-estree/tests/lib/parse.test.ts index dab87e38ab6..afa44a8c5f8 100644 --- a/packages/typescript-estree/tests/lib/parse.test.ts +++ b/packages/typescript-estree/tests/lib/parse.test.ts @@ -773,10 +773,10 @@ describe('parseAndGenerateServices', () => { tsconfigRootDir: PROJECT_DIR, filePath: resolve(PROJECT_DIR, 'file.ts'), }; - const withDefaultProgramConfig: TSESTreeOptions = { + const withDeprecatedDefaultProgramConfig: TSESTreeOptions = { ...config, project: './tsconfig.defaultProgram.json', - createDefaultProgram: true, + DEPRECATED__createDefaultProgram: true, }; describe('when file is in the project', () => { @@ -818,11 +818,11 @@ describe('parseAndGenerateServices', () => { }); }); - describe('when file is not in the project and createDefaultProgram=true', () => { + describe('when file is not in the project and DEPRECATED__createDefaultProgram=true', () => { it('returns error because __PLACEHOLDER__ can not be resolved', () => { expect( parser - .parseAndGenerateServices(code, withDefaultProgramConfig) + .parseAndGenerateServices(code, withDeprecatedDefaultProgramConfig) .services.program.getSemanticDiagnostics(), ).toHaveProperty( [0, 'messageText'], @@ -834,7 +834,7 @@ describe('parseAndGenerateServices', () => { expect( parser .parseAndGenerateServices(code, { - ...withDefaultProgramConfig, + ...withDeprecatedDefaultProgramConfig, moduleResolver: resolve(PROJECT_DIR, './moduleResolver.js'), }) .services.program.getSemanticDiagnostics(), diff --git a/packages/typescript-estree/tests/lib/semanticInfo.test.ts b/packages/typescript-estree/tests/lib/semanticInfo.test.ts index fae6a383662..04b0b7e6052 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.test.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.test.ts @@ -287,7 +287,7 @@ describe('semanticInfo', () => { it('default program produced with option', () => { const parseResult = parseCodeAndGenerateServices('var foo = 5;', { ...createOptions(''), - createDefaultProgram: true, + DEPRECATED__createDefaultProgram: true, }); expect(parseResult.services.program).toBeDefined(); diff --git a/packages/website/src/components/linter/config.ts b/packages/website/src/components/linter/config.ts index f077f3786ee..c3e95b321c3 100644 --- a/packages/website/src/components/linter/config.ts +++ b/packages/website/src/components/linter/config.ts @@ -4,7 +4,7 @@ export const parseSettings: ParseSettings = { code: '', comment: true, comments: [], - createDefaultProgram: false, + DEPRECATED__createDefaultProgram: false, debugLevel: new Set(), errorOnUnknownASTType: false, extraFileExtensions: [], From 7e3fe9a67abd394b0a114f2deb466edf5c9759ac Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 2 Nov 2022 06:06:03 -0700 Subject: [PATCH 68/76] feat: drop support for node v12 (#5918) BREAKING CHANGE: drops support for node v12 --- package.json | 2 +- packages/ast-spec/package.json | 2 +- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/experimental-utils/package.json | 2 +- packages/parser/package.json | 2 +- packages/scope-manager/package.json | 2 +- packages/type-utils/package.json | 2 +- packages/types/package.json | 2 +- packages/typescript-estree/package.json | 2 +- packages/utils/package.json | 2 +- packages/visitor-keys/package.json | 2 +- packages/website-eslint/package.json | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index bddf6b4fe48..d3ff24f36a6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "typecheck": "nx run-many --target=typecheck --all --parallel" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "devDependencies": { "@babel/code-frame": "^7.18.6", diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index a0c4f5d5362..ace52864124 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -9,7 +9,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index fbd344b1d47..52441d5fb50 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -11,7 +11,7 @@ "tslint" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 4e6dde4cf87..149326e397c 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -9,7 +9,7 @@ "typescript" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 890423ff65c..6a7cec4b79e 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/parser/package.json b/packages/parser/package.json index 11e72b17903..ad81f11d288 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -11,7 +11,7 @@ "LICENSE" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "repository": { "type": "git", diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index f58510fe87f..fadb71af960 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index be4ef3f95ed..ceaa9096cfb 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/types/package.json b/packages/types/package.json index 0cc513232d4..45e5dc220b2 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index b16ecb687b7..556b5005e67 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -11,7 +11,7 @@ "LICENSE" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "repository": { "type": "git", diff --git a/packages/utils/package.json b/packages/utils/package.json index 8064fe758bd..6c9d7edef5f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 39da7ca6633..eceb14ef2ed 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/website-eslint/package.json b/packages/website-eslint/package.json index 59d872c683b..62b32a56494 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -4,7 +4,7 @@ "private": true, "description": "ESLint which works in browsers.", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.17.0 || >=16.0.0" }, "types": "types/index.d.ts", "main": "dist/index.js", From a8e71d52169f32ab9e836ec96d980ba52deffe12 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sun, 6 Nov 2022 17:46:27 -0800 Subject: [PATCH 69/76] feat: bump minimum supported TS version to 4.2.4 (#5915) BREAKING CHANGE: Bumps the minimum supported range and removes handling for old versions --- README.md | 26 ++++-- package.json | 2 +- .../no-non-null-asserted-optional-chain.ts | 79 +------------------ .../rules/no-unnecessary-type-constraint.ts | 30 +------ ...o-non-null-asserted-optional-chain.test.ts | 1 - packages/typescript-estree/src/convert.ts | 13 +-- .../src/create-program/createWatchProgram.ts | 36 +-------- .../src/parseSettings/warnAboutTSVersion.ts | 2 +- .../typescript-estree/src/version-check.ts | 8 +- yarn.lock | 4 +- 10 files changed, 36 insertions(+), 165 deletions(-) diff --git a/README.md b/README.md index 93bee2f66dc..511c8dc54cf 100644 --- a/README.md +++ b/README.md @@ -51,23 +51,37 @@ The latest version under the `canary` tag **(latest commit to `main`)** is: ### Supported TypeScript Version -**The version range of TypeScript currently supported by this parser is `>=3.3.1 <5.0.0`.** +**The version range of TypeScript currently supported by this parser is `>=4.2.0 <5.0.0`.** -These versions are what we test against. +Note that we mirror [DefinitelyTyped's version support window](https://github.com/DefinitelyTyped/DefinitelyTyped/#support-window) - meaning we only support versions of TypeScript less than 2 years old. -We will always endeavor to support the latest stable version of TypeScript. -Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript. -In some cases, we may even be able to support additional pre-releases (i.e. betas and release candidates) of TypeScript, but only if doing so does not require us to compromise on support for the latest stable version. +You may find that our tooling works on older TypeScript versions however we provide no guarantees and **_we will not accept issues against unsupported versions_**. + +#### Supporting New TypeScript Releases + +With each new TypeScript release we file an issue to track the changes in the new version. The issue should always be pinned, and you can also [find the issues by searching for issues tagged with "New TypeScript Version"](https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aissue+label%3A%22New+TypeScript+Version%22+sort%3Acreated-desc). If the issue is open, we do not have official support yet - please be patient. + +In terms of what versions we support: + +- We do not support the `beta` releases. +- We _generally_ do not officially support the `rc` releases. +- We endeavor to support the latest stable TypeScript versions as soon as possible after the release. + +Generally we will begin working on supporting the next release when the `rc` version is released. + +#### Version Warning Logs Note that our packages have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript. -If you use a non-supported version of TypeScript, the parser will log a warning to the console. +However 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/) and [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/). **Please ensure that you are using a supported version before submitting any issues/bug reports.** ### Supported ESLint Version +We endeavour to support the latest stable ESLint versions as soon as possible after the release. + See the value of `eslint` declared in `@typescript-eslint/eslint-plugin`'s [package.json](./packages/eslint-plugin/package.json). ### Supported Node Version diff --git a/package.json b/package.json index d3ff24f36a6..76f4f0f2bea 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "tmp": "^0.2.1", "ts-node": "^10.7.0", "tslint": "^6.1.3", - "typescript": ">=3.3.1 <5.0.0" + "typescript": ">=4.2.4 <5.0.0" }, "resolutions": { "typescript": "~4.9.3", diff --git a/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts b/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts index d63b3ad43e3..27675423e11 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts @@ -1,18 +1,7 @@ import type { TSESLint, TSESTree } from '@typescript-eslint/utils'; -import { AST_NODE_TYPES } from '@typescript-eslint/utils'; -import * as semver from 'semver'; -import * as ts from 'typescript'; import * as util from '../util'; -const is3dot9 = semver.satisfies( - ts.version, - `>= 3.9.0 || >= 3.9.1-rc || >= 3.9.0-beta`, - { - includePrerelease: true, - }, -); - export default util.createRule({ name: 'no-non-null-asserted-optional-chain', meta: { @@ -32,16 +21,7 @@ export default util.createRule({ }, defaultOptions: [], create(context) { - // TS3.9 made a breaking change to how non-null works with optional chains. - // Pre-3.9, `x?.y!.z` means `(x?.y).z` - i.e. it essentially scrubbed the optionality from the chain - // Post-3.9, `x?.y!.z` means `x?.y!.z` - i.e. it just asserts that the property `y` is non-null, not the result of `x?.y`. - // This means that for > 3.9, x?.y!.z is valid! - // - // NOTE: these cases are still invalid for 3.9: - // - x?.y.z! - // - (x?.y)!.z - - const baseSelectors = { + return { // non-nulling a wrapped chain will scrub all nulls introduced by the chain // (x?.y)! // (x?.())! @@ -89,62 +69,5 @@ export default util.createRule({ }); }, }; - - if (is3dot9) { - return baseSelectors; - } - - return { - ...baseSelectors, - [[ - // > :not(ChainExpression) because that case is handled by a previous selector - 'MemberExpression > TSNonNullExpression.object > :not(ChainExpression)', - 'CallExpression > TSNonNullExpression.callee > :not(ChainExpression)', - ].join(', ')](child: TSESTree.Node): void { - // selector guarantees this assertion - const node = child.parent as TSESTree.TSNonNullExpression; - - let current = child; - while (current) { - switch (current.type) { - case AST_NODE_TYPES.MemberExpression: - if (current.optional) { - // found an optional chain! stop traversing - break; - } - - current = current.object; - continue; - - case AST_NODE_TYPES.CallExpression: - if (current.optional) { - // found an optional chain! stop traversing - break; - } - - current = current.callee; - continue; - - default: - // something that's not a ChainElement, which means this is not an optional chain we want to check - return; - } - } - - context.report({ - node, - messageId: 'noNonNullOptionalChain', - // use a suggestion instead of a fixer, because this can obviously break type checks - suggest: [ - { - messageId: 'suggestRemovingNonNull', - fix(fixer): TSESLint.RuleFix { - return fixer.removeRange([node.range[1] - 1, node.range[1]]); - }, - }, - ], - }); - }, - }; }, }); diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts index a337200a9a7..4e4547e2ffb 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts @@ -1,7 +1,5 @@ import type { TSESLint, TSESTree } from '@typescript-eslint/utils'; import { AST_NODE_TYPES } from '@typescript-eslint/utils'; -import * as semver from 'semver'; -import * as ts from 'typescript'; import * as util from '../util'; @@ -13,20 +11,6 @@ type TypeParameterWithConstraint = MakeRequired< 'constraint' >; -const is3dot5 = semver.satisfies( - ts.version, - `>= 3.5.0 || >= 3.5.1-rc || >= 3.5.0-beta`, - { - includePrerelease: true, - }, -); - -const is3dot9 = - is3dot5 && - semver.satisfies(ts.version, `>= 3.9.0 || >= 3.9.1-rc || >= 3.9.0-beta`, { - includePrerelease: true, - }); - export default util.createRule({ name: 'no-unnecessary-type-constraint', meta: { @@ -46,19 +30,13 @@ export default util.createRule({ }, defaultOptions: [], create(context) { - if (!is3dot5) { - return {}; - } - // In theory, we could use the type checker for more advanced constraint types... // ...but in practice, these types are rare, and likely not worth requiring type info. // https://github.com/typescript-eslint/typescript-eslint/pull/2516#discussion_r495731858 - const unnecessaryConstraints = is3dot9 - ? new Map([ - [AST_NODE_TYPES.TSAnyKeyword, 'any'], - [AST_NODE_TYPES.TSUnknownKeyword, 'unknown'], - ]) - : new Map([[AST_NODE_TYPES.TSUnknownKeyword, 'unknown']]); + const unnecessaryConstraints = new Map([ + [AST_NODE_TYPES.TSAnyKeyword, 'any'], + [AST_NODE_TYPES.TSUnknownKeyword, 'unknown'], + ]); const inJsx = context.getFilename().toLowerCase().endsWith('tsx'); const source = context.getSourceCode(); diff --git a/packages/eslint-plugin/tests/rules/no-non-null-asserted-optional-chain.test.ts b/packages/eslint-plugin/tests/rules/no-non-null-asserted-optional-chain.test.ts index 5f7caabc5b0..399c6b73488 100644 --- a/packages/eslint-plugin/tests/rules/no-non-null-asserted-optional-chain.test.ts +++ b/packages/eslint-plugin/tests/rules/no-non-null-asserted-optional-chain.test.ts @@ -17,7 +17,6 @@ ruleTester.run('no-non-null-asserted-optional-chain', rule, { 'foo?.bar();', '(foo?.bar).baz!;', '(foo?.bar()).baz!;', - // Valid as of 3.9 'foo?.bar!.baz;', 'foo?.bar!();', "foo?.['bar']!.baz;", diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index b2d5a671986..2bcf03e6193 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -33,7 +33,6 @@ import type { import type { SemanticOrSyntacticError } from './semantic-or-syntactic-errors'; import type { TSESTree, TSESTreeToTSNode, TSNode } from './ts-estree'; import { AST_NODE_TYPES } from './ts-estree'; -import { typescriptVersionIsAtLeast } from './version-check'; const SyntaxKind = ts.SyntaxKind; @@ -2151,13 +2150,6 @@ export class Converter { }); case SyntaxKind.NullKeyword: { - if (!typescriptVersionIsAtLeast['4.0'] && this.inTypeMode) { - // 4.0 started nesting null types inside a LiteralType node, but we still need to support pre-4.0 - return this.createNode(node, { - type: AST_NODE_TYPES.TSNullKeyword, - }); - } - return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: null, @@ -2769,10 +2761,7 @@ export class Converter { }); } case SyntaxKind.LiteralType: { - if ( - typescriptVersionIsAtLeast['4.0'] && - node.literal.kind === SyntaxKind.NullKeyword - ) { + if (node.literal.kind === SyntaxKind.NullKeyword) { // 4.0 started nesting null types inside a LiteralType node // but our AST is designed around the old way of null being a keyword return this.createNode( diff --git a/packages/typescript-estree/src/create-program/createWatchProgram.ts b/packages/typescript-estree/src/create-program/createWatchProgram.ts index d17835fff3c..96687206f7f 100644 --- a/packages/typescript-estree/src/create-program/createWatchProgram.ts +++ b/packages/typescript-estree/src/create-program/createWatchProgram.ts @@ -1,6 +1,5 @@ import debug from 'debug'; import fs from 'fs'; -import semver from 'semver'; import * as ts from 'typescript'; import type { ParseSettings } from '../parseSettings'; @@ -259,10 +258,6 @@ function getProgramsForProjects(parseSettings: ParseSettings): ts.Program[] { return results; } -const isRunningNoTimeoutFix = semver.satisfies(ts.version, '>=3.9.0-beta', { - includePrerelease: true, -}); - function createWatchProgram( tsconfigPath: string, parseSettings: ParseSettings, @@ -373,34 +368,9 @@ function createWatchProgram( // Since we don't want to asynchronously update program we want to disable timeout methods // So any changes in the program will be delayed and updated when getProgram is called on watch - let callback: (() => void) | undefined; - if (isRunningNoTimeoutFix) { - watchCompilerHost.setTimeout = undefined; - watchCompilerHost.clearTimeout = undefined; - } else { - log('Running without timeout fix'); - // But because of https://github.com/microsoft/TypeScript/pull/37308 we cannot just set it to undefined - // instead save it and call before getProgram is called - watchCompilerHost.setTimeout = (cb, _ms, ...args: unknown[]): unknown => { - callback = cb.bind(/*this*/ undefined, ...args); - return callback; - }; - watchCompilerHost.clearTimeout = (): void => { - callback = undefined; - }; - } - const watch = ts.createWatchProgram(watchCompilerHost); - if (!isRunningNoTimeoutFix) { - const originalGetProgram = watch.getProgram; - watch.getProgram = (): ts.BuilderProgram => { - if (callback) { - callback(); - } - callback = undefined; - return originalGetProgram.call(watch); - }; - } - return watch; + watchCompilerHost.setTimeout = undefined; + watchCompilerHost.clearTimeout = undefined; + return ts.createWatchProgram(watchCompilerHost); } function hasTSConfigChanged(tsconfigPath: CanonicalPath): boolean { diff --git a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts index ad9a74157d6..75c88ed0c97 100644 --- a/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts +++ b/packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts @@ -6,7 +6,7 @@ import type { ParseSettings } from './index'; * This needs to be kept in sync with the top-level README.md in the * typescript-eslint monorepo */ -const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.3.1 <5.0.0'; +const SUPPORTED_TYPESCRIPT_VERSIONS = '>=4.2.4 <5.0.0'; /* * The semver package will ignore prerelease ranges, and we don't want to explicitly document every one diff --git a/packages/typescript-estree/src/version-check.ts b/packages/typescript-estree/src/version-check.ts index 194636cb587..41913041301 100644 --- a/packages/typescript-estree/src/version-check.ts +++ b/packages/typescript-estree/src/version-check.ts @@ -12,11 +12,7 @@ function semverCheck(version: string): boolean { } const versions = [ - '3.7', - '3.8', - '3.9', - '4.0', - '4.1', + // '4.2', '4.3', '4.4', @@ -24,6 +20,8 @@ const versions = [ '4.6', '4.7', '4.8', + '4.9', + '5.0', ] as const; type Versions = typeof versions extends ArrayLike ? U : never; diff --git a/yarn.lock b/yarn.lock index 7cafafcd627..7754c213a4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6969,7 +6969,7 @@ eslint-plugin-simple-import-sort@^8.0.0: resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-8.0.0.tgz#9d9a2372b0606e999ea841b10458a370a6ccc160" integrity sha512-bXgJQ+lqhtQBCuWY/FUWdB27j4+lqcvXv5rUARkzbeWLwea+S5eBZEQrhnO+WgX3ZoJHVj0cn943iyXwByHHQw== -eslint-scope@5.1.1: +eslint-scope@5.1.1, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== @@ -13627,7 +13627,7 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, "typescript@>=3.3.1 <5.0.0", "typescript@^3 || ^4", typescript@next, typescript@~4.8.4, typescript@~4.9.3: +typescript@*, "typescript@>=4.2.4 <5.0.0", "typescript@^3 || ^4", typescript@next, typescript@~4.8.4, typescript@~4.9.3: version "4.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db" integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA== From f424b2a519595283be01149f0e13eb7f869bd247 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Thu, 10 Nov 2022 19:48:29 -0500 Subject: [PATCH 70/76] feat(utils): remove obsolete `meta.docs.suggestion` rule type (#5967) BREAKING CHANGE: Removes `meta.docs.suggestion` property --- packages/utils/src/ts-eslint/Rule.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/utils/src/ts-eslint/Rule.ts b/packages/utils/src/ts-eslint/Rule.ts index 7fe34067c95..f22e71400cf 100644 --- a/packages/utils/src/ts-eslint/Rule.ts +++ b/packages/utils/src/ts-eslint/Rule.ts @@ -22,10 +22,6 @@ interface RuleMetaDataDocs { * The URL of the rule's docs */ url?: string; - /** - * Specifies whether the rule can return suggestions. - */ - suggestion?: boolean; /** * Does the rule require us to create a full TypeScript Program in order for it * to type-check code. This is only used for documentation purposes. From cc62015b8ae5f207912ff8988e2a0b3fe9a79243 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:09:03 -0500 Subject: [PATCH 71/76] chore: drop support for node v14.17, v17 (#5971) feat: drop support for node v17 BREAKING CHANGE: drops support for node v17 --- package.json | 2 +- packages/ast-spec/package.json | 2 +- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/experimental-utils/package.json | 2 +- packages/parser/package.json | 2 +- packages/scope-manager/package.json | 2 +- packages/type-utils/package.json | 2 +- packages/types/package.json | 2 +- packages/typescript-estree/package.json | 2 +- packages/utils/package.json | 2 +- packages/visitor-keys/package.json | 2 +- packages/website-eslint/package.json | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 76f4f0f2bea..592ff528a5f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "typecheck": "nx run-many --target=typecheck --all --parallel" }, "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "devDependencies": { "@babel/code-frame": "^7.18.6", diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index ace52864124..05998bb22d9 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -9,7 +9,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 52441d5fb50..ee5a34b5856 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -11,7 +11,7 @@ "tslint" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 149326e397c..d87ddb5fbf3 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -9,7 +9,7 @@ "typescript" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 6a7cec4b79e..b499e5a9230 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/parser/package.json b/packages/parser/package.json index ad81f11d288..b1057d25c73 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -11,7 +11,7 @@ "LICENSE" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "repository": { "type": "git", diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index fadb71af960..7ded3d81a3e 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index ceaa9096cfb..ade9e169f9f 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/types/package.json b/packages/types/package.json index 45e5dc220b2..638b4ec633b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 556b5005e67..b9c668ca851 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -11,7 +11,7 @@ "LICENSE" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "repository": { "type": "git", diff --git a/packages/utils/package.json b/packages/utils/package.json index 6c9d7edef5f..3133d8b5e29 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index eceb14ef2ed..9f117bd178e 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "files": [ "dist", diff --git a/packages/website-eslint/package.json b/packages/website-eslint/package.json index 62b32a56494..e523b6d74dd 100644 --- a/packages/website-eslint/package.json +++ b/packages/website-eslint/package.json @@ -4,7 +4,7 @@ "private": true, "description": "ESLint which works in browsers.", "engines": { - "node": "^14.17.0 || >=16.0.0" + "node": "^14.18.0 || ^16.0.0 || >=18.0.0" }, "types": "types/index.d.ts", "main": "dist/index.js", From 2a5e20fd6733ccfa63dfc137287ae18027d4691a Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Sun, 13 Nov 2022 13:20:14 -0500 Subject: [PATCH 72/76] feat: raise tsconfig target to ES2021 (#5981) --- tsconfig.base.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 7bb2b5a7fa8..4116456c219 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -13,8 +13,8 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "target": "es2017", - "lib": ["es2017"], + "target": "ES2021", + "lib": ["ES2021"], "paths": {} } } From bda806d78ee46133587d9383baff52d796a594e5 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Sun, 13 Nov 2022 19:15:00 -0500 Subject: [PATCH 73/76] feat: drop support for ESLint v6 (#5972) BREAKING CHANGE: drop support for ESLint v6 --- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/experimental-utils/package.json | 2 +- packages/parser/package.json | 2 +- packages/type-utils/package.json | 2 +- packages/utils/package.json | 2 +- .../{eslint-v6 => eslint-v7}/.eslintrc.js | 0 .../{eslint-v6 => eslint-v7}/index.ts | 0 .../{eslint-v6 => eslint-v7}/package.json | 2 +- .../{eslint-v6 => eslint-v7}/tsconfig.json | 0 .../__snapshots__/eslint-v6.test.ts.snap | 28 ---------- .../__snapshots__/eslint-v7.test.ts.snap | 53 +++++++++++++++++++ .../{eslint-v6.test.ts => eslint-v7.test.ts} | 0 13 files changed, 60 insertions(+), 35 deletions(-) rename tests/integration/fixtures/{eslint-v6 => eslint-v7}/.eslintrc.js (100%) rename tests/integration/fixtures/{eslint-v6 => eslint-v7}/index.ts (100%) rename tests/integration/fixtures/{eslint-v6 => eslint-v7}/package.json (58%) rename tests/integration/fixtures/{eslint-v6 => eslint-v7}/tsconfig.json (100%) delete mode 100644 tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap create mode 100644 tests/integration/tests/__snapshots__/eslint-v7.test.ts.snap rename tests/integration/tests/{eslint-v6.test.ts => eslint-v7.test.ts} (100%) diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index ee5a34b5856..494b4fc4292 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -42,7 +42,7 @@ "lodash": "^4.17.21" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0", + "eslint": "^7.0.0 || ^8.0.0", "tslint": "^5.0.0 || ^6.0.0", "typescript": "*" }, diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index d87ddb5fbf3..936313604e1 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -71,7 +71,7 @@ }, "peerDependencies": { "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index b499e5a9230..0a55b72ffb4 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -41,7 +41,7 @@ "@typescript-eslint/utils": "5.44.0" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "devDependencies": { "typescript": "*" diff --git a/packages/parser/package.json b/packages/parser/package.json index b1057d25c73..0fde80b14c9 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -42,7 +42,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "dependencies": { "@typescript-eslint/scope-manager": "5.44.0", diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index ade9e169f9f..01e8306775d 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -49,7 +49,7 @@ "typescript": "*" }, "peerDependencies": { - "eslint": "*" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { diff --git a/packages/utils/package.json b/packages/utils/package.json index 3133d8b5e29..683dddfe683 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -49,7 +49,7 @@ "semver": "^7.3.7" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "devDependencies": { "@typescript-eslint/parser": "5.44.0", diff --git a/tests/integration/fixtures/eslint-v6/.eslintrc.js b/tests/integration/fixtures/eslint-v7/.eslintrc.js similarity index 100% rename from tests/integration/fixtures/eslint-v6/.eslintrc.js rename to tests/integration/fixtures/eslint-v7/.eslintrc.js diff --git a/tests/integration/fixtures/eslint-v6/index.ts b/tests/integration/fixtures/eslint-v7/index.ts similarity index 100% rename from tests/integration/fixtures/eslint-v6/index.ts rename to tests/integration/fixtures/eslint-v7/index.ts diff --git a/tests/integration/fixtures/eslint-v6/package.json b/tests/integration/fixtures/eslint-v7/package.json similarity index 58% rename from tests/integration/fixtures/eslint-v6/package.json rename to tests/integration/fixtures/eslint-v7/package.json index 71c2f5590c5..d939ab3f81c 100644 --- a/tests/integration/fixtures/eslint-v6/package.json +++ b/tests/integration/fixtures/eslint-v7/package.json @@ -1,5 +1,5 @@ { "devDependencies": { - "eslint": "6.0.0" + "eslint": "7.0.0" } } diff --git a/tests/integration/fixtures/eslint-v6/tsconfig.json b/tests/integration/fixtures/eslint-v7/tsconfig.json similarity index 100% rename from tests/integration/fixtures/eslint-v6/tsconfig.json rename to tests/integration/fixtures/eslint-v7/tsconfig.json diff --git a/tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap b/tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap deleted file mode 100644 index 4bb27abfcc9..00000000000 --- a/tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`eslint-v6 should lint successfully 1`] = ` -[ - { - "errorCount": 1, - "filePath": "/index.ts", - "fixableErrorCount": 0, - "fixableWarningCount": 0, - "messages": [ - { - "column": 15, - "endColumn": 18, - "endLine": 1, - "line": 1, - "message": "Unexpected any. Specify a different type.", - "messageId": "unexpectedAny", - "nodeType": "TSAnyKeyword", - "ruleId": "@typescript-eslint/no-explicit-any", - "severity": 2, - }, - ], - "source": "const noSemi: any = true; -", - "warningCount": 0, - }, -] -`; diff --git a/tests/integration/tests/__snapshots__/eslint-v7.test.ts.snap b/tests/integration/tests/__snapshots__/eslint-v7.test.ts.snap new file mode 100644 index 00000000000..eb23a06011e --- /dev/null +++ b/tests/integration/tests/__snapshots__/eslint-v7.test.ts.snap @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`eslint-v7 should lint successfully 1`] = ` +[ + { + "errorCount": 1, + "filePath": "/index.ts", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": [ + { + "column": 15, + "endColumn": 18, + "endLine": 1, + "line": 1, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "severity": 2, + "suggestions": [ + { + "desc": "Use \`unknown\` instead, this will force you to explicitly, and safely assert the type is correct.", + "fix": { + "range": [ + 14, + 17, + ], + "text": "unknown", + }, + "messageId": "suggestUnknown", + }, + { + "desc": "Use \`never\` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.", + "fix": { + "range": [ + 14, + 17, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + ], + "source": "const noSemi: any = true; +", + "usedDeprecatedRules": [], + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/tests/eslint-v6.test.ts b/tests/integration/tests/eslint-v7.test.ts similarity index 100% rename from tests/integration/tests/eslint-v6.test.ts rename to tests/integration/tests/eslint-v7.test.ts From af41b7fa7b9b8f3023fdabd40846598d5d4d4f61 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 00:48:59 -0500 Subject: [PATCH 74/76] feat(typescript-estree): allow providing code as a ts.SourceFile (#5892) --- packages/parser/src/parser.ts | 8 ++-- .../typescript-estree/src/ast-converter.ts | 2 +- .../create-program/createDefaultProgram.ts | 2 +- .../create-program/createIsolatedProgram.ts | 2 +- .../src/create-program/createSourceFile.ts | 17 +++++---- .../src/create-program/createWatchProgram.ts | 10 +++-- .../src/parseSettings/createParseSettings.ts | 20 ++++++---- .../src/parseSettings/index.ts | 9 ++++- packages/typescript-estree/src/parser.ts | 4 +- .../typescript-estree/src/source-files.ts | 17 +++++++++ .../tests/lib/source-files.test.ts | 37 +++++++++++++++++++ .../website/src/components/linter/config.ts | 1 + 12 files changed, 100 insertions(+), 29 deletions(-) create mode 100644 packages/typescript-estree/src/source-files.ts create mode 100644 packages/typescript-estree/tests/lib/source-files.test.ts diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index e7223e93332..f619f5e17c1 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -14,7 +14,7 @@ import { visitorKeys, } from '@typescript-eslint/typescript-estree'; import debug from 'debug'; -import type { CompilerOptions } from 'typescript'; +import type * as ts from 'typescript'; import { ScriptTarget } from 'typescript'; const log = debug('typescript-eslint:parser:parser'); @@ -41,7 +41,7 @@ function validateBoolean( } const LIB_FILENAME_REGEX = /lib\.(.+)\.d\.[cm]?ts$/; -function getLib(compilerOptions: CompilerOptions): Lib[] { +function getLib(compilerOptions: ts.CompilerOptions): Lib[] { if (compilerOptions.lib) { return compilerOptions.lib.reduce((acc, lib) => { const match = LIB_FILENAME_REGEX.exec(lib.toLowerCase()); @@ -76,14 +76,14 @@ function getLib(compilerOptions: CompilerOptions): Lib[] { } function parse( - code: string, + code: string | ts.SourceFile, options?: ParserOptions, ): ParseForESLintResult['ast'] { return parseForESLint(code, options).ast; } function parseForESLint( - code: string, + code: string | ts.SourceFile, options?: ParserOptions | null, ): ParseForESLintResult { if (!options || typeof options !== 'object') { diff --git a/packages/typescript-estree/src/ast-converter.ts b/packages/typescript-estree/src/ast-converter.ts index b9be864f529..0e55541969d 100644 --- a/packages/typescript-estree/src/ast-converter.ts +++ b/packages/typescript-estree/src/ast-converter.ts @@ -63,7 +63,7 @@ export function astConverter( * Optionally convert and include all comments in the AST */ if (parseSettings.comment) { - estree.comments = convertComments(ast, parseSettings.code); + estree.comments = convertComments(ast, parseSettings.codeFullText); } const astMaps = instance.getASTMaps(); diff --git a/packages/typescript-estree/src/create-program/createDefaultProgram.ts b/packages/typescript-estree/src/create-program/createDefaultProgram.ts index bfcc3066b17..174783f43db 100644 --- a/packages/typescript-estree/src/create-program/createDefaultProgram.ts +++ b/packages/typescript-estree/src/create-program/createDefaultProgram.ts @@ -56,7 +56,7 @@ function createDefaultProgram( const oldReadFile = compilerHost.readFile; compilerHost.readFile = (fileName: string): string | undefined => path.normalize(fileName) === path.normalize(parseSettings.filePath) - ? parseSettings.code + ? parseSettings.codeFullText : oldReadFile(fileName); const program = ts.createProgram( diff --git a/packages/typescript-estree/src/create-program/createIsolatedProgram.ts b/packages/typescript-estree/src/create-program/createIsolatedProgram.ts index 5ec1c8e0fe7..58d7ec8a61a 100644 --- a/packages/typescript-estree/src/create-program/createIsolatedProgram.ts +++ b/packages/typescript-estree/src/create-program/createIsolatedProgram.ts @@ -43,7 +43,7 @@ function createIsolatedProgram(parseSettings: ParseSettings): ASTAndProgram { getSourceFile(filename: string) { return ts.createSourceFile( filename, - parseSettings.code, + parseSettings.codeFullText, ts.ScriptTarget.Latest, /* setParentNodes */ true, getScriptKind(parseSettings.filePath, parseSettings.jsx), diff --git a/packages/typescript-estree/src/create-program/createSourceFile.ts b/packages/typescript-estree/src/create-program/createSourceFile.ts index 806e503f0e4..0214802f73f 100644 --- a/packages/typescript-estree/src/create-program/createSourceFile.ts +++ b/packages/typescript-estree/src/create-program/createSourceFile.ts @@ -2,6 +2,7 @@ import debug from 'debug'; import * as ts from 'typescript'; import type { ParseSettings } from '../parseSettings'; +import { isSourceFile } from '../source-files'; import { getScriptKind } from './getScriptKind'; const log = debug('typescript-eslint:typescript-estree:createSourceFile'); @@ -13,13 +14,15 @@ function createSourceFile(parseSettings: ParseSettings): ts.SourceFile { parseSettings.filePath, ); - return ts.createSourceFile( - parseSettings.filePath, - parseSettings.code, - ts.ScriptTarget.Latest, - /* setParentNodes */ true, - getScriptKind(parseSettings.filePath, parseSettings.jsx), - ); + return isSourceFile(parseSettings.code) + ? parseSettings.code + : ts.createSourceFile( + parseSettings.filePath, + parseSettings.codeFullText, + ts.ScriptTarget.Latest, + /* setParentNodes */ true, + getScriptKind(parseSettings.filePath, parseSettings.jsx), + ); } export { createSourceFile }; diff --git a/packages/typescript-estree/src/create-program/createWatchProgram.ts b/packages/typescript-estree/src/create-program/createWatchProgram.ts index 96687206f7f..d2d63676fca 100644 --- a/packages/typescript-estree/src/create-program/createWatchProgram.ts +++ b/packages/typescript-estree/src/create-program/createWatchProgram.ts @@ -3,6 +3,7 @@ import fs from 'fs'; import * as ts from 'typescript'; import type { ParseSettings } from '../parseSettings'; +import { getCodeText } from '../source-files'; import type { CanonicalPath } from './shared'; import { canonicalDirname, @@ -89,7 +90,10 @@ function saveWatchCallback( /** * Holds information about the file currently being linted */ -const currentLintOperationState: { code: string; filePath: CanonicalPath } = { +const currentLintOperationState: { + code: string | ts.SourceFile; + filePath: CanonicalPath; +} = { code: '', filePath: '' as CanonicalPath, }; @@ -147,7 +151,7 @@ function getProgramsForProjects(parseSettings: ParseSettings): ts.Program[] { // Update file version if necessary const fileWatchCallbacks = fileWatchCallbackTrackingMap.get(filePath); - const codeHash = createHash(parseSettings.code); + const codeHash = createHash(getCodeText(parseSettings.code)); if ( parsedFilesSeenHash.get(filePath) !== codeHash && fileWatchCallbacks && @@ -286,7 +290,7 @@ function createWatchProgram( const filePath = getCanonicalFileName(filePathIn); const fileContent = filePath === currentLintOperationState.filePath - ? currentLintOperationState.code + ? getCodeText(currentLintOperationState.code) : oldReadFile(filePath, encoding); if (fileContent !== undefined) { parsedFilesSeenHash.set(filePath, createHash(fileContent)); diff --git a/packages/typescript-estree/src/parseSettings/createParseSettings.ts b/packages/typescript-estree/src/parseSettings/createParseSettings.ts index 7a0965ae51c..767e4af8e97 100644 --- a/packages/typescript-estree/src/parseSettings/createParseSettings.ts +++ b/packages/typescript-estree/src/parseSettings/createParseSettings.ts @@ -1,6 +1,7 @@ import debug from 'debug'; import { sync as globSync } from 'globby'; import isGlob from 'is-glob'; +import type * as ts from 'typescript'; import type { CanonicalPath } from '../create-program/shared'; import { @@ -8,6 +9,7 @@ import { getCanonicalFileName, } from '../create-program/shared'; import type { TSESTreeOptions } from '../parser-options'; +import { isSourceFile } from '../source-files'; import type { MutableParseSettings } from './index'; import { inferSingleRun } from './inferSingleRun'; import { warnAboutTSVersion } from './warnAboutTSVersion'; @@ -17,15 +19,17 @@ const log = debug( ); export function createParseSettings( - code: string, + code: string | ts.SourceFile, options: Partial = {}, ): MutableParseSettings { + const codeFullText = enforceCodeString(code); const tsconfigRootDir = typeof options.tsconfigRootDir === 'string' ? options.tsconfigRootDir : process.cwd(); const parseSettings: MutableParseSettings = { - code: enforceString(code), + code, + codeFullText, comment: options.comment === true, comments: [], DEPRECATED__createDefaultProgram: @@ -127,12 +131,12 @@ export function createParseSettings( /** * Ensures source code is a string. */ -function enforceString(code: unknown): string { - if (typeof code !== 'string') { - return String(code); - } - - return code; +function enforceCodeString(code: unknown): string { + return isSourceFile(code) + ? code.getFullText(code) + : typeof code === 'string' + ? code + : String(code); } /** diff --git a/packages/typescript-estree/src/parseSettings/index.ts b/packages/typescript-estree/src/parseSettings/index.ts index 02479d5bd2b..07e818ae988 100644 --- a/packages/typescript-estree/src/parseSettings/index.ts +++ b/packages/typescript-estree/src/parseSettings/index.ts @@ -10,9 +10,14 @@ type DebugModule = 'typescript-eslint' | 'eslint' | 'typescript'; */ export interface MutableParseSettings { /** - * Code of the file being parsed. + * Code of the file being parsed, or raw source file containing it. */ - code: string; + code: string | ts.SourceFile; + + /** + * Full text of the file being parsed. + */ + codeFullText: string; /** * Whether the `comment` parse option is enabled. diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 478cfa490c9..6e8c01a974c 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -77,7 +77,7 @@ function parse( } function parseWithNodeMapsInternal( - code: string, + code: string | ts.SourceFile, options: T | undefined, shouldPreserveNodeMaps: boolean, ): ParseWithNodeMapsResult { @@ -130,7 +130,7 @@ function clearParseAndGenerateServicesCalls(): void { } function parseAndGenerateServices( - code: string, + code: string | ts.SourceFile, options: T, ): ParseAndGenerateServicesResult { /** diff --git a/packages/typescript-estree/src/source-files.ts b/packages/typescript-estree/src/source-files.ts new file mode 100644 index 00000000000..18cd4567090 --- /dev/null +++ b/packages/typescript-estree/src/source-files.ts @@ -0,0 +1,17 @@ +import * as ts from 'typescript'; + +export function isSourceFile(code: unknown): code is ts.SourceFile { + if (typeof code !== 'object' || code == null) { + return false; + } + + const maybeSourceFile = code as Partial; + return ( + maybeSourceFile.kind === ts.SyntaxKind.SourceFile && + typeof maybeSourceFile.getFullText === 'function' + ); +} + +export function getCodeText(code: string | ts.SourceFile): string { + return isSourceFile(code) ? code.getFullText(code) : code; +} diff --git a/packages/typescript-estree/tests/lib/source-files.test.ts b/packages/typescript-estree/tests/lib/source-files.test.ts new file mode 100644 index 00000000000..e6edb1c9c65 --- /dev/null +++ b/packages/typescript-estree/tests/lib/source-files.test.ts @@ -0,0 +1,37 @@ +import * as ts from 'typescript'; + +import { getCodeText, isSourceFile } from '../../src/source-files'; + +describe('isSourceFile', () => { + it.each([null, undefined, {}, { getFullText: (): string => '', text: '' }])( + `returns false when given %j`, + input => { + expect(isSourceFile(input)).toBe(false); + }, + ); + + it('returns true when given a real source file', () => { + const input = ts.createSourceFile('test.ts', '', ts.ScriptTarget.ESNext); + + expect(isSourceFile(input)).toBe(true); + }); +}); + +describe('getCodeText', () => { + it('returns the code when code is provided as a string', () => { + const code = '// Hello world'; + + expect(getCodeText(code)).toBe(code); + }); + + it('returns the code when code is provided as a source file', () => { + const code = '// Hello world'; + const sourceFile = ts.createSourceFile( + 'test.ts', + code, + ts.ScriptTarget.ESNext, + ); + + expect(getCodeText(sourceFile)).toBe(code); + }); +}); diff --git a/packages/website/src/components/linter/config.ts b/packages/website/src/components/linter/config.ts index c3e95b321c3..2dc3eaa0d7c 100644 --- a/packages/website/src/components/linter/config.ts +++ b/packages/website/src/components/linter/config.ts @@ -2,6 +2,7 @@ import type { ParseSettings } from '@typescript-eslint/typescript-estree/dist/pa export const parseSettings: ParseSettings = { code: '', + codeFullText: '', comment: true, comments: [], DEPRECATED__createDefaultProgram: false, From 4bdbe67955fd591c25e58b13e674ba05bf5ed585 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 16 Nov 2022 01:48:06 -0500 Subject: [PATCH 75/76] feat(eslint-plugin): [prefer-nullish-coalescing]: add support for assignment expressions (#5234) BREAKING CHANGE: Adds an additional class of checks to the rule --- .../docs/rules/prefer-nullish-coalescing.md | 15 +- .../src/rules/prefer-nullish-coalescing.ts | 149 +++++---- .../rules/prefer-nullish-coalescing.test.ts | 298 +++++++++--------- 3 files changed, 254 insertions(+), 208 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md index d2fc95f4066..5aa780f8002 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -1,5 +1,5 @@ --- -description: 'Enforce using the nullish coalescing operator instead of logical chaining.' +description: 'Enforce using the nullish coalescing operator instead of logical assignments or chaining.' --- > 🛑 This file is source code, not the primary documentation location! 🛑 @@ -9,7 +9,10 @@ description: 'Enforce using the nullish coalescing operator instead of logical c The `??` nullish coalescing runtime operator allows providing a default value when dealing with `null` or `undefined`. Because the nullish coalescing operator _only_ coalesces when the original value is `null` or `undefined`, it is much safer than relying upon logical OR operator chaining `||`, which coalesces on any _falsy_ value. -This rule reports when an `||` operator can be safely replaced with a `??`. +This rule reports when you can safely replace: + +- An `||` operator with `??` +- An `||=` operator with `??=` :::caution This rule will not work as expected if [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) is not enabled. @@ -73,7 +76,10 @@ declare const b: string | null; if (a || b) { } +if ((a ||= b)) { +} while (a || b) {} +while ((a ||= b)) {} do {} while (a || b); for (let i = 0; a || b; i += 1) {} a || b ? true : false; @@ -87,7 +93,10 @@ declare const b: string | null; if (a ?? b) { } +if ((a ??= b)) { +} while (a ?? b) {} +while ((a ??= b)) {} do {} while (a ?? b); for (let i = 0; a ?? b; i += 1) {} a ?? b ? true : false; @@ -110,6 +119,7 @@ declare const c: string | null; declare const d: string | null; a || (b && c); +a ||= b && c; (a && b) || c || d; a || (b && c) || d; a || (b && c && d); @@ -124,6 +134,7 @@ declare const c: string | null; declare const d: string | null; a ?? (b && c); +a ??= b && c; (a && b) ?? c ?? d; a ?? (b && c) ?? d; a ?? (b && c && d); diff --git a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts index ca40160e982..f29df6f6f98 100644 --- a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts @@ -23,17 +23,17 @@ export default util.createRule({ type: 'suggestion', docs: { description: - 'Enforce using the nullish coalescing operator instead of logical chaining', + 'Enforce using the nullish coalescing operator instead of logical assignments or chaining', recommended: 'strict', requiresTypeChecking: true, }, hasSuggestions: true, messages: { preferNullishOverOr: - 'Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.', + 'Prefer using nullish coalescing operator (`??{{ equals }}`) instead of a logical {{ description }} (`||{{ equals }}`), as it is a safer operator.', preferNullishOverTernary: - 'Prefer using nullish coalescing operator (`??`) instead of a ternary expression, as it is simpler to read.', - suggestNullish: 'Fix to nullish coalescing operator (`??`).', + 'Prefer using nullish coalescing operator (`??{{ equals }}`) instead of a ternary expression, as it is simpler to read.', + suggestNullish: 'Fix to nullish coalescing operator (`??{{ equals }}`).', }, schema: [ { @@ -74,6 +74,75 @@ export default util.createRule({ const sourceCode = context.getSourceCode(); const checker = parserServices.program.getTypeChecker(); + // todo: rename to something more specific? + function checkAssignmentOrLogicalExpression( + node: TSESTree.AssignmentExpression | TSESTree.LogicalExpression, + description: string, + equals: string, + ): void { + const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); + const type = checker.getTypeAtLocation(tsNode.left); + const isNullish = util.isNullableType(type, { allowUndefined: true }); + if (!isNullish) { + return; + } + + if (ignoreConditionalTests === true && isConditionalTest(node)) { + return; + } + + if ( + ignoreMixedLogicalExpressions === true && + isMixedLogicalExpression(node) + ) { + return; + } + + const barBarOperator = util.nullThrows( + sourceCode.getTokenAfter( + node.left, + token => + token.type === AST_TOKEN_TYPES.Punctuator && + token.value === node.operator, + ), + util.NullThrowsReasons.MissingToken('operator', node.type), + ); + + function* fix( + fixer: TSESLint.RuleFixer, + ): IterableIterator { + if (node.parent && util.isLogicalOrOperator(node.parent)) { + // '&&' and '??' operations cannot be mixed without parentheses (e.g. a && b ?? c) + if ( + node.left.type === AST_NODE_TYPES.LogicalExpression && + !util.isLogicalOrOperator(node.left.left) + ) { + yield fixer.insertTextBefore(node.left.right, '('); + } else { + yield fixer.insertTextBefore(node.left, '('); + } + yield fixer.insertTextAfter(node.right, ')'); + } + yield fixer.replaceText( + barBarOperator, + node.operator.replace('||', '??'), + ); + } + + context.report({ + data: { equals, description }, + node: barBarOperator, + messageId: 'preferNullishOverOr', + suggest: [ + { + data: { equals }, + messageId: 'suggestNullish', + fix, + }, + ], + }); + } + return { ConditionalExpression(node: TSESTree.ConditionalExpression): void { if (ignoreTernaryTests) { @@ -103,7 +172,7 @@ export default util.createRule({ node.test.right.left, node.test.right.right, ]; - if (node.test.operator === '||') { + if (['||', '||='].includes(node.test.operator)) { if ( node.test.left.operator === '===' && node.test.right.operator === '===' @@ -205,10 +274,13 @@ export default util.createRule({ if (isFixable) { context.report({ + // TODO: also account for = in the ternary clause + data: { equals: '' }, node, messageId: 'preferNullishOverTernary', suggest: [ { + data: { equals: '' }, messageId: 'suggestNullish', fix(fixer: TSESLint.RuleFixer): TSESLint.RuleFix { const [left, right] = @@ -231,64 +303,15 @@ export default util.createRule({ }); } }, - + 'AssignmentExpression[operator = "||="]'( + node: TSESTree.AssignmentExpression, + ): void { + checkAssignmentOrLogicalExpression(node, 'assignment', '='); + }, 'LogicalExpression[operator = "||"]'( node: TSESTree.LogicalExpression, ): void { - const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); - const type = checker.getTypeAtLocation(tsNode.left); - const isNullish = util.isNullableType(type, { allowUndefined: true }); - if (!isNullish) { - return; - } - - if (ignoreConditionalTests === true && isConditionalTest(node)) { - return; - } - - const isMixedLogical = isMixedLogicalExpression(node); - if (ignoreMixedLogicalExpressions === true && isMixedLogical) { - return; - } - - const barBarOperator = util.nullThrows( - sourceCode.getTokenAfter( - node.left, - token => - token.type === AST_TOKEN_TYPES.Punctuator && - token.value === node.operator, - ), - util.NullThrowsReasons.MissingToken('operator', node.type), - ); - - function* fix( - fixer: TSESLint.RuleFixer, - ): IterableIterator { - if (node.parent && util.isLogicalOrOperator(node.parent)) { - // '&&' and '??' operations cannot be mixed without parentheses (e.g. a && b ?? c) - if ( - node.left.type === AST_NODE_TYPES.LogicalExpression && - !util.isLogicalOrOperator(node.left.left) - ) { - yield fixer.insertTextBefore(node.left.right, '('); - } else { - yield fixer.insertTextBefore(node.left, '('); - } - yield fixer.insertTextAfter(node.right, ')'); - } - yield fixer.replaceText(barBarOperator, '??'); - } - - context.report({ - node: barBarOperator, - messageId: 'preferNullishOverOr', - suggest: [ - { - messageId: 'suggestNullish', - fix, - }, - ], - }); + checkAssignmentOrLogicalExpression(node, 'or', ''); }, }; }, @@ -331,7 +354,9 @@ function isConditionalTest(node: TSESTree.Node): boolean { return false; } -function isMixedLogicalExpression(node: TSESTree.LogicalExpression): boolean { +function isMixedLogicalExpression( + node: TSESTree.AssignmentExpression | TSESTree.LogicalExpression, +): boolean { const seen = new Set(); const queue = [node.parent, node.left, node.right]; for (const current of queue) { @@ -343,7 +368,7 @@ function isMixedLogicalExpression(node: TSESTree.LogicalExpression): boolean { if (current && current.type === AST_NODE_TYPES.LogicalExpression) { if (current.operator === '&&') { return true; - } else if (current.operator === '||') { + } else if (['||', '||='].includes(current.operator)) { // check the pieces of the node to catch cases like `a || b || c && d` queue.push(current.parent, current.left, current.right); } diff --git a/packages/eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts b/packages/eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts index 3824f464a58..62a7cece074 100644 --- a/packages/eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts @@ -21,20 +21,28 @@ const types = ['string', 'number', 'boolean', 'object']; const nullishTypes = ['null', 'undefined', 'null | undefined']; function typeValidTest( - cb: (type: string) => TSESLint.ValidTestCase | string, + cb: ( + type: string, + equals: '' | '=', + ) => TSESLint.ValidTestCase | string, ): (TSESLint.ValidTestCase | string)[] { - return types.map(type => cb(type)); + return [ + ...types.map(type => cb(type, '')), + ...types.map(type => cb(type, '=')), + ]; } + function nullishTypeValidTest( cb: ( nullish: string, type: string, + equals: string, ) => TSESLint.ValidTestCase | string, ): (TSESLint.ValidTestCase | string)[] { return nullishTypes.reduce<(TSESLint.ValidTestCase | string)[]>( (acc, nullish) => { types.forEach(type => { - acc.push(cb(nullish, type)); + acc.push(cb(nullish, type, ''), cb(nullish, type, '=')); }); return acc; }, @@ -45,12 +53,14 @@ function nullishTypeInvalidTest( cb: ( nullish: string, type: string, + equals: string, ) => TSESLint.InvalidTestCase, ): TSESLint.InvalidTestCase[] { return nullishTypes.reduce[]>( (acc, nullish) => { types.forEach(type => { - acc.push(cb(nullish, type)); + acc.push(cb(nullish, type, '')); + acc.push(cb(nullish, type, '=')); }); return acc; }, @@ -61,15 +71,15 @@ function nullishTypeInvalidTest( ruleTester.run('prefer-nullish-coalescing', rule, { valid: [ ...typeValidTest( - type => ` -declare const x: ${type}; -x || 'foo'; + (type, equals) => ` +declare let x: ${type}; +(x ||${equals} 'foo'); `, ), ...nullishTypeValidTest( - (nullish, type) => ` -declare const x: ${type} | ${nullish}; -x ?? 'foo'; + (nullish, type, equals) => ` +declare let x: ${type} | ${nullish}; +x ??${equals} 'foo'; `, ), @@ -102,35 +112,35 @@ x ?? 'foo'; 'null != x ? y : x;', 'undefined != x ? y : x;', ` -declare const x: string; +declare let x: string; x === null ? x : y; `, ` -declare const x: string | undefined; +declare let x: string | undefined; x === null ? x : y; `, ` -declare const x: string | null; +declare let x: string | null; x === undefined ? x : y; `, ` -declare const x: string | undefined | null; +declare let x: string | undefined | null; x !== undefined ? x : y; `, ` -declare const x: string | undefined | null; +declare let x: string | undefined | null; x !== null ? x : y; `, ` -declare const x: string | null | any; +declare let x: string | null | any; x === null ? x : y; `, ` -declare const x: string | null | unknown; +declare let x: string | null | unknown; x === null ? x : y; `, ` -declare const x: string | undefined; +declare let x: string | undefined; x === null ? x : y; `, ].map(code => ({ @@ -139,38 +149,38 @@ x === null ? x : y; })), // ignoreConditionalTests - ...nullishTypeValidTest((nullish, type) => ({ + ...nullishTypeValidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -x || 'foo' ? null : null; +declare let x: ${type} | ${nullish}; +(x ||${equals} 'foo') ? null : null; `, options: [{ ignoreConditionalTests: true }], })), - ...nullishTypeValidTest((nullish, type) => ({ + ...nullishTypeValidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -if (x || 'foo') {} +declare let x: ${type} | ${nullish}; +if ((x ||${equals} 'foo')) {} `, options: [{ ignoreConditionalTests: true }], })), - ...nullishTypeValidTest((nullish, type) => ({ + ...nullishTypeValidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -do {} while (x || 'foo') +declare let x: ${type} | ${nullish}; +do {} while ((x ||${equals} 'foo')) `, options: [{ ignoreConditionalTests: true }], })), - ...nullishTypeValidTest((nullish, type) => ({ + ...nullishTypeValidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -for (;x || 'foo';) {} +declare let x: ${type} | ${nullish}; +for (;(x ||${equals} 'foo');) {} `, options: [{ ignoreConditionalTests: true }], })), - ...nullishTypeValidTest((nullish, type) => ({ + ...nullishTypeValidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -while (x || 'foo') {} +declare let x: ${type} | ${nullish}; +while ((x ||${equals} 'foo')) {} `, options: [{ ignoreConditionalTests: true }], })), @@ -178,54 +188,54 @@ while (x || 'foo') {} // ignoreMixedLogicalExpressions ...nullishTypeValidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; a || b && c; `, options: [{ ignoreMixedLogicalExpressions: true }], })), ...nullishTypeValidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a || b || c && d; `, options: [{ ignoreMixedLogicalExpressions: true }], })), ...nullishTypeValidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a && b || c || d; `, options: [{ ignoreMixedLogicalExpressions: true }], })), ], invalid: [ - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -x || 'foo'; +declare let x: ${type} | ${nullish}; +(x ||${equals} 'foo'); `, output: null, errors: [ { messageId: 'preferNullishOverOr', line: 3, - column: 3, + column: 4, endLine: 3, - endColumn: 5, + endColumn: 6 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -x ?? 'foo'; +declare let x: ${type} | ${nullish}; +(x ??${equals} 'foo'); `, }, ], @@ -330,35 +340,35 @@ x ?? 'foo'; ...[ ` -declare const x: string | undefined; +declare let x: string | undefined; x !== undefined ? x : y; `, ` -declare const x: string | undefined; +declare let x: string | undefined; undefined !== x ? x : y; `, ` -declare const x: string | undefined; +declare let x: string | undefined; undefined === x ? y : x; `, ` -declare const x: string | undefined; +declare let x: string | undefined; undefined === x ? y : x; `, ` -declare const x: string | null; +declare let x: string | null; x !== null ? x : y; `, ` -declare const x: string | null; +declare let x: string | null; null !== x ? x : y; `, ` -declare const x: string | null; +declare let x: string | null; null === x ? y : x; `, ` -declare const x: string | null; +declare let x: string | null; null === x ? y : x; `, ].map(code => ({ @@ -386,10 +396,10 @@ x ?? y; })), // ignoreConditionalTests - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -x || 'foo' ? null : null; +declare let x: ${type} | ${nullish}; +(x ||${equals} 'foo') ? null : null; `, output: null, options: [{ ignoreConditionalTests: false }], @@ -397,25 +407,25 @@ x || 'foo' ? null : null; { messageId: 'preferNullishOverOr', line: 3, - column: 3, + column: 4, endLine: 3, - endColumn: 5, + endColumn: 6 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -x ?? 'foo' ? null : null; +declare let x: ${type} | ${nullish}; +(x ??${equals} 'foo') ? null : null; `, }, ], }, ], })), - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -if (x || 'foo') {} +declare let x: ${type} | ${nullish}; +if ((x ||${equals} 'foo')) {} `, output: null, options: [{ ignoreConditionalTests: false }], @@ -423,25 +433,25 @@ if (x || 'foo') {} { messageId: 'preferNullishOverOr', line: 3, - column: 7, + column: 8, endLine: 3, - endColumn: 9, + endColumn: 10 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -if (x ?? 'foo') {} +declare let x: ${type} | ${nullish}; +if ((x ??${equals} 'foo')) {} `, }, ], }, ], })), - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -do {} while (x || 'foo') +declare let x: ${type} | ${nullish}; +do {} while ((x ||${equals} 'foo')) `, output: null, options: [{ ignoreConditionalTests: false }], @@ -449,25 +459,25 @@ do {} while (x || 'foo') { messageId: 'preferNullishOverOr', line: 3, - column: 16, + column: 17, endLine: 3, - endColumn: 18, + endColumn: 19 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -do {} while (x ?? 'foo') +declare let x: ${type} | ${nullish}; +do {} while ((x ??${equals} 'foo')) `, }, ], }, ], })), - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -for (;x || 'foo';) {} +declare let x: ${type} | ${nullish}; +for (;(x ||${equals} 'foo');) {} `, output: null, options: [{ ignoreConditionalTests: false }], @@ -475,25 +485,25 @@ for (;x || 'foo';) {} { messageId: 'preferNullishOverOr', line: 3, - column: 9, + column: 10, endLine: 3, - endColumn: 11, + endColumn: 12 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -for (;x ?? 'foo';) {} +declare let x: ${type} | ${nullish}; +for (;(x ??${equals} 'foo');) {} `, }, ], }, ], })), - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -while (x || 'foo') {} +declare let x: ${type} | ${nullish}; +while ((x ||${equals} 'foo')) {} `, output: null, options: [{ ignoreConditionalTests: false }], @@ -501,15 +511,15 @@ while (x || 'foo') {} { messageId: 'preferNullishOverOr', line: 3, - column: 10, + column: 11, endLine: 3, - endColumn: 12, + endColumn: 13 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -while (x ?? 'foo') {} +declare let x: ${type} | ${nullish}; +while ((x ??${equals} 'foo')) {} `, }, ], @@ -520,9 +530,9 @@ while (x ?? 'foo') {} // ignoreMixedLogicalExpressions ...nullishTypeInvalidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; a || b && c; `, options: [{ ignoreMixedLogicalExpressions: false }], @@ -537,9 +547,9 @@ a || b && c; { messageId: 'suggestNullish', output: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; a ?? b && c; `, }, @@ -549,10 +559,10 @@ a ?? b && c; })), ...nullishTypeInvalidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a || b || c && d; `, options: [{ ignoreMixedLogicalExpressions: false }], @@ -567,10 +577,10 @@ a || b || c && d; { messageId: 'suggestNullish', output: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; (a ?? b) || c && d; `, }, @@ -586,10 +596,10 @@ declare const d: ${type} | ${nullish}; { messageId: 'suggestNullish', output: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a || b ?? c && d; `, }, @@ -599,10 +609,10 @@ a || b ?? c && d; })), ...nullishTypeInvalidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a && b || c || d; `, options: [{ ignoreMixedLogicalExpressions: false }], @@ -617,10 +627,10 @@ a && b || c || d; { messageId: 'suggestNullish', output: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a && (b ?? c) || d; `, }, @@ -636,10 +646,10 @@ a && (b ?? c) || d; { messageId: 'suggestNullish', output: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type} | ${nullish}; -declare const c: ${type} | ${nullish}; -declare const d: ${type} | ${nullish}; +declare let a: ${type} | ${nullish}; +declare let b: ${type} | ${nullish}; +declare let c: ${type} | ${nullish}; +declare let d: ${type} | ${nullish}; a && b || c ?? d; `, }, @@ -649,10 +659,10 @@ a && b || c ?? d; })), // should not false positive for functions inside conditional tests - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -if (() => x || 'foo') {} +declare let x: ${type} | ${nullish}; +if (() => (x ||${equals} 'foo')) {} `, output: null, options: [{ ignoreConditionalTests: true }], @@ -660,25 +670,25 @@ if (() => x || 'foo') {} { messageId: 'preferNullishOverOr', line: 3, - column: 13, + column: 14, endLine: 3, - endColumn: 15, + endColumn: 16 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -if (() => x ?? 'foo') {} +declare let x: ${type} | ${nullish}; +if (() => (x ??${equals} 'foo')) {} `, }, ], }, ], })), - ...nullishTypeInvalidTest((nullish, type) => ({ + ...nullishTypeInvalidTest((nullish, type, equals) => ({ code: ` -declare const x: ${type} | ${nullish}; -if (function werid() { return x || 'foo' }) {} +declare let x: ${type} | ${nullish}; +if (function weird() { return (x ||${equals} 'foo') }) {} `, output: null, options: [{ ignoreConditionalTests: true }], @@ -686,15 +696,15 @@ if (function werid() { return x || 'foo' }) {} { messageId: 'preferNullishOverOr', line: 3, - column: 33, + column: 34, endLine: 3, - endColumn: 35, + endColumn: 36 + equals.length, suggestions: [ { messageId: 'suggestNullish', output: ` -declare const x: ${type} | ${nullish}; -if (function werid() { return x ?? 'foo' }) {} +declare let x: ${type} | ${nullish}; +if (function weird() { return (x ??${equals} 'foo') }) {} `, }, ], @@ -704,9 +714,9 @@ if (function werid() { return x ?? 'foo' }) {} // https://github.com/typescript-eslint/typescript-eslint/issues/1290 ...nullishTypeInvalidTest((nullish, type) => ({ code: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type}; -declare const c: ${type}; +declare let a: ${type} | ${nullish}; +declare let b: ${type}; +declare let c: ${type}; a || b || c; `, output: null, @@ -721,9 +731,9 @@ a || b || c; { messageId: 'suggestNullish', output: ` -declare const a: ${type} | ${nullish}; -declare const b: ${type}; -declare const c: ${type}; +declare let a: ${type} | ${nullish}; +declare let b: ${type}; +declare let c: ${type}; (a ?? b) || c; `, }, From 36dc7ce5b3e5486d459c0bfff98410e2ad0e4fd9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 19 Nov 2022 09:46:09 -0500 Subject: [PATCH 76/76] chore: removed eslint@6 fallbacks for rule messages, and a snapshot (#6041) --- packages/eslint-plugin/src/rules/no-invalid-this.ts | 5 +---- packages/eslint-plugin/src/rules/no-unused-expressions.ts | 6 +----- .../eslint-plugin/src/rules/no-useless-constructor.ts | 8 ++------ packages/eslint-plugin/src/rules/quotes.ts | 5 +---- packages/eslint-plugin/src/rules/semi.ts | 6 +----- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-invalid-this.ts b/packages/eslint-plugin/src/rules/no-invalid-this.ts index 36236d0b4af..5cf502a7af9 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-this.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-this.ts @@ -23,10 +23,7 @@ export default createRule({ recommended: false, extendsBaseRule: true, }, - // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 - messages: baseRule.meta.messages ?? { - unexpectedThis: "Unexpected 'this'.", - }, + messages: baseRule.meta.messages, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, }, diff --git a/packages/eslint-plugin/src/rules/no-unused-expressions.ts b/packages/eslint-plugin/src/rules/no-unused-expressions.ts index 96830736f9d..0ad71a47fba 100644 --- a/packages/eslint-plugin/src/rules/no-unused-expressions.ts +++ b/packages/eslint-plugin/src/rules/no-unused-expressions.ts @@ -20,11 +20,7 @@ export default util.createRule({ }, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 - messages: baseRule.meta.messages ?? { - unusedExpression: - 'Expected an assignment or function call and instead saw an expression.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [ { diff --git a/packages/eslint-plugin/src/rules/no-useless-constructor.ts b/packages/eslint-plugin/src/rules/no-useless-constructor.ts index 98fcc9631c5..b83b2706fc8 100644 --- a/packages/eslint-plugin/src/rules/no-useless-constructor.ts +++ b/packages/eslint-plugin/src/rules/no-useless-constructor.ts @@ -54,10 +54,7 @@ export default util.createRule({ }, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 - messages: baseRule.meta.messages ?? { - noUselessConstructor: 'Useless constructor.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [], create(context) { @@ -65,8 +62,7 @@ export default util.createRule({ return { MethodDefinition(node): void { if ( - node.value && - node.value.type === AST_NODE_TYPES.FunctionExpression && + node.value?.type === AST_NODE_TYPES.FunctionExpression && node.value.body && checkAccessibility(node) && checkParams(node) diff --git a/packages/eslint-plugin/src/rules/quotes.ts b/packages/eslint-plugin/src/rules/quotes.ts index 4a23e9632d7..59f718c50ae 100644 --- a/packages/eslint-plugin/src/rules/quotes.ts +++ b/packages/eslint-plugin/src/rules/quotes.ts @@ -21,10 +21,7 @@ export default util.createRule({ }, fixable: 'code', hasSuggestions: baseRule.meta.hasSuggestions, - // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 - messages: baseRule.meta.messages ?? { - wrongQuotes: 'Strings must use {{description}}.', - }, + messages: baseRule.meta.messages, schema: baseRule.meta.schema, }, defaultOptions: [ diff --git a/packages/eslint-plugin/src/rules/semi.ts b/packages/eslint-plugin/src/rules/semi.ts index c6da7c7912e..5fad3f3b395 100644 --- a/packages/eslint-plugin/src/rules/semi.ts +++ b/packages/eslint-plugin/src/rules/semi.ts @@ -22,11 +22,7 @@ export default util.createRule({ fixable: 'code', hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 - messages: baseRule.meta.messages ?? { - missingSemi: 'Missing semicolon.', - extraSemi: 'Extra semicolon.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [ 'always',