Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent eslint from blocking git commit?

Tags:

git

eslint

I'm new to eslint and am using it to enforce coding style. However, when I write a TODO item into my code I get an eslint warning, alright that's fine. But, now when I try to git commit, it comes back with:

**** ESLint errors found :      line 145, col 9, Warning - Unexpected 'todo' comment. (no-warning-comments) 

How can I prevent eslint from blocking me from committing? I want it to still warn me about TODOs etc, but I would like to be able to commit my code as well.

like image 884
Tevon Strand-Brown Avatar asked Jul 05 '17 18:07

Tevon Strand-Brown


People also ask

How do you bypass ESLint?

How do I turn off rule ESLint? If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.

How do I disable ESLint errors in my browser?

You can disable errors in browser by adding the environment variable ESLINT_NO_DEV_ERRORS as it is mentioned here.

How do you use pre-commit hooks?

If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.

What is pre-commit hook in git?

The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.


2 Answers

You have a pre-commit hook.

git commit --no-verify 

allows to avoid it once. Or you can remove it completely from .git/hooks.

like image 132
phd Avatar answered Sep 20 '22 13:09

phd


In my case the culprit were package.json entries automatically created by a project creating CLI (nuxt.js). I removed from my package.json these entries:

"lint-staged": { ... }, "husky": { ... } 

and it solved the problem.

like image 45
Eggon Avatar answered Sep 17 '22 13:09

Eggon