Skip to content

Commit 5bcdb7c

Browse files
committed
Fix formatting
1 parent 81db162 commit 5bcdb7c

File tree

9 files changed

+860
-2356
lines changed

9 files changed

+860
-2356
lines changed

.github/workflows/nodejs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
node-version: [18.x, 20.x]
16+
node-version: [18.x, 20.x, 22.x]
1717

1818
steps:
1919
- uses: actions/checkout@v4
@@ -24,12 +24,12 @@ jobs:
2424
with:
2525
node-version: ${{ matrix.node-version }}
2626
- run: yarn install
27-
- run: yarn lint
27+
- run: yarn check
28+
- run: yarn format
2829
- run: yarn test
2930
env:
3031
CI: true
3132
- name: SonarCloud Scan
32-
if: github.repository == 'onigoetz/absorption' && github.event_name != 'pull_request'
3333
uses: sonarsource/sonarqube-scan-action@53c3e3207fe4b8d52e2f1ac9d6eb1d2506f626c0 # v2.0.2
3434
env:
3535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

biome.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"formatter": {
7+
"indentStyle": "space",
8+
"indentWidth": 2
9+
},
10+
"linter": {
11+
"enabled": true,
12+
"rules": {
13+
"recommended": true
14+
}
15+
}
16+
}

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
"yargs": "^17.0.0"
2929
},
3030
"devDependencies": {
31-
"@swissquote/crafty": "1.25.0",
32-
"@swissquote/eslint-plugin-swissquote": "1.25.0",
33-
"c8": "^9.0.0",
34-
"eslint": "8.57.0"
31+
"@biomejs/biome": "1.7.0",
32+
"c8": "^9.0.0"
3533
},
3634
"scripts": {
37-
"lint": "eslint src",
35+
"format": "biome format src",
36+
"check": "biome check src",
3837
"test": "TZ=Europe/Zurich c8 --reporter=text --reporter=html node --test __tests__/*.js",
3938
"prepublishOnly": "yarn test",
4039
"postpublish": "git push && git push --tags"

src/bin.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
loadFile,
1212
filePath,
1313
prepareWeights,
14-
sortByLinesDesc
14+
sortByLinesDesc,
1515
} from "./utils.js";
1616
import { listFiles } from "./git.js";
1717
import calculate from "./index.js";
@@ -29,12 +29,12 @@ function renderTable(header, columns, rows) {
2929
joinBody: colors.gray(`─`),
3030
joinLeft: ``,
3131
joinRight: ``,
32-
joinJoin: colors.gray(`┼`)
32+
joinJoin: colors.gray(`┼`),
3333
},
3434
drawHorizontalLine(index) {
3535
return index === 1;
3636
},
37-
columns
37+
columns,
3838
};
3939

4040
return table([header].concat(rows), options);
@@ -51,25 +51,25 @@ function renderFresh(result, maxResults) {
5151
name,
5252
toPct(lines),
5353
toPct(freshLines),
54-
toPct(fadingLines)
54+
toPct(fadingLines),
5555
]);
5656

5757
const columns = {
5858
0: {
59-
alignment: "left"
59+
alignment: "left",
6060
},
6161
1: {
6262
alignment: "right",
63-
width: 8
63+
width: 8,
6464
},
6565
2: {
6666
alignment: "right",
67-
width: 8
67+
width: 8,
6868
},
6969
3: {
7070
alignment: "right",
71-
width: 8
72-
}
71+
width: 8,
72+
},
7373
};
7474

7575
console.log(renderTable(["Name", "Total", "Fresh", "Fading"], columns, rows));
@@ -86,12 +86,12 @@ function renderLost(result, maxLostContributors) {
8686

8787
const columns = {
8888
0: {
89-
alignment: "left"
89+
alignment: "left",
9090
},
9191
1: {
9292
alignment: "right",
93-
width: 8
94-
}
93+
width: 8,
94+
},
9595
};
9696

9797
console.log(renderTable(["Name", "Total"], columns, rows));
@@ -105,26 +105,26 @@ function renderBigFiles(fileData) {
105105
total +
106106
Object.values(fileContributors).reduce(
107107
(subTotal, contributor) => subTotal + contributor,
108-
0
108+
0,
109109
),
110-
0
110+
0,
111111
);
112112

113113
acc.push({ name, lines });
114114

115115
return acc;
116-
}, [])
116+
}, []),
117117
)
118118
.slice(0, 5)
119119
.map(({ name, lines }) => [name, lines]);
120120

121121
const columns = {
122122
0: {
123-
alignment: "left"
123+
alignment: "left",
124124
},
125125
1: {
126-
alignment: "right"
127-
}
126+
alignment: "right",
127+
},
128128
};
129129

130130
console.log(renderTable(["File", "Lines"], columns, rows));
@@ -139,7 +139,7 @@ function renderTitle(title) {
139139
function commandRepositoryConfig(config) {
140140
config.positional("repository", {
141141
describe: "The repository to scan",
142-
type: "string"
142+
type: "string",
143143
});
144144
}
145145

@@ -149,7 +149,7 @@ yargs(hideBin(process.argv))
149149
"list-files <repository>",
150150
"List all files and their weights",
151151
commandRepositoryConfig,
152-
async argv => {
152+
async (argv) => {
153153
const repository = argv.repository;
154154
const weights = argv.weights ? await loadFile(argv.weights) : {};
155155
const withMedia = argv.withMedia;
@@ -163,15 +163,15 @@ yargs(hideBin(process.argv))
163163
(filename, hash) => {
164164
console.log(` ${filename} ${getWeight(filename)}`);
165165
},
166-
branch
166+
branch,
167167
);
168-
}
168+
},
169169
)
170170
.command(
171171
["calculate <repository>", "$0 <repository>"],
172172
"Calculate absorption",
173173
commandRepositoryConfig,
174-
async argv => {
174+
async (argv) => {
175175
const contributors = argv.contributors
176176
? await loadFile(argv.contributors)
177177
: [];
@@ -191,7 +191,7 @@ yargs(hideBin(process.argv))
191191
threshold,
192192
repository,
193193
verbose,
194-
branch
194+
branch,
195195
);
196196

197197
if (argv.json) {
@@ -207,7 +207,7 @@ yargs(hideBin(process.argv))
207207

208208
console.log();
209209
console.log(
210-
`The repository's absorption score is ${result.absorption.fresh}% fresh, ${result.absorption.fading}% fading and ${result.absorption.lost}% lost`
210+
`The repository's absorption score is ${result.absorption.fresh}% fresh, ${result.absorption.fading}% fading and ${result.absorption.lost}% lost`,
211211
);
212212

213213
renderTitle("Fresh/Fading knowledge");
@@ -222,60 +222,60 @@ yargs(hideBin(process.argv))
222222
renderLost(result, maxLostContributors);
223223
} else {
224224
console.log(
225-
"It seems this repository has no lost knowledge, congratulations !"
225+
"It seems this repository has no lost knowledge, congratulations !",
226226
);
227227
}
228228

229229
renderTitle("Biggest files");
230230
console.log(
231-
"Big files can skew the results (static test data, media files...), here are the biggest files found in this repository."
231+
"Big files can skew the results (static test data, media files...), here are the biggest files found in this repository.",
232232
);
233233
console.log();
234234

235235
renderBigFiles(result.fileData);
236-
}
236+
},
237237
)
238238
.option("json", {
239239
describe: "Output to a JSON file",
240-
type: "string"
240+
type: "string",
241241
})
242242
.option("threshold", {
243243
describe:
244244
"start with a number, followed by 'd' for days, 'w' for weeks, 'm' for months or 'y' for years (1y, 6m, 9w)",
245245
default: "1y",
246-
type: "string"
246+
type: "string",
247247
})
248248
.option("max-contributors", {
249249
describe: "Max number of active contributors",
250250
type: "integer",
251-
default: 10
251+
default: 10,
252252
})
253253
.option("max-lost-contributors", {
254254
describe: "Max number of lost contributors",
255255
type: "integer",
256-
default: 10
256+
default: 10,
257257
})
258258
.option("contributors", {
259259
describe: "Add complementary contributors data, through a JSON file",
260-
type: "string"
260+
type: "string",
261261
})
262262
.option("weights", {
263263
describe: "Change the weight of each file, through a JSON file",
264-
type: "string"
264+
type: "string",
265265
})
266266
.option("with-media", {
267267
describe: "Media files are ignored by default, this restores them",
268268
type: "boolean",
269-
default: false
269+
default: false,
270270
})
271271
.option("branch", {
272272
describe: "The branch to scan",
273273
type: "string",
274-
default: "master"
274+
default: "master",
275275
})
276276
.option("verbose", {
277277
type: "boolean",
278-
default: false
278+
default: false,
279279
})
280280
//.example("$0 calculate -f foo.js", "count the lines in the given file")
281281
.help("h")

src/cache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import findCacheDir from "find-cache-dir";
44
const store = DiskStore.create({
55
ttl: 60 * 60 * 24 * 90, // 3 months lifetime (in seconds)
66
path: findCacheDir({ name: "absorption", create: true }),
7-
subdirs: true
7+
subdirs: true,
88
});
99

1010
export default {
@@ -29,5 +29,5 @@ export default {
2929
},
3030
reset() {
3131
return store.reset();
32-
}
32+
},
3333
};

src/git.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function getBlame(execa, cwd, file, ref = "master") {
3434
author: "",
3535
mail: "",
3636
time: "",
37-
tz: ""
37+
tz: "",
3838
};
3939
}
4040

0 commit comments

Comments
 (0)