Skip to content

Commit dd1f805

Browse files
committed
feat(shellcheck): add code actions to disable rule
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]>
1 parent 29621ff commit dd1f805

File tree

4 files changed

+2274
-69
lines changed

4 files changed

+2274
-69
lines changed

Diff for: server/src/__tests__/server.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe('server', () => {
222222
{} as any,
223223
)
224224

225-
expect(result).toHaveLength(1)
225+
expect(result).toHaveLength(3)
226226
const codeAction = (result as CodeAction[])[0]
227227
expect(codeAction.diagnostics).toEqual([fixableDiagnostic])
228228
expect(codeAction.diagnostics).toEqual([fixableDiagnostic])

Diff for: server/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export default class BashServer {
405405

406406
const codeActions = params.context.diagnostics
407407
.map(({ data }) => codeActionsForUri[data?.id])
408-
.filter((action): action is LSP.CodeAction => action != null)
408+
.flat()
409409

410410
logger.debug(`onCodeAction: found ${codeActions.length} code action(s)`)
411411

0 commit comments

Comments
 (0)