Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(infra/biome): enable noAccumulatingSpread #7492

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"noNonNullAssertion": "off"
},
"performance": {
"noDelete": "off",
"noAccumulatingSpread": "off"
"noDelete": "off"
},
"security": {
"noGlobalEval": "off"
Expand Down
64 changes: 34 additions & 30 deletions packages/rspack-test-tools/src/processor/multi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,44 @@ export class MultiTaskProcessor<T extends ECompilerType>
if (typeof _multiOptions.findBundle !== "function") {
return [];
}
return this.multiCompilerOptions.reduce<string[]>(
(res, compilerOptions, index) => {
const curBundles = _multiOptions.findBundle!(
index,
context,
compilerOptions
);

const bundles = Array.isArray(curBundles)
? curBundles
: curBundles
? [curBundles]
: [];
const result: string[] = [];
const multiFileIndexMap: Record<string, number[]> =
context.getValue(_multiOptions.name, "multiFileIndexMap") || {};
for (const [
index,
compilerOptions
] of this.multiCompilerOptions.entries()) {
const curBundles = _multiOptions.findBundle!(
index,
context,
compilerOptions
);

const multiFileIndexMap: Record<string, number[]> =
context.getValue(_multiOptions.name, "multiFileIndexMap") || {};
for (const bundle of bundles) {
multiFileIndexMap[bundle] = [
...(multiFileIndexMap[bundle] || []),
index
];
const bundles = Array.isArray(curBundles)
? curBundles
: curBundles
? [curBundles]
: [];

for (const bundle of bundles) {
if (multiFileIndexMap[bundle]) {
multiFileIndexMap[bundle].push(index);
} else {
multiFileIndexMap[bundle] = [index];
}
context.setValue(
_multiOptions.name,
"multiFileIndexMap",
multiFileIndexMap
);
return [
...res,
...(Array.isArray(bundles) ? bundles : bundles ? [bundles] : [])
];
},
[]
}

result.push(...bundles);
}

context.setValue(
_multiOptions.name,
"multiFileIndexMap",
multiFileIndexMap
);

return result;
},
name: _multiOptions.name
});
Expand Down
5 changes: 1 addition & 4 deletions packages/rspack-test-tools/src/test/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ export class TestContext implements ITestContext {
if (name) {
return this.errors.get(name) || [];
}
return Array.from(this.errors.values()).reduce(
(res, arr) => [...res, ...arr],
[]
);
return Array.prototype.concat(...this.errors.values());
}
clearError(name?: string) {
if (name) {
Expand Down
13 changes: 7 additions & 6 deletions packages/rspack/src/stats/StatsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,13 @@ export class StatsFactory {
});

const hooks = this.hooks;
this._caches = Object.keys(hooks).reduce((prev, curr) => {
return {
...prev,
[curr]: new Map()
};
}, {} as Cache);
const caches = {} as Cache;

for (const key of Object.keys(hooks)) {
caches[key as keyof Cache] = new Map();
}

this._caches = caches;
this._inCreate = false;
}

Expand Down
Loading