@jsrepo/transform-biome 0.0.1-beta.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/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +39 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 jsrepo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @jsrepo/transform-biome
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@jsrepo/transform-biome)
|
|
4
|
+
[](https://npmjs.com/package/@jsrepo/transform-biome)
|
|
5
|
+
|
|
6
|
+
A transform plugin for formatting registry items with Biome using your local biome configuration before they are added to your project.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
Run the following command to install and add the transform to your config:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
jsrepo config transform @jsrepo/transform-biome
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Manual Configuration
|
|
17
|
+
|
|
18
|
+
Install the transform plugin:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pnpm install @jsrepo/transform-biome -D
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Add the transform to your config:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { defineConfig } from "jsrepo";
|
|
28
|
+
import biome from "@jsrepo/transform-biome";
|
|
29
|
+
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
transforms: [biome()],
|
|
32
|
+
});
|
|
33
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Transform } from "jsrepo";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A transform plugin for jsrepo to format code with prettier.
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { defineConfig } from "jsrepo";
|
|
10
|
+
* import biome from "@jsrepo/transform-biome";
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* // ...
|
|
14
|
+
* transforms: [biome()],
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param options - The options for the transform plugin.
|
|
19
|
+
*/
|
|
20
|
+
declare function export_default(): Transform;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { export_default as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Biome, Distribution } from "@biomejs/js-api";
|
|
2
|
+
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* A transform plugin for jsrepo to format code with prettier.
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineConfig } from "jsrepo";
|
|
9
|
+
* import biome from "@jsrepo/transform-biome";
|
|
10
|
+
*
|
|
11
|
+
* export default defineConfig({
|
|
12
|
+
* // ...
|
|
13
|
+
* transforms: [biome()],
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param options - The options for the transform plugin.
|
|
18
|
+
*/
|
|
19
|
+
function src_default() {
|
|
20
|
+
return { transform: async (code, opts) => {
|
|
21
|
+
return { code: await tryFormat(code, {
|
|
22
|
+
fileName: opts.fileName,
|
|
23
|
+
cwd: opts.cwd
|
|
24
|
+
}) };
|
|
25
|
+
} };
|
|
26
|
+
}
|
|
27
|
+
async function tryFormat(code, { fileName, cwd }) {
|
|
28
|
+
try {
|
|
29
|
+
const biome = await Biome.create({ distribution: Distribution.NODE });
|
|
30
|
+
const { projectKey } = biome.openProject(cwd);
|
|
31
|
+
return biome.formatContent(projectKey, code, { filePath: fileName }).content;
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(err);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { src_default as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jsrepo/transform-biome",
|
|
3
|
+
"description": "A transform plugin for jsrepo to format code with biome.",
|
|
4
|
+
"version": "0.0.1-beta.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://jsrepo.dev",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Aidan Bleser",
|
|
9
|
+
"url": "https://github.com/ieedan"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/jsrepojs/jsrepo"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/jsrepojs/jsrepo/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"jsrepo",
|
|
20
|
+
"transform",
|
|
21
|
+
"biome",
|
|
22
|
+
"plugin"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist/**/*"
|
|
34
|
+
],
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"jsrepo": "3.0.0-beta.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@biomejs/wasm-nodejs": "^2.2.4",
|
|
40
|
+
"@biomejs/js-api": "^3.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"tsdown": "^0.15.9",
|
|
44
|
+
"@types/node": "^24.9.1"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsdown",
|
|
48
|
+
"dev": "tsdown --watch",
|
|
49
|
+
"check": "tsc --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|