-
Notifications
You must be signed in to change notification settings - Fork 666
Conversation
We should probably have a guide on proper error message style and conventions. For now, how about we imitate ESLint?
|
I copy from here, https://github.com/rome/tools/blob/archived-js/website/src/docs/lint/rules/js/noDebugger.md
|
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 this contribution. For the Rome linter we aim to have as many rules as possible coming with automated fixes, Could you add a code action to the rule along with the diagnostic ?
Unfortunately the analyzer is still in a very early stage and it's missing many helpers around mutating syntax trees, in this case the fix means removing the debugger statement from it's parent node but I think that might need to be handled through a new helper function to either splice it out from the parent statement list or replace it with an empty statement in the if(cond) debugger
case for instance
I just found ESlint doesn't have a code action, so I keep the code action as is, which a None. If we want to port other rule, how could I know if it has a code action or not? |
In #2642 I tried to reference rules that have an auto-fix available when possible, so for instance the source for the |
It seems pub fn replace_node<N>(self, prev_node: N, next_node: N) -> Option<Self>
where
N: AstNode<Language = Self::Language>,
Self: Sized, |
You can use the |
ESlint messages are one of the reasons why we pledge to have better error messages. (https://rome.tools/#technical, first bullet point). The Rome classic linter was the most stable feature we had and its messages were reviewed by many people, Sebastian included. I think we should just port the old messages to this new linter rewrite. |
I'm not really clear on why the error message is better. From my perspective it's a little more verbose, but honestly a minor difference. I can go either way. A bigger issue I have is that there's no explanation or context around why this rule exists. With linting, I think it should be pretty important to have an explanation of why we are not allowing something. |
This is a good point! We should always try to explain why we deny something. Care to venture a suggestion? |
This is probably not the best place to discuss this, but besides improving to |
@leops @ematipico Think it's okay to make a discussion for this? I agree there should be a page for each rule with documentation. I'm also a fan of Rust's error index. |
This pull request is ready to merge @ematipico |
@ematipico , what about this one, both of you have been approved this pull request |
* feat: 🎸 feat/(rome_analyze):no-debugger * feat: 🎸 add code action * chore: 🤖 tweak action tetxt * test: 💍 add extra test * test: 💍 should remove debugger statement * style: 💄 fmt * test: 💍 debugger * chore: 🤖 change test * chore: 🤖 fix diff issue * chore: 🤖 merge main * chore: 🤖 fix snapshot
Summary
noDebugger
, part of ☂️ First batch of Linter Rules #2642Test Plan
noDebugger.js
ESlint
, https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-debugger.js