diff --git a/.husky/pre-commit b/.husky/pre-commit index b519fdce..7806eb63 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -26,6 +26,4 @@ PATH="/usr/local/bin:$PATH" # Format and submit code according to lintstagedrc configuration -npm run lint -npm run lint:prettier -npm run lint:stylelint +npm run lint:lint-staged diff --git a/package.json b/package.json index 4d30be52..a0a93afd 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", + "lint:lint-staged": "lint-staged", "prepare": "husky install" }, "dependencies": { @@ -59,7 +60,7 @@ "lint-staged": "^12.1.3", "node-sass": "^8.0.0", "npm-run-all": "^4.1.5", - "postcss-html": "^1.5.0", + "postcss-html": "^1.3.0", "postcss-scss": "^4.0.2", "prettier": "^2.7.1", "sass": "^1.56.1", @@ -81,5 +82,25 @@ "> 1%", "last 2 versions", "not dead" - ] + ], + "lint-staged": { + "*.{js,jsx,ts,tsx,vue}": [ + "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", + "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", + "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/" + ], + "{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [ + "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"" + ], + "package.json": [ + "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"" + ], + "*.{scss,less,styl}": [ + "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", + "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/" + ], + "*.md": [ + "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"" + ] + } }