Skip to content

Commit 03b9f49

Browse files
committed
fix: Apply prettier formatting to README and validation.ts
1 parent 50722d5 commit 03b9f49

File tree

8 files changed

+1636
-70
lines changed

8 files changed

+1636
-70
lines changed

.github/workflows/js-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ jobs:
168168
echo "- ESLint: ${{ needs.eslint.result }}"
169169
echo "- Prettier: ${{ needs.prettier.result }}"
170170
echo "- TypeScript: ${{ needs.typecheck.result }}"
171-
exit 1
171+
exit 1

packages/client/README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Client library for the WordPress Abilities API, providing a standardized way to
44

55
## Table of Contents
66

7-
- [Installation](#installation)
8-
- [Usage](#usage)
9-
- [API Reference](#api-reference)
10-
- [Development](#development)
11-
- [Testing](#testing)
7+
- [Installation](#installation)
8+
- [Usage](#usage)
9+
- [API Reference](#api-reference)
10+
- [Development](#development)
11+
- [Testing](#testing)
1212

1313
## Installation
1414

@@ -67,13 +67,13 @@ const { listAbilities, getAbility, executeAbility } = wp.abilities;
6767
const abilities = await listAbilities();
6868

6969
// Get a specific ability
70-
const ability = await getAbility( 'my-plugin/my-ability' );
70+
const ability = await getAbility('my-plugin/my-ability');
7171

7272
// Execute an ability
73-
const result = await executeAbility( 'my-plugin/my-ability', {
74-
param1: 'value1',
75-
param2: 'value2'
76-
} );
73+
const result = await executeAbility('my-plugin/my-ability', {
74+
param1: 'value1',
75+
param2: 'value2',
76+
});
7777
```
7878

7979
### Using with React and WordPress Data
@@ -85,28 +85,28 @@ import { useSelect } from '@wordpress/data';
8585
import { store as abilitiesStore } from '@wordpress/abilities';
8686

8787
function MyComponent() {
88-
const abilities = useSelect(
89-
( select ) => select( abilitiesStore ).getAbilities(),
90-
[]
91-
);
92-
93-
const specificAbility = useSelect(
94-
( select ) => select( abilitiesStore ).getAbility( 'my-plugin/my-ability' ),
95-
[]
96-
);
97-
98-
return (
99-
<div>
100-
<h2>All Abilities</h2>
101-
<ul>
102-
{ abilities.map( ( ability ) => (
103-
<li key={ ability.name }>
104-
<strong>{ ability.label }</strong>: { ability.description }
105-
</li>
106-
) ) }
107-
</ul>
108-
</div>
109-
);
88+
const abilities = useSelect(
89+
(select) => select(abilitiesStore).getAbilities(),
90+
[]
91+
);
92+
93+
const specificAbility = useSelect(
94+
(select) => select(abilitiesStore).getAbility('my-plugin/my-ability'),
95+
[]
96+
);
97+
98+
return (
99+
<div>
100+
<h2>All Abilities</h2>
101+
<ul>
102+
{abilities.map((ability) => (
103+
<li key={ability.name}>
104+
<strong>{ability.label}</strong>: {ability.description}
105+
</li>
106+
))}
107+
</ul>
108+
</div>
109+
);
110110
}
111111
```
112112

@@ -120,46 +120,46 @@ Returns all registered abilities. Automatically handles pagination to fetch all
120120

121121
```javascript
122122
const abilities = await listAbilities();
123-
console.log( `Found ${abilities.length} abilities` );
123+
console.log(`Found ${abilities.length} abilities`);
124124
```
125125

126126
#### `getAbility(name: string): Promise<Ability | null>`
127127

128128
Returns a specific ability by name, or null if not found.
129129

130130
```javascript
131-
const ability = await getAbility( 'my-plugin/create-post' );
132-
if ( ability ) {
133-
console.log( `Found ability: ${ability.label}` );
131+
const ability = await getAbility('my-plugin/create-post');
132+
if (ability) {
133+
console.log(`Found ability: ${ability.label}`);
134134
}
135135
```
136136

137137
#### `executeAbility(name: string, input?: Record<string, any>): Promise<any>`
138138

139139
Executes an ability with optional input parameters. The HTTP method is automatically determined based on the ability's type:
140140

141-
- `resource` type abilities use GET (read-only operations)
142-
- `tool` type abilities use POST (write operations)
141+
- `resource` type abilities use GET (read-only operations)
142+
- `tool` type abilities use POST (write operations)
143143

144144
```javascript
145145
// Execute a resource ability (GET)
146-
const data = await executeAbility( 'my-plugin/get-data', {
147-
id: 123
148-
} );
146+
const data = await executeAbility('my-plugin/get-data', {
147+
id: 123,
148+
});
149149

150150
// Execute a tool ability (POST)
151-
const result = await executeAbility( 'my-plugin/create-item', {
152-
title: 'New Item',
153-
content: 'Item content'
154-
} );
151+
const result = await executeAbility('my-plugin/create-item', {
152+
title: 'New Item',
153+
content: 'Item content',
154+
});
155155
```
156156

157157
### Store Selectors
158158

159159
When using with `@wordpress/data`:
160160

161-
- `getAbilities()` - Returns all abilities from the store
162-
- `getAbility(name)` - Returns a specific ability from the store
161+
- `getAbilities()` - Returns all abilities from the store
162+
- `getAbility(name)` - Returns a specific ability from the store
163163

164164
## Development
165165

@@ -201,7 +201,7 @@ npm run test:unit:debug
201201

202202
Tests are organized following WordPress conventions:
203203

204-
- Unit tests are located in `src/__tests__/`
205-
- Store tests are located in `src/store/__tests__/`
206-
- Test files use `.test.ts` or `.test.js` extension
207-
- Tests use Jest with `@wordpress/jest-preset-default` configuration
204+
- Unit tests are located in `src/__tests__/`
205+
- Store tests are located in `src/store/__tests__/`
206+
- Test files use `.test.ts` or `.test.js` extension
207+
- Tests use Jest with `@wordpress/jest-preset-default` configuration

0 commit comments

Comments
 (0)