Skip to content
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

ESLint not working on .vue files #9934

Closed
1 task done
joshkent94 opened this issue Mar 28, 2024 · 11 comments · Fixed by #10983
Closed
1 task done

ESLint not working on .vue files #9934

joshkent94 opened this issue Mar 28, 2024 · 11 comments · Fixed by #10983
Labels
defect [core label] eslint ESLint tooling support javascript JavaScript programming language support language An umbrella label for all programming languages syntax behaviors tooling An umbrella label for language tools, linters, formatters, etc typescript TypeScript programming language support vue Vue.js framework support

Comments

@joshkent94
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I have a Vue2 project and ESLint does not provide error warnings for those files despite it providing them for other files e.g .js.

Environment

Zed: v0.128.3 (Zed)
OS: macOS 14.3.1
Memory: 8 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

ESLint and Vue LSP logs are both empty

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

N/A

@joshkent94 joshkent94 added admin read Pending admin review defect [core label] triage Maintainer needs to classify the issue labels Mar 28, 2024
@shahzod-davlatov
Copy link

Same on Zed 0.129.1 (Preview)

Vue3 project

@JosephTLyons JosephTLyons added javascript JavaScript programming language support language An umbrella label for all programming languages syntax behaviors eslint ESLint tooling support vue Vue.js framework support tooling An umbrella label for language tools, linters, formatters, etc typescript TypeScript programming language support and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Mar 29, 2024
@fazulk
Copy link

fazulk commented Apr 24, 2024

Same thing .. last hurdle before i can really use this editor i think

@joshkent94
Copy link
Author

@mrnugget I know you’ve done a lot of work on ESLint, any chance of getting this in as it seems to be in high demand?

mrnugget added a commit that referenced this issue Apr 25, 2024
This fixes #9934 and does two things:

1. It registers ESLint as a secondary language server for Vue.js files
   (`.vue`)
2. It registers ESLint as a _secondary_ (instead of primary) language
   server for TypeScript, JavaScript and TSX.

The second point because I don't see any reason why ESLint should be
registered as a primary language server for these languages. I read
through the code in `project.rs` that uses the primary language server
and I don't think there will be any differences to how it previously
worked.

I also manually tested ESLint support in a Vue.js project, a Next.js
project and a plain old JS project — still works in all three.
@mrnugget
Copy link
Member

PR is here: #10983

I tested it on a brand-new Vue.js project with ESLint in it and it works. Will go out next week Wednesday in the preview release.

mrnugget added a commit that referenced this issue Apr 25, 2024
This fixes #9934 and does two things:

1. It registers ESLint as a secondary language server for Vue.js files
(`.vue`)
2. It registers ESLint as a _secondary_ (instead of primary) language
server for TypeScript, JavaScript and TSX.

The second point because I don't see any reason why ESLint should be
registered as a primary language server for these languages. I read
through the code in `project.rs` that uses the primary language server
and I don't think there will be any differences to how it previously
worked.

I also manually tested ESLint support in a Vue.js project, a Next.js
project and a plain old JS project — still works in all three.

Release Notes:

- Added ESLint support for Vue.js files by starting it as a language
server on `.vue` files.
([#9934](#9934)).
@e6voe9
Copy link

e6voe9 commented May 3, 2024

PR is here: #10983

I tested it on a brand-new Vue.js project with ESLint in it and it works. Will go out next week Wednesday in the preview release.

@mrnugget Just tested it. ESLint works perfectly fine, but just as a linter. It doesn't format the code like it does in .ts and .js files having this configured

"languages": {
  "JavaScript": {
    "formatter": {
      "code_actions": {
        "source.fixAll.eslint": true
      }
    }
  },
  "TypeScript": {
    "formatter": {
      "code_actions": {
        "source.fixAll.eslint": true
      }
    }
  },
  "Vue.js": {
    "formatter": {
      "code_actions": {
        "source.fixAll.eslint": true
      }
    }
  }
}

@mrnugget
Copy link
Member

mrnugget commented May 3, 2024

It does work for me as a formatter. It also works in code_actions_on_format.

screenshot-2024-05-03-13.12.17.mp4

Do you have anything in the logs? ~/Library/Logs/Zed/Zed.log or the language server logs?

@e6voe9
Copy link

e6voe9 commented May 3, 2024

Update

Formatting doesn't work for me in .vue files which have ts errors.

@e6voe9
Copy link

e6voe9 commented May 3, 2024

2024-05-03T13:29:15+02:00 [INFO] starting language servers for TypeScript: typescript-language-server, eslint
2024-05-03T13:29:15+02:00 [WARN] Generic lsp request to node failed: Request textDocument/codeAction failed with message: Cannot read properties of undefined (reading 'disableRuleComment')
2024-05-03T13:29:15+02:00 [ERROR] crates/project/src/project.rs:7009: Request textDocument/codeAction failed with message: Cannot read properties of undefined (reading 'disableRuleComment')
2024-05-03T13:29:15+02:00 [INFO] Language server with id 2 sent unhandled notification eslint/status:
{
  "uri": "*******/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts",
  "state": 1,
  "validationTime": 7
}
2024-05-03T13:29:16+02:00 [INFO] Language server with id 2 sent unhandled notification eslint/status:
{
  "uri": "*******/pages/Cart.vue",
  "state": 1,
  "validationTime": 973
}
2024-05-03T13:29:17+02:00 [INFO] Language server with id 2 sent unhandled notification eslint/status:
{
  "uri": "*******/pages/Cart.vue",
  "state": 1,
  "validationTime": 916
}
2024-05-03T13:29:19+02:00 [INFO] starting language servers for TypeScript: typescript-language-server, eslint
2024-05-03T13:29:19+02:00 [INFO] Language server with id 2 sent unhandled notification eslint/status:
{
  "uri": "*******/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts",
  "state": 1,
  "validationTime": 11
}
2024-05-03T13:29:21+02:00 [WARN] timed out waiting for formatting

This was the moment I saved the file.

@mrnugget
Copy link
Member

mrnugget commented May 3, 2024

Formatting doesn't work for me in .vue files which have ts errors.

Not sure what the exact problem is: should we format when there are errors? (we have other users who want us to disable formatting if there are errors, for example) should eslint format?

@e6voe9
Copy link

e6voe9 commented May 3, 2024

In my opinion code styling rules (eslint lsp) and types (typescript lsp) should work independently. They’re used for different purposes.

For example I want to add new functionality and I don’t wanna waste time writing types if I don’t even know if something is gonna work. In this case I have the situation when I have type errors, but I still would like for my formatter to work properly.

Answering your question: yes, I think eslint should format the file even if there are typescript errors.

@mrnugget
Copy link
Member

mrnugget commented May 3, 2024

Yeah, I'm not even sure whether that's the problem here. In your logs there's this:

2024-05-03T13:29:15+02:00 [WARN] Generic lsp request to node failed: Request textDocument/codeAction failed with message: Cannot read properties of undefined (reading 'disableRuleComment')
2024-05-03T13:29:15+02:00 [ERROR] crates/project/src/project.rs:7009: Request textDocument/codeAction failed with message: Cannot read properties of undefined (reading 'disableRuleComment')

I don't know whether this showed up when you hit save, but if it did, it seems like the code action doesn't work.

Can you reproduce the issue with a fresh Vue.js project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect [core label] eslint ESLint tooling support javascript JavaScript programming language support language An umbrella label for all programming languages syntax behaviors tooling An umbrella label for language tools, linters, formatters, etc typescript TypeScript programming language support vue Vue.js framework support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants