Skip to content

Commit 31046eb

Browse files
committed
chore: update docs to reflect new rules
1 parent 16edb5e commit 31046eb

File tree

6 files changed

+577
-206
lines changed

6 files changed

+577
-206
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,19 @@ export default config
153153

154154
### Plugin system (rules)
155155

156-
Pickier supports an ESLint-style plugin system for lint rules. You can load plugins, configure their rules per severity, and mark experimental rules as WIP to surface errors early.
157-
158-
Concepts:
159-
- Plugin: `{ name: string, rules: Record<string, RuleModule> }`
160-
- RuleModule: `{ meta?: { docs?: string; recommended?: boolean; wip?: boolean }, check(content, context) => LintIssue[] }`
161-
- Configure rules via `pluginRules: { 'pluginName/ruleId': 'off' | 'warn' | 'error' | ['warn', options] }`
156+
Pickier supports an ESLint-style plugin system for lint rules organized into focused categories:
157+
158+
**Available Plugins:**
159+
- `eslint/` - Legacy compatibility layer for ESLint rule names
160+
- `general/` - Error detection and possible problems (35+ rules)
161+
- `quality/` - Best practices and code quality (40+ rules)
162+
- `pickier/` - Sorting and import organization (17 rules)
163+
- `style/` - Code style enforcement (7 rules)
164+
- `ts/` - TypeScript-specific rules (9 rules)
165+
- `regexp/` - Regular expression safety (3 rules)
166+
- `markdown/` - Markdown documentation linting (53+ rules)
167+
168+
Configure rules via `pluginRules: { 'pluginName/ruleId': 'off' | 'warn' | 'error' | ['warn', options] }`
162169

163170
Define a plugin (example):
164171

docs/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,19 @@ Sometimes you need to break a rule temporarily. Use disable comments to suppress
109109

110110
### Plugin Architecture
111111

112-
Pickier's rules are organized into plugins:
113-
- **Core** - Built-in rules always available (quotes, indent, etc.)
114-
- **Pickier** - General code quality rules (no-unused-vars, prefer-const, etc.)
115-
- **Sort** - Organize imports, objects, and other structures
116-
- **RegExp** - Catch problematic regular expressions
117-
- **Markdown** - Format markdown files consistently
118-
119-
Each plugin can be configured independently, giving you fine-grained control.
112+
Pickier's rules are organized into plugins for better organization and discoverability:
113+
114+
- **Core** - Built-in rules always available (quotes, indent, debugger, console)
115+
- **ESLint** (`eslint/`) - Legacy compatibility layer for ESLint rule names
116+
- **General** (`general/`) - Error detection and possible problems (no-undef, no-const-assign, array-callback-return, etc.)
117+
- **Quality** (`quality/`) - Best practices and code quality (eqeqeq, no-eval, no-var, prefer-arrow-callback, etc.)
118+
- **Pickier** (`pickier/`) - Sorting and import organization (sort-imports, sort-objects, import-dedupe, etc.)
119+
- **Style** (`style/`) - Code style enforcement (brace-style, curly, max-statements-per-line, etc.)
120+
- **TypeScript** (`ts/`) - TypeScript-specific rules (no-explicit-any, prefer-optional-chain, no-floating-promises, etc.)
121+
- **RegExp** (`regexp/`) - Regular expression safety (no-super-linear-backtracking, no-unused-capturing-group, etc.)
122+
- **Markdown** (`markdown/`) - Markdown documentation linting with 53+ rules
123+
124+
Each plugin can be configured independently through the `pluginRules` configuration, giving you fine-grained control over your linting experience.
120125

121126
## Best Practices
122127

docs/rules/general.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# general (built-in plugin)
2+
3+
The `general` plugin provides error detection and possible problems rules. These rules catch common programming errors and potential bugs before they cause issues in production.
4+
5+
## Available Rules
6+
7+
All rules can be configured using either the `general/` or `eslint/` prefix (for backward compatibility).
8+
9+
### Error Detection
10+
11+
**Variable & Scope:**
12+
- `no-const-assign` - Disallow reassigning const variables
13+
- `no-redeclare` - Disallow variable redeclaration
14+
- `no-undef` - Disallow undeclared variables
15+
- `no-unused-vars` - Disallow unused variables ([docs](/rules/no-unused-vars))
16+
- `no-shadow` - Disallow variable declarations from shadowing outer scope
17+
- `no-use-before-define` - Disallow use of variables before they are defined
18+
19+
**Functions & Callbacks:**
20+
- `array-callback-return` - Enforce return statements in array callbacks
21+
- `getter-return` - Enforce return statements in getters
22+
- `constructor-super` - Require super() calls in constructors
23+
- `no-constructor-return` - Disallow returning value from constructor
24+
25+
**Control Flow:**
26+
- `for-direction` - Enforce "for" loop update clause moving counter in the right direction
27+
- `no-fallthrough` - Disallow fallthrough of case statements
28+
- `no-unreachable` - Disallow unreachable code after return, throw, continue, and break
29+
- `no-constant-condition` - Disallow constant expressions in conditions
30+
31+
**Objects & Classes:**
32+
- `no-dupe-keys` - Disallow duplicate keys in object literals
33+
- `no-dupe-class-members` - Disallow duplicate class members
34+
- `no-duplicate-case` - Disallow duplicate case labels
35+
36+
**Async & Promises:**
37+
- `no-async-promise-executor` - Disallow async promise executor
38+
- `no-promise-executor-return` - Disallow returning values from Promise executor
39+
40+
**Comparisons:**
41+
- `no-compare-neg-zero` - Disallow comparing against -0
42+
- `no-self-assign` - Disallow assignments where both sides are exactly the same
43+
- `no-self-compare` - Disallow comparisons where both sides are exactly the same
44+
- `use-isnan` - Require calls to isNaN() when checking for NaN
45+
- `valid-typeof` - Enforce comparing typeof expressions against valid strings
46+
47+
**Patterns & Syntax:**
48+
- `no-empty-pattern` - Disallow empty destructuring patterns
49+
- `no-sparse-arrays` - Disallow sparse arrays
50+
- `no-irregular-whitespace` - Disallow irregular whitespace
51+
- `no-loss-of-precision` - Disallow number literals that lose precision
52+
- `no-unsafe-negation` - Disallow negating the left operand of relational operators
53+
- `no-useless-catch` - Disallow unnecessary catch clauses
54+
55+
**Modern JavaScript:**
56+
- `prefer-const` - Require const declarations for variables that are never reassigned ([docs](/rules/prefer-const))
57+
- `prefer-object-spread` - Prefer object spread over Object.assign
58+
- `prefer-template` - Require template literals instead of string concatenation
59+
60+
## Configuration
61+
62+
Configure rules in your `pickier.config.ts`:
63+
64+
```ts
65+
import type { PickierConfig } from 'pickier'
66+
67+
const config: PickierConfig = {
68+
pluginRules: {
69+
// Use general/ prefix (recommended)
70+
'general/no-undef': 'error',
71+
'general/no-unused-vars': 'error',
72+
'general/prefer-const': 'error',
73+
74+
// Or use eslint/ prefix for compatibility
75+
'eslint/no-undef': 'error',
76+
},
77+
}
78+
79+
export default config
80+
```
81+
82+
## Best Practices
83+
84+
- Keep error detection rules at `'error'` severity to catch bugs early
85+
- Use `prefer-const` to enforce immutability by default
86+
- Enable `no-unused-vars` to keep code clean and catch typos
87+
- Most of these rules don't have auto-fix, so they require manual correction
88+
89+
## See Also
90+
91+
- [Quality Plugin](/rules/quality.md) - Best practices and code quality rules
92+
- [Rules Index](/rules/index.md) - Complete rule catalog
93+
- [Plugin System](/advanced/plugin-system.md) - Plugin configuration guide

0 commit comments

Comments
 (0)