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

Output a warning if React version is missing in settings #1857

Merged
merged 1 commit into from Jun 28, 2018

Conversation

alexzherdev
Copy link
Contributor

Resolves #1789

This message will appear when running some of the tests. Not sure if that should be avoided.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this seems great.

lib/util/log.js Outdated
*/
function log(message) {
if (!/\=-(f|-format)=/.test(process.argv.join('='))) {
/* eslint-disable no-console */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can use // eslint-disable-next-line no-console here

@kud
Copy link
Contributor

kud commented Aug 22, 2018

Hello.

I've got a little problem with this PR to be frank since I've got it.

Apparently this PR was done because of this #1789 which is in a way really cool.

However, I'm in the opposite situation and I try to keep react always updated (or at least often).

With this PR, it forces me to keep my .eslintrc.js always synchronised with my react version. And I'm pretty sure my team or I will forget to update it in the same time that we update our React version.

The question is so, is it possible in fact to react the version of the react installed via package.json instead of having the need to specify the version in our eslint config file?

@kud
Copy link
Contributor

kud commented Aug 22, 2018

Another idea is to add "latest" as react version. :D

@ljharb
Copy link
Member

ljharb commented Aug 22, 2018

@kud i could see adding a separate option for "detect" (using the "version" as a fallback), which did require('react').version - want to open an issue or PR that adds that?

@ljharb
Copy link
Member

ljharb commented Aug 22, 2018

(Note that it'd have to use process.cwd(), and the resolve package, to get the proper require path)

@alexzherdev
Copy link
Contributor Author

I think I got the "detect" option to work. I found something I didn't expect though: when extending airbnb's config (as opposed to the recommended config from the plugin), there is a version there in context.settings even if you don't set it in .eslintrc. I believe it comes from here https://github.com/airbnb/javascript/blob/02b4eea3452b0ae6da666b01f9da23f26148f5b6/packages/eslint-config-airbnb/rules/react.js#L464
Is this intended? I found this surprising and non-obvious 🤔

@ljharb
Copy link
Member

ljharb commented Sep 10, 2018

Yes, absolutely it's intended.

@alexzherdev
Copy link
Contributor Author

Oh. Is this just the version used at Airbnb?
@ljharb you mentioned elsewhere you would make not specifying the version throw. But then (correct me if I'm wrong) if most of plugin's users use it via extending airbnb, they would never observe that because of this implicit (for them) setting.

@ljharb
Copy link
Member

ljharb commented Sep 10, 2018

Yes, that is true. However, with that behavior, the airbnb config would probably remove that setting.

With "detect", it'd probably use that, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants