SublimeLinter / SublimeLinter-eslint

This linter plugin for SublimeLinter provides an interface to ESLint
MIT License
865 stars 88 forks source link

Prettier: "text.trimEnd is not function" with eslint / eslint-plugin-prettier #295

Closed YuriGor closed 4 years ago

YuriGor commented 4 years ago

Hi guys I just created a new project and installed most recent

    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-prettier": "^3.1.3",
    "prettier": "^2.0.5"

And when trying to lnt I see "TypeError: text.trimEnd is not a function" which comes from prettier. I see prettier starting from v2 requires nodejs v10+ But I had node 11 and tried to upgrade to node v14 In sublime linter settings I have

{
    "paths": {
        "linux": [
            "/home/gor/.nvm/versions/node/v14.0.0/bin"

And used to have v11 before trying to upgrade. When I run npx eslint in terminal it works fine npx prettier separately also works without errors.

I added console.log to prettier and I see in sublime console v8.10.0

Any idea how it's possible to still run this old node version in sublime somehow?

kaste commented 4 years ago

Same error if you start Sublime from your Terminal with everything setup as expected?

YuriGor commented 4 years ago

No, if started from terminal - it works fine... I just found in .bash_profile assigning this old version of node to PATH, removed it but it didn't help.. maybe will try to reboot..

kaste commented 4 years ago

I also don't think setting the path to node/v14.../bin can help here because we're actually looking and executing the eslint binary from your "node_modules" which in turn execs "../eslint/bin/eslint.js" which in turn has the bang "#!/usr/bin/env node".

kaste commented 4 years ago

No, if started from terminal - it works fine...

Ok, can't give any tips here but there are enough people in the official Sublime forum (regardless if you paid or not) knowing exactly how to get the proper ENV into Sublime when using whatever WindowManager.

YuriGor commented 4 years ago

Ok thanks a lot for the idea to run sublime from terminal

YuriGor commented 4 years ago

If someone also, I fixed this by adding:

{
  "linters": {
    "eslint": {
        "env": {"PATH":"/home/gor/.nvm/versions/node/v14.0.0/bin"}
    }
  }
}

to sublime linter's settings as suggested in SublimeLinter's troubleshooting docs