Skip to content
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

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

Closed
mgzenitech opened this issue Jul 15, 2024 · 14 comments · Fixed by #16 or #17
Closed

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

mgzenitech opened this issue Jul 15, 2024 · 14 comments · Fixed by #16 or #17

Comments

@mgzenitech
Copy link
Contributor

mgzenitech commented Jul 15, 2024

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()}`"
  }
]
@mgzenitech mgzenitech changed the title Example on how to set error id in format? Example on how to set rule id in format? Jul 15, 2024
@tamayika
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

there's also question for you in dotenv-linter/dotenv-linter#803

@tamayika
Copy link
Owner

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

tamayika added a commit that referenced this issue Jul 16, 2024
* move to quickjs-emscripten from jexpr
tamayika added a commit that referenced this issue Jul 16, 2024
tamayika added a commit that referenced this issue Jul 16, 2024
[#15] support capturing by user defined plalaceholders
@tamayika
Copy link
Owner

tamayika commented Jul 16, 2024

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
Copy link
Contributor Author

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

@mgzenitech
Copy link
Contributor Author

@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
Copy link
Contributor Author

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

@tamayika
Copy link
Owner

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 tamayika reopened this Jul 16, 2024
@tamayika
Copy link
Owner

Blockers:
microsoft/vscode#130367
microsoft/vscode-loader#57

@ccoVeille
Copy link

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
Copy link
Contributor Author

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

@tamayika
Copy link
Owner

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

tamayika added a commit that referenced this issue Jul 17, 2024
tamayika added a commit that referenced this issue Jul 17, 2024
[#15] run quickjs in worker threads
@tamayika
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants