Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add prettier script #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: lint CI

on: [push, pull_request]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议只在 pull_request 运行

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push 也需要的,不然合并到matser的时候master就不会检查了。

Copy link
Contributor

@chenzn1 chenzn1 Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那可以限定一下分支,只在 main test release 这些重要的分支触发。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没必要的,github 非常 rich,牺牲一点时间保证代码的正确性是非常合算的


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn cache
uses: actions/cache@v2
id: cache-yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
- run: yarn --ignore-engines
if: |
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
steps.cache-node-modules.outputs.cache-hit != 'true'
- run: yarn run lint
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ module.exports = {
singleQuote: true,
useTabs: false,
semi: true,
// windows and md table need this set
proseWrap: 'never',
endOfLine: 'lf',
};
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"build:css": "lerna run build:css",
"build-storybook": "build-storybook -c ./.storybook/js/",
"build:gatsbydoc": "lerna run build:lib --scope=@douyinfe/semi-webpack-plugin && cross-env NODE_ENV=production node --max_old_space_size=16384 ./node_modules/gatsby/cli.js build --prefix-paths --verbose && rm -rf build && mv public build",
"build:icon": "lerna run build:icon --scope='@douyinfe/semi-{icons,illustrations}'"
"build:icon": "lerna run build:icon --scope='@douyinfe/semi-{icons,illustrations}'",
"prettier": "prettier --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
},
"dependencies": {
"@douyinfe/semi-site-banner": "0.0.1",
Expand Down Expand Up @@ -161,7 +162,8 @@
"mini-css-extract-plugin": "^0.12.0",
"null-loader": "^3.0.0",
"postcss-loader": "^2.1.6",
"prettier": "^1.19.1",
"prettier": "^2.4.1",
"pretty-quick": "^3.1.1",
"progress-bar-webpack-plugin": "^1.12.1",
"react-dnd-cjs": "^9.5.1",
"react-storybook-addon-props-combinations": "^1.1.0",
Expand Down Expand Up @@ -192,6 +194,9 @@
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --ext '.js,.jsx,.ts,.tsx'"
],
"src/**/*.{js,jsx,ts,tsx,md,css,scss,json}": [
"pretty-quick --staged"
],
"packages/**/*.{js,jsx,ts,tsx}": [
"eslint --ext '.js,.jsx,.ts,.tsx'"
],
Expand Down