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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay