Integrated Prettier static analysis tool #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.