Skip to content
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

[no-use-before-define] False positives after upgrading from 4.0.1 to 4.1.0 #2520

Closed
3 tasks done
EvHaus opened this issue Sep 8, 2020 · 2 comments
Closed
3 tasks done
Labels
duplicate This issue or pull request already exists fix: user error issue was fixed by correcting the configuration / correcting the code

Comments

@EvHaus
Copy link

EvHaus commented Sep 8, 2020

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/no-use-before-define": "error"
  },
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module"
  }
}

Using @typescript-eslint/parser version 4.0.1 the following code works just fine:

import React from 'react';

const Component = () => <div />;

export default Components;

However, after upgrading the parser to 4.1.0, I'm getting this error:

| 1:8  error  'React' was used before it was defined  no-use-before-define
# tsconfig.json
{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "module": "commonjs",
    "lib": ["es2019", "dom"],
    "target": "esnext",
    "jsx": "react",
    "baseUrl": "./",
    "strict": true,
    "paths": {
      "*": [
        "src/*"
        "node_modules/*"
      ]
    },
    "resolveJsonModule": true
  }
}

Expected Result

There should be no error on this file.

Actual Result

ESLint error on:

| 1:8  error  'React' was used before it was defined  no-use-before-define

Versions

package version
@typescript-eslint/parser 4.1.0
TypeScript 4.0.2
ESLint 7.8.1
node 10.17.0
@EvHaus EvHaus added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Sep 8, 2020
@EvHaus
Copy link
Author

EvHaus commented Sep 8, 2020

Looks like this actually affects @typescript-eslint/eslint-plugin and not @typescript-eslint/parser. My apologies.

@bradzacher bradzacher added duplicate This issue or pull request already exists fix: user error issue was fixed by correcting the configuration / correcting the code and removed package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Sep 8, 2020
@bradzacher
Copy link
Member

bradzacher commented Sep 8, 2020

https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code

First answer in the FAQ which you ticked - you're using the wrong rule.

Also this is a duplicate of #2502 - please use the search next time.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists fix: user error issue was fixed by correcting the configuration / correcting the code
Projects
None yet
Development

No branches or pull requests

2 participants