Skip to content

Commit

Permalink
@biomejs/biome(formatter enabled) (#10)
Browse files Browse the repository at this point in the history
* formatter enabled
* line width to 80
* npm run fix
  • Loading branch information
kobakazu0429 authored Jan 22, 2024
1 parent 9dd3a86 commit 69dc8c9
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Biome
uses: biomejs/setup-biome@v2
- run: npm ci
- run: biome ci --formatter-enabled=false --linter-enabled=true --organize-imports-enabled=false .
- run: biome ci .
- run: npm run test
- run: npm run typecheck
- run: npm run build
13 changes: 5 additions & 8 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
}
},
"formatter": {
"enabled": false,
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120
"lineWidth": 80
},
"json": {
"parser": {
Expand All @@ -44,7 +44,7 @@
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120
"lineWidth": 80
}
},
"javascript": {
Expand All @@ -57,16 +57,13 @@
"arrowParentheses": "always",
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120,
"lineWidth": 80,
"quoteProperties": "asNeeded"
}
},
"overrides": [
{
"include": [
"src/kinks.ts",
"src/index.ts"
],
"include": ["src/kinks.ts", "src/index.ts"],
"linter": {
"enabled": true,
"rules": {
Expand Down
24 changes: 12 additions & 12 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import terser from "@rollup/plugin-terser";
import cjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import outputSize, { summarize } from "rollup-plugin-output-size";
import { visualizer } from "rollup-plugin-visualizer";
Expand All @@ -14,13 +14,13 @@ export default /** @type {import('rollup').RollupOptions} */ ({
{
file: pkg.exports["."].import,
format: "es",
sourcemap: true
sourcemap: true,
},
{
file: pkg.exports["."].require,
format: "cjs",
sourcemap: true
}
sourcemap: true,
},
],

plugins: [
Expand All @@ -30,26 +30,26 @@ export default /** @type {import('rollup').RollupOptions} */ ({
values: {
"process.env.NODE_ENV": JSON.stringify("production"),
"import.meta.env.NODE_ENV": JSON.stringify("production"),
"import.meta.vitest": JSON.stringify(false)
"import.meta.vitest": JSON.stringify(false),
},
preventAssignment: true
preventAssignment: true,
}),
typescript({
declaration: true,
rootDir: "src",
declarationDir: "types",
emitDeclarationOnly: true
emitDeclarationOnly: true,
}),
terser({
compress: {
passes: 6
}
passes: 6,
},
}),
outputSize({
summary(summary) {
console.log(summarize(summary));
}
},
}),
visualizer()
]
visualizer(),
],
});
92 changes: 46 additions & 46 deletions spec/tin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
["Nara", "naramachi_yasui_bunko"],
["Fushimi", "fushimijo_maplat"],
["Uno Loose", "uno_bus_gtfs_loose"],
["Uno Error", "uno_bus_gtfs_error"]
].map(dataset => {
["Uno Error", "uno_bus_gtfs_error"],
].map((dataset) => {
const town = dataset[0];
const filename = dataset[1];
describe(`Test by actual data (${town})`, () => {
Expand All @@ -24,7 +24,7 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
wh: [load_m.width, load_m.height],
strictMode: load_m.strictMode as Options["strictMode"],
vertexMode: load_m.vertexMode as Options["vertexMode"],
stateFull: isStateFull
stateFull: isStateFull,
});
tin.setPoints(load_m.gcps as Options["points"]);
if (load_m.edges) {
Expand All @@ -40,7 +40,7 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
// Normalizing edges structure
load_c_str = load_c_str.replace(
/{"illstNodes":(\[(?:[[\]\d.,]*)]),"mercNodes":(\[(?:[[\]\d.,]*)]),"startEnd":(\[(?:[\d,]+)])}/g,
"[$1,$2,$3]"
"[$1,$2,$3]",
);
load_c = JSON.parse(load_c_str);

Expand All @@ -50,15 +50,15 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
const loaded = JSON.parse(JSON.stringify(lTin.getCompiled()));

// After 0.7.3 Old format load test
[compiled, loaded].forEach(target => {
[compiled, loaded].forEach((target) => {
// points
expect(treeWalk(expected.points, 5)).toEqual(
treeWalk(target.points, 5)
treeWalk(target.points, 5),
);

// edges
expect(treeWalk(expected.edges, 5)).toEqual(
treeWalk(target.edges, 5)
treeWalk(target.edges, 5),
);

// weight buffer
Expand All @@ -72,19 +72,19 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
// tins points
expected.tins_points.forEach((expected_tins: any, index: number) => {
expect(sortTinsPoint(expected_tins)).toEqual(
sortTinsPoint(target.tins_points[index])
sortTinsPoint(target.tins_points[index]),
);
});

// edge nodes
expect(treeWalk(expected.edgeNodes, 5)).toEqual(
treeWalk(target.edgeNodes, 5)
treeWalk(target.edgeNodes, 5),
);

// kinks points
if (expected.kinks_points) {
expect(sortKinksPoint(expected.kinks_points)).toEqual(
sortKinksPoint(target.kinks_points)
sortKinksPoint(target.kinks_points),
);
}
});
Expand All @@ -109,32 +109,32 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
[150, 150],
[150, 200],
[60, 190],
[50, 100]
[50, 100],
],
strictMode: Tin.MODE_STRICT,
stateFull: isStateFull
stateFull: isStateFull,
});
tin.setPoints([
[
[80, 90],
[160, -90]
[160, -90],
],
[
[120, 120],
[240, -120]
[240, -120],
],
[
[100, 140],
[200, -140]
[200, -140],
],
[
[130, 180],
[260, -180]
[260, -180],
],
[
[70, 150],
[140, -150]
]
[140, -150],
],
]);

it("Test for compiling data", async () => {
Expand All @@ -144,19 +144,19 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
deepCloseTo(
tin.transform([140, 150]) as number[],
[277.25085848926574, -162.19095375292216],
7
7,
);
expect(
tin.transform([277.25085848926574, -162.19095375292216], true)
tin.transform([277.25085848926574, -162.19095375292216], true),
).toEqual([140, 150]);
expect(tin.transform([200, 130])).toEqual(false);
expect(
tin.transform([401.98029725204117, -110.95171624700066], true)
tin.transform([401.98029725204117, -110.95171624700066], true),
).toEqual(false);
deepCloseTo(
tin.transform([200, 130], false, true) as number[],
[401.98029725204117, -110.95171624700066],
7
7,
);
});
});
Expand All @@ -168,32 +168,32 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
[150, 150],
[150, 200],
[60, 190],
[50, 100]
[50, 100],
],
strictMode: Tin.MODE_AUTO,
stateFull: isStateFull
stateFull: isStateFull,
});
tin.setPoints([
[
[80, 90],
[160, -90]
[160, -90],
],
[
[120, 120],
[240, 120]
[240, 120],
],
[
[100, 140],
[200, -140]
[200, -140],
],
[
[130, 180],
[260, 180]
[260, 180],
],
[
[70, 150],
[140, -150]
]
[140, -150],
],
]);

it("Test for compiling data", async () => {
Expand All @@ -206,7 +206,7 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
err = e;
}
expect(err).not.toEqual(
'Backward transform is not allowed if strict_status == "strict_error"'
'Backward transform is not allowed if strict_status == "strict_error"',
);
tin.setStrictMode(Tin.MODE_STRICT);
await tin.updateTinAsync();
Expand All @@ -218,7 +218,7 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
err = e;
}
expect(err).toEqual(
'Backward transform is not allowed if strict_status == "strict_error"'
'Backward transform is not allowed if strict_status == "strict_error"',
);
});
});
Expand All @@ -229,7 +229,7 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
let err = "";
try {
tin = new Tin({
stateFull: isStateFull
stateFull: isStateFull,
});
} catch (_e) {
err = "err";
Expand All @@ -242,20 +242,20 @@ const testSet = ({ isStateFull }: { isStateFull: boolean }) => {
tin.setPoints([
[
[20, 20],
[20, 20]
[20, 20],
],
[
[30, 30],
[30, 30]
[30, 30],
],
[
[40, 40],
[40, 40]
]
[40, 40],
],
]);
err = "";
// @ts-ignore
await tin.updateTinAsync().catch(e => {
await tin.updateTinAsync().catch((e) => {
err = e;
});
expect(err).toEqual("TOO LINEAR1");
Expand All @@ -270,7 +270,7 @@ describe("Test for Tin function (StateFull)", () =>
function treeWalk(obj: any, depth: number) {
if (typeof obj === "object") {
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
Object.keys(obj).forEach(key => (obj[key] = treeWalk(obj[key], depth)));
Object.keys(obj).forEach((key) => (obj[key] = treeWalk(obj[key], depth)));
} else if (typeof obj === "number" && !`${obj}`.match(/^\d+$/)) {
// biome-ignore lint/style/noParameterAssign: <explanation>
obj = Math.round(obj * 10 ** depth) / 10 ** depth;
Expand All @@ -280,11 +280,11 @@ function treeWalk(obj: any, depth: number) {

function sortTinsPoint(tins_points: any[][]) {
return tins_points
.map(points =>
.map((points) =>
points
.map(key => `${key}`)
.map((key) => `${key}`)
.sort()
.join("_")
.join("_"),
)
.sort();
}
Expand All @@ -295,10 +295,10 @@ function sortKinksPoint(kinks_points: number[][]) {
? a[1] === b[1]
? 0
: a[1] > b[1]
? 1
: -1
? 1
: -1
: a[0] > b[0]
? 1
: -1
? 1
: -1,
);
}
Loading

0 comments on commit 69dc8c9

Please sign in to comment.