-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new rule: no-duplicate-spread-property (#185)
- Loading branch information
Showing
15 changed files
with
677 additions
and
0 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
baselines/packages/mimir/test/no-duplicate-spread-property/default/test.ts.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
export {}; | ||
|
||
declare function get<T>(): T; | ||
|
||
declare class WithMethods { | ||
foo(): void; | ||
bar: () => void; | ||
baz: string; | ||
} | ||
|
||
const foo = 'foo'; | ||
|
||
({ | ||
x: 1, | ||
~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...{x: 2, y: 2}, | ||
~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
y: 1, | ||
...{x: 3}, | ||
}); | ||
|
||
({ | ||
foo, | ||
~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...{foo}, | ||
}); | ||
|
||
({ | ||
[foo]: 1, | ||
~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...{[foo]: 2}, | ||
}); | ||
|
||
({ | ||
'__@iterator': 1, | ||
[Symbol.iterator]: 1, | ||
~~~~~~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...{[Symbol.iterator]: 2}, | ||
}); | ||
|
||
({ | ||
[get<string>()]: 1, | ||
...{[get<string>()]: 2}, | ||
}); | ||
|
||
({ | ||
[get<'foo'>()]: 1, | ||
...{[get<'foo'>()]: 2}, | ||
~~~~~~~~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...{[foo]: 3}, | ||
}); | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
baz: 1, | ||
~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...get<{foo?: string, bar: number, baz: boolean | undefined}>(), | ||
}); | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
baz: 1, | ||
bas: 1, | ||
...get<{foo: string, bar: number, bas: number} | {bar: number, baz: boolean, bas?: number}>(), | ||
...Boolean() && {foo}, | ||
}); | ||
|
||
{ | ||
let a, b; | ||
({[foo]: a, foo: b, ...{}} = get<{foo: string}>()); | ||
} | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
baz: 1, | ||
~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...get<WithMethods>(), | ||
}); | ||
|
||
({ | ||
foo() {}, | ||
bar: () => {}, | ||
~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
baz: get<() => void>(), | ||
~~~~~~~~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...get<WithMethods>(), | ||
}); | ||
|
||
({ | ||
foo() {}, | ||
~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
bar: () => {}, | ||
~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
baz: get<() => void>(), | ||
~~~~~~~~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
...get<{foo(): void, bar: () => void, baz: number}>(), | ||
}); | ||
|
||
({ | ||
...get<WithMethods>(), | ||
~~~~~~~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
}); | ||
|
||
({ | ||
...get<{foo: number, bar: number, baz: number}>(), | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [error no-duplicate-spread-property: Property is overridden later.] | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
}); |
101 changes: 101 additions & 0 deletions
101
baselines/packages/mimir/test/no-duplicate-spread-property/loose/test.ts.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
export {}; | ||
|
||
declare function get<T>(): T; | ||
|
||
declare class WithMethods { | ||
foo(): void; | ||
bar: () => void; | ||
baz: string; | ||
} | ||
|
||
const foo = 'foo'; | ||
|
||
({ | ||
x: 1, | ||
...{x: 2, y: 2}, | ||
y: 1, | ||
...{x: 3}, | ||
}); | ||
|
||
({ | ||
foo, | ||
...{foo}, | ||
}); | ||
|
||
({ | ||
[foo]: 1, | ||
...{[foo]: 2}, | ||
}); | ||
|
||
({ | ||
'__@iterator': 1, | ||
[Symbol.iterator]: 1, | ||
...{[Symbol.iterator]: 2}, | ||
}); | ||
|
||
({ | ||
[get<string>()]: 1, | ||
...{[get<string>()]: 2}, | ||
}); | ||
|
||
({ | ||
[get<'foo'>()]: 1, | ||
...{[get<'foo'>()]: 2}, | ||
...{[foo]: 3}, | ||
}); | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
baz: 1, | ||
...get<{foo?: string, bar: number, baz: boolean | undefined}>(), | ||
}); | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
baz: 1, | ||
bas: 1, | ||
...get<{foo: string, bar: number, bas: number} | {bar: number, baz: boolean, bas?: number}>(), | ||
...Boolean() && {foo}, | ||
}); | ||
|
||
{ | ||
let a, b; | ||
({[foo]: a, foo: b, ...{}} = get<{foo: string}>()); | ||
} | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
baz: 1, | ||
...get<WithMethods>(), | ||
}); | ||
|
||
({ | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
...get<WithMethods>(), | ||
}); | ||
|
||
({ | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
...get<{foo(): void, bar: () => void, baz: number}>(), | ||
}); | ||
|
||
({ | ||
...get<WithMethods>(), | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
}); | ||
|
||
({ | ||
...get<{foo: number, bar: number, baz: number}>(), | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
}); |
101 changes: 101 additions & 0 deletions
101
baselines/packages/mimir/test/no-duplicate-spread-property/pre260/test.ts.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
export {}; | ||
|
||
declare function get<T>(): T; | ||
|
||
declare class WithMethods { | ||
foo(): void; | ||
bar: () => void; | ||
baz: string; | ||
} | ||
|
||
const foo = 'foo'; | ||
|
||
({ | ||
x: 1, | ||
...{x: 2, y: 2}, | ||
y: 1, | ||
...{x: 3}, | ||
}); | ||
|
||
({ | ||
foo, | ||
...{foo}, | ||
}); | ||
|
||
({ | ||
[foo]: 1, | ||
...{[foo]: 2}, | ||
}); | ||
|
||
({ | ||
'__@iterator': 1, | ||
[Symbol.iterator]: 1, | ||
...{[Symbol.iterator]: 2}, | ||
}); | ||
|
||
({ | ||
[get<string>()]: 1, | ||
...{[get<string>()]: 2}, | ||
}); | ||
|
||
({ | ||
[get<'foo'>()]: 1, | ||
...{[get<'foo'>()]: 2}, | ||
...{[foo]: 3}, | ||
}); | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
baz: 1, | ||
...get<{foo?: string, bar: number, baz: boolean | undefined}>(), | ||
}); | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
baz: 1, | ||
bas: 1, | ||
...get<{foo: string, bar: number, bas: number} | {bar: number, baz: boolean, bas?: number}>(), | ||
...Boolean() && {foo}, | ||
}); | ||
|
||
{ | ||
let a, b; | ||
({[foo]: a, foo: b, ...{}} = get<{foo: string}>()); | ||
} | ||
|
||
({ | ||
foo: 1, | ||
bar: 1, | ||
baz: 1, | ||
...get<WithMethods>(), | ||
}); | ||
|
||
({ | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
...get<WithMethods>(), | ||
}); | ||
|
||
({ | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
...get<{foo(): void, bar: () => void, baz: number}>(), | ||
}); | ||
|
||
({ | ||
...get<WithMethods>(), | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
}); | ||
|
||
({ | ||
...get<{foo: number, bar: number, baz: number}>(), | ||
foo() {}, | ||
bar: () => {}, | ||
baz: get<() => void>(), | ||
}); |
Oops, something went wrong.