Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated Prettier static analysis tool #53

Open
wants to merge 1 commit into
base: f24
Choose a base branch
from

Conversation

sofian-syed
Copy link

@sofian-syed sofian-syed commented Oct 24, 2024

This pull request integrates Prettier into the NodeBB project to ensure consistent code formatting across the codebase and improved styling practices.

In the root directory, a configuration file (.prettierrc) has been created to define formatting rules such as line length, single quotes, and trailing commas. Additionally, also in the root directory, a .prettierignore file has been added to exclude unnecessary files and directories from formatting.

Prettier can be run using the command npx prettier --write ., which will apply the formatting rules defined in the .prettierrc file. The output of the Prettier run has been attached in the prettier-output.txt file as evidence of successful execution. I have also included images of the tool running locally at the end of this PR.

In this PR, I will also answer some questions from the writeup (Evaluation Questions):
What types of problems are you hoping your tooling will catch? What types of problems does this particular tool catch?
Prettier is designed to catch and fix inconsistencies in code formatting such as improper indentation, incorrect line lengths, use of double vs. single quotes, and missing or extra semicolons. The primary goal is to ensure that the codebase adheres to a consistent style.

What types of customization are possible or necessary?
Prettier offers customization for formatting including rules for line length, quote styles, trailing commas, bracket and indentation spacing. For our project, we configured these options via the .prettierrc file. setting rules such as using single quotes and enforcing trailing commas for multi-line objects. The .prettierignore file was also customized to exclude specific directories and files that should not be formatted like node_modules, public, and Docker configuration files.

How can/should this tool be integrated into a development process?
Prettier should be integrated as part of the CI/CD pipeline ideally running automatically before code is committed. Additionally, developers can integrate Prettier into their editor to format files automatically on save.

Are there many false positives? False negatives? True positive reports about things you don't care about?
Prettier doesn’t typically produce false positives or false negatives since its role is to format the code according to predefined rules. The tool will consistently report true positives regarding code style issues but these are not functional errors but only style corrections.

Below are also a few screenshots of the tool running locally.
Screenshot 2024-10-23 at 10 25 57 PM
Screenshot 2024-10-23 at 10 26 01 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants