DEV Community

MariannaKhanina
MariannaKhanina

Posted on

Настройка корректной работы eslint в VS Code, когда .eslintrc.js располагается не в корневой директории.

В settings.json добавить правило

"eslint.workingDirectories": [{ 
    "directory": "/path/to/directory/with/eslintrc_file", 
    "changeProcessCWD": true 
},],
Enter fullscreen mode Exit fullscreen mode

Выдержка из доки по поводу данной настройки:

    "eslint.workingDirectories": [
      "./client", // changeProcessCWD defaults to false
      { "directory": "./server", "changeProcessCWD": true }
    ]

In the above example, client.js will be evaluated from root using root/client/.eslintrc.json,
while server.js will be evaluated from root/server using root/server/.eslintrc.json
Using changeProcessCWD causes vscode-eslint to change the current working directory of the eslint process to directory as well. This is often necessary if ESLint is used to validate relative import statements like import A from 'components/A'; which would otherwise be resolved to the workspace folder root.

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay