Skip to content

chore(front): move to ESLint 10, replace eslint-plugin-import and enforce the rules of hooks #8480

Description

What we propose to do

Move openaev-front to ESLint 10, replace eslint-plugin-import with dependency-cruiser and knip, then start enforcing the Rules of Hooks. The work is split into three stacked pull requests, merged in this order:

  1. chore(deps): update eslint monorepo to v10 (#8480) #5168 (merged): ESLint 10 (eslint 10.12.0, @eslint/js 10.0.1). eslint-plugin-react 7.37.5 and eslint-plugin-import 2.32.0 are kept, with settings.react.version pinned to '19.3'. Base: main.
  2. chore(front): check dependencies with dependency-cruiser and knip, remove eslint-plugin-import (#8480) #8458: dependency-cruiser and knip check imports and declared dependencies, eslint-plugin-import is removed, and unused eslint-disable directives become errors. The custom ESLint rules move to TypeScript and classes-rule works again, and the legacy esbuild builder is removed. Base: main (was chore(deps): update eslint monorepo to v10 (#8480) #5168).
  3. chore(front): enforce the rules of hooks with ESLint (#8480) #8509: eslint-plugin-react-hooks (the official plugin) enforces the Rules of Hooks, and the violations are fixed. Base: chore(front): check dependencies with dependency-cruiser and knip, remove eslint-plugin-import (#8480) #8458.

#8456 tried a different route, replacing eslint-plugin-react with @eslint-react/eslint-plugin. It is closed: the version pin is enough for ESLint 10. The problems @eslint-react found in the code are listed below so they are not lost.

Status: #5168 is merged. #8458 and #8509 are open drafts. yarn lint, yarn check-ts, yarn depcruise, yarn knip --dependencies and yarn build pass locally on each one. #8509 still has to take in the latest commits of #8458.

Effort estimate

medium

Cost avoided

slower delivery

Impact if we do nothing

Short term: we stay on ESLint 9, which reached end of life on 2026-08-06 (https://eslint.org/version-support/) and gets no fixes at all, security fixes included. Renovate's ESLint 10 PR (#5168) stays blocked.

Mid term: lint plugins drop ESLint 9 one by one, and each update gets stuck behind this one. eslint-plugin-import keeps pulling a native resolver with a postinstall script into the install.

Long term: the upgrade turns into a large one-off migration instead of three small pull requests.

Evidence

  • OpenCTI has run ESLint 10 since 2026-02 ([deps] Update eslint monorepo to v10 (major) OpenCTI-Platform/opencti#14410) with the same eslint-plugin-react 7.37.5 and eslint-plugin-import 2.32.0. Its only workaround is the same version pin. It also runs knip --dependencies in CI.
  • Neither plugin has an ESLint 10 release. eslint-plugin-react has no fix on master either (ESLint v10 compatibility jsx-eslint/eslint-plugin-react#3977, open). eslint-plugin-import has one on master (Compatibility with ESLint 10 import-js/eslint-plugin-import#3227, closed 2026-06-29), but it is unreleased.
  • On ESLint 10, settings.react.version: 'detect' calls context.getFilename(), which ESLint 10 removed, so 7 of the 18 react rules we use crash. With the version pinned, nothing crashes.
  • We ran every non-deprecated rule of both plugins on ESLint 9 and on ESLint 10 with the pin, on the same code: 105,974 findings against 105,980. The only difference is 6 new no-useless-assignment errors from ESLint 10's recommended set, now fixed. No rule reports less.
  • The Rules of Hooks check found 63 violations. One is a crash: TextFieldAskAI returned early before its useState calls, so React throws "Rendered fewer hooks than expected" when the AI setting changes while the field is mounted.

Technical details

1. ESLint 10 (#5168)

  • Renovate's version bump, plus:
    • settings.react.version: '19.3', with a comment linking ESLint v10 compatibility jsx-eslint/eslint-plugin-react#3977. It must follow the installed React version until eslint-plugin-react supports ESLint 10.
    • The 6 no-useless-assignment fixes (dead initial values).
    • The classes-rule RuleTester test moves to flat config.
  • The eslint-plugin-import rules we use don't hit [tool] Update Node.js to v22.16.0 (release/current) #3227: that crash only affects no-default-export, no-named-export and unambiguous, which we don't enable.
  • --cache and TIMING=1 behave as before.

2. dependency-cruiser and knip, eslint-plugin-import removed (#8458)

  • dependency-cruiser 18.5.0, configured in openaev-front/.dependency-cruiser.ts and resolving imports through tsconfig.json. Rules: no-circular, not-to-dev-dep, no-non-package-json, not-to-unresolvable, and not-to-test (production code must not import src/__tests__ or tests_e2e).
    • It checks src, tests_e2e and the tooling files: scripts, and the vite / vitest / playwright / eslint / knip / dependency-cruiser configs.
    • It reads the transpiled output, so import X, { type Y } still counts as a runtime import.
    • Known violations live in .dependency-cruiser-known-violations.json. There is one: the TextFieldAskAI.tsx ↔ SimpleRichTextField.jsx cycle.
  • knip 6.41.0, configured in knip.ts. CI runs yarn knip --dependencies, as OpenCTI does. Seven unused packages are removed from the root: @mui/lab, @mui/system, classcat, d3-hierarchy, js-file-download, @types/d3-hierarchy, @typescript-eslint/utils (now declared by the custom rules package, which uses it).
  • CI (.github/actions/frontend-quality/action.yml) runs yarn depcruise, yarn knip --dependencies and the custom ESLint rule tests (yarn test:eslint-rules), which ran nowhere before.
  • Where each eslint-plugin-import rule went:
eslint-plugin-import New home
no-cycle depcruise no-circular
no-extraneous-dependencies depcruise not-to-dev-dep + no-non-package-json, and knip
no-unresolved tsc, depcruise not-to-unresolvable, Vite build
named, default, namespace, export tsc for TypeScript files. For JS files, the Vite build fails on a missing export (MISSING_EXPORT), and vite.config.ts turns IMPORT_IS_UNDEFINED into an error
no-duplicates core no-duplicate-imports with allowSeparateTypeImports
no-mutable-exports custom-rules/no-mutable-exports, with RuleTester tests
prefer-default-export dropped; the convention is written in .github/instructions/frontend.instructions.md
no-named-as-default dropped (its only 2 hits were suppressed false positives)
  • linterOptions.reportUnusedDisableDirectives is now 'error', and 12 stale directives are removed.
  • The custom ESLint rules (packages/eslint-plugin-custom-rules) are written in TypeScript and run from their sources by Node type stripping, with no build step. They use @typescript-eslint/utils and @typescript-eslint/rule-tester, are type-checked by yarn check-ts and linted with the rest of the front.
  • classes-rule never reported anything: it matched the @mui/styles form makeStyles(fn), while the code uses the curried tss-react makeStyles()(fn). It now follows the tss-react hooks with scope analysis, offers the removal of an unused class as a suggestion (not an autofix, so fix on save keeps a class being written), and the 30 unused classes it found are removed.
  • On a Node older than the engines range (>= 24.11.0), yarn lint, the IDE ESLint integration and yarn depcruise name the required version instead of failing with ERR_UNKNOWN_FILE_EXTENSION on the TypeScript files.
  • The legacy esbuild builder (builder/dev, builder/prod/prod.js, deprecated-start / deprecated-build) is removed with chokidar, esbuild, express, fs-extra and http-proxy-middleware. builder/prod/build stays the Vite output.
  • yarn.lock: eslint-plugin-import, eslint-import-resolver-next, unrs-resolver (21 native bindings and a postinstall) and napi-postinstall are gone. knip brings oxc-parser and oxc-resolver prebuilt binaries, with no install scripts.

3. Rules of Hooks (#8509)

  • eslint-plugin-react-hooks 7.1.1, recommended preset. Enabled as errors: rules-of-hooks, plus the rules with no findings (error-boundaries, unsupported-syntax, config, gating, void-use-memo). rules-of-hooks is off in tests_e2e, because Playwright fixtures receive a use callback.
  • Fixes:
    • TextFieldAskAI (early return before the hooks).
    • DeployScenario (the component was async).
    • AiTargetForm and AssetForm (feature flag hook called conditionally).
    • ConnectorLayout (hook called in a switch).
    • getTeamsColors, PlatformIcon, settingsEntries (hooks called from plain functions).
    • ScenarioTeams and SimulationTeams (hook called inside JSX).
    • ScenarioStatus (lowercase component name).
  • Functions that call hooks are renamed use*, for example useIsFeatureEnabled and useCountdown. Helpers that are not hooks lose their use prefix: getEntityIcon, getEntityLink, fetchFilterableProperties, getUseCaseIcon.
  • The React Compiler rules roughly double an uncached lint (54 s to 111 s).
  • Rules left off for now (findings today):
Rule Findings
exhaustive-deps 208
set-state-in-effect 143
refs 36
incompatible-library 14
immutability 13
static-components 9
globals 8
purity 7
set-state-in-render 4
preserve-manual-memoization 3
use-memo 1

What @eslint-react found (from #8456)

@eslint-react/eslint-plugin checks more than the official plugins. These are its findings that the stack above does not fix:

  • Components declared during render (static-components, 46 findings): such a component is a new type on every render, so React remounts it and loses its state. Examples:

    • SecurityPlatformDetail.tsx:457, InjectScoreTiles.tsx:42, InjectExpectationCard.tsx:71, TraceMessage.tsx:69, ConnectorDetailHero.tsx:89
    • ScenarioDistributionByExercise.tsx:141, ThreatArsenalActionOverview.tsx:190, TrendChip.tsx:38, ExpectationTypeChip.tsx:24, PostureGauges.tsx:70
    • ResponsePie.tsx:59, where Pie is built with useCallback and remounts the charts when pending or the theme changes.

    The official plugin reports 9 of these.

  • Fetch results that can arrive out of order: in useFetchInjectExecutionResult.tsx:29 and PaginationComponent.tsx:131, the effects have no cancellation, so an older response can overwrite newer state when the inputs change quickly. PaginationComponentV2 already guards against this. useCheckNetwork.tsx has no effect cleanup at all.

  • this.state read inside setState (no-access-state-in-setstate, 6 findings in QuickInject.jsx): updates can be lost when they are batched.

  • State set in effects (set-state-in-effect, 258 findings) and impure render (purity, 22): extra renders, and results that change between renders.

  • Missing or wrong effect dependencies (exhaustive-deps, 208).

  • Array index used as key (no-array-index-key, 60): wrong reuse of rows when a list is reordered or filtered.

  • React 19 migrations: useContext → use (132), <Context.Provider> → <Context> (93), forwardRef → ref as a prop (3).

  • Legacy React APIs: cloneElement (5), Children.map / toArray / forEach (4).

  • Naming:

    • use-state (45): the setter is not named after its state.
    • naming-convention-ref-name (31): refs not ending in Ref.
    • Contexts without a display name (29).
    • Two helpers named like hooks that call no hook: useIsManuallyUpdatable, useIsEligibleArianeSecurityPlatform.

Acceptance criteria

  • eslint 10 is on main, and every front-end CI check is green.
  • package.json and yarn.lock no longer contain eslint-plugin-import, eslint-import-resolver-next or unrs-resolver.
  • CI fails on a new import cycle, on a devDependency imported from production code, and on an undeclared or unused dependency.
  • No eslint-disable … import/* comment is left, and unused eslint-disable directives fail lint.
  • react-hooks/rules-of-hooks is enforced.

Merging the stack

Follow-ups

Area

front end, build, ci and dependencies

Staff driven or vertical

staff driven

Security check

  • This is not a security finding. Security findings follow their own path and their own SLA.

Activity

  1. added
    technical improvement
    needs triage
    frontend
    on Oct 13, 2026
  2. changed the title [-]chore(front): unblock ESLint 10 by replacing eslint-plugin-react and eslint-plugin-import[/-] [+]chore(front): move to ESLint 10, replace eslint-plugin-import and enforce the rules of hooks[/+] on Oct 14, 2026
  3. added
    solved
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendneeds triagesolvedtechnical improvement

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions