-
Notifications
You must be signed in to change notification settings - Fork 128
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
shellcheck: add code actions to disable rule #1069
base: main
Are you sure you want to change the base?
Conversation
Implements bash-lsp#933. Always add a code action to disable a given diagnostic for a given line or for the whole file. This patch handles: * indentation * existing directive. It also sorts the disable directives if any * multi-line command Add corresponding tests. Signed-off-by: Thomas Faivre <[email protected]>
9f94f89
to
dd1f805
Compare
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! Seems like a great starting point. I suggest adding some unit test and the. After that see if we should improve the implementation.
@@ -222,7 +222,7 @@ describe('server', () => { | |||
{} as any, | |||
) | |||
|
|||
expect(result).toHaveLength(1) | |||
expect(result).toHaveLength(3) |
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.
Let us check what all the code actions are about. Consider just doing a snapshot test of the entire result object.
result, | ||
}: { | ||
document: TextDocument | ||
uri: 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.
No reason to pass in the uri if we have the document.
lineNb, | ||
}: { | ||
document: TextDocument | ||
lineNb: number |
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.
Nit: the nb
abbreviation and postfix seems unnecessary.
}) | ||
} | ||
|
||
// TODO: use directives module |
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.
👍
|
||
private static getIndentation(line: string): string { | ||
const match = line.match(/^([\s]*)/) | ||
if (match && match[1]) { |
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.
Probably worth exploring using the AST for this.
@ThomasFaivre are you going to be working on this PR? |
Following my comment in #933, I ended up finishing my draft.
It is now fully functionnal:
Tested with Neovim (NVIM v0.10.0-dev-1846+gf31f260f0).
Therefore, I would like your opinion on the implementation.
I have already spotted some room for improvements:
What do you think?
Thanks!