pickier 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +232 -148
- package/dist/bin/cli.js +29896 -23356
- package/dist/rules/style/array-bracket-spacing.d.ts +2 -0
- package/dist/rules/style/arrow-parens.d.ts +2 -0
- package/dist/rules/style/arrow-spacing.d.ts +2 -0
- package/dist/rules/style/block-spacing.d.ts +2 -0
- package/dist/rules/style/comma-dangle.d.ts +2 -0
- package/dist/rules/style/comma-spacing.d.ts +2 -0
- package/dist/rules/style/comma-style.d.ts +2 -0
- package/dist/rules/style/computed-property-spacing.d.ts +2 -0
- package/dist/rules/style/dot-location.d.ts +2 -0
- package/dist/rules/style/function-call-spacing.d.ts +2 -0
- package/dist/rules/style/generator-star-spacing.d.ts +2 -0
- package/dist/rules/style/indent-binary-ops.d.ts +2 -0
- package/dist/rules/style/key-spacing.d.ts +2 -0
- package/dist/rules/style/keyword-spacing.d.ts +2 -0
- package/dist/rules/style/lines-between-class-members.d.ts +2 -0
- package/dist/rules/style/multiline-ternary.d.ts +2 -0
- package/dist/rules/style/new-parens.d.ts +2 -0
- package/dist/rules/style/no-extra-parens.d.ts +2 -0
- package/dist/rules/style/no-floating-decimal.d.ts +2 -0
- package/dist/rules/style/no-mixed-operators.d.ts +2 -0
- package/dist/rules/style/no-mixed-spaces-and-tabs.d.ts +2 -0
- package/dist/rules/style/no-tabs.d.ts +2 -0
- package/dist/rules/style/no-whitespace-before-property.d.ts +2 -0
- package/dist/rules/style/object-curly-spacing.d.ts +2 -0
- package/dist/rules/style/operator-linebreak.d.ts +2 -0
- package/dist/rules/style/padded-blocks.d.ts +2 -0
- package/dist/rules/style/quote-props.d.ts +2 -0
- package/dist/rules/style/rest-spread-spacing.d.ts +2 -0
- package/dist/rules/style/semi-spacing.d.ts +2 -0
- package/dist/rules/style/space-before-blocks.d.ts +2 -0
- package/dist/rules/style/space-before-function-paren.d.ts +2 -0
- package/dist/rules/style/space-in-parens.d.ts +2 -0
- package/dist/rules/style/space-infix-ops.d.ts +2 -0
- package/dist/rules/style/space-unary-ops.d.ts +2 -0
- package/dist/rules/style/spaced-comment.d.ts +2 -0
- package/dist/rules/style/switch-colon-spacing.d.ts +2 -0
- package/dist/rules/style/template-curly-spacing.d.ts +2 -0
- package/dist/rules/style/template-tag-spacing.d.ts +2 -0
- package/dist/rules/style/wrap-iife.d.ts +2 -0
- package/dist/rules/style/yield-star-spacing.d.ts +2 -0
- package/dist/rules/ts/member-delimiter-style.d.ts +4 -0
- package/dist/rules/ts/type-annotation-spacing.d.ts +2 -0
- package/dist/rules/ts/type-generic-spacing.d.ts +2 -0
- package/dist/rules/ts/type-named-tuple-spacing.d.ts +2 -0
- package/dist/src/index.js +20049 -15560
- package/dist/types.d.ts +1 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[![npm version][npm-version-src]][npm-version-href]
|
|
4
4
|
[![GitHub Actions][github-actions-src]][github-actions-href]
|
|
5
|
-
[](http://commitizen.github.io/cz-cli/)
|
|
6
5
|
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
|
|
7
6
|
<!-- [![Codecov][codecov-src]][codecov-href] -->
|
|
8
7
|
|
|
@@ -13,80 +12,106 @@
|
|
|
13
12
|
## Features
|
|
14
13
|
|
|
15
14
|
- Fast CLI with instant feedback
|
|
16
|
-
- Lint and format in one tool
|
|
17
|
-
- Zero-config defaults; simple, typed `pickier.config.ts`when you need it
|
|
15
|
+
- Lint and format in one tool via `pickier run`
|
|
16
|
+
- Zero-config defaults; simple, typed `pickier.config.ts` when you need it
|
|
18
17
|
- Import organization: splits type/value imports, sorts modules/specifiers, removes unused named imports
|
|
19
|
-
- JSON and config sorting for common
|
|
20
|
-
-
|
|
21
|
-
-
|
|
18
|
+
- JSON and config sorting for common files _(e.g. `package.json`, `tsconfig.json`)_
|
|
19
|
+
- **Markdown linting with 53+ rules** for documentation quality _(headings, lists, links, code blocks, tables, etc.)_
|
|
20
|
+
- 27 rules support auto-fix for common formatting issues
|
|
21
|
+
- Flexible formatting: `indent`, `indentStyle` _(tabs or spaces)_, `quotes`, `semi`, `trimTrailingWhitespace`, `maxConsecutiveBlankLines`, `finalNewline`
|
|
22
|
+
- Smart whitespace cleanup
|
|
23
|
+
- ESLint-style plugin system for lint rules _(load plugins, enable/disable rules, WIP labeling)_
|
|
24
|
+
- CI-friendly reporters _(stylish, compact, JSON)_ and strict `--max-warnings` control
|
|
22
25
|
- Programmatic API for custom tooling and editor integrations
|
|
23
26
|
|
|
24
|
-
## Install
|
|
27
|
+
## Install
|
|
25
28
|
|
|
29
|
+
```bash
|
|
26
30
|
# as a dev dependency
|
|
27
|
-
|
|
28
31
|
bun add -D pickier
|
|
29
32
|
|
|
30
33
|
# or
|
|
31
|
-
|
|
32
34
|
npm i -D pickier
|
|
33
35
|
|
|
34
36
|
# or
|
|
35
|
-
|
|
36
37
|
pnpm add -D pickier
|
|
37
38
|
|
|
38
39
|
# or
|
|
39
|
-
|
|
40
40
|
yarn add -D pickier
|
|
41
|
+
```
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
You can also run it directly via npx without installing:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
43
46
|
npx pickier --help
|
|
44
47
|
|
|
45
48
|
# or
|
|
46
|
-
|
|
47
49
|
bunx pickier --help
|
|
48
|
-
|
|
50
|
+
```
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
## Quick Start
|
|
51
53
|
|
|
52
|
-
pickier
|
|
54
|
+
The unified `pickier run` command handles both linting and formatting:
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
```bash
|
|
57
|
+
# Auto-detect mode (lint + format)
|
|
58
|
+
pickier run .
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
# Lint everything
|
|
61
|
+
pickier run . --mode lint
|
|
57
62
|
|
|
58
|
-
#
|
|
63
|
+
# Auto-fix lint issues (safe fixes only)
|
|
64
|
+
pickier run . --mode lint --fix
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
# Preview fixes without writing
|
|
67
|
+
pickier run . --mode lint --fix --dry-run --verbose
|
|
61
68
|
|
|
62
69
|
# Format and write changes
|
|
63
|
-
|
|
64
|
-
pickier format . --write
|
|
70
|
+
pickier run . --mode format --write
|
|
65
71
|
|
|
66
72
|
# Check formatting without writing (CI-friendly)
|
|
73
|
+
pickier run . --mode format --check
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## CLI
|
|
67
77
|
|
|
68
|
-
pickier
|
|
78
|
+
### `pickier run [...globs]`
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
The primary command. Routes to lint or format based on `--mode`.
|
|
71
81
|
|
|
72
|
-
|
|
73
|
-
-`--dry-run`: simulate fixes without writing
|
|
82
|
+
**Options:**
|
|
74
83
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
| Flag | Description | Default |
|
|
85
|
+
|------|-------------|---------|
|
|
86
|
+
| `--mode <mode>` | `auto`, `lint`, or `format` | `auto` |
|
|
87
|
+
| `--fix` | Apply safe fixes (lint mode) | `false` |
|
|
88
|
+
| `--dry-run` | Simulate fixes without writing (lint mode) | `false` |
|
|
89
|
+
| `--write` | Write changes to files (format mode) | `false` |
|
|
90
|
+
| `--check` | Check without writing, non-zero exit on differences (format mode) | `false` |
|
|
91
|
+
| `--max-warnings <n>` | Fail if warnings exceed _n_ | `-1` |
|
|
92
|
+
| `--reporter <name>` | `stylish`, `json`, or `compact` | `stylish` |
|
|
93
|
+
| `--ext <exts>` | Comma-separated extensions (overrides config) | — |
|
|
94
|
+
| `--ignore-path <file>` | Optional ignore file (e.g. `.gitignore`) | — |
|
|
95
|
+
| `--config <path>` | Path to pickier config file | — |
|
|
96
|
+
| `--cache` | Enable cache (lint mode, reserved) | `false` |
|
|
97
|
+
| `--verbose` | Verbose output | `false` |
|
|
81
98
|
|
|
82
|
-
|
|
99
|
+
**Examples:**
|
|
83
100
|
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
```bash
|
|
102
|
+
pickier run . --mode auto
|
|
103
|
+
pickier run src --mode lint --fix
|
|
104
|
+
pickier run "**/*.{ts,tsx,js}" --mode format --write
|
|
105
|
+
pickier run . --mode lint --reporter json --max-warnings 0
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> **Note:** The legacy `pickier lint` and `pickier format` commands are deprecated and will be removed in a future release. Use `pickier run --mode lint` and `pickier run --mode format` instead.
|
|
86
109
|
|
|
87
|
-
|
|
110
|
+
## Configuration
|
|
88
111
|
|
|
89
|
-
Pickier works out-of-the-box. To customize, create`pickier.config.ts`in your project root. All fields are optional
|
|
112
|
+
Pickier works out-of-the-box. To customize, create `pickier.config.ts` in your project root. All fields are optional.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
90
115
|
// pickier.config.ts
|
|
91
116
|
import type { PickierConfig } from 'pickier'
|
|
92
117
|
|
|
@@ -112,12 +137,14 @@ const config: PickierConfig = {
|
|
|
112
137
|
maxConsecutiveBlankLines: 1,
|
|
113
138
|
// one | two | none
|
|
114
139
|
finalNewline: 'one',
|
|
115
|
-
//
|
|
140
|
+
// indentation width (code files)
|
|
116
141
|
indent: 2,
|
|
117
|
-
//
|
|
142
|
+
// 'spaces' | 'tabs'
|
|
143
|
+
indentStyle: 'spaces',
|
|
144
|
+
// preferred string quotes: 'single' | 'double'
|
|
118
145
|
quotes: 'single',
|
|
119
146
|
// when true, safely remove stylistic semicolons
|
|
120
|
-
// (never touches for(;;) headers; removes duplicate/empty
|
|
147
|
+
// (never touches for(;;) headers; removes duplicate/empty semicolons)
|
|
121
148
|
semi: false,
|
|
122
149
|
},
|
|
123
150
|
|
|
@@ -129,8 +156,7 @@ const config: PickierConfig = {
|
|
|
129
156
|
|
|
130
157
|
// Plugin rules for markdown, style, sorting, etc.
|
|
131
158
|
pluginRules: {
|
|
132
|
-
// Markdown linting (53 rules available)
|
|
133
|
-
// See <https://pickier.dev/rules/markdown> for full list
|
|
159
|
+
// Markdown linting (53+ rules available)
|
|
134
160
|
'markdown/heading-increment': 'error',
|
|
135
161
|
'markdown/no-trailing-spaces': 'error',
|
|
136
162
|
'markdown/fenced-code-language': 'error',
|
|
@@ -139,18 +165,36 @@ const config: PickierConfig = {
|
|
|
139
165
|
}
|
|
140
166
|
|
|
141
167
|
export default config
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Plugin System
|
|
171
|
+
|
|
172
|
+
Pickier supports an ESLint-style plugin system for lint rules organized into focused categories.
|
|
173
|
+
|
|
174
|
+
**Available Plugins:**
|
|
175
|
+
|
|
176
|
+
| Plugin | Description | Rules |
|
|
177
|
+
|--------|-------------|-------|
|
|
178
|
+
| `pickier/` | Sorting, import organization, and core checks | 17+ |
|
|
179
|
+
| `general/` | Error detection and possible problems | 35+ |
|
|
180
|
+
| `quality/` | Best practices and code quality | 40+ |
|
|
181
|
+
| `style/` | Code style enforcement (spacing, punctuation, line breaks, etc.) | 50+ |
|
|
182
|
+
| `ts/` | TypeScript-specific rules (type safety, formatting) | 13+ |
|
|
183
|
+
| `regexp/` | Regular expression safety | 3+ |
|
|
184
|
+
| `markdown/` | Markdown documentation linting | 53+ |
|
|
185
|
+
| `lockfile/` | Lock file validation | 5+ |
|
|
186
|
+
|
|
187
|
+
Configure rules via `pluginRules`:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
pluginRules: {
|
|
191
|
+
'pluginName/ruleId': 'off' | 'warn' | 'error' | ['warn', options],
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Custom Plugin Example:**
|
|
196
|
+
|
|
197
|
+
```ts
|
|
154
198
|
// sample-plugin.ts
|
|
155
199
|
import type { PickierPlugin, RuleContext } from 'pickier'
|
|
156
200
|
|
|
@@ -181,157 +225,197 @@ export const samplePlugin: PickierPlugin = {
|
|
|
181
225
|
'experimental-check': {
|
|
182
226
|
meta: { wip: true },
|
|
183
227
|
check() {
|
|
184
|
-
// not implemented yet
|
|
228
|
+
// not implemented yet — WIP rules surface errors with a :wip-error suffix
|
|
185
229
|
throw new Error('WIP rule')
|
|
186
230
|
},
|
|
187
231
|
},
|
|
188
232
|
},
|
|
189
233
|
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Register the plugin in your config:**
|
|
190
237
|
|
|
191
|
-
```
|
|
238
|
+
```ts
|
|
192
239
|
// pickier.config.ts
|
|
193
240
|
import type { PickierConfig } from 'pickier'
|
|
194
241
|
import { samplePlugin } from './sample-plugin'
|
|
195
242
|
|
|
196
243
|
const config: PickierConfig = {
|
|
197
|
-
verbose: false,
|
|
198
|
-
ignores: ['**/node_modules/**'],
|
|
199
|
-
lint: { extensions: ['ts', 'js'], reporter: 'stylish', cache: false, maxWarnings: -1 },
|
|
200
|
-
format: { extensions: ['ts', 'js', 'json'], trimTrailingWhitespace: true, maxConsecutiveBlankLines: 1, finalNewline: 'one', indent: 2, quotes: 'single', semi: false },
|
|
201
|
-
rules: { noDebugger: 'error', noConsole: 'warn' },
|
|
202
|
-
// Register plugins (currently supports in-memory objects)
|
|
203
244
|
plugins: [samplePlugin],
|
|
204
|
-
// Enable/disable rules and pass options
|
|
205
245
|
pluginRules: {
|
|
206
246
|
'sample/no-todo': 'warn',
|
|
207
|
-
// WIP rules that throw will surface as errors with a :wip-error suffix
|
|
208
247
|
'sample/experimental-check': 'error',
|
|
209
248
|
},
|
|
210
249
|
}
|
|
211
250
|
|
|
212
251
|
export default config
|
|
213
|
-
```
|
|
252
|
+
```
|
|
214
253
|
|
|
215
|
-
|
|
254
|
+
### Formatting Details
|
|
216
255
|
|
|
217
|
-
|
|
256
|
+
**Semicolons**
|
|
218
257
|
|
|
219
|
-
|
|
258
|
+
Controlled by `format.semi` (default `false`). When `true`, Pickier safely removes only stylistic semicolons:
|
|
220
259
|
|
|
221
|
-
|
|
260
|
+
- Preserves `for (init; test; update)` headers
|
|
261
|
+
- Removes duplicate trailing semicolons (e.g. `foo();;` -> `foo();`)
|
|
262
|
+
- Removes lines that are just empty statements (`;`)
|
|
263
|
+
- Keeps normal end-of-line semicolons otherwise (non-destructive)
|
|
222
264
|
|
|
223
|
-
|
|
265
|
+
**Imports (TypeScript/JavaScript)**
|
|
224
266
|
|
|
225
|
-
|
|
267
|
+
Groups and rewrites the top import block:
|
|
226
268
|
|
|
227
|
-
|
|
269
|
+
- Splits type-only specifiers into `import type { ... } from 'x'`
|
|
270
|
+
- Keeps default and namespace imports
|
|
271
|
+
- Removes unused named specifiers (only when they have no alias)
|
|
272
|
+
- Merges multiple imports from the same module
|
|
228
273
|
|
|
229
|
-
|
|
274
|
+
Sorting order:
|
|
230
275
|
|
|
231
|
-
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
- removes duplicate trailing semicolons (e.g.`foo();;`→`foo();`)
|
|
235
|
-
- removes lines that are just empty statements (`;`)
|
|
236
|
-
- keeps normal end-of-line semicolons otherwise (non-destructive)
|
|
276
|
+
- By kind: type imports, side-effect imports, value imports
|
|
277
|
+
- For modules: external before relative
|
|
278
|
+
- For specifiers: A-Z by identifier
|
|
237
279
|
|
|
238
|
-
|
|
239
|
-
- Groups and rewrites the top import block:
|
|
240
|
-
- Splits type-only specifiers into `import type { ... } from 'x'`- Keeps default and namespace imports
|
|
241
|
-
- Removes unused named specifiers only when they have no alias
|
|
242
|
-
- Merges multiple imports from the same module
|
|
243
|
-
- Sorting
|
|
244
|
-
- Order by kind: type imports, side-effect imports, value imports
|
|
245
|
-
- For modules: external before relative
|
|
246
|
-
- For specifiers: A→Z by identifier; minor normalization for consistent ordering
|
|
247
|
-
- Spacing/newlines
|
|
248
|
-
- Ensures a single blank line between the import block and the rest of the file
|
|
249
|
-
- Respects`format.finalNewline`at EOF
|
|
280
|
+
Spacing:
|
|
250
281
|
|
|
251
|
-
|
|
282
|
+
- Ensures a single blank line between the import block and the rest of the file
|
|
283
|
+
- Respects `format.finalNewline` at EOF
|
|
252
284
|
|
|
253
|
-
|
|
254
|
-
-`noConsole`controls severity (turn off for libraries that allow console logs).
|
|
285
|
+
**Built-in Rules**
|
|
255
286
|
|
|
256
|
-
|
|
287
|
+
- `noDebugger` — removes `debugger` statements when `--fix` is used
|
|
288
|
+
- `noConsole` — controls severity (turn off for libraries that allow console logs)
|
|
289
|
+
|
|
290
|
+
## Benchmarks
|
|
291
|
+
|
|
292
|
+
Measured on an Apple M3 Pro with Bun 1.3.9. Each tool uses equivalent settings (single quotes, no semicolons, 2-space indent). Pickier and Prettier use their in-memory APIs; oxfmt and Biome have no JS formatting API, so they are called via stdin pipe. Full benchmark source is in `bechmarks/benchmarks/format-comparison.bench.ts`.
|
|
293
|
+
|
|
294
|
+
### In-memory / Programmatic API
|
|
295
|
+
|
|
296
|
+
Pickier `formatCode()` and Prettier `format()` run in-process. oxfmt and Biome are piped via stdin (no JS formatting API).
|
|
297
|
+
|
|
298
|
+
| File | Pickier | Biome (stdin) | oxfmt (stdin) | Prettier |
|
|
299
|
+
|------|--------:|--------------:|--------------:|---------:|
|
|
300
|
+
| Small (52 lines, 1 KB) | **41 us** | 40 ms | 51 ms | 1.59 ms |
|
|
301
|
+
| Medium (419 lines, 10 KB) | **417 us** | 42 ms | 50 ms | 10.2 ms |
|
|
302
|
+
| Large (1,279 lines, 31 KB) | **1.25 ms** | 46 ms | 50 ms | 28.1 ms |
|
|
303
|
+
|
|
304
|
+
### CLI (single file)
|
|
257
305
|
|
|
258
|
-
|
|
306
|
+
All four tools spawn a process and read the file from disk.
|
|
259
307
|
|
|
260
|
-
|
|
308
|
+
| File | Pickier | Biome | oxfmt | Prettier |
|
|
309
|
+
|------|--------:|------:|------:|---------:|
|
|
310
|
+
| Small (52 lines) | **37 ms** | 43 ms | 68 ms | 105 ms |
|
|
311
|
+
| Medium (419 lines) | **38 ms** | 53 ms | 71 ms | 143 ms |
|
|
312
|
+
| Large (1,279 lines) | **40 ms** | 90 ms | 73 ms | 187 ms |
|
|
313
|
+
|
|
314
|
+
### CLI Batch (all files, sequential)
|
|
315
|
+
|
|
316
|
+
| Tool | Time |
|
|
317
|
+
|------|-----:|
|
|
318
|
+
| Pickier | **121 ms** |
|
|
319
|
+
| Biome | 187 ms |
|
|
320
|
+
| oxfmt | 216 ms |
|
|
321
|
+
| Prettier | 423 ms |
|
|
322
|
+
|
|
323
|
+
### Throughput (large file x 20)
|
|
324
|
+
|
|
325
|
+
| Tool | Time |
|
|
326
|
+
|------|-----:|
|
|
327
|
+
| Pickier | **26 ms** |
|
|
328
|
+
| Prettier | 524 ms |
|
|
329
|
+
| Biome (stdin) | 957 ms |
|
|
330
|
+
| oxfmt (stdin) | 1,040 ms |
|
|
331
|
+
|
|
332
|
+
> Pickier's in-memory API is **22-39x faster than Prettier** and orders of magnitude faster than tools that must spawn a process. On CLI, Pickier's compiled binary beats Biome's native Rust binary across all file sizes — **37ms vs 43ms on small files**, and pulling further ahead on larger files. At throughput scale (20x large file), Pickier is **20x faster** than Prettier and **37x faster** than Biome/oxfmt.
|
|
261
333
|
|
|
262
334
|
```bash
|
|
335
|
+
# reproduce locally
|
|
336
|
+
bun bechmarks/benchmarks/format-comparison.bench.ts
|
|
337
|
+
```
|
|
263
338
|
|
|
264
|
-
|
|
339
|
+
## Programmatic Usage
|
|
340
|
+
|
|
341
|
+
Call Pickier from code (Bun/Node) for custom tooling, editors, or pipelines.
|
|
265
342
|
|
|
343
|
+
```ts
|
|
344
|
+
import type { RunOptions } from 'pickier'
|
|
345
|
+
import { config, defaultConfig, run, runLint, runFormat, lintText } from 'pickier'
|
|
346
|
+
|
|
347
|
+
// Unified run (recommended)
|
|
348
|
+
const exitCode = await run(['.'], {
|
|
349
|
+
mode: 'auto',
|
|
350
|
+
fix: true,
|
|
351
|
+
verbose: false,
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
// Lint specific directories
|
|
355
|
+
const lintCode = await runLint(['src', 'tests'], {
|
|
356
|
+
fix: true,
|
|
357
|
+
dryRun: false,
|
|
358
|
+
reporter: 'json',
|
|
359
|
+
maxWarnings: 0,
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
// Format specific globs
|
|
363
|
+
const fmtCode = await runFormat(['src/**/*.ts'], {
|
|
364
|
+
write: true,
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
// Lint a single string
|
|
368
|
+
const result = await lintText('const x = 1;;', {
|
|
369
|
+
filePath: 'virtual.ts',
|
|
370
|
+
})
|
|
371
|
+
|
|
372
|
+
// Access loaded config (from pickier.config.ts or defaults)
|
|
373
|
+
console.log('loaded config:', config)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Development
|
|
377
|
+
|
|
378
|
+
This repository contains Pickier's source under `packages/pickier`.
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# install deps
|
|
266
382
|
bun i
|
|
267
383
|
|
|
268
384
|
# run tests (with coverage)
|
|
269
|
-
|
|
270
385
|
bun test --coverage
|
|
271
386
|
|
|
272
387
|
# build JS and type declarations
|
|
273
|
-
|
|
274
388
|
bun run -C packages/pickier build
|
|
275
389
|
|
|
276
390
|
# compile native binary for your platform
|
|
277
|
-
|
|
278
391
|
bun run -C packages/pickier compile
|
|
279
392
|
|
|
280
393
|
# compile all platform binaries
|
|
281
|
-
|
|
282
394
|
bun run -C packages/pickier compile:all
|
|
395
|
+
```
|
|
283
396
|
|
|
284
|
-
|
|
397
|
+
Try the CLI locally without publishing:
|
|
285
398
|
|
|
399
|
+
```bash
|
|
286
400
|
# run the TS entry directly
|
|
287
|
-
|
|
288
401
|
bun packages/pickier/bin/cli.ts --help
|
|
289
402
|
|
|
290
403
|
# run the built dist CLI
|
|
291
|
-
|
|
292
|
-
bun packages/pickier/dist/bin/cli.js lint .
|
|
404
|
+
bun packages/pickier/dist/bin/cli.js run . --mode lint
|
|
293
405
|
|
|
294
406
|
# or the compiled native binary (after compile)
|
|
295
|
-
|
|
296
407
|
./packages/pickier/bin/pickier-<your-platform> --help
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
You can also call Pickier from code (Bun/Node). Useful for custom tooling, editors, or pipelines.```ts
|
|
300
|
-
import type { FormatOptions, LintOptions } from 'pickier'
|
|
301
|
-
// example.ts
|
|
302
|
-
import { pickierConfig, runFormat, runLint } from 'pickier'
|
|
303
|
-
|
|
304
|
-
// Lint some directories
|
|
305
|
-
const lintOptions: LintOptions = {
|
|
306
|
-
fix: true, // apply safe fixes
|
|
307
|
-
dryRun: false, // set true to simulate fixes
|
|
308
|
-
reporter: 'json', // 'stylish' | 'json' | 'compact'
|
|
309
|
-
maxWarnings: 0, // fail on any warning
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
const lintCode = await runLint(['src', 'tests'], lintOptions)
|
|
313
|
-
console.log('lint exit code:', lintCode)
|
|
314
|
-
|
|
315
|
-
// Format some globs
|
|
316
|
-
const formatOptions: FormatOptions = {
|
|
317
|
-
write: true, // write changes
|
|
318
|
-
}
|
|
408
|
+
```
|
|
319
409
|
|
|
320
|
-
|
|
321
|
-
console.log('format exit code:', fmtCode)
|
|
322
|
-
|
|
323
|
-
// Access loaded config (from pickier.config.ts or defaults)
|
|
324
|
-
console.log('loaded config:', pickierConfig)
|
|
325
|
-
|
|
326
|
-
```Run it with Bun:```bash
|
|
327
|
-
bun example.ts
|
|
328
|
-
```## Testing```bash
|
|
410
|
+
## Testing
|
|
329
411
|
|
|
412
|
+
```bash
|
|
330
413
|
bun test
|
|
414
|
+
```
|
|
331
415
|
|
|
332
|
-
|
|
416
|
+
## Changelog
|
|
333
417
|
|
|
334
|
-
Please see our [releases](https://github.com/
|
|
418
|
+
Please see our [releases](https://github.com/pickier/pickier/releases) page for more information on what has changed recently.
|
|
335
419
|
|
|
336
420
|
## Contributing
|
|
337
421
|
|
|
@@ -341,7 +425,7 @@ Please review the [Contributing Guide](https://github.com/stacksjs/contributing)
|
|
|
341
425
|
|
|
342
426
|
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
343
427
|
|
|
344
|
-
[Discussions on GitHub](https://github.com/
|
|
428
|
+
[Discussions on GitHub](https://github.com/pickier/pickier/discussions)
|
|
345
429
|
|
|
346
430
|
For casual chit-chat with others using this package:
|
|
347
431
|
|
|
@@ -367,15 +451,15 @@ We would like to extend our thanks to the following sponsors for funding Stacks
|
|
|
367
451
|
|
|
368
452
|
## License
|
|
369
453
|
|
|
370
|
-
The MIT License (MIT). Please see [LICENSE](
|
|
454
|
+
The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.
|
|
371
455
|
|
|
372
456
|
Made with 💙
|
|
373
457
|
|
|
374
458
|
<!-- Badges -->
|
|
375
|
-
[npm-version-src]:
|
|
376
|
-
[npm-version-href]:
|
|
377
|
-
[github-actions-src]:
|
|
378
|
-
[github-actions-href]:
|
|
459
|
+
[npm-version-src]: https://img.shields.io/npm/v/pickier?style=flat-square
|
|
460
|
+
[npm-version-href]: https://npmjs.com/package/pickier
|
|
461
|
+
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/pickier/pickier/ci.yml?style=flat-square&branch=main
|
|
462
|
+
[github-actions-href]: https://github.com/pickier/pickier/actions?query=workflow%3Aci
|
|
379
463
|
|
|
380
|
-
<!-- [codecov-src]:
|
|
381
|
-
[codecov-href]:
|
|
464
|
+
<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/pickier/pickier/main?style=flat-square -->
|
|
465
|
+
<!-- [codecov-href]: https://codecov.io/gh/pickier/pickier -->
|