B
B
bjorn-mozyakin2019-10-31 19:39:56
git
bjorn-mozyakin, 2019-10-31 19:39:56

How to set up eslint to work with git-hook pre-commit (checking eslint manually works)?

Seems like a simple setup. I do everything according to the instructions. But doesn't work.
There is a folder with a git repository that contains the project

test3/
—.git
—project1/
——node_modules/
——src/
———js/
————1.js
——.eslintrc.json

Installed locally eslint and 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

Created a .eslintrc.json config:
{ "extends": "standard"}
If I run the check in the terminal, everything works:
./node_modules/.bin/eslint src/js
I try to create a hook, in .git/hooks I rename pre-commit.sample to pre-commit
I delete its contents and paste:
path="$(git rev-parse --show-toplevel)"
"$path/project1/node_modules/.bin/eslint" "$path/project1/src/js/"

I'm trying to commit changes in a js file, I get a warning:
[[email protected] 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 [email protected] --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.

Apparently, local eslint does not see its own local plugins. But how do you give them to him? Where to write paths?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question