Repository navigation
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:
- chore(deps): update eslint monorepo to v10 (#8480) #5168 (merged): ESLint 10 (
eslint10.12.0,@eslint/js10.0.1).eslint-plugin-react7.37.5 andeslint-plugin-import2.32.0 are kept, withsettings.react.versionpinned to'19.3'. Base:main. - 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-importis removed, and unusedeslint-disabledirectives become errors. The custom ESLint rules move to TypeScript andclasses-ruleworks again, and the legacy esbuild builder is removed. Base:main(was chore(deps): update eslint monorepo to v10 (#8480) #5168). - 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-react7.37.5 andeslint-plugin-import2.32.0. Its only workaround is the same version pin. It also runsknip --dependenciesin CI. - Neither plugin has an ESLint 10 release.
eslint-plugin-reacthas no fix onmastereither (ESLint v10 compatibility jsx-eslint/eslint-plugin-react#3977, open).eslint-plugin-importhas one onmaster(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'callscontext.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-assignmenterrors from ESLint 10's recommended set, now fixed. No rule reports less. - The Rules of Hooks check found 63 violations. One is a crash:
TextFieldAskAIreturned early before itsuseStatecalls, 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 untileslint-plugin-reactsupports ESLint 10.- The 6
no-useless-assignmentfixes (dead initial values). - The
classes-ruleRuleTester test moves to flat config.
- The
eslint-plugin-importrules we use don't hit [tool] Update Node.js to v22.16.0 (release/current) #3227: that crash only affectsno-default-export,no-named-exportandunambiguous, which we don't enable. --cacheandTIMING=1behave as before.
2. dependency-cruiser and knip, eslint-plugin-import removed (#8458)
dependency-cruiser18.5.0, configured inopenaev-front/.dependency-cruiser.tsand resolving imports throughtsconfig.json. Rules:no-circular,not-to-dev-dep,no-non-package-json,not-to-unresolvable, andnot-to-test(production code must not importsrc/__tests__ortests_e2e).- It checks
src,tests_e2eand 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: theTextFieldAskAI.tsx↔SimpleRichTextField.jsxcycle.
- It checks
knip6.41.0, configured inknip.ts. CI runsyarn 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) runsyarn depcruise,yarn knip --dependenciesand the custom ESLint rule tests (yarn test:eslint-rules), which ran nowhere before. - Where each
eslint-plugin-importrule 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.reportUnusedDisableDirectivesis 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/utilsand@typescript-eslint/rule-tester, are type-checked byyarn check-tsand linted with the rest of the front. classes-rulenever reported anything: it matched the@mui/stylesformmakeStyles(fn), while the code uses the curried tss-reactmakeStyles()(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
enginesrange (>= 24.11.0),yarn lint, the IDE ESLint integration andyarn depcruisename the required version instead of failing withERR_UNKNOWN_FILE_EXTENSIONon the TypeScript files. - The legacy esbuild builder (
builder/dev,builder/prod/prod.js,deprecated-start/deprecated-build) is removed withchokidar,esbuild,express,fs-extraandhttp-proxy-middleware.builder/prod/buildstays the Vite output. yarn.lock:eslint-plugin-import,eslint-import-resolver-next,unrs-resolver(21 native bindings and apostinstall) andnapi-postinstallare gone. knip bringsoxc-parserandoxc-resolverprebuilt binaries, with no install scripts.
3. Rules of Hooks (#8509)
eslint-plugin-react-hooks7.1.1,recommendedpreset. Enabled as errors:rules-of-hooks, plus the rules with no findings (error-boundaries,unsupported-syntax,config,gating,void-use-memo).rules-of-hooksis off intests_e2e, because Playwright fixtures receive ausecallback.- Fixes:
TextFieldAskAI(early return before the hooks).DeployScenario(the component wasasync).AiTargetFormandAssetForm(feature flag hook called conditionally).ConnectorLayout(hook called in aswitch).getTeamsColors,PlatformIcon,settingsEntries(hooks called from plain functions).ScenarioTeamsandSimulationTeams(hook called inside JSX).ScenarioStatus(lowercase component name).
- Functions that call hooks are renamed
use*, for exampleuseIsFeatureEnabledanduseCountdown. Helpers that are not hooks lose theiruseprefix: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:89ScenarioDistributionByExercise.tsx:141,ThreatArsenalActionOverview.tsx:190,TrendChip.tsx:38,ExpectationTypeChip.tsx:24,PostureGauges.tsx:70ResponsePie.tsx:59, wherePieis built withuseCallbackand remounts the charts whenpendingor the theme changes.
The official plugin reports 9 of these.
-
Fetch results that can arrive out of order: in
useFetchInjectExecutionResult.tsx:29andPaginationComponent.tsx:131, the effects have no cancellation, so an older response can overwrite newer state when the inputs change quickly.PaginationComponentV2already guards against this.useCheckNetwork.tsxhas no effect cleanup at all. -
this.stateread insidesetState(no-access-state-in-setstate, 6 findings inQuickInject.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 inRef.- Contexts without a display name (29).
- Two helpers named like hooks that call no hook:
useIsManuallyUpdatable,useIsEligibleArianeSecurityPlatform.
Acceptance criteria
eslint10 is onmain, and every front-end CI check is green.package.jsonandyarn.lockno longer containeslint-plugin-import,eslint-import-resolver-nextorunrs-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 unusedeslint-disabledirectives fail lint. react-hooks/rules-of-hooksis enforced.
Merging the stack
- chore(deps): update eslint monorepo to v10 (#8480) #5168 is merged. Merge chore(front): check dependencies with dependency-cruiser and knip, remove eslint-plugin-import (#8480) #8458, then chore(front): enforce the rules of hooks with ESLint (#8480) #8509.
- Core CI only runs on pull requests that target
main. When GitHub retargets a stacked pull request tomainafter its base merges, CI does not start by itself. Push to the branch (or close and reopen the pull request), and wait for the Pipeline Gate before merging.
Follow-ups
- Remove the React version pin once
eslint-plugin-reactsupports ESLint 10 (ESLint v10 compatibility jsx-eslint/eslint-plugin-react#3977). - Turn on the remaining
react-hooksrules, starting withstatic-componentsandset-state-in-render, and fix the two fetch races. - Clear the knip backlog (37 unused files, 173 unused exports, 79 unused exported types, 6 duplicate exports), then widen the CI check beyond
--dependencies. - Fix the
TextFieldAskAI↔SimpleRichTextFieldcycle and empty the dependency-cruiser baseline. - React 19 API migrations.
- Reconsider
@eslint-react/eslint-plugin(chore(front): replace eslint-plugin-react with @eslint-react/eslint-plugin (#8480) #8456) for the checks the official plugins don't have.
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
[-]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[/+]chore(deps): update eslint monorepo to v10 (#8480) (#5168)
chore(front): fix the code for the lint, dependency-cruiser and knip …
chore(front): check declared dependencies with knip (#8480) (#8619)
chore(front): fail the build on undefined imports in app code only, d…
chore(front): pin Node 24 for fnm and nvm (#8480)
chore(front): remove the Node version file (#8480)
chore(deps): check deps with dependency-cruiser & knip (#8480)