简体   繁体   中英

How to use eslint plugin modules located in parent directory?

I have some services organized into a monorepo in such a fashion:

repo_root/ ├── services/ │ ├── service_one/ │ ├── service_two/ │ └── service_three/ ├── package.json ├── node_modules ├── .eslintrc

Additionally, each individual service has its own package.json and node_modules . I would like to use the eslint configuration stored in the repo_root directory to lint individual services. My problem is that when I try to run something like

eslint services/service_one

for example, it fails to find the eslint plugin modules that are required by .eslintrc and installed in the node_modules directory of repo_root .

I'd like to avoid redundantly requiring these plugin modules in every service. Is there anyway to configure eslint to intelligently find the modules even though they are in the parent directory of the services themselves?

For anyone wondering, my problem was I was running the command using a globally installed eslint, which in turn looked for global modules. After changing it to run a local version of eslint, everything worked fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM