Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ca810fa
NEW @W-23659201@ Add uibundle engine to Code Analyzer Core
amritmishra-sf Aug 17, 2026
ab15250
DOC @W-23659201@ Add README for uibundle engine
amritmishra-sf Aug 17, 2026
35cd871
FIX @W-23659201@ Skip virtual sources in AST orphan check, lower sour…
amritmishra-sf Aug 18, 2026
4064ba6
FIX @W-23659201@ Address PR review blockers on uibundle engine
amritmishra-sf Aug 18, 2026
4f48e7a
FIX @W-23659201@ Fix tsc type errors in uibundle engine tests
amritmishra-sf Aug 18, 2026
6e8c2d3
FIX @W-23659201@ Trim historical comments from uibundle validators
amritmishra-sf Aug 18, 2026
299cecc
FIX @W-23659201@ Remove uibundle from unpublished-package whitelist
amritmishra-sf Aug 18, 2026
b9c2659
FIX @W-23659201@ Strip remaining explanatory comments from uibundle s…
amritmishra-sf Aug 18, 2026
7b6b7f9
FIX @W-23659201@ Restore uibundle whitelist in version-check script
amritmishra-sf Aug 18, 2026
e91cbdc
FIX @W-23659201@ Remove uibundle engine README
amritmishra-sf Aug 18, 2026
0c948bd
Merge branch 'dev' into feature/W-23659201-uibundle-engine
amritmishra-sf Aug 18, 2026
f2aac4c
FIX @W-23659201@ Address PR #499 review blockers for uibundle engine
amritmishra-sf Aug 19, 2026
2147a6b
FIX @W-23659201@ Address PR #499 follow-up review comments
amritmishra-sf Aug 19, 2026
8f0ed18
FIX @W-23659201@ Align uibundle engine columns to 1-based SFCA conven…
amritmishra-sf Aug 19, 2026
b2d2d32
FIX @W-23659201@ Reduce uibundle Info-tier false positives on clean b…
amritmishra-sf Aug 20, 2026
6fa8155
FIX @W-23659201@ Make UIBundle rules opt-in for rule-selector all
amritmishra-sf Aug 20, 2026
2266307
Merge branch 'dev' into feature/W-23659201-uibundle-engine
amritmishra-sf Aug 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .node-scripts/validate-changed-package-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ function getLatestReleasedVersion(changedPackage) {

function isPackageThatHasNotPublished(changedPackage) {
return [
"packages/ENGINE-TEMPLATE"
"packages/ENGINE-TEMPLATE",
// TODO: remove once @salesforce/code-analyzer-uibundle-engine is published to npm (W-23659201)
"packages/code-analyzer-uibundle-engine"
].includes(changedPackage.replace("\\","/"));
}

Expand Down
1,538 changes: 411 additions & 1,127 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions packages/code-analyzer-core/src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ export class RuleImpl implements Rule {
const sevName: string = SeverityLevel[sevNumber];
const tags: string[] = this.getTags().map(t => t.toLowerCase());
const isDevPreviewApexGuru: boolean = tags.includes('devpreviewapexguru');
const isDevPreviewUIBundle: boolean = tags.includes('uibundle');
let selectables: string[];
if (isDevPreviewApexGuru) {
// DevPreviewApexGuru rules are opt-in: only selectable by engine name, rule name, or explicit tag.
// 'all' and severity are intentionally excluded so broad selectors (e.g. 'all', '4', 'Low') don't pull them in.
if (isDevPreviewApexGuru || isDevPreviewUIBundle) {
// Opt-in rule families (DevPreviewApexGuru, UIBundle) are only selectable by
// engine name, rule name, or explicit tag. 'all' and severity are intentionally
// excluded so broad selectors (e.g. 'all', '4', 'Low') don't pull them in.
selectables = [
this.getEngineName().toLowerCase(),
this.getName().toLowerCase(),
Expand Down
42 changes: 42 additions & 0 deletions packages/code-analyzer-core/test/rule-selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,48 @@ describe('Tests for selecting rules', () => {
});
});

describe('UIBundle rule selection behavior', () => {
beforeEach(async () => {
codeAnalyzer = createCodeAnalyzer();
await codeAnalyzer.addEnginePlugin(new stubs.UIBundleEnginePlugin());
});

it('UIBundle rules are NOT selected by severity number selector', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['4']); // Low
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual([]);
});

it('UIBundle rules are NOT selected by severity name selector', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['Low']);
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual([]);
});

it('UIBundle rules are NOT selected by all', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['all']);
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual([]);
});

it('UIBundle rules ARE selected by engine name', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['uibundleEngine']);
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual(['uibundleRule1', 'uibundleRule2']);
});

it('UIBundle rules ARE selected by rule name', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['uibundleRule1']);
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual(['uibundleRule1']);
});

it('UIBundle rules ARE selected by UIBundle tag', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['UIBundle']);
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual(['uibundleRule1', 'uibundleRule2']);
});

it('UIBundle rules ARE selected by UIBundleIntegrity tag they carry', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules(['UIBundleIntegrity']);
expect(ruleNamesFor(selection, 'uibundleEngine')).toEqual(['uibundleRule1', 'uibundleRule2']);
});
});

it('When attempting to get a rule that does not exist in the selection, then error', async () => {
const selection: RuleSelection = await codeAnalyzer.selectRules([]);

Expand Down
46 changes: 46 additions & 0 deletions packages/code-analyzer-core/test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,52 @@ class DevPreviewEngine extends engApi.Engine {
}
}

/**
* UIBundleEnginePlugin - A plugin to help with testing UIBundle opt-in rule selection behavior
*/
export class UIBundleEnginePlugin extends engApi.EnginePluginV1 {
getAvailableEngineNames(): string[] {
return ["uibundleEngine"];
}

async createEngine(_engineName: string, _config: engApi.ConfigObject): Promise<engApi.Engine> {
return new UIBundleEngine();
}
}

class UIBundleEngine extends engApi.Engine {
getName(): string {
return 'uibundleEngine';
}

getEngineVersion(): Promise<string> {
return Promise.resolve('1.0.0');
}

async describeRules(_describeOptions: engApi.DescribeOptions): Promise<engApi.RuleDescription[]> {
return [
{
name: "uibundleRule1",
severityLevel: engApi.SeverityLevel.Low,
tags: ['UIBundle', 'UIBundleIntegrity'],
description: 'A UIBundle rule with Low severity',
resourceUrls: []
},
{
name: "uibundleRule2",
severityLevel: engApi.SeverityLevel.High,
tags: ['UIBundle', 'UIBundleIntegrity'],
description: 'A UIBundle rule with High severity',
resourceUrls: []
}
];
}

async runRules(_ruleNames: string[], _runOptions: engApi.RunOptions): Promise<engApi.EngineRunResults> {
return { violations: [] };
}
}

/**
* FutureEnginePlugin - A plugin to help with testing forward compatibility
*/
Expand Down
14 changes: 14 additions & 0 deletions packages/code-analyzer-uibundle-engine/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BSD 3-Clause License

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is the license file present for all engines ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes, it seems like other engines have this too


Copyright (c) 2024, Salesforce.com, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 changes: 16 additions & 0 deletions packages/code-analyzer-uibundle-engine/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}]
}
}
);
69 changes: 69 additions & 0 deletions packages/code-analyzer-uibundle-engine/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "@salesforce/code-analyzer-uibundle-engine",
"description": "Plugin package that adds the 'uibundle' engine into Salesforce Code Analyzer. Validates UI Bundle build-output integrity — currently ships sourcemap-based verification of each shipped dist/ artifact against its declared sourcemap and the submitted src/ tree.",
"version": "0.1.0-SNAPSHOT",
"author": "The Salesforce Code Analyzer Team",
"license": "BSD-3-Clause",
"homepage": "https://developer.salesforce.com/docs/platform/salesforce-code-analyzer/overview",
"repository": {
"type": "git",
"url": "git+https://github.com/forcedotcom/code-analyzer-core.git",
"directory": "packages/code-analyzer-uibundle-engine"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"@babel/parser": "^7.25.0",
"@babel/traverse": "^7.25.0",
"@babel/types": "^7.25.0",
"@jridgewell/sourcemap-codec": "^1.5.5",
"@jridgewell/trace-mapping": "^0.3.31",
"@salesforce/code-analyzer-engine-api": "0.42.0-SNAPSHOT",
"@types/node": "^20.0.0"
},
"devDependencies": {
"@eslint/js": "^9.39.5",
"@types/babel__traverse": "^7.28.0",
"@types/jest": "^30.0.0",
"eslint": "^9.39.5",
"jest": "^30.4.2",
"rimraf": "^6.1.3",
"ts-jest": "^29.4.11",
"typescript": "^5.9.3",
"typescript-eslint": "^8.64.0"
},
"engines": {
"node": ">=20.0.0"
},
"files": [
"dist",
"LICENSE",
"package.json"
],
"scripts": {
"build": "tsc --build tsconfig.build.json --verbose",
"test": "tsc --build tsconfig.json && jest --coverage",
"lint": "eslint src/**/*.ts",
"package": "npm pack",
"all": "npm run build && npm run lint && npm run test && npm run package",
"clean": "tsc --build tsconfig.build.json --clean",
"postclean": "rimraf dist && rimraf coverage && rimraf ./*.tgz && rimraf vulnerabilities",
"scrub": "npm run clean && rimraf node_modules",
"showcoverage": "open ./coverage/lcov-report/index.html"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testMatch": [
"**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/"
],
"collectCoverageFrom": [
"src/**/*.ts",
"!src/index.ts"
]
}
}
Loading
Loading