Skip to content

[no-use-before-define] import * as React marked as error in TSX/JSX file #2502

@DisappearedStar

Description

@DisappearedStar
  • 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

.eslintrc.js

{
    parser: '@typescript-eslint/parser',
    parserOptions: {
        sourceType: 'module',
        ecmaVersion: 2018,
        ecmaFeatures: {
            jsx: true,
        },
    },
    rules: {
        'no-use-before-define': 'off',
        '@typescript-eslint/no-use-before-define': ['error', {variables: false}],
    }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "esnext",
    "moduleResolution": "node",
    "target": "es5",
    "allowJs": true,
    "importHelpers": true,
    "jsx": "react",
    "experimentalDecorators": true,
    "isolatedModules": true,
    "importsNotUsedAsValues": "error"
  }
}
// foo.tsx

import * as React from 'react';

const App = () => (
    <span>hello</span>
);

Expected Result

No lint errors

Actual Result

foo.tsx 1:13 React was used before it was defined. @typescript-eslint/no-use-before-define

Additional Info

  • AFAICT the error was introduced in 4.0.2-alpha.12 (alpha11 is ok)
  • essentially, in the project I'm involved with every .tsx / .jsx file that contains React import is affected

Versions

package version
@typescript-eslint/eslint-plugin 4.0.2-alpha.15
@typescript-eslint/parser 4.0.2-alpha.15
TypeScript 4.0.2
ESLint 7.8.1
node 10.16.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy