Skip to content

Conversation

@utarwyn
Copy link
Member

@utarwyn utarwyn commented Mar 22, 2025

This PR improves the rule @creedengo/no-multiple-style-changes (GCI12) to avoid false-positives about nested objects. It also exclude non-literals to avoid reports when values are dynamic.

Fixes #72

@utarwyn utarwyn added 💉 bug: confirmed Something isn't working 🗃️ rule Impacts a rule labels Mar 22, 2025
@utarwyn utarwyn requested review from Copilot and dedece35 March 22, 2025 20:06
@utarwyn utarwyn self-assigned this Mar 22, 2025
Copy link

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 aims to improve the rule @creedengo/no-multiple-style-changes (GCI12) by preventing false-positives when nested objects are involved and by excluding non-literal assignments.

  • Updated the test suite to include parser options and additional valid/invalid test cases for nested objects.
  • Modified the rule implementation to derive a full object name using the new getNodeFullName helper.
  • Updated the CHANGELOG to reflect these changes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
eslint-plugin/tests/lib/rules/no-multiple-style-changes.js Added parser options and extra tests to cover nested object scenarios.
eslint-plugin/lib/rules/no-multiple-style-changes.js Introduced getNodeFullName to support nested objects in style assignment checks.
CHANGELOG.md Updated changelog for the new PR changes.
Comments suppressed due to low confidence (1)

eslint-plugin/lib/rules/no-multiple-style-changes.js:43

  • The function getNodeFullName assumes that node has either a 'name' or 'property.name'. In cases where neither is available, this could lead to runtime errors. Consider adding safe checks to verify that these properties exist before using them.
names.unshift(node.name ?? node.property.name);

@sonarqubecloud
Copy link

@utarwyn utarwyn merged commit a41928f into main Mar 23, 2025
7 checks passed
@utarwyn utarwyn deleted the fix-72-style-changes-nested branch March 23, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💉 bug: confirmed Something isn't working 🗃️ rule Impacts a rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False-positive with nested objects in GCI12

2 participants