Skip to content

Commit caaf707

Browse files
committed
chore: add playground
1 parent 58e504c commit caaf707

5 files changed

Lines changed: 46 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ coverage
1212
dist
1313
dist-ssr
1414
*.local
15+
playground/*
16+
!playground/.gitkeep
1517

1618
# Editor directories and files
1719
.vscode/*

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ export default defineConfig([
5050
| `php/eqeqeq` | Require the use of `===` and `!==` | | |
5151
| `php/no-array-keyword` | Disallow the use of the array keyword | 🔧 | |
5252
| `php/require-visibility` | Require visibility for class methods and properties | | 💡 |
53+
54+
## Development
55+
56+
Use `npm run playground` to lint local PHP files under the `playground` directory.

eslint.config.playground.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* eslint-disable no-console */
2+
import fs from 'fs';
3+
import { defineConfig } from 'eslint/config';
4+
5+
if (!fs.existsSync('./dist/index.js')) {
6+
console.error('Please run `npm run build` before using the playground.');
7+
8+
process.exit(1);
9+
}
10+
11+
const phpFiles = fs
12+
.readdirSync('./playground')
13+
.filter((file) => file.endsWith('.php'));
14+
15+
if (phpFiles.length === 0) {
16+
console.error(
17+
'Please add PHP files to `/playground` before using the playground.',
18+
);
19+
20+
process.exit(1);
21+
}
22+
23+
const php = (await import('./dist/index.js')).default;
24+
25+
export default defineConfig({
26+
files: ['./**/*.php'],
27+
plugins: {
28+
php,
29+
},
30+
language: 'php/php',
31+
rules: {
32+
// TODO: Use recommended config.
33+
'php/eqeqeq': 'error',
34+
'php/disallow-references': 'error',
35+
'php/no-array-keyword': 'error',
36+
'php/require-visibility': 'error',
37+
},
38+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"format": "prettier --write ./",
4141
"format:check": "prettier --check ./",
4242
"build": "tsup",
43-
"release": "npm run build && changeset publish"
43+
"release": "npm run build && changeset publish",
44+
"playground": "eslint ./playground --config=eslint.config.playground.mjs"
4445
},
4546
"devDependencies": {
4647
"@changesets/cli": "^2.27.7",

playground/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)