-
Couldn't load subscription status.
- Fork 213
Convert to eslint 9 #4056
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
Convert to eslint 9 #4056
Conversation
76dfe00 to
d77537a
Compare
f568822 to
195c7e0
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.
Pull Request Overview
This PR upgrades ESLint from version 8 to version 9, along with updating several related plugins. The upgrade involves transitioning from the legacy .eslintrc.js configuration format to the new flat config format in eslint.config.mjs. Many lint rules have been temporarily disabled to address thousands of errors, with the plan to re-enable them incrementally in future work.
- Replaces legacy ESLint configuration with flat config format
- Updates ESLint plugins and removes outdated ones
- Removes unnecessary non-null assertions and type casts throughout the codebase
- Cleans up disabled ESLint comments that are no longer needed
Reviewed Changes
Copilot reviewed 39 out of 41 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
package.json |
Updates ESLint and plugin versions, removes outdated plugins |
eslint.config.mjs |
New flat config replacing old .eslintrc.js with updated rule configurations |
.eslintrc.js |
Removed legacy ESLint configuration file |
.eslintignore |
Removed in favor of global ignores in flat config |
| Multiple source files | Removes unnecessary non-null assertions and type casts flagged by new rules |
| request.response.body = await readFile( | ||
| join(scenarioDirPath, request.response.body.substring(5)), | ||
| "utf8", | ||
| ); |
Copilot
AI
Aug 4, 2025
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 readFile function is being called with an explicit encoding parameter "utf8", but the function signature and context suggest this might be reading binary data. Consider verifying that UTF-8 encoding is appropriate for all file types being read here, or handle encoding based on file type.
| ); | |
| const filePathToRead = join(scenarioDirPath, request.response.body.substring(5)); | |
| const fileBuffer = await readFile(filePathToRead); | |
| // Convert to string only for text files | |
| if (filePathToRead.endsWith(".txt") || filePathToRead.endsWith(".json")) { | |
| request.response.body = fileBuffer.toString("utf8"); | |
| } else { | |
| request.response.body = fileBuffer; | |
| } |
| if (!language) { | ||
| const dbschemeBase = basename(dbscheme) as keyof typeof dbSchemeToLanguage; | ||
| const dbschemeBase = basename(dbscheme); | ||
| language = dbSchemeToLanguage[dbschemeBase]; |
Copilot
AI
Aug 4, 2025
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.
Removing the type assertion as keyof typeof dbSchemeToLanguage could cause a runtime error if dbschemeBase is not a valid key in the dbSchemeToLanguage object. The indexing operation may return undefined, which could lead to unexpected behavior.
| language = dbSchemeToLanguage[dbschemeBase]; | |
| if (dbschemeBase in dbSchemeToLanguage) { | |
| language = dbSchemeToLanguage[dbschemeBase]; | |
| } |
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.
could cause a runtime error
I think the code being removed is entirely compile-time, so I'm going to ignore this copilot suggestion about runtime errors.
| public get<T>(key: string, defaultValue: T): T; | ||
| public get(key: any, defaultValue?: any): T | T | undefined { | ||
| public get(key: any, defaultValue?: any): T | undefined { | ||
| return this.map.get(key) || defaultValue; |
Copilot
AI
Aug 4, 2025
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 return type should be T | undefined when no default value is provided, or T when a default value is provided. The current signature removes the overload distinction that was present in the original interface, potentially breaking type safety.
| return this.map.get(key) || defaultValue; | |
| public get<T>(key: string, defaultValue?: T): T | undefined { | |
| if (this.map.has(key)) { | |
| return this.map.get(key) as T; | |
| } | |
| if (defaultValue !== undefined) { | |
| return defaultValue; | |
| } | |
| return undefined; |
6089c83 to
320df4d
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.
It makes sense to me to fix the other ESLint violations in follow-up PRs. These changes look good to me, my main concern is regarding the request handler where I don't think we should be reading the file as UTF-8.
extensions/ql-vscode/src/common/mock-gh-api/request-handlers.ts
Outdated
Show resolved
Hide resolved
| (disposable as any).onDidExpandElement && | ||
| (disposable as any).onDidCollapseElement && | ||
| (disposable as any).reveal | ||
| ) { |
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 suggestion from Copilot makes sense, assuming the in checks are also true for an actual TreeViewer.
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.
LGTM, thanks!
Upgrades eslint to version 9, as well as upgrading a few plugins.
I've tried to convert the old config as closely as I could, but I've removed a few plugins that weren't working well because they haven't received updates in a couple of years. It's also very possible I've misunderstood bits of the config!
I can now run
npm run lintlocally and hopefully it'll pass in CI too. I have fixed a few rules where it was simple or obvious to do, but for most rules I have disabled them as there were thousands of errors. After this is merged we'll want a secondary effort to try to re-enable rules as much as feasible.I've tried to keep the list of commits as clear and understandable as possible, so hopefully you can review this commit-by-commit.