{"id":13532030,"url":"https://github.com/wearerequired/lint-action","last_synced_at":"2025-05-14T13:05:41.588Z","repository":{"id":36960726,"uuid":"229542559","full_name":"wearerequired/lint-action","owner":"wearerequired","description":"✨ GitHub Action for detecting and auto-fixing lint errors","archived":false,"fork":false,"pushed_at":"2025-04-14T08:28:46.000Z","size":2960,"stargazers_count":595,"open_issues_count":30,"forks_count":145,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-19T10:27:31.162Z","etag":null,"topics":["ci","code-style","formatting","github-actions","hacktoberfest","lint-action","linter","linting"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wearerequired.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-22T09:02:44.000Z","updated_at":"2025-04-16T18:55:48.000Z","dependencies_parsed_at":"2024-01-24T05:47:53.804Z","dependency_job_id":"4a6b350e-868f-498c-a123-8efe5ddd36ce","html_url":"https://github.com/wearerequired/lint-action","commit_stats":{"total_commits":658,"total_committers":29,"mean_commits":"22.689655172413794","dds":0.6291793313069909,"last_synced_commit":"df31ae8635c46366688e0bea44d7aba2e1468813"},"previous_names":["samuelmeuli/lint-action"],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearerequired%2Flint-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearerequired%2Flint-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearerequired%2Flint-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearerequired%2Flint-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wearerequired","download_url":"https://codeload.github.com/wearerequired/lint-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249859772,"owners_count":21335994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","code-style","formatting","github-actions","hacktoberfest","lint-action","linter","linting"],"created_at":"2024-08-01T07:01:07.684Z","updated_at":"2025-05-14T13:05:41.516Z","avatar_url":"https://github.com/wearerequired.png","language":"JavaScript","funding_links":[],"categories":["Community Resources","JavaScript"],"sub_categories":["Static Analysis"],"readme":"# ✨ Lint Action\n\n- **Shows linting errors** on GitHub commits and PRs\n- Allows **auto-fixing** issues\n- Supports [many linters and formatters](#supported-tools)\n\n_**Note:** The behavior of actions like this one is currently limited in the context of forks. See [Limitations](#limitations)._\n\n## Screenshots\n\n- Checks on pull requests:\n\n  \u003cimg src=\"./.github/screenshots/check-runs.png\" alt=\"Screenshot of check runs\" width=\"75%\" /\u003e\n\n- Commit annotations:\n\n  \u003cimg src=\"./.github/screenshots/check-annotations.png\" alt=\"Screenshot of ESLint annotations\" width=\"90%\" /\u003e\n\n## Supported tools\n\n- **C:**\n  - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html)\n- **C++:**\n  - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html)\n- **C#:**\n  - [dotnet-format](https://github.com/dotnet/format)\n- **CSS:**\n  - [stylelint](https://stylelint.io)\n- **Go:**\n  - [gofmt](https://golang.org/cmd/gofmt)\n  - [golint](https://github.com/golang/lint)\n- **JavaScript:**\n  - [ESLint](https://eslint.org)\n  - [Prettier](https://prettier.io)\n  - [XO](https://github.com/xojs/xo)\n- **Objective-C:**\n  - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html)\n- **Objective-C++:**\n  - [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html)\n- **PHP:**\n  - [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)\n- **Python:**\n  - [Autopep8](https://github.com/hhatto/autopep8)\n  - [Black](https://black.readthedocs.io)\n  - [Flake8](http://flake8.pycqa.org)\n  - [Mypy](https://mypy.readthedocs.io/)\n  - [oitnb](https://pypi.org/project/oitnb/)\n  - [Pylint](https://pylint.pycqa.org)\n- **Ruby:**\n  - [ERB Lint](https://github.com/Shopify/erb-lint)\n  - [RuboCop](https://rubocop.readthedocs.io)\n- **Rust:**\n  - [clippy](https://github.com/rust-lang/rust-clippy)\n  - [rustfmt](https://github.com/rust-lang/rustfmt)\n- **Swift:**\n  - [swift-format](https://github.com/apple/swift-format) (official)\n  - [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) (by Nick Lockwood)\n  - [SwiftLint](https://github.com/realm/SwiftLint)\n- **TypeScript:**\n  - [tsc](https://www.typescriptlang.org/docs/handbook/compiler-options.html)\n- **VB.NET:**\n  - [dotnet-format](https://github.com/dotnet/format)\n\n## Usage\n\nCreate a new GitHub Actions workflow in your project, e.g. at `.github/workflows/lint.yml`. The content of the file should be in the following format:\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  # Replace pull_request with pull_request_target if you\n  # plan to use this action with forks, see the Limitations section\n  pull_request:\n    branches:\n      - main\n\n# Down scope as necessary via https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token\npermissions:\n  checks: write\n  contents: write\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      # Install your linters here\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          # Enable your linters here\n```\n\n## Examples\n\nAll linters are disabled by default. To enable a linter, simply set the option with its name to `true`, e.g. `eslint: true`.\n\nThe action doesn't install the linters for you; you are responsible for installing them in your CI environment.\n\n### JavaScript example (ESLint and Prettier)\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Set up Node.js\n        uses: actions/setup-node@v1\n        with:\n          node-version: 12\n\n      # ESLint and Prettier must be in `package.json`\n      - name: Install Node.js dependencies\n        run: npm ci\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          eslint: true\n          prettier: true\n```\n\n**Important:** Make sure to exclude the `.github` directory in your ESLint and Prettier configs as the default `GITHUB_TOKEN` **cannot** be used to update workflow files due to the missing `workflow` permission. See [Limitations](#limitations).\n\n### PHP example (PHP_CodeSniffer)\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Set up PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: \"7.4\"\n          coverage: none\n          tools: phpcs\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          php_codesniffer: true\n          # Optional: Ignore warnings\n          php_codesniffer_args: \"-n\"\n```\n\nIf you prefer to use [Composer](https://getcomposer.org/) you can also use this:\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Set up PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: \"7.4\"\n          coverage: none\n          tools: composer\n\n      - name: Install PHP dependencies\n        run: |\n          composer install --prefer-dist --no-progress --no-ansi --no-interaction\n          echo \"${PWD}/vendor/bin\" \u003e\u003e $GITHUB_PATH\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          php_codesniffer: true\n```\n\n### Python example (Flake8 and Black)\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Set up Python\n        uses: actions/setup-python@v1\n        with:\n          python-version: 3.8\n\n      - name: Install Python dependencies\n        run: pip install black flake8\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          black: true\n          flake8: true\n```\n\n### C, C++, Objective-C and Objective-C++ example (clang_format)\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Install ClangFormat\n        run: sudo apt-get install -y clang-format\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          clang_format: true\n```\n\n### C# and VB.NET example (dotnet_format)\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Set up .NET\n        uses: actions/setup-dotnet@v1\n        with:\n          dotnet-version: \"6.0.x\"\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          dotnet_format: true\n```\n\n### AutoFix example\n\n```yml\nname: Lint\n\non:\n  # Trigger the workflow on push or pull request,\n  # but only for the main branch\n  push:\n    branches:\n      - main\n  pull_request:\n    branches:\n      - main\n\njobs:\n  run-linters:\n    name: Run linters\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out Git repository\n        uses: actions/checkout@v4\n\n      - name: Set up Python\n        uses: actions/setup-python@v1\n        with:\n          python-version: 3.8\n\n      - name: Install Python dependencies\n        run: pip install black flake8\n\n      - name: Run linters\n        uses: wearerequired/lint-action@v2\n        with:\n          auto_fix: true\n          black: true\n          black_auto_fix: true\n          flake8: true\n          flake8_auto_fix: false\n```\n\nWith `auto_fix` set to `true`, by default the action will try and fix code issues automatically and commit and push them automatically. Here however, `flake8` linter does not support auto-fixing, so setting `flake8_auto_fix` to `false` will prevent any unnecessary warnings.\n\n## Configuration\n\n### Linter-specific options\n\n`[linter]` can be one of `autopep8`, `black`, `clang_format`, `dotnet_format`, `erblint`, `eslint`, `flake8`, `gofmt`, `golint`, `mypy`, `oitnb`, `php_codesniffer`, `prettier`, `pylint`, `rubocop`, `stylelint`, `swift_format_official`, `swift_format_lockwood`, `swiftlint` and `xo`:\n\n- **`[linter]`:** Enables the linter in your repository. Default: `false`\n- **`[linter]_args`**: Additional arguments to pass to the linter. Example: `eslint_args: \"--max-warnings 0\"` if ESLint checks should fail even if there are no errors and only warnings. Default: `\"\"`\n- **`[linter]_dir`**: Directory where the linting command should be run. Example: `eslint_dir: server/` if ESLint is installed in the `server` subdirectory. Default: Repository root\n- **`[linter]_extensions`:** Extensions of files to check with the linter. Example: `eslint_extensions: js,ts` to lint JavaScript and TypeScript files with ESLint. Default: Varies by linter, see [`action.yml`](./action.yml)\n- **`[linter]_command_prefix`:** Command prefix to be run before the linter command. Default: `\"\"`.\n- **`[linter]_auto_fix`:** Whether the linter should try to fix code style issues automatically. This option is useful to commit and push changes only for specific linters and not all of them when `auto_fix` option is set. Default: `true` if linter supports auto-fixing, `false` if not.\n\n### General options\n\n- **`github_token`:** The `GITHUB_TOKEN` to [authenticate on behalf of GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow#using-the-github_token-in-a-workflow). Defaults to the GitHub token.\n\n- **`continue_on_error`:** Whether the workflow run should also fail when linter failures are detected. Default: `true`\n\n- **`auto_fix`:** Whether linters should try to fix code style issues automatically. If some issues can be fixed, the action will apply the needed changes. Default: `false`\n\n  \u003cp align=\"center\"\u003e\n    \u003cimg src=\"./.github/screenshots/auto-fix.png\" alt=\"Screenshot of auto-fix commit\" width=\"80%\" /\u003e\n  \u003c/p\u003e\n\n- **`commit`:** Whether to commit and push the changes made by `auto_fix`. Default: `true`\n\n- **`git_name`**: Username for auto-fix commits. Default: `\"Lint Action\"`\n\n- **`git_email`**: Email address for auto-fix commits. Default: `\"lint-action@samuelmeuli.com\"`\n\n- **`git_no_verify`**: Bypass the pre-commit and pre-push git hooks. Default: `false`\n\n- **`commit_message`**: Template for auto-fix commit messages. The `${linter}` variable can be used to insert the name of the linter. Default: `\"Fix code style issues with ${linter}\"`\n\n- **`check_name`**: Template for the [name of the check run](https://docs.github.com/en/rest/reference/checks#create-a-check-run). Use this to ensure unique names when the action is used more than once in a workflow. The `${linter}` and `${dir}` variables can be used to insert the name and directory of the linter. Default: `\"${linter}\"`\n\n- **`neutral_check_on_warning`:** Whether the check run should conclude with a neutral status instead of success when the linter finds only warnings. Default: `false`\n\n### Linter support\n\nSome options are not available for specific linters:\n\n| Linter                | auto-fixing | extensions |\n| --------------------- | :---------: | :--------: |\n| autopep8              |     ✅      |  ❌ (py)   |\n| black                 |     ✅      |     ✅     |\n| clang_format          |     ✅      |     ✅     |\n| clippy                |     ✅      |  ❌ (rs)   |\n| dotnet_format         |     ✅      |  ❌ (cs)   |\n| erblint               |     ❌      |  ❌ (erb)  |\n| eslint                |     ✅      |     ✅     |\n| flake8                |     ❌      |     ✅     |\n| gofmt                 |     ✅      |  ❌ (go)   |\n| golint                |     ❌      |  ❌ (go)   |\n| mypy                  |     ❌      |  ❌ (py)   |\n| oitnb                 |     ✅      |     ✅     |\n| php_codesniffer       |     ❌      |     ✅     |\n| prettier              |     ✅      |     ✅     |\n| pylint                |     ❌      |  ❌ (py)   |\n| rubocop               |     ✅      |  ❌ (rb)   |\n| rustfmt               |     ✅      |  ❌ (rs)   |\n| stylelint             |     ✅      |     ✅     |\n| swift_format_official |     ✅      |     ✅     |\n| swift_format_lockwood |     ✅      | ❌ (swift) |\n| swiftlint             |     ✅      | ❌ (swift) |\n| tsc                   |     ❌      |  ❌ (ts)   |\n| xo                    |     ✅      |     ✅     |\n\n## Limitations\n\n### Pull requests\n\nThere are currently some limitations as to how this action (or any other action) can be used in the context of `pull_request` events from forks:\n\n- The action doesn't have permission to push auto-fix changes to the fork. This is because the `pull_request` event runs on the upstream repo, where the `github_token` is lacking permissions for the fork. [Source](https://github.community/t5/GitHub-Actions/Can-t-push-to-forked-repository-on-the-original-repository-s/m-p/35916/highlight/true#M2372)\n- The action doesn't have permission to create annotations for commits on forks unless you use the `pull_request_target` event. You can modify the default permissions granted to the `GITHUB_TOKEN` by using the `permissions` key and set the `checks` scope to `write`. See [GitHub documentation](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#permissions) for more.\n\n### Auto-fixing workflow files\n\nIf `auto_fix` is enabled and the default `GITHUB_TOKEN` is used, none of the linters should be allowed to change files in `.github/workflows` as the token doesn't have the necessary `workflow` permission. This can be achieved by adding the directory to the ignore config of the used linter. [Source](https://github.community/t/github-linting-remote-rejected/121365)\n\nFor details and comments, please refer to [#65](https://github.com/wearerequired/lint-action/issues/65) and [#74](https://github.com/wearerequired/lint-action/issues/74).\n\n\u003cbr\u003e\n\n[![a required open source product - let's get in touch](https://media.required.com/images/open-source-banner.png)](https://required.com/en/lets-get-in-touch/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwearerequired%2Flint-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwearerequired%2Flint-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwearerequired%2Flint-action/lists"}