diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml new file mode 100644 index 0000000..bd97080 --- /dev/null +++ b/.github/workflows/release-npm.yml @@ -0,0 +1,32 @@ +name: Release NPM + +on: + push: + tags: [ v* ] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-18.04 + steps: + - name: Checkout + uses: actions/checkout@master + - name: setup node + uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' + - name: Get version + id: get_version + run: echo "VERSION=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_OUTPUT + - name: Run Npm Scripts + run: | + node -v + npm -v + npm install + node -e 'var pkg = require("./package.json"); pkg.version= "${{ steps.get_version.outputs.VERSION }}"; require("fs").writeFileSync("./package.json", JSON.stringify(pkg, null, 2))' + npm run build + cd lib + npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.AUNT_NPM_TOKEN }} \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js index 7fbbb5b..a3e94f3 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,13 +1,23 @@ module.exports = { - semi: false, + // 一行代码的最大字符数,默认是80 + printWidth: 100, + // 每行末尾自动添加分号 + semi: true, trailingComma: 'es5', + // tab缩进大小,默认为2 tabWidth: 2, + // 字符串使用单引号 singleQuote: true, - bracketSameLine: false, + jsxBracketSameLine: false, + // 在jsx文件中的引号需要单独设置 jsxSingleQuote: true, + // object对象中key值是否加引号 (quoteProps: "")as-needed只有在需求要的情况下加引号,consistent是有一个需要引号就统一加,preserve是保留用户输入的引号 quoteProps: 'preserve', + // 箭头函数单个参数的情况是否省略括号 arrowParens: 'avoid', proseWrap: 'preserve', + // 对象空格 + bracketSpacing: true, overrides: [ { 'files': ['*.md'], @@ -16,4 +26,4 @@ module.exports = { }, }, ], -} +}; diff --git a/package.json b/package.json index adaffbb..a49cf5c 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "build": "gulp", "test": "umi-test", "test:coverage": "umi-test --coverage", - "lint": "eslint \"src/**/*.{js,ts,tsx}\"", + "lint": "npm run lint:prettier && npm run lint:es", + "lint:prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"", + "lint:es": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", "prepare": "husky install" }, "keywords": [ @@ -48,8 +50,13 @@ "platform": "github" }, "lint-staged": { - "src/**/*.{js,jsx,ts,tsx}": [ - "eslint --fix" + "*.{js,jsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.{ts,tsx}": [ + "eslint --fix", + "prettier --parser=typescript --write" ] }, "peerDependencies": {