Skip to content

Commit

Permalink
Merge pull request #262 from 10up/chore/linting
Browse files Browse the repository at this point in the history
chore: fix linting issues
  • Loading branch information
darylldoyle authored Dec 5, 2024
2 parents 89a1f46 + 8471c31 commit e23ba92
Show file tree
Hide file tree
Showing 25 changed files with 1,435 additions and 1,548 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: PHP Checks

on:
push:
branches: [ "trunk" ]
branches: ["trunk"]
pull_request:
branches: [ "trunk" ]
branches: ["trunk"]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
Expand All @@ -20,7 +19,7 @@ jobs:
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
php-version: "8.3"
tools: composer:v2

- name: Validate Root composer.json and composer.lock
Expand Down
16 changes: 4 additions & 12 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"*.css": [
"10up-toolkit lint-style"
],
"*.js": [
"10up-toolkit lint-js"
],
"*.jsx": [
"10up-toolkit lint-js"
],
"*.php": [
"./vendor/bin/phpcs"
]
"*.css": ["10up-toolkit lint-style"],
"*.js": ["10up-toolkit lint-js"],
"*.jsx": ["10up-toolkit lint-js"],
"*.php": ["./vendor/bin/phpcs"]
}
4 changes: 1 addition & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
]
"recommendations": ["dbaeumer.vscode-eslint"]
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It contains a bare bones theme and must use plugin for you to base your developm

## How to Use

*The best way to use the scaffold is to simply run `npx 10up-toolkit project init` in your terminal.*
_The best way to use the scaffold is to simply run `npx 10up-toolkit project init` in your terminal._

You can also use the scaffold manually by doing the following:

Expand All @@ -28,6 +28,7 @@ You can also use the scaffold manually by doing the following:
"mu-plugins/my-other-awesome-10up-plugin",
],
```

6. To build plugins/themes simply run `npm install` at the root and `npm run [build|start|watch]` and npm will automatically build all themes and plugins. If a WordPress critical error is received run `composer install` in all locations that have an existing `composer.lock` file; example locations: `root`, `/mu-plugins/10up-plugin`, `/themes/10up-theme`. Upon build completion set the `10up-theme` as active within WordPress admin by running `wp theme activate 10up-theme`.
7. `npm workspaces` do not have the ability to run scripts from multiple packages in parrallel. Because of that we use the `npm-run-all` package and we define specific scripts in `package.json` so you will need to update the `watch:*` scripts in `package.json` and replace `tenup-theme` and `tenup-plugin` with the actual package names.

Expand All @@ -36,17 +37,19 @@ You can also use the scaffold manually by doing the following:
"watch:plugin": "npm run watch -w=tenup-plugin",
"watch": "run-s watch:theme watch:plugin",
```

7. To add npm dependencies to your theme and/or plugins add the `-w=package-name` flag to the `npm install` command. E.g: `npm install --save prop-types -w=tenup-plugin` **DO NOT RUN** `npm install` inside an individual workspace/package. Always run the from the root folder.
8. If you're building Gutenberg blocks and importing `@wordpress/*` packages, **you do not** need to manually install them as `10up-toolkit` will handle these packages properly.

## Scaffold Rules

Much of the functionality in the scaffold is intended to be optional depending on the needs of your project e.g. i18n functionality. However, there are a few important principles that you must follow:

1. [10up Toolkit](https://github.com/10up/10up-toolkit) must be used for asset bundling. Over the years we've found differences in how assets are built across projects to be very confusing for engineers. As such, we are standardizing on 10up Toolkit (which you can extend as needed). 10up Toolkit contains in depth docs on how it works.
1. [10up Toolkit](https://github.com/10up/10up-toolkit) must be used for asset bundling. Over the years we've found differences in how assets are built across projects to be very confusing for engineers. As such, we are standardizing on 10up Toolkit (which you can extend as needed). 10up Toolkit contains in depth docs on how it works.
2. Functionality should be built into the 10up must-use functionality as much as possible. Presentation should be kept in the theme. Separating these two makes long term development, maintenance, and extensibility much easier.
3. Blocks should be built into the theme and follow the [example block](https://github.com/10up/wp-scaffold/tree/trunk/themes/10up-theme/includes/blocks/example-block) provided.
5. When creating new themes or plugins make sure to follow the `scripts` convention:
4. When creating new themes or plugins make sure to follow the `scripts` convention:

```json
"scripts": {
"start": "npm run watch",
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"require-dev": {
"10up/phpcs-composer": "^3.0",
"wpackagist-plugin/debug-bar": "*",
"wpackagist-plugin/query-monitor":"*",
"wpackagist-plugin/debug-bar-slow-actions":"*",
"wpackagist-plugin/query-monitor": "*",
"wpackagist-plugin/debug-bar-slow-actions": "*",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
"szepeviktor/phpstan-wordpress": "^1.3",
"php-stubs/wp-cli-stubs": "^2.11",
Expand Down
Loading

0 comments on commit e23ba92

Please sign in to comment.