Skip to content

[Feature Request] Expose shellcheck and shfmt as vscode code actions #1395

Description

@lonix1

What is the problem this feature will solve?

Currently: shellcheck is run automatically on document changes, while shfmt is exposed through formatting.

Problems:

  • Makes it difficult to control when these potentially expensive operations run
  • There is unwanted "on-type" behaviour; many prefer on-save instead

What is the feature you are proposing to solve the problem?

Bash IDE should expose both as vscode "Code Actions".

Using array syntax, which preserves ordering:

"[shellscript]": {
  "editor.codeActionsOnSave": [
    "source.fixAll.bash-ide-shfmt",
    "source.fixAll.bash-ide-shellcheck"
  ]
}

Or using object syntax, which exposes fine-grained policies:

"[shellscript]": {
  "editor.codeActionsOnSave": {
    "source.fixAll.bash-ide-shfmt": "explicit",
    "source.fixAll.bash-ide-shellcheck": "explicit"
  }
}

Code actions are the modern approach for this behaviour. Other formatting/linting extensions already work this way, and could be used for guidance (e.g. ESLint, Prettier, ShellCheck).

Implications:

  • Allow vscode settings to control lint/format-on-save behaviour
  • Avoids irritating and unnecessary on-type execution
  • Allow users to enable/disable each operation independently
  • Allow extension to provide both linting and formatting, without requiring the separate ShellCheck extension - one extension instead of two is a major win
  • Follow vscode's modern approach of letting the editor control save-time behaviour rather than hard-coding triggers in extension logic

I've noticed that there are many issues related to settings and overlap between various extensions and tools. This approach would probably address many of them, as it's the recommended modern on-save behaviour in vscode.

References:

What alternatives have you considered?

Multiple extensions, multiple tools, using prettier for formatting, complex vscode settings... a mess.

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions