Skip to content

Commit

Permalink
Merge pull request #60 from WordPress/feature/add-linting
Browse files Browse the repository at this point in the history
Add linting tools
  • Loading branch information
ryanwelcher authored Nov 13, 2023
2 parents 647c85d + 0271db7 commit 73c9e3f
Show file tree
Hide file tree
Showing 7 changed files with 589 additions and 9 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/pull-request-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Static Linting

on:
pull_request:
push:
branches:
- trunk

jobs:
php:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install dependencies
uses: php-actions/composer@v6
- name: Lint PHP files
run: composer run lint

name: PHP Files

other:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: 8

- name: Install dependencies
run: pnpm i
- name: Lint JavaScript files
run: npm run lint:js
- name: Lint CSS files
run: npm run lint:css
- name: Lint package.json files
run: npm run lint:pkg-json
env:
CI: true

name: Javascript, CSS, and package.json
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "wordpress/block-development-examples",
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"squizlabs/php_codesniffer": "^3.6",
"wp-coding-standards/wpcs": "^3.0"
},
"scripts": {
"lint": "./vendor/bin/phpcs --standard=phpcs.xml"
},
"config": {
"allow-plugins": {
"squizlabs/php_codesniffer": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"wp-coding-standards/wpcs": true
}
}
}
Loading

0 comments on commit 73c9e3f

Please sign in to comment.