Skip to content

chore(v2): align ESLint and Prettier with sdk-web - #1329

Open
crisryantan wants to merge 5 commits into
developmentfrom
chore/align-lint-sdk-web-v2
Open

chore(v2): align ESLint and Prettier with sdk-web#1329
crisryantan wants to merge 5 commits into
developmentfrom
chore/align-lint-sdk-web-v2

Conversation

@crisryantan

@crisryantan crisryantan commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace GTS, TSLint, legacy ESLint, and Prettier 1 with ESLint 9 flat config and Prettier 3 for the core SDK (aligned with sdk-web)
  • add Husky + lint-staged, then normalize formatting across src, test/src, and test/jest
  • preserve ES5 output compatibility, keep kits/** on their own tooling, and classify Sonar sources/tests separately

This is the v2/master counterpart of #1322 (which targets main for v3).

Test plan

  • npm run lint
  • npm run prettier
  • npm run build:iife
  • npm run test:jest

Checklist

  • Self-review completed
  • Tests added or updated
  • Tested locally

Standardize core SDK linting and formatting for v2 while preserving ES5
output and keeping kit tooling isolated. Mirrors the approach from #1322
onto master.
@crisryantan
crisryantan requested a review from a team as a code owner August 18, 2026 17:42
@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Tooling and CI-only changes; no production SDK runtime behavior. Risk is mainly contributor friction if new ESLint rules or pre-commit hooks fail on existing code.

Overview
Aligns core SDK lint/format with sdk-web by dropping .eslintrc and .prettierrc in favor of eslint.config.mjs (ESLint 9 flat config) and .prettierrc.yaml (Prettier 3, 120 print width). TypeScript gets @typescript-eslint rules matching sdk-web; legacy .js keeps relaxed rules (including off prefer-spread / prefer-rest-params for ES5 output). kits/** stays excluded from root lint.

Developer workflow moves from the old pre-commit package to Husky + lint-staged (Prettier write + ESLint fix on staged .js/.ts). .prettierignore expands to skip bundles, coverage, kits, and generated test artifacts.

CI and quality gates: BrowserStack workflows get a 30-minute job timeout; the main cross-browser workflow adds concurrency (one matrix per branch, cancel in-progress). .sonarcloud.properties sets sonar.sources=src and sonar.tests=test so duplicated test setup does not fail the new-code gate. Jest ignores Adobe/Rokt kit paths and restores jest/node types in ts-jest when the root tsconfig clears global types.

Docs (AGENTS.md, CONTRIBUTING.md, README.md) describe the new lint, lint:fix, format, and pre-commit behavior.

Reviewed by Cursor Bugbot for commit b5ade8e. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c8c2a38. Configure here.

Comment thread eslint.config.mjs
generateHash returns a number, getFirstSeenTime returns a numeric
timestamp, and PromotionActionType is numeric at runtime. The interfaces
declared these as strings, which made SonarCloud flag existing test
assertions as incompatible-type comparisons. Also drop the async keyword
from a describe callback, which must be synchronous.
@crisryantan

Copy link
Copy Markdown
Contributor Author

CI check triage

SonarCloud — fixed

The Quality Gate failed on D Reliability Rating on New Code: 11 bugs, all in test files. They were pre-existing assertions that Prettier reflowed, which made Sonar re-classify them as "new code".

Root cause was interfaces disagreeing with runtime values, so Sonar saw string vs number comparisons:

Declaration Was Runtime Now
MParticleWebSDK.generateHash / SDKHelpersApi.generateHash string utils.ts returns number number
IPersistence.getFirstSeenTime string | null numeric timestamp (setFirstSeenTime(_, time: number)) number | null
SDKPromotionAction.PromotionActionType / IServerV2DTO.pm.an string numeric enum (PromotionActionType = 0/1/2) number

Also removed async from a describe callback in tests-self-hosting-specific.js (test suite callbacks must be synchronous).

These are type-only changes plus one cast in sdkToEventsApiConverter where the Events API enum is genuinely a string. SonarCloud now passes.

BrowserStack — pre-existing, not caused by this PR

I ran cross-browser-testing.yml via workflow_dispatch against unmodified master HEAD (988b717) to get an apples-to-apples baseline:

  • master HEAD: 48 failures (47 Edge 15, 1 Firefox 51)
  • this PR: 49 failures

Every one of master's 48 failures is also present here. The single difference is Firefox 153 — mParticle instance manager … creates multiple instances with their own cookies, which is a flake: it passed in the other two BrowserStack runs on this branch.

Worth noting the two Old model to batch model conversion … page_url Edge 15 failures look new against the last pushed master CBT run, but that run predates feat: capture page_url in events (#1276). Those tests fail on master HEAD today.

One PR run also failed purely on BrowserStack Rate Limit Exceeded (0 test failures — Edge 15 / Safari 11.1 / Opera 37 could not start). cross-browser-testing.yml uses on: [push, pull_request], so a branch in this repo starts two concurrent runs and exhausts parallel sessions. Pre-existing config issue, separate from this PR.

Check PR for semantic target branch — pre-existing repo config

pr-branch-target-gitflow.yml@stable only accepts main or build/, but this repo's default branch is master. This check fails on every PR into master, including merged ones (#1274, #1254). Not something this PR can fix.

Verified locally

npm run lint · npm run prettier · npm run build:ts · npm run build:iife · npm run test:jest (26 suites / 625 tests) · Karma core suite (1087 tests, ChromeHeadless)

Bring over the lasting #1321 CBT fixes for master: shared karma
settings, drop EdgeHTML 15, concurrency across push/PR, tunnel
localIdentifier, longer wait timeouts, and deflaked identify /
multi-instance specs. Also stop re-registering @typescript-eslint
in the flat config so ESLint cannot hit a plugin redefinition error.
@crisryantan

Copy link
Copy Markdown
Contributor Author

Code review follow-up

Ported the lasting BrowserStack stability work from #1321 onto this v2/master branch and addressed the Bugbot finding.

From #1321 (net tip state)

EdgeHTML-only workarounds were intentionally skipped — #1321’s final tip reverts them after dropping Edge 15 from the matrix. What landed:

  • Shared BrowserStack karma settings (browserstack.karma.shared.js)
  • Drop legacy EdgeHTML 15 from the CBT matrix
  • Concurrency group shared across push and pull_request (github.head_ref || github.ref_name)
  • Tunnel localIdentifier pin + 30m job timeout
  • waitForCondition default raised to 3s; mocha timeout 20s
  • Deflake: wait for in-flight identify in failed-config core SDK spec
  • Deflake: wait for all instance cookies in multi-instance manager spec

Bugbot: ESLint plugin registered twice

Removed the duplicate @typescript-eslint plugin registration from eslint.config.mjs. FlatCompat already loads it via extends, so re-registering a second plugin object could trigger a redefinition error. npm run lint still passes.

@sonarqubecloud

Copy link
Copy Markdown

@crisryantan
crisryantan changed the base branch from master to development August 18, 2026 20:42
@crisryantan
crisryantan requested a review from rmi22186 August 19, 2026 13:11
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.

1 participant