Run UI5 linter on project with optional auto-fix and code quality analysis
Runs UI5 linter on project with optional auto-fix and code quality analysis
/plugin marketplace add secondsky/sap-skills/plugin install sapui5@sap-skills{{#if fix}} Running linter with auto-fix enabled... {{else}} Running linter (analysis only, no fixes applied)... {{/if}}
{{#if severity}} Reporting issues of severity: {{severity}} and above {{/if}}
I'll invoke the ui5-code-quality-advisor agent to analyze your code.
The agent will:
{{file}}{{else}}- All files: controllers, views, models, components{{/if}}run_ui5_linter first (fastest, most accurate)Parameters:
{{#if fix}}- Auto-fix: ENABLED ⚠️ (code will be modified){{else}}- Auto-fix: DISABLED (analysis only){{/if}}
{{#if file}}- Target: {{file}}{{else}}- Target: Entire project{{/if}}
{{#if severity}}- Min Severity: {{severity}}{{else}}- Min Severity: medium (default){{/if}}
Invoking ui5-code-quality-advisor agent...
Agent will analyze your code and provide a detailed quality report.
If the agent cannot be invoked, you can run these manual commands:
# Lint entire project
npx @ui5/mcp-server run_ui5_linter --config=ui5-linter.config.js
# Lint specific file
npx @ui5/mcp-server run_ui5_linter --files={{file}}
# Lint with auto-fix
npx @ui5/mcp-server run_ui5_linter --fix
# Install linter
npm install --save-dev @ui5/linter
# Lint project
ui5 lint
# Lint with details
ui5 lint --details
# Lint specific file
ui5 lint {{file}}
# jQuery.sap.* (deprecated since 1.58)
grep -r "jQuery\.sap\." webapp/
# sap.ui.commons.* (deprecated)
grep -r "sap\.ui\.commons\." webapp/
# Synchronous loading
grep -r "sap\.ui\.requireSync" webapp/
# Direct DOM manipulation (XSS risk)
grep -r "\.innerHTML" webapp/
grep -r "\.html\(" webapp/
# eval() usage (CSP violation)
grep -r "eval\(" webapp/
grep -r "new Function\(" webapp/
# Inline scripts
grep -r "<script>" webapp/view/*.xml
# Non-virtualized lists
grep -r "<m:List.*items=\"{/.*}\"" webapp/view/*.xml
# Missing $select (inefficient queries)
grep -r "path: '/'" webapp/view/*.xml | grep -v "$select"
# Missing ARIA labels
grep -r "<Button" webapp/view/*.xml | grep -v "ariaLabel"
grep -r "<Image" webapp/view/*.xml | grep -v "alt="
For deeper JavaScript/TypeScript linting:
Install ESLint:
npm install --save-dev eslint @sap/eslint-plugin-ui5-jsdocs
.eslintrc.json:
{
"env": {
"browser": true,
"es2022": true
},
"extends": [
"eslint:recommended"
],
"plugins": ["@sap/ui5-jsdocs"],
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"rules": {
"no-console": "warn",
"no-debugger": "error",
"no-eval": "error",
"@sap/ui5-jsdocs/no-jsdoc": "warn"
},
"globals": {
"sap": "readonly",
"jQuery": "readonly"
}
}
Run ESLint:
npx eslint webapp/
The agent will provide a report similar to this:
# Code Quality Report
Files Reviewed: 45
Total Issues: 23
| Severity | Count |
|----------|-------|
| CRITICAL | 2 |
| HIGH | 5 |
| MEDIUM | 12 |
| LOW | 4 |
## CRITICAL Issues
### 1. XSS Vulnerability
File: webapp/controller/Main.controller.js:67
Issue: Direct DOM manipulation bypasses XSS protection
Fix: Use data binding instead of innerHTML
### 2. CSP Violation
File: webapp/view/Main.view.xml:12
Issue: Inline script violates Content Security Policy
Fix: Move script to controller or Component.js
## HIGH Issues
### 3. Deprecated API
File: webapp/controller/ProductList.controller.js:23
Issue: jQuery.sap.require deprecated since UI5 1.58
Fix: Replace with sap.ui.define
... (more issues) ...
## Recommendations
Would you like me to apply automatic fixes for CRITICAL and HIGH issues?
CRITICAL (Must fix before deployment):
HIGH (Fix soon):
MEDIUM (Should fix):
LOW (Nice to have):
After seeing the linter report, you can:
Fix all issues:
/ui5-lint --fix
Fix only specific severity:
/ui5-lint --fix --severity=critical
Fix specific file:
/ui5-lint --fix --file=webapp/controller/Main.controller.js
Review before fixing:
/ui5-lint # See issues first
# Then approve fixes when prompted
Add linting to git pre-commit:
.husky/pre-commit:
#!/bin/sh
npm run lint
package.json:
{
"scripts": {
"lint": "ui5 lint"
}
}
Include in your CI pipeline:
.github/workflows/quality.yml:
- name: Lint UI5 Code
run: ui5 lint --details
Install UI5 extension for real-time linting:
Happy linting! 🔍