Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

New rules for linting type declarations #1844

Closed
ghost opened this issue Dec 11, 2016 · 4 comments
Closed

New rules for linting type declarations #1844

ghost opened this issue Dec 11, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 11, 2016

We've been working on lint rules for DefinitelyTyped and most may be of general use. Would you be interested in my making PRs for some of these rules?

Name Description PR
forbidden-types This forbids the Function, Object, Boolean, Number, and String types. These have better alternatives (specific function types, {}, boolean, number, string). #2271
functional-interfaces This prefers type Foo = () => void over interface Foo { (): void; }. #1891
interface-over-type-literal This prefers interface Foo { x: number; } over type Foo = { x: number; }. #1890
no-empty-interface This forbids interface Foo { }. (TypeScript is structurally typed, so this doesn't accomplish anything.) #1889
no-public This forbids the public keyword. This could be an option for member-access to make it forbid instead of mandate. #2247
unified-signatures This prefers `interface Foo { foo(x: number string): void; }overinterface Foo { foo(x: number): void; foo(x: string): void; }`.
void-return This forbids foo(x: void): number but allows foo(x: number): void. This could be joined with forbidden-types. N/A

(dt-header and no-single-declare-module will probably not be useful outside of DefinitelyTyped.)

@nchen63
Copy link
Contributor

nchen63 commented Dec 14, 2016

Name Description
forbidden-types 👍 Integrate into ban rule or rename to ban-type
functional-interfaces 👍 I like it
interface-over-type-literal 👍 I like it
no-empty-interface 👍 I like it
no-public 🤔 I don't see the benefit of this one
unified-signatures How would this work for more complex signatures like interface Foo { foo(x: number, y: boolean): void; foo(x: string, y: SomeInterface): void; }? Would it allow a bad combo like foo(true, "bar")?.
void-return I don't understand why someone would write foo(x: void): number in the first place

@adidahiya
Copy link
Contributor

I don't think the ban rule covers anything in type positions

@nchen63
Copy link
Contributor

nchen63 commented Dec 14, 2016

right, I'll edit the table

@ghost
Copy link
Author

ghost commented Feb 28, 2017

With #2273 this should be done.

@ghost ghost closed this as completed Feb 28, 2017
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants