Skip to content

Commit b4c7544

Browse files
committed
chore: replace eslint & prettier by biome
1 parent 5264afa commit b4c7544

104 files changed

Lines changed: 1046 additions & 2718 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

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

.prettierrc

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

biome.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
3+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
4+
"linter": {
5+
"enabled": true,
6+
"rules": {
7+
"recommended": true,
8+
"suspicious": {
9+
"noExplicitAny": "off",
10+
"noAssignInExpressions": "off",
11+
"noConsole": "error"
12+
},
13+
"style": {
14+
"noParameterAssign": "off",
15+
"noNonNullAssertion": "off"
16+
},
17+
"complexity": {
18+
"noForEach": "off"
19+
}
20+
}
21+
},
22+
"formatter": {
23+
"enabled": true,
24+
"indentStyle": "space",
25+
"indentWidth": 2
26+
},
27+
"javascript": {
28+
"formatter": {
29+
"quoteStyle": "single"
30+
}
31+
},
32+
"files": {
33+
"includes": [
34+
"**",
35+
"!**/dist",
36+
"!**/node_modules",
37+
"!**/docs",
38+
"!**/packages/test-helpers/fixtures",
39+
"!**/packages/cli/bin",
40+
"!**/packages/test-performance"
41+
]
42+
}
43+
}

build-cdn.js

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import path from 'path';
1+
import path from 'node:path';
22
import esbuild from 'esbuild';
33
import glob from 'tiny-glob';
44
import pkg from './packages/plainjs/package.json' with { type: 'json' };
55

66
const replaceDependenciesByJsdelivr = {
77
name: 'replace-dependencies-by-jsdelivr',
88
setup(build) {
9-
build.onResolve({ namespace: 'file', filter: /^@json2csv\/.*$/ }, async (args) => {
10-
if (args.kind !== 'import-statement') return;
11-
12-
const [, relativePath] = args.path.match(/\@json2csv\/(.*)/);
13-
return {
14-
path: path.join('..', relativePath, 'index.js'),
15-
external: true,
16-
namespace: 'dependency',
17-
};
18-
});
9+
build.onResolve(
10+
{ namespace: 'file', filter: /^@json2csv\/.*$/ },
11+
async (args) => {
12+
if (args.kind !== 'import-statement') return;
13+
14+
const [, relativePath] = args.path.match(/@json2csv\/(.*)/);
15+
return {
16+
path: path.join('..', relativePath, 'index.js'),
17+
external: true,
18+
namespace: 'dependency',
19+
};
20+
},
21+
);
1922

2023
build.onResolve({ namespace: 'file', filter: /^\.\/.*$/ }, (args) => {
2124
if (args.kind !== 'import-statement') return;
@@ -28,35 +31,44 @@ const replaceDependenciesByJsdelivr = {
2831
});
2932

3033
const dependencies = {
31-
'@streamparser/json': `https://cdn.jsdelivr.net/npm/@streamparser/json@${pkg.dependencies['@streamparser/json']}/dist/mjs/index.js`
34+
'@streamparser/json': `https://cdn.jsdelivr.net/npm/@streamparser/json@${pkg.dependencies['@streamparser/json']}/dist/mjs/index.js`,
3235
};
3336

34-
build.onResolve({ namespace: 'file', filter: new RegExp(`(?:${Object.keys(dependencies).join('|')})`) }, (args) => {
35-
if (args.kind !== 'import-statement') return;
37+
build.onResolve(
38+
{
39+
namespace: 'file',
40+
filter: new RegExp(`(?:${Object.keys(dependencies).join('|')})`),
41+
},
42+
(args) => {
43+
if (args.kind !== 'import-statement') return;
3644

37-
if (dependencies[args.path]) {
38-
return {
39-
path: dependencies[args.path] || args.path,
40-
external: true
41-
};
42-
}
43-
});
45+
if (dependencies[args.path]) {
46+
return {
47+
path: dependencies[args.path] || args.path,
48+
external: true,
49+
};
50+
}
51+
},
52+
);
4453
},
4554
};
4655

4756
const pkgs = ['plainjs', 'whatwg', 'transforms', 'formatters'];
4857

4958
pkgs.forEach(async (pkg) => {
5059
const entryPoints = await glob(`packages/${pkg}/src/*.ts`);
51-
esbuild.build({
52-
entryPoints,
53-
bundle: true,
54-
target: 'es2019',
55-
format: 'esm',
56-
outdir: `dist/cdn/${pkg}`,
57-
plugins: [replaceDependenciesByJsdelivr],
58-
}).catch((err) => {
59-
console.error(err);
60-
process.exit(1);
61-
});
62-
});
60+
esbuild
61+
.build({
62+
entryPoints,
63+
bundle: true,
64+
target: 'es2019',
65+
format: 'esm',
66+
outdir: `dist/cdn/${pkg}`,
67+
plugins: [replaceDependenciesByJsdelivr],
68+
})
69+
.catch((err) => {
70+
// biome-ignore lint/suspicious/noConsole: Print error for debugging
71+
console.error(err);
72+
process.exit(1);
73+
});
74+
});

build-cjs.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
2-
import path from 'path';
3-
import { writeFile } from 'fs/promises';
1+
import { writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
43

54
const pkgFolder = path.resolve();
65
const distFolder = path.join(pkgFolder, 'dist/cjs/');
76

8-
await writeFile(path.join(distFolder, 'package.json'), JSON.stringify({ type: "commonjs" }, null, ' '));
7+
await writeFile(
8+
path.join(distFolder, 'package.json'),
9+
JSON.stringify({ type: 'commonjs' }, null, ' '),
10+
);

0 commit comments

Comments
 (0)