-
Notifications
You must be signed in to change notification settings - Fork 5
Fix and optimize ESLint config #25
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
Conversation
Moving back to draft. Seeing a couple more issues. |
rules: { | ||
// Prevent dead code accumulation | ||
'@typescript-eslint/no-unused-vars': 'error', | ||
// The usage of `any` defeats the purpose of typescript. Consider using `unknown` type instead instead. |
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.
Totally unrelated sidebar but for the template did the team discuss the merits of js vs ts somewhere?
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.
@aligg Good question, I'm not sure. Do you remember @lorenyu @rocketnova?
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.
Don't think so, but at this point I think there's enough in house expertise with typescript and the ecosystem is mature enough that I think it's a pretty easy decision to go with typescript for the type safety which speeds up development
@@ -30,13 +30,14 @@ For linting, this application is leveraging `eslint`, `prettier` and Nava's [esl | |||
|
|||
In VSCode, do so by creating a `.vscode/settings.json` file with: | |||
|
|||
``` | |||
```json | |||
{ | |||
"editor.codeActionsOnSave": { | |||
"source.fixAll.eslint": true |
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.
this still means that format on save is done by prettier not eslint?
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.
Yep, I think this fixAll
line results in the --fix
flag being ran with ESLint when a file is changed: https://eslint.org/docs/latest/user-guide/command-line-interface#fixing-problems
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.
still a bit unfamiliar with line by line eslintrc configs but following a read through most make sense /lgtm
Changes
These changes fix a number of issues I noticed or ran into when opening the top-level directory in VS Code.
__dirname
fortsconfigRootDir
. The previous setting wasn't working for me. This also allows us to add inline code comments to explain the confusing aspects of the file (basically every line).root: true
so ESLint doesn't attempt to continue searching for lint settings above theapp
directoryoverrides
blocks. This is an optimization, but also fixed an issue I was running into (see screenshot below)Testing
Before:
After moving TypeScript lint settings into
overrides
(working TS and ESLint actions, but redundant errors):After
plugin:@typescript-eslint/eslint-recommended
was added to the list (less redundant errors)