Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix(eslint-plugin): [no-use-before-define] false positive with jsx pr…
- Loading branch information
|
@@ -258,7 +258,7 @@ export default util.createRule<Options, MessageIds>({ |
|
|
reference.init || |
|
|
!variable || |
|
|
variable.identifiers.length === 0 || |
|
|
(variable.identifiers[0].range[1] < reference.identifier.range[1] && |
|
|
(variable.identifiers[0].range[1] <= reference.identifier.range[1] && |
|
|
!isInInitializer(variable, reference)) || |
|
|
!isForbidden(variable, reference) |
|
|
) { |
|
|
|
@@ -290,6 +290,59 @@ enum Foo { |
|
|
`, |
|
|
options: [{ enums: false }], |
|
|
}, |
|
|
// https://github.com/typescript-eslint/typescript-eslint/issues/2502 |
|
|
{ |
|
|
code: ` |
|
|
import * as React from 'react'; |
|
|
|
|
|
<div />; |
|
|
`, |
|
|
parserOptions: { |
|
|
sourceType: 'module', |
|
|
ecmaFeatures: { |
|
|
jsx: true, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
code: ` |
|
|
import React from 'react'; |
|
|
|
|
|
<div />; |
|
|
`, |
|
|
parserOptions: { |
|
|
sourceType: 'module', |
|
|
ecmaFeatures: { |
|
|
jsx: true, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
code: ` |
|
|
import { h } from 'preact'; |
|
|
|
|
|
<div />; |
|
|
`, |
|
|
parserOptions: { |
|
|
sourceType: 'module', |
|
|
jsxPragma: 'h', |
|
|
ecmaFeatures: { |
|
|
jsx: true, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
code: ` |
|
|
const React = require('react'); |
|
|
|
|
|
<div />; |
|
|
`, |
|
|
parserOptions: { |
|
|
ecmaFeatures: { |
|
|
jsx: true, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
], |
|
|
invalid: [ |
|
|
{ |
|
|