Skip to content

chore: upgrade ESLint to flat config with dx-team v3#201

Open
JuroUhlar wants to merge 5 commits into
mainfrom
inter-2315/eslint-upgrade
Open

chore: upgrade ESLint to flat config with dx-team v3#201
JuroUhlar wants to merge 5 commits into
mainfrom
inter-2315/eslint-upgrade

Conversation

@JuroUhlar

@JuroUhlar JuroUhlar commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator
  • Migrate to ESLint 10 flat config with @fingerprintjs/eslint-config-dx-team v3 type-checked rules
  • Lint examples from the root config; restore per-example lint scripts
  • Apply minimal source/test fixes to pass the stricter rules (no useVisitorData behavior refactor)

Merge plan

We will merge this PR first, then apply additional improvements from #199 on top (notably the useVisitorData refactor and related test coverage).

Discussion point: WithEnvironment render-prop API

WithEnvironment now takes children: (env) => JSX.Element instead of cloning a single child. It is internal-only (not exported from the package entry), but flag if you prefer keeping the old cloneElement shape.

Discussion point: use-visitor-data mount fetch

Kept existing mount getData() behavior with a targeted react-hooks/set-state-in-effect disable and TODO rather than refactoring the hook in this PR.

Note: banner plugin types

vite.config.ts uses @ts-expect-error for rollup-plugin-banner2 and vite-plugin-banner — unmaintained plugins with stale Rollup 4 types, but still required for correct dist output.

Test plan

  • pnpm lint
  • pnpm test --run
  • pnpm build (license banner + "use client" in dist)

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
82.96% (-0.24% 🔻)
112/135
🟡 Branches
68.42% (+4.65% 🔼)
52/76
🟢 Functions
80.95% (+0.46% 🔼)
34/42
🟢 Lines
82.31% (-0.5% 🔻)
107/130
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / assert-is-defined.ts
50% 75% 100% 50%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / use-promise-store.ts
91.3% (-1% 🔻)
92.31% (+17.31% 🔼)
100%
90.91% (-1.4% 🔻)
🟢
... / fingerprint-provider.tsx
90.32% (-0.85% 🔻)
54.55% (-3.79% 🔻)
90.91% (+0.91% 🔼)
89.66% (-1.25% 🔻)

Test suite run success

22 tests passing in 15 suites.

Report generated by 🧪jest coverage report action from eb3a7a7

Show full coverage report
St File % Stmts % Branch % Funcs % Lines Uncovered Line #s
🟢 All files 82.96 68.42 80.95 82.3
🟢  src 88.7 75.86 83.33 88.33
🟢   detect-env.ts 90 83.33 100 90 15,87
🟢   env.ts 100 100 100 100
🟢   env.types.ts 85.71 40 50 83.33 14
🟡   ...nt-context.ts 75 100 0 75 8
🟡   get-env.ts 60 0 100 60 8-9
🟢   ssr.ts 100 100 100 100
🟢   ...sitor-data.ts 95.65 100 80 95.65 102
🟢  src/components 91.66 58.33 91.66 91.17
🟢   ...-provider.tsx 90.32 54.54 90.9 89.65 47,52,85
🟢   ...vironment.tsx 100 100 100 100
🟡  src/utils 64.86 69.56 66.66 63.88
🟡   ...is-defined.ts 50 75 100 50 3
🟡   to-error.ts 66.66 50 100 66.66 6
🟢   ...mise-store.ts 91.3 92.3 100 90.9 20,26
🔴   wait-until.ts 0 0 0 0 8-19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates the repo to ESLint 10 flat config using @fingerprintjs/eslint-config-dx-team v3 type-checked rules, updates lint scripts (root + examples), and applies targeted code/test adjustments to satisfy stricter linting without broader behavior refactors.

Changes:

  • Add root eslint.config.mjs (flat config) plus tsconfig.eslint.json; simplify root lint script and restore per-example lint scripts.
  • Update internal WithEnvironment to a render-prop API and adjust FingerprintProvider + related tests accordingly.
  • Apply small source/example/test tweaks to satisfy new TS/ESLint constraints (env detection typing, safer runtime checks, promise handling, etc.).

Reviewed changes

Copilot reviewed 42 out of 45 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vite.config.ts Adds TS error suppressions for banner plugins; keeps DTS generation; minor banner string tweak.
tsconfig.json Expands TS include to cover tests.
tsconfig.eslint.json Adds a dedicated TS project for type-aware ESLint across src/tests/examples/config files.
src/utils/use-promise-store.ts Reworks cache key serialization and store initialization approach.
src/utils/use-const.ts Removes useConst utility (no longer used).
src/utils/assert-is-truthy.ts Removes truthy assertion helper.
src/utils/assert-is-defined.ts Adds null/undefined-only assertion helper.
src/use-visitor-data.ts Switches to assertIsDefined; adds targeted lint disable for mount fetch behavior; minor error logging typing.
src/get-env.ts Tightens JSON.parse typing to unknown.
src/detect-env.ts Tightens env-check strategy typing to boolean and adjusts DOM/window checks.
src/components/with-environment.tsx Changes WithEnvironment from cloneElement to render-prop children API.
src/components/fingerprint-provider.tsx Adapts provider to new WithEnvironment API; minor refactors/strictness tweaks.
scripts/detect-env.js Disables @typescript-eslint/no-require-imports for CJS usage.
package.json Upgrades ESLint + related tooling deps; simplifies lint script.
examples/webpack-based/webpack.config.js Disables @typescript-eslint/no-require-imports for CJS usage.
examples/webpack-based/package.json Adds an example-local lint script.
examples/vite/src/vite-env.d.ts Adds Vite env typing for the example.
examples/vite/src/main.tsx Adds runtime checks for required env var and root element; fixes import style.
examples/vite/package.json Restores local lint script; relies on root lint toolchain.
examples/vite/eslint.config.js Removes per-example flat config (now covered by root config).
examples/preact/src/index.tsx Adds runtime checks for required env var.
examples/preact/src/components/app.tsx Marks getData() call as intentionally un-awaited (void).
examples/preact/preact.config.js Keeps dotenv-based injection in Preact config.
examples/preact/package.json Adjusts lint script and dependencies for Preact example.
examples/preact/.eslintrc.js Removes legacy ESLint config (now covered by root flat config).
examples/next/pages/_app.tsx Adds explicit env var getter/validation.
examples/next/package.json Switches lint to root ESLint; adjusts dependency placement for a private example.
examples/next-appDir/package.json Switches lint to root ESLint; adjusts dependency placement for a private example.
examples/next-appDir/app/page.tsx Removes unnecessary async on page component.
examples/next-appDir/app/layout.tsx Adds explicit env var getter/validation.
examples/next-appDir/app/HomePage.tsx Marks getData({}) as intentionally un-awaited (void).
examples/create-react-app/src/shared/pages/SignInPage.tsx Updates handlers to satisfy stricter linting; simplifies logging of visitor data.
examples/create-react-app/src/shared/pages/HomePage.tsx Wraps callback bodies to satisfy linting.
examples/create-react-app/src/shared/components/VisitorDataPresenter.tsx Tightens boolean/undefined checks in rendering logic.
examples/create-react-app/src/shared/components/Toggler.tsx Updates props typing and wraps callback body to satisfy linting.
examples/create-react-app/src/index.tsx Adds runtime check for root element presence.
examples/create-react-app/package.json Adds an example-local lint script.
eslint.config.mjs New root flat ESLint config wiring dx-team + react + hooks + type-aware parsing.
.eslintrc.js Removes legacy ESLint config (replaced by flat config).
tests/with-environment.test.tsx Updates tests to match render-prop WithEnvironment API and modern testing-library patterns.
tests/with-environment.preact.test.tsx Updates Preact test usage to pass render-prop children.
tests/use-visitor-data.test.tsx Updates tests to use screen/userEvent patterns and satisfy stricter lint rules.
tests/helpers.tsx Adjusts typing and wait promise typing to satisfy stricter rules.
tests/fpjs-provider.test.tsx Removes unnecessary async in test case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/use-promise-store.ts
Comment thread src/components/with-environment.tsx
Comment thread examples/preact/package.json
@github-actions

This comment has been minimized.

Migrate to ESLint 10 and type-checked flat config.
Lint examples from the root and apply minimal source/test fixes.
Exclude preact and example vite configs from type-checked lint.
Fix the vite example import path.
@JuroUhlar JuroUhlar force-pushed the inter-2315/eslint-upgrade branch from 60426e1 to eb3a7a7 Compare July 16, 2026 12:23
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR doesn't contain any changesets. If there are user-facing changes, don't forget to run:

pnpm exec changeset

to create a changeset.

@JuroUhlar JuroUhlar marked this pull request as ready for review July 16, 2026 12:25
JuroUhlar added a commit that referenced this pull request Jul 16, 2026
…ter-2222

Fold PR #201 into this branch and keep the unique useVisitorData refactor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants