Skip to content

Compatibility issue with eslint-plugin-vuejs-accessibility #31

@constgen

Description

@constgen

When I try to use https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility in the config together with eslint-plugin-jsonc something doesn't work as expected. eslint-plugin-vuejs-accessibility utilizes vue-eslint-parser (its peer dependency). Thats why when JSON files are linted it fails with an exception

Oops! Something went wrong! :(

ESLint: 7.18.0

TypeError: Error while loading rule 'vuejs-accessibility/interactive-supports-focus': context.parserServices.defineTemplateBodyVisitor is not a function

The ESLint config is like this (simplified example):

{
  "plugins": [
    "jsonc",
    "vue",
    "vuejs-accessibility"
  ],
  "parser": "vue-eslint-parser",
  "overrides": [
    {
      "files": ["*.json", "*.jsonc", "*.json5", "*.json6"],
      "parser":"jsonc-eslint-parser",
      "rules": {
        "jsonc/auto": "error"
      }
    }
  ],
  "rules": {
     "jsonc/indent": "error",
     "vuejs-accessibility/accessible-emoji": "error",
     // many rules
  }
}

And of course ESLint fails as we have overridden the parser for JSON files

I tried also another approach as Vue Plugin suggest - use "parserOptions.parser"

{
  "plugins": [
    "jsonc",
    "vue",
    "vuejs-accessibility"
  ],
  "parser": "vue-eslint-parser",
  "overrides": [
    {
      "files": ["*.json", "*.jsonc", "*.json5", "*.json6"],
      "parserOprions": {
        "parser":"jsonc-eslint-parser",
      },
      "rules": {
        "jsonc/auto": "error"
      }
    }
  ],
  "rules": {
     "jsonc/indent": "error",
     "vuejs-accessibility/accessible-emoji": "error",
     // many rules
  }
}

Now plugins work. Many core rules are also linted. But jsonc rules are not checked any more. For example "jsonc/indent" errors are not reported.

Expected

One of both

  1. vuejs-accessibility/* rules should not throw when the parser is not vue-eslint-parser and just ignore
  2. All jsonc/* rules are applied when configured with { "parser": "vue-eslint-parser", "parserOprions": { "parser":"jsonc-eslint-parser" } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions