Skip to content

chore(deps): upgrade ESLint from v8 to v9 with flat config migration - #214

Merged
uc-brunosilva merged 1 commit into
masterfrom
MSDK-3343-eslint-v9-upgrade
Jun 2, 2026
Merged

chore(deps): upgrade ESLint from v8 to v9 with flat config migration#214
uc-brunosilva merged 1 commit into
masterfrom
MSDK-3343-eslint-v9-upgrade

Conversation

@asadraza-usercentrics

@asadraza-usercentrics asadraza-usercentrics commented May 26, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

Resolves MSDK-3343. ESLint 8.x reached end-of-life and the @eslint/eslintrc
package it depends on was deprecated.

What changed

  • Replaced .eslintrc.js + .eslintignore with eslint.config.js (ESLint v9 flat config)
  • Upgraded eslint 8 → 9, replaced @react-native-community/eslint-config with
    @typescript-eslint + eslint-plugin-prettier@5 + prettier@3
  • src/fabric/** excluded from linting — codegen spec files have strict type
    requirements (Object vs object) that must not be auto-fixed
  • Prettier and import-sort rules set to warn so pre-existing style in model files
    doesn't block CI

Sample app fixes (caught during verification)

  • Removed unused Platform import in src/Usercentrics.tsx
  • Fixed no-unused-vars in scripts/publish-local.js
  • Fixed lint errors in sample screens (Home, CustomUI, WebviewIntegrationScreen)
  • Added nodeModulesPaths to sample/metro.config.js for Metro module resolution
  • Removed mavenLocal() from sample/android/settings.gradle.kts — was resolving
    a locally-built sandbox SDK instead of the published production artifact

Test plan

  • yarn lint passes with 0 errors
  • yarn test — 32/32 tests pass
  • Android sample app builds and shows consent banner
  • iOS sample app builds and shows consent banner

CodeAnt-AI Description

Upgrade linting setup and fix sample app issues caught during verification

What Changed

  • Moved the project to ESLint 9 and the newer flat config format, so linting works with the current toolchain
  • Kept pre-existing style issues from blocking CI by treating formatting and import-order issues as warnings
  • Fixed sample app code so it passes lint checks and avoids runtime build issues, including clearer consent screen handling and safer module resolution in Metro
  • Updated the local publish script and removed unused imports and variables found during verification

Impact

✅ Fewer lint failures during CI
✅ Smoother sample app builds
✅ Fewer Metro module resolution errors

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Chores

    • Updated ESLint configuration to v9 with flat-config format
    • Updated development dependencies for React Native and TypeScript tooling
    • Removed unused imports and dependencies from sample application
    • Updated sample application configuration settings
  • Bug Fixes

    • Enhanced error handling and validation in consent screens
    • Improved type safety with strict undefined checks

Review Change Stack

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented May 26, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR migrates ESLint configuration to v9 flat config format, updates sample app screens with stricter type checking and React hooks patterns, refines build configuration for improved module resolution, and rewrites the publish script with robust version restoration and error handling.

Changes

ESLint Configuration Migration to v9

Layer / File(s) Summary
ESLint flat configuration setup
eslint.config.js
New flat config exports global ignores, baseline JS/Prettier rules, CommonJS and TypeScript overrides with parser registration, and Jest-aware test file overrides that relax explicit-any restrictions.
Package dependencies and lint script update
package.json
Lint script simplified to eslint . without extension flags; devDependencies upgraded to ESLint v9, TypeScript linting packages, and Prettier plugins while dropping React Native community config.

Sample Application, Build Configuration & SDK Refinements

Layer / File(s) Summary
Build configuration updates
sample/android/settings.gradle.kts, sample/metro.config.js
Gradle removes mavenLocal() repository; Metro explicitly configures dual node_modules resolution paths for SDK and parent repository module discovery.
Sample app constants
sample/src/App.tsx
MEDIATION_TEST_ENABLED switched to false; SETTINGS_ID updated for Usercentrics configuration.
Sample screen refactoring with stricter checks and hooks
sample/src/screens/CustomUI.tsx, sample/src/screens/Home.tsx, sample/src/screens/WebviewIntegrationScreen.tsx
CustomUI uses strict === undefined checks across guard conditions and assigns CMP data to intermediate variable before state update; Home refactors consent callbacks into memoized React.useCallback with try/catch error logging and updated effect dependencies; WebviewIntegrationScreen removes unused Text import.
Publish script refactor with version restoration
scripts/publish-local.js
Script rewritten to track original package version, define restoration helper, register cleanup handlers for exit and signal termination, clean lib/, run compile, execute npm pack with validation, and compute absolute paths for installation instructions.
Core SDK import cleanup
src/Usercentrics.tsx
Unused Platform import removed from react-native imports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

Review effort 1/5, size:L

Suggested reviewers

  • uc-brunosilva
  • islameldesoky95
  • uc-brunosouza

Poem

A rabbit hops through linting rules,
ESLint nine brought shiny tools,
Sample screens now strict and fine,
With hooks and checks in perfect line,
Version restored when publish starts—
A PR of many moving parts! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: upgrading ESLint from v8 to v9 with migration to flat config format.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MSDK-3343-eslint-v9-upgrade

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

sample/metro.config.js

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

sample/src/App.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

sample/src/screens/CustomUI.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 2 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Upgrade ESLint to v9 with flat config and TypeScript linting improvements

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Migrated ESLint configuration from v8 to v9 with flat config format
• Replaced deprecated @react-native-community/eslint-config with @typescript-eslint and
  prettier
• Excluded src/fabric/** from linting to preserve codegen-required type strictness
• Fixed lint errors across sample app and scripts with improved code quality
Diagram
flowchart LR
  A["ESLint v8<br/>.eslintrc.js"] -->|"Migrate to flat config"| B["ESLint v9<br/>eslint.config.js"]
  C["@react-native-community<br/>eslint-config"] -->|"Replace with"| D["@typescript-eslint<br/>+ prettier + simple-import-sort"]
  E["Lint errors<br/>in samples"] -->|"Fix"| F["Clean code<br/>with warnings"]
  B --> G["Exclude src/fabric/**<br/>from linting"]

Loading

Grey Divider

File Changes

1. eslint.config.js ⚙️ Configuration changes +76/-0

New ESLint v9 flat config format

eslint.config.js


2. .eslintrc.js ⚙️ Configuration changes +0/-11

Removed legacy ESLint v8 config

.eslintrc.js


3. .eslintignore ⚙️ Configuration changes +0/-2

Removed ignore file for flat config

.eslintignore


View more (9)
4. package.json Dependencies +8/-3

Updated ESLint and linting dependencies

package.json


5. scripts/publish-local.js 🐞 Bug fix +115/-105

Fixed formatting and unused variable errors

scripts/publish-local.js


6. sample/metro.config.js ✨ Enhancement +7/-0

Added nodeModulesPaths for Metro resolution

sample/metro.config.js


7. sample/android/settings.gradle.kts 🐞 Bug fix +0/-1

Removed mavenLocal repository reference

sample/android/settings.gradle.kts


8. sample/src/App.tsx Miscellaneous +2/-2

Updated test settings and IDs

sample/src/App.tsx


9. sample/src/screens/CustomUI.tsx 🐞 Bug fix +13/-13

Fixed variable shadowing and equality checks

sample/src/screens/CustomUI.tsx


10. sample/src/screens/Home.tsx ✨ Enhancement +37/-24

Refactored with callbacks and error handling

sample/src/screens/Home.tsx


11. sample/src/screens/WebviewIntegrationScreen.tsx 🐞 Bug fix +1/-1

Removed unused Text import

sample/src/screens/WebviewIntegrationScreen.tsx


12. src/Usercentrics.tsx 🐞 Bug fix +1/-1

Removed unused Platform import

src/Usercentrics.tsx


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 26, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0)

Grey Divider


Remediation recommended

1. Undeclared globals import 🐞 Bug ☼ Reliability
Description
eslint.config.js imports the "globals" package directly, but package.json does not declare it in
devDependencies, making the lint configuration depend on transitive/hoisted resolution. This can
cause ESLint to fail to load the config with "Cannot find module 'globals'" in environments that
don’t hoist transitive dependencies (or if the transitive tree changes).
Code

eslint.config.js[R1-6]

Evidence
The ESLint config directly requires globals, but the repo’s declared devDependencies do not
include it, meaning dependency availability is not explicitly guaranteed by the project manifest.

eslint.config.js[1-6]
package.json[47-70]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`eslint.config.js` uses `require('globals')`, but `globals` is not declared in `package.json`. Because this is a direct import from the repo root, it should be explicitly declared to keep installs reproducible and avoid ESLint config load failures.

### Issue Context
The new flat config uses `globals` to set CommonJS/Node/Jest globals.

### Fix Focus Areas
- package.json[47-70]
- eslint.config.js[1-6]

### Suggested fix
Add `"globals": "^<appropriate-version>"` to `devDependencies` (choose a version compatible with the rest of the ESLint toolchain).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label May 26, 2026
@pantoaibot

pantoaibot Bot commented May 26, 2026

Copy link
Copy Markdown

PR Summary:

Upgrade ESLint to v9 and migrate to flat config; update devDeps and apply related lint/style and small runtime fixes across sample and scripts.

  • Add new flat ESLint config (eslint.config.js) using @eslint/js, @typescript-eslint, eslint-plugin-prettier and simple-import-sort; config splits rules for JS/TS/tests, warns on Prettier and import sorting to avoid CI breakage.
  • package.json:
    • Replace old ESLint config/deps with ESLint v9 ecosystem packages (@eslint/js, @typescript-eslint/parser & plugin, eslint-plugin-prettier, eslint-config-prettier, prettier).
    • Change "lint" script from "eslint . --ext .js,.jsx,.ts,.tsx" to "eslint .".
    • Bump prettier and eslint versions; run yarn/npm install required.
  • sample/metro.config.js: add resolver.nodeModulesPaths so Metro can resolve transitive deps in SDK node_modules.
  • sample/android/settings.gradle.kts: remove mavenLocal() entry (affects dependency resolution in sample build).
  • sample app changes:
    • sample/src/App.tsx: toggle MEDIATION_TEST_ENABLED -> false and update SETTINGS_ID (sample/demo change).
    • sample/src/screens/*:
      • Many TS/JS style fixes: strict equality (===), const naming for fetched data (cmpData/languageData), remove unused imports (Text in Webview screen), minor refactors.
      • HomeScreen: convert handlers to use useCallback, add try/catch with logging around Usercentrics.showFirstLayer/showSecondLayer/status, preserve behavior but add error handling and extra logs.
      • CustomUI and WebviewIntegration: guard checks standardized (=== undefined/null), cleanup variable names, maintain existing logic.
  • scripts/publish-local.js: code formatting and minor refactor (consistent single quotes, simplified catches) — behavior unchanged.
  • src/Usercentrics.tsx: remove unused Platform import (cleanup).

Potential impacts / action items:

  • Developers must install updated devDependencies (eslint v9 + plugins + prettier v3).
  • New ESLint flat config may surface different lint errors; check and fix as needed.
  • "lint" script no longer sets extensions explicitly (ESLint flat config resolves file types) — CI/config may need adjustment.
  • sample build behavior may change due to removal of mavenLocal() and updated Metro resolver.

Reviewed by Panto AI

Comment thread eslint.config.js
Comment thread package.json
Comment thread sample/src/App.tsx
Comment thread scripts/publish-local.js
Comment thread scripts/publish-local.js
Comment thread sample/android/settings.gradle.kts
@pantoaibot

pantoaibot Bot commented May 26, 2026

Copy link
Copy Markdown

Reviewed up to commit:0bfbb4d633082832553f767eb868c32144f60acb

Reviewed by Panto AI

@codeant-ai

codeant-ai Bot commented May 26, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@eslint.config.js`:
- Around line 19-23: Add the missing React Native baseline by including
'`@react-native-community`' in the ESLint configs array and make import-sorting
mandatory by adding the simple-import-sort plugin and turning on its rules for
all JS/TS file types; specifically, update eslint.config.js to include
'`@react-native-community`' alongside js.configs.recommended and
prettierRecommended, add 'simple-import-sort' to plugins, and replace the
current scoped/warn rules with global 'simple-import-sort/imports' and
'simple-import-sort/exports' set to 'error' (apply to **/*.{js,jsx,ts,tsx}) so
import ordering is enforced consistently.

In `@sample/src/App.tsx`:
- Around line 8-9: The README snippet showing sample constants must be updated
to match the new runtime defaults: change the MEDIATION_TEST_ENABLED value to
false and the SETTINGS_ID value to "EA4jnNPb9" so the documented example mirrors
the actual constants declared in the code (MEDIATION_TEST_ENABLED and
SETTINGS_ID); locate the README section with the sample snippet (lines showing
those two constants) and revise the values and any explanatory text that assumes
the old values.

In `@sample/src/screens/CustomUI.tsx`:
- Around line 174-175: The fetched CMP payload from Usercentrics.getCMPData()
(languageData) is only logged and not applied to component state, leaving `data`
stale; update the component state after the await by calling the appropriate
setter (e.g., setData(languageData) or merging into existing state) so the UI
and later actions use the refreshed CMP data; locate the call to
Usercentrics.getCMPData() and add the state update using the component's state
setter (handle merging if needed) and preserve async/await flow and basic error
handling.

In `@scripts/publish-local.js`:
- Around line 92-95: Replace the shell rm call used via execSync in
scripts/publish-local.js with Node's fs.rmSync to be cross-platform: remove the
execSync('rm -rf lib/') usage (and its try/catch) and call fs.rmSync for the lib
directory with { recursive: true, force: true } (import/require fs at top if
necessary) while retaining the same error-tolerant behavior; additionally,
update package.json's "compile" script (currently "rm -rf lib && tsc -p .") to a
cross-platform alternative (e.g., use a Node-based rm command or a package like
rimraf) so the removal of lib is not shell/POSIX dependent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf729a54-b794-4399-9ed7-9639b67a1bbd

📥 Commits

Reviewing files that changed from the base of the PR and between 2a0a334 and 0bfbb4d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • .eslintignore
  • .eslintrc.js
  • eslint.config.js
  • package.json
  • sample/android/settings.gradle.kts
  • sample/metro.config.js
  • sample/src/App.tsx
  • sample/src/screens/CustomUI.tsx
  • sample/src/screens/Home.tsx
  • sample/src/screens/WebviewIntegrationScreen.tsx
  • scripts/publish-local.js
  • src/Usercentrics.tsx
💤 Files with no reviewable changes (3)
  • .eslintrc.js
  • sample/android/settings.gradle.kts
  • .eslintignore

Comment thread eslint.config.js
Comment thread sample/src/App.tsx
Comment thread sample/src/screens/CustomUI.tsx
Comment thread scripts/publish-local.js
Comment thread sample/src/screens/Home.tsx
@uc-brunosilva
uc-brunosilva merged commit ea9cf47 into master Jun 2, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants