Repository navigation
Move to ESLint 9 and flat config - #35
Draft
alistair3149 wants to merge 1 commit into
Draft
alistair3149 wants to merge 1 commit into
alistair3149 wants to merge 1 commit into
Conversation
eslint-config-wikimedia 0.33.1 supports ESLint 9 and flat config (T364065). This moves resources/visual-editor onto them, up from eslint-config-wikimedia 0.24 and typescript-eslint 5, and fixes the 95 problems the newer rules report. - Bump eslint-config-wikimedia ^0.24.0 → ^0.33.1 and eslint ^8.41.0 → ^9.39.5. Drop @wmde/eslint-config-wikimedia-typescript, whose rules eslint-config-wikimedia now ships itself, the @typescript-eslint packages only it needed, and the unused eslint-import-resolver-typescript. - Replace .eslintrc.js with eslint.config.js. The lint scripts drop --ext and --ignore-path, which flat config does not support. - Fix the problems the newer rules report. 89 are fixed by --fix: trailing commas, spacing inside template literal placeholders, blank lines between class members, two arrow callbacks and one arrow body. By hand: the four constructor interfaces no longer extend `Function`, `CommandsPopupWidget` becomes a type alias, and `getCommandLabel` uses `catch {}`. - Move the `ve.activationComplete` handler into a named function. As the arrow function prefer-arrow-callback asks for, the build wraps the bundle in a CommonJS shim that ends in `export`, which ResourceLoader cannot load. - Run Node 22 instead of 19 in CI and in the Dockerfile behind `make visual-editor-*`. ESLint 9 does not support Node 19. - Rebuild dist/assets/index.js. It differs from the previous build only in the forEach callback in `getCommandElTemplate` and the hook handler, neither of which uses `this`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
eslint-config-wikimedia 0.33.1 supports ESLint 9 and flat config (T364065). This moves
resources/visual-editoronto them, up from eslint-config-wikimedia 0.24 and typescript-eslint 5, and fixes the 95 problems the newer rules report.Human input
Goal and shape: goal from @alistair3149; shape Claude's.
dist/assets/index.jsbelongs in this PR.Outcome: not reviewed by a human yet. Left for you: the hand-made source changes below.
Claude's calls
ve.activationCompletehandler, rather than keeping the anonymous function behind aneslint-disablecomment.catch {}ingetCommandLabel.eslint .would otherwise lint them.Changes
One commit.
eslint-config-wikimedia^0.24.0 → ^0.33.1 andeslint^8.41.0 → ^9.39.5. Drop@wmde/eslint-config-wikimedia-typescript, whose rules eslint-config-wikimedia now ships itself, the@typescript-eslintpackages only it needed, and the unusedeslint-import-resolver-typescript..eslintrc.jswitheslint.config.js. The lint scripts drop--extand--ignore-path, which flat config does not support.--fix: trailing commas, spacing inside template literal placeholders, blank lines between class members, two arrow callbacks and one arrow body. By hand: the four constructor interfaces no longer extendFunction,CommandsPopupWidgetbecomes a type alias, andgetCommandLabelusescatch {}.ve.activationCompletehandler into a named function. As the arrow functionprefer-arrow-callbackasks for, the build wraps the bundle in a CommonJS shim that ends inexport, which ResourceLoader cannot load.make visual-editor-*. ESLint 9 does not support Node 19.dist/assets/index.js. It differs from the previous build only in theforEachcallback ingetCommandElTemplateand the hook handler, neither of which usesthis.Verification evidence
--print-configforsrc/Commands/CommandRegistry.ts,src/@types/globals.d.ts,vite.config.tsandenv.d.tsmatches between those two setups, apart from ESLint 9's owneslint:recommendedchanges. The config file itself is now linted as CommonJS with core rules, instead of with the TypeScript parser and rules.npm run lint-no-fixreports nothing on the same 16 files, witheslint.config.jsin place of.eslintrc.js.npm run build(type-check and Vite) passes.npm ci: one ESLint (9.39.5), no invalid dependencies.dist/assets/index.jsbyte for byte. Built with the arrow-function handler, the bundle gained a CommonJS wrapper ending inexport default B();; with the named function it has none, and differs from the previous build only at the two places above.Lint (visual-editor)andTest build (visual-editor)./opens the popup with the same 17 commands, typingbulleaves "Bullet list", Enter inserts a bullet list and closes the popup,/reopens it and Escape closes it. The resulting document is identical between the two builds; no JavaScript errors on either.