Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwelcher authored Jan 23, 2025
0 parents commit eb2237a
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
node_modules
vendor
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
}
46 changes: 46 additions & 0 deletions .github/workflows/pull-request-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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

strategy:
matrix:
node-version: [14.x, 16.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
vendor
build
.DS_Store
.vscode
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# WordPress Code Examples Starter

This template repository is pre-configured to provide all of the tools to format code to match the WordPress coding standards.


## What does it provide?

1. Linting and formatting tools for PHP, JavaScript, CSS and package.json files.
2. A GitHub action to that runs linting on PRs and merged to trunk.
3. Build process provided by `@wordpress/scripts`

## How do I use it?
1. Start by clicking the `Use this template` to use this as a starting point for your project.
2. Run `npm run setup` to install everything.
3. If using VSCode add the following to your settings.json
```json
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
```

18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ryanwelcher/wordpress-project-template",
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"squizlabs/php_codesniffer": "^3.6",
"wp-coding-standards/wpcs": "^2.3"
},
"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
}
}
}
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "wordpress-project-template",
"version": "0.1.0",
"description": "A starting point for WordPress projects",
"author": "Ryan Welcher",
"license": "GPL-2.0-or-later",
"main": "build/index.js",
"scripts": {
"setup": "npm install --force && composer install",
"build": "wp-scripts build",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"format:js": "wp-scripts format",
"packages-update": "wp-scripts packages-update",
"plugin-zip": "wp-scripts plugin-zip",
"start": "wp-scripts start"
},
"prettier": "@wordpress/prettier-config",
"devDependencies": {
"@wordpress/scripts": "^23.1.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "npm:[email protected]"
}
}
9 changes: 9 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for my twitch streams">
<rule ref="WordPress"/>
<arg name="extensions" value="php"/>
<file>.</file>
<!-- Exclude Vendor directory -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/build/*</exclude-pattern>
</ruleset>
Empty file added src/.gitkeep
Empty file.

0 comments on commit eb2237a

Please sign in to comment.