zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.58k stars 3.04k forks source link

ESLINT Not working #17923

Closed wilson-salonkee closed 1 month ago

wilson-salonkee commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Hello,

Some coworkers in my company started using Zed a bit (to test it out) and they recommended me to give it a shot (even though there are still a lot of features missing).

After installing it and giving it a try, I noticed that ESLINT is not working... In your documentation it says that I should work out of the box if we have a eslint file in the project. The comparaison with vscode is in the screenshot bellow.

There are not really steps to follow as some other people I know it just works for them...

My config looks like this:

{
  "base_keymap": "VSCode",
  "ui_font_size": 16,
  "buffer_font_size": 16,
  "ui_font_family": "JetBrains Mono",
  "terminal": {
    "font_family": "MesloLGS NF",
    "font_size": 14,
    "shell": "system",
    "font_weight": 700,
    "line_height": "standard"
  },
  "theme": {
    "mode": "system",
    "light": "Atelier Lakeside Dark",
    "dark": ""
  },
  "lsp": {
    "eslint": {
      "settings": {
        "problems": {
          "shortenToSingleLine": true
        }
      }
    },
    "vtsls": {
      "initialization_options": {
        "preferences": {
          "includeInlayParameterNameHints": "all",
          "includeInlayParameterNameHintsWhenArgumentMatchesName": true,
          "includeInlayFunctionParameterTypeHints": true,
          "includeInlayVariableTypeHints": true,
          "includeInlayVariableTypeHintsWhenTypeMatchesName": true,
          "includeInlayPropertyDeclarationTypeHints": true,
          "includeInlayFunctionLikeReturnTypeHints": true,
          "includeInlayEnumMemberValueHints": true
        }
      }
    }
  },
  "languages": {
    "JavaScript": {
      "formatter": {
        "code_actions": {
          "source.fixAll.eslint": true
        }
      },
      "code_actions_on_format": {
        "source.fixAll.eslint": true
      }
    }
  }
}

Environment

Zed: v0.152.4 (Zed) OS: macOS 14.6.1 Memory: 16 GiB Architecture: aarch64

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

image

If applicable, attach your Zed.log file to this issue.

Zed.log

2024-09-17T07:45:47.930074+02:00 [INFO] building git repository, `.git` path in the worktree: ".git"
2024-09-17T07:45:47.936158+02:00 [ERROR] oneshot canceled
2024-09-17T07:45:47.936302+02:00 [ERROR] oneshot canceled
2024-09-17T07:45:47.936494+02:00 [ERROR] oneshot canceled
2024-09-17T07:45:47.959581+02:00 [INFO] starting language servers for JavaScript: vtsls, tailwindcss-language-server, eslint
2024-09-17T07:45:47.959693+02:00 [INFO] starting language server "vtsls", path: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", id: 10
2024-09-17T07:45:47.959807+02:00 [INFO] starting language server "tailwindcss-language-server", path: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", id: 11
2024-09-17T07:45:47.960029+02:00 [INFO] starting language server. binary path: "/Users/wilsonoliveiradasilva/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", args: ["/Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/tailwindcss-language-server/node_modules/.bin/tailwindcss-language-server", "--stdio"]
2024-09-17T07:45:48.003205+02:00 [INFO] starting language servers for JavaScript: vtsls, tailwindcss-language-server, eslint
2024-09-17T07:45:48.004203+02:00 [INFO] starting language servers for JavaScript: vtsls, tailwindcss-language-server, eslint
2024-09-17T07:45:48.024943+02:00 [INFO] starting language servers for JavaScript: vtsls, tailwindcss-language-server, eslint
2024-09-17T07:45:48.645694+02:00 [WARN] unhandled capability registration: Registration { id: "d15ab940-92e4-47bc-91d2-3a27a9349d07", method: "workspace/didChangeWorkspaceFolders", register_options: Some(Object {}) }
2024-09-17T07:45:48.726811+02:00 [INFO] starting language server. binary path: "/Users/wilsonoliveiradasilva/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", args: ["/Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/vtsls/node_modules/@vtsls/language-server/bin/vtsls.js", "--stdio"]
mrnugget commented 1 month ago

Hey, two things here:

  1. You don't need code_actions_on_format and code_actions as the formatter. If you define formatters then that's the only formatters that run. If you define code_actions_on_format, then the code actions are run, followed by prettier or the language server's formatting action.
  2. If you run debug: open language server logs and select eslint in the dropdown in the top left — anything there? If you enable RPC messsages and hit save in a file, does anything happen?
wilson-salonkee commented 1 month ago

Hello @mrnugget ,

Thanks for the reply, I've removed the stuff you mentionned.

As for the logs, there is no eslint in the dropdown.... only copilot, vtsls, etc... (look at screenshot bellow)

image

One of my colleagues has it though, loaded from the same project as I'm currently in.

mrnugget commented 1 month ago

Interesting. So it doesn't start up. Is there anything else in the main log? It reads like it does want to start it, but since it doesn't show up in the list of opened language servers, I'd expect there to be an error message saying that it doesn't start up yet.


One of my colleagues has it though, loaded from the same project as I'm currently in.

So it works on your colleagues machine? Then I guess we need to find out what's different between your machines. Do you have, by any chance, a package.json or node_modules in your home directory?

wilson-salonkee commented 1 month ago

So after some digging I did find some more interesting logs regarding eslint.

Caused by:
    No such file or directory (os error 2)
2024-09-17T15:59:30.428193+02:00 [INFO] starting language server "eslint", path: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", id: 6
2024-09-17T15:59:30.428469+02:00 [INFO] starting language server. binary path: "/Users/wilsonoliveiradasilva/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", args: ["/Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/eslint/vscode-eslint-release/vscode-eslint/server/out/eslintServer.js", "--stdio"]
2024-09-17T15:59:30.495123+02:00 [ERROR] cannot read LSP message headers
2024-09-17T15:59:30.495247+02:00 [ERROR] Broken pipe (os error 32)
2024-09-17T15:59:30.495338+02:00 [ERROR] server shut down
2024-09-17T15:59:30.495405+02:00 [ERROR] failed to start language server "eslint": oneshot canceled
2024-09-17T15:59:30.49548+02:00 [ERROR] server stderr: Some("node:internal/modules/cjs/loader:1222\n  throw err;\n  ^\n")
2024-09-17T15:59:30.49557+02:00 [INFO] retrying installation of language server "eslint" in 1s
2024-09-17T15:59:31.497193+02:00 [ERROR] No such file or directory (os error 2)
2024-09-17T15:59:31.497459+02:00 [INFO] About to spawn test binary
2024-09-17T15:59:31.497607+02:00 [WARN] test binary failed to launch
2024-09-17T15:59:31.497734+02:00 [WARN] test binary check failed
2024-09-17T15:59:31.49788+02:00 [INFO] beginning to reinstall server
2024-09-17T15:59:31.498035+02:00 [INFO] deleting server container
2024-09-17T15:59:31.49821+02:00 [ERROR] server container removal

Caused by:
    No such file or directory (os error 2)
2024-09-17T15:59:31.498398+02:00 [INFO] starting language server "eslint", path: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", id: 7
2024-09-17T15:59:31.498655+02:00 [INFO] starting language server. binary path: "/Users/wilsonoliveiradasilva/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", args: ["/Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/eslint/vscode-eslint-release/vscode-eslint/server/out/eslintServer.js", "--stdio"]
2024-09-17T15:59:31.565581+02:00 [ERROR] cannot read LSP message headers
2024-09-17T15:59:31.565705+02:00 [ERROR] Broken pipe (os error 32)
2024-09-17T15:59:31.565796+02:00 [ERROR] server shut down
2024-09-17T15:59:31.565863+02:00 [ERROR] failed to start language server "eslint": oneshot canceled
2024-09-17T15:59:31.565938+02:00 [ERROR] server stderr: Some("node:internal/modules/cjs/loader:1222\n  throw err;\n  ^\n")
2024-09-17T15:59:31.566026+02:00 [ERROR] Hit 4 reinstallation attempts for "eslint"
2024-09-17T15:59:33.776243+02:00 [ERROR] connection error: error reading rpc message from socket

And we do, but we have exactly the same project now running.

Here's the package.json

{
  "name": "home",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
  },
  "dependencies": {
    "@adyen/api-library": "^10.2.0",
    "@aws-sdk/client-appconfigdata": "^3.576.0",
    "@aws-sdk/client-ec2": "^3.354.0",
    "@aws-sdk/client-ecs": "^3.574.0",
    "@aws-sdk/client-s3": "^3.354.0",
    "@aws-sdk/client-secrets-manager": "^3.354.0",
    "@aws-sdk/s3-request-presigner": "^3.354.0",
    "@babel/runtime": "^7.23.4",
    "@fast-csv/format": "4.3.5",
    "@node-saml/passport-saml": "^4.0.1",
    "@sendgrid/client": "^7.6.1",
    "@sendgrid/eventwebhook": "^7.4.5",
    "@sendgrid/mail": "^6.5.5",
    "@sentry/node": "^7.68.0",
    "@socket.io/redis-adapter": "^8.0.1",
    "@touch4it/ical-timezones": "^1.8.1",
    "adm-zip": "^0.5.10",
    "angular-signature": "1.0.3",
    "ansi-colors": "^4.1.1",
    "async": "^3.2.4",
    "axios": "^0.21.2",
    "base-64": "^1.0.0",
    "bluebird": "^3.7.2",
    "body-parser": "^1.19.0",
    "bwip-js": "^2.0.11",
    "compression": "^1.7.4",
    "cookie-parser": "^1.4.5",
    "coupon-code": "^0.4.5",
    "cron": "^3.1.6",
    "cypress-wait-until": "^1.7.2",
    "date-holidays": "^3.16.4",
    "decimal.js": "10.2.0",
    "dotenv": "^16.0.1",
    "dotenv-parse-variables": "^2.0.0",
    "ejs": "^3.1.8",
    "express": "^4.17.1",
    "express-mysql-session": "^3.0.0",
    "express-session": "^1.17.1",
    "fancy-log": "^1.3.3",
    "file-stream-rotator": "0.0.7",
    "fs-extra": "^7.0.1",
    "generic-pool": "^3.9.0",
    "glob": "^7.1.6",
    "gocardless-nodejs": "3.4.0",
    "google-libphonenumber": "^3.2.9",
    "hashids": "^1.1.4",
    "https": "^1.0.0",
    "i18n": "^0.13.2",
    "ical-generator": "^3.5.1",
    "iconv-lite": "^0.6.3",
    "ioredis": "^5.3.2",
    "jsonschema": "^1.4.0",
    "jsonwebtoken": "^9.0.0",
    "jspdf": "^2.3.1",
    "jspdf-autotable": "^3.5.14",
    "juice": "8.1.0",
    "libphonenumber-js": "^1.9.44",
    "lodash": "^4.17.15",
    "lru-cache": "^6.0.0",
    "merge-pdf-buffers": "^1.0.3",
    "minimist": "^1.2.5",
    "moment": "^2.25.3",
    "moment-timezone": "^0.5.28",
    "mongodb": "^3.6.4",
    "multiparty": "^4.1.2",
    "mysql-migrations": "^1.0.7",
    "mysql2": "^3.9.1",
    "nexmo": "^2.6.0",
    "node-cache": "^4.2.1",
    "node-fetch": "^2.6.7",
    "nodemailer": "^6.7.8",
    "passport": "^0.6.0",
    "passport-facebook": "^3.0.0",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "playwright-webkit": "^1.35.1",
    "puppeteer": "^2.1.1",
    "qrcode": "1.5.1",
    "rate-limiter-flexible": "^2.4.1",
    "redis": "^4.6.10",
    "redlock": "^5.0.0-beta.2",
    "request": "^2.88.2",
    "sanitizer": "^0.1.2",
    "shape-json": "1.1.7",
    "sharp": "^0.32.6",
    "signature_pad": "^1.5.0",
    "sitemap": "^7.0.0",
    "socket.io": "^4.5.4",
    "socket.io-client": "^4.5.4",
    "swagger-autogen": "^2.22.0",
    "swagger-ui-express": "^4.5.0",
    "swissqrbill": "3.2.2",
    "tar": "^6.1.0",
    "tunnel-ssh": "^4.1.6",
    "twilio": "^3.43.1",
    "typesense": "^1.7.2",
    "uuid": "^8.3.1",
    "validator": "^13.6.0",
    "xlsx": "^0.14.5"
  },
  "devDependencies": {
    "@aws-sdk/types": "^3.347.0",
    "@lokalise/node-api": "^7.2.0",
    "@swc/core": "^1.3.42",
    "@types/axios": "^0.14.0",
    "@types/node": "^20.11.16",
    "cypress": "^13.1.0",
    "deepmerge-json": "^1.5.0",
    "del": "^6.0.0",
    "eslint": "^7.32.0",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-angular": "^4.1.0",
    "eslint-plugin-cypress": "^2.12.1",
    "eslint-plugin-disable-features": "^0.1.3",
    "eslint-plugin-import": "^2.25.2",
    "eslint-plugin-prettier": "^4.0.0",
    "extract-zip": "^2.0.1",
    "gulp": "^4.0.2",
    "gulp-clean-css": "^4.3.0",
    "gulp-concat": "^2.6.1",
    "gulp-ng-annotate": "^2.1.0",
    "gulp-nodemon": "^2.5.0",
    "gulp-swc": "^1.2.3",
    "gulp-uglify-es": "^3.0.0",
    "husky": "^8.0.0",
    "jasmine": "^3.7.0",
    "jest": "^27.3.1",
    "lint-staged": "^13.0.3",
    "morgan": "^1.10.0",
    "prettier": "^2.4.1",
    "through2": "^4.0.2",
    "wait-on": "^6.0.0",
    "workbox-build": "^7.0.0"
  },
  "optionalDependencies": {
    "bufferutil": "^4.0.5",
    "utf-8-validate": "^5.0.7"
  },
  "lint-staged": {
    "*.js": "eslint --quiet",
    "*.ts": "eslint --quiet"
  }
}
wilson-salonkee commented 1 month ago

Inside that languages folder (In Application Support/Zed) I do not have eslint installed I guess? Is there a way to install it? Also I've tried to uninstall Zed and install it again the issue still stays there, seems like the cache files/config files do not get removed?

mrnugget commented 1 month ago

The logs here say that ESLint is in the directory, though:

2024-09-17T15:59:31.498398+02:00 [INFO] starting language server "eslint", path: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", id: 7
2024-09-17T15:59:31.498655+02:00 [INFO] starting language server. binary path: "/Users/wilsonoliveiradasilva/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/wilsonoliveiradasilva/Desktop/salonkee/home", args: ["/Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/eslint/vscode-eslint-release/vscode-eslint/server/out/eslintServer.js", "--stdio"]
2024-09-17T15:59:31.565581+02:00 [ERROR] cannot read LSP message headers
2024-09-17T15:59:31.565705+02:00 [ERROR] Broken pipe (os error 32)
2024-09-17T15:59:31.565796+02:00 [ERROR] server shut down
2024-09-17T15:59:31.565863+02:00 [ERROR] failed to start language server "eslint": oneshot canceled
2024-09-17T15:59:31.565938+02:00 [ERROR] server stderr: Some("node:internal/modules/cjs/loader:1222\n  throw err;\n  ^\n")

Specifically here: /Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/eslint/vscode-eslint-release/vscode-eslint/server/out/eslintServer.js

Does that not exist?

To me it reads as if ESLint is installed and wants to start, but it can't because of that error:

server stderr: Some("node:internal/modules/cjs/loader:1222\n  throw err;\n  ^\n")

Coming back to my question from above:

Then I guess we need to find out what's different between your machines. Do you have, by any chance, a package.json or node_modules in your home directory?

Do you have something like that?

Also, it's correct that your project is in this folder? /Users/wilsonoliveiradasilva/Desktop/salonkee/home, yes?

What happens if you try to start the installed ESLint manually?

$ cd /Users/wilsonoliveiradasilva/Desktop/salonkee/home
$ /Users/wilsonoliveiradasilva/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node /Users/wilsonoliveiradasilva/Library/Application Support/Zed/languages/eslint/vscode-eslint-release/vscode-eslint/server/out/eslintServer.js --stdio
wilson-salonkee commented 1 month ago

Hello,

I did have a node_modules folder and a package.json file in /Users/wilsonoliveiradasilva/... I've removed them, now eslint is working how it was suppose to...

Thanks so much for your time and help! I wish you guys the best, now I'll give Zed a proper try!