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

Example on how to set rule id in format? #15

Closed mgzenitech closed 1 month ago

mgzenitech commented 1 month ago

For example: output from cli: .internal/.src/.env/.0.env:1 SpaceCharacter: The line has spaces around equal sign

format: ${file}:${startLine} ${message}

But SpaceCharacter is ID of rule that I'd like to process in openUri action. Did not find any example how to do it with plain line output parsing and not json. Please advise.

something like: ${file}:${startLine} ${ruleId}: ${message}

Then if I understood correctly use something like:

"actions": [
  {
    "title": "`Open ${$.ruleId} rule document page`",
    "type": "openUri",
    "uri": "`https://dotenv-linter.github.io/#/checks/${$.ruleId.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()}`"
  }
]
tamayika commented 1 month ago

lines format does not support capturing by non reserved key currently. If your linter can emit output with json or yaml format, please try it.

mgzenitech commented 1 month ago

lines format does not support capturing by non reserved key currently. If your linter can emit output with json or yaml format, please try it.

there's only lines format nothing else. Will you add ID support for lines?

mgzenitech commented 1 month ago

there's also question for you in https://github.com/dotenv-linter/dotenv-linter/issues/803

tamayika commented 1 month ago

OK, I will add support capturing by user defined placeholder in the next update.

tamayika commented 1 month ago

I've released 0.3.0 to support user defined placeholders. I don't have an environment to run dotenv-linter but have confirmed by simple echo linter.

{
    "name": "cmd",
    "binPath": "cmd",
    "condition": "$.fileExtname == '.go'",
    "on": [
        "save"
    ],
    "args": [
        "/c",
        "echo",
        "F:\\work\\temp\\proto\\main.go:1 SpaceCharacter: The line has spaces around equal sign",
    ],
    "diagnostic": {
        "output": "stdout",
        "type": "lines",
        "format": "${file}:${startLine} ${ruleId}: ${message}",
        "actions": [
            {
                "type": "openUri",
                "title": "`Open ${$$.ruleId} rule document page`",
                "uri": "`https://dotenv-linter.github.io/#/checks/${$$.ruleId.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()}`"
            }
        ]
    }
}
mgzenitech commented 1 month ago

superb :) once I'm finished with complete config for dotenv-lint I'll add PR for whole example in the folder ;)

mgzenitech commented 1 month ago

@tamayika something's up with new version as in any-lint output I get infinite loop of errors:

Invalid host defined options
TypeError: Invalid host defined options
    at Object.importModuleLoader (/home/marius/.vscode-oss/extensions/tamayika.vscode-any-lint-0.3.0/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.js:1:6461)
    at Ve (/home/marius/.vscode-oss/extensions/tamayika.vscode-any-lint-0.3.0/node_modules/quickjs-emscripten-core/dist/index.js:6:4292)
/home/marius/Documents/Projects/zenitech/prototype-generic-vscode
poetry poe lint:dotenv -f extension-output-tamayika.vscode-any-lint-#1-any-lint

config:

"any-lint.linters": [
    {
      "args": [
        "poe",
        "lint:dotenv",
        "-f",
        "${file}"
      ],
      "binPath": "poetry",
      "condition": "$.fileExtname.endsWith('.env')",
      "cwd": "${workspaceFolder}",
      "diagnostic": {
        "actions": [
          {
            "title": "`Open ${$$.ruleId} rule document page`",
            "type": "openUri",
            // eslint-disable-next-line @stylistic/js/max-len
            "uri": "`https://dotenv-linter.github.io/#/checks/${$$.ruleId.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()}`"
          }
        ],
        "format": "${file}:${startLine} ${message}",
        "output": "stdout"
      },
      "name": "dotenv-linter",
      "on": [
        "change",
        "save"
      ]
    }
  ]
mgzenitech commented 1 month ago

for some reason ${file} resolves to extension-output-tamayika.vscode-any-lint-#1-any-lint now

tamayika commented 1 month ago

Sorry, I found dynamic import error only in vscode production environment. I rollbacked to 0.3.1(the same as 0.2.2). Please be patiant to resolve vscode issue.

tamayika commented 1 month ago

Blockers: https://github.com/microsoft/vscode/issues/130367 https://github.com/microsoft/vscode-loader/pull/57

ccoVeille commented 1 month ago

Wow, these issues are old as hell.

Is there anything you can do to rewrite the way you were trying?

Because I feel like nothing will happen to fix the issues for ages

mgzenitech commented 1 month ago

yeah, if possible somehow to rethink the solution to not wait for these changes then probably the wisest thing would be to it...

tamayika commented 1 month ago

I will investigate if there is a work around in a week.

tamayika commented 1 month ago

I've released 0.3.2 and confirmed it works well in vscode production environment. If you have some trouble in configuration, please re-open this issue.