From 05d7f57a49e0acfe2e67d36752573441825f989e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 15 May 2024 14:36:44 +0200 Subject: [PATCH] More fixes --- __mocks__/{fs.js => node:fs.js} | 0 packages/commander/src/utils/appendRevisionToVersion.ts | 2 +- packages/commander/src/utils/copyFiles.ts | 2 +- packages/commander/src/utils/generateZipFile.ts | 2 +- .../commander/src/utils/test/appendRevisionToVersion.js | 2 +- packages/commander/src/utils/test/bundlePlugin.js | 4 ++-- packages/commander/src/utils/test/copyFiles.js | 4 ++-- packages/commander/src/utils/test/createBuild.js | 2 +- .../commander/src/utils/test/deleteExistingZipFiles.js | 2 +- packages/commander/src/utils/test/generateZipFile.js | 4 ++-- .../commander/src/utils/test/getCurrentVersionNumber.js | 2 +- packages/commander/src/utils/test/getIgnoredFiles.js | 2 +- packages/commander/src/utils/test/updateCdnUrl.js | 2 +- .../commander/src/utils/test/updateVersionNumbers.js | 2 +- packages/fonts/scripts/utils/buildFonts.ts | 2 +- packages/fonts/scripts/utils/getFontMetrics.ts | 8 ++++---- packages/fonts/scripts/utils/test/buildFonts.js | 4 ++-- packages/fonts/scripts/utils/test/getFontMetrics.js | 4 ++-- packages/karma-puppeteer-client/src/client.js | 9 +++++---- packages/migration/scripts/utils/test/updateTemplates.js | 4 ++-- packages/migration/scripts/utils/updateTemplates.js | 4 ++-- .../src/components/checklist/checks/videoOptimization.js | 1 + packages/tinymce-button/src/index.js | 5 +++-- 23 files changed, 38 insertions(+), 35 deletions(-) rename __mocks__/{fs.js => node:fs.js} (100%) diff --git a/__mocks__/fs.js b/__mocks__/node:fs.js similarity index 100% rename from __mocks__/fs.js rename to __mocks__/node:fs.js diff --git a/packages/commander/src/utils/appendRevisionToVersion.ts b/packages/commander/src/utils/appendRevisionToVersion.ts index 1ec5f2c1c329..a11ee0029ff9 100644 --- a/packages/commander/src/utils/appendRevisionToVersion.ts +++ b/packages/commander/src/utils/appendRevisionToVersion.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { execSync } from 'child_process'; +import { execSync } from 'node:child_process'; /** * Appends the current revision to the version number for nightly builds. diff --git a/packages/commander/src/utils/copyFiles.ts b/packages/commander/src/utils/copyFiles.ts index d347664ecd03..0f98c578cb1d 100644 --- a/packages/commander/src/utils/copyFiles.ts +++ b/packages/commander/src/utils/copyFiles.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { execFileSync } from 'child_process'; +import { execFileSync } from 'node:child_process'; /** * Copies all files minuses ignored ones from source to target directory. diff --git a/packages/commander/src/utils/generateZipFile.ts b/packages/commander/src/utils/generateZipFile.ts index 6aca4c8eecc9..cd514b4337f6 100644 --- a/packages/commander/src/utils/generateZipFile.ts +++ b/packages/commander/src/utils/generateZipFile.ts @@ -18,7 +18,7 @@ * External dependencies */ import { dirname, basename, join } from 'node:path'; -import { execFileSync } from 'child_process'; +import { execFileSync } from 'node:child_process'; import { existsSync, unlinkSync } from 'node:fs'; /** diff --git a/packages/commander/src/utils/test/appendRevisionToVersion.js b/packages/commander/src/utils/test/appendRevisionToVersion.js index 21c65557857f..20e062057849 100644 --- a/packages/commander/src/utils/test/appendRevisionToVersion.js +++ b/packages/commander/src/utils/test/appendRevisionToVersion.js @@ -19,7 +19,7 @@ */ import appendRevisionToVersion from '../appendRevisionToVersion'; -jest.mock('child_process', () => { +jest.mock('node:child_process', () => { return { execSync: () => '1234567', }; diff --git a/packages/commander/src/utils/test/bundlePlugin.js b/packages/commander/src/utils/test/bundlePlugin.js index 2ba2c34e212b..39cc99b62c0f 100644 --- a/packages/commander/src/utils/test/bundlePlugin.js +++ b/packages/commander/src/utils/test/bundlePlugin.js @@ -27,8 +27,8 @@ import generateZipFile from '../generateZipFile'; import getCurrentVersionNumber from '../getCurrentVersionNumber'; import deleteExistingZipFiles from '../deleteExistingZipFiles'; -jest.mock('fs'); -jest.mock('child_process'); +jest.mock('node:fs'); +jest.mock('node:child_process'); jest.mock('../generateZipFile'); jest.mock('../getCurrentVersionNumber'); diff --git a/packages/commander/src/utils/test/copyFiles.js b/packages/commander/src/utils/test/copyFiles.js index 752983b01deb..b9f2ef207031 100644 --- a/packages/commander/src/utils/test/copyFiles.js +++ b/packages/commander/src/utils/test/copyFiles.js @@ -17,14 +17,14 @@ /** * External dependencies */ -import { execFileSync } from 'child_process'; +import { execFileSync } from 'node:child_process'; /** * Internal dependencies */ import copyFiles from '../copyFiles'; -jest.mock('child_process'); +jest.mock('node:child_process'); describe('copyFiles', () => { it('should sync source files to target', () => { diff --git a/packages/commander/src/utils/test/createBuild.js b/packages/commander/src/utils/test/createBuild.js index b2fe7f60aca1..5bd0a7957b02 100644 --- a/packages/commander/src/utils/test/createBuild.js +++ b/packages/commander/src/utils/test/createBuild.js @@ -25,7 +25,7 @@ import { __setMockFiles } from 'node:fs'; import createBuild from '../createBuild'; import copyFiles from '../copyFiles'; -jest.mock('fs'); +jest.mock('node:fs'); jest.mock('../getIgnoredFiles', () => jest.fn(() => ['bar.txt', 'baz/'])); jest.mock('../copyFiles'); diff --git a/packages/commander/src/utils/test/deleteExistingZipFiles.js b/packages/commander/src/utils/test/deleteExistingZipFiles.js index 250572e8cc9c..ea3bf6c29fd8 100644 --- a/packages/commander/src/utils/test/deleteExistingZipFiles.js +++ b/packages/commander/src/utils/test/deleteExistingZipFiles.js @@ -24,7 +24,7 @@ import { __setMockFiles, readdirSync } from 'node:fs'; */ import deleteExistingZipFiles from '../deleteExistingZipFiles'; -jest.mock('fs'); +jest.mock('node:fs'); describe('deleteExistingZipFiles', () => { const MOCK_FILE_INFO = { diff --git a/packages/commander/src/utils/test/generateZipFile.js b/packages/commander/src/utils/test/generateZipFile.js index 65af97647000..cf73ad0698bc 100644 --- a/packages/commander/src/utils/test/generateZipFile.js +++ b/packages/commander/src/utils/test/generateZipFile.js @@ -17,14 +17,14 @@ /** * External dependencies */ -import { execFileSync } from 'child_process'; +import { execFileSync } from 'node:child_process'; /** * Internal dependencies */ import generateZipFile from '../generateZipFile'; -jest.mock('child_process'); +jest.mock('node:child_process'); describe('generateZipFile', () => { it('should ZIP the web-stories directory', () => { diff --git a/packages/commander/src/utils/test/getCurrentVersionNumber.js b/packages/commander/src/utils/test/getCurrentVersionNumber.js index 86293a44b8ba..370fee6792fc 100644 --- a/packages/commander/src/utils/test/getCurrentVersionNumber.js +++ b/packages/commander/src/utils/test/getCurrentVersionNumber.js @@ -24,7 +24,7 @@ import { __setMockFiles } from 'node:fs'; */ import getCurrentVersionNumber from '../getCurrentVersionNumber'; -jest.mock('fs'); +jest.mock('node:fs'); const PLUGIN_FILE_CONTENT = ` { const MOCK_FILE_INFO = { diff --git a/packages/commander/src/utils/test/updateCdnUrl.js b/packages/commander/src/utils/test/updateCdnUrl.js index 58fcf3ff1923..447eb6be5d78 100644 --- a/packages/commander/src/utils/test/updateCdnUrl.js +++ b/packages/commander/src/utils/test/updateCdnUrl.js @@ -24,7 +24,7 @@ import { __setMockFiles, readFileSync } from 'node:fs'; */ import updateCdnUrl from '../updateCdnUrl'; -jest.mock('fs'); +jest.mock('node:fs'); const PLUGIN_FILE_CONTENT = ` jest.fn(() => '1.0.0-alpha+1234567') ); diff --git a/packages/fonts/scripts/utils/buildFonts.ts b/packages/fonts/scripts/utils/buildFonts.ts index 6592c79aa1a9..5abc10e491ce 100644 --- a/packages/fonts/scripts/utils/buildFonts.ts +++ b/packages/fonts/scripts/utils/buildFonts.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { writeFileSync } from 'fs'; +import { writeFileSync } from 'node:fs'; /** * Internal dependencies diff --git a/packages/fonts/scripts/utils/getFontMetrics.ts b/packages/fonts/scripts/utils/getFontMetrics.ts index 5a04e3f9d35b..9c40630dbd33 100644 --- a/packages/fonts/scripts/utils/getFontMetrics.ts +++ b/packages/fonts/scripts/utils/getFontMetrics.ts @@ -17,10 +17,10 @@ /** * External dependencies */ -import { unlinkSync, writeFileSync } from 'fs'; -import Crypto from 'crypto'; -import { tmpdir } from 'os'; -import Path from 'path'; +import { unlinkSync, writeFileSync } from 'node:fs'; +import Crypto from 'node:crypto'; +import { tmpdir } from 'node:os'; +import Path from 'node:path'; import { loadSync } from 'opentype.js'; /** diff --git a/packages/fonts/scripts/utils/test/buildFonts.js b/packages/fonts/scripts/utils/test/buildFonts.js index 381e53733fae..947b3a1c72ed 100644 --- a/packages/fonts/scripts/utils/test/buildFonts.js +++ b/packages/fonts/scripts/utils/test/buildFonts.js @@ -22,7 +22,7 @@ * External dependencies */ // eslint-disable-next-line header/header -- Needed because of the @jest-environment comment. -import { __setMockFiles, readFileSync } from 'fs'; +import { __setMockFiles, readFileSync } from 'node:fs'; /** * Internal dependencies @@ -33,7 +33,7 @@ import getFontMetrics from '../getFontMetrics'; jest.spyOn(global, 'fetch').mockImplementation(); -jest.mock('fs'); +jest.mock('node:fs'); jest.mock('../getFontMetrics'); const ABEZEE_FONT_METRICS = { diff --git a/packages/fonts/scripts/utils/test/getFontMetrics.js b/packages/fonts/scripts/utils/test/getFontMetrics.js index ea581d38f7ec..b4fa11132158 100644 --- a/packages/fonts/scripts/utils/test/getFontMetrics.js +++ b/packages/fonts/scripts/utils/test/getFontMetrics.js @@ -21,8 +21,8 @@ * External dependencies */ // eslint-disable-next-line header/header -- Needed because of the @jest-environment comment. -import { join } from 'path'; -import { readFileSync } from 'fs'; +import { join } from 'node:path'; +import { readFileSync } from 'node:fs'; /** * Internal dependencies diff --git a/packages/karma-puppeteer-client/src/client.js b/packages/karma-puppeteer-client/src/client.js index 7dad9759762a..e7cdd6c4452a 100644 --- a/packages/karma-puppeteer-client/src/client.js +++ b/packages/karma-puppeteer-client/src/client.js @@ -14,7 +14,8 @@ * limitations under the License. */ -((global) => { +(function (global) { + 'use strict'; function noCleanup() {} @@ -26,7 +27,7 @@ * @return {*} Function result. */ function puppeteerFunction(methodName) { - return () => { + return function () { var args = Array.prototype.slice.call(arguments, 0); var name = '__karma_puppeteer_' + methodName; if (!window[name]) { @@ -48,7 +49,7 @@ */ function withSelector(methodName) { var func = puppeteerFunction(methodName); - return () => { + return function () { var args = Array.prototype.slice.call(arguments, 0); var node = args[0] && args[0].nodeType ? args[0] : null; var cleanup = noCleanup; @@ -56,7 +57,7 @@ var uniqueId = Math.random(); node.setAttribute('karma_puppeteer_id', uniqueId); args[0] = '[karma_puppeteer_id="' + uniqueId + '"]'; - cleanup = () => { + cleanup = function () { node.removeAttribute('karma_puppeteer_id'); }; } diff --git a/packages/migration/scripts/utils/test/updateTemplates.js b/packages/migration/scripts/utils/test/updateTemplates.js index 2abd7512c536..d431513c2d72 100644 --- a/packages/migration/scripts/utils/test/updateTemplates.js +++ b/packages/migration/scripts/utils/test/updateTemplates.js @@ -17,14 +17,14 @@ /** * External dependencies */ -import { __setMockFiles, readFileSync } from 'fs'; +import { __setMockFiles, readFileSync } from 'node:fs'; /** * Internal dependencies */ import updateTemplates from '../updateTemplates'; -jest.mock('fs'); +jest.mock('node:fs'); jest.mock('../../module', () => ({ migrate: jest.fn(() => ({ migratedkey: 'migratedvalue' })), DATA_VERSION: 9999, diff --git a/packages/migration/scripts/utils/updateTemplates.js b/packages/migration/scripts/utils/updateTemplates.js index 32f2e32f26bc..57de53c5f0f7 100644 --- a/packages/migration/scripts/utils/updateTemplates.js +++ b/packages/migration/scripts/utils/updateTemplates.js @@ -17,8 +17,8 @@ /** * External dependencies */ -import { readdirSync, readFileSync, writeFileSync, lstatSync } from 'fs'; -import { join, resolve } from 'path'; +import { readdirSync, readFileSync, writeFileSync, lstatSync } from 'node:fs'; +import { join, resolve } from 'node:path'; /** * Internal dependencies diff --git a/packages/story-editor/src/components/checklist/checks/videoOptimization.js b/packages/story-editor/src/components/checklist/checks/videoOptimization.js index ee73aa26e7e2..bd65c893a2a0 100644 --- a/packages/story-editor/src/components/checklist/checks/videoOptimization.js +++ b/packages/story-editor/src/components/checklist/checks/videoOptimization.js @@ -302,6 +302,7 @@ const BulkVideoOptimization = () => { }; const VideoOptimization = () => { + // `isTranscodingEnabled` already checks for `hasUploadMediaAction`. const { isTranscodingEnabled } = useFFmpeg(); return isTranscodingEnabled ? : null; diff --git a/packages/tinymce-button/src/index.js b/packages/tinymce-button/src/index.js index 8ebe25789d73..ea5031fd7cbd 100644 --- a/packages/tinymce-button/src/index.js +++ b/packages/tinymce-button/src/index.js @@ -43,13 +43,14 @@ if (!_.hasOwnProperty('pluck')) { _.pluck = _.map; } -tinymce.PluginManager.add('web_stories', (editor) => { +// eslint-disable-next-line prefer-arrow-callback -- Must not be an arrow function. +tinymce.PluginManager.add('web_stories', function (editor) { editor.addButton('web_stories', { text: __('Web Stories', 'web-stories'), classes: 'web-stories', image: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjA4IiBoZWlnaHQ9IjIwOCIgdmlld0JveD0iMCAwIDIwOCAyMDgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxjaXJjbGUgY3g9IjEwMCIgY3k9IjEwMCIgcj0iMTAwIiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNMTM1LjIgNjIuNDAwNUMxNDAuOTQ0IDYyLjQwMDUgMTQ1LjYgNjcuMDU2NyAxNDUuNiA3Mi44MDA1VjEzNS4yQzE0NS42IDE0MC45NDQgMTQwLjk0NCAxNDUuNiAxMzUuMiAxNDUuNlY2Mi40MDA1WiIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTU3LjIgNjIuNDAwNUM1Ny4yIDU2LjY1NjcgNjEuODU2MiA1Mi4wMDA1IDY3LjYgNTIuMDAwNUgxMTQuNEMxMjAuMTQ0IDUyLjAwMDUgMTI0LjggNTYuNjU2NyAxMjQuOCA2Mi40MDA1VjE0NS42QzEyNC44IDE1MS4zNDQgMTIwLjE0NCAxNTYgMTE0LjQgMTU2SDY3LjZDNjEuODU2MiAxNTYgNTcuMiAxNTEuMzQ0IDU3LjIgMTQ1LjZWNjIuNDAwNVoiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xNTYgNzIuODAwNUMxNjAuMzA4IDcyLjgwMDUgMTYzLjggNzYuMjkyNyAxNjMuOCA4MC42MDA1VjEyNy40QzE2My44IDEzMS43MDggMTYwLjMwOCAxMzUuMiAxNTYgMTM1LjJWNzIuODAwNVoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==', - onClick: () => { + onClick: function () { dispatch(store).setEditor(editor); dispatch(store).toggleModal(true); },