[#75379] Add eslint to op-blocknote-extensions#143
Open
ihordubas99 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces ESLint to the op-blocknote-extensions package using a flat config modelled after the OpenProject frontend setup (adapted for React). The bulk of the diff is the mechanical reformatting that resulted from auto-fixing existing source files against the new rules (single quotes, semicolons, custom @stylistic/type-annotation-spacing that removes spaces around : in type annotations), plus targeted eslint-disable comments where type-checked rules clash with existing any-heavy editor code.
Changes:
- Adds
eslint.config.js(flat config) with TypeScript-typed rules, React Hooks/Refresh, Vitest, and@stylisticplugins, plus newtsconfig.test.jsonandtest/tsconfig.jsonso test/config files are covered by the type-aware parser. - Adds
@stylistic/eslint-pluginand@vitest/eslint-pluginto devDependencies and alintstep to the CI workflow. - Auto-fixes all
lib/,src/, andtest/files to match the new rules (quotes, semicolons, type-annotation spacing), plus a few targeted refactors (e.g.UnavailableCard.tsxandOptionsPopover.tsxreordered so styled components are declared before use,colors.tsregex/optional-chain cleanups,useWorkPackageSearch.tserror-type narrowing).
Reviewed changes
Copilot reviewed 74 out of 80 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| eslint.config.js | New flat ESLint config with TS, React, Vitest, and stylistic rule sets and per-folder overrides. |
| tsconfig.test.json, test/tsconfig.json | Extra tsconfigs so the type-aware parser can resolve test and config files. |
| .github/workflows/test.yml | Adds npm run lint step before tests. |
| package.json, package-lock.json | Adds @stylistic/eslint-plugin and @vitest/eslint-plugin devDependencies. |
| vite.config.ts, vitest.config.ts, vitest.browser.config.ts | Quote/semicolon auto-fixes. |
| src/* (App.tsx, main.tsx, op-blocknote.ts, fetchOverride.ts) | Quote/semicolon/type-annotation fixes plus a few eslint-disable comments for any usage. |
| lib/index.ts, lib/initialize.ts, lib/openProjectTypes.ts | Quotes/semis/type-annotation spacing; Array<T> rewritten as T[]. |
| lib/locales/en.ts and lib/locales/crowdin/*.ts | Quote-style fixes only. |
| lib/services/colors.ts | Quotes, optional-chain (a?.b), .then(() => undefined) instead of () => {}. |
| lib/services/i18n.ts | Quotes, void i18n.changeLanguage, regex-exec, eslint-disable for unsafe-any access on dynamic locale modules. |
| lib/services/openProjectApi.ts | Quotes; response.json() as Promise<T>; catch((error:unknown) => ...) with disable for prefer-promise-reject-errors. |
| lib/services/slashMenuAliases.ts, lib/services/wpBridge.ts | Quotes, type-annotation spacing; wpBridge closure no longer needs set! non-null asserts after if (!set) initialization. |
| lib/plugins/pasteDeduplicatePlugin.ts, lib/utils/{id,selection}.ts | Quotes and type-annotation spacing. |
| lib/hooks/* | Quotes/types; added disables for any editor params; useWorkPackage drops redundant as WorkPackage cast; useWorkPackageSearch narrows error via instanceof Error. |
| lib/components/HashMenu/* | Quotes/types; editorUtils.ts introduces a RawNode interface and uses regex.exec(text) to satisfy lint. |
| lib/components/InlineWorkPackage/* | Quotes/types; chip component gets a couple of eslint-disable lines for any editor and ref access. |
| lib/components/BlockWorkPackage/* | Quotes/types; spec.tsx now casts block.props to a typed shape in toExternalHTML. |
| lib/components/Search/*, SlashMenu.tsx, ShadowDomWrapper.tsx | Quotes/types; SlashMenu.tsx imports AnyEditor from HashMenu/editorUtils. |
| lib/components/WorkPackage/* (UnavailableCard, OptionsPopover, atoms, tokens, types, index) | Quotes/types; UnavailableCard and OptionsPopover reordered so styled-component definitions precede the exported components. |
| global.d.ts | { [k: string]: string } rewritten as Record<string, string>. |
| test/** | Quotes/types; searchDropdown.browser.test.tsx consolidates toHaveBeenCalledOnce + toHaveBeenCalledWith into toHaveBeenCalledExactlyOnceWith; editorHelpers.ts drops some redundant :string annotations on parameters with defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c27b3ac to
1dcb80c
Compare
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.
Ticket
https://community.openproject.org/projects/communicator-stream/work_packages/75379
What are you trying to accomplish?
Add ESLint to the op-blocknote-extensions package to enforce consistent code style and catch potential issues early, aligned with the OpenProject frontend ESLint configuration.
What approach did you choose and why?
The ESLint flat config (eslint.config.js) was modelled after the OpenProject frontend config, adapted for React (instead of Angular):
TypeScript rules: typescript-eslint with recommendedTypeChecked + stylisticTypeChecked for type-aware linting
React rules: eslint-plugin-react-hooks and eslint-plugin-react-refresh instead of Angular plugins
Stylistic rules: @stylistic/eslint-plugin for formatting (single quotes, semicolons, type annotation spacing)
Vitest rules: @vitest/eslint-plugin for test files
Separate tsconfigs (tsconfig.test.json, test/tsconfig.json) added to support TypeScript project service for files outside the main tsconfig scope
All existing source files were updated with auto-fixed formatting (single quotes, type annotation spacing).
A lint step was added to the CI workflow (.github/workflows/test.yml)
Merge checklist