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

linter reports incorrect line number when line contains <template> tag #1794

Closed

Conversation

hmajoros
Copy link
Contributor

@hmajoros hmajoros commented Mar 2, 2023

a continuation of the PRs from yesterday to make more improvements to GJS/GTS linting. This test demonstrates that when a lint error falls on the line containing the <template> tag, the post-process script incorrectly reports the line number / column number as 0:0.

will be pushing a fix shortly

@hmajoros
Copy link
Contributor Author

hmajoros commented Mar 2, 2023

commenting the rough shape of the issue here, mostly to help myself find the optimal solution:

our token extracted via pulling the specific line/column specified in the message will match [__GLIMMER_TEMPLATE(, and when we loop over originalLines regex-ing for token, we never find it because the originalLines still uses <template>, not the placeholder value.

We could easily do something like:

    if (token.includes(util.TEMPLATE_TAG_PLACEHOLDER)) {
      token = util.TEMPLATE_TAG_NAME;
    }

but this would then break if a template had multiple instances of <template> in the same component, because the loop function would eagerly catch the first instance of <template> for every template in the file, and we'd get all lint errors mapped onto one line.

This problem isn't specific just to the <template> issue, however: this should be generalized for any case where you may encounter the same token in multiple lint rules, and need to handle mapping them to different locations.

@hmajoros
Copy link
Contributor Author

hmajoros commented Mar 2, 2023

I am going to follow up with a fix for multiple template tags / tokens in the same file coming in a different PR

@hmajoros
Copy link
Contributor Author

hmajoros commented Mar 2, 2023

closing in favor of larger refactor effort: #1795

@hmajoros hmajoros closed this Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant