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

"react/jsx-no-undef" rule ignores "globals" setting. #1115

Open
DusanDimitric opened this issue Apr 23, 2018 · 8 comments

Comments

@DusanDimitric
Copy link

commented Apr 23, 2018

Hi, I'm using standard with react-native and babel-plugin-jsx-control-statements.

Standard version: v11.0.1

Problem

standard shows errors for babel-plugin-jsx-control-statements globals such as If, Choose etc. even though they're declared in package.json standard.globals and the babel-plugin-jsx-control-statements is specified in .babelrc (as seen below)

file: package.json
...
  "standard": {
    "parser": "babel-eslint",
    "globals": [
      "describe",
      "test",
      "it",
      "jest",
      "beforeAll",
      "beforeEach",
      "afterAll",
      "afterEach",
      "expect",
      "fetch",
      "navigator",
      "__DEV__",
      "XMLHttpRequest",
      "FormData",
      "React$Element",
      "If",
      "Choose",
      "When",
      "Otherwise",
      "For",
      "With"
    ]
  }
...
file: .babelrc
...
  "plugins": [
    "jsx-control-statements"
  ],
...

Example output

$ standard --verbose | snazzy
...
  36:14  error  'Choose' is not defined     react/jsx-no-undef
  37:16  error  'When' is not defined       react/jsx-no-undef
  40:16  error  'Otherwise' is not defined  react/jsx-no-undef
  45:12  error  'Choose' is not defined     react/jsx-no-undef
  46:14  error  'When' is not defined       react/jsx-no-undef
  49:14  error  'Otherwise' is not defined  react/jsx-no-undef
  53:12  error  'Choose' is not defined     react/jsx-no-undef
  54:14  error  'When' is not defined       react/jsx-no-undef
  57:14  error  'Otherwise' is not defined  react/jsx-no-undef
...

Expected behavior

standard should not throw react/jsx-no-undef errors for variables declared in package.json > standard.globals:

      "If",
      "Choose",
      "When",
      "Otherwise",
      "For",
      "With"

I've seen this line in the CHANGELOG.md:

Fix jsx-no-undef will not check the global scope by default.

But I guess it doesn't relate to this case.

Let me know if I can provide any more details.
Thanks a lot,
D.D.

@DusanDimitric

This comment has been minimized.

Copy link
Author

commented Apr 23, 2018

@DusanDimitric

This comment has been minimized.

Copy link
Author

commented Apr 23, 2018

Can this react/jsx-no-undef rule be changed so it reads the globals declared in package.json in any way ?

@feross feross closed this Apr 26, 2018

@feross feross reopened this Apr 26, 2018

@feross

This comment has been minimized.

Copy link
Member

commented Apr 26, 2018

@DusanDimitric Yep, we can include this in the next release.

@feross feross added this to the standard v12 milestone Apr 26, 2018

@DusanDimitric

This comment has been minimized.

Copy link
Author

commented Apr 26, 2018

Thanks ;)

@feross

This comment has been minimized.

Copy link
Member

commented Apr 30, 2018

I'm going to leave this issue open so that I remember to include this in the next release.

@feross feross reopened this Apr 30, 2018

@stale

This comment has been minimized.

Copy link

commented Jul 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Jul 29, 2018

@stale stale bot closed this Aug 5, 2018

@bovas85

This comment has been minimized.

Copy link

commented Sep 27, 2018

I can see it's still giving an error here, can we please check this?

@ForkInSpace

This comment has been minimized.

Copy link

commented Nov 4, 2018

I second this ^

@lock lock bot locked as resolved and limited conversation to collaborators Feb 2, 2019

@standard standard unlocked this conversation Aug 5, 2019

@feross feross modified the milestones: standard v12, standard v14 Aug 5, 2019

@feross feross reopened this Aug 5, 2019

@stale stale bot removed the stale label Aug 5, 2019

@feross feross added the accepted label Aug 5, 2019

@feross feross modified the milestones: standard 14, standard 15 Aug 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.