Home > Blockchain >  lint-staged generates new .eslintcache file on commit
lint-staged generates new .eslintcache file on commit

Time:02-17

I'm creating a new Vue project via npm init vue@latest and select everything (Eslint with Prettier)

I'm using the following setup

  • OS: Win11
  • node: v17.4
  • npm: v8.4

I setup lint-staged via npx mrm@2 lint-staged. For testing purposes I add a new file inside the src directory

// calc.js

function 
add
(numOne, 
  numTwo) {
  return numOne   
  
              numTwo;
}

When committing the new file the linter fixes the code style as expected. But after that I manually have to delete a generated .eslintcache file.

Older posts say I should add

*.eslintcache

to the .gitignore file. But I compared the generated .gitignore file with the generated one from the Vue CLI and both don't have this line. When using the Vue CLI the cache file doesn't appear.

So are there any other solutions or is there something I missed?

CodePudding user response:

The .eslintcache file is created from ESLint's --cache flag, which is included in the default linter command of lint-staged:

// package.json
{
  "lint-staged": {                                   
  • Related