Skip to content

Commit

Permalink
JS Tools: update the GH action lint to use ESM for chalk v5 (#40944)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftbj authored Jan 10, 2025
1 parent 3374c19 commit c6543c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
- '.github/workflows/*.{yml,yaml}'
- '.github/actions/*/action.{yml,yaml}'
- 'projects/github-actions/*/action.{yml,yaml}'
# If we edit the linting JS files, we need to run it.
- 'tools/js-tools/lint-gh-actions.{js,mjs}'
misc_php:
# If composer, phpcs config, or the codesniffer package itself changed, there may be a new standard.
- 'composer.json'
Expand Down Expand Up @@ -341,7 +343,7 @@ jobs:
run: pnpm run lint-changed --git-base=$SHA $(jq -rn --argjson files "$FILES" '$files[]')

### Lints GitHub Actions yaml files.
# Local equivalent: `./tools/js-tools/lint-gh-actions.js <files>`
# Local equivalent: `./tools/js-tools/lint-gh-actions.mjs <files>`
lint_gh_actions:
name: Lint GitHub Actions yaml files
runs-on: ubuntu-latest
Expand All @@ -358,7 +360,7 @@ jobs:

- run: pnpm install
- name: Run lint
run: ./tools/js-tools/lint-gh-actions.js -v '.github/workflows/*.{yml,yaml}' '.github/actions/*/action.{yml,yaml}' 'projects/github-actions/*/action.{yml,yaml}'
run: ./tools/js-tools/lint-gh-actions.mjs -v '.github/workflows/*.{yml,yaml}' '.github/actions/*/action.{yml,yaml}' 'projects/github-actions/*/action.{yml,yaml}'

### Checks that copied files (e.g. readme, license) are in sync
# Local equivalent: `./tools/check-copied-files.sh`
Expand Down
2 changes: 1 addition & 1 deletion tools/js-tools/git-hooks/pre-commit-hook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function runCheckGitHubActionsYamlFiles() {
return;
}

const result = spawnSync( './tools/js-tools/lint-gh-actions.js', files, {
const result = spawnSync( './tools/js-tools/lint-gh-actions.mjs', files, {
stdio: 'inherit',
} );
if ( result && result.status ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

/* eslint-env node */

const fs = require( 'fs' );
const chalk = require( 'chalk' );
const { glob } = require( 'glob' );
const YAML = require( 'yaml' );
import fs from 'fs';
import chalk from 'chalk';
import { glob } from 'glob';
import YAML from 'yaml';

const isCI = !! process.env.CI;

Expand Down

0 comments on commit c6543c4

Please sign in to comment.