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

[gjs] Fix bug with regex issues when parsing GLIMMER_TEMPLATE #1793

Merged
merged 4 commits into from
Mar 1, 2023

Conversation

hmajoros
Copy link
Contributor

@hmajoros hmajoros commented Mar 1, 2023

another specific fix from #1659: when a lint error lands on the line containing <template>, we get an error like the following:

SyntaxError: Invalid regular expression: /\b[__GLIMMER_TEMPLATE(`\b/: Unterminated character class
        at new RegExp (<anonymous>)

an easy way to repro this is to enable the lines-between-class-members rule, and put a <template> immediately after another class member.

I wrote a test, which currently is failing with the following message. This should just need some regexp escaping like Krystan mentioned in the original issue. will work on that shortly

 template tag failing test repro
    ✕ should break (12 ms)

  ● template tag failing test repro › should break

    SyntaxError: Invalid regular expression: /\b[__GLIMMER_TEMPLATE(`\b/: Unterminated character class
        at new RegExp (<anonymous>)

      123 |
      124 |     for (const [index, line] of originalLines.entries()) {
    > 125 |       const column = line.search(new RegExp(`\\b${token}\\b`));
          |                                  ^
      126 |       if (column > -1) {
      127 |         originalLineNumber = index + 1;
      128 |         originalColumnNumber = column + 1;

      at lib/preprocessors/glimmer.js:125:34
          at Array.map (<anonymous>)
      at map (lib/preprocessors/glimmer.js:106:20)
      at Linter._verifyWithProcessor (node_modules/eslint/lib/linter/linter.js:1906:16)
      at Linter._verifyWithConfigArray (node_modules/eslint/lib/linter/linter.js:1765:25)
      at Linter.verify (node_modules/eslint/lib/linter/linter.js:1479:65)
      at Linter.verifyAndFix (node_modules/eslint/lib/linter/linter.js:2031:29)
      at verifyText (node_modules/eslint/lib/cli-engine/cli-engine.js:245:48)
      at CLIEngine.executeOnText (node_modules/eslint/lib/cli-engine/cli-engine.js:917:26)
      at ESLint.lintText (node_modules/eslint/lib/eslint/eslint.js:593:23)
      at Object.lintText (tests/lib/rules-preprocessor/gjs-gts-processor-test.js:278:34)

@lin-ll lin-ll added the Bug label Mar 1, 2023
@lin-ll lin-ll changed the title failing test case for regex issues when parsing GLIMMER_TEMPLATE Fix bug with regex issues when parsing GLIMMER_TEMPLATE Mar 1, 2023
@lin-ll lin-ll changed the title Fix bug with regex issues when parsing GLIMMER_TEMPLATE [gjs] Fix bug with regex issues when parsing GLIMMER_TEMPLATE Mar 1, 2023
@lin-ll lin-ll merged commit cc33ece into ember-cli:master Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants