-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: ESLint config #1025
base: main
Are you sure you want to change the base?
fix: ESLint config #1025
Conversation
✅ Deploy Preview for findadoc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
No dependency changes detected. Learn more about Socket for GitHub ↗︎ 👍 No dependency changes detected in pull request |
e3ebf10
to
b8ec835
Compare
b8ec835
to
b2d35f0
Compare
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.
@gminetoma Great work.
Left a few comments. A couple questions and then I will passed it off to Phil
@@ -62,7 +62,8 @@ export default withNuxt( | |||
], | |||
'vars-on-top': 'off', | |||
yoda: ['error', 'never', { exceptRange: true }], | |||
'no-console': 'error', // we should use the logger instead | |||
// Change to a logger in the future |
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.
Do you want to write a proposal and research what logger can be implemented. Give a few choices as to what you found and the benefits to each. You can use the template in the gitbook
. @ermish does that sound good?
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.
Or @ermish do you already have one you like?
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.
We already have a specific one to use. It's with Grafana / Prometheus
if (!data) { | ||
return | ||
} |
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.
The new linting rules want this styling? I like it as long as it's consistent. Also probably more readable for people learning a codebase. 😎
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.
I didn't change any rules besides the no-console
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.
@gminetoma you actually added a bunch of rules by adding the recommended ones. Many times they don't fit our codebases style and what we agreed upon. I haven't read through the rest but our two choices are either inherit from recommended then override the specific ones or stop using recommended and just list out the rules. Usually there's not that many that are 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.
Personally for this one, I like simple returns and would like to change this rule back.
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.
My intention was to apply the correct recommended rules since ...tseslint.configs.recommended
was only being applied in the rules, which was denying all the rules in the block.
I just fixed it, but if this is not what was intended, we can remove it.
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.
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.
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.
Let's add an override and use the simpler way 👍
Sorry if I wasn't clear, I meant even though you didn't add any specific rules, this PR still does enable rules that were not being linted before it.
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.
Should I make this a rule, or can we leave it up to the developer to decide? What format do you prefer?
if (condition) return
if (condition) {
return
}
stores/locationsStore.ts
Outdated
alert('Error getting data! Please contact our support team by clicking the bottom right link on the page!') | ||
console.error('Error getting data! Please contact our support team by clicking the bottom right link on the page!') |
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.
Nice! This alert would cause a 500 on yarn dev:localserver
if the backend wasn't running
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.
Wait. This was intentionally an alert because it's saying our whole site has crashed and we want to tell the user. We could replace this with a modal as an alternative, but console won't work here.
We also have a console error in the line before to give more dev details which this is now duplicating
c276cbb
to
5445d95
Compare
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.
@ermish On to you. I tagged you in a couple of my comments
Actually I'm going to use my judgment to say I want to have return there but not have to explicitly say I defined. So not yet to you |
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.
Actually, I changed my mind. Sorry to do that. Could you see if it is possible to update the config to not require explicitly stating undefined. I am fine with there being a return. But adding undefined seems extra, like a semicolon and we don't use those
5445d95
to
1f77280
Compare
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.
Ok @ermish now it is all yours
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.
Human linting of the PR complete!
eslint.config.js
Outdated
}, | ||
settings: { | ||
vitest: { | ||
typecheck: 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.
I don't think we want this feature turned on. It's going to run tsc which would duplicate the typescript Linting and slow things down.
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 feature is for Vitest if type checking is enabled in its config.
Since it's not, I'll remove it.
https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#enabling-with-type-testing
https://vitest.dev/guide/testing-types
i18n/checkLocaleKeys.js
Outdated
import fs from 'fs' | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
// Convert import.meta.url to __dirname equivalent | ||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
const fileName = fileURLToPath(import.meta.url) |
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.
These are reserved names and should be kept.
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.
Should I keep it or remove it? These names are not available in ES modules.
We have rules that block the usage of "_" for variable naming.
Even if we were running a .cjs
script, we shouldn't modify them.
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.
They're well known names in the JavaScript/node space. The linting is from new rules added in this PR that are throwing the error so we should just override the rule.
I think the rule can be ok if it allows exceptions for any other reserved words/special cases
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.
I added this file to the ignore list since it doesn't follow a bunch of our rules.
I also reverted all its changes.
@@ -100,7 +100,7 @@ async function queryProfessionals(searchSpecialty?: Specialty, searchLanguage?: | |||
return professionalsSearchResult | |||
} catch (error) { | |||
console.error(`Error getting professionals: ${JSON.stringify(error)}`) | |||
alert('Error getting data! Please contact our support team by clicking the bottom right link on the page!') |
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.
Also should keep this one
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.
I'm bringing the alerts back. Should I remove the rule or ignore them per line?
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.
Good question. Probably ignore on the lines. We don't want to accidentally check in any other alerts and realistically the ONLY time you should use an alert is when everything is failing
@@ -135,7 +135,7 @@ async function queryFacilities(healthcareProfessionalIds: string[], searchCity?: | |||
return locationFilteredSearchResults | |||
} catch (error) { | |||
console.error(`Error getting facilities: ${JSON.stringify(error)}`) | |||
alert('Error getting data! Please contact our support team by clicking the bottom right link on the page!') |
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.
And this one
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.
@NabbeunNabi We can make a separate issue for moving these alerts to nicer user modal messages
utils/handleServerErrorMessaging.ts
Outdated
@@ -13,7 +13,7 @@ export function handleServerErrorMessaging( | |||
} | |||
toast.error((t('serverErrorMessages.genericErrorMessage'))) | |||
console.error((t('serverErrorMessages.genericErrorMessage'))) | |||
console.info(t('serverErrorMessages.errorCodeMessagingNeeded')) |
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.
I think this one should be info since we already have the error right before it
Allow console warn, error and info
1f77280
to
9196c52
Compare
9196c52
to
b9d41b1
Compare
The `consistent-return` rule causes inconsistencies across the codebase. It requires returning values like `return undefined`, which is unnecessary.
Renamed `l` and `o` to `currentLocale`
b9d41b1
to
ff68d08
Compare
Fix ignores paths
Some lines are supposed to work this way.
ff68d08
to
fbef2f0
Compare
✅ Resolves #982
🔧 What Changed
We are now using the correct recommended TSESLint rules (
tseslint.configs.eslintRecommended.rules
).Previously, we were using the wrong plugin property:
tseslint.configs.recommended
. This includes not only the rules but the entire recommended plugin configuration.Added Vitest ESLint Plugin and Fixed the Following Errors:
Styling
yarn lint --fix
and manually fixedmax-statements-per-line
.no-console
console.log
.console.warn
,console.error
andconsole.info
can still be used.console
commands once a logger is added.no-underscore-dangle
no-shadow
consistent-return
no-alert
eslint-disable-next-line no-alert
Notes:
I didn't remove the
require-atomic-updates
warning. This needs further investigation—it may just be a false alarm.