-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
feat: support TypeScript syntax in default-param-last
#19431
base: main
Are you sure you want to change the base?
feat: support TypeScript syntax in default-param-last
#19431
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
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.
Thanks for getting this started. I left some points of clarification.
With regards to documentation, I think it would be good to add some code examples showing TypeScript.
I'm also wondering if maybe we should add something into meta
indicating that this rule is TypeScript-aware?
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
@@ -14,7 +27,8 @@ module.exports = { | |||
description: "Enforce default parameters to be last", | |||
recommended: false, | |||
frozen: true, | |||
url: "https://eslint.org/docs/latest/rules/default-param-last" | |||
url: "https://eslint.org/docs/latest/rules/default-param-last", | |||
typescript: "syntax" |
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'm also wondering if maybe we should add something into
meta
indicating that this rule is TypeScript-aware?
I found this to be a surprisingly difficult design question. The property needs to indicate:
- It does support TypeScript syntax
- It doesn't support TypeScript types
...and I couldn't figure out any nice succinct single-word property names for this. Using typescript: "syntax"
here explicitly tells folks it's only syntax, not types. It leaves an option for custom parsers like tseslint to later put in "types"
too, maybe. But I'm not confident in this.
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, yeah. I'll bring it up at the TSC meeting and see what opinions people have.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Starts on #19173.
Updates
default-param-last
to account for TypeScript syntax features as handled in the@typescript-eslint/default-param-last
extension rule:Includes tests equivalent to what the extension rule currently tests that's exclusive to TypeScript. They're in a separate
ruleTesterTypeScript
instance that uses@typescript-eslint/parser
.Is there anything you'd like reviewers to focus on?
Should we also update documentation?