Skip to content
Permalink
Browse files

fix(eslint-plugin): [no-use-before-define] false positive with jsx pr…

…agma reference (#2503)

Fixes #2502
  • Loading branch information
bradzacher committed Sep 6, 2020
1 parent 3b0e58f commit 5afeeab24ad013142f2431750f24e6085d0a6f3a
@@ -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: [
{

0 comments on commit 5afeeab

Please sign in to comment.