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

Disable rules based on Node.js version #423

Merged
merged 3 commits into from
Feb 13, 2020
Merged

Disable rules based on Node.js version #423

merged 3 commits into from
Feb 13, 2020

Conversation

pvdlg
Copy link
Contributor

@pvdlg pvdlg commented Feb 13, 2020

This PR change how the internal logic works regarding the nodeVersion. Instead of disabling rules by default and enabling them based on the version we now do the opposite.

That allow us to define whatever rules we like regardless of the Node version and then disable some based on the user's node version.

This way we won't have to change anything when we increase the minimum Node version supported by XO !

For XO users it doesn't change anything.

Fix #421

@sindresorhus sindresorhus changed the title Disable rules based on Node version Disable rules based on Node.js version Feb 13, 2020
@sindresorhus sindresorhus merged commit 74b34bf into master Feb 13, 2020
@sindresorhus sindresorhus deleted the node-version branch February 13, 2020 08:42
@sindresorhus
Copy link
Member

Good idea! This is much better.

'10.0.0': 'off'
},
'prefer-named-capture-group': {
'10.0.0': 'off'
Copy link
Member

Choose a reason for hiding this comment

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

I noticed now that this no longer reports when I run XO on https://github.com/avajs/ava (It does with XO 0.26.0)

Its node version target is: "node": ">=10.18.0 <11 || >=12.14.0 <13 || >=13.5.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just tested that with >=10.18.0 <11 || >=12.14.0 <13 || >=13.5.0 the current code turn off only the following rules:

  • node/prefer-global/text-encoder
  • node/prefer-global/text-decoder
  • unicorn/prefer-flat-map
  • node/prefer-promises/dns
  • node/prefer-promises/fs

Maybe you have an outdated version of eslint-config-xo so the rule is not enabled in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also tried to run xo 0.26.0 on the current codebase of https://github.com/avajs/ava and the rule doesn't report.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, weird. I couldn't reproduce it multiple times earlier. Just tried reinstalling node_modules everywhere and now it of course works... Sorry for wasting your time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem! I'd rather spend more time to make sure it works.
Sometimes weird stuff happens with package-lock.json......

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

Successfully merging this pull request may close these issues.

Fix the nodeVersion tests
2 participants