Skip to content

chore(site): align ESLint config to typescript-eslint's recommended-requiring-type-checking #5797

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

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Jan 19, 2023

From https://twitter.com/jsjoeio/status/1616168014172557314:

  1. Has the config extend https://typescript-eslint.io/linting/configs#recommended-requiring-type-checking, not just https://typescript-eslint.io/linting/configs#recommended
  2. Removes rule overrides that aren't necessary. Those are mostly:
  3. Fixed all immediately fixable rule complaints (commented inline)
  4. Disabled the rest of the newly complaining rules in the ESLint config, with a TODO comment each

I'd definitely recommend filing those TODOs in your backlog and linking to them in the config file. Most of those rules can catch an instance of any or some other unfortunate practice sneaking into your app. Though, note that the ones around template string concatenation might not have as many (or any) reports after typescript-eslint/typescript-eslint#6014 lands.

@github-actions
Copy link

github-actions bot commented Jan 19, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! ✨

@JoshuaKGoldberg
Copy link
Contributor Author

Wait wait, it's still a draft and I still have to fix or disable the lint complaints. There's much more to come 😄

@JoshuaKGoldberg
Copy link
Contributor Author

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

@kylecarbs
Copy link
Member

@JoshuaKGoldberg I figured, but still agree with the thread linked. I'll re-review once all the changes are made!

@@ -20,8 +20,7 @@ export const hardCodedCSRFCookie = (): string => {
export const withDefaultFeatures = (
fs: Partial<TypesGen.Entitlements["features"]>,
): TypesGen.Entitlements["features"] => {
for (const k in TypesGen.FeatureNames) {
const feature = k as TypesGen.FeatureName
for (const feature of TypesGen.FeatureNames) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://typescript-eslint.io/rules/no-for-in-array

A for-in loop (for (var i in o)) iterates over the properties of an Object. While it is legal to use for-in loops with array types, it is not common. for-in will iterate over the indices of the array as strings, omitting any "holes" in the array.

@@ -152,8 +151,7 @@ export const getTokens = async (): Promise<TypesGen.APIKey[]> => {
}

export const deleteAPIKey = async (keyId: string): Promise<void> => {
const response = await axios.delete("/api/v2/users/me/keys/" + keyId)
return response.data
await axios.delete("/api/v2/users/me/keys/" + keyId)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function indicates it returns Promise<void>, so any returned data is ignored. It's violating @typescript-eslint/no-unsafe-return anyway so I figured I'd clean it up. 🙂

const bannerPillSingular = await screen.queryByText(Language.licenseIssue)
const bannerPillPlural = await screen.queryByText(Language.licenseIssues(2))
const bannerPillSingular = screen.queryByText(Language.licenseIssue)
const bannerPillPlural = screen.queryByText(Language.licenseIssues(2))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

screen.queryByText, screen.getByRole, etc. don't return Promises. There's no need to await them.

@typescript-eslint/await-thenable

await (
await getUsers(queryToFilter(query))
).users,
(await getUsers(queryToFilter(query))).users,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also is an await of something (.users) that is not async.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review January 19, 2023 20:54
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner January 19, 2023 20:54
@JoshuaKGoldberg JoshuaKGoldberg requested review from code-asher and kylecarbs and removed request for a team and code-asher January 19, 2023 20:54
@BrunoQuaresma
Copy link
Collaborator

BrunoQuaresma commented Jan 24, 2023

@JoshuaKGoldberg thx for your contribution! There is just one minor conflict to solve before we merge it. Unfortunately, I don't have permission for it.

@BrunoQuaresma BrunoQuaresma requested review from BrunoQuaresma and removed request for kylecarbs and BrunoQuaresma January 24, 2023 14:51
@BrunoQuaresma BrunoQuaresma self-assigned this Jan 24, 2023
@JoshuaKGoldberg
Copy link
Contributor Author

...huh, I swear I used to know where that option was. Fixed!

@BrunoQuaresma BrunoQuaresma merged commit 43a441f into coder:main Jan 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2023
@JoshuaKGoldberg JoshuaKGoldberg deleted the ts-eslint-recommended-requiring-type-checking branch January 26, 2023 13:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants