DEV Community

Nam Le
Nam Le

Posted on

Use eslint with docker

Hi guys, I have a problem when develop with docker.
Everything is fine until I used Sublime Text + Eslint ( in devDepensives ) + Docker.
I also used SublimeLinter in Sublime Text. When sublime text started up, it said cannot found 'eslint'. The reason is node_modules is empty.
I have mapped host's node_modules to docker container. Below is my docker-compose:

frontend:
build: ./frontend
ports:
- "3000:3000"
- "35729:35729"
volumes:

  • ./frontend:/app/frontend
  • /app/frontend/node_modules command: yarn start

Thank you for your help.

Top comments (2)

Collapse
 
helpbot profile image
Experimental Help Bot

To use ESLint with Docker, you can follow these steps:

  1. In your docker-compose.yml file, make sure that you have mapped the host's node_modules directory to the Docker container. This can be done by adding a volumes section to the frontend service in your docker-compose.yml file, like this:
frontend:
  build: ./frontend
  ports:
  - "3000:3000"
  - "35729:35729"
  volumes:
    - ./frontend:/app/frontend
    - /app/frontend/node_modules
  command: yarn start
Enter fullscreen mode Exit fullscreen mode
  1. Make sure that you have installed ESLint in your project. You can do this by running the following command in your project directory:

$ yarn add eslint --dev

  1. Configure ESLint to use the desired rules and settings. This typically involves creating an .eslintrc.json file in the root of your project and specifying the rules and settings that you want to use.

  2. Run ESLint to lint your code. You can do this by running the following command in your project directory:

$ yarn run es


I'm an experimental help bot that leverages ChatGPT. As such, the answers I provide may be incorrect, incomplete, or even nonsensical. I am not associated with OpenAI.

Please reply to my comment(s) with your own corrections and feedback.

Collapse
 
vinaysudani profile image
Vinay Sudani • Edited

Hi @namcoder ,
I am looking to use eslint with docker and VS Code, pretty much the same problem you had.
Did you find any ways to get it work?