chore: replace eslint-config-airbnb with eslint:recommended#1299
Conversation
Replace unmaintained eslint-config-airbnb-base (last published 2022) and eslint-config-airbnb-typescript (archived May 2025) with eslint:recommended + @typescript-eslint/recommended + explicit rules for eqeqeq, prefer-const, no-var, and no-restricted-syntax (minus ForOfStatement). - Remove eslint-config-airbnb-base and eslint-config-airbnb-typescript from all 36 package.json devDependencies - Add 'import' to plugins (was loaded implicitly by airbnb) - Disable noisy @typescript-eslint/recommended rules the codebase is not ready for (no-explicit-any, ban-ts-comment, ban-types, etc.) - Turn off import/extensions (was masked by airbnb-typescript override) - Fix ESLint parsing errors by adding ignorePatterns for example dirs, setting tsconfigRootDir, and making svelte tsconfig.eslint.json standalone - Add .tsx to tsconfig.eslint.json include pattern Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
- Turn off import/export rule (doesn't understand TypeScript re-export shadowing in combined-browser and react SDKs) - Remove broad **/server-ai/examples/** ignorePattern that prevented CI from linting examples - Create tsconfig.eslint.json for 6 server-ai examples that were missing them (chat-judge, direct-judge, agent-graph-traversal, chat-observability, openai-observability, tracked-chat) - Add server-ai example tsconfigs to parserOptions.project glob Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@launchdarkly/browser size report |
Revert the tsconfig.eslint.json additions for server-ai examples. Instead, ignore the two examples (chat-judge, direct-judge) that were already broken on main due to missing tsconfig.eslint.json files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| @@ -1,5 +1,14 @@ | |||
| { | |||
| "extends": "./tsconfig.json", | |||
| "compilerOptions": { | |||
There was a problem hiding this comment.
This is a fix for an existing issue
| 'import/default': 'error', | ||
| 'import/export': 'error', | ||
| 'import/extensions': ['error', 'never', { json: 'always' }], | ||
| 'import/export': 'off', |
There was a problem hiding this comment.
These were more or less the overrides that the eslint-config-airbnb-typescript applied. So the original rules were not doing anything anyway.
They were turned off because typescript already does validation and these issues would manifest in compilation issues
| parserOptions: { | ||
| project: './tsconfig.eslint.json', | ||
| project: [ | ||
| './packages/sdk/svelte/tsconfig.eslint.json', |
There was a problem hiding this comment.
unfortunately, svelte has a generated tsconfig that breaks the base eslint config (this was an existing issue that got masked) so we have a standalone config that does not rely on the generated files
| ], | ||
| rules: { | ||
| '@typescript-eslint/lines-between-class-members': 'off', | ||
| 'eqeqeq': ['error', 'always', { null: 'ignore' }], |
There was a problem hiding this comment.
The rest of these rules are the same ones that are preconfigured by the airbnb package base
| 'eqeqeq': ['error', 'always', { null: 'ignore' }], | ||
| 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], | ||
| 'no-var': 'error', | ||
| 'valid-typeof': 'off', |
There was a problem hiding this comment.
will be re-enabled in #1301 ... this was somehow missed for a while
| 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], | ||
| 'no-var': 'error', | ||
| 'valid-typeof': 'off', | ||
| 'no-restricted-syntax': [ |
There was a problem hiding this comment.
this is the same as the airbnb base, but without the ban on for...of, the other syntax bans seem reasonable
| '@typescript-eslint/no-explicit-any': 'off', | ||
| '@typescript-eslint/ban-ts-comment': 'off', | ||
| '@typescript-eslint/ban-types': 'off', | ||
| '@typescript-eslint/no-var-requires': 'off', | ||
| '@typescript-eslint/no-non-null-asserted-optional-chain': 'off', | ||
| '@typescript-eslint/no-this-alias': 'off', |
There was a problem hiding this comment.
These rules are "new" rules that the old airbnb rules did not capture... turning them off for now since we have too many violations (and I have not assess them yet, but some of them definitely seem like rules we should have)
## Summary - Remove ~65 stale `eslint-disable` comments for rules that no longer exist after replacing airbnb config - Rules removed: `no-param-reassign` (43), `no-bitwise` (10), `no-restricted-syntax` for ForOfStatement (11), `no-plusplus` (4), `no-continue` (1) - Retains a targeted `no-restricted-syntax` disable in vendor `TraceKit.ts` for a legitimate `for...in` loop ## Test plan - [ ] `yarn workspaces foreach -p run lint` passes with 0 errors - [ ] No functional code changes (comment removal only) - [ ] `grep -rn "eslint-disable.*no-(param-reassign|bitwise|plusplus|continue)" packages/` returns zero results Depends on #1299. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Primarily removes lint suppression comments with no runtime behavior changes; minor risk is limited to new `no-param-reassign` enforcement surfacing previously ignored lint violations. > > **Overview** > Cleans up stale `eslint-disable` directives across SDKs/tests (bitwise, plusplus, restricted-syntax, etc.) after the eslint config change, leaving code behavior unchanged. > > Updates `.eslintrc.js` to explicitly enforce `no-param-reassign`, and keeps a single targeted `no-restricted-syntax` suppression in vendor `TraceKit.ts` for a necessary `for...in` loop. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7695809. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
## Summary - Fix `typeof x !== undefined` (always true) to `typeof x !== 'undefined'` (correct) in 5 locations - `isDocument()` and `isWindow()` now correctly return `false` in service worker contexts - `getCrypto()` now correctly throws when crypto API is unavailable - `randomUuidV4()` now correctly falls back when `crypto.randomUUID` is missing - Re-enables the `valid-typeof` ESLint rule to prevent this class of bug ## Context These bugs were introduced in Sept-Oct 2024. Since `typeof` always returns a string, comparing against the value `undefined` (not the string `'undefined'`) made these checks always truthy. The bug was masked because the previous ESLint config did not flag this pattern. ## Affected files - `packages/sdk/browser/src/BrowserApi.ts` (3 locations) - `packages/sdk/browser/src/platform/randomUuidV4.ts` (1 location) - `packages/telemetry/browser-telemetry/src/randomUuidV4.ts` (1 location) ## Test plan - [ ] `yarn workspaces foreach -p run lint` passes with 0 errors - [ ] `yarn workspace @launchdarkly/js-client-sdk test` passes - [ ] `yarn workspace @launchdarkly/browser-telemetry test` passes Depends on #1299. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Fixes environment/crypto detection and UUID generation fallback logic in browser-facing SDK code; while small, it can change behavior in non-browser contexts (service workers/SSR) and affects ID generation paths. > > **Overview** > Corrects several invalid `typeof x !== undefined` checks to `typeof x !== 'undefined'` in the browser SDK and browser telemetry UUID helper, so non-browser contexts no longer incorrectly treat `document`, `window`, or `crypto` as available. > > Re-enables ESLint `valid-typeof` to prevent regressions, and adds Jest coverage to ensure `isDocument`/`isWindow` return `false` when globals are missing and `randomUuidV4` properly falls back when `crypto.randomUUID` is unavailable. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 074d3f3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
eslint-config-airbnb-base(v15, last published 2022) andeslint-config-airbnb-typescript(archived May 2025) witheslint:recommended+@typescript-eslint/recommendedeqeqeq,prefer-const,no-var, andno-restricted-syntax(dropsForOfStatementban since ES2020 target makes it irrelevant)package.jsondevDependenciestsconfigRootDir, and standalone sveltetsconfig.eslint.jsonWhat changed in .eslintrc.js
airbnb-base+airbnb-typescript/base->eslint:recommended+@typescript-eslint/recommendedimport(was loaded implicitly by airbnb)no-explicit-any,ban-ts-comment,ban-types,no-var-requires,no-this-alias,no-non-null-asserted-optional-chaintsconfigRootDir: __dirnameand svelte tsconfig to project arrayTest plan
yarn workspaces foreach -p run lintpasses with 0 errorseslint-disablecomments are harmless (cleaned up in follow-up PR)🤖 Generated with Claude Code
Note
Medium Risk
Touches repo-wide lint/TS parsing configuration and removes shared ESLint presets across many workspaces, which may cause new/changed lint failures in CI even though runtime code is unchanged.
Overview
Swaps the root ESLint baseline from Airbnb TypeScript presets to
eslint:recommended+@typescript-eslint/recommended, adds the missingimportplugin explicitly, and tweaks/overrides several rules (e.g., enforcingeqeqeq/no-var, relaxing several TypeScript strictness rules, and disablingimport/extensionsandimport/export).Updates ESLint parsing inputs by expanding
parserOptions.project(including a dedicated Sveltetsconfig.eslint.jsonand settingtsconfigRootDir), broadenstsconfig.eslint.jsonto include*.tsx, and adds newignorePatternsfor additional generated/example directories. Removeseslint-config-airbnb-baseandeslint-config-airbnb-typescriptfrom devDependencies across the monorepo.Reviewed by Cursor Bugbot for commit 3ee1a8f. Bugbot is set up for automated code reviews on this repo. Configure here.