question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier should cause CI to fail if code contains formatting issues

See original GitHub issue

When I run yarn format locally, it fixes files which I didn’t touch myself.

Shouldn’t CI pipeline fail for these formatting issues so they don’t land on develop branch?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
thdkcommented, Apr 21, 2021

What about changing the build script in package.json to:

"build": "prettier --check src/ && eslint src/ && CI=true react-scripts build",

0reactions
darrenvongcommented, Aug 18, 2021

Ive commited an attempt to add a job to gitlab ci to run just the prettier check.

I think it’s better to use the same image as frontend and the version of Prettier already installed in the dev dependencies, since Prettier are pretty aggressive at changing the formatting rules between even non-major versions, so using npx will likely introduce discrepancies from what we got installed locally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add diff in output of --check (for CI use cases) #6885 - GitHub
When formatted with Prettier, the comment is moved to the next line causing ESLint (which shouldn't have thrown an error) to throw an...
Read more >
CLI - Prettier
Applying this practice will minimise the number of times the CI fails because of code formatting problems. If you need to pipe the...
Read more >
Why does Prettier not format code in VS Code? - Stack Overflow
Select File -> Preferences -> Settings ( Ctrl + comma ) and search form formatter; Set Prettiers as Default formatter. enter image ...
Read more >
Fail pipelines which fail prettier code formatting standards
Let's "prettify" the remainder of our frontend codebase and then make this a hard failure in CI once we're done.
Read more >
Integrating and Enforcing Prettier & ESLint
code processed with prettier-eslint can still be considered incorrectly formatted by Prettier because this is just a hack · we're assuming that ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found