Skip to content

rutajdash/prettier-cli-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prettier CLI Check

A GitHub action to run Prettier CLI Checks. This project was heavily inspired by other actions available and a shoutout to @creyD. The goal of this project was to create a simple action which would be easy to use.

Code Style Latest Release MIT License Issues Contributors Forks Stargazers

Usage

Parameters

Parameter Default Description
file_pattern '**/*.js' The file pattern prettier will check. Follow glob syntax.
config_path '' The path to the prettierrc file. Read more here.
ignore_path './.prettierignore' The path to the prettierignore file. This file should list file patterns to skip using the glob syntax.
prettier_version 'latest' The version of prettier to use. Find versions here.
fail_on_error true Whether the action should fail if prettier finds errors in formatting.

Output

You can access the list of files prettier found errors using the actions context like steps.<step-id>.outputs.prettier_output. The returned value is a list of files as a string, one per line.

Examples

name: Continuous Integration

# This action works with pull requests and pushes on the main branch
on:
  pull_request:
  push:
    branches: [main]

jobs:
  prettier:
    name: Prettier Check
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Run Prettier
        id: prettier-run
        uses: rutajdash/prettier-cli-action@v1.0.0
        with:
          config_path: ./.prettierrc.yml

      # This step only runs if prettier finds errors causing the previous step to fail
      # This steps lists the files where errors were found
      - name: Prettier Output
        if: ${{ failure() }}
        shell: bash
        run: |
          echo "The following files are not formatted:"
          echo "${{steps.prettier-run.outputs.prettier_output}}"

More documentation for writing a workflow can be found here.

Issues

Please report all bugs and feature requests using the GitHub issues function. Thanks!

Contributing

Pull Requests are always welcome! Feel free to pick any issue or raise a new feature request! Do read the contributing guidelines and code of conduct.