Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 70 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,76 @@ env:
TARGET_DRUPAL_CORE_VERSION: 11

jobs:
changes:
runs-on: ubicloud-standard-4
permissions:
pull-requests: read
outputs:
js: ${{ steps.filter.outputs.js }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
js:
- '**/*.js'

eslint:
needs: changes
if: needs.changes.outputs.js == 'true'
runs-on: ubicloud-standard-4
timeout-minutes: 10
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Run ESLint
id: lint
run: |
set +e
npx eslint . 2>&1 | tee eslint-output.txt
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"

- name: Generate summary
if: always()
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const output = fs.readFileSync('eslint-output.txt', 'utf8');
const errorMatch = output.match(/(\d+)\s+error/);
const warningMatch = output.match(/(\d+)\s+warning/);
const errors = errorMatch ? errorMatch[1] : '0';
const warnings = warningMatch ? warningMatch[1] : '0';
const problems = Number(errors) + Number(warnings);
const summary = [
'## ESLint Results',
'',
'| Metric | Count |',
'|----------|-------|',
`| Problems | ${problems} |`,
`| Errors | ${errors} |`,
`| Warnings | ${warnings} |`,
].join('\n');
core.summary.addRaw(summary).write();

- name: Fail if lint errors
if: always()
run: |
exit_code="${{ steps.lint.outputs.exit_code }}"
if [ "$exit_code" != "0" ]; then
echo "ESLint found errors."
exit 1
fi

drupal-lint:
runs-on: ubicloud-standard-4
timeout-minutes: 60
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@
/drush
/drupal.phar
/drupal

# Node.js
node_modules/
54 changes: 54 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import antfu from '@antfu/eslint-config';

export default antfu(
{
type: 'lib',
javascript: {
overrides: {
'no-console': ['error', { allow: ['warn', 'error'] }],
},
},
typescript: false,
vue: false,
react: false,
jsonc: false,
yaml: false,
toml: false,
markdown: false,
stylistic: {
semi: true,
quotes: 'single',
},
},
{
files: ['js/**/*.js'],
languageOptions: {
globals: {
Drupal: 'readonly',
drupalSettings: 'readonly',
once: 'readonly',
jQuery: 'readonly',
navigator: 'readonly',
window: 'readonly',
document: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
fetch: 'readonly',
Promise: 'readonly',
Array: 'readonly',
IntersectionObserver: 'readonly',
console: 'readonly',
JSON: 'readonly',
Object: 'readonly',
},
},
rules: {
'no-prototype-builtins': 'off',
},
},
{
ignores: [
'node_modules/**',
],
},
);
Loading
Loading