Skip to content

shanquan954/test

Repository files navigation

Just only a test

Setting up Husky and Code Quality Tools

1. Install Husky

  • Install Husky as a dev dependency:

    npm install husky --save-dev
  • Initialize Husky:

    npx husky install
  • Set up the pre-commit hook to run tests:

    npm pkg set scripts.prepare="husky install"
    npx husky add .husky/pre-commit "npm test"

2. Install Prettier

  • Install Prettier as a dev dependency with an exact version:

    yarn add --dev --exact prettier
  • Create a .prettierrc file with default settings:

    node --eval "fs.writeFileSync('.prettierrc','{}\n')"
  • Create a .prettierignore file to ignore artifacts:

    # Ignore artifacts:
    build
    coverage
    

3. Install ESLint

  • Initialize ESLint configuration:
    npx eslint --init

4. Install eslint-config-prettier and eslint-plugin-prettier

  • Install the necessary packages:

    yarn add -D eslint-config-prettier eslint-plugin-prettier
  • Add them to eslintrc.js:

    module.exports = {
    ...
      extends: ["airbnb-base", "prettier", "plugin:prettier/recommended"],
    ...
    };

5. Install lint-staged

  • Install lint-staged as a dev dependency:

    yarn add -D lint-staged
  • Create a .lintstagedrc.json file and define staged tasks:

    {
      "*.js": ["eslint", "prettier --write"],
      "*.{js,ts,json,html}": "prettier --write"
    }

6. Add npx lint-staged to pre-commit hook

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

npx lint-staged

Commit-lint

1. Install

npm install --save-dev @commitlint/{cli,config-conventional,prompt-cli}
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js

2. Provide a shortcut

{
  "scripts": {
    "commit": "commit"
  }
}

3. Test Prompt

git add .
npm run commit

4. Use CZ-Git

yarn add -D cz-git

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published