@bjorn-mozyakin

Как настроить eslint на работу с git-hook pre-commit (проверка eslint вручную работает)?

Вроде простейшая настройка. Делаю все по инструкции. Но не работает.

Есть папка с гит репозиторием, в котором лежит проект
test3/
—.git
—project1/
——node_modules/
——src/
———js/
————1.js
——.eslintrc.json

Установил локально eslint и eslint-config-standard:
npm install --save-dev eslint-config-standard eslint-plugin-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-node
npm install --save-dev eslint

Создал конфиг .eslintrc.json:
{ "extends": "standard"}

Если запустить в терминале проверку - все работает:
./node_modules/.bin/eslint src/js

Пытаюсь создать хук, в .git/hooks переименовываю pre-commit.sample в pre-commit
Удаляю его содержимое и вставляю:
path="$(git rev-parse --show-toplevel)"
"$path/project1/node_modules/.bin/eslint" "$path/project1/src/js/"

Пытаюсь закоммитить изменения в js-файле, выдается предупреждение:
[notebook@NOTEBOOKs-MacBook-Pro project1 (master +)]$ git commit -m "T"
Oops! Something went wrong! :(
ESLint: 6.6.0.

ESLint couldn't find the plugin "eslint-plugin-import".

(The package "eslint-plugin-import" was not found when loaded as a Node module from the directory "/Users/notebook/Documents/Projects/test3".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-import@latest --save-dev
The plugin "eslint-plugin-import" was referenced from the config file in "project1/.eslintrc.json » eslint-config-standard".

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

Видимо, локальный eslint не видит свои локальные же плагины. Но как их ему подсунуть? Где прописать пути?
  • Вопрос задан
  • 904 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы