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

core(fr): clone default categories to avoid modification #13337

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Changes from 2 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
4 changes: 3 additions & 1 deletion lighthouse-core/fraggle-rock/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';

const legacyDefaultConfig = require('../../config/default-config.js');
const {deepClone} = require('../../config/config-helpers.js');

/** @type {LH.Config.AuditJson[]} */
const frAudits = [
Expand All @@ -22,7 +23,8 @@ const frCategoryAuditRefExtensions = {
/** @return {LH.Config.Json['categories']} */
function mergeCategories() {
if (!legacyDefaultConfig.categories) return {};
const categories = legacyDefaultConfig.categories;
// Don't modify original default config.
const categories = deepClone(legacyDefaultConfig.categories);
for (const key of Object.keys(frCategoryAuditRefExtensions)) {
if (!categories[key]) continue;
categories[key].auditRefs.push(...frCategoryAuditRefExtensions[key]);
Expand Down