-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ESLint - The Essential Linter and Formatter for JavaScript and TypeScript #1224
Conversation
This reverts commit 77a88e0.
Wasn't the issue with eslint and an auto formatter that a different dev didn't like the output of the formatted code? Also secretly hoping we enable |
Well, it's customizable so we are discussing the rules internally at the moment. |
@Greenlamp2
IMHO, I very much prefer to have a standardized way of doing things than to let everyone bring their own convention. For instance, I usually prefer double-quote strings, but I very much prefer that I'm required to use single-quote strings rather than having both existing in the same project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Greenlamp2
Thanks for this initiative!
-
If you prefer not to use the pre-commit hook, you can manually run ESLint to automatically fix issues using the command
Do we want to allow that? In the sense that I believe we should enforce the rules in the repository, as to avoid inconsistencies in the codebase.
What do you think? cc: @bennybroseph
-
Also, on another note, do you think it would make sense to enable a Github Action (like this one) to run the linter in PRs as well, just to avoid inconsistencies in the codebase if someone bypasses the hooks (either by not installing the hooks in the first place, or by committing with
--no-verify
)?
I know the free-tier includes 2000 minutes per month, but I honestly have no idea about the time the linter usually takes to run on a file, and how many times the action will be run. I believe before diving into that, it would be great to know if that could be an enhancement of the current process or not.What do you think?
yes a Github action would be perfect, we can try it, 2000min can be translated to around 4000 commits, i don't know how many commits we do every month though, it will need to be tracked somehow. |
…eslint # Conflicts: # src/battle-scene.ts # src/battle.ts # src/data/ability.ts # src/field/pokemon.ts # src/game-mode.ts # src/locales/de/voucher.ts # src/locales/es/battle-message-ui-handler.ts # src/locales/es/berry.ts # src/locales/es/menu-ui-handler.ts # src/locales/es/pokemon-info.ts # src/phases.ts # src/ui/text.ts # src/utils.ts
…at/eslint # Conflicts: # src/battle-scene.ts # src/battle.ts # src/data/ability.ts # src/field/pokemon.ts # src/game-mode.ts # src/locales/de/voucher.ts # src/locales/es/menu-ui-handler.ts # src/locales/es/pokemon-info.ts # src/phases.ts # src/ui/text.ts # src/utils.ts
stage_fixed: true in the lefthook.yml is to add the linted files to the commit, otherwise a second commit with eslint would be needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks for taking the time to work on that!
I just left a comment about updating the README, but the configuration and the workflow looks great!
@Greenlamp2 |
everything will be squashed on merge, don't worry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it begins
…ript (pagefaultgames#1224) * eslint config + packages * updated eslint config * fix the issue eslint adding ;;;; at interfaces * first round with eslint --fix . * removed config for unused export * Revert "first round with eslint --fix ." This reverts commit 77a88e0. * removed config for camelCase * for real this time, first round of eslint --fix . * halfway to manual eslint fix * eslint done * added "how to setup" the hook to eslint --fix each new file before commit (if wanted) * removed eslintrc config file duplicat * fix human error + ignore build folder + merge overrides * added curly brace style + eslint * applied double quote linter rule * added lefthook * test precommit * test precommit * test precommit * test precommit * test precommit * test precommit * test precommit * github action to run eslint * added node_modules to ignore eslint * different action for typescript * no need for different glob (default src) * node 20 * node 20 * removed no longer needed install file * remove hooks part from README * eslint fixes --------- Co-authored-by: Frederico Santos <frederico.f.santos@tecnico.ulisboa.pt>
Integrating ESLint for Improved Code Quality and Consistency
Introduction
ESLint is a powerful tool for identifying and fixing problems in JavaScript and TypeScript code. This addition will help us maintain a consistent code style, improve code quality, and catch potential bugs early.
Key Features
Automation:
Manual Usage:
npx eslint --fix . or npm run eslint
GitHub Action:
Summary of ESLint Rules
General Rules:
===
and!==
instead of==
and!=
(eqeqeq
).indent
).quotes
).var
; uselet
orconst
(no-var
).const
for variables that are never reassigned (prefer-const
).@typescript-eslint/no-unused-vars
).eol-last
).curly
).1tbs
) for TypeScript-specific syntax (@typescript-eslint/brace-style
).TypeScript-Specific Rules:
@typescript-eslint/semi
).@typescript-eslint/no-extra-semi
).Benefits
Conclusion
Integrating ESLint with these rules will greatly benefit our project by maintaining a high standard of code quality and consistency. Please review the PR and provide your feedback.
Thank you for your attention and cooperation!
Feel free to reach out if you have any questions or need further clarification on the ESLint rules. Happy coding!
Note: This presentation was assisted by AI.