Skip to content

Conversation

@Anemy
Copy link
Member

@Anemy Anemy commented Dec 18, 2025

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 const vs Readonly<...> in some places, let me know if y'all have a idea of the pattern I should follow. I'm thinking let's prefer Readonly as it ensures we're not casting unintentionally?

@Anemy Anemy requested a review from a team as a code owner December 18, 2025 18:32
Copy link
Contributor

Copilot AI left a 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 const assertions to readonly constant objects
  • Fixed test assertions to use queryByTestId instead of getByTestId with 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)

Comment on lines +46 to +50
Object.create(null);

for (const tag of expectedTags) {
result[tag] = null;

Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
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) {

Copilot uses AI. Check for mistakes.
'AtlasAiService',
`Failed to parse value for tag <${tag}>: ${value}`,
{ error: e }
);
Copy link
Member Author

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.

@codeowners-service-app
Copy link

Assigned kraenhansen for team compass-developers because paula-stacho is out of office.

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.

2 participants