-
Notifications
You must be signed in to change notification settings - Fork 246
chore(lint): bump devtools shared eslint to latest, resolve issues COMPASS-10193 #7669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the devtools shared ESLint configuration to the latest version and resolves linting issues identified by the new rules. The changes primarily focus on improving type safety and following best practices for object initialization.
Key changes:
- Updated ESLint plugin dependencies from version 8.49.0 to 8.50.0
- Replaced object literal initializations with
Object.create(null)for true dictionary objects - Added
as constassertions to readonly constant objects - Fixed test assertions to use
queryByTestIdinstead ofgetByTestIdwith throw checks - Refactored code to improve clarity and type safety
Reviewed changes
Copilot reviewed 43 out of 44 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated TypeScript ESLint plugin versions to 8.50.0 |
| configs/eslint-config-compass/package.json | Updated ESLint config and plugin dependencies |
| packages/data-service/src/data-service.ts | Replaced implicit object with explicit type definition for groupStage |
| packages/connection-form/src/utils/csfle-kms-fields.ts | Added const assertion to empty object |
| packages/connection-form/src/hooks/use-connection-color.ts | Added const assertions to color mapping objects |
| packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.spec.tsx | Changed object initialization to Object.create(null) |
| packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx | Added const assertion to options object |
| packages/compass/src/main/auto-update-manager.ts | Wrapped Record types with Readonly for immutable objects |
| packages/compass-sidebar/src/components/use-filtered-connections.ts | Changed object initialization to Object.create(null) |
| packages/compass-settings/src/components/settings/proxy-settings.tsx | Added const assertion to update object |
| packages/compass-schema/src/modules/geo.spec.ts | Added const assertions to test layer objects |
| packages/compass-schema/src/components/export-schema-modal.tsx | Added const assertion to format options object |
| packages/compass-saved-aggregations-queries/src/index.spec.tsx | Fixed test assertions to use queryByTestId |
| packages/compass-indexes/src/modules/search-indexes.ts | Added const assertion to error messages object |
| packages/compass-indexes/src/modules/create-index.tsx | Changed spec object initialization to Object.create(null) |
| packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.tsx | Added const assertion to badge variants mapping |
| packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.spec.tsx | Fixed test assertions to use queryByTestId |
| packages/compass-import-export/src/utils/logger.ts | Changed logger registry initialization to Object.create(null) |
| packages/compass-import-export/src/modules/import.ts | Changed object initializations to Object.create(null) |
| packages/compass-import-export/src/import/list-csv-fields.ts | Changed fieldMap initialization to Object.create(null) |
| packages/compass-import-export/src/csv/csv-utils.spec.ts | Changed parsed object initialization to Object.create(null) |
| packages/compass-import-export/src/csv/csv-types.ts | Wrapped Record type with Readonly for field type labels |
| packages/compass-generative-ai/src/utils/parse-xml-response.ts | Refactored result object initialization and simplified conditional logic |
| packages/compass-generative-ai/src/components/ai-optin-modal.tsx | Added const assertion to styles object |
| packages/compass-generative-ai/src/atlas-ai-service.ts | Changed schema object initialization to Object.create(null) |
| packages/compass-editor/src/editor.tsx | Added const assertion to languages mapping |
| packages/compass-e2e-tests/tests/my-queries-tab.test.ts | Changed object initializations to Object.create(null) |
| packages/compass-e2e-tests/tests/collection-ai-query.test.ts | Fixed chai assertion syntax for string type check |
| packages/compass-e2e-tests/helpers/compass.ts | Added const assertion to configuration object |
| packages/compass-e2e-tests/helpers/commands/create-index.ts | Added const assertion to index type mapping |
| packages/compass-e2e-tests/helpers/commands/connect-form.ts | Added const assertion to color map |
| packages/compass-data-modeling/src/utils/nodes-and-edges.ts | Changed selection object initialization to Object.create(null) |
| packages/compass-data-modeling/src/components/saved-diagrams-list.tsx | Added const assertion to feature description object |
| packages/compass-context-menu/src/use-context-menu.spec.tsx | Fixed test assertions to use queryByTestId |
| packages/compass-components/src/components/drawer-portal.tsx | Changed nodes object initialization to Object.create(null) |
| packages/compass-components/src/components/document-list/document-edit-actions-footer.tsx | Added const assertion to status messages object |
| packages/compass-components/src/components/bson-value.tsx | Added const assertion to color mapping object |
| packages/compass-components/src/components/actions/small-icon-button.tsx | Added const assertion to button size styles |
| packages/compass-collection/src/transform-schema-to-field-info.ts | Changed fieldInfo object initialization to Object.create(null) |
| packages/compass-collection/src/components/mock-data-generator-modal/constants.ts | Wrapped Record types with Readonly for constant mappings |
| packages/compass-collection/src/components/collection-header/badges.tsx | Wrapped Record type with Readonly for badges mapping |
| packages/compass-assistant/src/prompts.spec.ts | Replaced generic Record type with explicit object type definition |
| packages/compass-aggregations/src/modules/side-panel.spec.ts | Changed localStorage values initialization to Object.create(null) |
| Object.create(null); | ||
|
|
||
| for (const tag of expectedTags) { | ||
| result[tag] = null; | ||
|
|
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initialization of result[tag] = null should occur after creating the object and before the loop, not inside the loop. Consider initializing all tags to null immediately after creating the object to avoid redundant assignments in each iteration.
| Object.create(null); | |
| for (const tag of expectedTags) { | |
| result[tag] = null; | |
| Object.fromEntries( | |
| expectedTags.map((tag) => [tag, null as string | null]) | |
| ) as Record<(typeof expectedTags)[number], string | null>; | |
| for (const tag of expectedTags) { |
| 'AtlasAiService', | ||
| `Failed to parse value for tag <${tag}>: ${value}`, | ||
| { error: e } | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a bit of a refactor here to simplify things.
|
Assigned |
COMPASS-10193
Fixes a few issues resulting from the new rules we added in
https://github.com/mongodb-js/devtools-shared/tree/main/configs/eslint-plugin-devtools/rules
Did one small refactor I'll callout in a comment.
Not sure on if we want
... as constvsReadonly<...>in some places, let me know if y'all have a idea of the pattern I should follow. I'm thinking let's preferReadonlyas it ensures we're not casting unintentionally?