@ntsim/oxlint-config 0.2.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/README.md +95 -0
- package/dist/index.d.mts +696 -0
- package/dist/index.mjs +780 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# oxlint-config
|
|
2
|
+
|
|
3
|
+
An [oxlint](https://oxc.rs/docs/guide/usage/linter) configuration providing composable lint presets for JavaScript/TypeScript projects using React, Vitest, and Testing Library.
|
|
4
|
+
|
|
5
|
+
The main configuration is derived from the Airbnb ESLint config with modifications to be more relaxed. Notably, some redundant / very old rules have also been removed.
|
|
6
|
+
|
|
7
|
+
Overall, this is still quite a **strict** and **opinionated** configuration but provides lots of safeguards against common mistakes and bad conventions, and ultimately helps to provide consistency to a codebase.
|
|
8
|
+
|
|
9
|
+
## Presets
|
|
10
|
+
|
|
11
|
+
| Preset | Description |
|
|
12
|
+
| ---------------------- | --------------------------------------------------------------------------------- |
|
|
13
|
+
| `baseConfig` | Core rules — best practices, imports, promises, unicorn, and oxc |
|
|
14
|
+
| `typescriptConfig` | TypeScript-specific rules (scoped to `.ts`/`.tsx`/`.cts`/`.mts`/`.d.ts`) |
|
|
15
|
+
| `reactConfig` | React patterns, hooks, and jsx-a11y accessibility rules |
|
|
16
|
+
| `vitestConfig` | Test quality rules (scoped to `*.{test,spec}.*` files) |
|
|
17
|
+
| `testingLibraryConfig` | Testing Library and jest-dom best practices (scoped to `*.{test,spec}.{tsx,jsx}`) |
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Install the package, then extend the presets you need in your `oxlint.config.ts`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { defineConfig } from "oxlint";
|
|
25
|
+
import { baseConfig, typescriptConfig, reactConfig } from "oxlint-config";
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
extends: [baseConfig, typescriptConfig, reactConfig],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Development
|
|
33
|
+
|
|
34
|
+
### Prerequisites
|
|
35
|
+
|
|
36
|
+
- Node.js v24+ (version pinned in `package.json`, `.nvmrc` and `mise.toml`)
|
|
37
|
+
- [pnpm v11+](https://pnpm.io/) (version pinned in `package.json` — do not use other package managers)
|
|
38
|
+
|
|
39
|
+
We recommended installing the correct Node version for the project with [mise](https://mise.en.dev/) or [fnm](https://github.com/Schniz/fnm).
|
|
40
|
+
|
|
41
|
+
Install the correct `pnpm` version using corepack:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
corepack enable
|
|
45
|
+
corepack install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Setup
|
|
49
|
+
|
|
50
|
+
1. Install dependencies:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Scripts
|
|
57
|
+
|
|
58
|
+
| Command | Description |
|
|
59
|
+
| ----------------------- | -------------------------------- |
|
|
60
|
+
| `pnpm run lint` | Run oxlint against the repo |
|
|
61
|
+
| `pnpm run lint:fix` | Fix any auto-fixable lints |
|
|
62
|
+
| `pnpm run format` | Format with oxfmt |
|
|
63
|
+
| `pnpm run format:check` | Check formatting without writing |
|
|
64
|
+
| `pnpm run types` | Type-check with `tsc --noEmit` |
|
|
65
|
+
|
|
66
|
+
### Project layout
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
src/
|
|
70
|
+
index.ts # Public entry — re-exports all presets
|
|
71
|
+
presets/
|
|
72
|
+
base.ts # Base/JS rules
|
|
73
|
+
typescript.ts # TypeScript rules
|
|
74
|
+
react.ts # React + a11y rules
|
|
75
|
+
vitest.ts # Vitest test rules
|
|
76
|
+
testingLibrary.ts # Testing Library + jest-dom rules
|
|
77
|
+
utils/
|
|
78
|
+
globs.ts # Shared file-glob patterns
|
|
79
|
+
confusingBrowserGlobals.ts # Browser globals that should use window.*
|
|
80
|
+
oxlint.config.ts # This repo's own lint config
|
|
81
|
+
tsconfig.json # Strict TS config (no emit, bundler resolution)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Conventions
|
|
85
|
+
|
|
86
|
+
- Relative imports must include the `.ts` extension (required by `allowImportingTsExtensions` + ESM resolution).
|
|
87
|
+
- Rule severity follows the ESLint-compatible shape: `"error" | "warn" | "off"` or `[severity, options]`.
|
|
88
|
+
- Keep rules alphabetized within a section when practical.
|
|
89
|
+
- Prefer editing existing presets over creating new files.
|
|
90
|
+
|
|
91
|
+
### Adding a new preset
|
|
92
|
+
|
|
93
|
+
1. Create `src/presets/<name>.ts` exporting a `defineConfig({...})` from `oxlint`.
|
|
94
|
+
2. Re-export it from `src/index.ts`.
|
|
95
|
+
3. If the preset should apply to this repo, add it to the `extends` array in `oxlint.config.ts`.
|