pickier 0.1.10 → 0.1.12
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/LICENSE.md +21 -0
- package/README.md +381 -0
- package/package.json +7 -7
- package/dist/ast.d.ts +0 -24
- package/dist/bin/cli.js +0 -22177
- package/dist/config.d.ts +0 -3
- package/dist/format.d.ts +0 -6
- package/dist/formatter.d.ts +0 -6
- package/dist/index.d.ts +0 -8
- package/dist/linter.d.ts +0 -19
- package/dist/plugins/eslint.d.ts +0 -1
- package/dist/plugins/general.d.ts +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/markdown.d.ts +0 -1
- package/dist/plugins/node.d.ts +0 -1
- package/dist/plugins/perfectionist.d.ts +0 -5
- package/dist/plugins/pickier.d.ts +0 -1
- package/dist/plugins/quality.d.ts +0 -1
- package/dist/plugins/regexp.d.ts +0 -1
- package/dist/plugins/style.d.ts +0 -1
- package/dist/plugins/ts.d.ts +0 -1
- package/dist/plugins/unused-imports.d.ts +0 -5
- package/dist/rules/general/array-callback-return.d.ts +0 -1
- package/dist/rules/general/constructor-super.d.ts +0 -1
- package/dist/rules/general/for-direction.d.ts +0 -1
- package/dist/rules/general/getter-return.d.ts +0 -1
- package/dist/rules/general/no-async-promise-executor.d.ts +0 -1
- package/dist/rules/general/no-compare-neg-zero.d.ts +0 -1
- package/dist/rules/general/no-cond-assign.d.ts +0 -1
- package/dist/rules/general/no-const-assign.d.ts +0 -1
- package/dist/rules/general/no-constant-condition.d.ts +0 -1
- package/dist/rules/general/no-constructor-return.d.ts +0 -1
- package/dist/rules/general/no-dupe-class-members.d.ts +0 -1
- package/dist/rules/general/no-dupe-keys.d.ts +0 -1
- package/dist/rules/general/no-duplicate-case.d.ts +0 -1
- package/dist/rules/general/no-empty-pattern.d.ts +0 -1
- package/dist/rules/general/no-fallthrough.d.ts +0 -1
- package/dist/rules/general/no-irregular-whitespace.d.ts +0 -1
- package/dist/rules/general/no-loss-of-precision.d.ts +0 -1
- package/dist/rules/general/no-new.d.ts +0 -12
- package/dist/rules/general/no-promise-executor-return.d.ts +0 -1
- package/dist/rules/general/no-redeclare.d.ts +0 -1
- package/dist/rules/general/no-regex-spaces.d.ts +0 -9
- package/dist/rules/general/no-self-assign.d.ts +0 -1
- package/dist/rules/general/no-self-compare.d.ts +0 -1
- package/dist/rules/general/no-sparse-arrays.d.ts +0 -1
- package/dist/rules/general/no-undef.d.ts +0 -1
- package/dist/rules/general/no-unreachable.d.ts +0 -1
- package/dist/rules/general/no-unsafe-negation.d.ts +0 -1
- package/dist/rules/general/no-unused-vars.d.ts +0 -1
- package/dist/rules/general/no-useless-catch.d.ts +0 -1
- package/dist/rules/general/prefer-const.d.ts +0 -1
- package/dist/rules/general/prefer-object-spread.d.ts +0 -1
- package/dist/rules/general/prefer-template.d.ts +0 -7
- package/dist/rules/general/use-isnan.d.ts +0 -1
- package/dist/rules/general/valid-typeof.d.ts +0 -1
- package/dist/rules/imports/first.d.ts +0 -1
- package/dist/rules/imports/import-dedupe.d.ts +0 -1
- package/dist/rules/imports/named.d.ts +0 -1
- package/dist/rules/imports/no-cycle.d.ts +0 -1
- package/dist/rules/imports/no-duplicate-imports.d.ts +0 -1
- package/dist/rules/imports/no-import-dist.d.ts +0 -1
- package/dist/rules/imports/no-import-node-modules-by-path.d.ts +0 -1
- package/dist/rules/imports/no-unresolved.d.ts +0 -1
- package/dist/rules/markdown/blanks-around-fences.d.ts +0 -4
- package/dist/rules/markdown/blanks-around-headings.d.ts +0 -4
- package/dist/rules/markdown/blanks-around-lists.d.ts +0 -4
- package/dist/rules/markdown/blanks-around-tables.d.ts +0 -4
- package/dist/rules/markdown/code-block-style.d.ts +0 -4
- package/dist/rules/markdown/code-fence-style.d.ts +0 -4
- package/dist/rules/markdown/commands-show-output.d.ts +0 -4
- package/dist/rules/markdown/descriptive-link-text.d.ts +0 -4
- package/dist/rules/markdown/emphasis-style.d.ts +0 -4
- package/dist/rules/markdown/fenced-code-language.d.ts +0 -4
- package/dist/rules/markdown/first-line-heading.d.ts +0 -4
- package/dist/rules/markdown/heading-increment.d.ts +0 -4
- package/dist/rules/markdown/heading-start-left.d.ts +0 -4
- package/dist/rules/markdown/heading-style.d.ts +0 -4
- package/dist/rules/markdown/hr-style.d.ts +0 -4
- package/dist/rules/markdown/line-length.d.ts +0 -4
- package/dist/rules/markdown/link-fragments.d.ts +0 -4
- package/dist/rules/markdown/link-image-reference-definitions.d.ts +0 -4
- package/dist/rules/markdown/link-image-style.d.ts +0 -4
- package/dist/rules/markdown/list-indent.d.ts +0 -4
- package/dist/rules/markdown/list-marker-space.d.ts +0 -4
- package/dist/rules/markdown/no-alt-text.d.ts +0 -4
- package/dist/rules/markdown/no-bare-urls.d.ts +0 -4
- package/dist/rules/markdown/no-blanks-blockquote.d.ts +0 -4
- package/dist/rules/markdown/no-duplicate-heading.d.ts +0 -4
- package/dist/rules/markdown/no-emphasis-as-heading.d.ts +0 -4
- package/dist/rules/markdown/no-empty-links.d.ts +0 -4
- package/dist/rules/markdown/no-hard-tabs.d.ts +0 -4
- package/dist/rules/markdown/no-inline-html.d.ts +0 -4
- package/dist/rules/markdown/no-missing-space-atx.d.ts +0 -4
- package/dist/rules/markdown/no-missing-space-closed-atx.d.ts +0 -4
- package/dist/rules/markdown/no-multiple-blanks.d.ts +0 -4
- package/dist/rules/markdown/no-multiple-space-atx.d.ts +0 -4
- package/dist/rules/markdown/no-multiple-space-blockquote.d.ts +0 -4
- package/dist/rules/markdown/no-multiple-space-closed-atx.d.ts +0 -4
- package/dist/rules/markdown/no-reversed-links.d.ts +0 -4
- package/dist/rules/markdown/no-space-in-code.d.ts +0 -4
- package/dist/rules/markdown/no-space-in-emphasis.d.ts +0 -4
- package/dist/rules/markdown/no-space-in-links.d.ts +0 -4
- package/dist/rules/markdown/no-trailing-punctuation.d.ts +0 -4
- package/dist/rules/markdown/no-trailing-spaces.d.ts +0 -4
- package/dist/rules/markdown/ol-prefix.d.ts +0 -4
- package/dist/rules/markdown/proper-names.d.ts +0 -4
- package/dist/rules/markdown/reference-links-images.d.ts +0 -4
- package/dist/rules/markdown/required-headings.d.ts +0 -4
- package/dist/rules/markdown/single-title.d.ts +0 -4
- package/dist/rules/markdown/single-trailing-newline.d.ts +0 -4
- package/dist/rules/markdown/strong-style.d.ts +0 -4
- package/dist/rules/markdown/table-column-count.d.ts +0 -4
- package/dist/rules/markdown/table-column-style.d.ts +0 -4
- package/dist/rules/markdown/table-pipe-style.d.ts +0 -4
- package/dist/rules/markdown/ul-indent.d.ts +0 -4
- package/dist/rules/markdown/ul-style.d.ts +0 -4
- package/dist/rules/node/prefer-global-buffer.d.ts +0 -8
- package/dist/rules/node/prefer-global-process.d.ts +0 -8
- package/dist/rules/quality/complexity.d.ts +0 -1
- package/dist/rules/quality/default-case.d.ts +0 -1
- package/dist/rules/quality/eqeqeq.d.ts +0 -1
- package/dist/rules/quality/max-depth.d.ts +0 -1
- package/dist/rules/quality/max-lines-per-function.d.ts +0 -1
- package/dist/rules/quality/no-alert.d.ts +0 -1
- package/dist/rules/quality/no-await-in-loop.d.ts +0 -1
- package/dist/rules/quality/no-caller.d.ts +0 -1
- package/dist/rules/quality/no-case-declarations.d.ts +0 -1
- package/dist/rules/quality/no-else-return.d.ts +0 -1
- package/dist/rules/quality/no-empty-function.d.ts +0 -1
- package/dist/rules/quality/no-empty.d.ts +0 -1
- package/dist/rules/quality/no-eval.d.ts +0 -1
- package/dist/rules/quality/no-extend-native.d.ts +0 -1
- package/dist/rules/quality/no-extra-boolean-cast.d.ts +0 -1
- package/dist/rules/quality/no-global-assign.d.ts +0 -1
- package/dist/rules/quality/no-implied-eval.d.ts +0 -1
- package/dist/rules/quality/no-iterator.d.ts +0 -1
- package/dist/rules/quality/no-lonely-if.d.ts +0 -1
- package/dist/rules/quality/no-new-func.d.ts +0 -1
- package/dist/rules/quality/no-new-wrappers.d.ts +0 -1
- package/dist/rules/quality/no-new.d.ts +0 -1
- package/dist/rules/quality/no-octal.d.ts +0 -1
- package/dist/rules/quality/no-param-reassign.d.ts +0 -1
- package/dist/rules/quality/no-proto.d.ts +0 -1
- package/dist/rules/quality/no-return-assign.d.ts +0 -1
- package/dist/rules/quality/no-sequences.d.ts +0 -1
- package/dist/rules/quality/no-shadow.d.ts +0 -1
- package/dist/rules/quality/no-throw-literal.d.ts +0 -1
- package/dist/rules/quality/no-use-before-define.d.ts +0 -1
- package/dist/rules/quality/no-useless-call.d.ts +0 -1
- package/dist/rules/quality/no-useless-concat.d.ts +0 -1
- package/dist/rules/quality/no-useless-escape.d.ts +0 -1
- package/dist/rules/quality/no-useless-rename.d.ts +0 -1
- package/dist/rules/quality/no-useless-return.d.ts +0 -1
- package/dist/rules/quality/no-var.d.ts +0 -1
- package/dist/rules/quality/no-with.d.ts +0 -1
- package/dist/rules/quality/prefer-arrow-callback.d.ts +0 -1
- package/dist/rules/quality/require-await.d.ts +0 -1
- package/dist/rules/regexp/no-super-linear-backtracking.d.ts +0 -1
- package/dist/rules/regexp/no-unused-capturing-group.d.ts +0 -1
- package/dist/rules/regexp/no-useless-lazy.d.ts +0 -8
- package/dist/rules/sort/exports.d.ts +0 -1
- package/dist/rules/sort/heritage-clauses.d.ts +0 -1
- package/dist/rules/sort/imports.d.ts +0 -1
- package/dist/rules/sort/keys.d.ts +0 -1
- package/dist/rules/sort/named-imports.d.ts +0 -1
- package/dist/rules/sort/objects.d.ts +0 -1
- package/dist/rules/style/brace-style.d.ts +0 -9
- package/dist/rules/style/consistent-chaining.d.ts +0 -1
- package/dist/rules/style/consistent-list-newline.d.ts +0 -1
- package/dist/rules/style/curly.d.ts +0 -4
- package/dist/rules/style/if-newline.d.ts +0 -1
- package/dist/rules/style/indent-unindent.d.ts +0 -1
- package/dist/rules/style/max-statements-per-line.d.ts +0 -1
- package/dist/rules/style/no-multi-spaces.d.ts +0 -9
- package/dist/rules/style/no-multiple-empty-lines.d.ts +0 -8
- package/dist/rules/style/no-trailing-spaces.d.ts +0 -8
- package/dist/rules/style/top-level-function.d.ts +0 -5
- package/dist/rules/ts/no-explicit-any.d.ts +0 -1
- package/dist/rules/ts/no-floating-promises.d.ts +0 -1
- package/dist/rules/ts/no-misused-promises.d.ts +0 -1
- package/dist/rules/ts/no-require-imports.d.ts +0 -1
- package/dist/rules/ts/no-top-level-await.d.ts +0 -3
- package/dist/rules/ts/no-ts-export-equal.d.ts +0 -1
- package/dist/rules/ts/no-unsafe-assignment.d.ts +0 -1
- package/dist/rules/ts/prefer-nullish-coalescing.d.ts +0 -1
- package/dist/rules/ts/prefer-optional-chain.d.ts +0 -1
- package/dist/run.d.ts +0 -5
- package/dist/src/index.js +0 -20299
- package/dist/types.d.ts +0 -86
- package/dist/utils.d.ts +0 -30
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Open Web Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
<p align="center"><img src=".github/art/cover.jpg" alt="Social Card of this repo"></p>
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![GitHub Actions][github-actions-src]][github-actions-href]
|
|
5
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
6
|
+
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
|
|
7
|
+
<!-- [![Codecov][codecov-src]][codecov-href] -->
|
|
8
|
+
|
|
9
|
+
# Pickier
|
|
10
|
+
|
|
11
|
+
> Fast linting and formatting. Minimal defaults. Extensible. Built for speed.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- 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
|
|
18
|
+
- Import organization: splits type/value imports, sorts modules/specifiers, removes unused named imports
|
|
19
|
+
- JSON and config sorting for common files_(e.g.`package.json`, `tsconfig.json`)_-**Markdown linting with 53 rules**for documentation quality_(headings, lists, links, code blocks, tables, etc.)_- 27 rules support auto-fix for common formatting issues
|
|
20
|
+
- Flexible formatting: `indent`, `indentStyle`_(tabs or spaces)_, `quotes`, `semi`, `trimTrailingWhitespace`, `maxConsecutiveBlankLines`, `finalNewline`- Smart whitespace cleanup
|
|
21
|
+
- ESLint-style plugin system for lint rules_(load plugins, enable/disable rules, WIP labeling)_- CI-friendly reporters_(stylish, compact, JSON)_and strict`--max-warnings`control
|
|
22
|
+
- Programmatic API for custom tooling and editor integrations
|
|
23
|
+
|
|
24
|
+
## Install```bash
|
|
25
|
+
|
|
26
|
+
# as a dev dependency
|
|
27
|
+
|
|
28
|
+
bun add -D pickier
|
|
29
|
+
|
|
30
|
+
# or
|
|
31
|
+
|
|
32
|
+
npm i -D pickier
|
|
33
|
+
|
|
34
|
+
# or
|
|
35
|
+
|
|
36
|
+
pnpm add -D pickier
|
|
37
|
+
|
|
38
|
+
# or
|
|
39
|
+
|
|
40
|
+
yarn add -D pickier
|
|
41
|
+
|
|
42
|
+
```You can also run it directly via npx without installing:```bash
|
|
43
|
+
npx pickier --help
|
|
44
|
+
|
|
45
|
+
# or
|
|
46
|
+
|
|
47
|
+
bunx pickier --help
|
|
48
|
+
```## Quick start```bash
|
|
49
|
+
|
|
50
|
+
# Lint everything, pretty output
|
|
51
|
+
|
|
52
|
+
pickier lint .
|
|
53
|
+
|
|
54
|
+
# Auto-fix issues (safe fixes only)
|
|
55
|
+
|
|
56
|
+
pickier lint . --fix
|
|
57
|
+
|
|
58
|
+
# Preview fixes without writing
|
|
59
|
+
|
|
60
|
+
pickier lint . --fix --dry-run --verbose
|
|
61
|
+
|
|
62
|
+
# Format and write changes
|
|
63
|
+
|
|
64
|
+
pickier format . --write
|
|
65
|
+
|
|
66
|
+
# Check formatting without writing (CI-friendly)
|
|
67
|
+
|
|
68
|
+
pickier format . --check
|
|
69
|
+
|
|
70
|
+
```## CLI
|
|
71
|
+
|
|
72
|
+
-`pickier lint [...globs]`-`--fix`: apply safe fixes (e.g. remove `debugger`statements)
|
|
73
|
+
-`--dry-run`: simulate fixes without writing
|
|
74
|
+
|
|
75
|
+
- `--max-warnings <n>`: fail if warnings exceed n (default: -1)
|
|
76
|
+
- `--reporter <stylish|json|compact>`: output format (default: stylish)
|
|
77
|
+
- `--ext <.ts,.tsx,.js,...>`: comma-separated extensions (overrides config)
|
|
78
|
+
- `--ignore-path <file>`: optional ignore file (e.g. .gitignore)
|
|
79
|
+
- `--cache`: reserved (no-op currently)
|
|
80
|
+
- `--verbose`- Examples:
|
|
81
|
+
|
|
82
|
+
-`pickier lint . --dry-run`-`pickier lint src --fix`-`pickier lint "src/**/*.{ts,tsx}" --reporter json`-`pickier format [...globs]`-`--write`: write formatted files
|
|
83
|
+
|
|
84
|
+
- `--check`: only check, non-zero exit on differences
|
|
85
|
+
- `--ext <.ts,.tsx,.js,.json,...>`-`--ignore-path <file>`-`--verbose`- Examples:
|
|
86
|
+
|
|
87
|
+
-`pickier format . --check`-`pickier format src --write`-`pickier format "**/*.{ts,tsx,js}" --write`## Configuration
|
|
88
|
+
|
|
89
|
+
Pickier works out-of-the-box. To customize, create`pickier.config.ts`in your project root. All fields are optional.```ts
|
|
90
|
+
// pickier.config.ts
|
|
91
|
+
import type { PickierConfig } from 'pickier'
|
|
92
|
+
|
|
93
|
+
const config: PickierConfig = {
|
|
94
|
+
verbose: false,
|
|
95
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/build/**'],
|
|
96
|
+
|
|
97
|
+
lint: {
|
|
98
|
+
// which extensions to lint ('.ts' or 'ts' both supported)
|
|
99
|
+
extensions: ['ts', 'js'],
|
|
100
|
+
// stylish | json | compact
|
|
101
|
+
reporter: 'stylish',
|
|
102
|
+
// reserved (not used yet)
|
|
103
|
+
cache: false,
|
|
104
|
+
// -1 disables, otherwise fail when warnings > maxWarnings
|
|
105
|
+
maxWarnings: -1,
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
format: {
|
|
109
|
+
// which extensions to format
|
|
110
|
+
extensions: ['ts', 'js', 'json', 'md', 'yaml', 'yml'],
|
|
111
|
+
trimTrailingWhitespace: true,
|
|
112
|
+
maxConsecutiveBlankLines: 1,
|
|
113
|
+
// one | two | none
|
|
114
|
+
finalNewline: 'one',
|
|
115
|
+
// 2-space indentation (code files)
|
|
116
|
+
indent: 2,
|
|
117
|
+
// preferred string quotes in code files: 'single' | 'double'
|
|
118
|
+
quotes: 'single',
|
|
119
|
+
// when true, safely remove stylistic semicolons
|
|
120
|
+
// (never touches for(;;) headers; removes duplicate/empty semicolon statements)
|
|
121
|
+
semi: false,
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
rules: {
|
|
125
|
+
// 'off' | 'warn' | 'error'
|
|
126
|
+
noDebugger: 'error',
|
|
127
|
+
noConsole: 'warn',
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// Plugin rules for markdown, style, sorting, etc.
|
|
131
|
+
pluginRules: {
|
|
132
|
+
// Markdown linting (53 rules available)
|
|
133
|
+
// See <https://pickier.dev/rules/markdown> for full list
|
|
134
|
+
'markdown/heading-increment': 'error',
|
|
135
|
+
'markdown/no-trailing-spaces': 'error',
|
|
136
|
+
'markdown/fenced-code-language': 'error',
|
|
137
|
+
'markdown/no-duplicate-heading': 'warn',
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default config
|
|
142
|
+
```### Plugin system (rules)
|
|
143
|
+
|
|
144
|
+
Pickier supports an ESLint-style plugin system for lint rules organized into focused categories:**Available Plugins:**-`eslint/`- Legacy compatibility layer for ESLint rule names
|
|
145
|
+
-`general/`- Error detection and possible problems (35+ rules)
|
|
146
|
+
-`quality/`- Best practices and code quality (40+ rules)
|
|
147
|
+
-`pickier/`- Sorting and import organization (17 rules)
|
|
148
|
+
-`style/`- Code style enforcement (7 rules)
|
|
149
|
+
-`ts/`- TypeScript-specific rules (9 rules)
|
|
150
|
+
-`regexp/`- Regular expression safety (3 rules)
|
|
151
|
+
-`markdown/`- Markdown documentation linting (53+ rules)
|
|
152
|
+
|
|
153
|
+
Configure rules via`pluginRules: { 'pluginName/ruleId': 'off' | 'warn' | 'error' | ['warn', options] }`Define a plugin (example):```ts
|
|
154
|
+
// sample-plugin.ts
|
|
155
|
+
import type { PickierPlugin, RuleContext } from 'pickier'
|
|
156
|
+
|
|
157
|
+
export const samplePlugin: PickierPlugin = {
|
|
158
|
+
name: 'sample',
|
|
159
|
+
rules: {
|
|
160
|
+
'no-todo': {
|
|
161
|
+
meta: { docs: 'disallow TODO comments', recommended: true },
|
|
162
|
+
check(content: string, ctx: RuleContext) {
|
|
163
|
+
const issues = []
|
|
164
|
+
const lines = content.split(/\r?\n/)
|
|
165
|
+
for (let i = 0; i < lines.length; i++) {
|
|
166
|
+
const col = lines[i].indexOf('TODO')
|
|
167
|
+
if (col !== -1) {
|
|
168
|
+
issues.push({
|
|
169
|
+
filePath: ctx.filePath,
|
|
170
|
+
line: i + 1,
|
|
171
|
+
column: col + 1,
|
|
172
|
+
ruleId: 'sample/no-todo',
|
|
173
|
+
message: 'Unexpected TODO comment.',
|
|
174
|
+
severity: 'warning',
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return issues
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
'experimental-check': {
|
|
182
|
+
meta: { wip: true },
|
|
183
|
+
check() {
|
|
184
|
+
// not implemented yet
|
|
185
|
+
throw new Error('WIP rule')
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
```Use the plugin in config:```ts
|
|
192
|
+
// pickier.config.ts
|
|
193
|
+
import type { PickierConfig } from 'pickier'
|
|
194
|
+
import { samplePlugin } from './sample-plugin'
|
|
195
|
+
|
|
196
|
+
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
|
+
plugins: [samplePlugin],
|
|
204
|
+
// Enable/disable rules and pass options
|
|
205
|
+
pluginRules: {
|
|
206
|
+
'sample/no-todo': 'warn',
|
|
207
|
+
// WIP rules that throw will surface as errors with a :wip-error suffix
|
|
208
|
+
'sample/experimental-check': 'error',
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default config
|
|
213
|
+
```CLI example:```bash
|
|
214
|
+
|
|
215
|
+
pickier lint src --reporter json
|
|
216
|
+
|
|
217
|
+
# If a WIP rule throws, you will see an error like
|
|
218
|
+
|
|
219
|
+
# {
|
|
220
|
+
|
|
221
|
+
# "ruleId": "sample/experimental-check:wip-error"
|
|
222
|
+
|
|
223
|
+
# "message": "Rule sample/experimental-check is marked as WIP and threw: ..."
|
|
224
|
+
|
|
225
|
+
#
|
|
226
|
+
|
|
227
|
+
# }
|
|
228
|
+
|
|
229
|
+
```### Formatting details
|
|
230
|
+
|
|
231
|
+
- Semicolons
|
|
232
|
+
- Controlled by`format.semi`(default`false`). When `true`, Pickier removes only stylistic semicolons safely:
|
|
233
|
+
- preserves `for (init; test; update)`headers
|
|
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)
|
|
237
|
+
|
|
238
|
+
- Imports (TypeScript/JavaScript)
|
|
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
|
|
250
|
+
|
|
251
|
+
Notes:
|
|
252
|
+
|
|
253
|
+
-`noDebugger`removes lines that are debugger statements when`--fix`is used.
|
|
254
|
+
-`noConsole`controls severity (turn off for libraries that allow console logs).
|
|
255
|
+
|
|
256
|
+
## Development
|
|
257
|
+
|
|
258
|
+
This repository contains Pickier’s source under`packages/pickier`.
|
|
259
|
+
|
|
260
|
+
Common tasks:
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
|
|
264
|
+
# install deps
|
|
265
|
+
|
|
266
|
+
bun i
|
|
267
|
+
|
|
268
|
+
# run tests (with coverage)
|
|
269
|
+
|
|
270
|
+
bun test --coverage
|
|
271
|
+
|
|
272
|
+
# build JS and type declarations
|
|
273
|
+
|
|
274
|
+
bun run -C packages/pickier build
|
|
275
|
+
|
|
276
|
+
# compile native binary for your platform
|
|
277
|
+
|
|
278
|
+
bun run -C packages/pickier compile
|
|
279
|
+
|
|
280
|
+
# compile all platform binaries
|
|
281
|
+
|
|
282
|
+
bun run -C packages/pickier compile:all
|
|
283
|
+
|
|
284
|
+
```Try the CLI locally without publishing:```bash
|
|
285
|
+
|
|
286
|
+
# run the TS entry directly
|
|
287
|
+
|
|
288
|
+
bun packages/pickier/bin/cli.ts --help
|
|
289
|
+
|
|
290
|
+
# run the built dist CLI
|
|
291
|
+
|
|
292
|
+
bun packages/pickier/dist/bin/cli.js lint .
|
|
293
|
+
|
|
294
|
+
# or the compiled native binary (after compile)
|
|
295
|
+
|
|
296
|
+
./packages/pickier/bin/pickier-<your-platform> --help
|
|
297
|
+
```## Programmatic usage
|
|
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
|
+
}
|
|
319
|
+
|
|
320
|
+
const fmtCode = await runFormat(['src/**/*.ts'], formatOptions)
|
|
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
|
|
329
|
+
|
|
330
|
+
bun test
|
|
331
|
+
|
|
332
|
+
```## Changelog
|
|
333
|
+
|
|
334
|
+
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
|
|
335
|
+
|
|
336
|
+
## Contributing
|
|
337
|
+
|
|
338
|
+
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
|
|
339
|
+
|
|
340
|
+
## Community
|
|
341
|
+
|
|
342
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
343
|
+
|
|
344
|
+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
|
|
345
|
+
|
|
346
|
+
For casual chit-chat with others using this package:
|
|
347
|
+
|
|
348
|
+
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
|
|
349
|
+
|
|
350
|
+
## Postcardware
|
|
351
|
+
|
|
352
|
+
“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where`pickier` is being used! We showcase them on our website too.
|
|
353
|
+
|
|
354
|
+
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
|
|
355
|
+
|
|
356
|
+
## Sponsors
|
|
357
|
+
|
|
358
|
+
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
|
|
359
|
+
|
|
360
|
+
- [JetBrains](https://www.jetbrains.com/)
|
|
361
|
+
- [The Solana Foundation](https://solana.com/)
|
|
362
|
+
|
|
363
|
+
## Credits
|
|
364
|
+
|
|
365
|
+
- [Chris Breuer](https://github.com/chrisbbreuer)
|
|
366
|
+
- [All Contributors](../../contributors)
|
|
367
|
+
|
|
368
|
+
## License
|
|
369
|
+
|
|
370
|
+
The MIT License (MIT). Please see [LICENSE](https://github.com/pickier/pickier/tree/main/LICENSE.md) for more information.
|
|
371
|
+
|
|
372
|
+
Made with 💙
|
|
373
|
+
|
|
374
|
+
<!-- Badges -->
|
|
375
|
+
[npm-version-src]: <https://img.shields.io/npm/v/pickier?style=flat-square>
|
|
376
|
+
[npm-version-href]: <https://npmjs.com/package/pickier>
|
|
377
|
+
[github-actions-src]: <https://img.shields.io/github/actions/workflow/status/pickier/pickier/ci.yml?style=flat-square&branch=main>
|
|
378
|
+
[github-actions-href]: <https://github.com/pickier/pickier/actions?query=workflow%3Aci>
|
|
379
|
+
|
|
380
|
+
<!-- [codecov-src]: <https://img.shields.io/codecov/c/gh/pickier/pickier/main?style=flat-square>
|
|
381
|
+
[codecov-href]: <https://codecov.io/gh/pickier/pickier> -->
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pickier",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.12",
|
|
5
5
|
"description": "Format, lint and more in a fraction of seconds.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://github.com/
|
|
8
|
+
"homepage": "https://github.com/pickier/pickier#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/
|
|
11
|
+
"url": "git+https://github.com/pickier/pickier.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/pickier/pickier/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"pickier",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"test:watch": "PICKIER_NO_AUTO_CONFIG=1 bun test --watch"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@stacksjs/clapp": "^0.
|
|
73
|
+
"@stacksjs/clapp": "^0.2.0",
|
|
74
74
|
"p-limit": "^7.2.0",
|
|
75
|
-
"tinyglobby": "^0.2.
|
|
75
|
+
"tinyglobby": "^0.2.15"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"bunfig": "^0.
|
|
78
|
+
"bunfig": "^0.15.6"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/dist/ast.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare function buildSourceMap(text: string): SourceMap;
|
|
2
|
-
// Very small tokenizer sufficient for structural tasks. Tracks strings, template, regex, comments.
|
|
3
|
-
export declare function tokenize(text: string): Token[];
|
|
4
|
-
export declare function findMatching(text: string, start: number, open: string, close: string): number;
|
|
5
|
-
// Lightweight parsing utilities (no deps). Intentionally minimal for Pickier rules.
|
|
6
|
-
// Provides tokenization, simple bracket matching, and loc <-> index mapping.
|
|
7
|
-
export declare interface Loc {
|
|
8
|
-
line: number
|
|
9
|
-
column: number
|
|
10
|
-
}
|
|
11
|
-
export declare interface Range {
|
|
12
|
-
start: number
|
|
13
|
-
end: number
|
|
14
|
-
}
|
|
15
|
-
export declare interface Token {
|
|
16
|
-
type: string
|
|
17
|
-
value: string
|
|
18
|
-
start: number
|
|
19
|
-
end: number
|
|
20
|
-
}
|
|
21
|
-
export declare interface SourceMap {
|
|
22
|
-
lineStarts: number[]
|
|
23
|
-
indexToLoc: (idx: number) => Loc
|
|
24
|
-
}
|