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

Use dev Node to check for unsupported Node builtins in tests #5158

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Jan 15, 2025

Explanation

The n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax, and n/no-unsupported-features/node-builtins ESLint rules ensure that production code is not using features of JavaScript that are unsupported by the expected version of Node. It does this by keeping track of which versions various features will become generally available and failing if the version of Node it sees does not match.

By default, this rule uses engines.node to know which is the "expected version of Node". While that is fine for production code, we use a later version of Node — which is set to the current LTS version — for tests, and therefore we may be allowed to use features that were once experimental in previous versions.

To fix this, this commit overrides the three n/no-unsupported-features/* rules to use the current LTS of Node for tests.

References

Changelog

(N/A)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

The `n/no-unsupported-features/es-builtins`,
`n/no-unsupported-features/es-syntax`, and
`n/no-unsupported-features/node-builtins` ESLint rules ensure that
production code is not using features of JavaScript that are unsupported
by the expected version of Node. It does this by keeping track of which
versions various features will become generally available and failing if
the version of Node it sees does not match.

By default, this rule uses `engines.node` to know which is the "expected
version of Node". While that is fine for production code, we use a later
version of Node — which is set to the current LTS version — for tests,
and therefore we may be allowed to use features that were once
experimental in previous versions.

To fix this, this commit overrides the three
`n/no-unsupported-features/*` rules to use the current LTS of Node for
tests.
@@ -83,6 +85,11 @@ const config = createConfig([
'jest/prefer-lowercase-title': 'warn',
'jest/prefer-strict-equal': 'warn',
},
settings: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mcmire mcmire marked this pull request as ready for review January 15, 2025 21:05
@mcmire mcmire requested a review from a team January 15, 2025 21:06
@mcmire mcmire enabled auto-merge (squash) January 16, 2025 19:18
@mcmire mcmire merged commit 9f36688 into main Jan 16, 2025
117 checks passed
@mcmire mcmire deleted the use-dev-node-for-builtins-rule branch January 16, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants