Skip to content
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

Update ESLint config and apply changes #5599

Merged
merged 14 commits into from
Feb 10, 2025
Merged

Update ESLint config and apply changes #5599

merged 14 commits into from
Feb 10, 2025

Conversation

flozia
Copy link
Collaborator

@flozia flozia commented Feb 7, 2025

References:

PR #5590

Description

This PR does a couple of things:

  1. Unblocks updating the eslint group (PR chore(deps-dev): bump the eslint group across 1 directory with 7 updates #5590)
  2. Migrates and update our ESLint config from .eslintrc.json to eslint.config.js
  3. Applies the changes to our codebase
  4. Adds the commit 9d28f6b to .git-blame-ignore-revs which includes most of the automatically applied changes by Prettier.

How to test

  1. npm install
  2. npm run lint

dependabot bot and others added 8 commits February 5, 2025 14:04
Bumps the eslint group with 7 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `7.5.0` | `8.23.0` |
| [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) | `7.5.0` | `8.23.0` |
| [eslint](https://github.com/eslint/eslint) | `8.57.0` | `9.19.0` |
| [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) | `3.6.1` | `3.7.0` |
| [eslint-plugin-check-file](https://github.com/dukeluo/eslint-plugin-check-file) | `2.7.1` | `3.0.0` |
| [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) | `27.9.0` | `28.11.0` |
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | `48.2.2` | `50.6.3` |



Updates `@typescript-eslint/eslint-plugin` from 7.5.0 to 8.23.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.23.0/packages/eslint-plugin)

Updates `@typescript-eslint/parser` from 7.5.0 to 8.23.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.23.0/packages/parser)

Updates `eslint` from 8.57.0 to 9.19.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](eslint/eslint@v8.57.0...v9.19.0)

Updates `eslint-import-resolver-typescript` from 3.6.1 to 3.7.0
- [Release notes](https://github.com/import-js/eslint-import-resolver-typescript/releases)
- [Changelog](https://github.com/import-js/eslint-import-resolver-typescript/blob/master/CHANGELOG.md)
- [Commits](import-js/eslint-import-resolver-typescript@v3.6.1...v3.7.0)

Updates `eslint-plugin-check-file` from 2.7.1 to 3.0.0
- [Release notes](https://github.com/dukeluo/eslint-plugin-check-file/releases)
- [Changelog](https://github.com/dukeluo/eslint-plugin-check-file/blob/main/CHANGELOG.md)
- [Commits](dukeluo/eslint-plugin-check-file@v2.7.1...v3.0.0)

Updates `eslint-plugin-jest` from 27.9.0 to 28.11.0
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](jest-community/eslint-plugin-jest@v27.9.0...v28.11.0)

Updates `eslint-plugin-jsdoc` from 48.2.2 to 50.6.3
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc)
- [Commits](gajus/eslint-plugin-jsdoc@v48.2.2...v50.6.3)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: eslint
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: eslint
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: eslint
- dependency-name: eslint-import-resolver-typescript
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: eslint
- dependency-name: eslint-plugin-check-file
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: eslint
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: eslint
- dependency-name: eslint-plugin-jsdoc
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: eslint
...

Signed-off-by: dependabot[bot] <[email protected]>
@flozia flozia changed the title WIPUpdate ESLint config and apply changes WIP: Update ESLint config and apply changes Feb 7, 2025
@flozia flozia marked this pull request as draft February 7, 2025 18:14
@flozia flozia changed the base branch from main to dependabot/npm_and_yarn/eslint-4602aa654d February 7, 2025 18:15
@flozia flozia changed the base branch from dependabot/npm_and_yarn/eslint-4602aa654d to main February 7, 2025 18:15
@flozia flozia changed the title WIP: Update ESLint config and apply changes Update ESLint config and apply changes Feb 7, 2025
@flozia flozia marked this pull request as ready for review February 7, 2025 18:26
@flozia flozia marked this pull request as draft February 7, 2025 18:27
Copy link

github-actions bot commented Feb 7, 2025

1 similar comment
Copy link

github-actions bot commented Feb 7, 2025

@flozia flozia force-pushed the update-eslint-config branch from 9a4d79d to 31f5a7f Compare February 7, 2025 18:32
@flozia flozia marked this pull request as ready for review February 7, 2025 18:33
@flozia flozia requested review from Vinnl, rhelmer and mansaj February 7, 2025 18:33
Copy link
Collaborator

@rhelmer rhelmer left a comment

Choose a reason for hiding this comment

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

A few comments but lgtm, thanks for unblocking this eslint upgrade!

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Copy link
Collaborator

Choose a reason for hiding this comment

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

According to eslint/eslint#17726 (reply in thread) (I haven't verified further), Typescript is an available option for ESLint configuration now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only from ESLint 9.9.0 onwards, unfortunately. The dependency update PR #5590 is bumping ESLint from 8.57.0 to 9.19.0.

@@ -67,7 +67,7 @@ test("EmailUtils.init with SMTP URL invokes nodemailer.createTransport", async (

const result = await initEmail(testSmtpUrl);
expect(mockedNodemailer.createTransport).toHaveBeenCalledWith(testSmtpUrl);
// eslint-disable-next-line @typescript-eslint/unbound-method
Copy link
Collaborator

Choose a reason for hiding this comment

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

So nice being able to remove these!

@@ -24,7 +24,7 @@ export async function GET() {
try {
const flags = await getAllFeatureFlags();
return NextResponse.json(flags);
} catch (e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you didn't introduce this and I'm fine with the change as-is, but I think there's value in logging these messages so we can tell exactly what went wrong when diagnosing. I don't think that it should be returned to the caller or anything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure how to tackle this, we might want a tech debt ticket to audit our existing exception handling. wdyt?

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 think that’s a good idea — created MNTOR-4047.

@flozia flozia self-assigned this Feb 8, 2025
Copy link
Collaborator

@Vinnl Vinnl left a comment

Choose a reason for hiding this comment

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

Huh, that's fewer changes than I expected. (Probably still lot of effort though :) ) Nice work!

eslint.config.js Show resolved Hide resolved
eslint.config.js Outdated
project: "tsconfig.json",
},
},
ignores: ["coverage", "dist", "scripts", "sentry.*.config.ts"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of scope for this PR, but in case it's super easy: scripts is probably too broad, since it also includes our cron jobs. Could possibly be limited to src/scripts/loadtest/?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I see now it did run against some of the files in there? 🤔

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 was confused with this at first: We had ./scriptswhich has been removed completely so I also removed it from the list of ignored files here. This is the updated ignore list src/scripts and I agree that it is a bit too general. I wanted to limit the changes introduced by this PR and will address this in a follow-up.

@@ -49,7 +49,6 @@ global.TextEncoder = TextEncoder;

// Jest doesn't like the top-level await in envVars.ts, so we mock it.
jest.mock("./src/envVars", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, from what I can see this rule has been replaced by this rule in the recommended set, which I'd expect to still trigger here. Could that indicate that we're not running ESLint on all TS files anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Actually, the linter did complain about this line: Fixed in a43708c.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh? Hmm, then my followup question is: why don't I see any failed jobs here? Shouldn't the linter have complained about it in CI as well?

Copy link
Collaborator Author

@flozia flozia Feb 10, 2025

Choose a reason for hiding this comment

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

It seems like it never failed on jest.setup.ts. I’ve gone back to before the commits in this PR and checked (introduced intentional issues an ran the linter). I’m working on a follow-up to narrow down the ignored files even more and also to make sure that the linting issues in the config and setup files are blocking.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Follow-up: I’ve created PR #5619 to address next lint not running on the root files.

@flozia flozia merged commit a6a5495 into main Feb 10, 2025
16 checks passed
@flozia flozia deleted the update-eslint-config branch February 10, 2025 15:34
Copy link

Cleanup completed - database 'blurts-server-pr-5599' destroyed, cloud run service 'blurts-server-pr-5599' destroyed

@flozia flozia mentioned this pull request Feb 12, 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