diff --git a/.eslintignore b/.eslintignore index 5f7b681..176e9b3 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,16 +1,13 @@ -**/lwc/**/*.css -**/lwc/**/*.html -**/lwc/**/*.json -**/lwc/**/*.svg -**/lwc/**/*.xml -**/aura/**/*.auradoc -**/aura/**/*.cmp -**/aura/**/*.css -**/aura/**/*.design -**/aura/**/*.evt -**/aura/**/*.json -**/aura/**/*.svg -**/aura/**/*.tokens -**/aura/**/*.xml -**/aura/**/*.app +*.xml +*.cls +*.html +*.auradoc +*.cmp +*.css +*.design +*.evt +*.json +*.svg +*.tokens +*.app .sfdx diff --git a/.github/workflows/code-analyze.yml b/.github/workflows/code-analyze.yml index 6e28961..3457574 100644 --- a/.github/workflows/code-analyze.yml +++ b/.github/workflows/code-analyze.yml @@ -8,15 +8,22 @@ jobs: PMD: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - - name: Setup Salesforce CLI - run: | - yarn global add @salesforce/cli - sf plugins:install @salesforce/sfdx-scanner - - name: SF Code Analyzer - PMD - run: | - sf scanner:run --engine pmd --target force-app --pmdconfig=config/pmd/ruleset.xml --format table --severity-threshold 3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + - name: Setup Salesforce CLI + run: | + yarn global add @salesforce/cli + sf plugins:install @salesforce/sfdx-scanner + - name: SF Code Analyzer - PMD - Report findings as comments + uses: mitchspano/sfdx-scan-pull-request@v0.1.16 + with: + report-mode: comments + engine: pmd + pmdconfig: config/pmd/ruleset.xml + severity-threshold: 4 + strictly-enforced-rules: '[{ "engine": "pmd", "category": "Performance", "rule": "AvoidDebugStatements" }]' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RetireJS: runs-on: ubuntu-latest @@ -27,11 +34,16 @@ jobs: run: | yarn global add @salesforce/cli sf plugins:install @salesforce/sfdx-scanner - - name: SF Code Analyzer - RetireJS - run: | - sf scanner:run --engine "retire-js" --target force-app --format table --severity-threshold 3 + - name: SF Code Analyzer - RetireJS - Report findings as comments + uses: mitchspano/sfdx-scan-pull-request@v0.1.16 + with: + report-mode: comments + engine: retire-js + severity-threshold: 4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GraphEngine: + ESLint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -40,11 +52,20 @@ jobs: run: | yarn global add @salesforce/cli sf plugins:install @salesforce/sfdx-scanner - - name: SF Code Analyzer - Data Flow Analysis + - name: Install deps run: | - sf scanner:run:dfa --target force-app --projectdir force-app --format table --severity-threshold 3 + yarn install + - name: SF Code Analyzer - ESLint - Report findings as comments + uses: mitchspano/sfdx-scan-pull-request@v0.1.16 + with: + report-mode: comments + engine: eslint + eslintconfig: .eslintrc.json + severity-threshold: 4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ESLint: + GraphEngine: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -53,9 +74,6 @@ jobs: run: | yarn global add @salesforce/cli sf plugins:install @salesforce/sfdx-scanner - - name: Install deps - run: | - yarn install - - name: SF Code Analyzer - ESLint + - name: SF Code Analyzer - Data Flow Analysis run: | - sf scanner:run --engine eslint --eslintconfig=.eslintrc.json --target "force-app/**/*.js" --format table --severity-threshold 3 + sf scanner:run:dfa --target force-app --projectdir force-app --format table --severity-threshold 3 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18d47b5..253259e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,8 @@ on: push: branches: - main + paths: + - force-app/** jobs: code-analyze: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b558852..5cd11b8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -2,6 +2,10 @@ name: Pull Request on: pull_request: + branches: + - main + paths: + - force-app/** jobs: code-analyze: diff --git a/force-app/main/default/lwc/helloWorld/__tests__/helloWorld.test.js b/force-app/main/default/lwc/helloWorld/__tests__/helloWorld.test.js index 2c57186..d0fe000 100644 --- a/force-app/main/default/lwc/helloWorld/__tests__/helloWorld.test.js +++ b/force-app/main/default/lwc/helloWorld/__tests__/helloWorld.test.js @@ -22,4 +22,4 @@ describe('c-hello-world', () => { // const div = element.shadowRoot.querySelector('div'); expect(1).toBe(1); }); -}); +}); \ No newline at end of file diff --git a/force-app/main/default/lwc/helloWorld/helloWorld.html b/force-app/main/default/lwc/helloWorld/helloWorld.html index fdeba7b..9c838cb 100644 --- a/force-app/main/default/lwc/helloWorld/helloWorld.html +++ b/force-app/main/default/lwc/helloWorld/helloWorld.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/force-app/main/default/lwc/helloWorld/helloWorld.js b/force-app/main/default/lwc/helloWorld/helloWorld.js index 3327682..b2a15b4 100644 --- a/force-app/main/default/lwc/helloWorld/helloWorld.js +++ b/force-app/main/default/lwc/helloWorld/helloWorld.js @@ -1,3 +1,3 @@ import { LightningElement } from 'lwc'; -export default class HelloWorld extends LightningElement {} +export default class HelloWorld extends LightningElement {} \ No newline at end of file diff --git a/force-app/main/default/lwc/helloWorld/helloWorld.js-meta.xml b/force-app/main/default/lwc/helloWorld/helloWorld.js-meta.xml index b315c99..cc0d4bf 100644 --- a/force-app/main/default/lwc/helloWorld/helloWorld.js-meta.xml +++ b/force-app/main/default/lwc/helloWorld/helloWorld.js-meta.xml @@ -1,5 +1,5 @@ - + 58.0 false - + \ No newline at end of file