Skip to content

launchdarkly-labs/fix-it-felix

Repository files navigation

πŸ› οΈ Fix-it Felix - GitHub Action

Fix-it Felix is a GitHub Action that automatically fixes minor code quality issues (linting, formatting) in pull requests. It's designed to be configurable, safe, and work across multiple repositories in your organization.

✨ Features

  • πŸ”§ Multiple Fixers: Support for ESLint, Prettier, and Markdownlint
  • 🎨 Custom Commands: Use your own npm scripts or custom commands
  • βš™οΈ Configurable: Per-repository configuration via .felixrc.json
  • πŸ€– Auto-commit: Automatically commits fixes to PR branches
  • πŸ›‘οΈ Safety First: Built-in safeguards against infinite loops
  • πŸ” Dry-run Mode: Preview changes without committing
  • 🚫 Skip Control: Label-based opt-out mechanism
  • πŸ“„ Draft PR Control: Optionally skip draft PRs
  • 🍴 Fork Friendly: Handles forked PRs gracefully

πŸš€ Quick Start

Basic Usage

Create .github/workflows/fix-it-felix.yml in your repository:

name: Fix-it Felix

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  autofix:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      # ⚠️ REQUIRED: Install dependencies before running Felix
      # This ensures your project's exact tool versions and configs are used
      - name: Install dependencies
        run: npm ci

      - name: Run Fix-it Felix
        uses: launchdarkly-labs/fix-it-felix@v1
        with:
          fixers: 'eslint,prettier'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

πŸ“– Inputs

Input Description Required Default
fixers Comma-separated list of fixers to run No eslint,prettier
commit_message Commit message for auto-fix commits No πŸ€– Fix-it Felix: Auto-fixed code quality issues
config_path Path to Felix configuration file No .felixrc.json
dry_run Run in dry-run mode (comment instead of commit) No false
skip_label PR label that skips Felix processing No skip-felix
skip_draft_prs Skip processing draft pull requests No false
allowed_bots Comma-separated list of bot names Felix should run against No ``
paths Comma-separated list of paths to run fixers on No .

πŸ“€ Outputs

Output Description
fixes_applied Whether any fixes were applied (true/false)
changed_files Comma-separated list of files that were modified

πŸ”§ Supported Fixers

ESLint

  • Default Command: npx eslint --fix .
  • Extensions: .js, .jsx, .ts, .tsx, .vue
  • Config: Respects existing ESLint configuration
  • Custom Commands: Override with your own npm scripts or commands

Prettier

  • Default Command: npx prettier --write
  • Extensions: .js, .jsx, .ts, .tsx, .json, .css, .scss, .md, .yml, .yaml
  • Config: Respects existing Prettier configuration
  • Custom Commands: Override with your own npm scripts or commands

Markdownlint

  • Default Command: npx markdownlint-cli2 --fix
  • Extensions: .md, .markdown
  • Config: Respects existing Markdownlint configuration
  • Custom Commands: Override with your own npm scripts or commands

βš™οΈ Configuration

Basic Setup

Control Felix through action inputs:

- name: Run Fix-it Felix
  uses: launchdarkly-labs/fix-it-felix@v1
  with:
    fixers: 'eslint,prettier' # Which tools to run
    paths: 'src,docs' # Which directories to process
    dry_run: false # Set to true to preview changes

Repository Configuration

For advanced settings, create a .felixrc.json file:

{
  "fixers": ["eslint", "prettier"],
  "paths": ["src", "docs"],
  "ignore": ["node_modules/**", "dist/**"],
  "eslint": {
    "configFile": ".eslintrc.js",
    "extensions": [".js", ".jsx", ".ts", ".tsx"]
  },
  "prettier": {
    "extensions": [".js", ".jsx", ".ts", ".tsx", ".json", ".md"]
  }
}

Custom Commands

Use your own npm scripts instead of built-in commands:

{
  "eslint": {
    "command": ["npm", "run", "lint:fix"],
    "appendPaths": true // Append file paths for performance
  },
  "prettier": {
    "command": ["npm", "run", "format"],
    "appendPaths": false // Run script as-is
  }
}

πŸ“š Full Configuration Guide β†’

πŸ“š Documentation

πŸ›‘οΈ Safety Features

Infinite Loop Protection

  • Detects commits made by Felix or other bots
  • Skips processing if last commit was automated
  • Prevents endless fix-commit cycles
  • Exception: Bots listed in allowed_bots will bypass this protection

Fork Handling

  • Automatically detects forked PRs
  • Skips processing (cannot commit to forks with default token)
  • Logs appropriate messages

Draft PR Handling

By default, Felix processes draft PRs just like regular PRs. You can configure Felix to skip draft PRs entirely:

- name: Run Fix-it Felix
  uses: launchdarkly/fix-it-felix-action@v1
  with:
    skip_draft_prs: true

This is useful when you want to:

  • Prevent commits on work-in-progress PRs
  • Let developers refine their changes before auto-fixing
  • Reduce action runs during development

Skip Mechanisms

  • Label-based: Add skip-felix label to PR
  • Draft PRs: Set skip_draft_prs: true to skip draft PRs
  • Configuration: Set fixers: [] in .felixrc.json
  • Event-based: Only runs on specific PR events

πŸ” Dry-run Mode

Test Felix without committing changes:

- name: Run Fix-it Felix (Dry Run)
  uses: launchdarkly-labs/fix-it-felix@v1
  with:
    fixers: 'eslint,prettier'
    dry_run: true
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

In dry-run mode, Felix will:

  • Run all configured fixers
  • Generate a PR comment with proposed changes
  • Not commit or push any changes

πŸ“ Examples

See the examples/ directory for workflow examples:

πŸ”§ Development

Prerequisites

  • Node.js 20+
  • npm

Setup

npm install

Build

npm run build

Test

npm test

Package for Release

npm run package

🀝 Contributing

  1. Create a feature branch
  2. Make your changes
  3. Add tests if applicable
  4. Run npm run package to update the distribution
  5. Submit a pull request

🎯 Roadmap

  • Support for more fixers (stylelint, gofmt, black, etc.)
  • Custom fixer support βœ… Completed - Use custom commands
  • Monorepo support
  • Slack/Discord notifications
  • Performance optimizations

Made with ❀️ by LaunchDarkly

About

GitHub action to auto-fix PRs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •