Skip to content

Commit 5f43969

Browse files
committed
feat(lint): add default lint rules
1 parent 582cd8e commit 5f43969

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed

.changeset/afraid-heads-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@bomb.sh/tools": minor
3+
---
4+
5+
Add default lint rules with oxlint

oxlintrc.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["unicorn", "typescript", "oxc", "import", "node"],
4+
"jsPlugins": ["./rules/plugin.js"],
5+
"categories": {
6+
"correctness": "error",
7+
"suspicious": "warn"
8+
},
9+
"rules": {
10+
"no-restricted-imports": [
11+
"error",
12+
{
13+
"paths": [
14+
{
15+
"name": "node:path",
16+
"message": "Use File URLs (new URL()) instead. Only use fileURLToPath() at third-party module boundaries."
17+
},
18+
{
19+
"name": "path",
20+
"message": "Use File URLs (new URL()) instead. Only use fileURLToPath() at third-party module boundaries."
21+
},
22+
{
23+
"name": "node:path/posix",
24+
"message": "Use File URLs (new URL()) instead."
25+
},
26+
{
27+
"name": "node:path/win32",
28+
"message": "Use File URLs (new URL()) instead."
29+
}
30+
]
31+
}
32+
],
33+
"import/no-commonjs": "error",
34+
"node/no-path-concat": "error"
35+
}
36+
}

rules/plugin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import("oxlint").Plugin} */
2+
const plugin = {
3+
meta: {
4+
name: "bombshell-dev",
5+
},
6+
rules: {},
7+
};
8+
9+
export default plugin;

src/commands/init.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { readFile, writeFile } from "node:fs/promises";
2-
import { dirname, sep } from "node:path";
32
import { cwd } from "node:process";
43
import { pathToFileURL } from "node:url";
54
import { x } from "tinyexec";
65
import type { CommandContext } from "../context.ts";
76

87
export async function init(ctx: CommandContext) {
98
const [_name = "."] = ctx.args;
10-
const name = _name === "." ? dirname(cwd()) : _name;
11-
const dest = new URL("./.temp/", pathToFileURL([cwd(), sep].join("")));
9+
const cwdUrl = pathToFileURL(`${cwd()}/`);
10+
const name = _name === "." ? new URL("../", cwdUrl).pathname.split("/").filter(Boolean).pop()! : _name;
11+
const dest = new URL("./.temp/", cwdUrl);
1212
for await (const line of x("pnpx", ["giget@latest", "gh:bombshell-dev/template", name])) {
1313
console.log(line);
1414
}

src/commands/lint.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import { fileURLToPath } from "node:url";
12
import { x } from "tinyexec";
23
import type { CommandContext } from "../context.ts";
34
import { local } from "../utils.ts";
45

6+
const config = fileURLToPath(new URL("../../oxlintrc.json", import.meta.url));
7+
58
export async function lint(ctx: CommandContext) {
6-
const oxlint = x(local("oxlint"), ["./src", ...ctx.args]);
9+
const oxlint = x(local("oxlint"), ["-c", config, "./src", ...ctx.args]);
710

811
for await (const line of oxlint) {
912
console.log(line);

0 commit comments

Comments
 (0)