ota-meshi/eslint-plugin-astro

ESLint Prettier and Astro Configuration Causes Error with Quick Fix Code Action

miller-productions opened this issue · 1 comments

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

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

8.40.0

What version of eslint-plugin-astro are you using?

0.26.2

What did you do?

Configuration: .eslintrc.cjs
module.exports = {
  extends: [
    "plugin:astro/recommended",
    "plugin:prettier/recommended",
  ],
  // ...
  overrides: [
    {
      // Define the configuration for `.astro` file.
      files: ["*.astro"],
      // Allows Astro components to be parsed.
      parser: "astro-eslint-parser",
      // Parse the script in `.astro` as TypeScript by adding the following configuration.
      // It's the setting you need when using TypeScript.
      parserOptions: {
        parser: "@typescript-eslint/parser",
        extraFileExtensions: [".astro"],
      },
      rules: {
        // override/add rules settings here, such as:
        // "astro/no-set-html-directive": "error"
      },
    },
    // ...
  ],
};

<!-- Paste your code here -->

What did you expect to happen?

Configuring VSCode ESLint to use plugin:astro/recommended along with plugin:prettier/recommended would work in .astro files.

Steps to demonstrate:

  1. Configure a basic astro project repo
  2. Install VSCode extensions:
  1. Install devDependecies:
    "@typescript-eslint/eslint-plugin": "^5.59.2",
    "@typescript-eslint/parser": "^5.59.2",
    "eslint": "^8.40.0",
    "eslint-plugin-astro": "^0.26.2",
    "eslint-plugin-prettier": "^4.2.1",
    "prettier": "^2.8.8"
  1. In a .astro file, cause something that breaks a Prettier rule, VSCode should show a Problem (underlined in red)
  2. Hover over the underlined problem.

Expected Result

  • VSCode should pop up a window with explanation of the eslint(prettier) problem plus a Quick Fix code action option that you could click on to auto fix the problem

What actually happened?

Actual Result

  1. Open the Output console in VSCode and switch to see ESLint output.
  2. Observe that when you hover over the underlined problem, an error occurs and no Quick Fix code action is available.

Error message displayed is:

[Error - 8:19:40 PM] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Invalid regular expression: //** eslint-disable-next-line/: Nothing to repeat
  Code: -32603 

Link to Minimal Reproducible Example

Apologies, I don't have one yet. I can try to create one if needed.

Additional comments

This error does not trigger in other filetypes. i.e. try the same thing on a .js file or a .ts file, no issue occurs - it works as expected. It is just with .astro files that this occurs.

Just ran another more detailed check.

Turns out the issue appears to be with astro-eslint-parser, not with eslint-plugin-astro.

I'll close this issue for now and re-open one over in astro-eslint-parser