Adonis integration with husky and lint-staged

Hello. I’m trying integrate Adonis testing with husky amd lint-staged. Everything works fine, except when I try to run the tests before commiting code.

My configuration at package.json is :

"husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.js": [
      "eslint --fix",
      "adonis test",
      "git add"
    ]
  },

If I run the command adonis test I get the failing test :
But If I run through lint-staged I get nothing :

err03

Any clues ?

Thanks

Ok, I found myself how to manage this.

I removed the code from package.json and created a file named lint-staged.config.js with the following code :

module.exports = {
‘*.js’: () => [‘eslint --fix’, ‘adonis test --bail’]
}

And everything worked fine.

I hope this tip be helpful to someone.

Cheers

2 Likes