Skip to content

:octocat: Github action to run ESLint on changed pull request files with support for reporting errors via Github checks.

License

Notifications You must be signed in to change notification settings

tj-actions/eslint-changed-files

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

Repository files navigation

Ubuntu Mac OS Public workflows that use this action.

Test Update release version.

All Contributors

eslint-changed-files

Run ESLint on either all files or selectively run ESLint on only changed files in a pull request with support for inline annotations of ESLint Warnings & Errors.

Screen Shot 2022-03-04 at 5 01 35 AM

Features

  • Easy to debug
  • Fast execution
  • Fix ESlint errors
  • Glob pattern extension filtering
  • Excludes ignored files from change detection.
  • Inline annotations of ESLint Warnings & Errors.
  • Inline annotations with possible resolutions that can be applied to the Pull Request.
  • Monorepo support.

Example

Screen Shot 2021-09-06 at 1 15 22 PM

Usage

...:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20.x

      - name: Install dependencies
        run: npm ci  # OR: yarn install --frozen-lockfile

      - name: Run eslint on changed files
        uses: tj-actions/eslint-changed-files@v25
        with:
          config_path: "/path/to/eslint.config.mjs"
          extra_args: "--max-warnings=0"

For more working examples view the test.yml

If you feel generous and want to show some extra appreciation:

Support this project with a ⭐

Buy me a coffee

Inputs

- uses: tj-actions/eslint-changed-files@v25
  id: eslint-changed-files
  with:
    # Run [ESlint](https://eslint.org) on all matching 
    # files. 
    # Type: boolean
    # Default: "false"
    all_files: ''

    # [ESLint](https://eslint.org/) [configuration file](https://eslint.org/docs/user-guide/configuring/). Optionally omit this 
    # input for Mono repositories. 
    # Type: string
    config_path: ''

    # Escaped changed file paths passed 
    # to ESLint. NOTE: This defaults 
    # to `true` to prevent command 
    # injection. 
    # Type: boolean
    # Default: "true"
    escape_paths: ''

    # Extra arguments passed to [ESlint](https://eslint.org/docs/user-guide/command-line-interface)
    # Type: string
    extra_args: ''

    # Exit code for reviewdog when 
    # errors are found. 
    # Type: boolean
    # Default: "true"
    fail_on_error: ''

    # List of file extensions to 
    # watch for changes and run 
    # [ESlint](https://eslint.org/) against. 
    # Type: string
    # Default: **/*.{ts,tsx,js,jsx}
    #          
    file_extensions: ''

    # [Filter mode](https://github.com/reviewdog/reviewdog#filter-mode) for the reviewdog command 
    # (added, diff_context, file, nofilter). 
    # Type: string
    # Default: "added"
    filter_mode: ''

    # When using [ESlint](https://eslint.org/) `v8.x` use 
    # this option to pass the 
    # .eslintignore file to silence ignore 
    # files warning [ignore file](https://eslint.org/docs/latest/use/configure/ignore-deprecated#using-an-alternate-file) 
    # Type: string
    ignore_path: ''

    # [ESLint](https://eslint.org/docs/latest/use/configure/ignore) [configuration file](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files) ignores key. Optionally 
    # ignoring files in the `ignores` 
    # key from being passed to 
    # ESLint, this input would be 
    # ignored when `all_files` is set 
    # to `true`. 
    # Type: string
    ignore_patterns: ''

    # Report level for reviewdog (info,warning,error)
    # Type: string
    # Default: "error"
    level: ''

    # Relative path under GITHUB_WORKSPACE to 
    # the repository 
    # Type: string
    # Default: "."
    path: ''

    # [Reporter](https://github.com/reviewdog/reviewdog#reporters) of reviewdog command (github-check, github-pr-review). 
    # github-pr-review can use Markdown and 
    # add a link to the 
    # rule page in reviewdog reports. 
    # Type: string
    # Default: "github-pr-review"
    reporter: ''

    # Skip running reviewdog i.e don't 
    # add any annotations. 
    # Type: boolean
    # Default: "false"
    skip_annotations: ''

    # Skip initially fetching additional history 
    # to improve performance for shallow 
    # repositories. NOTE: This could lead 
    # to errors with missing history. 
    # It's intended to be used 
    # when you've fetched all necessary 
    # history to perform the diff. 
    # Type: boolean
    # Default: "false"
    skip_initial_fetch: ''

    # [GITHUB TOKEN](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow) or a repo scoped [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) 
    # Type: string
    # Default: "${{ github.token }}"
    token: ''

    # Force the use of Github's 
    # REST API even when a 
    # local copy of the repository 
    # exists 
    # Type: boolean
    # Default: "false"
    use_rest_api: ''

Credits

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Clinton Blackburn
Clinton Blackburn

💻
Sava Vidakovic
Sava Vidakovic

💻 ⚠️ 📖
Aravind
Aravind

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!