vuejs / vue-eslint-parser

The ESLint custom parser for `.vue` files.
MIT License
435 stars 74 forks source link

Parser fails on TemplateLiteral in object property in VExpressionContainer #187

Closed levchak0910 closed 1 year ago

levchak0910 commented 1 year ago

Before You File a Bug Report Please Confirm You Have Done The Following...

What version of ESLint are you using?

8.15.0

What version of eslint-plugin-vue and vue-eslint-parser are you using?

What did you do?

Configuration = fork of eslint-plugin-vue

Trying to get a correct parsed result

<template>
  <div :class="{`some`: true}" /> <!-- backticks! -->
</template>

What did you expect to happen?

I expect to see a child ObjectExpression with Property[name=some][type=TemplateLiteral] in VExpressionContainer

What actually happened?

I see null in an expression of VExpressionContainer

here is a screen of astexplorer version of vue-eslint-parser is 7.6.0 there, but the parsing result is the same for 9.1.1 image

Link to Minimal Reproducible Example

module.exports = {
  meta: {
    type: 'problem',
    fixable: null,
    schema: [],
  },
  /** @param {RuleContext} context */
  create(context) {
    return utils.defineTemplateBodyVisitor(context, {
      VAttribute(node) {
        console.log(node.value.expression) // = null
      },
    })
  },
}

Additional comments

let me know if a reproducible repository is anyway needed

levchak0910 commented 1 year ago

Seems I am wrong It is not possible to create object with keys as template literal

const b = {
  `some`: true,
}

> Uncaught SyntaxError: Unexpected template string