@letstri/oxc-config 0.2.0 → 0.2.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 CHANGED
@@ -109,7 +109,7 @@ export default oxlintConfig({
109
109
 
110
110
  ### Tailwind
111
111
 
112
- `tailwind(options?)` returns a config chunk for
112
+ `tailwind({ entryPoint })` returns a config chunk for
113
113
  [`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss).
114
114
  Spread it into `oxlintConfig`:
115
115
 
@@ -121,14 +121,14 @@ export default oxlintConfig({
121
121
  })
122
122
  ```
123
123
 
124
- `entryPoint` is your Tailwind entry CSS, so the plugin can resolve class names. The plugin is an **optional peer dependency** — install it yourself:
124
+ `entryPoint` (required) is your Tailwind entry CSS, so the plugin can resolve
125
+ class names. The plugin is an **optional peer dependency** — install it yourself:
125
126
 
126
127
  ```bash
127
128
  pnpm add -D eslint-plugin-better-tailwindcss
128
129
  ```
129
130
 
130
- If the plugin is missing, `tailwind()` logs a reminder and returns an empty
131
- config instead of crashing oxlint.
131
+ If the plugin is missing, `tailwind()` throws with an install hint.
132
132
 
133
133
  ## Editor setup
134
134
 
package/dist/index.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import { defineConfig } from "oxfmt";
2
- import { defineConfig as defineConfig$1 } from "oxlint";
3
- //#region src/index.d.ts
4
- type OxlintOptions = Parameters<typeof defineConfig$1>[0];
5
- type OxfmtOptions = Parameters<typeof defineConfig>[0];
1
+ import { defineConfig } from "oxlint";
2
+ import { defineConfig as defineConfig$1 } from "oxfmt";
3
+ //#region src/oxlint.d.ts
4
+ type OxlintOptions$1 = Parameters<typeof defineConfig>[0];
6
5
  /**
7
6
  * Build an oxlint config.
8
7
  *
@@ -11,8 +10,6 @@ type OxfmtOptions = Parameters<typeof defineConfig>[0];
11
10
  * plugin whose dependency lives elsewhere — e.g. a nested workspace like
12
11
  * `apps/web/package.json` — add it through `overrides.plugins`.
13
12
  *
14
- * `overrides` is deep-merged over the base config via defu.
15
- *
16
13
  * @example
17
14
  * ```ts
18
15
  * // auto-detect from the current package.json
@@ -26,10 +23,17 @@ type OxfmtOptions = Parameters<typeof defineConfig>[0];
26
23
  * @example
27
24
  * ```ts
28
25
  * // add Tailwind linting
29
- * export default oxlintConfig({ ...tailwind('app/globals.css') })
26
+ * export default oxlintConfig({ ...tailwind({ entryPoint: 'app/globals.css' }) })
30
27
  * ```
31
28
  */
32
- declare function oxlintConfig(overrides?: OxlintOptions): OxlintOptions;
29
+ declare function oxlintConfig(overrides?: OxlintOptions$1): OxlintOptions$1;
30
+ //#endregion
31
+ //#region src/oxfmt.d.ts
32
+ type OxfmtOptions = Parameters<typeof defineConfig$1>[0];
33
+ declare function oxfmtConfig(overrides?: OxfmtOptions): OxfmtOptions;
34
+ //#endregion
35
+ //#region src/tailwind.d.ts
36
+ type OxlintOptions = Parameters<typeof defineConfig>[0];
33
37
  interface TailwindOptions {
34
38
  /**
35
39
  * Path to the Tailwind entry CSS. Required — the plugin needs it to resolve
@@ -45,17 +49,16 @@ interface TailwindOptions {
45
49
  }
46
50
  /**
47
51
  * Tailwind linting via [`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss).
48
- * Spread the result into {@link oxlintConfig}:
52
+ * Spread the result into `oxlintConfig`:
49
53
  *
50
54
  * ```ts
51
55
  * export default oxlintConfig({ ...tailwind({ entryPoint: 'app/globals.css' }) })
52
56
  * ```
53
57
  *
54
58
  * The plugin is an optional peer dependency — install it yourself
55
- * (`pnpm add -D eslint-plugin-better-tailwindcss`). If it is missing, a warning
56
- * is logged and an empty config is returned so oxlint does not crash.
59
+ * (`pnpm add -D eslint-plugin-better-tailwindcss`). If it is missing, an error
60
+ * is thrown.
57
61
  */
58
62
  declare function tailwind({ entryPoint, cwd }: TailwindOptions): OxlintOptions;
59
- declare function oxfmtConfig(overrides?: OxfmtOptions): OxfmtOptions;
60
63
  //#endregion
61
64
  export { oxfmtConfig, oxlintConfig, tailwind };
package/dist/index.mjs CHANGED
@@ -1,11 +1,25 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
1
  import process from "node:process";
4
2
  import { defu } from "defu";
5
- import { defineConfig } from "oxfmt";
6
- import { defineConfig as defineConfig$1 } from "oxlint";
7
- //#region src/index.ts
8
- const baseOxlintConfig = defineConfig$1({
3
+ import { defineConfig } from "oxlint";
4
+ import { readFileSync } from "node:fs";
5
+ import { resolve } from "node:path";
6
+ import { defineConfig as defineConfig$1 } from "oxfmt";
7
+ //#region src/utils.ts
8
+ function getInstalledPackages(cwd) {
9
+ const names = /* @__PURE__ */ new Set();
10
+ try {
11
+ const pkg = JSON.parse(readFileSync(resolve(cwd, "package.json"), "utf-8"));
12
+ for (const field of [
13
+ pkg.dependencies,
14
+ pkg.devDependencies,
15
+ pkg.peerDependencies
16
+ ]) for (const name of Object.keys(field ?? {})) names.add(name);
17
+ } catch {}
18
+ return names;
19
+ }
20
+ //#endregion
21
+ //#region src/oxlint.ts
22
+ const baseOxlintConfig = defineConfig({
9
23
  categories: {
10
24
  correctness: "error",
11
25
  suspicious: "warn",
@@ -474,13 +488,6 @@ const baseOxlintConfig = defineConfig$1({
474
488
  }
475
489
  ]
476
490
  });
477
- const baseOxfmtConfig = defineConfig({
478
- singleQuote: true,
479
- semi: false,
480
- arrowParens: "avoid",
481
- sortImports: true,
482
- quoteProps: "consistent"
483
- });
484
491
  const basePlugins = [
485
492
  "import",
486
493
  "unicorn",
@@ -489,11 +496,6 @@ const basePlugins = [
489
496
  "promise",
490
497
  "oxc"
491
498
  ];
492
- const TAILWIND_PLUGIN = "eslint-plugin-better-tailwindcss";
493
- /**
494
- * Map of a dependency to the oxlint plugins it enables. A plugin is registered
495
- * when any of its packages is found in the nearest `package.json`.
496
- */
497
499
  const pluginDetectors = {
498
500
  typescript: {
499
501
  packages: ["typescript"],
@@ -520,18 +522,6 @@ const pluginDetectors = {
520
522
  plugins: ["jest"]
521
523
  }
522
524
  };
523
- function getInstalledPackages(cwd) {
524
- const names = /* @__PURE__ */ new Set();
525
- try {
526
- const pkg = JSON.parse(readFileSync(resolve(cwd, "package.json"), "utf-8"));
527
- for (const field of [
528
- pkg.dependencies,
529
- pkg.devDependencies,
530
- pkg.peerDependencies
531
- ]) for (const name of Object.keys(field ?? {})) names.add(name);
532
- } catch {}
533
- return names;
534
- }
535
525
  function resolvePlugins(cwd) {
536
526
  const installed = getInstalledPackages(cwd);
537
527
  const plugins = [...basePlugins];
@@ -546,8 +536,6 @@ function resolvePlugins(cwd) {
546
536
  * plugin whose dependency lives elsewhere — e.g. a nested workspace like
547
537
  * `apps/web/package.json` — add it through `overrides.plugins`.
548
538
  *
549
- * `overrides` is deep-merged over the base config via defu.
550
- *
551
539
  * @example
552
540
  * ```ts
553
541
  * // auto-detect from the current package.json
@@ -561,30 +549,42 @@ function resolvePlugins(cwd) {
561
549
  * @example
562
550
  * ```ts
563
551
  * // add Tailwind linting
564
- * export default oxlintConfig({ ...tailwind('app/globals.css') })
552
+ * export default oxlintConfig({ ...tailwind({ entryPoint: 'app/globals.css' }) })
565
553
  * ```
566
554
  */
567
555
  function oxlintConfig(overrides = {}) {
568
556
  return defu(overrides, { plugins: resolvePlugins(process.cwd()) }, baseOxlintConfig);
569
557
  }
558
+ //#endregion
559
+ //#region src/oxfmt.ts
560
+ const baseOxfmtConfig = defineConfig$1({
561
+ singleQuote: true,
562
+ semi: false,
563
+ arrowParens: "avoid",
564
+ sortImports: true,
565
+ quoteProps: "consistent"
566
+ });
567
+ function oxfmtConfig(overrides = {}) {
568
+ return defu(overrides, baseOxfmtConfig);
569
+ }
570
+ //#endregion
571
+ //#region src/tailwind.ts
572
+ const TAILWIND_PLUGIN = "eslint-plugin-better-tailwindcss";
570
573
  /**
571
574
  * Tailwind linting via [`eslint-plugin-better-tailwindcss`](https://github.com/schoero/eslint-plugin-better-tailwindcss).
572
- * Spread the result into {@link oxlintConfig}:
575
+ * Spread the result into `oxlintConfig`:
573
576
  *
574
577
  * ```ts
575
578
  * export default oxlintConfig({ ...tailwind({ entryPoint: 'app/globals.css' }) })
576
579
  * ```
577
580
  *
578
581
  * The plugin is an optional peer dependency — install it yourself
579
- * (`pnpm add -D eslint-plugin-better-tailwindcss`). If it is missing, a warning
580
- * is logged and an empty config is returned so oxlint does not crash.
582
+ * (`pnpm add -D eslint-plugin-better-tailwindcss`). If it is missing, an error
583
+ * is thrown.
581
584
  */
582
585
  function tailwind({ entryPoint, cwd = process.cwd() }) {
583
- if (!getInstalledPackages(cwd).has(TAILWIND_PLUGIN)) {
584
- console.warn(`[@letstri/oxc-config] Tailwind linting needs "${TAILWIND_PLUGIN}". Install it: pnpm add -D ${TAILWIND_PLUGIN}`);
585
- return {};
586
- }
587
- return defineConfig$1({
586
+ if (!getInstalledPackages(cwd).has(TAILWIND_PLUGIN)) throw new Error(`[@letstri/oxc-config] Tailwind linting needs "${TAILWIND_PLUGIN}". Install it: pnpm add -D ${TAILWIND_PLUGIN}`);
587
+ return defineConfig({
588
588
  jsPlugins: [TAILWIND_PLUGIN],
589
589
  settings: { "better-tailwindcss": { entryPoint } },
590
590
  rules: {
@@ -599,8 +599,5 @@ function tailwind({ entryPoint, cwd = process.cwd() }) {
599
599
  }
600
600
  });
601
601
  }
602
- function oxfmtConfig(overrides = {}) {
603
- return defu(overrides, baseOxfmtConfig);
604
- }
605
602
  //#endregion
606
603
  export { oxfmtConfig, oxlintConfig, tailwind };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letstri/oxc-config",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Opinionated Oxlint and Oxfmt configs",
5
5
  "homepage": "https://github.com/letstri/oxc-config#readme",
6
6
  "bugs": {