@adamhl8/configs 3.0.2 → 3.1.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 +12 -0
- package/dist/adamhl8-bunfig/index +1 -0
- package/dist/adamhl8-gitignore/index +1 -0
- package/dist/configs/bask.base.d.ts.map +1 -1
- package/dist/configs/bask.base.js +8 -4
- package/dist/configs/bask.base.js.map +1 -1
- package/dist/configs/oxfmt.base.d.ts +10 -1
- package/dist/configs/oxfmt.base.d.ts.map +1 -1
- package/dist/configs/oxfmt.base.js +7 -1
- package/dist/configs/oxfmt.base.js.map +1 -1
- package/dist/configs/oxlint.base.d.ts +103 -89
- package/dist/configs/oxlint.base.d.ts.map +1 -1
- package/dist/configs/oxlint.base.js +170 -22
- package/dist/configs/oxlint.base.js.map +1 -1
- package/dist/configs/release-it.base.js.map +1 -1
- package/dist/env/utils.js.map +1 -1
- package/dist/merge-config/merge-config.d.ts.map +1 -1
- package/dist/merge-config/merge-config.js.map +1 -1
- package/dist/utils.js +31 -2
- package/dist/utils.js.map +1 -1
- package/package.json +35 -16
package/README.md
CHANGED
|
@@ -37,6 +37,14 @@ export * from "@adamhl8/configs/bask"
|
|
|
37
37
|
|
|
38
38
|
It provides `lint`, `build`, `test`, `bump-deps`, `release`, `release-run` (hidden, run by the release workflow), `tofu-check`, `commit-types`, and `prepare`. Run `bunx bask` to list them along with the allowed commit types. The tasks degrade gracefully so projects can use them as-is: `build` only runs `tsdown` if the project has a `tsdown.config.ts`, `test` (`bun test`) passes when there are no tests, and `tofu-check` (a `tofu plan` drift check, which `build` also runs) skips itself unless run locally in a project with `.tofu` files.
|
|
39
39
|
|
|
40
|
+
In projects that depend on `tailwindcss`, `lint` also runs [tailwint](https://github.com/peterwangsc/tailwint) on `.astro` files, because oxlint can't see Astro markup. It only checks and never fixes, because tailwint resolves a class conflict by deleting a class by position, not by which one wins. Projects with `.astro` files install it:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
bun add -D tailwint @tailwindcss/language-server
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Both are optional peer dependencies. bask runs `bun tailwint` from the project, so with bun's `isolated` linker the bin has to be installed by the project, not just by `@adamhl8/configs`.
|
|
47
|
+
|
|
40
48
|
To customize a task, add hooks to it from your `bask.ts`. A hook also runs when another base task calls that task, so extending `lint` extends `build` too:
|
|
41
49
|
|
|
42
50
|
```ts
|
|
@@ -86,6 +94,8 @@ const config = oxfmtConfig({ ... })
|
|
|
86
94
|
export default defineConfig(config)
|
|
87
95
|
```
|
|
88
96
|
|
|
97
|
+
In projects that depend on `tailwindcss`, Tailwind classes are sorted against the project's Tailwind stylesheet, so classes from plugins and `@theme` sort correctly. The stylesheet is found the same way the Tailwind language server finds it: the first CSS file, in sorted order, that does `@import "tailwindcss"`. oxfmt has to run from the project root for this to find the file. If it picks the wrong file, set `sortTailwindcss: { stylesheet: "path/to/global.css" }`.
|
|
98
|
+
|
|
89
99
|
### oxlint
|
|
90
100
|
|
|
91
101
|
```ts
|
|
@@ -97,6 +107,8 @@ const config = oxlintConfig({ ... })
|
|
|
97
107
|
export default defineConfig(config)
|
|
98
108
|
```
|
|
99
109
|
|
|
110
|
+
When the project depends on `tailwindcss`, the config enables [oxlint-tailwindcss](https://github.com/sergioazoc/oxlint-tailwindcss) with every rule except `enforce-sort-order` and `enforce-consistent-line-wrapping` (oxfmt handles these), `enforce-logical` (it conflicts with `enforce-physical`), and `max-class-count`. The plugin reads the design system from the same stylesheet oxfmt sorts against. If that's the wrong file, set `settings: { tailwindcss: { entryPoint: "path/to/global.css" } }`, alongside the oxfmt `sortTailwindcss` override.
|
|
111
|
+
|
|
100
112
|
### knip
|
|
101
113
|
|
|
102
114
|
```ts
|
|
@@ -3,6 +3,7 @@ import bun from "bun";
|
|
|
3
3
|
import { isPlainObject, merge } from "es-toolkit";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
+
import "es-toolkit/predicate";
|
|
6
7
|
const CONFIG_DIRS = ["./configs/", "../configs/"];
|
|
7
8
|
/** Returns the absolute path of a file in this package's `configs` folder. */
|
|
8
9
|
const configFilePath = (name) => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import bun from "bun";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import "es-toolkit/predicate";
|
|
5
6
|
const CONFIG_DIRS = ["./configs/", "../configs/"];
|
|
6
7
|
/** Returns the absolute path of a file in this package's `configs` folder. */
|
|
7
8
|
const configFilePath = (name) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bask.base.d.ts","names":[],"sources":["../../src/configs/bask.base.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"bask.base.d.ts","names":[],"sources":["../../src/configs/bask.base.ts"],"mappings":";qBAyBa,mCAAS;qBAIT,iCAAO;qBASP,kCAAQ;qBAOR,8BAAI;qBAIJ,8BAAI;qBA0BJ,+BAAK;qBAYL,iCAAO;qBAIP,oCAAU;qBAIV,qCAAW"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveProjectTailwind } from "../utils.js";
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
3
|
import { list, task } from "@adamhl8/bask";
|
|
3
4
|
import bun, { $, Glob } from "bun";
|
|
@@ -29,13 +30,16 @@ const bumpDeps = task(async ({ sh }) => {
|
|
|
29
30
|
await sh`rm -rf node_modules/`;
|
|
30
31
|
await sh`bun install --no-summary --no-cache`;
|
|
31
32
|
});
|
|
32
|
-
const test = task(async () => {
|
|
33
|
-
await
|
|
33
|
+
const test = task(async ({ sh }) => {
|
|
34
|
+
await sh`bun test --pass-with-no-tests`.echo(false);
|
|
34
35
|
});
|
|
35
36
|
const lint = task(async ({ sh }) => {
|
|
36
37
|
await sh`bun markdown-toc -i --bullets - --maxdepth 3 ./README.md`;
|
|
37
38
|
await sh`bun oxlint --fix --fix-suggestions --fix-dangerously`;
|
|
38
39
|
await sh`bun oxfmt`;
|
|
40
|
+
if (resolveProjectTailwind()) {
|
|
41
|
+
if ((await lsFiles([":(glob)**/*.astro"])).length > 0) await sh`bun tailwint "**/*.astro"`;
|
|
42
|
+
}
|
|
39
43
|
const tofuFiles = await lsFiles([
|
|
40
44
|
":(glob)**/*.tf",
|
|
41
45
|
":(glob)**/*.tofu",
|
|
@@ -63,8 +67,8 @@ const release = task(async ({ sh }) => {
|
|
|
63
67
|
const releaseRun = task({ hidden: true }, async ({ sh }) => {
|
|
64
68
|
await sh`bun release-it -VV --ci`;
|
|
65
69
|
});
|
|
66
|
-
const commitTypes = task(async () => {
|
|
67
|
-
const { 2: types } = (await
|
|
70
|
+
const commitTypes = task(async ({ sh }) => {
|
|
71
|
+
const { 2: types } = (await sh`bun commitlint --print-config json`.echo(false).json()).rules["type-enum"];
|
|
68
72
|
console.log(`Commit types:\n ${types.join("\n ")}`);
|
|
69
73
|
});
|
|
70
74
|
list.after(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bask.base.js","names":[],"sources":["../../src/configs/bask.base.ts"],"sourcesContent":["import { existsSync } from \"node:fs\"\n\nimport { list, task } from \"@adamhl8/bask\"\nimport bun, { $, Glob } from \"bun\"\n\n// oxlint-disable-next-line node/no-process-env\nconst inCi = Boolean(process.env[\"CI\"])\n\n/** Lists tracked and untracked files matching the pathspecs, skipping gitignored ones. */\nconst lsFiles = async (pathspecs: string[]) => {\n const output = await $`git ls-files -z --cached --others --exclude-standard -- ${pathspecs}`.quiet().text()\n return output.split(\"\\0\").filter(Boolean)\n}\n\n/** Checks that we're not in CI, the repo has a root tofu module, and the aws profile exists on this machine. */\nconst canRunTofu = async () => {\n if (inCi) return false\n const tofuFiles = await Array.fromAsync(new Glob(\"*.tofu\").scan())\n if (tofuFiles.length === 0) return false\n const profiles = await $`aws configure list-profiles`.nothrow().quiet().text()\n return profiles.split(\"\\n\").includes(\"adamhl8\")\n}\n\nexport const tofuCheck = task(async ({ sh }) => {\n if (await canRunTofu()) await sh`tofu plan -detailed-exitcode -concise -compact-warnings`\n})\n\nexport const prepare = task(async ({ sh }) => {\n // Skip `lefthook install` in CI so commits made by the workflows don't run the hooks.\n if (!inCi) await sh`lefthook install`\n await sh`bun adamhl8-gitignore`\n await sh`bun adamhl8-bunfig`\n await sh`bun oxfmt bunfig.toml`\n if (await canRunTofu()) await sh`tofu init -upgrade`\n})\n\nexport const bumpDeps = task(async ({ sh }) => {\n await sh`bunx npm-check-updates --upgrade --format group`\n await sh`rm -f bun.lock`\n await sh`rm -rf node_modules/`\n await sh`bun install --no-summary --no-cache`\n})\n\nexport const test = task(async () => {\n await
|
|
1
|
+
{"version":3,"file":"bask.base.js","names":[],"sources":["../../src/configs/bask.base.ts"],"sourcesContent":["import { existsSync } from \"node:fs\"\n\nimport { list, task } from \"@adamhl8/bask\"\nimport bun, { $, Glob } from \"bun\"\n\nimport { resolveProjectTailwind } from \"#utils.ts\"\n\n// oxlint-disable-next-line node/no-process-env - read `CI` directly because the CI runner sets it\nconst inCi = Boolean(process.env[\"CI\"])\n\n/** Lists tracked and untracked files matching the pathspecs, skipping gitignored ones. */\nconst lsFiles = async (pathspecs: string[]) => {\n const output = await $`git ls-files -z --cached --others --exclude-standard -- ${pathspecs}`.quiet().text()\n return output.split(\"\\0\").filter(Boolean)\n}\n\n/** Checks that we're not in CI, the repo has a root tofu module, and the aws profile exists on this machine. */\nconst canRunTofu = async () => {\n if (inCi) return false\n const tofuFiles = await Array.fromAsync(new Glob(\"*.tofu\").scan())\n if (tofuFiles.length === 0) return false\n const profiles = await $`aws configure list-profiles`.nothrow().quiet().text()\n return profiles.split(\"\\n\").includes(\"adamhl8\")\n}\n\nexport const tofuCheck = task(async ({ sh }) => {\n if (await canRunTofu()) await sh`tofu plan -detailed-exitcode -concise -compact-warnings`\n})\n\nexport const prepare = task(async ({ sh }) => {\n // Skip `lefthook install` in CI so commits made by the workflows don't run the hooks.\n if (!inCi) await sh`lefthook install`\n await sh`bun adamhl8-gitignore`\n await sh`bun adamhl8-bunfig`\n await sh`bun oxfmt bunfig.toml`\n if (await canRunTofu()) await sh`tofu init -upgrade`\n})\n\nexport const bumpDeps = task(async ({ sh }) => {\n await sh`bunx npm-check-updates --upgrade --format group`\n await sh`rm -f bun.lock`\n await sh`rm -rf node_modules/`\n await sh`bun install --no-summary --no-cache`\n})\n\nexport const test = task(async ({ sh }) => {\n await sh`bun test --pass-with-no-tests`.echo(false)\n})\n\nexport const lint = task(async ({ sh }) => {\n await sh`bun markdown-toc -i --bullets - --maxdepth 3 ./README.md`\n await sh`bun oxlint --fix --fix-suggestions --fix-dangerously`\n await sh`bun oxfmt`\n\n if (resolveProjectTailwind()) {\n // Check for `.astro` files first so projects without them don't need tailwint installed.\n const astroFiles = await lsFiles([\":(glob)**/*.astro\"])\n // Skip `--fix` because tailwint resolves a class conflict by deleting a class by position, not by which one wins.\n if (astroFiles.length > 0) await sh`bun tailwint \"**/*.astro\"`\n }\n\n const tofuFiles = await lsFiles([\n \":(glob)**/*.tf\",\n \":(glob)**/*.tofu\",\n \":(glob)**/*.tfvars\",\n \":(glob)**/*.tftest.hcl\",\n \":(glob)**/*.tofutest.hcl\",\n ])\n if (tofuFiles.length > 0) await sh`tofu fmt ${tofuFiles}`\n\n await sh`bun knip-bun`\n if (existsSync(\".github/workflows\")) await sh`actionlint`\n await test()\n})\n\nexport const build = task(async ({ sh }) => {\n await lint()\n if (await bun.file(\"tsdown.config.ts\").exists()) await sh`bun tsdown`\n // Fail in CI if the build changed or created any files, because lint fixes and formatting are applied in place.\n // `--intent-to-add` makes untracked files show up in the diff.\n if (inCi) {\n await sh`git add --intent-to-add --all`\n await sh`git diff --exit-code`\n }\n await tofuCheck()\n})\n\nexport const release = task(async ({ sh }) => {\n await sh`gh workflow run release.yml`\n})\n\nexport const releaseRun = task({ hidden: true }, async ({ sh }) => {\n await sh`bun release-it -VV --ci`\n})\n\nexport const commitTypes = task(async ({ sh }) => {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion - trust the shape that `commitlint --print-config json` prints\n const config = (await sh`bun commitlint --print-config json`.echo(false).json()) as {\n rules: { \"type-enum\": [number, string, string[]] }\n }\n const { 2: types } = config.rules[\"type-enum\"]\n console.log(`Commit types:\\n ${types.join(\"\\n \")}`)\n})\n\nlist.after(async () => {\n console.log()\n await commitTypes()\n})\n"],"mappings":";;;;;AAQA,MAAM,OAAO,QAAQ,QAAQ,IAAI,KAAK;;AAGtC,MAAM,UAAU,OAAO,cAAwB;CAE7C,QAAO,MADc,CAAC,2DAA2D,YAAY,MAAM,CAAC,CAAC,KAAK,EAAA,CAC5F,MAAM,IAAI,CAAC,CAAC,OAAO,OAAO;AAC1C;;AAGA,MAAM,aAAa,YAAY;CAC7B,IAAI,MAAM,OAAO;CAEjB,KAAI,MADoB,MAAM,UAAU,IAAI,KAAK,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAA,CACnD,WAAW,GAAG,OAAO;CAEnC,QAAO,MADgB,CAAC,8BAA8B,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAA,CAC7D,MAAM,IAAI,CAAC,CAAC,SAAS,SAAS;AAChD;AAEA,MAAa,YAAY,KAAK,OAAO,EAAE,SAAS;CAC9C,IAAI,MAAM,WAAW,GAAG,MAAM,EAAE;AAClC,CAAC;AAED,MAAa,UAAU,KAAK,OAAO,EAAE,SAAS;CAE5C,IAAI,CAAC,MAAM,MAAM,EAAE;CACnB,MAAM,EAAE;CACR,MAAM,EAAE;CACR,MAAM,EAAE;CACR,IAAI,MAAM,WAAW,GAAG,MAAM,EAAE;AAClC,CAAC;AAED,MAAa,WAAW,KAAK,OAAO,EAAE,SAAS;CAC7C,MAAM,EAAE;CACR,MAAM,EAAE;CACR,MAAM,EAAE;CACR,MAAM,EAAE;AACV,CAAC;AAED,MAAa,OAAO,KAAK,OAAO,EAAE,SAAS;CACzC,MAAM,EAAE,gCAAgC,KAAK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120;
|
|
6
6
|
readonly semi: false;
|
|
7
|
+
readonly astro: {
|
|
8
|
+
readonly allowShorthand: false;
|
|
9
|
+
};
|
|
10
|
+
readonly experimentalOperatorPosition: "start";
|
|
7
11
|
readonly jsdoc: true;
|
|
8
12
|
readonly sortImports: {
|
|
9
13
|
readonly groups: ["builtin", "external", ["subpath", "internal"], ["index", "sibling", "parent"], "side_effect", ["style", "side_effect_style"]];
|
|
10
14
|
};
|
|
11
|
-
readonly
|
|
15
|
+
readonly sortPackageJson: {
|
|
16
|
+
readonly sortScripts: true;
|
|
17
|
+
};
|
|
18
|
+
readonly sortTailwindcss: true | {
|
|
19
|
+
stylesheet: string;
|
|
20
|
+
};
|
|
12
21
|
}>;
|
|
13
22
|
//#endregion
|
|
14
23
|
//# sourceMappingURL=oxfmt.base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxfmt.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/oxfmt.base.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"oxfmt.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/oxfmt.base.ts"],"mappings":";;;qBA4Ba,aAAWA,sBAAA;WApBV;;;aAEH;;WACqB;;;aAG5B;;;aASiB"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { createMergeConfigFn } from "../merge-config/merge-config.js";
|
|
2
|
+
import { resolveProjectTailwind } from "../utils.js";
|
|
3
|
+
//#region src/configs/oxfmt.base.ts
|
|
4
|
+
const tailwindStylesheet = resolveProjectTailwind();
|
|
2
5
|
const oxfmtConfig = createMergeConfigFn({
|
|
3
6
|
printWidth: 120,
|
|
4
7
|
semi: false,
|
|
8
|
+
astro: { allowShorthand: false },
|
|
9
|
+
experimentalOperatorPosition: "start",
|
|
5
10
|
jsdoc: true,
|
|
6
11
|
sortImports: { groups: [
|
|
7
12
|
"builtin",
|
|
@@ -15,7 +20,8 @@ const oxfmtConfig = createMergeConfigFn({
|
|
|
15
20
|
"side_effect",
|
|
16
21
|
["style", "side_effect_style"]
|
|
17
22
|
] },
|
|
18
|
-
|
|
23
|
+
sortPackageJson: { sortScripts: true },
|
|
24
|
+
sortTailwindcss: tailwindStylesheet ? { stylesheet: tailwindStylesheet } : true
|
|
19
25
|
});
|
|
20
26
|
//#endregion
|
|
21
27
|
export { oxfmtConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxfmt.base.js","names":[],"sources":["../../src/configs/oxfmt.base.ts"],"sourcesContent":["import type { OxfmtConfig } from \"oxfmt\"\n\nimport { createMergeConfigFn } from \"#merge-config/merge-config.ts\"\n\nconst baseConfig = {\n printWidth: 120,\n semi: false,\n jsdoc: true,\n sortImports: {\n groups: [\n \"builtin\",\n \"external\",\n [\"subpath\", \"internal\"],\n [\"index\", \"sibling\", \"parent\"],\n \"side_effect\",\n [\"style\", \"side_effect_style\"],\n ],\n },\n sortTailwindcss: true,\n} as const satisfies OxfmtConfig\n\nexport const oxfmtConfig = createMergeConfigFn<OxfmtConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"oxfmt.base.js","names":[],"sources":["../../src/configs/oxfmt.base.ts"],"sourcesContent":["import type { OxfmtConfig } from \"oxfmt\"\n\nimport { createMergeConfigFn } from \"#merge-config/merge-config.ts\"\nimport { resolveProjectTailwind } from \"#utils.ts\"\n\nconst tailwindStylesheet = resolveProjectTailwind()\n\nconst baseConfig = {\n printWidth: 120,\n semi: false,\n astro: { allowShorthand: false },\n experimentalOperatorPosition: \"start\",\n jsdoc: true,\n sortImports: {\n groups: [\n \"builtin\",\n \"external\",\n [\"subpath\", \"internal\"],\n [\"index\", \"sibling\", \"parent\"],\n \"side_effect\",\n [\"style\", \"side_effect_style\"],\n ],\n },\n sortPackageJson: { sortScripts: true },\n // Sort against the project's stylesheet so classes from plugins and `@theme` are known.\n sortTailwindcss: tailwindStylesheet ? { stylesheet: tailwindStylesheet } : true,\n} as const satisfies OxfmtConfig\n\nexport const oxfmtConfig = createMergeConfigFn<OxfmtConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";;;AAKA,MAAM,qBAAqB,uBAAuB;AAuBlD,MAAa,cAAc,oBAAoD;CApB7E,YAAY;CACZ,MAAM;CACN,OAAO,EAAE,gBAAgB,MAAM;CAC/B,8BAA8B;CAC9B,OAAO;CACP,aAAa,EACX,QAAQ;EACN;EACA;EACA,CAAC,WAAW,UAAU;EACtB;GAAC;GAAS;GAAW;EAAQ;EAC7B;EACA,CAAC,SAAS,mBAAmB;CAC/B,EACF;CACA,iBAAiB,EAAE,aAAa,KAAK;CAErC,iBAAiB,qBAAqB,EAAE,YAAY,mBAAmB,IAAI;AAGE,CAAU"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { OptionalMergeConfigFn } from "../merge-config/merge-config.js";
|
|
2
|
-
import { OxlintConfig } from "oxlint";
|
|
2
|
+
import { DummyRule, OxlintConfig, OxlintOverride } from "oxlint";
|
|
3
3
|
//#region src/configs/oxlint.base.d.ts
|
|
4
|
+
type PluginRules = Record<string, DummyRule>;
|
|
4
5
|
export declare const oxlintConfig: OptionalMergeConfigFn<OxlintConfig, {
|
|
5
|
-
|
|
6
|
+
options: {
|
|
6
7
|
readonly reportUnusedDisableDirectives: "error";
|
|
7
8
|
readonly typeAware: true;
|
|
8
9
|
readonly typeCheck: true;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
categories: {
|
|
11
12
|
readonly correctness: "error";
|
|
12
13
|
readonly nursery: "error";
|
|
13
14
|
readonly pedantic: "error";
|
|
@@ -16,121 +17,134 @@ export declare const oxlintConfig: OptionalMergeConfigFn<OxlintConfig, {
|
|
|
16
17
|
readonly style: "error";
|
|
17
18
|
readonly suspicious: "error";
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
plugins: ["eslint", "react", "unicorn", "typescript", "oxc", "import", "jsdoc", "vitest", "jsx-a11y", "react-perf", "promise", "node"];
|
|
21
|
+
jsPlugins: string[];
|
|
22
|
+
overrides: ({
|
|
22
23
|
readonly files: [".release-it.ts", "astro.config.ts", "commitlint.config.ts", "knip.ts", "oxfmt.config.ts", "oxlint.config.ts", "prisma.config.ts", "tsdown.config.ts"];
|
|
23
24
|
readonly rules: {
|
|
24
25
|
readonly "import/no-default-export": "off";
|
|
25
26
|
};
|
|
26
|
-
}
|
|
27
|
+
} | {
|
|
27
28
|
readonly files: ["bask.ts"];
|
|
28
29
|
readonly rules: {
|
|
29
30
|
readonly "clean-modules/require-direct-exports": "off";
|
|
30
31
|
readonly "import/export": "off";
|
|
31
32
|
};
|
|
32
|
-
}
|
|
33
|
+
} | {
|
|
33
34
|
readonly files: [".release-it.ts"];
|
|
34
35
|
readonly rules: {
|
|
35
36
|
readonly "no-template-curly-in-string": "off";
|
|
36
37
|
};
|
|
37
|
-
}
|
|
38
|
+
} | {
|
|
38
39
|
readonly files: ["**/*.tsx"];
|
|
39
40
|
readonly rules: {
|
|
40
|
-
readonly "func-style": ["error", "
|
|
41
|
-
readonly
|
|
42
|
-
readonly namedExports: "ignore";
|
|
43
|
-
};
|
|
41
|
+
readonly "func-style": ["error", "declaration", {
|
|
42
|
+
readonly allowArrowFunctions: true;
|
|
44
43
|
}];
|
|
45
44
|
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
} | (Omit<OxlintOverride, "rules"> & {
|
|
46
|
+
rules?: PluginRules;
|
|
47
|
+
}))[];
|
|
48
|
+
rules: {
|
|
49
|
+
curly: ["error", "multi-or-nest"];
|
|
50
|
+
"func-style": ["error", "expression"];
|
|
51
|
+
"require-unicode-regexp": ["error", {
|
|
52
|
+
readonly requireFlag: "v";
|
|
53
|
+
}];
|
|
54
|
+
"react/function-component-definition": ["error", {
|
|
55
|
+
readonly namedComponents: "function-declaration";
|
|
56
|
+
readonly unnamedComponents: "arrow-function";
|
|
57
|
+
}];
|
|
58
|
+
"react/jsx-curly-brace-presence": ["error", {
|
|
54
59
|
readonly children: "never";
|
|
55
60
|
readonly propElementValues: "always";
|
|
56
61
|
readonly props: "never";
|
|
57
62
|
}];
|
|
58
|
-
|
|
59
|
-
readonly requireFlag: "v";
|
|
60
|
-
}];
|
|
61
|
-
readonly "unicorn/filename-case": ["error", {
|
|
63
|
+
"unicorn/filename-case": ["error", {
|
|
62
64
|
readonly cases: {
|
|
63
65
|
readonly kebabCase: true;
|
|
64
66
|
readonly pascalCase: true;
|
|
65
67
|
};
|
|
66
68
|
}];
|
|
67
|
-
|
|
69
|
+
"unicorn/no-useless-undefined": ["error", {
|
|
68
70
|
readonly checkArguments: false;
|
|
69
71
|
}];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
72
|
+
"capitalized-comments": "off";
|
|
73
|
+
"id-length": "off";
|
|
74
|
+
"init-declarations": "off";
|
|
75
|
+
"max-classes-per-file": "off";
|
|
76
|
+
"max-lines": "off";
|
|
77
|
+
"max-lines-per-function": "off";
|
|
78
|
+
"max-statements": "off";
|
|
79
|
+
"no-console": "off";
|
|
80
|
+
"no-continue": "off";
|
|
81
|
+
"no-duplicate-imports": "off";
|
|
82
|
+
"no-inline-comments": "off";
|
|
83
|
+
"no-magic-numbers": "off";
|
|
84
|
+
"no-plusplus": "off";
|
|
85
|
+
"no-regex-spaces": "off";
|
|
86
|
+
"no-ternary": "off";
|
|
87
|
+
"no-undef": "off";
|
|
88
|
+
"no-undefined": "off";
|
|
89
|
+
"no-useless-return": "off";
|
|
90
|
+
"no-void": "off";
|
|
91
|
+
"one-var": "off";
|
|
92
|
+
"require-await": "off";
|
|
93
|
+
"sort-imports": "off";
|
|
94
|
+
"sort-keys": "off";
|
|
95
|
+
"import/exports-last": "off";
|
|
96
|
+
"import/group-exports": "off";
|
|
97
|
+
"import/max-dependencies": "off";
|
|
98
|
+
"import/no-named-export": "off";
|
|
99
|
+
"import/no-nodejs-modules": "off";
|
|
100
|
+
"import/no-unassigned-import": "off";
|
|
101
|
+
"import/prefer-default-export": "off";
|
|
102
|
+
"jsdoc/require-param": "off";
|
|
103
|
+
"jsdoc/require-returns": "off";
|
|
104
|
+
"node/callback-return": "off";
|
|
105
|
+
"node/no-sync": "off";
|
|
106
|
+
"node/no-top-level-await": "off";
|
|
107
|
+
"oxc/no-async-await": "off";
|
|
108
|
+
"oxc/no-optional-chaining": "off";
|
|
109
|
+
"oxc/no-rest-spread-properties": "off";
|
|
110
|
+
"react/exhaustive-effect-dependencies": "off";
|
|
111
|
+
"react/forbid-component-props": "off";
|
|
112
|
+
"react/hooks": "off";
|
|
113
|
+
"react/invariant": "off";
|
|
114
|
+
"react/jsx-filename-extension": "off";
|
|
115
|
+
"react/jsx-max-depth": "off";
|
|
116
|
+
"react/jsx-no-literals": "off";
|
|
117
|
+
"react/memo-dependencies": "off";
|
|
118
|
+
"react/no-deriving-state-in-effects": "off";
|
|
119
|
+
"react/react-in-jsx-scope": "off";
|
|
120
|
+
"react/rule-suppression": "off";
|
|
121
|
+
"react/todo": "off";
|
|
122
|
+
"typescript/consistent-return": "off";
|
|
123
|
+
"typescript/explicit-function-return-type": "off";
|
|
124
|
+
"typescript/explicit-module-boundary-types": "off";
|
|
125
|
+
"typescript/prefer-readonly-parameter-types": "off";
|
|
126
|
+
"typescript/strict-boolean-expressions": "off";
|
|
127
|
+
"unicorn/no-array-callback-reference": "off";
|
|
128
|
+
"unicorn/no-array-method-this-argument": "off";
|
|
129
|
+
"unicorn/no-await-expression-member": "off";
|
|
130
|
+
"unicorn/no-process-exit": "off";
|
|
131
|
+
"unicorn/number-literal-case": "off";
|
|
132
|
+
"unicorn/switch-case-braces": "off";
|
|
133
|
+
"vitest/no-hooks": "off";
|
|
134
|
+
"vitest/no-importing-vitest-globals": "off";
|
|
135
|
+
"vitest/prefer-describe-function-title": "off";
|
|
136
|
+
"vitest/prefer-expect-assertions": "off";
|
|
137
|
+
"vitest/prefer-importing-vitest-globals": "off";
|
|
138
|
+
"vitest/prefer-lowercase-title": "off";
|
|
139
|
+
"vitest/prefer-to-be-falsy": "off";
|
|
140
|
+
"vitest/prefer-to-be-truthy": "off";
|
|
141
|
+
"vitest/require-hook": "off";
|
|
142
|
+
"vitest/require-test-timeout": "off";
|
|
143
|
+
};
|
|
144
|
+
settings: {
|
|
145
|
+
[k: string]: unknown;
|
|
133
146
|
};
|
|
134
147
|
}>;
|
|
135
148
|
//#endregion
|
|
149
|
+
export {};
|
|
136
150
|
//# sourceMappingURL=oxlint.base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/oxlint.base.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"oxlint.base.d.ts","names":["_$_merge_config_merge_config_ts0.OptionalMergeConfigFn"],"sources":["../../src/configs/oxlint.base.ts"],"mappings":";;;KAmBK,cAAc,eAAe;qBAmUrB,cA/T4CA,sBA+ThC;;aAvMrB;aACA;aACA;;;aAIA;aACA;aACA;aACA;aACA;aACA;aACA;;;;;;;eA+BI;;;;;eAMA;eACA;;;;;eAMA;;;;;;;;;;IAhLiD,QAAA;;;;;;eAgMF;;;eAI9B;eAA2C;;;eAER;eAA4B;eAAiB;;;;iBAKxF;iBAAiB;;;;;;IAON;IACX;IACQ;IACG;IACX;IACa;IACR;IACJ;IACC;IACS;IACF;IACF;IACL;IACI;IACL;IACF;IACI;IACK;IACV;IACA;IACM;IACD;IACH;IAEU;IACC;IACG;IACD;IACE;IACG;IACC;IAET;IACE;IAED;IACR;IACW;IAEL;IACM;IACK;IAEO;IACR;IACjB;IACI;IACa;IACT;IACE;IACE;IACW;IACV;IACF;IACZ;IAEkB;IACY;IACC;IACC;IACL;IAEF;IACE;IACH;IACX;IACI;IACD;IAEX;IACmB;IACG;IACN;IACO;IACT;IACJ;IACC;IACP;IACQ"}
|
|
@@ -1,7 +1,123 @@
|
|
|
1
1
|
import { createMergeConfigFn } from "../merge-config/merge-config.js";
|
|
2
|
-
import { resolvePackagePath } from "../utils.js";
|
|
2
|
+
import { readProjectPackageJson, resolvePackagePath, resolveProjectTailwind } from "../utils.js";
|
|
3
|
+
import cleanModulesPlugin from "@adamhl8/eslint-plugin-clean-modules";
|
|
4
|
+
import e18ePlugin from "@e18e/eslint-plugin";
|
|
5
|
+
import bunismsPlugin from "eslint-plugin-bunisms";
|
|
6
|
+
import honoPlugin from "eslint-plugin-hono";
|
|
7
|
+
import reactWebApiPlugin from "eslint-plugin-react-web-api";
|
|
8
|
+
import reactEffectPlugin from "eslint-plugin-react-you-might-not-need-an-effect";
|
|
9
|
+
import { rules } from "eslint-plugin-regexp";
|
|
10
|
+
import { rules as rules$1 } from "oxlint-plugin-directive-comments";
|
|
11
|
+
import tailwindcssPlugin from "oxlint-tailwindcss";
|
|
3
12
|
//#region src/configs/oxlint.base.ts
|
|
4
|
-
|
|
13
|
+
/** Sets every rule in a JS plugin to `severity`, because `categories` doesn't apply to JS plugins. */
|
|
14
|
+
const setAllPluginRules = (name, rules, severity) => Object.fromEntries(Object.keys(rules).map((rule) => [`${name}/${rule}`, severity]));
|
|
15
|
+
const { dependencies, engines } = readProjectPackageJson();
|
|
16
|
+
const tailwindStylesheet = resolveProjectTailwind();
|
|
17
|
+
const plugins = {
|
|
18
|
+
bunisms: {
|
|
19
|
+
overrides: [{
|
|
20
|
+
excludeFiles: [
|
|
21
|
+
"src/**/__tests__/**",
|
|
22
|
+
"src/**/*.test.{ts,tsx}",
|
|
23
|
+
"src/**/test-setup.ts",
|
|
24
|
+
"src/**/test-utils.ts"
|
|
25
|
+
],
|
|
26
|
+
files: engines.has("node") ? ["src/**"] : [],
|
|
27
|
+
rules: setAllPluginRules("bunisms", bunismsPlugin.rules, "off")
|
|
28
|
+
}],
|
|
29
|
+
package: "eslint-plugin-bunisms",
|
|
30
|
+
pluginRules: bunismsPlugin.rules,
|
|
31
|
+
rules: { "bunisms/prefer-mock-restore-in-after-each": "off" }
|
|
32
|
+
},
|
|
33
|
+
"clean-modules": {
|
|
34
|
+
package: "@adamhl8/eslint-plugin-clean-modules",
|
|
35
|
+
pluginRules: cleanModulesPlugin.rules
|
|
36
|
+
},
|
|
37
|
+
"directive-comments": {
|
|
38
|
+
package: "oxlint-plugin-directive-comments",
|
|
39
|
+
pluginRules: rules$1,
|
|
40
|
+
rules: {
|
|
41
|
+
"directive-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
|
|
42
|
+
"directive-comments/no-use": "off"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
e18e: {
|
|
46
|
+
package: "@e18e/eslint-plugin",
|
|
47
|
+
pluginRules: e18ePlugin.rules,
|
|
48
|
+
rules: {
|
|
49
|
+
"e18e/no-indexof-equality": "off",
|
|
50
|
+
"e18e/no-spread-in-reduce": "off",
|
|
51
|
+
"e18e/prefer-array-at": "off",
|
|
52
|
+
"e18e/prefer-array-some": "off",
|
|
53
|
+
"e18e/prefer-array-to-reversed": "off",
|
|
54
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
55
|
+
"e18e/prefer-date-now": "off",
|
|
56
|
+
"e18e/prefer-exponentiation-operator": "off",
|
|
57
|
+
"e18e/prefer-flatmap-over-map-flat": "off",
|
|
58
|
+
"e18e/prefer-includes": "off",
|
|
59
|
+
"e18e/prefer-nullish-coalescing": "off",
|
|
60
|
+
"e18e/prefer-object-has-own": "off",
|
|
61
|
+
"e18e/prefer-slice-over-split-index": "off",
|
|
62
|
+
"e18e/prefer-spread-syntax": "off"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
hono: {
|
|
66
|
+
enabled: dependencies.has("hono"),
|
|
67
|
+
package: "eslint-plugin-hono",
|
|
68
|
+
pluginRules: honoPlugin.rules,
|
|
69
|
+
rules: { "hono/no-process-env": "off" }
|
|
70
|
+
},
|
|
71
|
+
"react-web-api": {
|
|
72
|
+
enabled: dependencies.has("react"),
|
|
73
|
+
package: "eslint-plugin-react-web-api",
|
|
74
|
+
pluginRules: reactWebApiPlugin.rules
|
|
75
|
+
},
|
|
76
|
+
"react-you-might-not-need-an-effect": {
|
|
77
|
+
enabled: dependencies.has("react"),
|
|
78
|
+
package: "eslint-plugin-react-you-might-not-need-an-effect",
|
|
79
|
+
pluginRules: reactEffectPlugin.rules,
|
|
80
|
+
rules: {
|
|
81
|
+
"react-you-might-not-need-an-effect/no-adjust-state-on-prop-change": "off",
|
|
82
|
+
"react-you-might-not-need-an-effect/no-chain-state-updates": "off",
|
|
83
|
+
"react-you-might-not-need-an-effect/no-derived-state": "off",
|
|
84
|
+
"react-you-might-not-need-an-effect/no-initialize-state": "off",
|
|
85
|
+
"react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change": "off"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
regexp: {
|
|
89
|
+
package: "eslint-plugin-regexp",
|
|
90
|
+
pluginRules: rules,
|
|
91
|
+
rules: {
|
|
92
|
+
"regexp/letter-case": ["error", {
|
|
93
|
+
hexadecimalEscape: "uppercase",
|
|
94
|
+
unicodeEscape: "uppercase"
|
|
95
|
+
}],
|
|
96
|
+
"regexp/no-control-character": "off",
|
|
97
|
+
"regexp/no-empty-character-class": "off",
|
|
98
|
+
"regexp/no-invalid-regexp": "off",
|
|
99
|
+
"regexp/no-super-linear-move": "off",
|
|
100
|
+
"regexp/no-useless-escape": "off",
|
|
101
|
+
"regexp/prefer-named-capture-group": "off",
|
|
102
|
+
"regexp/require-unicode-regexp": "off",
|
|
103
|
+
"regexp/require-unicode-sets-regexp": "off",
|
|
104
|
+
"regexp/sort-alternatives": "off"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
tailwindcss: {
|
|
108
|
+
enabled: Boolean(tailwindStylesheet),
|
|
109
|
+
package: "oxlint-tailwindcss",
|
|
110
|
+
pluginRules: tailwindcssPlugin.rules,
|
|
111
|
+
rules: {
|
|
112
|
+
"tailwindcss/enforce-consistent-line-wrapping": "off",
|
|
113
|
+
"tailwindcss/enforce-logical": "off",
|
|
114
|
+
"tailwindcss/enforce-sort-order": "off",
|
|
115
|
+
"tailwindcss/max-class-count": "off"
|
|
116
|
+
},
|
|
117
|
+
settings: { tailwindcss: { entryPoint: tailwindStylesheet } }
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const nativeConfig = {
|
|
5
121
|
options: {
|
|
6
122
|
reportUnusedDisableDirectives: "error",
|
|
7
123
|
typeAware: true,
|
|
@@ -30,7 +146,6 @@ const baseConfig = {
|
|
|
30
146
|
"promise",
|
|
31
147
|
"node"
|
|
32
148
|
],
|
|
33
|
-
jsPlugins: [resolvePackagePath("@adamhl8/eslint-plugin-clean-modules")],
|
|
34
149
|
overrides: [
|
|
35
150
|
{
|
|
36
151
|
files: [
|
|
@@ -60,23 +175,24 @@ const baseConfig = {
|
|
|
60
175
|
files: ["**/*.tsx"],
|
|
61
176
|
rules: { "func-style": [
|
|
62
177
|
"error",
|
|
63
|
-
"
|
|
64
|
-
{
|
|
178
|
+
"declaration",
|
|
179
|
+
{ allowArrowFunctions: true }
|
|
65
180
|
] }
|
|
66
181
|
}
|
|
67
182
|
],
|
|
68
183
|
rules: {
|
|
69
|
-
"clean-modules/require-direct-exports": "error",
|
|
70
|
-
"clean-modules/require-import-extensions": "error",
|
|
71
|
-
"clean-modules/require-subpath-imports": "error",
|
|
72
184
|
curly: ["error", "multi-or-nest"],
|
|
73
185
|
"func-style": ["error", "expression"],
|
|
186
|
+
"require-unicode-regexp": ["error", { requireFlag: "v" }],
|
|
187
|
+
"react/function-component-definition": ["error", {
|
|
188
|
+
namedComponents: "function-declaration",
|
|
189
|
+
unnamedComponents: "arrow-function"
|
|
190
|
+
}],
|
|
74
191
|
"react/jsx-curly-brace-presence": ["error", {
|
|
75
192
|
children: "never",
|
|
76
193
|
propElementValues: "always",
|
|
77
194
|
props: "never"
|
|
78
195
|
}],
|
|
79
|
-
"require-unicode-regexp": ["error", { requireFlag: "v" }],
|
|
80
196
|
"unicorn/filename-case": ["error", { cases: {
|
|
81
197
|
kebabCase: true,
|
|
82
198
|
pascalCase: true
|
|
@@ -84,16 +200,7 @@ const baseConfig = {
|
|
|
84
200
|
"unicorn/no-useless-undefined": ["error", { checkArguments: false }],
|
|
85
201
|
"capitalized-comments": "off",
|
|
86
202
|
"id-length": "off",
|
|
87
|
-
"import/exports-last": "off",
|
|
88
|
-
"import/group-exports": "off",
|
|
89
|
-
"import/max-dependencies": "off",
|
|
90
|
-
"import/no-named-export": "off",
|
|
91
|
-
"import/no-nodejs-modules": "off",
|
|
92
|
-
"import/no-unassigned-import": "off",
|
|
93
|
-
"import/prefer-default-export": "off",
|
|
94
203
|
"init-declarations": "off",
|
|
95
|
-
"jsdoc/require-param": "off",
|
|
96
|
-
"jsdoc/require-returns": "off",
|
|
97
204
|
"max-classes-per-file": "off",
|
|
98
205
|
"max-lines": "off",
|
|
99
206
|
"max-lines-per-function": "off",
|
|
@@ -104,26 +211,43 @@ const baseConfig = {
|
|
|
104
211
|
"no-inline-comments": "off",
|
|
105
212
|
"no-magic-numbers": "off",
|
|
106
213
|
"no-plusplus": "off",
|
|
214
|
+
"no-regex-spaces": "off",
|
|
107
215
|
"no-ternary": "off",
|
|
108
216
|
"no-undef": "off",
|
|
109
217
|
"no-undefined": "off",
|
|
110
218
|
"no-useless-return": "off",
|
|
111
219
|
"no-void": "off",
|
|
220
|
+
"one-var": "off",
|
|
221
|
+
"require-await": "off",
|
|
222
|
+
"sort-imports": "off",
|
|
223
|
+
"sort-keys": "off",
|
|
224
|
+
"import/exports-last": "off",
|
|
225
|
+
"import/group-exports": "off",
|
|
226
|
+
"import/max-dependencies": "off",
|
|
227
|
+
"import/no-named-export": "off",
|
|
228
|
+
"import/no-nodejs-modules": "off",
|
|
229
|
+
"import/no-unassigned-import": "off",
|
|
230
|
+
"import/prefer-default-export": "off",
|
|
231
|
+
"jsdoc/require-param": "off",
|
|
232
|
+
"jsdoc/require-returns": "off",
|
|
112
233
|
"node/callback-return": "off",
|
|
113
234
|
"node/no-sync": "off",
|
|
114
235
|
"node/no-top-level-await": "off",
|
|
115
|
-
"one-var": "off",
|
|
116
236
|
"oxc/no-async-await": "off",
|
|
117
237
|
"oxc/no-optional-chaining": "off",
|
|
118
238
|
"oxc/no-rest-spread-properties": "off",
|
|
239
|
+
"react/exhaustive-effect-dependencies": "off",
|
|
119
240
|
"react/forbid-component-props": "off",
|
|
241
|
+
"react/hooks": "off",
|
|
242
|
+
"react/invariant": "off",
|
|
120
243
|
"react/jsx-filename-extension": "off",
|
|
121
244
|
"react/jsx-max-depth": "off",
|
|
122
245
|
"react/jsx-no-literals": "off",
|
|
246
|
+
"react/memo-dependencies": "off",
|
|
247
|
+
"react/no-deriving-state-in-effects": "off",
|
|
123
248
|
"react/react-in-jsx-scope": "off",
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"sort-keys": "off",
|
|
249
|
+
"react/rule-suppression": "off",
|
|
250
|
+
"react/todo": "off",
|
|
127
251
|
"typescript/consistent-return": "off",
|
|
128
252
|
"typescript/explicit-function-return-type": "off",
|
|
129
253
|
"typescript/explicit-module-boundary-types": "off",
|
|
@@ -147,6 +271,30 @@ const baseConfig = {
|
|
|
147
271
|
"vitest/require-test-timeout": "off"
|
|
148
272
|
}
|
|
149
273
|
};
|
|
274
|
+
const enabledPluginEntries = Object.entries(plugins).filter(([, plugin]) => plugin.enabled ?? true);
|
|
275
|
+
const enabledPlugins = enabledPluginEntries.map(([, plugin]) => plugin);
|
|
276
|
+
const resolvedPluginPackages = enabledPlugins.map((plugin) => resolvePackagePath(plugin.package));
|
|
277
|
+
const pluginOverrides = enabledPlugins.flatMap((plugin) => plugin.overrides ?? []);
|
|
278
|
+
const pluginSettings = Object.fromEntries(enabledPlugins.flatMap((plugin) => Object.entries(plugin.settings ?? {})));
|
|
279
|
+
/** Lists a plugin's rules as entries */
|
|
280
|
+
const toPluginRuleEntries = ([name, { pluginRules = {}, rules }]) => {
|
|
281
|
+
const defaultRules = setAllPluginRules(name, pluginRules, "error");
|
|
282
|
+
return Object.entries({
|
|
283
|
+
...defaultRules,
|
|
284
|
+
...rules
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
const resolvedPluginRules = Object.fromEntries(enabledPluginEntries.flatMap(toPluginRuleEntries));
|
|
288
|
+
const baseConfig = {
|
|
289
|
+
...nativeConfig,
|
|
290
|
+
jsPlugins: resolvedPluginPackages,
|
|
291
|
+
overrides: [...nativeConfig.overrides, ...pluginOverrides],
|
|
292
|
+
rules: {
|
|
293
|
+
...resolvedPluginRules,
|
|
294
|
+
...nativeConfig.rules
|
|
295
|
+
},
|
|
296
|
+
settings: pluginSettings
|
|
297
|
+
};
|
|
150
298
|
const oxlintConfig = createMergeConfigFn(baseConfig);
|
|
151
299
|
//#endregion
|
|
152
300
|
export { oxlintConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint.base.js","names":[],"sources":["../../src/configs/oxlint.base.ts"],"sourcesContent":["import type { OxlintConfig } from \"oxlint\"\n\nimport { createMergeConfigFn } from \"#merge-config/merge-config.ts\"\nimport { resolvePackagePath } from \"#utils.ts\"\n\nconst baseConfig = {\n options: {\n reportUnusedDisableDirectives: \"error\",\n typeAware: true,\n typeCheck: true,\n },\n\n categories: {\n correctness: \"error\",\n nursery: \"error\",\n pedantic: \"error\",\n perf: \"error\",\n restriction: \"error\",\n style: \"error\",\n suspicious: \"error\",\n },\n\n plugins: [\n \"eslint\",\n \"react\",\n \"unicorn\",\n \"typescript\",\n \"oxc\",\n \"import\",\n \"jsdoc\",\n \"vitest\",\n \"jsx-a11y\",\n \"react-perf\",\n \"promise\",\n \"node\",\n ],\n\n // Resolve to an absolute path so consumers load it from this package's own deps.\n jsPlugins: [resolvePackagePath(\"@adamhl8/eslint-plugin-clean-modules\")],\n\n overrides: [\n {\n files: [\n \".release-it.ts\",\n \"astro.config.ts\",\n \"commitlint.config.ts\",\n \"knip.ts\",\n \"oxfmt.config.ts\",\n \"oxlint.config.ts\",\n \"prisma.config.ts\",\n \"tsdown.config.ts\",\n ],\n rules: {\n \"import/no-default-export\": \"off\",\n },\n },\n {\n files: [\"bask.ts\"],\n rules: {\n \"clean-modules/require-direct-exports\": \"off\",\n \"import/export\": \"off\",\n },\n },\n {\n files: [\".release-it.ts\"],\n rules: {\n \"no-template-curly-in-string\": \"off\",\n },\n },\n {\n files: [\"**/*.tsx\"],\n rules: {\n \"func-style\": [\"error\", \"expression\", { overrides: { namedExports: \"ignore\" } }],\n },\n },\n ],\n\n rules: {\n \"clean-modules/require-direct-exports\": \"error\",\n \"clean-modules/require-import-extensions\": \"error\",\n \"clean-modules/require-subpath-imports\": \"error\",\n\n curly: [\"error\", \"multi-or-nest\"],\n \"func-style\": [\"error\", \"expression\"],\n \"react/jsx-curly-brace-presence\": [\"error\", { children: \"never\", propElementValues: \"always\", props: \"never\" }],\n \"require-unicode-regexp\": [\"error\", { requireFlag: \"v\" }],\n \"unicorn/filename-case\": [\n \"error\",\n {\n cases: { kebabCase: true, pascalCase: true },\n },\n ],\n \"unicorn/no-useless-undefined\": [\"error\", { checkArguments: false }],\n\n \"capitalized-comments\": \"off\",\n \"id-length\": \"off\",\n \"import/exports-last\": \"off\",\n \"import/group-exports\": \"off\",\n \"import/max-dependencies\": \"off\",\n \"import/no-named-export\": \"off\",\n \"import/no-nodejs-modules\": \"off\",\n \"import/no-unassigned-import\": \"off\",\n \"import/prefer-default-export\": \"off\",\n \"init-declarations\": \"off\",\n \"jsdoc/require-param\": \"off\",\n \"jsdoc/require-returns\": \"off\",\n \"max-classes-per-file\": \"off\",\n \"max-lines\": \"off\",\n \"max-lines-per-function\": \"off\",\n \"max-statements\": \"off\",\n \"no-console\": \"off\",\n \"no-continue\": \"off\",\n \"no-duplicate-imports\": \"off\",\n \"no-inline-comments\": \"off\",\n \"no-magic-numbers\": \"off\",\n \"no-plusplus\": \"off\",\n \"no-ternary\": \"off\",\n \"no-undef\": \"off\",\n \"no-undefined\": \"off\",\n \"no-useless-return\": \"off\",\n \"no-void\": \"off\",\n \"node/callback-return\": \"off\",\n \"node/no-sync\": \"off\",\n \"node/no-top-level-await\": \"off\",\n \"one-var\": \"off\",\n \"oxc/no-async-await\": \"off\",\n \"oxc/no-optional-chaining\": \"off\",\n \"oxc/no-rest-spread-properties\": \"off\",\n \"react/forbid-component-props\": \"off\",\n \"react/jsx-filename-extension\": \"off\",\n \"react/jsx-max-depth\": \"off\",\n \"react/jsx-no-literals\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"require-await\": \"off\",\n \"sort-imports\": \"off\",\n \"sort-keys\": \"off\",\n \"typescript/consistent-return\": \"off\",\n \"typescript/explicit-function-return-type\": \"off\",\n \"typescript/explicit-module-boundary-types\": \"off\",\n \"typescript/prefer-readonly-parameter-types\": \"off\",\n \"typescript/strict-boolean-expressions\": \"off\",\n \"unicorn/no-array-callback-reference\": \"off\",\n \"unicorn/no-array-method-this-argument\": \"off\",\n \"unicorn/no-await-expression-member\": \"off\",\n \"unicorn/no-process-exit\": \"off\",\n \"unicorn/number-literal-case\": \"off\",\n \"unicorn/switch-case-braces\": \"off\",\n \"vitest/no-hooks\": \"off\",\n \"vitest/no-importing-vitest-globals\": \"off\",\n \"vitest/prefer-describe-function-title\": \"off\",\n \"vitest/prefer-expect-assertions\": \"off\",\n \"vitest/prefer-importing-vitest-globals\": \"off\",\n \"vitest/prefer-lowercase-title\": \"off\",\n \"vitest/prefer-to-be-falsy\": \"off\",\n \"vitest/prefer-to-be-truthy\": \"off\",\n \"vitest/require-hook\": \"off\", // reenable when false positives are fixed?\n \"vitest/require-test-timeout\": \"off\",\n },\n} as const satisfies OxlintConfig\n\nexport const oxlintConfig = createMergeConfigFn<OxlintConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";;;AAKA,MAAM,aAAa;CACjB,SAAS;EACP,+BAA+B;EAC/B,WAAW;EACX,WAAW;CACb;CAEA,YAAY;EACV,aAAa;EACb,SAAS;EACT,UAAU;EACV,MAAM;EACN,aAAa;EACb,OAAO;EACP,YAAY;CACd;CAEA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAGA,WAAW,CAAC,mBAAmB,sCAAsC,CAAC;CAEtE,WAAW;EACT;GACE,OAAO;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF;GACA,OAAO,EACL,4BAA4B,MAC9B;EACF;EACA;GACE,OAAO,CAAC,SAAS;GACjB,OAAO;IACL,wCAAwC;IACxC,iBAAiB;GACnB;EACF;EACA;GACE,OAAO,CAAC,gBAAgB;GACxB,OAAO,EACL,+BAA+B,MACjC;EACF;EACA;GACE,OAAO,CAAC,UA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,mBAAmB;EACnB,sCAAsC;EACtC,yCAAyC;EACzC,mCAAmC;EACnC,0CAA0C;EAC1C,iCAAiC;EACjC,6BAA6B;EAC7B,8BAA8B;EAC9B,uBAAuB;EACvB,+BAA+B;CACjC;AACF;AAEA,MAAa,eAAe,oBAAqD,UAAU"}
|
|
1
|
+
{"version":3,"file":"oxlint.base.js","names":["directiveCommentsPluginRules","regexpPluginRules"],"sources":["../../src/configs/oxlint.base.ts"],"sourcesContent":["import cleanModulesPlugin from \"@adamhl8/eslint-plugin-clean-modules\"\nimport e18ePlugin from \"@e18e/eslint-plugin\"\nimport bunismsPlugin from \"eslint-plugin-bunisms\"\nimport honoPlugin from \"eslint-plugin-hono\"\nimport reactWebApiPlugin from \"eslint-plugin-react-web-api\"\nimport reactEffectPlugin from \"eslint-plugin-react-you-might-not-need-an-effect\"\nimport { rules as regexpPluginRules } from \"eslint-plugin-regexp\"\nimport type { DummyRule, OxlintConfig, OxlintOverride } from \"oxlint\"\nimport { rules as directiveCommentsPluginRules } from \"oxlint-plugin-directive-comments\"\nimport tailwindcssPlugin from \"oxlint-tailwindcss\"\n\nimport { createMergeConfigFn } from \"#merge-config/merge-config.ts\"\nimport { readProjectPackageJson, resolvePackagePath, resolveProjectTailwind } from \"#utils.ts\"\n\n/** Sets every rule in a JS plugin to `severity`, because `categories` doesn't apply to JS plugins. */\nconst setAllPluginRules = (name: string, rules: Record<string, unknown>, severity: \"error\" | \"off\") =>\n Object.fromEntries(Object.keys(rules).map((rule) => [`${name}/${rule}`, severity] as const))\n\n// Type plugin rules with oxlint's generic `DummyRule` because its per-rule config types aren't exported, which breaks declaration emit.\ntype PluginRules = Record<string, DummyRule>\n\n/** A JS plugin and the slice of oxlint config that goes with it. Each one is merged into the base config. */\ninterface PluginPart extends Omit<OxlintConfig, \"jsPlugins\" | \"overrides\" | \"rules\"> {\n overrides?: (Omit<OxlintOverride, \"rules\"> & { rules?: PluginRules })[]\n rules?: PluginRules\n /** Loads the plugin only when true. Defaults to true. */\n enabled?: boolean\n package: string\n /** The plugin's rule definitions, used to set every rule to \"error\". The part's own `rules` then take precedence. */\n pluginRules: Record<string, unknown> | undefined\n}\n\nconst { dependencies, engines } = readProjectPackageJson()\nconst tailwindStylesheet = resolveProjectTailwind()\n\n// Key each part by the rule namespace its plugin registers.\nconst plugins: Record<string, PluginPart> = {\n bunisms: {\n overrides: [\n {\n excludeFiles: [\"src/**/__tests__/**\", \"src/**/*.test.{ts,tsx}\", \"src/**/test-setup.ts\", \"src/**/test-utils.ts\"],\n // Turn off Bun suggestions in Node runtime code. Tests and tooling still run on Bun.\n files: engines.has(\"node\") ? [\"src/**\"] : [],\n rules: setAllPluginRules(\"bunisms\", bunismsPlugin.rules, \"off\"),\n },\n ],\n package: \"eslint-plugin-bunisms\",\n pluginRules: bunismsPlugin.rules,\n rules: {\n \"bunisms/prefer-mock-restore-in-after-each\": \"off\", // `test-setup.ts` preloads restore mocks globally\n },\n },\n \"clean-modules\": {\n package: \"@adamhl8/eslint-plugin-clean-modules\",\n pluginRules: cleanModulesPlugin.rules,\n },\n \"directive-comments\": {\n package: \"oxlint-plugin-directive-comments\",\n pluginRules: directiveCommentsPluginRules,\n rules: {\n \"directive-comments/disable-enable-pair\": [\"error\", { allowWholeFile: true }],\n \"directive-comments/no-use\": \"off\", // bans every directive comment\n },\n },\n e18e: {\n package: \"@e18e/eslint-plugin\",\n pluginRules: e18ePlugin.rules,\n rules: {\n \"e18e/no-indexof-equality\": \"off\", // needs type information, which JS plugins don't get\n \"e18e/no-spread-in-reduce\": \"off\", // `oxc/no-accumulating-spread` covers this\n \"e18e/prefer-array-at\": \"off\", // `unicorn/prefer-at` covers this\n \"e18e/prefer-array-some\": \"off\", // `unicorn/prefer-array-some` covers this\n \"e18e/prefer-array-to-reversed\": \"off\", // `unicorn/no-array-reverse` covers this\n \"e18e/prefer-array-to-sorted\": \"off\", // `unicorn/no-array-sort` covers this\n \"e18e/prefer-date-now\": \"off\", // `unicorn/prefer-date-now` covers this\n \"e18e/prefer-exponentiation-operator\": \"off\", // `prefer-exponentiation-operator` covers this\n \"e18e/prefer-flatmap-over-map-flat\": \"off\", // `unicorn/prefer-array-flat-map` covers this\n \"e18e/prefer-includes\": \"off\", // `unicorn/prefer-includes` covers this\n \"e18e/prefer-nullish-coalescing\": \"off\", // `typescript/prefer-nullish-coalescing` covers this\n \"e18e/prefer-object-has-own\": \"off\", // `prefer-object-has-own` covers this\n \"e18e/prefer-slice-over-split-index\": \"off\",\n \"e18e/prefer-spread-syntax\": \"off\", // `unicorn/prefer-spread` and `prefer-object-spread` cover this\n },\n },\n hono: {\n enabled: dependencies.has(\"hono\"),\n package: \"eslint-plugin-hono\",\n pluginRules: honoPlugin.rules,\n rules: {\n \"hono/no-process-env\": \"off\", // `node/no-process-env` covers this\n },\n },\n \"react-web-api\": {\n enabled: dependencies.has(\"react\"),\n package: \"eslint-plugin-react-web-api\",\n pluginRules: reactWebApiPlugin.rules,\n },\n \"react-you-might-not-need-an-effect\": {\n enabled: dependencies.has(\"react\"),\n package: \"eslint-plugin-react-you-might-not-need-an-effect\",\n pluginRules: reactEffectPlugin.rules,\n rules: {\n \"react-you-might-not-need-an-effect/no-adjust-state-on-prop-change\": \"off\", // `react/set-state-in-effect` covers this\n \"react-you-might-not-need-an-effect/no-chain-state-updates\": \"off\", // `react/set-state-in-effect` covers this\n \"react-you-might-not-need-an-effect/no-derived-state\": \"off\", // `react/set-state-in-effect` covers this\n \"react-you-might-not-need-an-effect/no-initialize-state\": \"off\", // `react/set-state-in-effect` covers this\n \"react-you-might-not-need-an-effect/no-reset-all-state-on-prop-change\": \"off\", // `react/set-state-in-effect` covers this\n },\n },\n regexp: {\n package: \"eslint-plugin-regexp\",\n pluginRules: regexpPluginRules,\n rules: {\n \"regexp/letter-case\": [\"error\", { hexadecimalEscape: \"uppercase\", unicodeEscape: \"uppercase\" }], // match `unicorn/escape-case`\n \"regexp/no-control-character\": \"off\", // `no-control-regex` covers this\n \"regexp/no-empty-character-class\": \"off\", // `no-empty-character-class` covers this\n \"regexp/no-invalid-regexp\": \"off\", // `no-invalid-regexp` covers this\n \"regexp/no-super-linear-move\": \"off\",\n \"regexp/no-useless-escape\": \"off\", // `no-useless-escape` covers this\n \"regexp/prefer-named-capture-group\": \"off\", // `prefer-named-capture-group` covers this\n \"regexp/require-unicode-regexp\": \"off\", // `require-unicode-regexp` covers this\n \"regexp/require-unicode-sets-regexp\": \"off\", // `require-unicode-regexp` covers this\n \"regexp/sort-alternatives\": \"off\",\n },\n },\n tailwindcss: {\n // Load the Tailwind plugin only with a stylesheet because it reports every class string without one.\n enabled: Boolean(tailwindStylesheet),\n package: \"oxlint-tailwindcss\",\n pluginRules: tailwindcssPlugin.rules,\n rules: {\n \"tailwindcss/enforce-consistent-line-wrapping\": \"off\", // oxfmt handles line width\n \"tailwindcss/enforce-logical\": \"off\", // conflicts with `tailwindcss/enforce-physical`\n \"tailwindcss/enforce-sort-order\": \"off\", // oxfmt sorts classes\n \"tailwindcss/max-class-count\": \"off\",\n },\n // Keep `entryPoint` relative because the plugin resolves it against the directory of the project's oxlint config.\n settings: { tailwindcss: { entryPoint: tailwindStylesheet } },\n },\n}\n\nconst nativeConfig = {\n options: {\n reportUnusedDisableDirectives: \"error\",\n typeAware: true,\n typeCheck: true,\n },\n\n categories: {\n correctness: \"error\",\n nursery: \"error\",\n pedantic: \"error\",\n perf: \"error\",\n restriction: \"error\",\n style: \"error\",\n suspicious: \"error\",\n },\n\n plugins: [\n \"eslint\",\n \"react\",\n \"unicorn\",\n \"typescript\",\n \"oxc\",\n \"import\",\n \"jsdoc\",\n \"vitest\",\n \"jsx-a11y\",\n \"react-perf\",\n \"promise\",\n \"node\",\n ],\n\n overrides: [\n {\n files: [\n \".release-it.ts\",\n \"astro.config.ts\",\n \"commitlint.config.ts\",\n \"knip.ts\",\n \"oxfmt.config.ts\",\n \"oxlint.config.ts\",\n \"prisma.config.ts\",\n \"tsdown.config.ts\",\n ],\n rules: {\n \"import/no-default-export\": \"off\",\n },\n },\n {\n files: [\"bask.ts\"],\n rules: {\n \"clean-modules/require-direct-exports\": \"off\",\n \"import/export\": \"off\",\n },\n },\n {\n files: [\".release-it.ts\"],\n rules: {\n \"no-template-curly-in-string\": \"off\",\n },\n },\n {\n files: [\"**/*.tsx\"],\n rules: {\n \"func-style\": [\"error\", \"declaration\", { allowArrowFunctions: true }],\n },\n },\n ],\n\n rules: {\n /* Modified rules */\n\n curly: [\"error\", \"multi-or-nest\"],\n \"func-style\": [\"error\", \"expression\"],\n \"require-unicode-regexp\": [\"error\", { requireFlag: \"v\" }],\n\n \"react/function-component-definition\": [\n \"error\",\n { namedComponents: \"function-declaration\", unnamedComponents: \"arrow-function\" },\n ],\n \"react/jsx-curly-brace-presence\": [\"error\", { children: \"never\", propElementValues: \"always\", props: \"never\" }],\n\n \"unicorn/filename-case\": [\n \"error\",\n {\n cases: { kebabCase: true, pascalCase: true },\n },\n ],\n \"unicorn/no-useless-undefined\": [\"error\", { checkArguments: false }],\n\n /* Disabled rules */\n\n \"capitalized-comments\": \"off\",\n \"id-length\": \"off\",\n \"init-declarations\": \"off\",\n \"max-classes-per-file\": \"off\",\n \"max-lines\": \"off\",\n \"max-lines-per-function\": \"off\",\n \"max-statements\": \"off\",\n \"no-console\": \"off\",\n \"no-continue\": \"off\",\n \"no-duplicate-imports\": \"off\",\n \"no-inline-comments\": \"off\",\n \"no-magic-numbers\": \"off\",\n \"no-plusplus\": \"off\",\n \"no-regex-spaces\": \"off\", // `regexp/prefer-quantifier` covers this\n \"no-ternary\": \"off\",\n \"no-undef\": \"off\",\n \"no-undefined\": \"off\",\n \"no-useless-return\": \"off\",\n \"no-void\": \"off\",\n \"one-var\": \"off\",\n \"require-await\": \"off\",\n \"sort-imports\": \"off\",\n \"sort-keys\": \"off\",\n\n \"import/exports-last\": \"off\",\n \"import/group-exports\": \"off\",\n \"import/max-dependencies\": \"off\",\n \"import/no-named-export\": \"off\",\n \"import/no-nodejs-modules\": \"off\",\n \"import/no-unassigned-import\": \"off\",\n \"import/prefer-default-export\": \"off\",\n\n \"jsdoc/require-param\": \"off\",\n \"jsdoc/require-returns\": \"off\",\n\n \"node/callback-return\": \"off\",\n \"node/no-sync\": \"off\",\n \"node/no-top-level-await\": \"off\",\n\n \"oxc/no-async-await\": \"off\",\n \"oxc/no-optional-chaining\": \"off\",\n \"oxc/no-rest-spread-properties\": \"off\",\n\n \"react/exhaustive-effect-dependencies\": \"off\", // `react/exhaustive-deps` covers this\n \"react/forbid-component-props\": \"off\",\n \"react/hooks\": \"off\", // `react/rules-of-hooks` covers this\n \"react/invariant\": \"off\",\n \"react/jsx-filename-extension\": \"off\",\n \"react/jsx-max-depth\": \"off\",\n \"react/jsx-no-literals\": \"off\",\n \"react/memo-dependencies\": \"off\", // `react/exhaustive-deps` covers this\n \"react/no-deriving-state-in-effects\": \"off\", // `react/set-state-in-effect` covers this\n \"react/react-in-jsx-scope\": \"off\",\n \"react/rule-suppression\": \"off\",\n \"react/todo\": \"off\",\n\n \"typescript/consistent-return\": \"off\",\n \"typescript/explicit-function-return-type\": \"off\",\n \"typescript/explicit-module-boundary-types\": \"off\",\n \"typescript/prefer-readonly-parameter-types\": \"off\",\n \"typescript/strict-boolean-expressions\": \"off\",\n\n \"unicorn/no-array-callback-reference\": \"off\",\n \"unicorn/no-array-method-this-argument\": \"off\",\n \"unicorn/no-await-expression-member\": \"off\",\n \"unicorn/no-process-exit\": \"off\",\n \"unicorn/number-literal-case\": \"off\",\n \"unicorn/switch-case-braces\": \"off\",\n\n \"vitest/no-hooks\": \"off\",\n \"vitest/no-importing-vitest-globals\": \"off\",\n \"vitest/prefer-describe-function-title\": \"off\",\n \"vitest/prefer-expect-assertions\": \"off\",\n \"vitest/prefer-importing-vitest-globals\": \"off\",\n \"vitest/prefer-lowercase-title\": \"off\",\n \"vitest/prefer-to-be-falsy\": \"off\",\n \"vitest/prefer-to-be-truthy\": \"off\",\n \"vitest/require-hook\": \"off\", // reenable when false positives are fixed?\n \"vitest/require-test-timeout\": \"off\",\n },\n} as const satisfies OxlintConfig\n\nconst enabledPluginEntries = Object.entries(plugins).filter(([, plugin]) => plugin.enabled ?? true)\nconst enabledPlugins = enabledPluginEntries.map(([, plugin]) => plugin)\n// Resolve JS plugins to absolute paths so consumers load them from this package's own deps.\nconst resolvedPluginPackages = enabledPlugins.map((plugin) => resolvePackagePath(plugin.package))\nconst pluginOverrides = enabledPlugins.flatMap((plugin) => plugin.overrides ?? [])\nconst pluginSettings = Object.fromEntries(enabledPlugins.flatMap((plugin) => Object.entries(plugin.settings ?? {})))\n\n/** Lists a plugin's rules as entries */\nconst toPluginRuleEntries = ([name, { pluginRules = {}, rules }]: [string, PluginPart]) => {\n const defaultRules = setAllPluginRules(name, pluginRules, \"error\")\n const pluginRuleEntries = Object.entries({ ...defaultRules, ...rules })\n return pluginRuleEntries\n}\n\nconst resolvedPluginRules = Object.fromEntries(enabledPluginEntries.flatMap(toPluginRuleEntries))\n\nconst baseConfig = {\n ...nativeConfig,\n jsPlugins: resolvedPluginPackages,\n overrides: [...nativeConfig.overrides, ...pluginOverrides],\n rules: {\n ...resolvedPluginRules,\n ...nativeConfig.rules,\n },\n settings: pluginSettings,\n} satisfies OxlintConfig\n\nexport const oxlintConfig = createMergeConfigFn<OxlintConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,qBAAqB,MAAc,OAAgC,aACvE,OAAO,YAAY,OAAO,KAAK,KAAK,CAAC,CAAC,KAAK,SAAS,CAAC,GAAG,KAAK,GAAG,QAAQ,QAAQ,CAAU,CAAC;AAgB7F,MAAM,EAAE,cAAc,YAAY,uBAAuB;AACzD,MAAM,qBAAqB,uBAAuB;AAGlD,MAAM,UAAsC;CAC1C,SAAS;EACP,WAAW,CACT;GACE,cAAc;IAAC;IAAuB;IAA0B;IAAwB;GAAsB;GAE9G,OAAO,QAAQ,IAAI,MAAM,IAAI,CAAC,QAAQ,IAAI,CAAC;GAC3C,OAAO,kBAAkB,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YAAY,eAAe,SAAS,WAAW,OAAO,QAAQ,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;;AAGnH,MAAM,uBAAuB,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,aAAmC;CACzF,MAAM,eAAe,kBAAkB,MAAM,aAAa,OAAO;CAEjE,OAD0B,OAAO,QAAQ;EAAE,GAAG;EAAc,GAAG;CAAM,CAC9C;AACzB;AAEA,MAAM,sBAAsB,OAAO,YAAY,qBAAqB,QAAQ,mBAAmB,CAAC;AAEhG,MAAM,aAAa;CACjB,GAAG;CACH,WAAW;CACX,WAAW,CAAC,GAAG,aAAa,WAAW,GAAG,eAAe;CACzD,OAAO;EACL,GAAG;EACH,GAAG,aAAa;CAClB;CACA,UAAU;AACZ;AAEA,MAAa,eAAe,oBAAqD,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-it.base.js","names":[],"sources":["../../src/configs/release-it.base.ts"],"sourcesContent":["// oxlint-disable no-template-curly-in-string\nimport type { Config } from \"release-it\"\n\nimport { createMergeConfigFn } from \"#merge-config/merge-config.ts\"\nimport { configFilePath } from \"#utils.ts\"\n\n// release-it's `Hooks` type only lists the hooks of its built-in plugins.\ntype PluginHooks = Partial<Record<`${\"before\" | \"after\"}:${string}`, string | string[]>>\ntype ReleaseItConfig = Config & { hooks?: PluginHooks }\n\nconst baseConfig = {\n hooks: {\n \"before:init\": \"bunx bask build\",\n \"after:release-it-git-cliff:beforeRelease\": \"bun oxfmt CHANGELOG.md\",\n },\n plugins: {\n \"release-it-git-cliff\": {\n config: configFilePath(\"cliff.base.toml\"),\n output: \"CHANGELOG.md\",\n },\n },\n git: {\n commitMessage: \"release: ${tagName}\",\n // Set the `v` explicitly because release-it only detects it from an existing tag.\n tagName: \"v${version}\",\n tagAnnotation: \"release ${tagName}\",\n addUntrackedFiles: true,\n },\n github: {\n release: true,\n releaseName: \"${tagName}\",\n },\n npm: {\n publishPackageManager: \"bun\",\n publishPath: \"\",\n publishArgs: [\"--ignore-scripts\"],\n },\n} as const satisfies ReleaseItConfig\n\nexport const releaseItConfig = createMergeConfigFn<ReleaseItConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";;;AAUA,MAAM,aAAa;CACjB,OAAO;EACL,eAAe;EACf,4CAA4C;CAC9C;CACA,SAAS,EACP,wBAAwB;EACtB,QAAQ,eAAe,iBAAiB;EACxC,QAAQ;CACV,EACF;CACA,KAAK;EACH,eAAe;EAEf,SAAS;EACT,eAAe;EACf,mBAAmB;CACrB;CACA,QAAQ;EACN,SAAS;EACT,aAAa;CACf;CACA,KAAK;EACH,uBAAuB;EACvB,aAAa;EACb,aAAa,CAAC,kBAAkB;CAClC;AACF;AAEA,MAAa,kBAAkB,oBAAwD,UAAU"}
|
|
1
|
+
{"version":3,"file":"release-it.base.js","names":[],"sources":["../../src/configs/release-it.base.ts"],"sourcesContent":["// oxlint-disable no-template-curly-in-string - These aren't real string templates, they are templates replaced by release-it\nimport type { Config } from \"release-it\"\n\nimport { createMergeConfigFn } from \"#merge-config/merge-config.ts\"\nimport { configFilePath } from \"#utils.ts\"\n\n// release-it's `Hooks` type only lists the hooks of its built-in plugins.\ntype PluginHooks = Partial<Record<`${\"before\" | \"after\"}:${string}`, string | string[]>>\ntype ReleaseItConfig = Config & { hooks?: PluginHooks }\n\nconst baseConfig = {\n hooks: {\n \"before:init\": \"bunx bask build\",\n \"after:release-it-git-cliff:beforeRelease\": \"bun oxfmt CHANGELOG.md\",\n },\n plugins: {\n \"release-it-git-cliff\": {\n config: configFilePath(\"cliff.base.toml\"),\n output: \"CHANGELOG.md\",\n },\n },\n git: {\n commitMessage: \"release: ${tagName}\",\n // Set the `v` explicitly because release-it only detects it from an existing tag.\n tagName: \"v${version}\",\n tagAnnotation: \"release ${tagName}\",\n addUntrackedFiles: true,\n },\n github: {\n release: true,\n releaseName: \"${tagName}\",\n },\n npm: {\n publishPackageManager: \"bun\",\n publishPath: \"\",\n publishArgs: [\"--ignore-scripts\"],\n },\n} as const satisfies ReleaseItConfig\n\nexport const releaseItConfig = createMergeConfigFn<ReleaseItConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";;;AAUA,MAAM,aAAa;CACjB,OAAO;EACL,eAAe;EACf,4CAA4C;CAC9C;CACA,SAAS,EACP,wBAAwB;EACtB,QAAQ,eAAe,iBAAiB;EACxC,QAAQ;CACV,EACF;CACA,KAAK;EACH,eAAe;EAEf,SAAS;EACT,eAAe;EACf,mBAAmB;CACrB;CACA,QAAQ;EACN,SAAS;EACT,aAAa;CACf;CACA,KAAK;EACH,uBAAuB;EACvB,aAAa;EACb,aAAa,CAAC,kBAAkB;CAClC;AACF;AAEA,MAAa,kBAAkB,oBAAwD,UAAU"}
|
package/dist/env/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["arkenvType","type"],"sources":["../../src/env/utils.ts"],"sourcesContent":["import { type as arkenvType } from \"arkenv\"\nimport type { type as arktype } from \"arktype\"\n\n/**\n * Makes an env var required while `when` is true, otherwise optional.\n *\n * A set value must always satisfy `def`. An unset var takes `fallback` (exempt from `def` validation), or the key is\n * omitted entirely if no fallback is given.\n */\nexport function requireWhen<const def>(\n when: boolean,\n type: arktype.validate<def>,\n): ReturnType<arktype.instantiate<def>[\"optional\"]>\nexport function requireWhen<const def>(\n when: boolean,\n type: arktype.validate<def>,\n fallback: arktype.infer<def>,\n): arktype.instantiate<def>\n/* oxlint-disable typescript/no-unsafe-type-assertion */\nexport function requireWhen(when: boolean, type: unknown, ...rest: [unknown?]): never {\n const t = arkenvType.raw(type)\n if (when) return t as never\n if (rest.length === 0) return t.optional() as never\n const [fallback] = rest\n // defaulting to a sentinel keeps the fallback exempt from def validation without\n // letting an explicitly set value bypass it (env values can never be a symbol)\n const unset = Symbol(\"unset\")\n return t\n .or(arkenvType.unit(unset))\n .pipe((v: unknown) => (v === unset ? fallback : v))\n .default(unset as never) as never\n}\n"],"mappings":";;AAmBA,SAAgB,YAAY,MAAe,QAAe,GAAG,MAAyB;CACpF,MAAM,IAAIA,KAAW,IAAIC,MAAI;CAC7B,IAAI,MAAM,OAAO;CACjB,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,SAAS;CACzC,MAAM,CAAC,YAAY;CAGnB,MAAM,QAAQ,OAAO,OAAO;CAC5B,OAAO,EACJ,GAAGD,KAAW,KAAK,KAAK,CAAC,CAAC,CAC1B,MAAM,MAAgB,MAAM,QAAQ,WAAW,CAAE,CAAC,CAClD,QAAQ,KAAc;AAC3B"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["arkenvType","type"],"sources":["../../src/env/utils.ts"],"sourcesContent":["import { type as arkenvType } from \"arkenv\"\nimport type { type as arktype } from \"arktype\"\n\n/**\n * Makes an env var required while `when` is true, otherwise optional.\n *\n * A set value must always satisfy `def`. An unset var takes `fallback` (exempt from `def` validation), or the key is\n * omitted entirely if no fallback is given.\n */\nexport function requireWhen<const def>(\n when: boolean,\n type: arktype.validate<def>,\n): ReturnType<arktype.instantiate<def>[\"optional\"]>\nexport function requireWhen<const def>(\n when: boolean,\n type: arktype.validate<def>,\n fallback: arktype.infer<def>,\n): arktype.instantiate<def>\n/* oxlint-disable typescript/no-unsafe-type-assertion - cast to the types the overload signatures declare */\nexport function requireWhen(when: boolean, type: unknown, ...rest: [unknown?]): never {\n const t = arkenvType.raw(type)\n if (when) return t as never\n if (rest.length === 0) return t.optional() as never\n const [fallback] = rest\n // defaulting to a sentinel keeps the fallback exempt from def validation without\n // letting an explicitly set value bypass it (env values can never be a symbol)\n const unset = Symbol(\"unset\")\n return t\n .or(arkenvType.unit(unset))\n .pipe((v: unknown) => (v === unset ? fallback : v))\n .default(unset as never) as never\n}\n/* oxlint-enable typescript/no-unsafe-type-assertion - limit the exemption to `requireWhen` */\n"],"mappings":";;AAmBA,SAAgB,YAAY,MAAe,QAAe,GAAG,MAAyB;CACpF,MAAM,IAAIA,KAAW,IAAIC,MAAI;CAC7B,IAAI,MAAM,OAAO;CACjB,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,SAAS;CACzC,MAAM,CAAC,YAAY;CAGnB,MAAM,QAAQ,OAAO,OAAO;CAC5B,OAAO,EACJ,GAAGD,KAAW,KAAK,KAAK,CAAC,CAAC,CAC1B,MAAM,MAAgB,MAAM,QAAQ,WAAW,CAAE,CAAC,CAClD,QAAQ,KAAc;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-config.d.ts","names":[],"sources":["../../src/merge-config/merge-config.ts"],"mappings":";;;;;;;;;;;;;YAgCY,cAAc,YAAY,sBAAsB,0BAA0B,aAAa,aACjG,YAAY,sBACT,aAAa,YAAY,8BAEpB,0BAA0B,aAAa,mBACvC,6BAA6B,aAAa,QAAQ,cAExD,YAAY,mBACZ,eAAe,yBACZ,aAAa,aAAa,YAAY,oBAAoB;;YAGrD,sBAAsB,YAAY,cAAc,cAAc,YAAY,
|
|
1
|
+
{"version":3,"file":"merge-config.d.ts","names":[],"sources":["../../src/merge-config/merge-config.ts"],"mappings":";;;;;;;;;;;;;YAgCY,cAAc,YAAY,sBAAsB,0BAA0B,aAAa,aACjG,YAAY,sBACT,aAAa,YAAY,8BAEpB,0BAA0B,aAAa,mBACvC,6BAA6B,aAAa,QAAQ,cAExD,YAAY,mBACZ,eAAe,yBACZ,aAAa,aAAa,YAAY,oBAAoB;;YAGrD,sBAAsB,YAAY,cAAc,cAAc,YAAY,qBAC3E,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-config.js","names":["baseArray"],"sources":["../../src/merge-config/merge-config.ts"],"sourcesContent":["/* oxlint-disable unicorn/prefer-structured-clone
|
|
1
|
+
{"version":3,"file":"merge-config.js","names":["baseArray"],"sources":["../../src/merge-config/merge-config.ts"],"sourcesContent":["/* oxlint-disable unicorn/prefer-structured-clone - structuredClone does not properly clone functions */\nimport { cloneDeep, mergeWith } from \"es-toolkit\"\nimport type { ReadonlyDeep } from \"type-fest\"\n\nimport type { Clean, MergedConfig, Mode } from \"#merge-config/merge.types.ts\"\n\n/**\n * The runtime counterpart of MergedConfig in merge.types.ts: a deep merge whose customizer applies the array mode. The\n * source is pre-cloned so the result never aliases the caller's objects. The merge visits string keys only, so\n * symbol-keyed properties in user configs are dropped (the types mirror this).\n */\nconst merge = (target: object, source: object, mode: Mode): object =>\n mergeWith(target, cloneDeep(source), (objValue: unknown, srcValue: unknown) => {\n if (!Array.isArray(srcValue)) return\n const userArray: unknown[] = srcValue\n if (mode === \"spread\" && Array.isArray(objValue)) {\n const baseArray: unknown[] = objValue\n return [...baseArray, ...userArray]\n }\n return userArray\n })\n\n/**\n * The merge config function. `userConfig` is deep merged into `BaseConfig` with arrays appended to the base array. The\n * optional `replaceConfig` is then deep merged into that result with arrays used as-is, so putting an array there\n * replaces just that key (sibling keys still merge normally, and a key in both configs gets the replace config's\n * value). Required keys must be provided in `userConfig`.\n *\n * The `const` type parameters keep literal types without requiring `as const` at the call site. The constraints accept\n * readonly arrays/objects (e.g. from `as const`), and the result is writable so it stays assignable to the tools' own\n * (mutable) config types.\n */\nexport type MergeConfigFn<UserConfig, BaseConfig> = (<const UserConfigToMerge extends ReadonlyDeep<UserConfig>>(\n userConfig: UserConfigToMerge,\n) => MergedConfig<BaseConfig, UserConfigToMerge>)\n & (<\n const UserConfigToMerge extends ReadonlyDeep<UserConfig>,\n const ReplaceConfigToMerge extends ReadonlyDeep<Partial<UserConfig>>,\n >(\n userConfig: UserConfigToMerge,\n replaceConfig: ReplaceConfigToMerge,\n ) => MergedConfig<MergedConfig<BaseConfig, UserConfigToMerge>, ReplaceConfigToMerge, \"replace\">)\n\n/** A MergeConfigFn that can also be called with no arguments, returning a writable clone of the base config. */\nexport type OptionalMergeConfigFn<UserConfig, BaseConfig> = MergeConfigFn<UserConfig, BaseConfig>\n & (() => Clean<BaseConfig>)\n\n/**\n * Creates a config merge function with proper types for merging with a base config. `UserConfig` is not inferrable, so\n * both type arguments must be passed explicitly.\n */\nexport const createMergeConfigFn = <UserConfig extends object, BaseConfig extends ReadonlyDeep<UserConfig>>(\n baseConfig: BaseConfig,\n): OptionalMergeConfigFn<UserConfig, BaseConfig> => {\n // Loosely typed on purpose, the assertion below gives it the precise public signature\n const mergeConfigFn = (userConfig?: object, replaceConfig?: object) => {\n // Start from a clone so consumers can't mutate the shared base config\n const result = cloneDeep(baseConfig)\n if (userConfig !== undefined) merge(result, userConfig, \"spread\")\n if (replaceConfig !== undefined) merge(result, replaceConfig, \"replace\")\n return result\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion - give the loosely typed implementation its precise public signature\n return mergeConfigFn as OptionalMergeConfigFn<UserConfig, BaseConfig>\n}\n"],"mappings":";;;;;;;AAWA,MAAM,SAAS,QAAgB,QAAgB,SAC7C,UAAU,QAAQ,UAAU,MAAM,IAAI,UAAmB,aAAsB;CAC7E,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;CAC9B,MAAM,YAAuB;CAC7B,IAAI,SAAS,YAAY,MAAM,QAAQ,QAAQ,GAE7C,OAAO,CAAC,GAAGA,UAAW,GAAG,SAAS;CAEpC,OAAO;AACT,CAAC;;;;;AA+BH,MAAa,uBACX,eACkD;CAElD,MAAM,iBAAiB,YAAqB,kBAA2B;EAErE,MAAM,SAAS,UAAU,UAAU;EACnC,IAAI,eAAe,KAAA,GAAW,MAAM,QAAQ,YAAY,QAAQ;EAChE,IAAI,kBAAkB,KAAA,GAAW,MAAM,QAAQ,eAAe,SAAS;EACvE,OAAO;CACT;CAGA,OAAO;AACT"}
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { existsSync, globSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { isPlainObject } from "es-toolkit/predicate";
|
|
3
5
|
//#region src/utils.ts
|
|
4
6
|
const CONFIG_DIRS = ["./configs/", "../configs/"];
|
|
5
7
|
/** Returns the absolute path of a file in this package's `configs` folder. */
|
|
@@ -11,7 +13,34 @@ const configFilePath = (name) => {
|
|
|
11
13
|
};
|
|
12
14
|
/** Returns the absolute path of a package's entry file, resolved from this package's dependencies. */
|
|
13
15
|
const resolvePackagePath = (specifier) => fileURLToPath(import.meta.resolve(specifier));
|
|
16
|
+
const keysOf = (value) => isPlainObject(value) ? Object.keys(value) : [];
|
|
17
|
+
/**
|
|
18
|
+
* Reads the project's `package.json` fields that the base configs branch on. `dependencies` merges the regular, dev,
|
|
19
|
+
* and peer dependency names.
|
|
20
|
+
*/
|
|
21
|
+
const readProjectPackageJson = () => {
|
|
22
|
+
const packageJson = existsSync("package.json") ? JSON.parse(readFileSync("package.json", "utf8")) : {};
|
|
23
|
+
const fields = isPlainObject(packageJson) ? packageJson : {};
|
|
24
|
+
return {
|
|
25
|
+
dependencies: new Set([
|
|
26
|
+
"dependencies",
|
|
27
|
+
"devDependencies",
|
|
28
|
+
"peerDependencies"
|
|
29
|
+
].flatMap((field) => keysOf(fields[field]))),
|
|
30
|
+
engines: new Set(keysOf(fields["engines"]))
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const TAILWIND_IMPORT = /@import\s*["']tailwindcss(?:\/[^"']+)?["']/v;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the project's Tailwind stylesheet relative to the project root, or `false` when the project doesn't use
|
|
36
|
+
* Tailwind. The stylesheet is the first CSS file, in sorted order, that imports `tailwindcss`.
|
|
37
|
+
*/
|
|
38
|
+
const resolveProjectTailwind = () => {
|
|
39
|
+
const { dependencies } = readProjectPackageJson();
|
|
40
|
+
if (!dependencies.has("tailwindcss")) return false;
|
|
41
|
+
return globSync("**/*.{css,scss,sass,less,pcss}", { exclude: (filePath) => ["node_modules", ".git"].includes(path.basename(filePath)) }).toSorted().find((file) => TAILWIND_IMPORT.test(readFileSync(file, "utf8"))) ?? false;
|
|
42
|
+
};
|
|
14
43
|
//#endregion
|
|
15
|
-
export { configFilePath, resolvePackagePath };
|
|
44
|
+
export { configFilePath, readProjectPackageJson, resolvePackagePath, resolveProjectTailwind };
|
|
16
45
|
|
|
17
46
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { existsSync } from \"node:fs\"\nimport { fileURLToPath } from \"node:url\"\n\n// Check both folders because a bin bundles this file into `<bin>/index`, one level below `configs`.\nconst CONFIG_DIRS = [\"./configs/\", \"../configs/\"] as const\n\n/** Returns the absolute path of a file in this package's `configs` folder. */\nexport const configFilePath = (name: string) => {\n const filePaths = CONFIG_DIRS.map((dir) => fileURLToPath(new URL(`${dir}${name}`, import.meta.url)))\n const filePath = filePaths.find((candidate) => existsSync(candidate))\n if (!filePath) throw new Error(`Couldn't find config file \"${name}\" in:\\n${filePaths.join(\"\\n\")}`)\n return filePath\n}\n\n/** Returns the absolute path of a package's entry file, resolved from this package's dependencies. */\nexport const resolvePackagePath = (specifier: string) => fileURLToPath(import.meta.resolve(specifier))\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { existsSync, globSync, readFileSync } from \"node:fs\"\nimport path from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport { isPlainObject } from \"es-toolkit/predicate\"\n\n// Check both folders because a bin bundles this file into `<bin>/index`, one level below `configs`.\nconst CONFIG_DIRS = [\"./configs/\", \"../configs/\"] as const\n\n/** Returns the absolute path of a file in this package's `configs` folder. */\nexport const configFilePath = (name: string) => {\n const filePaths = CONFIG_DIRS.map((dir) => fileURLToPath(new URL(`${dir}${name}`, import.meta.url)))\n const filePath = filePaths.find((candidate) => existsSync(candidate))\n if (!filePath) throw new Error(`Couldn't find config file \"${name}\" in:\\n${filePaths.join(\"\\n\")}`)\n return filePath\n}\n\n/** Returns the absolute path of a package's entry file, resolved from this package's dependencies. */\nexport const resolvePackagePath = (specifier: string) => fileURLToPath(import.meta.resolve(specifier))\n\nconst keysOf = (value: unknown) => (isPlainObject(value) ? Object.keys(value) : [])\n\n/**\n * Reads the project's `package.json` fields that the base configs branch on. `dependencies` merges the regular, dev,\n * and peer dependency names.\n */\nexport const readProjectPackageJson = () => {\n const packageJson: unknown = existsSync(\"package.json\") ? JSON.parse(readFileSync(\"package.json\", \"utf8\")) : {}\n const fields = isPlainObject(packageJson) ? packageJson : {}\n\n const dependencyFields = [\"dependencies\", \"devDependencies\", \"peerDependencies\"]\n const dependencies = new Set(dependencyFields.flatMap((field) => keysOf(fields[field])))\n const engines = new Set(keysOf(fields[\"engines\"]))\n\n return { dependencies, engines }\n}\n\n// Match entry stylesheets the same way `@tailwindcss/language-server` does.\nconst TAILWIND_IMPORT = /@import\\s*[\"']tailwindcss(?:\\/[^\"']+)?[\"']/v\n\n/**\n * Returns the project's Tailwind stylesheet relative to the project root, or `false` when the project doesn't use\n * Tailwind. The stylesheet is the first CSS file, in sorted order, that imports `tailwindcss`.\n */\nexport const resolveProjectTailwind = () => {\n const { dependencies } = readProjectPackageJson()\n if (!dependencies.has(\"tailwindcss\")) return false\n\n const stylesheets = globSync(\"**/*.{css,scss,sass,less,pcss}\", {\n exclude: (filePath) => [\"node_modules\", \".git\"].includes(path.basename(filePath)),\n }).toSorted()\n\n return stylesheets.find((file) => TAILWIND_IMPORT.test(readFileSync(file, \"utf8\"))) ?? false\n}\n"],"mappings":";;;;;AAOA,MAAM,cAAc,CAAC,cAAc,aAAa;;AAGhD,MAAa,kBAAkB,SAAiB;CAC9C,MAAM,YAAY,YAAY,KAAK,QAAQ,cAAc,IAAI,IAAI,GAAG,MAAM,QAAQ,YAAY,GAAG,CAAC,CAAC;CACnG,MAAM,WAAW,UAAU,MAAM,cAAc,WAAW,SAAS,CAAC;CACpE,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8BAA8B,KAAK,SAAS,UAAU,KAAK,IAAI,GAAG;CACjG,OAAO;AACT;;AAGA,MAAa,sBAAsB,cAAsB,cAAc,YAAY,QAAQ,SAAS,CAAC;AAErG,MAAM,UAAU,UAAoB,cAAc,KAAK,IAAI,OAAO,KAAK,KAAK,IAAI,CAAC;;;;;AAMjF,MAAa,+BAA+B;CAC1C,MAAM,cAAuB,WAAW,cAAc,IAAI,KAAK,MAAM,aAAa,gBAAgB,MAAM,CAAC,IAAI,CAAC;CAC9G,MAAM,SAAS,cAAc,WAAW,IAAI,cAAc,CAAC;CAM3D,OAAO;EAAE,cAAA,IAHgB,IAAI;GADH;GAAgB;GAAmB;EACjB,CAAC,CAAC,SAAS,UAAU,OAAO,OAAO,MAAM,CAAC,CAGlE;EAAG,SAAA,IAFH,IAAI,OAAO,OAAO,UAAU,CAEnB;CAAE;AACjC;AAGA,MAAM,kBAAkB;;;;;AAMxB,MAAa,+BAA+B;CAC1C,MAAM,EAAE,iBAAiB,uBAAuB;CAChD,IAAI,CAAC,aAAa,IAAI,aAAa,GAAG,OAAO;CAM7C,OAJoB,SAAS,kCAAkC,EAC7D,UAAU,aAAa,CAAC,gBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,SAAS,QAAQ,CAAC,EAClF,CAAC,CAAC,CAAC,SAEc,CAAC,CAAC,MAAM,SAAS,gBAAgB,KAAK,aAAa,MAAM,MAAM,CAAC,CAAC,KAAK;AACzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "My shared configs for TS projects",
|
|
5
5
|
"homepage": "https://github.com/adamhl8/configs",
|
|
6
6
|
"bugs": {
|
|
@@ -50,24 +50,32 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@adamhl8/eslint-plugin-clean-modules": "^0.1.5",
|
|
53
|
-
"@commitlint/config-conventional": "^21.2.
|
|
53
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
54
54
|
"@commitlint/types": "^21.2.3",
|
|
55
|
+
"@e18e/eslint-plugin": "^0.8.1",
|
|
55
56
|
"arkenv": "^0.12.3",
|
|
56
|
-
"arktype": "^2.2.
|
|
57
|
+
"arktype": "^2.2.9",
|
|
57
58
|
"es-toolkit": "^1.52.0",
|
|
59
|
+
"eslint-plugin-bunisms": "^0.11.0",
|
|
60
|
+
"eslint-plugin-hono": "^1.1.0",
|
|
61
|
+
"eslint-plugin-react-web-api": "^5.28.7",
|
|
62
|
+
"eslint-plugin-react-you-might-not-need-an-effect": "^1.0.2",
|
|
63
|
+
"eslint-plugin-regexp": "^3.3.1",
|
|
64
|
+
"oxlint-plugin-directive-comments": "^0.1.0",
|
|
65
|
+
"oxlint-tailwindcss": "^1.16.0",
|
|
58
66
|
"ts-explicit-errors": "^4.1.3",
|
|
59
67
|
"type-fest": "^5.10.0"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
62
|
-
"@adamhl8/bask": "^0.
|
|
70
|
+
"@adamhl8/bask": "^0.5.0",
|
|
63
71
|
"@adamhl8/configs": "file:.",
|
|
64
72
|
"@arethetypeswrong/core": "^0.18.5",
|
|
65
|
-
"@commitlint/cli": "^21.2.
|
|
73
|
+
"@commitlint/cli": "^21.2.4",
|
|
66
74
|
"@types/bun": "^1.4.3",
|
|
67
|
-
"knip": "^6.
|
|
75
|
+
"knip": "^6.42.1",
|
|
68
76
|
"markdown-toc": "^1.2.0",
|
|
69
|
-
"oxfmt": "^0.
|
|
70
|
-
"oxlint": "^1.
|
|
77
|
+
"oxfmt": "^0.74.0",
|
|
78
|
+
"oxlint": "^1.89.0",
|
|
71
79
|
"oxlint-tsgolint": "^7.0.2004",
|
|
72
80
|
"publint": "^0.3.25",
|
|
73
81
|
"release-it": "^21.1.1",
|
|
@@ -76,25 +84,30 @@
|
|
|
76
84
|
"typescript": "^7.0.2"
|
|
77
85
|
},
|
|
78
86
|
"peerDependencies": {
|
|
79
|
-
"@adamhl8/bask": ">=0.
|
|
80
|
-
"@arethetypeswrong/core": ">=0.18",
|
|
87
|
+
"@adamhl8/bask": ">=0.3",
|
|
88
|
+
"@arethetypeswrong/core": ">=0.18.1",
|
|
81
89
|
"@commitlint/cli": ">=21",
|
|
82
90
|
"@commitlint/config-conventional": ">=21",
|
|
91
|
+
"@tailwindcss/language-server": ">=0.14",
|
|
83
92
|
"knip": ">=6",
|
|
84
93
|
"markdown-toc": ">=1",
|
|
85
|
-
"oxfmt": ">=0.
|
|
86
|
-
"oxlint": ">=1",
|
|
87
|
-
"oxlint-tsgolint": ">=0.
|
|
88
|
-
"publint": ">=0.3",
|
|
89
|
-
"release-it": ">=21",
|
|
94
|
+
"oxfmt": ">=0.73",
|
|
95
|
+
"oxlint": ">=1.79",
|
|
96
|
+
"oxlint-tsgolint": ">=7.0.2004",
|
|
97
|
+
"publint": ">=0.3.8",
|
|
98
|
+
"release-it": ">=21.1",
|
|
90
99
|
"release-it-git-cliff": ">=0.1",
|
|
91
|
-
"
|
|
100
|
+
"tailwint": ">=1.1",
|
|
101
|
+
"tsdown": ">=0.22.7",
|
|
92
102
|
"typescript": "^7.0.0"
|
|
93
103
|
},
|
|
94
104
|
"peerDependenciesMeta": {
|
|
95
105
|
"@arethetypeswrong/core": {
|
|
96
106
|
"optional": true
|
|
97
107
|
},
|
|
108
|
+
"@tailwindcss/language-server": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
98
111
|
"publint": {
|
|
99
112
|
"optional": true
|
|
100
113
|
},
|
|
@@ -104,8 +117,14 @@
|
|
|
104
117
|
"release-it-git-cliff": {
|
|
105
118
|
"optional": true
|
|
106
119
|
},
|
|
120
|
+
"tailwint": {
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
107
123
|
"tsdown": {
|
|
108
124
|
"optional": true
|
|
109
125
|
}
|
|
126
|
+
},
|
|
127
|
+
"engines": {
|
|
128
|
+
"bun": ">=1.4"
|
|
110
129
|
}
|
|
111
130
|
}
|