DEV Community

Cover image for Add Eslint, Prettier, Husky, Lint-staged to Vue Project
Tony Zheng
Tony Zheng

Posted on

5

Add Eslint, Prettier, Husky, Lint-staged to Vue Project

1. Install packages

npm install husky lint-staged eslint prettier --save-dev
Enter fullscreen mode Exit fullscreen mode

2. eslint configuration

npm init @eslint/config
Enter fullscreen mode Exit fullscreen mode

3. lint-staged Configuration
Add this to package.json

{
  ...
  "lint-staged": {
    "src/**/*.{js,vue,html,css}": "prettier --write",
    "src/**/*.{js,vue}": "eslint --fix"
  }
}
Enter fullscreen mode Exit fullscreen mode

4. husky configuration

npx husky-init && npm install
Enter fullscreen mode Exit fullscreen mode

Update .husky/pre-commit file

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

👋 Kindness is contagious

Please leave a ❀ or a friendly comment on this post if you found it helpful!

Okay