DEV Community

Discussion on: React Clean Code - Simple ways to write better and cleaner code

Collapse
 
sebavuye profile image
Sebastian Vuye

Nice tips!

Adding a linter to your project can also help , as I recognize many lint warnings/errors in your tips.

Collapse
 
thawkin3 profile image
Tyler Hawkins • Edited

Thanks! I definitely agree that using a linter in any codebase is a must. You'll be happy to know that I used ESLint and Prettier in my project while preparing this article.

Linters will only go so far though, and they'll only catch the things that you configure them to.

For example, using the ESLint settings that react-scripts uses from create-react-app alongside my Prettier configuration, the only error caught in all of my code snippets above are the use of double quotes inside the curly braces in the fourth bad example.

Linters also won't be able to catch other code smells that only humans can see, such as bad variable names or confusing logic in the code. Ultimately it takes a human to ensure that the code is clean.