Skip to content

Commit 91ed16f

Browse files
committed
replace eslint with biome
1 parent 8dc68dd commit 91ed16f

29 files changed

Lines changed: 278 additions & 1541 deletions

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
yarn lint && yarn lint:shell

.vscode/settings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.organizeImports.biome": true
5+
},
6+
"[javascript]": {
7+
"editor.defaultFormatter": "biomejs.biome"
8+
},
9+
"[typescript]": {
10+
"editor.defaultFormatter": "biomejs.biome"
11+
},
12+
"[typescriptreact]": {
13+
"editor.defaultFormatter": "biomejs.biome"
14+
},
15+
"[json]": {
16+
"editor.defaultFormatter": "biomejs.biome"
17+
}
18+
}

biome.jsonc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.2/schema.json",
3+
"files": {
4+
"includes": ["**", "!node_modules/*", "!**/node_modules/*", "!**/dist/*"]
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"suspicious": {
10+
"noExplicitAny": "off"
11+
}
12+
}
13+
},
14+
"formatter": {
15+
"indentStyle": "space",
16+
"indentWidth": 2,
17+
"lineWidth": 120
18+
},
19+
"javascript": {
20+
"formatter": {
21+
"quoteStyle": "single",
22+
"jsxQuoteStyle": "double"
23+
}
24+
}
25+
}

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
"packages/*"
66
],
77
"devDependencies": {
8+
"@biomejs/biome": "^2.2.2",
89
"@tsconfig/node-ts": "^23.6.1",
910
"@tsconfig/node22": "^22.0.2",
1011
"@types/node": "22",
11-
"babel-eslint": "^8.2.3",
12-
"eslint": "^4.19.1",
13-
"husky": "^0.14.3",
12+
"husky": "^9.1.7",
1413
"typescript": "^5.9.2"
1514
},
1615
"scripts": {
17-
"precommit": "yarn lint && yarn lint:shell",
18-
"lint": "eslint 'packages/**/*.js'",
19-
"lint:shell": "belt ewnd9:lint-shell"
16+
"lint": "biome check ./packages/belt-cli/ --write",
17+
"lint:shell": "belt ewnd9:lint-shell",
18+
"prepare": "husky"
2019
}
2120
}

packages/belt-cli/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"description": "Global CLI scripts registry",
55
"private": true,
66
"type": "module",
7-
"main": "dist/index.js",
87
"bin": {
9-
"belt": "dist/index.js"
8+
"belt": "cli.js"
109
},
1110
"author": "ewnd9 <ewndnine@gmail.com>",
1211
"license": "MIT",

packages/belt-cli/src/commands/flash-drive.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
2-
3-
import execa from "../modules/execa.js";
41
import prompts from 'prompts';
2+
import execa from '../modules/execa.js';
53

64
export async function run() {
75
const dir = '/media/flashdrive';
@@ -21,10 +19,10 @@ export async function run() {
2119

2220
return {
2321
title: parts.join(' '),
24-
value: i
22+
value: i,
2523
};
2624
}),
27-
initial: devices.length - 1
25+
initial: devices.length - 1,
2826
});
2927

3028
const device = devices[value];
@@ -56,16 +54,16 @@ async function getDevices() {
5654

5755
async function getMounts() {
5856
const stdout = (await execa('cat', ['/proc/mounts'], {})) || '';
59-
return stdout
60-
.split('\n')
61-
.reduce((acc: Record<string, string>, line: string) => {
57+
return stdout.split('\n').reduce(
58+
(acc: Record<string, string>, line: string) => {
6259
const [src, dest] = line.split(' ');
6360

6461
if (src.startsWith('/dev/sd')) {
6562
acc[src] = dest;
6663
}
6764

6865
return acc;
69-
}, {} as Record<string, string>)
66+
},
67+
{} as Record<string, string>,
68+
);
7069
}
71-

packages/belt-cli/src/commands/incantation/index.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
2-
3-
import fs from 'fs';
4-
import yaml from 'js-yaml';
1+
import fs from 'node:fs';
52
import { globby } from 'globby';
6-
import { rootPath, generateCode } from "./utils.js";
3+
import yaml from 'js-yaml';
4+
import { generateCode, rootPath } from './utils.js';
75

86
export async function run() {
97
const snippetsPath = `${rootPath}/snippets`;
@@ -34,28 +32,22 @@ export async function run() {
3432
`${rootPath}/config/code/snippets/javascript.json`,
3533
`${rootPath}/config/code/snippets/javascriptreact.json`,
3634
`${rootPath}/config/code/snippets/typescript.json`,
37-
`${rootPath}/config/code/snippets/typescriptreact.json`
38-
]
35+
`${rootPath}/config/code/snippets/typescriptreact.json`,
36+
],
3937
},
4038
json: {
41-
code: `${rootPath}/config/code/snippets/json.json`
39+
code: `${rootPath}/config/code/snippets/json.json`,
4240
},
4341
jsonc: {
44-
code: `${rootPath}/config/code/snippets/jsonc.json`
42+
code: `${rootPath}/config/code/snippets/jsonc.json`,
4543
},
4644
markdown: {
47-
code: [
48-
`${rootPath}/config/code/snippets/markdown.json`
49-
]
50-
}
45+
code: [`${rootPath}/config/code/snippets/markdown.json`],
46+
},
5147
};
5248

5349
Object.entries(snippets).forEach(([lang, snippets]: [string, any]) => {
54-
generateCode(
55-
lang,
56-
snippets,
57-
arrayify((paths as any)[lang].code)
58-
);
50+
generateCode(lang, snippets, arrayify((paths as any)[lang].code));
5951
});
6052
}
6153

packages/belt-cli/src/commands/incantation/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
33

44
export const rootPath = path.resolve(`${__dirname}/../../../..`);
55

6-
export function generateCode(lang: string, snippets: any[], paths: string[]) {
6+
export function generateCode(_lang: string, snippets: any[], paths: string[]) {
77
const result = snippets.reduce((total: any, { name, prefix, body }: any) => {
88
total[name] = {
99
prefix,
1010
// vs-code needs to encode ${string} to $\\{string\\}
1111
// see https://github.com/Microsoft/vscode/issues/1670
1212
// body: body.replace(/\\([\{\}])/gm, '$1'),
13+
// biome-ignore lint/suspicious/noTemplateCurlyInString: see above
1314
body: body.replace(/\$\{([_a-zA-Z]+)\}/gm, '${$1\\}'),
1415
description: name,
1516
};

0 commit comments

Comments
 (0)