Skip to content

Commit

Permalink
new rule: no-duplicate-spread-property (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff authored Apr 26, 2018
1 parent f22efda commit 4e5183b
Show file tree
Hide file tree
Showing 15 changed files with 677 additions and 0 deletions.
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>(),
});
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>(),
});
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>(),
});
Loading

0 comments on commit 4e5183b

Please sign in to comment.