From 6d18f7c368833e9a2b3970cc51fed697efc849b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Go=CC=88khan=20O=CC=88ztu=CC=88rk?= Date: Wed, 17 Aug 2022 18:16:14 +0300 Subject: [PATCH] feat: adds git hooks --- .eslintrc.cjs | 42 ++++++++++++++++++++------------ .husky/pre-commit | 4 +++ package.json | 9 ++++++- postcss.config.cjs | 3 ++- src/components/Button/Button.vue | 2 +- 5 files changed, 41 insertions(+), 19 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.eslintrc.cjs b/.eslintrc.cjs index de80a3c..6958ea5 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -3,22 +3,32 @@ require('@rushstack/eslint-patch/modern-module-resolution'); module.exports = { root: true, - extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/eslint-config-typescript/recommended', '@vue/eslint-config-prettier', 'plugin:storybook/recommended', 'plugin:storybook/recommended'], + extends: [ + 'plugin:vue/vue3-essential', + 'eslint:recommended', + '@vue/eslint-config-typescript/recommended', + '@vue/eslint-config-prettier', + 'plugin:storybook/recommended', + 'plugin:storybook/recommended', + ], parserOptions: { - ecmaVersion: 'latest' + ecmaVersion: 'latest', }, rules: { - 'prettier/prettier': ['error', { - singleQuote: true, - trailingComma: 'es5', - printWidth: 80, - tabWidth: 2, - semi: true, - bracketSpacing: true, - arrowParens: 'always', - jsxBracketSameLine: false, - vueIndentScriptAndStyle: false - }], - 'vue/multi-word-component-names': 0 - } -}; \ No newline at end of file + 'prettier/prettier': [ + 'error', + { + singleQuote: true, + trailingComma: 'es5', + printWidth: 80, + tabWidth: 2, + semi: true, + bracketSpacing: true, + arrowParens: 'always', + jsxBracketSameLine: false, + vueIndentScriptAndStyle: false, + }, + ], + 'vue/multi-word-component-names': 0, + }, +}; diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..d24fdfc --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/package.json b/package.json index 0b3236f..9308adc 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "storybook": "start-storybook -p 6006", - "build-storybook": "build-storybook" + "build-storybook": "build-storybook", + "prepare": "husky install" }, "dependencies": { "vue": "^3.2.37" @@ -49,8 +50,11 @@ "eslint": "^8.21.0", "eslint-plugin-storybook": "^0.6.4", "eslint-plugin-vue": "^9.3.0", + "husky": "^8.0.0", "jsdom": "^20.0.0", + "lint-staged": "^13.0.3", "npm-run-all": "^4.1.5", + "pinst": "^3.0.0", "postcss": "^8.4.16", "prettier": "^2.7.1", "tailwindcss": "^3.1.8", @@ -59,5 +63,8 @@ "vitest": "^0.21.0", "vue-loader": "^16.8.3", "vue-tsc": "^0.39.5" + }, + "lint-staged": { + "*.vue": "eslint --fix" } } diff --git a/postcss.config.cjs b/postcss.config.cjs index 33ad091..caa74a9 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,6 +1,7 @@ +/* eslint-env node */ module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/src/components/Button/Button.vue b/src/components/Button/Button.vue index 98fa3ed..746c429 100644 --- a/src/components/Button/Button.vue +++ b/src/components/Button/Button.vue @@ -1,6 +1,6 @@