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

TypeError: Cannot read property 'message' of undefined #42

Open
EvgenyOrekhov opened this issue Mar 9, 2021 · 7 comments
Open

TypeError: Cannot read property 'message' of undefined #42

EvgenyOrekhov opened this issue Mar 9, 2021 · 7 comments

Comments

@EvgenyOrekhov
Copy link

I think this error appeared when I upgraded ember-template-lint to v3.

@jakebixbyavalara
Copy link

@jaydgruber also ran into this recently with the upgrade. He is locked out of his github account for the moment, so he asked me to post here, but it appears the issue is due to the TaggedTemplateExpression not using an async function.

// https://github.com/ember-template-lint/eslint-plugin-hbs/blob/master/lib/rules/check-hbs-template-literals.js#L73
      TaggedTemplateExpression: (node) => { // I think this needs to be an async function
        if (node.tag.name === 'hbs') {
          if (node.quasi.type === 'TemplateLiteral') {
            let hbs = node.quasi.quasis[0].value.cooked
            hbs = unindentAndStripSafeNewlines(hbs)
            const results = linter.verify({source: hbs.toString(), moduleId: context.id}) // and I think this needs to await
            if (results.length !== 0) {
              // If I log from here, `results = Promise { <pending> }`
              // so even though it has a length, `results[0] = undefined`
              const firstLine = results[0].message.split('\n')[0]
              const msg = `${results.length} error(s): ${firstLine}`
              context.report(node, msg)
            }
          }
        }
      },

@rwjblue
Copy link
Member

rwjblue commented Mar 10, 2021

Yeah, the issue is that I don't think ESLint allows async here 🤔

@lifeart
Copy link

lifeart commented Mar 10, 2021

@rwjblue wondering, should we add verifySync with filtering on async rules?

@rwjblue
Copy link
Member

rwjblue commented Mar 10, 2021

Ya probably :(

@dfreeman
Copy link

dfreeman commented Jun 1, 2021

This seems to have broken template lint integration with non-unstable ELS (embertooling.vscode-ember):

(node:77599) UnhandledPromiseRejectionWarning: TypeError: errors.map is not a function
    at TemplateLinter.<anonymous> (/Users/dfreeman/.vscode/extensions/embertooling.vscode-ember-0.2.1/node_modules/@emberwatch/ember-language-server/lib/template-linter.js:38:38)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/dfreeman/.vscode/extensions/embertooling.vscode-ember-0.2.1/node_modules/@emberwatch/ember-language-server/lib/template-linter.js:4:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Sticking a console.log in there, I can see errors is a pending promise rather than an array.

(I realize that's not directly related to eslint-plugin-hbs, but this seems to be where the relevant conversation has landed)

@lifeart
Copy link

lifeart commented Jun 1, 2021

@dfreeman embertooling.vscode-ember is not really supported, consider Unstable LS as Stable

@amk221
Copy link

amk221 commented Apr 21, 2022

What's the situation with this? I've had 'hbs/check-hbs-template-literals': 'off' for a while now and eager to get it back on

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

No branches or pull requests

6 participants