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", }, ],