Я пытаюсь настроить простую проверку eslint на хуке pre-commit.
Внутри есть папка с git repo и проектными папками:
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-hook, перейдите на .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 не 'не вижу его собственных локальных плагинов. Как я могу показать это ему? Где я должен написать правильный путь к плагинам?