Skip to content

Commit dcf81d9

Browse files
committed
refactor: fix eslint
1 parent 45d285b commit dcf81d9

8 files changed

Lines changed: 15 additions & 9 deletions

File tree

eslint.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import antfu from "@antfu/eslint-config";
33

44
export default antfu({
55
javascript: true,
6-
typescript: true,
6+
typescript: {
7+
overrides: {
8+
"e18e/prefer-static-regex": "off",
9+
},
10+
},
711
stylistic: {
812
semi: true,
913
quotes: "double",

src/core/builder/fluent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,6 @@ export function generateFluentDts(messages: string[]) {
255255
/* eslint-disable */
256256
// @ts-nocheck
257257
export type FluentMessageId =
258-
${Array.from(messages).sort().map(id => ` | '${id}'`).join("\n")};
258+
${messages.toSorted().map(id => ` | '${id}'`).join("\n")};
259259
`;
260260
}

src/core/builder/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class Build extends Base {
4646
}
4747

4848
await this.ctx.hooks.callHook("build:done", this.ctx);
49-
this.logger.success(`Build finished in ${(new Date().getTime() - t.getTime()) / 1000} s.`);
49+
this.logger.success(`Build finished in ${(Date.now() - t.getTime()) / 1000} s.`);
5050
}
5151

5252
private async prepareAssets() {

src/core/builder/replace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function replace(contents: string, from: RegExp | RegExp[], to: string |
88
const froms = Array.isArray(from) ? from : [from];
99
const tos = Array.isArray(to)
1010
? to
11+
// eslint-disable-next-line e18e/prefer-array-fill -- `Array.from({length: froms.length}).fill(to)` breaks type infer
1112
: Array.from({ length: froms.length }, () => to);
1213

1314
if (froms.length !== tos.length) {
@@ -51,8 +52,8 @@ export default async function replaceDefine(dist: string, define: BuildConfig["d
5152
// `${dist}/addon/**/*.css`,
5253
// `${dist}/addon/**/*.json`,
5354
// ],
54-
from: Array.from(replaceMap.keys()),
55-
to: Array.from(replaceMap.values()),
55+
from: [...replaceMap.keys()],
56+
to: [...replaceMap.values()],
5657
// isGlob: false,
5758
});
5859
}

src/core/releaser/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default class Release extends Base {
6464

6565
await this.ctx.hooks.callHook("release:done", this.ctx);
6666
this.logger.success(
67-
`Done in ${(new Date().getTime() - t.getTime()) / 1000} s.`,
67+
`Done in ${(Date.now() - t.getTime()) / 1000} s.`,
6868
);
6969
}
7070

src/core/tester/test-bundler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,5 @@ export function findImpactedTests(changedFilePath: string, buildMetadata: BuildR
172172
impactedTestFiles.add(testFilePath);
173173
}
174174
}
175-
return Array.from(impactedTestFiles);
175+
return [...impactedTestFiles];
176176
}

src/utils/prefs-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ export class PrefsManager {
120120
return false;
121121
else if (!Number.isNaN(Number(value)))
122122
return Number(value);
123-
else if (value.match(/^["'](.*)["']$/))
123+
// eslint-disable-next-line regexp/no-unused-capturing-group
124+
else if (/^["'](.*)["']$/.test(value))
124125
return value.replace(/^["'](.*)["']$/, "$1");
125126
else
126127
return value;

src/utils/string.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function toArray<T>(value: T | T[]): T[] {
3434
* @see https://github.com/sodiray/radash/blob/069b26cdd7d62e6ac16a0ad3baa1c9abcca420bc/src/string.ts#L111-L126
3535
*/
3636
export function template(str: string, data: Record<string, any>, regex: RegExp = /\{\{(.+?)\}\}/g): string {
37-
return Array.from(str.matchAll(regex)).reduce((acc, match) => {
37+
return [...str.matchAll(regex)].reduce((acc, match) => {
3838
return acc.replace(match[0], data[match[1]]);
3939
}, str);
4040
}

0 commit comments

Comments
 (0)