From c0e910f7346de87fb20df234cda544e34508c031 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sun, 17 Oct 2021 23:53:47 +0800 Subject: [PATCH] chore: Add prettier. --- .husky/pre-commit | 4 ++++ .prettierignore | 11 +++++++++++ .prettierrc | 11 +++++++++++ package.json | 10 +++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 .husky/pre-commit create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..d37daa0 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install lint-staged diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..afe1615 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +**/*.md +**/*.svg +**/*.ejs +**/*.yml +package.json +node_modules +dist +build +coverage +lib +test diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..764fbde --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 120, + "overrides": [ + { + "files": ".prettierrc", + "options": { "parser": "json" } + } + ] +} diff --git a/package.json b/package.json index 1d21329..f63122c 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,13 @@ "types": "./lib/index.d.ts", "exports": "./lib/index.js", "scripts": { + "prepare": "husky install", "start": "node lib/index.js", "watch": "tsbb watch --disable-babel", "build": "tsbb build --disable-babel", "test": "tsbb test", - "coverage": "tsbb test --coverage" + "coverage": "tsbb test --coverage", + "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"" }, "repository": { "type": "git", @@ -32,7 +34,13 @@ "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, + "lint-staged": { + "*.{js,jsx,tsx,ts,less,md,json}": "prettier --write" + }, "devDependencies": { + "husky": "7.0.2", + "lint-staged": "11.1.2", + "prettier": "2.3.2", "tsbb": "3.4.4" } }