DEV Community

sfrunza13
sfrunza13

Posted on

1

My Photohub

My Photohub

The idea for my photohub is a very cool one, essentially a UI for uploading images to a github repository.

The project is in its very first stages now and just finding its legs and it's great to be a part of that start. I noticed that there was no linter config file on the root of the project and so I decided to add linting with eslint and a .eslintrc.js config file.

Things I learned

I don't think I have linted a react project before so I did not realize that the regular es lint would not cut it, it was giving me linting errors for the use of certain characters I knew were properly being utilized within the context of a React page such as JSX. I went online and found that there is in fact a plugin that has a lot of the recommended alterations ready to go, plug and play style called eslint-plugin-react which you can specify in the .eslintrc.js file along with a few other alterations like detecting the react version and adding jsx to parserOptions.ecmaFeatures. Which once I did I was still getting errors but ones that were more apropos our React syntax.

From the linter I learned that it's apparently good form to always validate your props types in React. We had a few functional components in the project that were being exported in the same line they were being defined, separating the export and the function definition gives us the space we need to bring in prop-types and start validating we are using what we expect to be using in our component.

So I got to work separating the exports from the functions and adding a .propTypes check for each of them. After that and adding React to some import statements (not sure why the linter was complaining about this), there were no more errors and I was ready to push.

Revisions

Taimoor Dawami suggested that I add prettier formatting and some instructions on how to use the linting script and the formatter in CONTRIBUTING.md and so I did both of those things in subsequent commits.

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Image of DataStax

AI Agents Made Easy with Langflow

Connect models, vector stores, memory and other AI building blocks with the click of a button to build and deploy AI-powered agents.

Get started for free

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay