Skip to content

Latest commit

 

History

History
75 lines (60 loc) · 3.46 KB

wp-scripts.md

File metadata and controls

75 lines (60 loc) · 3.46 KB

Reusable workflows – @wordpress/scripts

Lint

This workflow runs ESLint, Stylelint, and markdownlint wrapped in the @wordpress/scripts library. It does so by executing the wp-scripts binary in the ./node_modules/.bin/ folder.

Simplest possible example:

name: Static code analysis assets
on:
  push:
jobs:
  wp-scripts-lint:
    uses: inpsyde/reusable-workflows/.github/workflows/wp-scripts-lint.yml@main

Configuration parameters

Inputs

Name Default Description
NODE_OPTIONS '' Space-separated list of command-line Node options
NODE_VERSION 18 Node version with which the assets will be compiled
NPM_REGISTRY_DOMAIN 'https://npm.pkg.github.com/' Domain of the private npm registry
LINT_TOOLS '["js", "style", "md-docs"]' Array of checks to be executed by @wordpress/scripts
ESLINT_ARGS '' Set of arguments passed to wp-script lint-js
STYLELINT_ARGS '' Set of arguments passed to wp-script lint-style
MARKDOWNLINT_ARGS '' Set of arguments passed to wp-script lint-md-docs
PACKAGE_JSONLINT_ARGS '' Set of arguments passed to wp-scripts lint-pkg-json

ℹ️ By default, "pkg-json" is not part of the LINT_TOOLS input.
ℹ️ The --formatter github flag is hardcoded into the wp-script lint-style command; it must not be passed via STYLELINT_ARGS.

Secrets

Name Description
NPM_REGISTRY_TOKEN Authentication for the private npm registry
GITHUB_USER_EMAIL Email address for the GitHub user configuration
GITHUB_USER_NAME Username for the GitHub user configuration
GITHUB_USER_SSH_KEY Private SSH key associated with the GitHub user passed as GITHUB_USER_NAME
ENV_VARS Additional environment variables as a JSON formatted object

Example with configuration parameters:

name: Static code analysis assets
on:
  pull_request:
jobs:
  wp-scripts-lint-js:
    uses: inpsyde/reusable-workflows/.github/workflows/wp-scripts-lint-js.yml@main
    secrets:
      NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
      ENV_VARS: >-
        [{"name":"EXAMPLE_USERNAME", "value":"${{ secrets.USERNAME }}"}]
    with:
      NODE_VERSION: 18
      ESLINT_ARGS: '-o eslint_report.json -f json'
      STYLELINT_ARGS: '"./resources/**/*.scss"'

Note:

Stylelint requires quotes around file glob patterns.