-
-
Notifications
You must be signed in to change notification settings - Fork 735
refactor(linter/plugins): remove | undefined from optional function params types
#15885
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
refactor(linter/plugins): remove | undefined from optional function params types
#15885
Conversation
Merge activity
|
… params types (#15885) `| undefined` in optional function params (e.g. `param?: string | undefined`) is pointless. Remove them.
f870a1a to
b2de90b
Compare
| beforeCount?: number | null | undefined, | ||
| afterCount?: number | null | undefined, | ||
| ): string { | ||
| getText(node?: Ranged | null, beforeCount?: number | null, afterCount?: number | null): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should copy eslint's API and remove | null here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. If ESLint doesn't accept null, then yes I guess we shouldn't either, so that plugins written and tested in Oxlint remain compatible with ESLint. But in a lot of cases, ESLint uses !option to check for defined/undefined, so is very liberal indeed. I think ideally we don't want to do that as truthiness checks are somewhat expensive compared to == null (I believe).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ===undefined is probably faster than ==null i would guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We only use == null where we want to catch either. Wherever possible, we use === undefined or === null.
But if it was me designing a lib, I'd accept either null or undefined to mean "nothing" in all external APIs, and conform the input so we only use null internally.
… params types (#15885) `| undefined` in optional function params (e.g. `param?: string | undefined`) is pointless. Remove them.

| undefinedin optional function params (e.g.param?: string | undefined) is pointless. Remove them.