Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:55:38 +08:00
commit 4e7b2cfa56
19 changed files with 6651 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
# GitHub Actions Workflow for UI5 Linter
#
# Place this file in: .github/workflows/ui5-lint.yml
#
# Prerequisites:
# - Package.json must have a 'lint' script that runs ui5lint
# - UI5 Linter must be installed as a dev dependency
# - UI5 Linter CLI supports: --quiet, --format (json/html), --details flags
#
# Documentation: https://github.com/UI5/linter
name: UI5 Lint
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
lint:
name: Lint UI5 Code
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run UI5 Linter
run: npm run lint -- --quiet --format json 2> lint-diagnostics.log | tee lint-results.json
continue-on-error: true
- name: Display Lint Results
if: always()
run: cat lint-results.json
- name: Upload Lint Results
if: always()
uses: actions/upload-artifact@v5
with:
name: lint-results
path: lint-results.json
retention-days: 7
- name: Generate HTML Report
if: always()
run: npm run lint -- --format html --details 2> lint-diagnostics.log | tee lint-report.html
continue-on-error: true
- name: Upload HTML Report
if: always()
uses: actions/upload-artifact@v5
with:
name: lint-report
path: lint-report.html
retention-days: 7
- name: Check Lint Results
run: |
if [ ! -f lint-results.json ]; then
echo "❌ Lint results file not found"
exit 1
fi
if ! jq '[.[].errorCount] | add' lint-results.json > /tmp/error_count 2>/dev/null; then
echo "❌ Failed to parse lint-results.json"
exit 1
fi
ERROR_COUNT=$(cat /tmp/error_count)
ERROR_COUNT=${ERROR_COUNT:-0}
if [ "$ERROR_COUNT" -gt 0 ]; then
echo "❌ Found $ERROR_COUNT linting errors"
exit 1
else
echo "✅ No linting errors found"
fi

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env sh
# Pre-commit hook using Husky and lint-staged
#
# Setup Instructions:
# 1. Install Husky and lint-staged:
# npm install --save-dev husky lint-staged
#
# 2. Initialize Husky:
# npx husky install
#
# 3. Add this pre-commit hook:
# npx husky add .husky/pre-commit "npx lint-staged"
#
# 4. Add lint-staged configuration to package.json:
# {
# "lint-staged": {
# "webapp/**/*.{js,xml,json}": [
# "ui5lint"
# ]
# }
# }
#
# Documentation: https://github.com/UI5/linter
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

View File

@@ -0,0 +1,19 @@
{
"name": "your-ui5-app",
"version": "1.0.0",
"description": "Your UI5 Application",
"scripts": {
"lint": "ui5lint",
"lint:fix": "ui5lint --fix",
"lint:details": "ui5lint --details",
"lint:ci": "ui5lint --quiet --format json > lint-results.json",
"lint:report": "ui5lint --format html --details > lint-report.html"
},
"devDependencies": {
"@ui5/linter": "^1.20.5"
},
"engines": {
"node": ">=20.11.0 || >=22.0.0",
"npm": ">=8.0.0"
}
}

View File

@@ -0,0 +1,58 @@
/**
* UI5 Linter Configuration (CommonJS)
*
* Use this configuration file for traditional Node.js projects.
* Place this file in your project root (same directory as ui5.yaml and package.json).
*
* Documentation: https://github.com/UI5/linter/blob/main/README.md
*/
module.exports = {
/**
* Ignore Patterns
*
* Array of glob patterns to exclude files from linting.
* Patterns are relative to project root.
* Use '!' prefix for negation (include files despite earlier ignore).
* Pattern order matters - later patterns override earlier ones.
*/
ignores: [
// Third-party libraries (no control over code quality)
"webapp/thirdparty/**",
"webapp/vendor/**",
// Mock data and local services (often auto-generated)
"webapp/localService/**",
// Test files (optional - remove if you want to lint tests)
"webapp/test/**",
// Include integration tests (negation example)
"!webapp/test/integration/**",
// Build output directories
"dist/**",
"build/**",
// Minified files (already optimized, no need to lint)
"**/*.min.js",
"**/*.bundle.js",
// UI Adaptation changes (generated by Fiori)
"webapp/changes/**",
],
/**
* File Patterns (Optional)
*
* Array of glob patterns specifying which files to lint.
* If omitted, all files in the project are linted (except ignores).
*
* Uncomment and customize if you want to lint specific files only:
*/
// files: [
// "webapp/**/*.js",
// "webapp/**/*.xml",
// "webapp/manifest.json",
// ],
};

View File

@@ -0,0 +1,58 @@
/**
* UI5 Linter Configuration (ES Module)
*
* Use this configuration file for modern JavaScript projects with "type": "module" in package.json.
* Place this file in your project root (same directory as ui5.yaml and package.json).
*
* Documentation: https://github.com/UI5/linter/blob/main/README.md
*/
export default {
/**
* Ignore Patterns
*
* Array of glob patterns to exclude files from linting.
* Patterns are relative to project root.
* Use '!' prefix for negation (include files despite earlier ignore).
* Pattern order matters - later patterns override earlier ones.
*/
ignores: [
// Third-party libraries (no control over code quality)
"webapp/thirdparty/**",
"webapp/vendor/**",
// Mock data and local services (often auto-generated)
"webapp/localService/**",
// Test files (optional - remove if you want to lint tests)
"webapp/test/**",
// Include integration tests (negation example)
"!webapp/test/integration/**",
// Build output directories
"dist/**",
"build/**",
// Minified files (already optimized, no need to lint)
"**/*.min.js",
"**/*.bundle.js",
// UI Adaptation changes (generated by Fiori)
"webapp/changes/**",
],
/**
* File Patterns (Optional)
*
* Array of glob patterns specifying which files to lint.
* If omitted, all files in the project are linted (except ignores).
*
* Uncomment and customize if you want to lint specific files only:
*/
// files: [
// "webapp/**/*.js",
// "webapp/**/*.xml",
// "webapp/manifest.json",
// ],
};