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

Rule proposal: require node:assert/strict #2420

Closed
electrovir opened this issue Aug 5, 2024 · 5 comments
Closed

Rule proposal: require node:assert/strict #2420

electrovir opened this issue Aug 5, 2024 · 5 comments
Labels

Comments

@electrovir
Copy link
Sponsor

electrovir commented Aug 5, 2024

Description

The built-in Node.js node:assert module is considered "legacy" and node:assert/strict is the non-legacy module. See the docs here: https://nodejs.org/api/assert.html#legacy-assertion-mode.

In particular, those docs note that the legacy node:assert module may produce unexpected, rather absurd, results.

Fail

import assert from 'node:assert'
import assert from 'assert'

Pass

import assert from 'node:assert/strict'
import assert from 'assert/strict'

Proposed rule name

prefer-node-assert-strict, prefer-strict-node-assert, prefer-strict-node-assert-module, prefer-strict-node-import

Additional Info

No response

@sindresorhus
Copy link
Owner

This would probably be better suited for https://github.com/eslint-community/eslint-plugin-n

@electrovir
Copy link
Sponsor Author

Looks like the original eslint-plugin-node repo even has a ticket about it: mysticatea/eslint-plugin-node#218

@electrovir
Copy link
Sponsor Author

electrovir commented Aug 5, 2024

While I don't see a strictly followed conceptual split between this plugin and eslint-plugin-n, I can guess where that split would be, and I agree this rule makes sense in there. If you prefer this proposal to be in eslint-plugin-n I can open an issue there.

@sindresorhus
Copy link
Owner

If you prefer this proposal to be in eslint-plugin-n I can open an issue there.

👍

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2024
@electrovir
Copy link
Sponsor Author

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

No branches or pull requests

2 participants