Skip to content

[#75379] Add eslint to op-blocknote-extensions#143

Open
ihordubas99 wants to merge 2 commits into
devfrom
code-maintenance/75379-add-eslint-to-op-blocknote-extensions
Open

[#75379] Add eslint to op-blocknote-extensions#143
ihordubas99 wants to merge 2 commits into
devfrom
code-maintenance/75379-add-eslint-to-op-blocknote-extensions

Conversation

@ihordubas99
Copy link
Copy Markdown
Collaborator

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

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Copy link
Copy Markdown

Copilot AI left a 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 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 @stylistic plugins, plus new tsconfig.test.json and test/tsconfig.json so test/config files are covered by the type-aware parser.
  • Adds @stylistic/eslint-plugin and @vitest/eslint-plugin to devDependencies and a lint step to the CI workflow.
  • Auto-fixes all lib/, src/, and test/ files to match the new rules (quotes, semicolons, type-annotation spacing), plus a few targeted refactors (e.g. UnavailableCard.tsx and OptionsPopover.tsx reordered so styled components are declared before use, colors.ts regex/optional-chain cleanups, useWorkPackageSearch.ts error-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.

@ihordubas99 ihordubas99 marked this pull request as ready for review May 28, 2026 13:35
@ihordubas99 ihordubas99 requested a review from judithroth May 28, 2026 13:35
@ihordubas99 ihordubas99 force-pushed the code-maintenance/75379-add-eslint-to-op-blocknote-extensions branch from c27b3ac to 1dcb80c Compare May 29, 2026 09:29
@ihordubas99 ihordubas99 marked this pull request as draft May 29, 2026 09:48
@ihordubas99 ihordubas99 marked this pull request as ready for review May 29, 2026 09:55
@ihordubas99 ihordubas99 requested a review from Copilot May 29, 2026 09:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 75 out of 81 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants