@autofleet/lint 1.0.0
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/.oxfmtrc.json +22 -0
- package/.oxlintrc.json +255 -0
- package/MIGRATION_GAPS.md +299 -0
- package/README.md +273 -0
- package/RULES.md +396 -0
- package/bin/oxfmt.cjs +43 -0
- package/bin/oxlint.cjs +44 -0
- package/bin/postinstall.cjs +87 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# @autofleet/lint
|
|
2
|
+
|
|
3
|
+
**Rust-powered, ultra-fast linting and formatting for Autofleet projects** using [Oxlint v1.43.0](https://oxc.rs/) and [Oxfmt v0.28.0](https://oxc.rs/docs/guide/usage/formatter).
|
|
4
|
+
|
|
5
|
+
## 🚀 Why Oxlint + Oxfmt?
|
|
6
|
+
|
|
7
|
+
- **37x faster** than ESLint (~1-2 seconds vs 60+ seconds)
|
|
8
|
+
- **30x faster** than Prettier (~0.5 seconds vs 15+ seconds)
|
|
9
|
+
- **100% Prettier conformance** - Oxfmt now has 100% compatibility with Prettier output
|
|
10
|
+
- **80% reduction** in CI lint+format time
|
|
11
|
+
- **Type-safe config** - TypeScript config files with full autocomplete (since v1.43.0)
|
|
12
|
+
- **Batteries included** - all dependencies bundled, no peer dependency hell
|
|
13
|
+
- **Single toolchain** - Oxc project maintains all rules consistently
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev @autofleet/lint
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 🔧 Usage
|
|
22
|
+
|
|
23
|
+
### NPM Scripts
|
|
24
|
+
|
|
25
|
+
Add these to your `package.json`:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"scripts": {
|
|
30
|
+
"lint": "autofleet-lint",
|
|
31
|
+
"lint:fix": "autofleet-lint --fix",
|
|
32
|
+
"lint:fix-all": "autofleet-lint --fix-suggestions --fix-dangerously",
|
|
33
|
+
"format": "autofleet-fmt",
|
|
34
|
+
"format:check": "autofleet-fmt --check"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### CLI Commands
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Lint with default (src directory)
|
|
43
|
+
npm run lint
|
|
44
|
+
|
|
45
|
+
# Lint specific files/directories
|
|
46
|
+
autofleet-lint src/lib
|
|
47
|
+
|
|
48
|
+
# Auto-fix safe issues
|
|
49
|
+
npm run lint:fix
|
|
50
|
+
|
|
51
|
+
# Auto-fix all issues (including suggestions and dangerous)
|
|
52
|
+
npm run lint:fix-all
|
|
53
|
+
|
|
54
|
+
# Format code
|
|
55
|
+
npm run format
|
|
56
|
+
|
|
57
|
+
# Check formatting without modifying files
|
|
58
|
+
npm run format:check
|
|
59
|
+
|
|
60
|
+
# Format specific files
|
|
61
|
+
autofleet-fmt src/utils/**/*.ts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 📋 Configuration
|
|
65
|
+
|
|
66
|
+
### Oxlint Configuration
|
|
67
|
+
|
|
68
|
+
✅ **Oxlint supports `extends`** - Create an `.oxlintrc.json` in your project root:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"extends": ["./node_modules/@autofleet/lint/.oxlintrc.json"]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Override rules** for your specific project:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"extends": ["./node_modules/@autofleet/lint/.oxlintrc.json"],
|
|
81
|
+
"rules": {
|
|
82
|
+
"no-console": "off",
|
|
83
|
+
"unicorn/no-array-callback-reference": "off"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**File-specific overrides** using the `overrides` field:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"extends": ["./node_modules/@autofleet/lint/.oxlintrc.json"],
|
|
93
|
+
"overrides": [
|
|
94
|
+
{
|
|
95
|
+
"files": ["scripts/**/*.js"],
|
|
96
|
+
"rules": {
|
|
97
|
+
"no-console": "off"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"files": ["**/*.test.ts"],
|
|
102
|
+
"rules": {
|
|
103
|
+
"typescript/no-explicit-any": "off"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Note:** TypeScript config (`oxlint.config.ts`) is supported in v1.43.0+ but requires Node.js >= 22.12.0. For Node.js < 22.12.0, use `.oxlintrc.json` with `extends`
|
|
111
|
+
|
|
112
|
+
### Oxfmt Configuration
|
|
113
|
+
|
|
114
|
+
⚠️ **Oxfmt does NOT support `extends`** - you must **copy** the configuration file.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Copy from @autofleet/lint to your project
|
|
118
|
+
cp node_modules/@autofleet/lint/.oxfmtrc.json .oxfmtrc.json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Our default settings:
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"semi": true,
|
|
125
|
+
"trailingComma": "all",
|
|
126
|
+
"singleQuote": true,
|
|
127
|
+
"printWidth": 120,
|
|
128
|
+
"tabWidth": 2,
|
|
129
|
+
"useTabs": false,
|
|
130
|
+
"arrowParens": "always",
|
|
131
|
+
"endOfLine": "lf",
|
|
132
|
+
"ignorePatterns": [
|
|
133
|
+
"dist",
|
|
134
|
+
"build",
|
|
135
|
+
"node_modules",
|
|
136
|
+
"coverage",
|
|
137
|
+
"**/migrations/*",
|
|
138
|
+
"*.min.js",
|
|
139
|
+
"*.min.css",
|
|
140
|
+
"package-lock.json",
|
|
141
|
+
"pnpm-lock.yaml",
|
|
142
|
+
"yarn.lock"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Note**: Oxfmt also respects `.gitignore` files automatically.
|
|
148
|
+
|
|
149
|
+
## 🎨 VSCode Integration
|
|
150
|
+
|
|
151
|
+
Install the Oxc extension:
|
|
152
|
+
```
|
|
153
|
+
ext install oxc.oxc-vscode
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Update your `.vscode/settings.json`:
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"editor.formatOnSave": true,
|
|
161
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
162
|
+
"[typescript]": {
|
|
163
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
164
|
+
},
|
|
165
|
+
"[javascript]": {
|
|
166
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
167
|
+
},
|
|
168
|
+
"[json]": {
|
|
169
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## 🔄 Migrating from ESLint + Prettier
|
|
175
|
+
|
|
176
|
+
We've migrated **140+ rules** from our previous ESLint setup to Oxlint. See [MIGRATION_GAPS.md](./MIGRATION_GAPS.md) for:
|
|
177
|
+
- Complete list of unsupported rules
|
|
178
|
+
- Workarounds for missing features
|
|
179
|
+
- Impact assessment
|
|
180
|
+
- Benefits analysis
|
|
181
|
+
|
|
182
|
+
### Key Differences
|
|
183
|
+
|
|
184
|
+
1. **Import Ordering**: Not auto-sorted by Oxlint
|
|
185
|
+
- **Workaround**: Use IDE "Organize Imports" (VSCode: Shift+Alt+O)
|
|
186
|
+
|
|
187
|
+
2. **Naming Conventions**: Not enforced by Oxlint
|
|
188
|
+
- **Workaround**: Follow conventions manually, enforce in code review
|
|
189
|
+
|
|
190
|
+
3. **Formatting**: Oxfmt has 95% Prettier compatibility
|
|
191
|
+
- May produce slightly different output in edge cases
|
|
192
|
+
- Aiming for 99.99% compatibility in future releases
|
|
193
|
+
|
|
194
|
+
## 📚 Available Rules
|
|
195
|
+
|
|
196
|
+
Oxlint includes **665+ built-in rules** from:
|
|
197
|
+
- ✅ ESLint core rules
|
|
198
|
+
- ✅ TypeScript ESLint rules
|
|
199
|
+
- ✅ Unicorn rules (modern JavaScript patterns)
|
|
200
|
+
- ✅ Import rules
|
|
201
|
+
- ✅ Jest rules
|
|
202
|
+
- ✅ OXC custom rules (unique performance & correctness checks)
|
|
203
|
+
|
|
204
|
+
Our configuration enables **140+ rules** carefully selected for:
|
|
205
|
+
- Code correctness
|
|
206
|
+
- TypeScript best practices
|
|
207
|
+
- Modern JavaScript patterns
|
|
208
|
+
- Performance optimizations
|
|
209
|
+
|
|
210
|
+
## 🛠️ Auto-Fix Capabilities
|
|
211
|
+
|
|
212
|
+
Oxlint categorizes fixes into three types:
|
|
213
|
+
|
|
214
|
+
### Safe Fixes (`--fix`)
|
|
215
|
+
Changes that do NOT alter program behavior:
|
|
216
|
+
- Remove unused variables
|
|
217
|
+
- Fix import ordering
|
|
218
|
+
- Simplify boolean expressions
|
|
219
|
+
|
|
220
|
+
### Suggestions (`--fix-suggestions`)
|
|
221
|
+
Changes that MAY alter behavior:
|
|
222
|
+
- Convert `var` to `const`/`let`
|
|
223
|
+
- Simplify conditional logic
|
|
224
|
+
- Optimize array methods
|
|
225
|
+
|
|
226
|
+
### Dangerous Fixes (`--fix-dangerously`)
|
|
227
|
+
Aggressive changes that may break code:
|
|
228
|
+
- Remove unused function parameters
|
|
229
|
+
- Aggressive dead code removal
|
|
230
|
+
|
|
231
|
+
**Recommendation**: Use `--fix` regularly, use `--fix-suggestions --fix-dangerously` carefully.
|
|
232
|
+
|
|
233
|
+
## 🔍 Ignore Patterns
|
|
234
|
+
|
|
235
|
+
Default ignore patterns (configured in `oxlint.config.ts`):
|
|
236
|
+
- `dist/`
|
|
237
|
+
- `build/`
|
|
238
|
+
- `node_modules/`
|
|
239
|
+
- `coverage/`
|
|
240
|
+
- `*.config.js`
|
|
241
|
+
- `**/migrations/*`
|
|
242
|
+
- `**/mock.ts`
|
|
243
|
+
|
|
244
|
+
To customize, edit `oxlint.config.ts` in your project:
|
|
245
|
+
```typescript
|
|
246
|
+
import type { Linter } from 'oxlint';
|
|
247
|
+
import baseConfig from './node_modules/@autofleet/lint/oxlint.config';
|
|
248
|
+
|
|
249
|
+
const config: Linter.Config = {
|
|
250
|
+
...baseConfig,
|
|
251
|
+
ignorePatterns: [
|
|
252
|
+
...baseConfig.ignorePatterns,
|
|
253
|
+
'your-custom-ignore-pattern',
|
|
254
|
+
],
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export default config;
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## 📖 Documentation
|
|
261
|
+
|
|
262
|
+
- [Oxlint Documentation](https://oxc.rs/docs/guide/usage/linter.html)
|
|
263
|
+
- [Oxfmt Documentation](https://oxc.rs/docs/guide/usage/formatter)
|
|
264
|
+
- [Supported Rules](https://oxc.rs/docs/guide/usage/linter/rules)
|
|
265
|
+
- [Migration Gaps](./MIGRATION_GAPS.md)
|
|
266
|
+
|
|
267
|
+
## 🤝 Contributing
|
|
268
|
+
|
|
269
|
+
This package is maintained by the Autofleet engineering team. For issues or suggestions, please reach out on Slack or create an issue in the autorepo.
|
|
270
|
+
|
|
271
|
+
## 📜 License
|
|
272
|
+
|
|
273
|
+
ISC © Autofleet
|
package/RULES.md
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
# @autofleet/lint - Complete Rules Documentation
|
|
2
|
+
|
|
3
|
+
Complete documentation of all linting and formatting rules in `@autofleet/lint` v2.0.0.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a batteries-included linting solution with two Rust-powered tools:
|
|
8
|
+
|
|
9
|
+
1. **Oxlint v1.43.0** - Ultra-fast linter (37x faster than ESLint) with 665+ rules
|
|
10
|
+
2. **Oxfmt v0.28.0** - Ultra-fast formatter (30x faster than Prettier) with 100% Prettier conformance
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Oxlint Rules](#oxlint-rules)
|
|
17
|
+
- [Core ESLint Rules](#core-eslint-rules)
|
|
18
|
+
- [TypeScript Rules](#typescript-rules)
|
|
19
|
+
- [Unicorn Rules (Modern JavaScript)](#unicorn-rules-modern-javascript)
|
|
20
|
+
- [Import Rules](#import-rules)
|
|
21
|
+
- [Jest Rules](#jest-rules)
|
|
22
|
+
- [OXC Custom Rules](#oxc-custom-rules)
|
|
23
|
+
- [Oxfmt Configuration](#oxfmt-configuration)
|
|
24
|
+
- [Rule Severity Levels](#rule-severity-levels)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Oxlint Rules
|
|
29
|
+
|
|
30
|
+
Oxlint v1.43.0 includes **665 built-in rules** from ESLint, TypeScript ESLint, Unicorn, Import, Jest, React, and custom OXC rules.
|
|
31
|
+
|
|
32
|
+
Our configuration enables **140+ carefully selected rules** focused on:
|
|
33
|
+
- Code correctness and safety
|
|
34
|
+
- TypeScript best practices
|
|
35
|
+
- Modern JavaScript patterns
|
|
36
|
+
- Performance optimizations
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Core ESLint Rules
|
|
41
|
+
|
|
42
|
+
### Critical Safety Rules (Error Level)
|
|
43
|
+
|
|
44
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
45
|
+
|------|-------|---------|----------|
|
|
46
|
+
| `no-console` | error | Prevents console statements in production | ❌ |
|
|
47
|
+
| `no-debugger` | error | Prevents debugger statements | ✅ |
|
|
48
|
+
| `no-var` | error | Enforces `const`/`let` over `var` | ✅ |
|
|
49
|
+
| `prefer-const` | error | Enforces `const` for never-reassigned variables | ✅ |
|
|
50
|
+
| `eqeqeq` | error | Requires `===` and `!==` | ✅ |
|
|
51
|
+
| `curly` | error | Requires curly braces for all control statements | ✅ |
|
|
52
|
+
| `no-async-promise-executor` | error | Prevents async functions as Promise executors | ❌ |
|
|
53
|
+
| `prefer-promise-reject-errors` | error | Requires Error objects for Promise rejections | ❌ |
|
|
54
|
+
| `no-unreachable` | error | Detects unreachable code after return/throw | ❌ |
|
|
55
|
+
| `no-unsafe-negation` | error | Prevents unsafe negation of left operand | ✅ |
|
|
56
|
+
| `no-unsafe-optional-chaining` | error | Prevents unsafe optional chaining usage | ❌ |
|
|
57
|
+
| `use-isnan` | error | Requires isNaN() for NaN checks | ✅ |
|
|
58
|
+
| `valid-typeof` | error | Ensures valid typeof comparisons | ❌ |
|
|
59
|
+
| `no-const-assign` | error | Prevents reassigning const variables | ❌ |
|
|
60
|
+
| `no-dupe-keys` | error | Prevents duplicate keys in object literals | ❌ |
|
|
61
|
+
| `no-import-assign` | error | Prevents assignment to imported bindings | ❌ |
|
|
62
|
+
|
|
63
|
+
### Code Quality Rules (Warning Level)
|
|
64
|
+
|
|
65
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
66
|
+
|------|-------|---------|----------|
|
|
67
|
+
| `no-await-in-loop` | warn | Suggests Promise.all for concurrent ops | ❌ |
|
|
68
|
+
| `no-constant-condition` | warn | Detects constant conditions in loops/ifs | ❌ |
|
|
69
|
+
| `no-empty` | warn | Warns on empty block statements | ❌ |
|
|
70
|
+
| `no-prototype-builtins` | warn | Prevents direct use of Object.prototype methods | ✅ |
|
|
71
|
+
| `require-await` | warn | Requires await in async functions | ❌ |
|
|
72
|
+
| `no-useless-catch` | warn | Detects unnecessary catch clauses | ✅ |
|
|
73
|
+
| `no-useless-escape` | warn | Detects unnecessary escape characters | ✅ |
|
|
74
|
+
| `no-return-assign` | warn | Prevents assignment in return statement | ❌ |
|
|
75
|
+
| `no-sequences` | error | Prevents comma operator usage | ❌ |
|
|
76
|
+
| `no-multi-assign` | warn | Prevents chained assignments | ❌ |
|
|
77
|
+
| `no-nested-ternary` | warn | Prevents nested ternary expressions | ❌ |
|
|
78
|
+
| `no-param-reassign` | warn | Prevents parameter reassignment | ❌ |
|
|
79
|
+
| `operator-assignment` | warn | Requires shorthand assignment operators | ✅ |
|
|
80
|
+
| `prefer-destructuring` | warn | Suggests destructuring for arrays/objects | ✅ |
|
|
81
|
+
| `prefer-exponentiation-operator` | warn | Prefers `**` over Math.pow() | ✅ |
|
|
82
|
+
| `prefer-object-spread` | warn | Prefers object spread over Object.assign() | ✅ |
|
|
83
|
+
| `prefer-rest-params` | warn | Prefers rest parameters over arguments | ✅ |
|
|
84
|
+
| `prefer-spread` | warn | Prefers spread operator over .apply() | ✅ |
|
|
85
|
+
| `prefer-template` | warn | Prefers template literals over string concatenation | ✅ |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## TypeScript Rules
|
|
90
|
+
|
|
91
|
+
### Critical TypeScript Rules (Error Level)
|
|
92
|
+
|
|
93
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
94
|
+
|------|-------|---------|----------|
|
|
95
|
+
| `typescript/no-floating-promises` | error | Catches unhandled promise rejections | ❌ |
|
|
96
|
+
| `typescript/await-thenable` | error | Prevents awaiting non-promises | ❌ |
|
|
97
|
+
| `typescript/no-misused-promises` | error | Prevents async mistakes in conditionals | ❌ |
|
|
98
|
+
| `typescript/no-array-delete` | error | Prevents using delete on arrays | ❌ |
|
|
99
|
+
| `typescript/no-duplicate-enum-values` | error | Prevents duplicate enum member values | ❌ |
|
|
100
|
+
| `typescript/no-for-in-array` | error | Prevents for-in loops on arrays | ❌ |
|
|
101
|
+
| `typescript/no-implied-eval` | error | Prevents eval-like patterns | ❌ |
|
|
102
|
+
| `typescript/no-import-type-side-effects` | error | Prevents type import side effects | ✅ |
|
|
103
|
+
| `typescript/no-extra-non-null-assertion` | error | Prevents redundant non-null assertions | ✅ |
|
|
104
|
+
| `typescript/no-unused-vars` | error | Detects unused variables (with _ exceptions) | ❌ |
|
|
105
|
+
|
|
106
|
+
### TypeScript Best Practices (Warning Level)
|
|
107
|
+
|
|
108
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
109
|
+
|------|-------|---------|----------|
|
|
110
|
+
| `typescript/no-explicit-any` | warn | Discourages `any` type (allows in tests) | ❌ |
|
|
111
|
+
| `typescript/require-await` | warn | Requires await in async functions | ❌ |
|
|
112
|
+
| `typescript/ban-types` | warn | Warns on problematic type aliases | ❌ |
|
|
113
|
+
| `typescript/no-empty-interface` | warn | Prevents empty interfaces | ✅ |
|
|
114
|
+
| `typescript/no-extraneous-class` | warn | Prevents classes used only as namespaces | ❌ |
|
|
115
|
+
| `typescript/no-namespace` | warn | Discourages TypeScript namespaces | ❌ |
|
|
116
|
+
| `typescript/no-non-null-assertion` | warn | Warns on non-null assertions | ❌ |
|
|
117
|
+
| `typescript/no-this-alias` | warn | Prevents `const self = this` patterns | ✅ |
|
|
118
|
+
| `typescript/no-unnecessary-type-assertion` | warn | Detects redundant type assertions | ✅ |
|
|
119
|
+
| `typescript/no-unnecessary-type-constraint` | warn | Detects redundant type constraints | ✅ |
|
|
120
|
+
| `typescript/no-unsafe-argument` | warn | Warns on unsafe argument types | ❌ |
|
|
121
|
+
| `typescript/no-unsafe-assignment` | warn | Warns on unsafe assignments | ❌ |
|
|
122
|
+
| `typescript/no-unsafe-call` | warn | Warns on unsafe function calls | ❌ |
|
|
123
|
+
| `typescript/no-unsafe-member-access` | warn | Warns on unsafe property access | ❌ |
|
|
124
|
+
| `typescript/no-unsafe-return` | warn | Warns on unsafe return types | ❌ |
|
|
125
|
+
| `typescript/prefer-as-const` | warn | Prefers `as const` assertions | ✅ |
|
|
126
|
+
| `typescript/prefer-for-of` | warn | Prefers for-of over indexed loops | ❌ |
|
|
127
|
+
| `typescript/prefer-function-type` | warn | Prefers function types over interfaces | ✅ |
|
|
128
|
+
| `typescript/prefer-includes` | warn | Prefers .includes() over .indexOf() | ✅ |
|
|
129
|
+
| `typescript/prefer-nullish-coalescing` | warn | Prefers ?? over \|\| for null checks | ✅ |
|
|
130
|
+
| `typescript/prefer-optional-chain` | warn | Prefers ?. over manual null checks | ✅ |
|
|
131
|
+
| `typescript/prefer-ts-expect-error` | warn | Prefers @ts-expect-error over @ts-ignore | ✅ |
|
|
132
|
+
| `typescript/consistent-type-imports` | warn | Enforces type import style | ✅ |
|
|
133
|
+
| `typescript/adjacent-overload-signatures` | warn | Groups overload signatures together | ❌ |
|
|
134
|
+
| `typescript/array-type` | warn | Enforces consistent array type syntax | ✅ |
|
|
135
|
+
| `typescript/consistent-type-definitions` | warn | Enforces interface or type alias | ✅ |
|
|
136
|
+
| `typescript/no-base-to-string` | warn | Prevents calling toString() on objects | ❌ |
|
|
137
|
+
| `typescript/no-confusing-non-null-assertion` | warn | Prevents confusing ! placements | ✅ |
|
|
138
|
+
| `typescript/no-duplicate-type-constituents` | warn | Prevents duplicate union/intersection types | ✅ |
|
|
139
|
+
| `typescript/no-unnecessary-boolean-literal-compare` | warn | Simplifies boolean comparisons | ✅ |
|
|
140
|
+
| `typescript/prefer-literal-enum-member` | warn | Requires literal values for enum members | ❌ |
|
|
141
|
+
| `typescript/prefer-namespace-keyword` | warn | Prefers namespace over module keyword | ✅ |
|
|
142
|
+
| `typescript/prefer-return-this-type` | warn | Improves method chaining types | ❌ |
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Unicorn Rules (Modern JavaScript)
|
|
147
|
+
|
|
148
|
+
### Critical Unicorn Rules (Error Level)
|
|
149
|
+
|
|
150
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
151
|
+
|------|-------|---------|----------|
|
|
152
|
+
| `unicorn/prefer-node-protocol` | error | Requires node: protocol for imports | ✅ |
|
|
153
|
+
| `unicorn/prefer-array-some` | error | Prefers .some() over .find() for boolean checks | ✅ |
|
|
154
|
+
| `unicorn/prefer-array-find` | error | Prefers .find() over .filter()[0] | ✅ |
|
|
155
|
+
| `unicorn/prefer-includes` | error | Prefers .includes() over .indexOf() !== -1 | ✅ |
|
|
156
|
+
| `unicorn/prefer-string-starts-ends-with` | error | Prefers .startsWith()/.endsWith() | ✅ |
|
|
157
|
+
| `unicorn/throw-new-error` | error | Requires `new Error()` for throwing | ✅ |
|
|
158
|
+
| `unicorn/error-message` | error | Requires error messages | ❌ |
|
|
159
|
+
| `unicorn/no-instanceof-array` | error | Requires Array.isArray() | ✅ |
|
|
160
|
+
| `unicorn/prefer-optional-catch-binding` | error | Allows optional catch binding | ✅ |
|
|
161
|
+
| `unicorn/new-for-builtins` | error | Requires new for built-in constructors | ✅ |
|
|
162
|
+
| `unicorn/no-instanceof-builtins` | error | Prevents instanceof for built-ins | ✅ |
|
|
163
|
+
| `unicorn/no-new-buffer` | error | Prevents deprecated Buffer constructor | ✅ |
|
|
164
|
+
|
|
165
|
+
### Unicorn Best Practices (Warning Level)
|
|
166
|
+
|
|
167
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
168
|
+
|------|-------|---------|----------|
|
|
169
|
+
| `unicorn/prefer-default-parameters` | warn | Prefers default parameters | ✅ |
|
|
170
|
+
| `unicorn/prefer-spread` | warn | Prefers spread operator | ✅ |
|
|
171
|
+
| `unicorn/prefer-ternary` | warn | Prefers ternary over if/else for assignment | ✅ |
|
|
172
|
+
| `unicorn/consistent-function-scoping` | warn | Moves functions to appropriate scope | ❌ |
|
|
173
|
+
| `unicorn/no-useless-undefined` | warn | Prevents explicit undefined returns | ✅ |
|
|
174
|
+
| `unicorn/no-nested-ternary` | warn | Prevents nested ternary expressions | ❌ |
|
|
175
|
+
| `unicorn/prefer-at` | warn | Prefers .at() for array access | ✅ |
|
|
176
|
+
| `unicorn/prefer-array-flat-map` | warn | Prefers .flatMap() over .map().flat() | ✅ |
|
|
177
|
+
| `unicorn/prefer-array-index-of` | warn | Prefers .indexOf() over .findIndex() for primitives | ✅ |
|
|
178
|
+
| `unicorn/prefer-set-has` | warn | Prefers Set.has() over array.includes() | ❌ |
|
|
179
|
+
| `unicorn/prefer-string-slice` | warn | Prefers .slice() over .substr() | ✅ |
|
|
180
|
+
| `unicorn/prefer-string-replace-all` | warn | Prefers .replaceAll() over regex replace | ✅ |
|
|
181
|
+
| `unicorn/prefer-string-trim-start-end` | warn | Prefers .trimStart()/.trimEnd() | ✅ |
|
|
182
|
+
| `unicorn/prefer-math-min-max` | warn | Prefers Math.min/max over ternary | ✅ |
|
|
183
|
+
| `unicorn/prefer-number-properties` | warn | Prefers Number.isNaN() over global | ✅ |
|
|
184
|
+
| `unicorn/prefer-object-from-entries` | warn | Prefers Object.fromEntries() | ❌ |
|
|
185
|
+
| `unicorn/number-literal-case` | warn | Enforces lowercase for number literals | ✅ |
|
|
186
|
+
| `unicorn/no-lonely-if` | warn | Prevents lonely if in else block | ✅ |
|
|
187
|
+
| `unicorn/no-useless-spread` | warn | Prevents unnecessary spread | ✅ |
|
|
188
|
+
| `unicorn/no-useless-fallback-in-spread` | warn | Prevents useless fallback in spread | ✅ |
|
|
189
|
+
| `unicorn/no-useless-length-check` | warn | Simplifies .length checks | ✅ |
|
|
190
|
+
| `unicorn/no-useless-promise-resolve-reject` | warn | Simplifies Promise patterns | ✅ |
|
|
191
|
+
| `unicorn/prefer-modern-math-apis` | warn | Prefers modern Math methods | ✅ |
|
|
192
|
+
| `unicorn/prefer-native-coercion-functions` | warn | Prefers native coercion | ✅ |
|
|
193
|
+
| `unicorn/prefer-add-event-listener` | warn | Prefers addEventListener | ✅ |
|
|
194
|
+
| `unicorn/prefer-dom-node-append` | warn | Prefers .append() over .appendChild() | ✅ |
|
|
195
|
+
| `unicorn/prefer-dom-node-remove` | warn | Prefers .remove() over .removeChild() | ✅ |
|
|
196
|
+
| `unicorn/prefer-dom-node-text-content` | warn | Prefers .textContent over .innerText | ✅ |
|
|
197
|
+
| `unicorn/prefer-query-selector` | warn | Prefers querySelector | ✅ |
|
|
198
|
+
| `unicorn/prefer-reflect-apply` | warn | Prefers Reflect.apply() | ❌ |
|
|
199
|
+
| `unicorn/prefer-regexp-test` | warn | Prefers .test() over .match() | ✅ |
|
|
200
|
+
| `unicorn/prefer-prototype-methods` | warn | Prefers prototype methods | ❌ |
|
|
201
|
+
| `unicorn/prefer-code-point` | warn | Prefers .codePointAt() | ✅ |
|
|
202
|
+
| `unicorn/prefer-date-now` | warn | Prefers Date.now() over new Date() | ✅ |
|
|
203
|
+
| `unicorn/prefer-array-flat` | warn | Prefers .flat() over array flattening | ✅ |
|
|
204
|
+
| `unicorn/escape-case` | warn | Enforces lowercase escape sequences | ✅ |
|
|
205
|
+
| `unicorn/no-console-spaces` | warn | Prevents spaces in console calls | ✅ |
|
|
206
|
+
| `unicorn/no-hex-escape` | warn | Prevents hex escapes | ✅ |
|
|
207
|
+
| `unicorn/no-new-array` | warn | Prevents new Array() | ✅ |
|
|
208
|
+
| `unicorn/no-typeof-undefined` | warn | Simplifies typeof checks | ✅ |
|
|
209
|
+
| `unicorn/no-unreadable-array-destructuring` | warn | Prevents unclear destructuring | ❌ |
|
|
210
|
+
| `unicorn/no-unreadable-iife` | warn | Prevents unclear IIFEs | ❌ |
|
|
211
|
+
| `unicorn/consistent-empty-array-spread` | warn | Enforces consistent empty array spread | ✅ |
|
|
212
|
+
| `unicorn/prefer-structured-clone` | warn | Prefers structuredClone() | ❌ |
|
|
213
|
+
| `unicorn/prefer-type-error` | warn | Requires TypeError for type errors | ❌ |
|
|
214
|
+
| `unicorn/relative-url-style` | warn | Enforces relative URL style | ✅ |
|
|
215
|
+
| `unicorn/require-array-join-separator` | warn | Requires explicit separator in .join() | ❌ |
|
|
216
|
+
| `unicorn/require-number-to-fixed-digits-argument` | warn | Requires argument in .toFixed() | ❌ |
|
|
217
|
+
|
|
218
|
+
**Special Unicorn Rules:**
|
|
219
|
+
- `unicorn/no-thenable` - Error level, but disabled via overrides for validation files (`**/validations/**/*.ts`, `**/*validation*.ts`) to allow Joi/Yup `.then()` syntax
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Import Rules
|
|
224
|
+
|
|
225
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
226
|
+
|------|-------|---------|----------|
|
|
227
|
+
| `import/no-duplicates` | error | Prevents duplicate imports | ✅ |
|
|
228
|
+
| `import/no-self-import` | error | Prevents importing itself | ❌ |
|
|
229
|
+
| `import/no-cycle` | warn | Detects circular dependencies | ❌ |
|
|
230
|
+
| `import/named` | error | Ensures named imports exist | ❌ |
|
|
231
|
+
| `import/namespace` | error | Ensures namespace imports are valid | ❌ |
|
|
232
|
+
| `import/default` | error | Ensures default export exists | ❌ |
|
|
233
|
+
| `import/no-named-as-default` | warn | Warns when importing default as named | ❌ |
|
|
234
|
+
| `import/no-named-as-default-member` | warn | Warns on default import property access | ❌ |
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Jest Rules
|
|
239
|
+
|
|
240
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
241
|
+
|------|-------|---------|----------|
|
|
242
|
+
| `jest/no-conditional-expect` | error | Prevents expect in conditionals | ❌ |
|
|
243
|
+
| `jest/no-focused-tests` | error | Prevents .only tests | ✅ |
|
|
244
|
+
| `jest/no-identical-title` | error | Prevents duplicate test names | ❌ |
|
|
245
|
+
| `jest/no-jasmine-globals` | error | Prevents Jasmine globals | ✅ |
|
|
246
|
+
| `jest/no-mocks-import` | error | Prevents importing from __mocks__ | ❌ |
|
|
247
|
+
| `jest/no-standalone-expect` | error | Prevents expect outside tests | ❌ |
|
|
248
|
+
| `jest/valid-describe-callback` | error | Validates describe callbacks | ❌ |
|
|
249
|
+
| `jest/valid-expect` | error | Validates expect usage | ❌ |
|
|
250
|
+
| `jest/expect-expect` | warn | Ensures tests have assertions | ❌ |
|
|
251
|
+
| `jest/no-alias-methods` | warn | Prevents Jest alias methods | ✅ |
|
|
252
|
+
| `jest/no-commented-out-tests` | warn | Detects commented tests | ❌ |
|
|
253
|
+
| `jest/no-disabled-tests` | warn | Detects disabled tests | ❌ |
|
|
254
|
+
| `jest/no-test-prefixes` | warn | Prevents fdescribe/fit | ✅ |
|
|
255
|
+
| `jest/valid-title` | warn | Validates test titles | ✅ |
|
|
256
|
+
| `jest/prefer-hooks-on-top` | warn | Places hooks at top | ❌ |
|
|
257
|
+
| `jest/prefer-spy-on` | warn | Prefers jest.spyOn() | ✅ |
|
|
258
|
+
| `jest/prefer-todo` | warn | Prefers test.todo() | ✅ |
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## OXC Custom Rules
|
|
263
|
+
|
|
264
|
+
Unique performance and correctness checks created by the Oxc team:
|
|
265
|
+
|
|
266
|
+
| Rule | Level | Purpose | Auto-Fix |
|
|
267
|
+
|------|-------|---------|----------|
|
|
268
|
+
| `oxc/bad-array-method-on-arguments` | error | Prevents array methods on arguments | ❌ |
|
|
269
|
+
| `oxc/bad-bitwise-operator` | error | Detects misused bitwise operators | ❌ |
|
|
270
|
+
| `oxc/bad-char-at-comparison` | error | Detects incorrect charAt comparisons | ✅ |
|
|
271
|
+
| `oxc/bad-comparison-sequence` | error | Detects incorrect comparison chains | ✅ |
|
|
272
|
+
| `oxc/bad-min-max-func` | error | Detects incorrect Math.min/max usage | ✅ |
|
|
273
|
+
| `oxc/bad-object-literal-comparison` | error | Detects object literal comparisons | ❌ |
|
|
274
|
+
| `oxc/bad-replace-all-arg` | error | Detects incorrect replaceAll arguments | ❌ |
|
|
275
|
+
| `oxc/const-comparisons` | error | Detects always-true/false comparisons | ✅ |
|
|
276
|
+
| `oxc/double-comparisons` | error | Simplifies redundant comparisons | ✅ |
|
|
277
|
+
| `oxc/misrefactored-assign-op` | error | Detects misrefactored assignments | ✅ |
|
|
278
|
+
| `oxc/missing-throw` | error | Detects Error objects not thrown | ✅ |
|
|
279
|
+
| `oxc/number-arg-out-of-range` | error | Detects out-of-range number arguments | ❌ |
|
|
280
|
+
| `oxc/uninvoked-array-callback` | error | Detects callback not invoked | ❌ |
|
|
281
|
+
| `oxc/approx-constant` | warn | Suggests built-in constants | ❌ |
|
|
282
|
+
| `oxc/erasing-op` | warn | Detects operations that erase values | ✅ |
|
|
283
|
+
| `oxc/no-accumulating-spread` | warn | Warns on performance issues with spread | ❌ |
|
|
284
|
+
| `oxc/only-used-in-recursion` | warn | Detects variables only used recursively | ❌ |
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
# Oxfmt Configuration
|
|
289
|
+
|
|
290
|
+
Oxfmt v0.28.0 has **100% Prettier conformance** and supports all major Prettier options.
|
|
291
|
+
|
|
292
|
+
## Configured Options
|
|
293
|
+
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"semi": true,
|
|
297
|
+
"trailingComma": "all",
|
|
298
|
+
"singleQuote": true,
|
|
299
|
+
"printWidth": 120,
|
|
300
|
+
"tabWidth": 2,
|
|
301
|
+
"useTabs": false,
|
|
302
|
+
"arrowParens": "always",
|
|
303
|
+
"endOfLine": "lf"
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Option Descriptions
|
|
308
|
+
|
|
309
|
+
| Option | Value | Purpose |
|
|
310
|
+
|--------|-------|---------|
|
|
311
|
+
| `semi` | `true` | Add semicolons at the end of statements |
|
|
312
|
+
| `trailingComma` | `"all"` | Add trailing commas wherever possible |
|
|
313
|
+
| `singleQuote` | `true` | Use single quotes instead of double quotes |
|
|
314
|
+
| `printWidth` | `120` | Wrap lines at 120 characters |
|
|
315
|
+
| `tabWidth` | `2` | Use 2 spaces for indentation |
|
|
316
|
+
| `useTabs` | `false` | Use spaces instead of tabs |
|
|
317
|
+
| `arrowParens` | `"always"` | Always include parens around arrow function params |
|
|
318
|
+
| `endOfLine` | `"lf"` | Use Unix line endings (LF) |
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
# Rule Severity Levels
|
|
323
|
+
|
|
324
|
+
## Error (Block CI/Pull Requests)
|
|
325
|
+
|
|
326
|
+
Rules marked as `error` will:
|
|
327
|
+
- Fail CI builds
|
|
328
|
+
- Block pull requests
|
|
329
|
+
- Must be fixed before merging
|
|
330
|
+
|
|
331
|
+
**Examples:**
|
|
332
|
+
- `no-console` - Production code safety
|
|
333
|
+
- `no-debugger` - Production code safety
|
|
334
|
+
- `typescript/no-floating-promises` - Prevents silent failures
|
|
335
|
+
- `eqeqeq` - Type safety
|
|
336
|
+
|
|
337
|
+
## Warning (Should Fix)
|
|
338
|
+
|
|
339
|
+
Rules marked as `warn` will:
|
|
340
|
+
- Show in linting output
|
|
341
|
+
- Not block CI/pull requests
|
|
342
|
+
- Should be addressed when convenient
|
|
343
|
+
|
|
344
|
+
**Examples:**
|
|
345
|
+
- `typescript/no-explicit-any` - Type safety (allowed in tests)
|
|
346
|
+
- `no-await-in-loop` - Performance suggestion
|
|
347
|
+
- `prefer-const` - Best practice
|
|
348
|
+
- Most Unicorn rules - Modern JavaScript patterns
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
# Auto-Fix Categories
|
|
353
|
+
|
|
354
|
+
Oxlint categorizes auto-fixes into three types:
|
|
355
|
+
|
|
356
|
+
## Safe Fixes (`--fix`)
|
|
357
|
+
Changes that do NOT alter program behavior:
|
|
358
|
+
- Formatting fixes
|
|
359
|
+
- Adding missing semicolons
|
|
360
|
+
- Removing unused imports
|
|
361
|
+
- Simplifying boolean expressions
|
|
362
|
+
|
|
363
|
+
## Suggestions (`--fix-suggestions`)
|
|
364
|
+
Changes that MAY alter behavior:
|
|
365
|
+
- Converting `var` to `const`/`let`
|
|
366
|
+
- Simplifying conditional logic
|
|
367
|
+
- Optimizing array methods
|
|
368
|
+
|
|
369
|
+
## Dangerous Fixes (`--fix-dangerously`)
|
|
370
|
+
Aggressive changes that may break code:
|
|
371
|
+
- Removing unused function parameters
|
|
372
|
+
- Aggressive dead code removal
|
|
373
|
+
|
|
374
|
+
**Usage:**
|
|
375
|
+
```bash
|
|
376
|
+
npm run lint:fix # Safe fixes only
|
|
377
|
+
npm run lint:fix-all # All fixes (use carefully)
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
# Summary
|
|
383
|
+
|
|
384
|
+
- **Total Rules**: 140+ enabled from 665+ available
|
|
385
|
+
- **Error Rules**: ~50 (critical safety and correctness)
|
|
386
|
+
- **Warning Rules**: ~90 (best practices and modern patterns)
|
|
387
|
+
- **Auto-Fixable**: ~110 rules support automatic fixes
|
|
388
|
+
- **Performance**: 37x faster than ESLint, 30x faster than Prettier
|
|
389
|
+
- **Compatibility**: 100% Prettier conformance with Oxfmt v0.28.0
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
**Last Updated**: 2026-02-10
|
|
394
|
+
**Package Version**: @autofleet/lint v2.0.0
|
|
395
|
+
**Oxlint Version**: v1.43.0
|
|
396
|
+
**Oxfmt Version**: v0.28.0
|