Skip to content

SNOW-2112371 Add prettier and format the repo #1073

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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-rsavenok
Copy link
Collaborator

@sfc-gh-rsavenok sfc-gh-rsavenok commented May 13, 2025

Description

Adds prettier and formats all files in the repo.

Why? (Pros)

  • (almost) 0 config code formatter for all of our files
  • Its formatting/checking is faster than ESLint
  • ESLint deprecated all code formatting rules in the newest version

Cons of using prettier?

  • It's highly opinionated about how the code should be formatted, so unlike ESLint, rules can't be disabled in specific places

New libraries added

  • husky - installs git hooks on npm installs
  • lint-staged - find all changed files before commit
  • prettier - code formatter

Combination of those 3 allows to autoformat the changed file in a pre-commit git hook

Security Review

https://github.com/snowflakedb/security_reviews/pull/6849

Checklist

  • Create tests which fail without the change (if possible)
  • Make all tests (unit and integration) pass (npm run test:unit and npm run test:integration)
  • Extend the types in index.d.ts file (if necessary)
  • Extend the README / documentation and ensure is properly displayed (if necessary)
  • Provide JIRA issue id (if possible) or GitHub issue id in commit message

Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@sfc-gh-snowflakedb-snyk-sa
Copy link
Contributor

sfc-gh-snowflakedb-snyk-sa commented May 13, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@@ -2,7 +2,6 @@
Please explain the changes you made here.

### Checklist
- [ ] Format code according to the existing code style (run `npm run lint:check -- CHANGED_FILES` and fix problems in changed code)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this one as our GH actions will fail anyway if the code is not linted

singleQuote: true,
tabWidth: 2,
endOfLine: 'lf',
printWidth: 100,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default prettier is 80, but since we have lots of log messages, I think it's reasonable to increase it to 100

},
'rules': {
rules: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all rules that are defaults in prettier

"scripts": {
"lint:check": "eslint && check-dts index.d.ts",
"lint:check:all": "eslint lib samples system_test test && check-dts index.d.ts",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reduced the number of lint scripts to only those that run on the CI/Precommit hook, because developers shouldn't need to run them manually.

In rare cases where a developer needs to run something specific, node supports that using npx eslint ..arguments.. and npx prettier ..arguments...

@sfc-gh-rsavenok sfc-gh-rsavenok changed the title Add prettier and format the repo SNOW-2112371 Add prettier and format the repo May 20, 2025
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.

3 participants