Last active
August 26, 2020 22:39
-
-
Save sjurgis/16cb5e1e1dc4d68ad3cf2151d848c7a3 to your computer and use it in GitHub Desktop.
ESLint Github action for lwc, aura and other JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: aura && lwc lint | |
on: | |
push: | |
paths: | |
- 'myns/main/services/aura/**' | |
- 'myns/main/polyfills/aura/**' | |
- 'myns/main/default/aura/**' | |
- 'myns/main/default/staticresources/JS_Callbacks/**' | |
- 'myns/main/default/lwc/**' | |
- 'ui-tests/selenium/js/**' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- uses: actions/setup-node@v1 | |
- name: Cache node modules | |
id: cache | |
uses: actions/cache@v1 | |
with: | |
path: node_modules # npm cache files are stored in `~/.npm` on Linux/macOS | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: ESlint aura and lwc | |
run: npm run lint | |
BEGIN package.json FILE | |
{ | |
"scripts": { | |
"lint": "eslint --quiet myns/main/default/lwc myns/main/services/aura myns/main/polyfills/aura myns/main/default/aura myns/main/default/staticresources/JS_Callbacks ui-tests/selenium/js/" | |
}, | |
"devDependencies": { | |
"@lwc/eslint-plugin-lwc": "^0.9.0", | |
"@salesforce/sfdx-lwc-jest": "^0.5.4", | |
"babel-eslint": "^10.0.3", | |
"eslint": "^6.8.0", | |
} | |
} | |
BEGIN .eslintrc.js FILE placed in myns/main/default/lwc | |
{ | |
"parser": "babel-eslint", | |
"plugins": ["@lwc/eslint-plugin-lwc"], | |
"rules": { | |
"@lwc/lwc/no-deprecated": "error", | |
"@lwc/lwc/valid-api": "error", | |
"@lwc/lwc/valid-track": "error", | |
"@lwc/lwc/valid-wire": "error", | |
"@lwc/lwc/no-document-query": "error", | |
"@lwc/lwc/consistent-component-name": "error", | |
"@lwc/lwc/no-leading-uppercase-api-name": "error", | |
"@lwc/lwc/no-dupe-class-members": "error", | |
"@lwc/lwc/no-inner-html": "error", | |
"semi": 0, | |
"no-multiple-empty-lines": 0, | |
"comma-dangle": 0 | |
}, | |
"extends": "../../../../.eslintrc.js" | |
} | |
BEGIN .git/hooks/pre-commit FILE (aka pre-commit hook) | |
#!/bin/bash | |
exec 1>&2 | |
npm run lint | |
WARNING: YOU NEED A .eslintrc.js file in main directory that uses es5 for aura and rest of the files specified in the paths above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment