Skip to content

Empty class breaks eslint for vue/no-restricted-class #2424

Closed
@ibrahimBeladi

Description

@ibrahimBeladi

When we have an empty class with no ="" in the deceleration, like in

<template>
    <span class>Hello</span>
</template>

with vue/no-restricted-class being warn or error, then it breaks the ESLint job/process

After running yarn eslint src/your-file.vue:

Oops! Something went wrong! :(

ESLint: 8.57.0

TypeError: Cannot read properties of null (reading 'value')
Occurred while linting path-to-file.vue:1
Rule: "vue/no-restricted-class"
    at VAttribute[directive=false][key.name="class"] (/project-path/node_modules/eslint-plugin-vue/lib/rules/no-restricted-class.js:136:44)
    at EventEmitter.emit (node:events:513:28)
    at NodeEventGenerator.applySelector (/project-path/node_modules/vue-eslint-parser/index.js:4373:26)
    at NodeEventGenerator.applySelectors (/project-path/node_modules/vue-eslint-parser/index.js:4387:22)
    at NodeEventGenerator.enterNode (/project-path/node_modules/vue-eslint-parser/index.js:4395:14)
    at traverse (/project-path/node_modules/vue-eslint-parser/index.js:165:13)
    at traverse (/project-path/node_modules/vue-eslint-parser/index.js:172:21)
    at traverse (/project-path/node_modules/vue-eslint-parser/index.js:177:13)
    at traverse (/project-path/node_modules/vue-eslint-parser/index.js:172:21)
    at traverseNodes (/project-path/node_modules/vue-eslint-parser/index.js:183:5)
error Command failed with exit code 2.

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.57.0
  • eslint-plugin-vue version: 9.22.0
  • Vue version: 2.7.16
  • Node version: v18.14.0 (with npm 9.3.1)
  • Operating System: Linux Mint

Please show your full configuration:

module.exports = {
  extends: ['plugin:vue/recommended'],

  rules: {
    'vue/no-restricted-class': ['error', '/^(m|p)(l|r)-/']
  }
};

What did you do?

<template>
    <span class>Hello</span>
</template>

What did you expect to happen?
ESLint continues

What actually happened?
ESLint breaks

Repository to reproduce this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions