INTER-2222: Upgrade to ESLint v10 flat config#199
Draft
erayaydin wants to merge 5 commits into
Draft
Conversation
Use `@fingerprintjs/eslint-config-dx-team@2.0.0` which requires ESLint v10. Related-Task: INTER-2222
Contributor
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success21 tests passing in 15 suites. Report generated by 🧪jest coverage report action from d7ba0fb Show full coverage report
|
Member
Author
|
Moving the PR to draft since we're planning to upgrade |
…inter-2222 # Conflicts: # package.json
Contributor
pnpm exec changesetto create a changeset. |
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.
Use
@fingerprintjs/eslint-config-dx-team@3.0.0which requires ESLint v10, exports a flat config array, and ships a type-aware config via its/type-checkedexport.Dependency changes
eslint8.57.0^10.4.1@fingerprintjs/eslint-config-dx-team^0.1.0^3.0.0eslint@^10+typescript-eslint@^8)eslint-config-next14.1.3^16.2.0@rushstack/eslint-patchwhich fails on ESLint v10; v16 is flat-config nativeeslint-plugin-react-hooks^4.6.0^7.0.0eslint-config-next@16eslint-plugin-prettier^5.5.5@eslint/eslintrc^3.0.0FlatCompatinexamples/preact. We can consider moving this to the example package.json filetypescript-eslint^8.60.0Config notes
settings.react.version: '18.2'instead of'detect': thedetectpath ineslint-plugin-react@7.37.xcallscontext.getFilename()which was removed in ESLint v10.Parser override for
.jsfiles:eslint-config-next@16sets@babel/eslint-parserfor all files, then restores@typescript-eslint/parseronly for.ts/.tsx. The babel parser'seslint-scope@5.xscope manager lacks theaddGlobals()method ESLint v10 requires, so we re-apply@typescript-eslint/parserfor.js/.jsxfiles.examples/preact— usesFlatCompatto wrapeslint-config-preact(no flat config support).plugin:@typescript-eslint/recommendedis replaced withtseslint.configs.recommended(unified package v8) to support TypeScript 5.9Type-aware linting (dx-team v3)
Switched the root config to the
/type-checkedexport, which layersstrictTypeCheckedplusstrict-boolean-expressions,prefer-nullish-coalescing,restrict-template-expressions, etc. on top of the base rules.tsconfig.eslint.jsoncoveringsrc,__tests__, and the root config files. The buildtsconfig.jsonstill only includessrc, so tests/config would otherwise fail the type-aware parser with "not in project".parserOptions.projectblock is ordered afternextConfigso its parser swap doesn't strip the typed parser off.tsxfiles; pure-JS config/scripts getdisableTypeChecked.srcfixes are mechanical (?? [],??=,String(...)in templates, explicit nullish checks). Full pass verified:eslint --max-warnings 0,tsc --noEmit, 21/21 tests, andvite buildall green.Discussion point: test rule relaxation scoped to one rule
Tests only turn off
@typescript-eslint/no-unsafe-assignment, because vitest'sexpect.any()matcher returnsany. I measured what actually fires rather than copying the broader relaxation set from the node SDK — only this one triggers. Push back if you'd rather pre-emptively relax the fullno-unsafe-*set for tests.Discussion point:
assertIsTruthy→assertIsDefinedstrict-boolean-expressionsflagged the!valuecheck. Since the function assertsNonNullable<T>and throws "must not be null or undefined", I changed it to an explicitvalue === null || value === undefinedand renamed it to match its real contract. Behaviour-adjacent but safe: both callers pass objects, never falsy primitives.Discussion point: removed always-true
if (env)guardIn
fingerprint-provider.tsxenvis typed non-nullable, sono-unnecessary-conditionflagged the guard. Removed it and kept explicit empty/undefined handling forenv.version. Thereact-sdk/.../reactintegration-info assertion exercises this path.Code changes (ESLint v10 base rules)
@typescript-eslint/no-empty-object-typeEmpty object type
{}is now flagged;objectis the correct replacement when you mean "no specific props".no-promise-executor-return__tests__/helpers.tsx@typescript-eslint/no-non-null-assertionDOM
querySelectorcalls in tests suppressed witheslint-disable-next-line. The elements are asserted to exist by the test setup.@typescript-eslint/no-explicit-any{ env?: { name: string } }instead ofany.render(...args: any[])->render(...args: unknown[]).@typescript-eslint/ban-ts-commentThe rule now requires a description when suppressing comments.
@typescript-eslint/consistent-type-assertionsconst mock = fn as FunctionComponent->const mock: FunctionComponent = fneslint-disable-next-line.no-useless-constructorEmpty constructor removed. It provided no behaviour and is redundant when the parent's constructor signature is identical.
@typescript-eslint/no-require-importsCJS file using
require()suppressed with a file-level disable. The script runs in Nodebefore any bundler, and cannot use ESM (depends on Node.js version).