-
-
Notifications
You must be signed in to change notification settings - Fork 230
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(eslint-plugin): [prefer-output-readonly] add suggestion #459
feat(eslint-plugin): [prefer-output-readonly] add suggestion #459
Conversation
Nx Cloud ReportCI ran the following commands for commit 317f297. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch Sent with 💌 from NxCloud. |
@@ -19,17 +19,24 @@ export default createESLintRule<Options, MessageIds>({ | |||
messages: { | |||
preferOutputReadonly: | |||
'Prefer to declare `@Output` as readonly since they are not supposed to be reassigned', | |||
suggestFix: 'Add readonly modifier', |
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.
Having it as a suggestion makes sense, thanks! But I don't see any reason not to make the message key descriptive, it is what the eslint docs show in all their examples: https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions
...and allows for multiple suggestions to more easily be provided if applicable.
suggestFix: 'Add readonly modifier', | |
addReadonlyModifier: 'Add readonly modifier', |
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.
(Note the suggestion was just an easy way to add the feedback, it would need to be applied in all locations across multiple files)
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.
Good idea, I went with suggestAddReadonlyModifier
after seeing many cases with the suggest
prefix in @typescript-eslint
repo as https://github.com/typescript-eslint/typescript-eslint/blob/1c1b572c3000d72cfe665b7afbada0ec415e7855/packages/eslint-plugin/src/rules/no-non-null-assertion.ts#L22.
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 a lot!
To be reviewed after #458's merge.
Note that I went with a
suggest
instead offix
, because if we fix it directly we can break the code since there is no guarantee that@Output
property is not being mutated somewhere.