Skip to content

Conversation

@haifeng-li-at-salesforce
Copy link
Contributor

feat: Add getter komaci rules to offline analysis tool

What does this PR do?

This PR adds getter violation detection features and comprehensive tests to the mobile-web-mcp server's offline analysis tool. The implementation includes Komaci rules for validating getter usage in Lightning Web Components (LWC) to ensure mobile-ready patterns.

What issues does this PR fix or reference?

Gus Item: @W-20161235@

Changes

  1. feat: add getter komaci rules to offline analysis tool of mobile-web-mcp

    • Implemented getter validation rules in the offline analysis tool
    • Enhanced rule configuration with getter-specific checks
    • Updated schemas to support getter analysis
  2. test: add tests for getter komaci rules for offline analysis tool of mobile-web-mcp server

    • Added comprehensive test coverage for getter rules
    • Extended test suite with 319 new lines of test code
    • Validated getter violation detection across various scenarios

Files Changed

packages/mcp-provider-mobile-web/package.json                          |   2 +-
packages/mcp-provider-mobile-web/src/schemas/analysisSchema.ts         |   1 +
packages/mcp-provider-mobile-web/src/schemas/lwcSchema.ts              |   6 +-
packages/mcp-provider-mobile-web/src/tools/offline-analysis/
  get_mobile_lwc_offline_analysis.ts                                   |  40 ++-
packages/mcp-provider-mobile-web/src/tools/offline-analysis/
  ruleConfig.ts                                                        |  79 ++++-
packages/mcp-provider-mobile-web/test/tools/offlineAnalysisTool.test.ts| 343 +++++++++++++++++++--

6 files changed, 431 insertions(+), 40 deletions(-)

Summary

  • Added: Getter Komaci rules for LWC offline analysis
  • Enhanced: Rule configuration system with getter validation logic
  • Updated: Analysis and LWC schemas to support getter checks
  • Tested: Comprehensive test suite ensuring getter violation detection works correctly

Impact

This change improves the mobile-web-mcp server's ability to detect and report getter-related violations in Lightning Web Components, helping developers write more mobile-friendly code.

@haifeng-li-at-salesforce haifeng-li-at-salesforce requested a review from a team as a code owner November 10, 2025 21:36

const baseName = code.name;

bundleAnalyzer.setLwcBundleFromContent(baseName, jsCode, htmlCode);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Load both JS and HTM files into bundle. Sometimes getter in JS is referenced from 'html' files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All HTML templates have been passed in setLwcBundleFromContent

}

private analyzeIssues(code: string, messages: Linter.LintMessage[]): ExpertCodeAnalysisIssuesType {
private analyzeIssues(code: string, messages: Linter.LintMessage[], jsPath: string): ExpertCodeAnalysisIssuesType {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the file path to help the model quickly locate the file containing the issues.

export const LwcCodeSchema = z.object({
name: z.string().min(1).describe('Name of the LWC component'),
namespace: z.string().describe('Namespace of the LWC component').default('c'),
js: LwcFileSchema.describe('LWC component JavaScript file.'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LWC has only 1 JS file

@haifeng-li-at-salesforce haifeng-li-at-salesforce changed the title Getter validation W-20161235: Add getter komaci rules to offline analysis tool Nov 10, 2025
Copy link
Contributor

@khawkins khawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change I'd like to see is not artificially limiting the number of LWC templates in the analysis. Otherwise, this passes muster to me.

Copy link
Contributor

@khawkins khawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a formatting issue suggestion in the prompt, but otherwise this looks fine to me.

…leConfig.ts

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>
"dedent": "^1.5.3",
"@salesforce/mcp-provider-api": "^0.4.0",
"@salesforce/eslint-plugin-lwc-graph-analyzer": "^1.0.0",
"@salesforce/eslint-plugin-lwc-graph-analyzer": "^1.1.0-beta.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has a non-prerelease version of this been released?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this beta includes the Komaci 260 release, so the official graph analyzer release will need to happen in the 262 timeframe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iowillhoit A bit of backstory on this one. eslint-plugin-lwc-graph-analyzer depends on the Komaci static analyzer, and that in turn has a dependency on core major releases, where changes can be breaking. Now in this case:

  • Other than the Komaci dependency update, the code line of eslint-plugin-lwc-graph-analyzer has otherwise been stable for quite some time.
  • The Komaci change itself is mostly a bug fix that we wanted for this PR, and otherwise as a product isn't changing significantly anymore.
  • Given that the Komaci change is technically a part of the next major release, we were nevertheless reluctant to make the dependency a part of the latest publication, just to follow that cadence. So we're effectively staging the change, with no other anticipated updates, until the next major release lands.
  • But given what we know about the actualities of the change, it felt okay to consume that change ourselves, here, since all of the code is stable and more or less static these days.

Anyway, I wanted to give you the details that went into the decision. Happy to discuss more, if you have questions.

@iowillhoit iowillhoit merged commit 094ee00 into salesforcecli:main Nov 14, 2025
14 checks passed
SamarthAroraa pushed a commit to SamarthAroraa/mcp that referenced this pull request Nov 17, 2025
…rcecli#326)

* feat: add getter komaci rules to offline analysis tool of mobile-web-mcp

* test: add tests for getter komaci rules for offline analysis tool of `mobile-web-mcp` server

* fix: change based on feedback

* fix: change  based on feedback. Make instructions more AI friendly

* Update packages/mcp-provider-mobile-web/src/tools/offline-analysis/ruleConfig.ts

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>

* fix: update graph-analyzer with node 20 engine

---------

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>
SamarthAroraa pushed a commit to SamarthAroraa/mcp that referenced this pull request Nov 20, 2025
…rcecli#326)

* feat: add getter komaci rules to offline analysis tool of mobile-web-mcp

* test: add tests for getter komaci rules for offline analysis tool of `mobile-web-mcp` server

* fix: change based on feedback

* fix: change  based on feedback. Make instructions more AI friendly

* Update packages/mcp-provider-mobile-web/src/tools/offline-analysis/ruleConfig.ts

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>

* fix: update graph-analyzer with node 20 engine

---------

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>
SamarthAroraa pushed a commit to SamarthAroraa/mcp that referenced this pull request Nov 20, 2025
…rcecli#326)

* feat: add getter komaci rules to offline analysis tool of mobile-web-mcp

* test: add tests for getter komaci rules for offline analysis tool of `mobile-web-mcp` server

* fix: change based on feedback

* fix: change  based on feedback. Make instructions more AI friendly

* Update packages/mcp-provider-mobile-web/src/tools/offline-analysis/ruleConfig.ts

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>

* fix: update graph-analyzer with node 20 engine

---------

Co-authored-by: Kevin Hawkins <khawkins@salesforce.com>
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.

3 participants