[Draft] Palak Add support for Prettier Config #604
Closed
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.
Description
This pull request aims to improve code formatting consistency across the team by aligning ESLint and Prettier configurations. In addition to the rule adjustments, I've included specific rules to handle unnecessary list warnings or errors, promoting cleaner and more maintainable code.
Benefits of Using
.prettierrc
and Format-on-Save:Motivation
In numerous pull requests, I observed formatting inconsistencies leading to challenges and unnecessary changes in files solely due to formatting differences. This PR addresses these issues, streamlining the development process and enhancing code readability by establishing a standardized code format.
Related PRS (if any):
N/A
Main changes explained:
Created
.prettierrc
fileFormatting Consistency:
semi: true
) to ensure a consistent style throughout the codebase.singleQuote: true
) to maintain a unified and clean look for strings.trailingComma: "none"
) to adhere to a no-trailing-comma style.printWidth: 100
) for better readability and adherence to code review standards.tabWidth: 2
) for a clean and readable code layout.bracketSpacing: true
) to improve code readability.arrowParens: "always"
) to enhance code consistency.ESLint Configuration:
object-curly-newline
rule ("object-curly-newline": 0
) to allow more flexibility in object destructuring formatting.arrow-parens
rule ("arrow-parens": "off"
) to allow more flexibility in arrow function parameter parentheses.no-console
rule ("no-console": ["error", { "allow": ["warn", "error"] }]
) to allow the use ofconsole.warn
andconsole.error
in addition toconsole.log
.comma-dangle
rule ("comma-dangle": "off"
) to allow trailing commas in object literals and array literals.no-else-return
rule ("no-else-return": "off"
) to eliminate warnings related to unnecessaryelse
statements.consistent-return
rule ("consistent-return": "off"
) to allow more flexibility in return statement consistency.Added prettier and eslint related packages to dev dependencies in package.json
How to test:
check into current branch
do
npm install
and...
to run this PR locallyConfigure Prettier Extension:
Configure VS Code Settings:
Ctrl + ,
orCmd + ,
).Prettier - Code Formatter
as the default formatter.Enable Format On Save:
Format On Save
option for automatic formatting.Test Formatting:
.js
file from your project.Ctrl + S
orCmd + S
).Repeat Testing:
These steps ensure that the Prettier configuration is applied consistently through the "Format On Save" feature, enhancing the overall code formatting experience for all team members.
Next Steps
This is my first PR. I am looking forward to getting some more suggestions and feedback.
Once this PR is approved, Consider creating a separate pull request dedicated solely to formatting fixes. This makes it easier to track changes and allows team members to review and discuss formatting adjustments specifically. The formatting PR will resolve any lingering formatting issues across the codebase, contributing to a polished and standardized look.
Screenshots or videos of changes:
I have tested the changes to two files.
src/controllers/dashBoardController.js
andsrc/controllers/actionItemController.js
.Note:
This is still a draft PR. Please reach out to me if any doubts. There are a lot of things that can still be added to the configurations.