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

Relax rule: JSX: Consider the global scope when checking for defined Components (react/jsx-no-undef) #1115

Closed
DimiTech opened this issue Apr 23, 2018 · 10 comments
Labels
Milestone

Comments

@DimiTech
Copy link

DimiTech 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.

@DimiTech
Copy link
Author

This Important note seems related:

https://github.com/vkbansal/eslint-plugin-jsx-control-statements#important

@DimiTech
Copy link
Author

DimiTech 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 as completed Apr 26, 2018
@feross feross reopened this Apr 26, 2018
@feross
Copy link
Member

feross 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
@DimiTech
Copy link
Author

Thanks ;)

@feross
Copy link
Member

feross 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
Copy link

stale bot 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 as completed Aug 5, 2018
@bovas85
Copy link

bovas85 commented Sep 27, 2018

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

@ForkInSpace
Copy link

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
@nikonakoneko
Copy link

Any update? :(

@feross feross modified the milestones: standard 15, standard 16 Oct 22, 2020
@feross feross changed the title "react/jsx-no-undef" rule ignores "globals" setting. Relax rule: JSX: Consider the global scope when checking for defined Components Oct 29, 2020
@feross feross changed the title Relax rule: JSX: Consider the global scope when checking for defined Components Relax rule: JSX: Consider the global scope when checking for defined Components (react/jsx-no-undef) Oct 29, 2020
@feross
Copy link
Member

feross commented Oct 29, 2020

Sorry for the delay – this will be fixed in standard 16!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Archived in project
Development

No branches or pull requests

5 participants