@letstri/oxc-config 0.2.1 → 0.3.1
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 +17 -16
- package/dist/index.d.mts +17 -7
- package/dist/index.mjs +20 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@ Opinionated, shared [oxlint](https://oxc.rs/docs/guide/usage/linter.html) and [o
|
|
|
4
4
|
|
|
5
5
|
> [!NOTE]
|
|
6
6
|
> This is an **opinionated** config — it ships a curated set of rules and
|
|
7
|
-
> formatting defaults meant to work out of the box. Override
|
|
8
|
-
> disagree with
|
|
7
|
+
> formatting defaults meant to work out of the box. [Override](#overrides)
|
|
8
|
+
> anything you disagree with.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -44,7 +44,7 @@ Set up @letstri/oxc-config (oxlint + oxfmt) in this project:
|
|
|
44
44
|
- "format:check": "oxfmt --check"
|
|
45
45
|
6. Framework plugins auto-enable from the nearest package.json. If a framework
|
|
46
46
|
dep (react/vue/next/vitest/jest/typescript) lives in a nested workspace,
|
|
47
|
-
enable it manually, e.g. `oxlintConfig({
|
|
47
|
+
enable it manually, e.g. `oxlintConfig({ plugins: ['vue'] })`.
|
|
48
48
|
7. Add the VS Code and Zed editor settings from the @letstri/oxc-config README.
|
|
49
49
|
8. Run `pnpm lint` and `pnpm format` and fix anything reported.
|
|
50
50
|
````
|
|
@@ -96,33 +96,34 @@ export default oxlintConfig({
|
|
|
96
96
|
|
|
97
97
|
### Overrides
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
config via [defu](https://github.com/unjs/defu)
|
|
99
|
+
`oxlintConfig` / `oxfmtConfig` accept **any number of config objects**, all
|
|
100
|
+
deep-merged over the base config via [defu](https://github.com/unjs/defu) (arrays
|
|
101
|
+
are concatenated, so plugins from different pieces combine instead of
|
|
102
|
+
overwriting):
|
|
101
103
|
|
|
102
104
|
```ts
|
|
103
|
-
export default oxlintConfig({
|
|
104
|
-
rules: {
|
|
105
|
-
'no-console': 'off',
|
|
106
|
-
},
|
|
107
|
-
})
|
|
105
|
+
export default oxlintConfig({ rules: { 'no-console': 'off' } }, { plugins: ['vue'] })
|
|
108
106
|
```
|
|
109
107
|
|
|
110
108
|
### Tailwind
|
|
111
109
|
|
|
112
110
|
`tailwind({ entryPoint })` returns a config chunk for
|
|
113
111
|
[`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss).
|
|
114
|
-
|
|
112
|
+
Pass it as an argument to `oxlintConfig`:
|
|
115
113
|
|
|
116
114
|
```ts
|
|
117
115
|
import { oxlintConfig, tailwind } from '@letstri/oxc-config'
|
|
118
116
|
|
|
119
|
-
export default oxlintConfig(
|
|
120
|
-
|
|
121
|
-
})
|
|
117
|
+
export default oxlintConfig(
|
|
118
|
+
{ plugins: ['react', 'jsx-a11y'] },
|
|
119
|
+
tailwind({ entryPoint: 'app/globals.css' }),
|
|
120
|
+
)
|
|
122
121
|
```
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
Because arguments are merged (not spread), Tailwind's plugins combine with the
|
|
124
|
+
ones above rather than overwriting them. `entryPoint` (required) is your Tailwind
|
|
125
|
+
entry CSS, so the plugin can resolve class names. The plugin is an **optional
|
|
126
|
+
peer dependency** — install it yourself:
|
|
126
127
|
|
|
127
128
|
```bash
|
|
128
129
|
pnpm add -D eslint-plugin-better-tailwindcss
|
package/dist/index.d.mts
CHANGED
|
@@ -8,7 +8,10 @@ type OxlintOptions$1 = Parameters<typeof defineConfig>[0];
|
|
|
8
8
|
* Plugins are auto-enabled by detecting their package (`typescript`, `react`,
|
|
9
9
|
* `vue`, `next`, `vitest`, `jest`) in the nearest `package.json`. To enable a
|
|
10
10
|
* plugin whose dependency lives elsewhere — e.g. a nested workspace like
|
|
11
|
-
* `apps/web/package.json` — add it through `
|
|
11
|
+
* `apps/web/package.json` — add it through `plugins`.
|
|
12
|
+
*
|
|
13
|
+
* Pass any number of config objects; they are deep-merged (arrays concatenated),
|
|
14
|
+
* so pieces like {@link tailwind} compose without clobbering each other.
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```ts
|
|
@@ -22,15 +25,22 @@ type OxlintOptions$1 = Parameters<typeof defineConfig>[0];
|
|
|
22
25
|
* ```
|
|
23
26
|
* @example
|
|
24
27
|
* ```ts
|
|
25
|
-
* //
|
|
26
|
-
* export default oxlintConfig(
|
|
28
|
+
* // compose Tailwind — its plugins merge with the ones above, not overwrite
|
|
29
|
+
* export default oxlintConfig(
|
|
30
|
+
* { plugins: ['react', 'jsx-a11y'] },
|
|
31
|
+
* tailwind({ entryPoint: 'app/globals.css' }),
|
|
32
|
+
* )
|
|
27
33
|
* ```
|
|
28
34
|
*/
|
|
29
|
-
declare function oxlintConfig(overrides
|
|
35
|
+
declare function oxlintConfig(...overrides: OxlintOptions$1[]): OxlintOptions$1;
|
|
30
36
|
//#endregion
|
|
31
37
|
//#region src/oxfmt.d.ts
|
|
32
38
|
type OxfmtOptions = Parameters<typeof defineConfig$1>[0];
|
|
33
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Build an oxfmt config. Pass any number of config objects; they are deep-merged
|
|
41
|
+
* over the base config via defu.
|
|
42
|
+
*/
|
|
43
|
+
declare function oxfmtConfig(...overrides: OxfmtOptions[]): OxfmtOptions;
|
|
34
44
|
//#endregion
|
|
35
45
|
//#region src/tailwind.d.ts
|
|
36
46
|
type OxlintOptions = Parameters<typeof defineConfig>[0];
|
|
@@ -49,10 +59,10 @@ interface TailwindOptions {
|
|
|
49
59
|
}
|
|
50
60
|
/**
|
|
51
61
|
* Tailwind linting via [`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss).
|
|
52
|
-
*
|
|
62
|
+
* Pass the result as an argument to `oxlintConfig`:
|
|
53
63
|
*
|
|
54
64
|
* ```ts
|
|
55
|
-
* export default oxlintConfig(
|
|
65
|
+
* export default oxlintConfig(tailwind({ entryPoint: 'app/globals.css' }))
|
|
56
66
|
* ```
|
|
57
67
|
*
|
|
58
68
|
* The plugin is an optional peer dependency — install it yourself
|
package/dist/index.mjs
CHANGED
|
@@ -534,7 +534,10 @@ function resolvePlugins(cwd) {
|
|
|
534
534
|
* Plugins are auto-enabled by detecting their package (`typescript`, `react`,
|
|
535
535
|
* `vue`, `next`, `vitest`, `jest`) in the nearest `package.json`. To enable a
|
|
536
536
|
* plugin whose dependency lives elsewhere — e.g. a nested workspace like
|
|
537
|
-
* `apps/web/package.json` — add it through `
|
|
537
|
+
* `apps/web/package.json` — add it through `plugins`.
|
|
538
|
+
*
|
|
539
|
+
* Pass any number of config objects; they are deep-merged (arrays concatenated),
|
|
540
|
+
* so pieces like {@link tailwind} compose without clobbering each other.
|
|
538
541
|
*
|
|
539
542
|
* @example
|
|
540
543
|
* ```ts
|
|
@@ -548,34 +551,42 @@ function resolvePlugins(cwd) {
|
|
|
548
551
|
* ```
|
|
549
552
|
* @example
|
|
550
553
|
* ```ts
|
|
551
|
-
* //
|
|
552
|
-
* export default oxlintConfig(
|
|
554
|
+
* // compose Tailwind — its plugins merge with the ones above, not overwrite
|
|
555
|
+
* export default oxlintConfig(
|
|
556
|
+
* { plugins: ['react', 'jsx-a11y'] },
|
|
557
|
+
* tailwind({ entryPoint: 'app/globals.css' }),
|
|
558
|
+
* )
|
|
553
559
|
* ```
|
|
554
560
|
*/
|
|
555
|
-
function oxlintConfig(overrides
|
|
556
|
-
return defu(overrides, { plugins: resolvePlugins(process.cwd()) }, baseOxlintConfig);
|
|
561
|
+
function oxlintConfig(...overrides) {
|
|
562
|
+
return defu({}, ...overrides, { plugins: resolvePlugins(process.cwd()) }, baseOxlintConfig);
|
|
557
563
|
}
|
|
558
564
|
//#endregion
|
|
559
565
|
//#region src/oxfmt.ts
|
|
560
566
|
const baseOxfmtConfig = defineConfig$1({
|
|
567
|
+
printWidth: 100,
|
|
561
568
|
singleQuote: true,
|
|
562
569
|
semi: false,
|
|
563
570
|
arrowParens: "avoid",
|
|
564
571
|
sortImports: true,
|
|
565
572
|
quoteProps: "consistent"
|
|
566
573
|
});
|
|
567
|
-
|
|
568
|
-
|
|
574
|
+
/**
|
|
575
|
+
* Build an oxfmt config. Pass any number of config objects; they are deep-merged
|
|
576
|
+
* over the base config via defu.
|
|
577
|
+
*/
|
|
578
|
+
function oxfmtConfig(...overrides) {
|
|
579
|
+
return defu({}, ...overrides, baseOxfmtConfig);
|
|
569
580
|
}
|
|
570
581
|
//#endregion
|
|
571
582
|
//#region src/tailwind.ts
|
|
572
583
|
const TAILWIND_PLUGIN = "eslint-plugin-better-tailwindcss";
|
|
573
584
|
/**
|
|
574
585
|
* Tailwind linting via [`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss).
|
|
575
|
-
*
|
|
586
|
+
* Pass the result as an argument to `oxlintConfig`:
|
|
576
587
|
*
|
|
577
588
|
* ```ts
|
|
578
|
-
* export default oxlintConfig(
|
|
589
|
+
* export default oxlintConfig(tailwind({ entryPoint: 'app/globals.css' }))
|
|
579
590
|
* ```
|
|
580
591
|
*
|
|
581
592
|
* The plugin is an optional peer dependency — install it yourself
|