This project has the basic config for ESLint with ES6. You can configure it to be used in combination with Git Hooks. By doing so, every time you commit changes to Git, Git Hooks will run ESLint and, if any syntax error is found, ESLint will accuse it and your changes won't be committed to the Git repository.
I assume you're creating a new project based on this project.
- Install dependencies (it must be globally)
$ npm install -g
- Start a git repository
$ git init
- Add ESLint command to the end of file
.git/hooks/precommit.sample
$ echo 'eslint src' >> .git/hooks/precommit.sample
- Rename
.git/hooks/precommit.sample
to.git/hooks/precommit
$ mv .git/hooks/precommit.sample .git/hooks/precommit
- Copy .eslintrc to your project folder
$ cp .eslintrc /path/to/project/folder/
- Navigate to the project folder
$ cd /path/to/project/folder/
- Install dependencies
$ npm install -g --save eslint babel-eslint
- Add ESLint command to the end of file
.git/hooks/precommit.sample
$ echo 'eslint src' >> .git/hooks/precommit.sample
- Rename
.git/hooks/precommit.sample
to.git/hooks/precommit
$ mv .git/hooks/precommit.sample .git/hooks/precommit
Every time you commit, git hooks will automatically run ESLint. Usual workflow:
-
Change file
/path/to/file/file.js
-
Add file to be committed
$ git add /path/to/file/file.js
- Commit file
$ git commit -m "Your commit message here"
If there's any syntax error, ESLint will accuse it and won't let you commit your changes to the Git repository.
[Medium[(https://amirelemam.medium.com/commit-better-with-git-hooks-803a2814b36b)
These files are licensed under the MIT License