Skip to content

Commit fd684ce

Browse files
authored
Merge pull request #642 from lightspeedwp/copilot/fix-598e3708-d3f3-4ddc-8547-246ea591224c
Update .editorconfig and linting setup to WordPress standards with tabs for PHP
2 parents 1cd14f8 + e403e6d commit fd684ce

365 files changed

Lines changed: 53 additions & 92822 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,32 @@
33

44
# WordPress Coding Standards
55
# https://make.wordpress.org/core/handbook/coding-standards/
6-
7-
# Tour Operator Plugin - EditorConfig
8-
# Extends standardized configuration from .github/linting/.editorconfig
6+
# Based on WordPress Core .editorconfig: https://core.trac.wordpress.org/browser/trunk/.editorconfig
97

108
root = true
119

12-
# All files (WordPress defaults)
10+
# All files (WordPress defaults: tabs, LF line endings)
1311
[*]
1412
charset = utf-8
1513
end_of_line = lf
1614
insert_final_newline = true
1715
trim_trailing_whitespace = true
18-
19-
# PHP files (WordPress standard: tabs)
20-
[*.php]
2116
indent_style = tab
22-
indent_size = 4
2317

2418
# JavaScript/TypeScript files (WordPress wp-scripts standard: spaces)
25-
[*.{js,ts,jsx,tsx}]
26-
indent_style = space
27-
indent_size = 2
28-
29-
# CSS/SCSS files (WordPress standard: spaces)
30-
[*.{css,scss,sass,less}]
31-
indent_style = space
32-
indent_size = 2
33-
34-
# JSON files
35-
[*.json]
19+
[*.{js,jsx,ts,tsx,json}]
3620
indent_style = space
3721
indent_size = 2
3822

39-
# YAML files
23+
# YAML files (standard: 2 spaces)
4024
[*.{yml,yaml}]
4125
indent_style = space
4226
indent_size = 2
4327

4428
# Markdown files (preserve trailing whitespace for line breaks)
4529
[*.md]
4630
trim_trailing_whitespace = false
47-
indent_style = space
48-
indent_size = 2
4931

50-
# Config files
51-
[{.eslintrc,.prettierrc,.stylelintrc}]
52-
indent_style = space
53-
indent_size = 2
32+
# Special WordPress files (CRLF line endings as per Core)
33+
[{*.txt,wp-config-sample.php}]
34+
end_of_line = crlf

.gitattributes

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Set the default behavior, in case people don't have core.autocrlf set.
2-
* text=auto
2+
* text=auto eol=lf
33

44
# Declare files that will always have LF line endings on checkout.
55
*.css text eol=lf
66
*.js text eol=lf
77
*.json text eol=lf
88
*.php text eol=lf
99
*.md text eol=lf
10-
*.txt text eol=lf
1110
*.xml text eol=lf
1211
*.yml text eol=lf
1312
*.yaml text eol=lf
1413

14+
# Exception: Some WordPress files should use CRLF (as per .editorconfig)
15+
*.txt text eol=crlf
16+
wp-config-sample.php text eol=crlf
17+
1518
# Build files
1619
*.min.css text eol=lf
1720
*.min.js text eol=lf

.github/linting/.editorconfig

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,35 @@
11
# EditorConfig for Tour Operator Plugin
22
# https://editorconfig.org
33

4+
# WordPress Coding Standards
5+
# https://make.wordpress.org/core/handbook/coding-standards/
6+
# Based on WordPress Core .editorconfig: https://core.trac.wordpress.org/browser/trunk/.editorconfig
7+
48
# Top-most EditorConfig file
59
root = true
610

7-
# All files
11+
# All files (WordPress defaults: tabs, LF line endings)
812
[*]
913
charset = utf-8
1014
end_of_line = lf
1115
insert_final_newline = true
1216
trim_trailing_whitespace = true
13-
14-
# PHP files
15-
[*.php]
1617
indent_style = tab
17-
indent_size = 4
18-
19-
# JavaScript files
20-
[*.{js,ts,jsx,tsx}]
21-
indent_style = space
22-
indent_size = 2
23-
24-
# CSS/SCSS files
25-
[*.{css,scss,sass,less}]
26-
indent_style = space
27-
indent_size = 2
2818

29-
# JSON files
30-
[*.json]
19+
# JavaScript/TypeScript files (WordPress wp-scripts standard: spaces)
20+
[*.{js,jsx,ts,tsx,json}]
3121
indent_style = space
3222
indent_size = 2
3323

34-
# YAML files
24+
# YAML files (standard: 2 spaces)
3525
[*.{yml,yaml}]
3626
indent_style = space
3727
indent_size = 2
3828

39-
# Markdown files
29+
# Markdown files (preserve trailing whitespace for line breaks)
4030
[*.md]
4131
trim_trailing_whitespace = false
42-
indent_style = space
43-
indent_size = 2
4432

45-
# Package files
46-
[{package.json,composer.json}]
47-
indent_style = space
48-
indent_size = 2
33+
# Special WordPress files (CRLF line endings as per Core)
34+
[{*.txt,wp-config-sample.php}]
35+
end_of_line = crlf

.github/workflows/phpcs.yml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHPCS Check with Annotations
1+
name: WPCS Check
22

33
on:
44
pull_request:
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
phpcs:
12-
name: Run PHPCS
12+
name: Run WPCS
1313
runs-on: ubuntu-latest
1414
permissions:
1515
contents: read
@@ -40,20 +40,9 @@ jobs:
4040
run: |
4141
if [ -f package.json ]; then npm ci --ignore-scripts; fi
4242
43-
- name: Run PHPCS with 10up action
44-
uses: 10up/wpcs-action@v2
43+
- name: WPCS check
44+
uses: 10up/wpcs-action@stable
4545
with:
46+
use_local_config: 'true'
4647
enable_warnings: true
47-
phpcs_bin_path: vendor/bin/phpcs
48-
standard: 10up-Default
49-
paths: |
50-
.
51-
extra_args: -d memory_limit=512M --report=checkstyle
52-
53-
- name: Upload PHPCS report artifact (optional)
54-
if: always()
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: phpcs-report
58-
path: phpcs-report.xml
59-
if-no-files-found: ignore
48+
only_changed_files: true

.phpcs.xml.dist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0"?>
2-
<ruleset name="Tour Operator 10up Default">
3-
<description>Base PHPCS configuration for IDE integration using 10up-Default ruleset. Extended project-specific config lives in phpcs.xml.dist.</description>
2+
<ruleset name="Tour Operator">
3+
<description>Minimal PHPCS configuration for IDE integration using 10up-Default ruleset. Extended project-specific config lives in phpcs.xml.dist.</description>
44
<rule ref="10up-Default" />
55
<arg name="extensions" value="php"/>
6-
<exclude-pattern>*/vendor/*</exclude-pattern>
7-
<exclude-pattern>*/node_modules/*</exclude-pattern>
8-
<exclude-pattern>*/build/*</exclude-pattern>
6+
<exclude-pattern>vendor/*</exclude-pattern>
7+
<exclude-pattern>node_modules/*</exclude-pattern>
8+
<exclude-pattern>build/*</exclude-pattern>
99
</ruleset>

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ Override the PHP compatibility test version (example: PHP 7.2+):
6969

7070
### Continuous Integration
7171

72-
PHPCS runs automatically on pushes to `2.1-trunk` and all pull requests via the GitHub Action workflow at `.github/workflows/phpcs.yml` using the version specified in that workflow file (currently `10up/wpcs-action@v2.0.0`—please keep this in sync with the workflow).
72+
WPCS runs automatically on pushes to `2.1-trunk` and all pull requests via the GitHub Action workflow at `.github/workflows/phpcs.yml` using `10up/wpcs-action@stable` with local configuration.
7373

7474
The workflow:
7575

7676
1. Installs Composer + Node dependencies.
77-
2. Runs PHPCS with annotations on the PR (errors & warnings surfaced inline).
78-
3. Uploads a report artifact when available.
77+
2. Runs WPCS with local config (`phpcs.xml.dist`) and annotations on the PR.
78+
3. Checks only changed files for efficiency and enables warnings.
79+
4. Uses the 10up-Default ruleset with project-specific customizations.
7980

8081
### Project Management Automation
8182

@@ -133,6 +134,20 @@ Use the WordPress action directly in a workflow step:
133134
134135
You can scope events (`pull_request`, `issues`) and extend with additional job steps (e.g. changelog validation, label enforcement).
135136

137+
### EditorConfig & Code Style
138+
139+
This plugin follows WordPress Coding Standards with consistent indentation enforced via `.editorconfig`:
140+
141+
- **PHP files**: Tabs (WordPress standard)
142+
- **JavaScript/TypeScript**: 2 spaces
143+
- **CSS/SCSS**: 2 spaces
144+
- **JSON/YAML**: 2 spaces
145+
- **Markdown**: 2 spaces (preserves trailing whitespace)
146+
147+
Configuration references:
148+
- [WordPress PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/)
149+
- [WordPress Core .editorconfig](https://core.trac.wordpress.org/browser/trunk/.editorconfig)
150+
136151
### IDE Integration
137152

138153
If your IDE does not detect the `10up-Default` ruleset, it will fall back to `.phpcs.xml.dist`. Make sure your PHPCS extension/binary points to `vendor/bin/phpcs`.

vendor/cmb-field-select2/.gitignore

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)