tamayika / vscode-any-lint

VSCode Any Lint allows you to lint any files with any command line tools
Other
4 stars 2 forks source link

Register specific diagnostic run actions with "Fix All" action? #27

Open mgzenitech opened 1 month ago

mgzenitech commented 1 month ago

Would it be possible to register specific diagnostic run actions with "Fix All" action?

Screenshot from 2024-07-22 09-20-47

Most of the linter extensions integrate well with that.

For example:

          {
            "args": [
              "`fix`",
              "`-q`",
              "`--no-backup`",
              "$.file"
            ],
            "binPath": "`dotenv-linter`",
            "cwd": "$.workspaceFolder",
            "lintAfterRun": "true",
            "title": "`Fix all fixable problems`",
            "type": "run"
          }

I'd like this to get called when calling Fix All action. In addition then there's a way to setup VSCode to automatically fix all linting issues on save.

Or exposing some diagnostic run actions would also work, for example how ESLint does that in addition to normal integration: Screenshot from 2024-07-22 09-25-52

tamayika commented 1 month ago

Maybe you should use this extension for custom command. https://marketplace.visualstudio.com/items?itemName=edonet.vscode-command-runner

mgzenitech commented 1 month ago

Maybe you should use this extension for custom command. https://marketplace.visualstudio.com/items?itemName=edonet.vscode-command-runner

What's the id for linter diagnostic run action? because I have another extension which allows calling internal VSCode actions.

For example that's how I call other extension action:

  "runOnSave.commands": [
    {
      "async": false,
      "commandBeforeSaving": "stylelint.executeAutofix",
      "match": ".*\\.css$",
      "runIn": "vscode"
    }
  ],

stylelint.executeAutofix is command id.

In VSCode actions list I see run action but not sure if that's the one to call or even how to use it to trigger my command Screenshot from 2024-07-22 15-04-40

tamayika commented 1 month ago

It's not intended to run internal command from another extension.

How about adding one more linter before actual linter if you want to implement auto fix on save?

{
  "any-lint.linters": [
    {
      "name": "dot-env auto fix",
      "condition": "$.fileExtname == '.env'",
      "args": [
        "fix",
        "-q",
        "--no-backup",
        "${file}"
      ],
      "binPath": "dotenv-linter",
      "cwd": "${workspaceFolder}",
      "on": [
        "save"
      ]
    },
    {
      // same as dot-env example
    }
  ]
}
mgzenitech commented 1 week ago

It's not intended to run internal command from another extension.

How about adding one more linter before actual linter if you want to implement auto fix on save?

{
  "any-lint.linters": [
    {
      "name": "dot-env auto fix",
      "condition": "$.fileExtname == '.env'",
      "args": [
        "fix",
        "-q",
        "--no-backup",
        "${file}"
      ],
      "binPath": "dotenv-linter",
      "cwd": "${workspaceFolder}",
      "on": [
        "save"
      ]
    },
    {
      // same as dot-env example
    }
  ]
}

Yeah, I could just call the command directly but wouldn't it be nicer and somehow more native to be able to integrate actions with source.fixAll.any-lint ? Interface could be just by adding additional property, like "asFixAll": true ?

          {
            "args": [
              "`fix`",
              "`-q`",
              "`--no-backup`",
              "$.file"
            ],
            "binPath": "`dotenv-linter`",
            "cwd": "$.workspaceFolder",
            "lintAfterRun": "true",
            "title": "`Fix all fixable problems`",
            "type": "run",
            "asFixAll": true,
          }

Or at least have ability to call them directly, set shortcuts, etc

any-lint.dotenv-linter.action.(some id that people can add to actions)