DEV Community

Cover image for Create a PR to automatically fix code linting errors
Iacovos Constantinou
Iacovos Constantinou

Posted on

3 3

Create a PR to automatically fix code linting errors

This Github workflow aims to automatically fix as many lint errors as possible.

In particular, it executes eslint with --fix argument, so that we report and fix lint errors. Note that not all lint errors can be fixed automatically.

If any errors were fixed by eslint, a new PR is created including the changes made. The base is always the current branch while the assignee is the PR author.

This allows the PR author to review the changes and if needed merge them into the initial PR.

On top of that, the PR is marked with the label autofix.

My Workflow

The repository can be found here.

On purpose there is a lint error in index.js and you can review the PR created here to fix this. .

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo softius / actions-auto-improve-code-style

Create a PR automatically to fix code linting errors.

actions-auto-improve-code-style

This GitHub workflow executes eslint with --fix argument, so that we can not only capture but also automatically fix as many as possible.

If any errors were fixed by eslint, a new PR is created including the changes made. The base is always the current branch while the assignee is the PR author.

This allows the PR author to review the changes and if needed merge them into into the initial PR.




Additional Resources / Info

While this workflow uses eslint, the same approach can be used with phpcs/phpcbf and other linters.

To customize the workflow further, you can refer to this action.

Make sure to follow me on dev.to, Medium or Twitter to read more about PHP, Docker and other dev topics.

Photo by Ken Suarez on Unsplash

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay