diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d12ee04..e84890f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,11 +4,15 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 with: - node-version: 10 - - uses: JS-DevTools/npm-publish@v1 + node-version: '14' + + - name: Publish on npm + uses: JS-DevTools/npm-publish@v1 + if: startsWith(github.ref, 'refs/tags/') with: token: ${{ secrets.NPM_TOKEN }} access: public diff --git a/README.md b/README.md index 2c975ec..4132452 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,18 @@ [![Code style][style-src]][style-href] [![Downloads][downloads-src]][downloads-href] +[![Version][version-src]][version-href] > My personal [Prettier](https://prettier.io) config / workflow #### Install ```bash +# With npm npm i -D prettier @bokub/prettier-config + +# With yarn +yarn add -D prettier @bokub/prettier-config ``` #### Add the following to your `package.json`: @@ -19,21 +24,51 @@ npm i -D prettier @bokub/prettier-config } ``` -#### _Optional:_ Setup pre-commit hook +#### _Optional:_ Setup pre-commit hook with husky ```bash +# With npm npx husky-init npm i -D pretty-quick npx husky set .husky/pre-commit "npx pretty-quick --staged" + +# With yarn +npx husky-init # add --yarn2 for Yarn 2 +yarn add -D pretty-quick +yarn husky set .husky/pre-commit "npx pretty-quick --staged" ``` -#### _Optional:_ Run prettier on old code +#### _Optional:_ Run prettier on existing code ```bash npx prettier --write . ``` +#### _Optional:_ Setup with ESLint + +```bash +# With npm +npm i -D eslint-config-prettier eslint-plugin-prettier eslint@latest + +# With yarn +yarn add -D eslint-config-prettier eslint-plugin-prettier eslint@latest +``` + +Then, edit your ESLint configuration file: + +```jsonc +{ + "plugins": ["prettier"], + "extends": ["", "plugin:prettier/recommended"], // Add to the end of the array + "rules": { + "prettier/prettier": "warn" // Optionally, you can set the error level to warn + } +} +``` + [style-src]: https://flat.badgen.net/badge/code%20style/prettier/ff69b4 [style-href]: https://github.com/prettier/prettier [downloads-src]: https://flat.badgen.net/npm/dt/@bokub/prettier-config [downloads-href]: https://www.npmjs.com/package/@bokub/prettier-config +[version-src]: https://runkit.io/bokub/npm-version/branches/master/@bokub/prettier-config?style=flat +[version-href]: https://www.npmjs.com/package/@bokub/prettier-config