lint-staged: Error `string` and `indent` should be strings

I’m getting this error message when running lint-staged with husky:

husky > npm run -s precommit (node v8.1.3)

`string` and `indent` should be strings

husky > pre-commit hook failed (add --no-verify to bypass)

Config:

"lint-staged": {
  "{config,src,tests,mocks}/**/*.{js,jsx}": [
    "prettier-eslint --write",
    "git add",
    "npm run test -- --findRelatedTests"
  ],
  "src/**/*.scss": [
    "stylelint --syntax scss --fix",
    "git add"
  ]
},

I tested out husky without lint-staged and it worked. I also tested out lint-staged with no rules which worked as well.

When I modify my rules to only include one test file like this:

"lint-staged": {
  "test.scss": [
    "stylelint --syntax scss --fix",
    "git add"
  ]
},

I get this error message:

/home/jonathan/Projects/kontextR/cockpit-ui/node_modules/indent-string/index.js:6
                throw new TypeError('`string` and `indent` should be strings');
                ^

TypeError: `string` and `indent` should be strings
    at module.exports (/home/jonathan/Projects/kontextR/cockpit-ui/node_modules/indent-string/index.js:6:9)
    at renderHelper (/home/jonathan/Projects/kontextR/cockpit-ui/node_modules/listr-update-renderer/index.js:19:16)
    at render (/home/jonathan/Projects/kontextR/cockpit-ui/node_modules/listr-update-renderer/index.js:48:12)
    at Timeout._id.setInterval [as _onTimeout] (/home/jonathan/Projects/kontextR/cockpit-ui/node_modules/listr-update-renderer/index.js:68:4)
    at ontimeout (timers.js:488:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:283:5)

Environment node: 8.1.3 npm: 5.1.0 husky: 0.14.3 lint-staged: 4.0.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15

Most upvoted comments

@IgnusG I’m on npm 5.3.0.

This is definitely a dependency version issue. Removing node_modules and re- npm installing fixed the problem.

@cirpo remove node_modules, package.lock and then try npm install. Hope it helps