8000 [no-use-before-define] Add option to ignore interfaces · Issue #1262 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

[no-use-before-define] Add option to ignore interfaces #1262

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
avahe-kellenberger opened this issue Nov 26, 2019 · 2 comments
Closed

[no-use-before-define] Add option to ignore interfaces #1262

avahe-kellenberger opened this issue Nov 26, 2019 · 2 comments
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@avahe-kellenberger
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/no-use-before-define": [
        "error",
        {
            classes: true,
            functions: false,
            typedefs: false,
        },
    ]
  }
}
class A implements B {}

interface B {
  a: string
}

Expected Result
No error, since interfaces are hoisted.

Actual Result
'B' was used before it was defined. eslint(@typescript-eslint/no-use-before-define)

Versions

package version
@typescript-eslint/eslint-plugin 2.6.1
@typescript-eslint/parser 2.6.1
TypeScript 3.7.2
ESLint 6.6.0
node 13.2.0
npm 6.12.1
@avahe-kellenberger avahe-kellenberger added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Nov 26, 2019
@bradzacher
Copy link
Member

It's just generally recommended to just not use this rule.
It's got really bad support for TS features across the board, and it doesn't do anything useful that the TS typechecker doesn't already do.

typedefs should cover interface and type declarations, but it doesn't actually do anything (#249), and nobody has bothered to fix it.

The bigger problem here is that the scope analysis is not in a great state, so the rule will never work completely correctly..

that all being said - I won't block anyone that wants to add an option to the rule..

@bradzacher bradzacher added enhancement: plugin rule option New rule option for an existing eslint-plugin rule and removed triage Waiting for team members to take a look labels Nov 26, 2019
etaoins added a commit to seek-oss/eslint-config-seek that referenced this issue Dec 23, 2019
This rule doesn't allow code like this:

```typescript
type MyKey = keyof typeof myRecord;

const myRecord = {
  ...
};
```

There is a typedefs option, but it doesn't work.

Per a typescript-eslint maintainer:

"It's just generally recommended to just not use this rule.

It's got really bad support for TS features across the board, and it
doesn't do anything useful that the TS typechecker doesn't already do."

typescript-eslint/typescript-eslint#1262 (comment)

Co-authored-by: Ryan Cumming <etaoins@gmail.com>
@bradzacher
Copy link
Member

Merging into #1856

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants
0