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: remove util.cjs, break up util.js to shared and report utils #14378

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
- run: yarn test-legacy-javascript
- run: yarn i18n:checks
- run: yarn dogfood-lhci
- run: bash core/scripts/copy-util-commonjs.sh

# Fail if any changes were written to any source files or generated untracked files (ex, from: build/build-cdt-lib.js).
- run: git add -A && git diff --cached --exit-code
Expand Down
2 changes: 1 addition & 1 deletion core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {isUnderTest} from '../lib/lh-env.js';
import * as statistics from '../lib/statistics.js';
import {Util} from '../util.cjs';
import {Util} from '../../shared/shared-utils.js';

const DEFAULT_PASS = 'defaultPass';

Expand Down
2 changes: 1 addition & 1 deletion core/computed/resource-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {makeComputedArtifact} from './computed-artifact.js';
import {NetworkRecords} from './network-records.js';
import {NetworkRequest} from '../lib/network-request.js';
import {Budget} from '../config/budget.js';
import {Util} from '../util.cjs';
import {Util} from '../../shared/shared-utils.js';

/** @typedef {{count: number, resourceSize: number, transferSize: number}} ResourceEntry */

Expand Down
2 changes: 1 addition & 1 deletion core/lib/url-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

import {Util} from '../util.cjs';
import {Util} from '../../shared/shared-utils.js';
import {LighthouseError} from './lh-error.js';

/** @typedef {import('./network-request.js').NetworkRequest} NetworkRequest */
Expand Down
6 changes: 0 additions & 6 deletions core/scripts/c8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,4 @@ node node_modules/.bin/c8 \
--exclude '**/test/' \
--exclude '**/scripts/' \
--exclude 'core/lib/page-functions.js' \
--exclude 'core/util-commonjs.js' \
$*

# util-commonjs is a copy of renderer/util, which has its own test coverage.
# Admittedly, util-commonjs is used in different ways, but we don't expect it to also have complete
# coverage as some methods are renderer-specific. Ideally, we'd combine the coverage, but in the
# meantime we'll ignore coverage requirements for this file.
20 changes: 0 additions & 20 deletions core/scripts/copy-util-commonjs.sh

This file was deleted.

7 changes: 3 additions & 4 deletions core/scripts/i18n/collect-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import tsc from 'typescript';
import MessageParser from 'intl-messageformat-parser';
import esMain from 'es-main';

import {Util} from '../../util.cjs';
import {splitMarkdownCodeSpans, splitMarkdownLink} from '../../../shared/markdown.js';
import {collectAndBakeCtcStrings} from './bake-ctc-to-lhl.js';
import {pruneObsoleteLhlMessages} from './prune-obsolete-lhl-messages.js';
import {countTranslatedMessages} from './count-translated.js';
Expand Down Expand Up @@ -49,7 +49,6 @@ const ignoredPathComponents = [
'**/test/**',
'**/*-test.js',
'**/*-renderer.js',
'**/util-commonjs.js',
'treemap/app/src/main.js',
];

Expand Down Expand Up @@ -236,7 +235,7 @@ function _processPlaceholderMarkdownCode(icu) {

icu.message = '';
let idx = 0;
for (const segment of Util.splitMarkdownCodeSpans(message)) {
for (const segment of splitMarkdownCodeSpans(message)) {
if (segment.isCode) {
const placeholderName = `MARKDOWN_SNIPPET_${idx++}`;
// Backtick replacement looks unreadable here, so .join() instead.
Expand Down Expand Up @@ -272,7 +271,7 @@ function _processPlaceholderMarkdownLink(icu) {
icu.message = '';
let idx = 0;

for (const segment of Util.splitMarkdownLink(message)) {
for (const segment of splitMarkdownLink(message)) {
if (!segment.isLink) {
// Plain text segment.
icu.message += segment.text;
Expand Down
Loading