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

feat(eslint-plugin): [prefer-output-readonly] add suggestion #459

Merged

Conversation

rafaelss95
Copy link
Member

@rafaelss95 rafaelss95 commented May 15, 2021

To be reviewed after #458's merge.

Note that I went with a suggest instead of fix, because if we fix it directly we can break the code since there is no guarantee that @Output property is not being mutated somewhere.

@rafaelss95 rafaelss95 requested a review from JamesHenry May 15, 2021 03:36
@nx-cloud
Copy link

nx-cloud bot commented May 15, 2021

Nx Cloud Report

CI 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

Status Command
#000000 nx run-many --target=build --all --parallel
#000000 nx run-many --target=check-configs --all --parallel
#000000 nx run-many --target=test --all --parallel
#000000 nx run-many --target=typecheck --all --parallel

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',
Copy link
Member

@JamesHenry JamesHenry May 15, 2021

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.

Suggested change
suggestFix: 'Add readonly modifier',
addReadonlyModifier: 'Add readonly modifier',

Copy link
Member

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)

Copy link
Member Author

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.

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@JamesHenry JamesHenry merged commit f3ff789 into angular-eslint:master May 15, 2021
@rafaelss95 rafaelss95 deleted the feat/prefer-output-readonly branch May 15, 2021 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants