Skip to content

Cannot use no-restricted-syntax with wildcard:nth-child selector #870

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

Closed
mrginglymus opened this issue Apr 9, 2019 · 0 comments · Fixed by #1440
Closed

Cannot use no-restricted-syntax with wildcard:nth-child selector #870

mrginglymus opened this issue Apr 9, 2019 · 0 comments · Fixed by #1440

Comments

@mrginglymus
Copy link

Tell us about your environment

  • ESLint version: 5.12.0
  • eslint-plugin-vue version: 5.2.2
  • Node version: 10.15.0

Firstly, huge thanks for adding the no-restricted-syntax rule. It's proving very useful.

However, I'm having trouble with the following rule

CallExpression[callee.name=interpolate] > :nth-child(3)[value!=true])

This works fine on no-restricted-syntax, but fails on vue/no-restriceted-syntax.

To reproduce, add the following test case to the no-restricted-syntax test:

{
  code: `
    <template>
      <input :value="interpolate(foo, bar, true)">
    </template>`,
  options: [
    {
      'selector': 'CallExpression > :nth-child(3)[value!=true]',
      'message': 'Third argument of interpolate must be true'
    }
  ]
}

What did you expect to happen?
Test would pass

What actually happened?
Test failed:

TypeError: Cannot read property 'length' of undefined
Occurred while linting <input>:1
  at nthChild (node_modules/esquery/esquery.js:256:34)
  at matches (node_modules/esquery/esquery.js:158:25)
  at matches (node_modules/esquery/esquery.js:76:30)
  at Function.matches (node_modules/esquery/esquery.js:103:25)
  at NodeEventGenerator.applySelector (node_modules/vue-eslint-parser/index.js:3272:21)
  at NodeEventGenerator.applySelectors (node_modules/vue-eslint-parser/index.js:3284:22)
  at NodeEventGenerator.enterNode (node_modules/vue-eslint-parser/index.js:3295:14)
  at traverse (node_modules/vue-eslint-parser/index.js:113:13)
  at traverseNodes (node_modules/vue-eslint-parser/index.js:131:5)
  at scriptVisitor.Program:exit.node (node_modules/vue-eslint-parser/index.js:3731:25)

Note that the test passes if the rule is changed to

CallExpression > Literal:nth-child(3)[value!=true]

Thanks again!

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 a pull request may close this issue.

1 participant