Skip to content

Commit 033af3b

Browse files
authored
chore: add Biome to lint & format code (#20)
1 parent c5d8a60 commit 033af3b

9 files changed

Lines changed: 922 additions & 594 deletions

File tree

biome.json

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"assist": {
4+
"actions": {
5+
"source": {
6+
"organizeImports": "on"
7+
}
8+
}
9+
},
10+
"html": {
11+
"formatter": {
12+
"enabled": true
13+
}
14+
},
15+
"formatter": {
16+
"enabled": true,
17+
"indentWidth": 2,
18+
"lineEnding": "lf",
19+
"formatWithErrors": true,
20+
"lineWidth": 140,
21+
"indentStyle": "space",
22+
"includes": [
23+
"**",
24+
"!**/.cache",
25+
"!**/dist/**",
26+
"!**/*.json",
27+
"!**/node_modules/**"
28+
]
29+
},
30+
"javascript": {
31+
"parser": {
32+
"unsafeParameterDecoratorsEnabled": true
33+
},
34+
"formatter": {
35+
"arrowParentheses": "asNeeded",
36+
"quoteProperties": "asNeeded",
37+
"semicolons": "always",
38+
"indentStyle": "space",
39+
"quoteStyle": "single"
40+
}
41+
},
42+
"json": {
43+
"formatter": {
44+
"indentStyle": "space"
45+
},
46+
"parser": {
47+
"allowComments": true
48+
}
49+
},
50+
"linter": {
51+
"enabled": true,
52+
"includes": [
53+
"**",
54+
"!**/.cache",
55+
"!**/dist/**",
56+
"!**/*.json",
57+
"!**/node_modules/**"
58+
],
59+
"rules": {
60+
"correctness": {
61+
"useImportExtensions": "error"
62+
},
63+
"recommended": true,
64+
"complexity": {
65+
"noForEach": "off",
66+
"noStaticOnlyClass": "off"
67+
},
68+
"performance": {
69+
"noBarrelFile": "off",
70+
"noDelete": "off"
71+
},
72+
"suspicious": {
73+
"noExplicitAny": "off",
74+
"noPrototypeBuiltins": "off"
75+
},
76+
"style": {
77+
"noNonNullAssertion": "off",
78+
"noParameterAssign": "off",
79+
"useExponentiationOperator": "off"
80+
}
81+
}
82+
},
83+
"vcs": {
84+
"clientKind": "git",
85+
"enabled": false,
86+
"root": "./"
87+
}
88+
}

package-lock.json

Lines changed: 167 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
"url": "https://github.com/ghiscoding/native-copyfiles/issues"
3636
},
3737
"scripts": {
38+
"prebuild": "npm run biome:lint:write && npm run biome:format:write",
3839
"build": "tsc --outDir dist",
40+
"biome:lint:check": "biome lint ./src",
41+
"biome:lint:write": "biome lint --write ./src",
42+
"biome:format:check": "biome format ./src",
43+
"biome:format:write": "biome format --write ./src",
3944
"preview:copy": "node dist/cli.js test-copyin test-copyout --flat --verbose",
4045
"preview:release": "release-it --only-version --dry-run",
4146
"release": "release-it --only-version",
@@ -48,6 +53,7 @@
4853
"yargs": "^18.0.0"
4954
},
5055
"devDependencies": {
56+
"@biomejs/biome": "^2.0.0-beta.6",
5157
"@release-it/conventional-changelog": "^10.0.1",
5258
"@types/node": "^22.15.30",
5359
"@types/yargs": "^17.0.33",
@@ -59,4 +65,4 @@
5965
"engines": {
6066
"node": "^20.0.0 || >=22.0.0"
6167
}
62-
}
68+
}

src/__tests__/cli-fail.spec.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@ import { beforeEach, describe, expect, test, vi } from 'vitest';
22

33
describe('copyfiles', () => {
44
beforeEach(() => {
5-
vi.spyOn(process, 'exit').mockImplementation((() => { }) as any);
5+
vi.spyOn(process, 'exit').mockImplementation((() => {}) as any);
66
});
77

8-
test('CLI entry failure (no valid process.argv)', () => new Promise((done: any) => {
9-
const errorSpy = vi.spyOn(global.console, 'error').mockReturnValue();
10-
const exitSpy = vi.spyOn(process, 'exit');
8+
test('CLI entry failure (no valid process.argv)', () =>
9+
new Promise((done: any) => {
10+
const errorSpy = vi.spyOn(global.console, 'error').mockReturnValue();
11+
const exitSpy = vi.spyOn(process, 'exit');
1112

12-
import('../cli')
13-
.then((cli: any) => {
14-
cli();
15-
})
16-
.catch(e => {
17-
expect(errorSpy).toHaveBeenCalledWith(
18-
new Error('Please make sure to provide both <inFile> and <outDirectory>, i.e.: "copyfiles <inFile> <outDirectory>"')
19-
);
20-
expect(exitSpy).toHaveBeenCalledWith(1);
21-
process.exitCode = undefined;
22-
done();
23-
process.exit(0);
24-
});
25-
}));
26-
});
13+
import('../cli.js')
14+
.then((cli: any) => {
15+
cli();
16+
})
17+
.catch(_ => {
18+
expect(errorSpy).toHaveBeenCalledWith(
19+
new Error('Please make sure to provide both <inFile> and <outDirectory>, i.e.: "copyfiles <inFile> <outDirectory>"'),
20+
);
21+
expect(exitSpy).toHaveBeenCalledWith(1);
22+
process.exitCode = undefined;
23+
done();
24+
process.exit(0);
25+
});
26+
}));
27+
});

0 commit comments

Comments
 (0)