Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tests: add dependency constraints to eslint-plugin tests#5916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 13 commits intomainfromadd-dep-constraints-to-rule-tests
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
4598ca8
tests: add dependency constraints to eslint-plugin tests
bradzacherOct 27, 2022
b4dd439
Update packages/eslint-plugin/tests/rules/non-nullable-type-assertion…
JoshuaKGoldbergNov 13, 2022
27eb35c
Merge branch 'main'
JoshuaKGoldbergNov 13, 2022
ef2105a
yarn format
JoshuaKGoldbergNov 14, 2022
e6ea324
Merge branch 'main' into add-dep-constraints-to-rule-tests
JoshuaKGoldbergNov 14, 2022
3965014
Fix lint issues with formatting
JoshuaKGoldbergNov 14, 2022
6bee109
Remove dependencyConstraints from test cases too
JoshuaKGoldbergNov 14, 2022
7bb7eee
Update snapshots
JoshuaKGoldbergNov 14, 2022
d81c4e4
fix failing test
bradzacherNov 16, 2022
56bd530
revert rule tester change
bradzacherNov 16, 2022
3f684bd
fix(typescript-estree): don't consider a cached program unless it's s…
bradzacherNov 16, 2022
49ebfa1
Merge branch 'fix-using-cached-program-incorrectly' into add-dep-cons…
bradzacherNov 16, 2022
9396b38
Merge branch 'main' into add-dep-constraints-to-rule-tests
bradzacherNov 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,6 +266,9 @@ export { type T, T };
type T = 1;
export type { T, T };
`,
dependencyConstraints: {
typescript: '4.5',
},
errors: [
{
messageId: 'typeOverValue',
Expand All@@ -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',
Expand All@@ -303,6 +309,9 @@ const x = 1;
export type { T, T };
export { x };
`,
dependencyConstraints: {
typescript: '4.5',
},
errors: [
{
messageId: 'singleExportIsType',
Expand All@@ -322,6 +331,9 @@ type T = 1;
const x = 1;
export { type T, x };
`,
dependencyConstraints: {
typescript: '4.5',
},
options: [{ fixMixedExportsWithInlineTypeSpecifier: true }],
errors: [
{
Expand All@@ -340,6 +352,9 @@ export { type T, T };
type T = 1;
export type { T, T };
`,
dependencyConstraints: {
typescript: '4.5',
},
options: [{ fixMixedExportsWithInlineTypeSpecifier: true }],
errors: [
{
Expand All@@ -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: [
{
Expand All@@ -388,6 +406,9 @@ export {
CatchScope as CScope,
} from '@typescript-eslint/scope-manager';
`,
dependencyConstraints: {
typescript: '4.5',
},
options: [{ fixMixedExportsWithInlineTypeSpecifier: true }],
errors: [
{
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 = {
Expand DownExpand Up@@ -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
`
Expand DownExpand Up@@ -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: [
{
Expand All@@ -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: [
{
Expand Down
27 changes: 27 additions & 0 deletionspackages/eslint-plugin/tests/rules/member-ordering.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,9 @@ interface Foo {
}
`,
{
dependencyConstraints: {
typescript: '4.5',
},
code: `
// no accessibility === public
interface Foo {
Expand DownExpand Up@@ -1250,6 +1253,9 @@ class Foo {
f = 1;
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['static-initialization', 'method', 'field'] }],
},
{
Expand All@@ -1260,6 +1266,9 @@ class Foo {
static {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['method', 'field', 'static-initialization'] }],
},
{
Expand All@@ -1270,6 +1279,9 @@ class Foo {
m() {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['field', 'static-initialization', 'method'] }],
},
`
Expand DownExpand Up@@ -4029,6 +4041,9 @@ class Foo {
f = 1;
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['method', 'field', 'static-initialization'] }],
errors: [
{
Expand DownExpand Up@@ -4059,6 +4074,9 @@ class Foo {
static {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['static-initialization', 'method', 'field'] }],
errors: [
{
Expand All@@ -4080,6 +4098,9 @@ class Foo {
m() {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['static-initialization', 'field', 'method'] }],
errors: [
{
Expand All@@ -4101,6 +4122,9 @@ class Foo {
m() {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [{ default: ['field', 'static-initialization', 'method'] }],
errors: [
{
Expand All@@ -4124,6 +4148,9 @@ class Foo {
md() {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [
{ default: ['decorated-method', 'static-initialization', 'method'] },
],
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -499,6 +499,9 @@ class Foo {
static {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [
{
default: {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1694,6 +1694,9 @@ class Foo {
static {}
}
`,
dependencyConstraints: {
typescript: '4.4',
},
options: [
{
default: {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,22 +32,42 @@ interface Test {
'f!': </* a */>(/* 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?: <T>(a?: T) => T };',
"type Test = { readonly ['f']?: <T>(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`
Expand All@@ -56,15 +76,23 @@ interface Test {
interface Test { f<T>(a: T): T }
interface Test { ['f']<T extends {}>(a: T, b: T): T }
interface Test { 'f!'</* a */>(/* 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?<T>(a?: T): T }
type Test = { readonly ['f']?<T>(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: [
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,6 +78,9 @@ class Foo extends Base {
override foo() {}
}
`,
dependencyConstraints: {
typescript: '4.3',
},
options: [{ allow: ['overrideMethods'] }],
},
],
Expand DownExpand Up@@ -206,6 +209,9 @@ class Foo extends Base {
override foo() {}
}
`,
dependencyConstraints: {
typescript: '4.3',
},
errors: [
{
messageId: 'unexpected',
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -536,6 +536,9 @@ type Foo = {
[K in keyof Other]: \`\${K & number}\`;
};
`,
dependencyConstraints: {
typescript: '4.1',
},
options: [{ ignoreTypeIndexes: true }],
errors: [
{
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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: [
Expand DownExpand Up@@ -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,
Expand All@@ -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,
Expand All@@ -471,6 +487,9 @@ ruleTester.run('no-redundant-type-constituents', rule, {
},
{
code: 'type T = `${number}` | string;',
dependencyConstraints: {
typescript: '4.1',
},
errors: [
{
column: 10,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp