35
Automaitcally format NodeJS projects.
source link: https://www.tuicool.com/articles/Qrmyqum
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Node Code Formatter
Automatically formats your code!
Automatically format pull requests
Never tell your users to format their code, as we do it on the fly!
Usage :pencil2:
For a more detailed installation guide look into our wiki
- Create a
formatter.yml
file in.github/workflows/
- Paste this code into the file:
on: push name: Node Code Formatter jobs: lint: name: Node Code Formatter runs-on: ubuntu-latest steps: - name: Node Code Formatter uses: MarvinJWendt/run-node-formatter@stable env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- Commit the file :twisted_rightwards_arrows:
Setup formatter scripts :clipboard:
Simply put your code formatter into a script named format
or lint
in your package.json
(Yarn only supports a lint
script at the moment).
Make sure that your code formatter is a dependency of your module!
StandardJS
... "scripts": { "format": "standard --fix" }
Prettier
... "scripts": { "format": "prettier --write" }
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK