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/animation/src/components/test/animationProvider.tsx b/packages/animation/src/components/test/animationProvider.tsx index 455233fd0632..0f6bd7176b00 100644 --- a/packages/animation/src/components/test/animationProvider.tsx +++ b/packages/animation/src/components/test/animationProvider.tsx @@ -50,9 +50,9 @@ function createWrapperWithProps( Wrapper: React.FunctionComponent, props: T ) { - const WrapperWithProps = function ({ children }: PropsWithChildren) { - return {children}; - }; + const WrapperWithProps = ({ children }: PropsWithChildren) => ( + {children} + ); return WrapperWithProps; } diff --git a/packages/animation/src/parts/createAnimation.tsx b/packages/animation/src/parts/createAnimation.tsx index a6d171e89e85..da8d7956a07a 100644 --- a/packages/animation/src/parts/createAnimation.tsx +++ b/packages/animation/src/parts/createAnimation.tsx @@ -48,30 +48,28 @@ function createAnimation( ? {} : getInitialStyleFromKeyframes(keyframes); - const AMPTarget: VoidFunctionComponent = function ({ + const AMPTarget: VoidFunctionComponent = ({ children, style = {}, - }) { - return ( - - {children} - - ); - }; + }) => ( + + {children} + + ); const selector = targetLeafElement ? `#${id} [data-leaf-element="true"]` : `#${id}`; - const AMPAnimation: VoidFunctionComponent = function () { - return ; - }; + const AMPAnimation: VoidFunctionComponent = () => ( + + ); return { id, diff --git a/packages/animation/src/parts/effects/backgroundPan.ts b/packages/animation/src/parts/effects/backgroundPan.ts index 4fe336bb75b4..d84735525673 100644 --- a/packages/animation/src/parts/effects/backgroundPan.ts +++ b/packages/animation/src/parts/effects/backgroundPan.ts @@ -26,7 +26,7 @@ import createAnimation from '../createAnimation'; import { type AMPEffectTiming, AnimationDirection, - AnimationType, + type AnimationType, type Element, FieldType, } from '../../types'; diff --git a/packages/animation/src/parts/effects/drop.ts b/packages/animation/src/parts/effects/drop.ts index ec4c2e4629f9..e7907dbc954b 100644 --- a/packages/animation/src/parts/effects/drop.ts +++ b/packages/animation/src/parts/effects/drop.ts @@ -26,7 +26,7 @@ import type { DimensionableElement } from '@googleforcreators/units'; import createAnimation from '../createAnimation'; import { type AMPEffectTiming, - AnimationType, + type AnimationType, type Element, FieldType, type Keyframes, diff --git a/packages/animation/src/parts/effects/pan.ts b/packages/animation/src/parts/effects/pan.ts index e3be06e6df50..043bff7a45d6 100644 --- a/packages/animation/src/parts/effects/pan.ts +++ b/packages/animation/src/parts/effects/pan.ts @@ -33,7 +33,7 @@ import createAnimation from '../createAnimation'; import { type AMPEffectTiming, AnimationDirection, - AnimationType, + type AnimationType, type Element, FieldType, } from '../../types'; diff --git a/packages/animation/src/parts/simple/blinkOn.ts b/packages/animation/src/parts/simple/blinkOn.ts index 9a56086dfc57..1ee35f34ba1e 100644 --- a/packages/animation/src/parts/simple/blinkOn.ts +++ b/packages/animation/src/parts/simple/blinkOn.ts @@ -19,7 +19,11 @@ */ import generateLookupMap from '../../utils/generateLookupMap'; import padArray from '../../utils/padArray'; -import { type AMPEffectTiming, AnimationType, FieldType } from '../../types'; +import { + type AMPEffectTiming, + type AnimationType, + FieldType, +} from '../../types'; import createAnimation from '../createAnimation'; const DEFAULT_BLINKS = 10; diff --git a/packages/animation/src/parts/simple/fade.ts b/packages/animation/src/parts/simple/fade.ts index 4df46981f873..f6a6f5163e7b 100644 --- a/packages/animation/src/parts/simple/fade.ts +++ b/packages/animation/src/parts/simple/fade.ts @@ -17,7 +17,11 @@ /** * Internal dependencies */ -import { type AMPEffectTiming, AnimationType, FieldType } from '../../types'; +import { + type AMPEffectTiming, + type AnimationType, + FieldType, +} from '../../types'; import createAnimation from '../createAnimation'; const defaults: AMPEffectTiming = { diff --git a/packages/animation/src/parts/simple/flip.ts b/packages/animation/src/parts/simple/flip.ts index 28ce56424093..6bcc29728f38 100644 --- a/packages/animation/src/parts/simple/flip.ts +++ b/packages/animation/src/parts/simple/flip.ts @@ -19,7 +19,7 @@ */ import { type AMPEffectTiming, - AnimationType, + type AnimationType, Axis, FieldType, Rotation, diff --git a/packages/animation/src/parts/simple/floatOn.ts b/packages/animation/src/parts/simple/floatOn.ts index 2a5d62ddd3a3..7bf701dd1942 100644 --- a/packages/animation/src/parts/simple/floatOn.ts +++ b/packages/animation/src/parts/simple/floatOn.ts @@ -20,7 +20,7 @@ import { type AMPEffectTiming, AnimationDirection, - AnimationType, + type AnimationType, FieldType, } from '../../types'; import createAnimation from '../createAnimation'; diff --git a/packages/animation/src/parts/simple/move.ts b/packages/animation/src/parts/simple/move.ts index 077531165e18..8e793a939dcb 100644 --- a/packages/animation/src/parts/simple/move.ts +++ b/packages/animation/src/parts/simple/move.ts @@ -19,7 +19,7 @@ */ import { type AMPEffectTiming, - AnimationType, + type AnimationType, type Element, FieldType, } from '../../types'; diff --git a/packages/animation/src/parts/simple/spin.ts b/packages/animation/src/parts/simple/spin.ts index 60224b8ea264..2059c4d0d422 100644 --- a/packages/animation/src/parts/simple/spin.ts +++ b/packages/animation/src/parts/simple/spin.ts @@ -19,7 +19,7 @@ */ import { type AMPEffectTiming, - AnimationType, + type AnimationType, type Element, FieldType, } from '../../types'; diff --git a/packages/animation/src/parts/simple/zoom.ts b/packages/animation/src/parts/simple/zoom.ts index 6944af3f4da7..51447190699c 100644 --- a/packages/animation/src/parts/simple/zoom.ts +++ b/packages/animation/src/parts/simple/zoom.ts @@ -17,7 +17,11 @@ /** * Internal dependencies */ -import { type AMPEffectTiming, AnimationType, FieldType } from '../../types'; +import { + type AMPEffectTiming, + type AnimationType, + FieldType, +} from '../../types'; import createAnimation from '../createAnimation'; const defaults: AMPEffectTiming = { fill: 'forwards', duration: 1000 }; diff --git a/packages/animation/src/typings/global.d.ts b/packages/animation/src/typings/global.d.ts index bb82070b796c..819461a78f5c 100644 --- a/packages/animation/src/typings/global.d.ts +++ b/packages/animation/src/typings/global.d.ts @@ -33,5 +33,3 @@ declare global { } } } - -export {}; diff --git a/packages/animation/src/utils/createKeyframeEffect.ts b/packages/animation/src/utils/createKeyframeEffect.ts index 611aea4268ad..ab0550beca4a 100644 --- a/packages/animation/src/utils/createKeyframeEffect.ts +++ b/packages/animation/src/utils/createKeyframeEffect.ts @@ -28,7 +28,9 @@ function createKeyframeEffect( const convertedTimings: EffectTiming = { ...timings, iterations: - timings.iterations === 'infinity' ? Infinity : timings.iterations, + timings.iterations === 'infinity' + ? Number.POSITIVE_INFINITY + : timings.iterations, }; return new KeyframeEffect(target, keyframes, convertedTimings); diff --git a/packages/animation/src/utils/padArray.ts b/packages/animation/src/utils/padArray.ts index 44020e8d4d9b..aebcef9cc603 100644 --- a/packages/animation/src/utils/padArray.ts +++ b/packages/animation/src/utils/padArray.ts @@ -15,7 +15,7 @@ */ function padArray(values: number[], padCount: number) { - return values.map((val) => Array(padCount).fill(val)).flat(); + return values.flatMap((val) => Array(padCount).fill(val)); } export default padArray; diff --git a/packages/animation/src/utils/test/createKeyframeEffect.ts b/packages/animation/src/utils/test/createKeyframeEffect.ts index 63fe61667b2b..867e85422cd9 100644 --- a/packages/animation/src/utils/test/createKeyframeEffect.ts +++ b/packages/animation/src/utils/test/createKeyframeEffect.ts @@ -34,7 +34,7 @@ describe('createKeyframeEffect', () => { createKeyframeEffect(element, keyframes, timings); expect(mockKeyframeEffect).toHaveBeenCalledWith(element, keyframes, { - iterations: Infinity, + iterations: Number.POSITIVE_INFINITY, }); }); diff --git a/packages/commander/src/index.ts b/packages/commander/src/index.ts index 6daac7bcb5f1..4d2086f796f7 100755 --- a/packages/commander/src/index.ts +++ b/packages/commander/src/index.ts @@ -18,8 +18,8 @@ /** * External dependencies */ -import { mkdirSync, rmSync, existsSync } from 'fs'; -import { relative } from 'path'; +import { mkdirSync, rmSync, existsSync } from 'node:fs'; +import { relative } from 'node:path'; import { Command } from 'commander'; import { inc as semverInc, type ReleaseType } from 'semver'; @@ -181,7 +181,7 @@ program const pluginFilePath = `${PLUGIN_DIR}/${PLUGIN_FILE}`; updateCdnUrl( pluginFilePath, - version === 'main' ? version : parseInt(version) + version === 'main' ? version : Number.parseInt(version) ); console.log(`Assets CDN URL successfully updated!`); 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/bundlePlugin.ts b/packages/commander/src/utils/bundlePlugin.ts index 541565f8e2ca..324cecb63f1e 100644 --- a/packages/commander/src/utils/bundlePlugin.ts +++ b/packages/commander/src/utils/bundlePlugin.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { dirname } from 'path'; +import { dirname } from 'node:path'; /** * Internal dependencies 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/deleteExistingZipFiles.ts b/packages/commander/src/utils/deleteExistingZipFiles.ts index c6cbd623361c..c62bdd1b4333 100644 --- a/packages/commander/src/utils/deleteExistingZipFiles.ts +++ b/packages/commander/src/utils/deleteExistingZipFiles.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { readdirSync, unlinkSync } from 'fs'; +import { readdirSync, unlinkSync } from 'node:fs'; /** * Removes all existing ZIP files in the build folder. diff --git a/packages/commander/src/utils/generateZipFile.ts b/packages/commander/src/utils/generateZipFile.ts index 1622ec7addb9..cd514b4337f6 100644 --- a/packages/commander/src/utils/generateZipFile.ts +++ b/packages/commander/src/utils/generateZipFile.ts @@ -17,9 +17,9 @@ /** * External dependencies */ -import { dirname, basename, join } from 'path'; -import { execFileSync } from 'child_process'; -import { existsSync, unlinkSync } from 'fs'; +import { dirname, basename, join } from 'node:path'; +import { execFileSync } from 'node:child_process'; +import { existsSync, unlinkSync } from 'node:fs'; /** * Generates a ZIP file. diff --git a/packages/commander/src/utils/getCurrentVersionNumber.ts b/packages/commander/src/utils/getCurrentVersionNumber.ts index 001f7f4bb86c..1b2af6e525d3 100644 --- a/packages/commander/src/utils/getCurrentVersionNumber.ts +++ b/packages/commander/src/utils/getCurrentVersionNumber.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { readFileSync } from 'fs'; +import { readFileSync } from 'node:fs'; const VERSION_REGEX = /\* Version:(.+)/; const VERSION_CONSTANT_REGEX = diff --git a/packages/commander/src/utils/getIgnoredFiles.ts b/packages/commander/src/utils/getIgnoredFiles.ts index 7cbd17fa8743..04a58ff19666 100644 --- a/packages/commander/src/utils/getIgnoredFiles.ts +++ b/packages/commander/src/utils/getIgnoredFiles.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { existsSync, lstatSync, readFileSync } from 'fs'; +import { existsSync, lstatSync, readFileSync } from 'node:fs'; /** * Returns a list of files that should be ignored based on the .distignore file. diff --git a/packages/commander/src/utils/resizeSvgPath.ts b/packages/commander/src/utils/resizeSvgPath.ts index d210a9886ff4..44a0ccf06073 100644 --- a/packages/commander/src/utils/resizeSvgPath.ts +++ b/packages/commander/src/utils/resizeSvgPath.ts @@ -21,7 +21,7 @@ export default function resizeSvgPath(x: number, y: number, path: string) { .split(' '); let coordIndex = 0; return coords.reduce((acc, value) => { - const parsed = parseFloat(value); + const parsed = Number.parseFloat(value); if (!isNaN(parsed)) { const scaled = coordIndex % 2 === 0 ? parsed / x : parsed / y; return `${acc} ${scaled.toFixed(6)}`; 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 097a5d036dec..39cc99b62c0f 100644 --- a/packages/commander/src/utils/test/bundlePlugin.js +++ b/packages/commander/src/utils/test/bundlePlugin.js @@ -17,7 +17,7 @@ /** * External dependencies */ -import { __setMockFiles } from 'fs'; +import { __setMockFiles } from 'node:fs'; /** * Internal dependencies @@ -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 c3a6b7a2dc16..5bd0a7957b02 100644 --- a/packages/commander/src/utils/test/createBuild.js +++ b/packages/commander/src/utils/test/createBuild.js @@ -17,7 +17,7 @@ /** * External dependencies */ -import { __setMockFiles } from 'fs'; +import { __setMockFiles } from 'node:fs'; /** * Internal dependencies @@ -25,7 +25,7 @@ import { __setMockFiles } from '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 6d66af6ada3a..ea3bf6c29fd8 100644 --- a/packages/commander/src/utils/test/deleteExistingZipFiles.js +++ b/packages/commander/src/utils/test/deleteExistingZipFiles.js @@ -17,14 +17,14 @@ /** * External dependencies */ -import { __setMockFiles, readdirSync } from 'fs'; +import { __setMockFiles, readdirSync } from 'node:fs'; /** * Internal dependencies */ 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 a6c9df280e63..370fee6792fc 100644 --- a/packages/commander/src/utils/test/getCurrentVersionNumber.js +++ b/packages/commander/src/utils/test/getCurrentVersionNumber.js @@ -17,14 +17,14 @@ /** * External dependencies */ -import { __setMockFiles } from 'fs'; +import { __setMockFiles } from 'node:fs'; /** * Internal dependencies */ import getCurrentVersionNumber from '../getCurrentVersionNumber'; -jest.mock('fs'); +jest.mock('node:fs'); const PLUGIN_FILE_CONTENT = ` { const MOCK_FILE_INFO = { @@ -32,9 +32,9 @@ describe('getIgnoredFiles', () => { example.txt # somefile.php - + doesnotexist.txt - + sub `, '/foo/example.txt': '', diff --git a/packages/commander/src/utils/test/updateCdnUrl.js b/packages/commander/src/utils/test/updateCdnUrl.js index 1e5be191ce5b..447eb6be5d78 100644 --- a/packages/commander/src/utils/test/updateCdnUrl.js +++ b/packages/commander/src/utils/test/updateCdnUrl.js @@ -17,14 +17,14 @@ /** * External dependencies */ -import { __setMockFiles, readFileSync } from 'fs'; +import { __setMockFiles, readFileSync } from 'node:fs'; /** * Internal dependencies */ 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/commander/src/utils/updateCdnUrl.ts b/packages/commander/src/utils/updateCdnUrl.ts index f8b247f76003..47a3a88afde4 100644 --- a/packages/commander/src/utils/updateCdnUrl.ts +++ b/packages/commander/src/utils/updateCdnUrl.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { readFileSync, writeFileSync } from 'fs'; +import { readFileSync, writeFileSync } from 'node:fs'; const CDN_BASE_URL = 'https://wp.stories.google/static/'; const CDN_URL_CONSTANT_REGEX = diff --git a/packages/commander/src/utils/updateVersionNumbers.ts b/packages/commander/src/utils/updateVersionNumbers.ts index 40ab4c774eaf..b3298dae454a 100644 --- a/packages/commander/src/utils/updateVersionNumbers.ts +++ b/packages/commander/src/utils/updateVersionNumbers.ts @@ -17,7 +17,7 @@ /** * External dependencies */ -import { readFileSync, writeFileSync } from 'fs'; +import { readFileSync, writeFileSync } from 'node:fs'; /** * Internal dependencies diff --git a/packages/dashboard/src/app/reducer/story/storyReducer.js b/packages/dashboard/src/app/reducer/story/storyReducer.js index c279de01c6bf..a76fff610b38 100644 --- a/packages/dashboard/src/app/reducer/story/storyReducer.js +++ b/packages/dashboard/src/app/reducer/story/storyReducer.js @@ -76,7 +76,7 @@ function storyReducer(state, action) { [storyGroupStatus]: state.totalStoriesByStatus[storyGroupStatus] - 1, }, stories: Object.keys(state.stories).reduce((memo, storyId) => { - if (parseInt(storyId) !== action.payload.id) { + if (Number.parseInt(storyId) !== action.payload.id) { memo[storyId] = state.stories[storyId]; } return memo; diff --git a/packages/dashboard/src/app/views/exploreTemplates/index.js b/packages/dashboard/src/app/views/exploreTemplates/index.js index be38175cf715..59b1b893ad35 100644 --- a/packages/dashboard/src/app/views/exploreTemplates/index.js +++ b/packages/dashboard/src/app/views/exploreTemplates/index.js @@ -246,7 +246,7 @@ function ExploreTemplatesView() { useEffect(() => { if (idRef.current && orderedTemplates.length) { const isValidId = orderedTemplates.some( - (template) => template.id === parseInt(idRef.current) + (template) => template.id === Number.parseInt(idRef.current) ); if (!isValidId) { replace(''); @@ -254,7 +254,7 @@ function ExploreTemplatesView() { } setIsDetailsViewOpen(true); - updateTemplateView(parseInt(idRef.current)); + updateTemplateView(Number.parseInt(idRef.current)); } }, [orderedTemplates, replace, updateTemplateView]); diff --git a/packages/dashboard/src/app/views/exploreTemplates/templateFilters.js b/packages/dashboard/src/app/views/exploreTemplates/templateFilters.js index 8e69522d6853..7fd3e6679208 100644 --- a/packages/dashboard/src/app/views/exploreTemplates/templateFilters.js +++ b/packages/dashboard/src/app/views/exploreTemplates/templateFilters.js @@ -26,7 +26,7 @@ import { } from '../../../constants'; export function updateSelectedItems(items, setter) { - return function (sender) { + return (sender) => { const newSelectedItems = items.map((item) => { if (item.value === sender) { return { ...item, selected: !item.selected }; @@ -39,7 +39,7 @@ export function updateSelectedItems(items, setter) { } export function clearAllSelectedItems(items, setter) { - return function () { + return () => { const newSelectedItems = items.map((item) => { return { ...item, selected: false }; }); diff --git a/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js b/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js index 237f4453440a..2345c5749440 100644 --- a/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js +++ b/packages/dashboard/src/app/views/myStories/karma/myStories.karma.js @@ -472,7 +472,7 @@ describe('CUJ: Creator can view their stories in grid view', () => { // find all author filters const authorSelect = await fixture.screen.findByLabelText( - new RegExp(`^Option List Selector$`) + /^Option List Selector$/ ); expect(authorSelect).toBeTruthy(); @@ -506,7 +506,7 @@ describe('CUJ: Creator can view their stories in grid view', () => { // find all category filters const categorySelect = await fixture.screen.findByLabelText( - new RegExp(`^Option List Selector$`) + /^Option List Selector$/ ); expect(categorySelect).toBeTruthy(); diff --git a/packages/dashboard/src/components/scrollToTop/index.js b/packages/dashboard/src/components/scrollToTop/index.js index 50d46d3b43c4..9cb81c4ffd5e 100644 --- a/packages/dashboard/src/components/scrollToTop/index.js +++ b/packages/dashboard/src/components/scrollToTop/index.js @@ -70,7 +70,7 @@ const ScrollToTop = () => { useEffect(() => { window.addEventListener('scroll', handleScroll, { passive: true }); - return function () { + return () => { window.removeEventListener('scroll', handleScroll, { passive: true }); }; }, [handleScroll]); diff --git a/packages/date/src/convertFormatString.ts b/packages/date/src/convertFormatString.ts index 294d330f8e79..4f26877e68ae 100644 --- a/packages/date/src/convertFormatString.ts +++ b/packages/date/src/convertFormatString.ts @@ -114,9 +114,9 @@ const formatMap = { B(date: Date) { // Biel Mean Time (BMT) is UTC+1. const timezoned = zonedTimeToUtc(date, '+0100'); - const seconds = parseInt(format(timezoned, 's')); - const minutes = parseInt(format(timezoned, 'm')); - const hours = parseInt(format(timezoned, 'H')); + const seconds = Number.parseInt(format(timezoned, 's')); + const minutes = Number.parseInt(format(timezoned, 'm')); + const hours = Number.parseInt(format(timezoned, 'H')); // Round results like PHP also does. return Math.round( diff --git a/packages/design-system/src/components/datalist/types.ts b/packages/design-system/src/components/datalist/types.ts index f24fdaa70e69..96e85ffdd7bd 100644 --- a/packages/design-system/src/components/datalist/types.ts +++ b/packages/design-system/src/components/datalist/types.ts @@ -71,15 +71,13 @@ export interface OptionListProps { noMatchesFoundLabel?: string; } -export interface ContentRenderer { - (options: { - searchKeyword: string; - setIsExpanded: (isExpanded: boolean) => void; - trigger: number; - queriedOptions: O[] | null; - listId: string; - }): JSX.Element | null; -} +export type ContentRenderer = (options: { + searchKeyword: string; + setIsExpanded: (isExpanded: boolean) => void; + trigger: number; + queriedOptions: O[] | null; + listId: string; +}) => JSX.Element | null; export interface OptionsContainerProps { isOpen: boolean; diff --git a/packages/design-system/src/components/input/useNumericInput.tsx b/packages/design-system/src/components/input/useNumericInput.tsx index 650792e79a03..7829d7835717 100644 --- a/packages/design-system/src/components/input/useNumericInput.tsx +++ b/packages/design-system/src/components/input/useNumericInput.tsx @@ -126,8 +126,8 @@ const useNumericInput = ({ // Restricts inputted string to be <= max. const parsedValue = options.isFloat - ? parseFloat(ev.target.value) - : parseInt(ev.target.value); + ? Number.parseFloat(ev.target.value) + : Number.parseInt(ev.target.value); if (max !== undefined && parsedValue > max) { if (parsedValue > max) { setCurrentValue( diff --git a/packages/design-system/src/components/input/validation.ts b/packages/design-system/src/components/input/validation.ts index 39a54c3cc91d..67c5848e1f6b 100644 --- a/packages/design-system/src/components/input/validation.ts +++ b/packages/design-system/src/components/input/validation.ts @@ -25,8 +25,8 @@ export function parseInput( ) { if (`${String(value)}`.length > 0) { let boundedValue = isFloat - ? parseFloat(String(value)) - : parseInt(String(value)); + ? Number.parseFloat(String(value)) + : Number.parseInt(String(value)); if (min !== undefined) { boundedValue = Math.max(min, boundedValue); @@ -52,8 +52,8 @@ export function isInputValid( } const valueAsANumber = isFloat - ? parseFloat(String(value)) - : parseInt(String(value)); + ? Number.parseFloat(String(value)) + : Number.parseInt(String(value)); if (min !== undefined && valueAsANumber < min) { return false; diff --git a/packages/design-system/src/components/keyboard/keyboard.tsx b/packages/design-system/src/components/keyboard/keyboard.tsx index 2897b282e45c..79b0fb4e0dc6 100644 --- a/packages/design-system/src/components/keyboard/keyboard.tsx +++ b/packages/design-system/src/components/keyboard/keyboard.tsx @@ -151,7 +151,7 @@ export function useIsKeyPressed( }, []); useEffect(() => { window.addEventListener('blur', handleBlur); - return function () { + return () => { window.removeEventListener('blur', handleBlur); }; }, [handleBlur]); diff --git a/packages/design-system/src/components/keyboard/utils.ts b/packages/design-system/src/components/keyboard/utils.ts index 3b9f7499f860..fa48a08a8ca4 100644 --- a/packages/design-system/src/components/keyboard/utils.ts +++ b/packages/design-system/src/components/keyboard/utils.ts @@ -85,8 +85,7 @@ export function resolveKeySpec(keyDict: Keys, keyNameOrSpec: KeyNameOrSpec) { } = keySpec; const mappedKeys = new Array() .concat(keyOrArray) - .map((key) => keyDict[key as keyof Keys] || key) - .flat(); + .flatMap((key) => keyDict[key as keyof Keys] || key); const allKeys = addMods(mappedKeys, shift); return { key: allKeys, diff --git a/packages/e2e-test-utils/src/checkVersion.js b/packages/e2e-test-utils/src/checkVersion.js index feed5a762644..50f3238add6c 100644 --- a/packages/e2e-test-utils/src/checkVersion.js +++ b/packages/e2e-test-utils/src/checkVersion.js @@ -15,8 +15,8 @@ */ function checkVersion(a, b) { - const x = a.split('.').map((e) => parseInt(e)); - const y = b.split('.').map((e) => parseInt(e)); + const x = a.split('.').map((e) => Number.parseInt(e)); + const y = b.split('.').map((e) => Number.parseInt(e)); // eslint-disable-next-line guard-for-in for (const i in x) { diff --git a/packages/e2e-test-utils/src/deleteAllMedia.js b/packages/e2e-test-utils/src/deleteAllMedia.js index 93be48f8b961..18c41e78b7f2 100644 --- a/packages/e2e-test-utils/src/deleteAllMedia.js +++ b/packages/e2e-test-utils/src/deleteAllMedia.js @@ -41,7 +41,7 @@ async function deleteAllMedia() { await page.hover(`#${elementId}`); await Promise.all([ - await expect(page).toClick(`#${elementId} a.submitdelete`), + expect(page).toClick(`#${elementId} a.submitdelete`), page.waitForNavigation(), ]); await page.waitForSelector(`#message`); diff --git a/packages/e2e-test-utils/src/deleteMedia.js b/packages/e2e-test-utils/src/deleteMedia.js index 8ace37549dc5..86f5be736f1c 100644 --- a/packages/e2e-test-utils/src/deleteMedia.js +++ b/packages/e2e-test-utils/src/deleteMedia.js @@ -43,7 +43,7 @@ async function deleteMedia(fileName) { await page.hover(`#${elementId}`); await Promise.all([ - await expect(page).toClick(`#${elementId} a.submitdelete`), + expect(page).toClick(`#${elementId} a.submitdelete`), page.waitForNavigation(), ]); await page.waitForSelector(`#message`); diff --git a/packages/e2e-test-utils/src/shopping.js b/packages/e2e-test-utils/src/shopping.js index 310c4711d6bf..7df010192534 100644 --- a/packages/e2e-test-utils/src/shopping.js +++ b/packages/e2e-test-utils/src/shopping.js @@ -52,7 +52,7 @@ export const insertProduct = async (product, clickOnTab = true) => { response.url().includes('web-stories/v1/products') && response.status() === 200 ), - await page.waitForSelector(`[aria-label="Add ${product}"]`), + page.waitForSelector(`[aria-label="Add ${product}"]`), ]); expect(page).toClick(`[aria-label="Add ${product}"]`); diff --git a/packages/e2e-tests/src/specs/editor/fontCheck.js b/packages/e2e-tests/src/specs/editor/fontCheck.js index c18cd06d294d..fe934f9eec71 100644 --- a/packages/e2e-tests/src/specs/editor/fontCheck.js +++ b/packages/e2e-tests/src/specs/editor/fontCheck.js @@ -200,10 +200,7 @@ describe.skip('Font Check', () => { const title = 'Test back to dashboard from dialog'; await prepareStoryWithFontCheckDialog(title); // click outside the dialog - await Promise.all([ - await page.mouse.click(100, 100), - page.waitForNavigation(), - ]); + await Promise.all([page.mouse.click(100, 100), page.waitForNavigation()]); await expect(page).toMatchElement('h2', { text: 'Dashboard' }); }); @@ -211,7 +208,7 @@ describe.skip('Font Check', () => { const title = 'Test back to dashboard from dialog'; await prepareStoryWithFontCheckDialog(title); await Promise.all([ - await page.keyboard.press('Escape'), + page.keyboard.press('Escape'), page.waitForNavigation(), ]); await expect(page).toMatchElement('h2', { text: 'Dashboard' }); diff --git a/packages/e2e-tests/src/specs/editor/media/hotlinking.js b/packages/e2e-tests/src/specs/editor/media/hotlinking.js index 1ab81382bce7..4421fc70c27b 100644 --- a/packages/e2e-tests/src/specs/editor/media/hotlinking.js +++ b/packages/e2e-tests/src/specs/editor/media/hotlinking.js @@ -72,7 +72,7 @@ describe('Media Hotlinking', () => { expect(page).toClick('[role="dialog"] button', { text: 'Insert', }), - await page.waitForResponse( + page.waitForResponse( (response) => //eslint-disable-next-line jest/no-conditional-in-test -- False positive. response.url().includes('web-stories/v1/hotlink/validate') && @@ -107,7 +107,7 @@ describe('Media Hotlinking', () => { expect(page).toClick('[role="dialog"] button', { text: 'Insert', }), - await page.waitForResponse( + page.waitForResponse( (response) => //eslint-disable-next-line jest/no-conditional-in-test -- False positive. response.url().includes('web-stories/v1/hotlink/validate') && diff --git a/packages/e2e-tests/src/specs/editor/storyDetailsModal/contributorUser.js b/packages/e2e-tests/src/specs/editor/storyDetailsModal/contributorUser.js index d0c3b6e683b1..53f8df5d0d83 100644 --- a/packages/e2e-tests/src/specs/editor/storyDetailsModal/contributorUser.js +++ b/packages/e2e-tests/src/specs/editor/storyDetailsModal/contributorUser.js @@ -150,7 +150,7 @@ describe('Story Details Modal - Contributor User', () => { expect(page).toClick('[role="dialog"] button', { text: 'Use image as poster image', }), - await page.waitForResponse( + page.waitForResponse( (response) => //eslint-disable-next-line jest/no-conditional-in-test -- False positive. response.url().includes('web-stories/v1/hotlink/validate') && diff --git a/packages/element-library/src/text/outputWithUnits.tsx b/packages/element-library/src/text/outputWithUnits.tsx index cc2d85287bff..8306c09fff7a 100644 --- a/packages/element-library/src/text/outputWithUnits.tsx +++ b/packages/element-library/src/text/outputWithUnits.tsx @@ -118,9 +118,9 @@ function TextOutputWithUnits({ }; const unitlessPaddingVertical = padding?.vertical - ? parseFloat(dataToStyleY(padding.vertical)) + ? Number.parseFloat(dataToStyleY(padding.vertical)) : 0; - const unitlessFontSize = parseFloat(dataToStyleY(rest.fontSize)); + const unitlessFontSize = Number.parseFloat(dataToStyleY(rest.fontSize)); const lineHeight = getHighlightLineheight( rest.lineHeight, diff --git a/packages/element-library/src/text/test/output.js b/packages/element-library/src/text/test/output.js index 43d023844529..d06354158e6e 100644 --- a/packages/element-library/src/text/test/output.js +++ b/packages/element-library/src/text/test/output.js @@ -180,7 +180,7 @@ describe('TextOutput', () => { height: 100, rotationAngle: 0, padding: { - vertical: NaN, + vertical: Number.NaN, horizontal: null, }, }; diff --git a/packages/element-library/src/types.ts b/packages/element-library/src/types.ts index 4f017bdbe28f..f65bfa14c432 100644 --- a/packages/element-library/src/types.ts +++ b/packages/element-library/src/types.ts @@ -28,5 +28,3 @@ export * from './types'; export * from './utils/textMeasurements'; export const elementTypes: ElementDefinition[] = []; - -export {}; diff --git a/packages/eslint-import-resolver/src/index.cjs b/packages/eslint-import-resolver/src/index.cjs index bd3afe31427d..6dc4df0e2fd6 100644 --- a/packages/eslint-import-resolver/src/index.cjs +++ b/packages/eslint-import-resolver/src/index.cjs @@ -22,7 +22,7 @@ const nodeResolver = require('eslint-import-resolver-node'); exports.interfaceVersion = 2; -exports.resolve = function (source, file, config) { +exports.resolve = (source, file, config) => { function nodeResolve(src) { return nodeResolver.resolve(src, file, { ...config, 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/glider/src/index.js b/packages/glider/src/index.js index 8aff1e9bbab6..1f3741e4dd39 100644 --- a/packages/glider/src/index.js +++ b/packages/glider/src/index.js @@ -54,7 +54,7 @@ Glider.prototype.scrollItem = function (slide, dot, e) { this.opt.slidesToShow = Math.max(1, this.opt.slidesToShow); // This will also cause this.itemWidth to be Infinity because division by zero returns Infinity in JS. // Update this.itemWidth with actual value in this case. - if (this.itemWidth === Infinity) { + if (this.itemWidth === Number.POSITIVE_INFINITY) { // It's a sibling. const carouselWrapper = e.target.parentElement.querySelector( '.web-stories-list__carousel' @@ -64,8 +64,9 @@ Glider.prototype.scrollItem = function (slide, dot, e) { ); this.itemWidth = - parseFloat(itemStyle.width) + - (parseFloat(itemStyle.marginLeft) + parseFloat(itemStyle.marginRight)); + Number.parseFloat(itemStyle.width) + + (Number.parseFloat(itemStyle.marginLeft) + + Number.parseFloat(itemStyle.marginRight)); } const originalSlide = slide; diff --git a/packages/karma-failed-tests-reporter/src/index.cjs b/packages/karma-failed-tests-reporter/src/index.cjs index 88042e5da75c..8919d5c0d1b3 100644 --- a/packages/karma-failed-tests-reporter/src/index.cjs +++ b/packages/karma-failed-tests-reporter/src/index.cjs @@ -28,14 +28,14 @@ const FailedTestsReporter = function (baseReporterDecorator, config) { const failedTests = []; - this.onSpecComplete = function (browser, result) { + this.onSpecComplete = (browser, result) => { const { success, fullName } = result; if (!success) { failedTests.push(fullName); } }; - this.onRunComplete = function () { + this.onRunComplete = () => { if (outputFile) { fs.mkdirSync(path.dirname(outputFile), { recursive: true }); fs.writeFileSync(outputFile, failedTests.join('\n')); diff --git a/packages/karma-fixture/src/events.js b/packages/karma-fixture/src/events.js index 7bcf62d2eaef..2699642c2d87 100644 --- a/packages/karma-fixture/src/events.js +++ b/packages/karma-fixture/src/events.js @@ -276,7 +276,7 @@ class Mouse { return rel; } if (rel.endsWith('%')) { - const percent = parseFloat(rel) / 100; + const percent = Number.parseFloat(rel) / 100; return size * percent; } throw new Error('Unknown rel size: ' + rel); diff --git a/packages/karma-fixture/src/init.js b/packages/karma-fixture/src/init.js index a1f9eb72f89d..92ff09157e50 100644 --- a/packages/karma-fixture/src/init.js +++ b/packages/karma-fixture/src/init.js @@ -185,7 +185,7 @@ beforeAll(() => { // Add custom matchers inspired by jest's and jest-dom's ditto jasmine.addMatchers({ toBeEmpty: () => ({ - compare: function (actual) { + compare: (actual) => { const innerHTML = actual?.innerHTML ?? ''; const pass = innerHTML === ''; return { @@ -197,7 +197,7 @@ beforeAll(() => { }, }), toHaveFocus: () => ({ - compare: function (actual) { + compare: (actual) => { const doc = actual?.ownerDocument || actual?.document; const pass = doc.activeElement === actual; return { @@ -209,7 +209,7 @@ beforeAll(() => { }, }), toHaveStyle: (util, customEqualityTesters) => ({ - compare: function (element, property, expected) { + compare: (element, property, expected) => { const actual = element ? window.getComputedStyle(element)[property] : null; @@ -223,7 +223,7 @@ beforeAll(() => { }, }), toHaveProperty: (util, customEqualityTesters) => ({ - compare: function (element, property, expected) { + compare: (element, property, expected) => { const actual = element?.[property] ?? ''; const pass = typeof expected === 'string' @@ -238,7 +238,7 @@ beforeAll(() => { }, }), toHaveTextContent: (util, customEqualityTesters) => ({ - compare: function (element, expected) { + compare: (element, expected) => { const actual = element.textContent.trim(); const pass = util.equals(actual, expected, customEqualityTesters); return { @@ -250,7 +250,7 @@ beforeAll(() => { }, }), toBeOneOf: (util, customEqualityTesters) => ({ - compare: function (actual, expecteds) { + compare: (actual, expecteds) => { const passer = (expected) => util.equals(actual, expected, customEqualityTesters); const pass = expecteds.some(passer); @@ -270,7 +270,7 @@ beforeAll(() => { jasmine.addAsyncMatchers({ toHaveNoViolations: () => ({ - compare: async function (element, options) { + compare: async (element, options) => { const result = await window.axe.run(element, options); const pass = result.violations.length === 0; diff --git a/packages/karma-puppeteer-launcher/src/mouseWithDnd.cjs b/packages/karma-puppeteer-launcher/src/mouseWithDnd.cjs index 9829b045f4ce..6e11f9e936ab 100644 --- a/packages/karma-puppeteer-launcher/src/mouseWithDnd.cjs +++ b/packages/karma-puppeteer-launcher/src/mouseWithDnd.cjs @@ -133,7 +133,7 @@ class DndClientBinding { document.addEventListener( 'dragstart', - function (e) { + (e) => { if (e.isTrusted) { e.preventDefault(); e.stopPropagation(); diff --git a/packages/masks/src/masks.ts b/packages/masks/src/masks.ts index 3c80fb39d55b..ba40188fa2a2 100644 --- a/packages/masks/src/masks.ts +++ b/packages/masks/src/masks.ts @@ -16,8 +16,8 @@ /** * External dependencies */ -import { ElementType, getDefinitionForType } from '@googleforcreators/elements'; -import type { Element, Mask } from '@googleforcreators/elements'; +import { getDefinitionForType } from '@googleforcreators/elements'; +import type { ElementType, Element, Mask } from '@googleforcreators/elements'; import type { CSSProperties } from 'react'; /** diff --git a/packages/masks/src/types.ts b/packages/masks/src/types.ts index 068e3fc10766..4dcb8f398911 100644 --- a/packages/masks/src/types.ts +++ b/packages/masks/src/types.ts @@ -14,10 +14,9 @@ * limitations under the License. */ -export interface RegisterDropTargetCallback { - (id: string, pathRef: SVGPathElement | null): void; -} +export type RegisterDropTargetCallback = ( + id: string, + pathRef: SVGPathElement | null +) => void; -export interface UnregisterDropTargetCallback { - (id: string): void; -} +export type UnregisterDropTargetCallback = (id: string) => void; diff --git a/packages/masks/src/utils/elementBorder.ts b/packages/masks/src/utils/elementBorder.ts index 414bd5b57d0d..1dbcad96813b 100644 --- a/packages/masks/src/utils/elementBorder.ts +++ b/packages/masks/src/utils/elementBorder.ts @@ -219,9 +219,7 @@ export function getBorderColor({ color }: Required>) { return `rgba(${r},${g},${b},${a === undefined ? 1 : a})`; } -interface Converter { - (border: number): number; -} +type Converter = (border: number) => number; /** * Returns border values based on if it's preview or not. diff --git a/packages/media/src/getMsFromHMS.ts b/packages/media/src/getMsFromHMS.ts index 462be86b9b88..1bccd1ede050 100644 --- a/packages/media/src/getMsFromHMS.ts +++ b/packages/media/src/getMsFromHMS.ts @@ -29,7 +29,9 @@ function getMsFromHMS(time: string | null): number { return 0; } const seconds = - parseFloat(parts[2]) + parseInt(parts[1]) * 60 + parseInt(parts[0]) * 3600; + Number.parseFloat(parts[2]) + + Number.parseInt(parts[1]) * 60 + + Number.parseInt(parts[0]) * 3600; return Math.round(1000 * seconds); } diff --git a/packages/media/src/getVideoLength.ts b/packages/media/src/getVideoLength.ts index 7c241e502c01..23ccd08edffc 100644 --- a/packages/media/src/getVideoLength.ts +++ b/packages/media/src/getVideoLength.ts @@ -33,7 +33,8 @@ interface VideoLength { function getVideoLength(video: HTMLMediaElement): VideoLength { // If the element's media doesn't have a known duration—such as for live media streams—the value of duration is +Infinity. // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/duration - const isNumber = !isNaN(video.duration) && Infinity !== video.duration; + const isNumber = + !isNaN(video.duration) && Number.POSITIVE_INFINITY !== video.duration; const duration = isNumber ? video.duration : 0; const length = Math.round(duration); const lengthFormatted = getVideoLengthDisplay(length); 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/output/src/typings/global.d.ts b/packages/output/src/typings/global.d.ts index 5f05f6944d7f..e7fa511bcaa9 100644 --- a/packages/output/src/typings/global.d.ts +++ b/packages/output/src/typings/global.d.ts @@ -116,5 +116,3 @@ declare global { } } } - -export {}; diff --git a/packages/output/src/typings/jest.d.ts b/packages/output/src/typings/jest.d.ts index 7e8c2bda2eee..687b9d1b41f4 100644 --- a/packages/output/src/typings/jest.d.ts +++ b/packages/output/src/typings/jest.d.ts @@ -29,5 +29,3 @@ declare global { } } } - -export {}; diff --git a/packages/patterns/src/getColorFromGradientStyle.ts b/packages/patterns/src/getColorFromGradientStyle.ts index 3e8cf5801e12..8a194266d7b1 100644 --- a/packages/patterns/src/getColorFromGradientStyle.ts +++ b/packages/patterns/src/getColorFromGradientStyle.ts @@ -47,7 +47,7 @@ function parseGradient(style: string, gradient: string): Gradient { { color: startColor, position: 0 }, { color: endColor, position: 1 }, ], - rotation: rotationMatch ? parseFloat(rotationMatch[0]) : 0, + rotation: rotationMatch ? Number.parseFloat(rotationMatch[0]) : 0, }; } @@ -88,9 +88,9 @@ function getColorRange(matches: RegExpMatchArray) { function parseColor(r: string, g: string, b: string, a: string) { return { - r: parseInt(r), - g: parseInt(g), - b: parseInt(b), - a: a ? parseFloat(a) : undefined, + r: Number.parseInt(r), + g: Number.parseInt(g), + b: Number.parseInt(b), + a: a ? Number.parseFloat(a) : undefined, }; } diff --git a/packages/patterns/src/getSolidFromHex.ts b/packages/patterns/src/getSolidFromHex.ts index 0dacd2efd056..78fe93c0fb90 100644 --- a/packages/patterns/src/getSolidFromHex.ts +++ b/packages/patterns/src/getSolidFromHex.ts @@ -30,7 +30,7 @@ function getSolidFromHex(hex: string): Pattern { } = createSolidFromString(`#${hex.slice(0, 6)}`); const opacityDigits = hex.slice(6); - const opacity = opacityDigits ? parseInt(opacityDigits, 16) : 100; + const opacity = opacityDigits ? Number.parseInt(opacityDigits, 16) : 100; return createSolid(r, g, b, opacity / 100); } diff --git a/packages/react/src/renderToStaticMarkup.ts b/packages/react/src/renderToStaticMarkup.ts index 374ec510b135..755e241ce92b 100644 --- a/packages/react/src/renderToStaticMarkup.ts +++ b/packages/react/src/renderToStaticMarkup.ts @@ -39,7 +39,7 @@ function renderToStaticMarkup( element: ReactElement | ReactElement[] | null | string ): string { const originalConsoleError = console.error; - console.error = function (error, ...args) { + console.error = (error, ...args) => { if ( typeof error === 'string' && !error.startsWith('Warning: useLayoutEffect does nothing on the server') diff --git a/packages/react/src/typings/global.d.ts b/packages/react/src/typings/global.d.ts index 8f68995af1b0..85b1cca53048 100644 --- a/packages/react/src/typings/global.d.ts +++ b/packages/react/src/typings/global.d.ts @@ -18,4 +18,4 @@ declare global { var WEB_STORIES_ENV: string; } -export {}; +export type {}; diff --git a/packages/react/src/useContextSelector.ts b/packages/react/src/useContextSelector.ts index 902f10804b8d..6ca4b8ac0316 100644 --- a/packages/react/src/useContextSelector.ts +++ b/packages/react/src/useContextSelector.ts @@ -26,9 +26,7 @@ import type { MutableRefObject, Context } from 'react'; */ import shallowEqual from './shallowEqual'; -interface EqualityFn { - (a: unknown, b: unknown): boolean; -} +type EqualityFn = (a: unknown, b: unknown) => boolean; /** * This hook returns a part of the context value by selector. diff --git a/packages/react/src/useResizeEffect.ts b/packages/react/src/useResizeEffect.ts index 9e24b78298fc..9192ca35372f 100644 --- a/packages/react/src/useResizeEffect.ts +++ b/packages/react/src/useResizeEffect.ts @@ -20,9 +20,7 @@ import { useEffect } from 'react'; import type { DependencyList, MutableRefObject } from 'react'; -interface ResizeHandler { - (dimensions: { width: number; height: number }): void; -} +type ResizeHandler = (dimensions: { width: number; height: number }) => void; /** * @param ref Target node ref. diff --git a/packages/rich-text/src/formatters/letterSpacing.ts b/packages/rich-text/src/formatters/letterSpacing.ts index 5adc234a8a6c..8de2538684a8 100644 --- a/packages/rich-text/src/formatters/letterSpacing.ts +++ b/packages/rich-text/src/formatters/letterSpacing.ts @@ -40,7 +40,7 @@ function styleToLetterSpacing(style: string) { function elementToStyle(element: HTMLElement) { const isSpan = element.tagName.toLowerCase() === 'span'; // This will implicitly strip any trailing unit from the value - it's assumed to be em - const letterSpacing = parseFloat(element.style.letterSpacing); + const letterSpacing = Number.parseFloat(element.style.letterSpacing); const hasLetterSpacing = letterSpacing && !isNaN(letterSpacing); if (isSpan && hasLetterSpacing) { return letterSpacingToStyle(letterSpacing * 100); diff --git a/packages/rich-text/src/formatters/util.ts b/packages/rich-text/src/formatters/util.ts index 1e95926f5eec..b6cecb6f58bb 100644 --- a/packages/rich-text/src/formatters/util.ts +++ b/packages/rich-text/src/formatters/util.ts @@ -22,7 +22,7 @@ import type { FontWeight, FontVariantStyle } from '@googleforcreators/elements'; /** * Internal dependencies */ -import { LETTERSPACING, WEIGHT } from '../customConstants'; +import { type LETTERSPACING, WEIGHT } from '../customConstants'; export const isStyle = (style: string | undefined, prefix: string) => Boolean(style?.startsWith(prefix)); @@ -52,9 +52,9 @@ export function styleToNumeric( const raw = getVariable(style, prefix); // Negative numbers are prefixed with an N: if (raw.charAt(0) === 'N') { - return -parseInt(raw.slice(1)); + return -Number.parseInt(raw.slice(1)); } - return parseInt(raw); + return Number.parseInt(raw); } export function weightToStyle(weight: number) { diff --git a/packages/rich-text/src/formatters/weight.ts b/packages/rich-text/src/formatters/weight.ts index d6c35b1978ec..76207c189a1f 100644 --- a/packages/rich-text/src/formatters/weight.ts +++ b/packages/rich-text/src/formatters/weight.ts @@ -39,7 +39,7 @@ function styleToWeight(style: string) { function elementToStyle(element: HTMLElement) { const isSpan = element.tagName.toLowerCase() === 'span'; - const fontWeight = parseInt(element.style.fontWeight); + const fontWeight = Number.parseInt(element.style.fontWeight); const hasFontWeight = fontWeight && !isNaN(fontWeight); if (isSpan && hasFontWeight && fontWeight !== 400) { return weightToStyle(fontWeight); diff --git a/packages/rich-text/src/typings/jest.d.ts b/packages/rich-text/src/typings/jest.d.ts index 7d6daf701930..e36611159260 100644 --- a/packages/rich-text/src/typings/jest.d.ts +++ b/packages/rich-text/src/typings/jest.d.ts @@ -27,4 +27,4 @@ declare global { } } -export {}; +export type {}; diff --git a/packages/stories-block/src/block/block-types/single-story/edit.js b/packages/stories-block/src/block/block-types/single-story/edit.js index 2e6ec13102dd..13673b32570e 100644 --- a/packages/stories-block/src/block/block-types/single-story/edit.js +++ b/packages/stories-block/src/block/block-types/single-story/edit.js @@ -343,8 +343,8 @@ function StoryEmbedEdit({ onResizeStop={(event, direction, elt, delta) => { onResizeStop(); setAttributes({ - width: parseInt(width + delta.width), - height: parseInt(height + delta.height), + width: Number.parseInt(width + delta.width), + height: Number.parseInt(height + delta.height), }); }} > diff --git a/packages/stories-block/src/block/block-types/single-story/editInLoop.js b/packages/stories-block/src/block/block-types/single-story/editInLoop.js index 3c4efaca4fef..fbca4998eba3 100644 --- a/packages/stories-block/src/block/block-types/single-story/editInLoop.js +++ b/packages/stories-block/src/block/block-types/single-story/editInLoop.js @@ -228,8 +228,8 @@ function StoryEmbedEditInLoop({ onResizeStop={(event, direction, elt, delta) => { onResizeStop(); setAttributes({ - width: parseInt(width + delta.width), - height: parseInt(height + delta.height), + width: Number.parseInt(width + delta.width), + height: Number.parseInt(height + delta.height), }); }} > diff --git a/packages/stories-block/src/block/block-types/single-story/embedControls.js b/packages/stories-block/src/block/block-types/single-story/embedControls.js index ae11e44cfa70..7ad1f82af540 100644 --- a/packages/stories-block/src/block/block-types/single-story/embedControls.js +++ b/packages/stories-block/src/block/block-types/single-story/embedControls.js @@ -181,7 +181,7 @@ const EmbedControls = (props) => { min={minWidth} max={maxWidth} onChange={(value) => - setAttributes({ width: parseInt(value) }) + setAttributes({ width: Number.parseInt(value) }) } /> { max={maxHeight} onChange={(value) => setAttributes({ - height: parseInt(value), + height: Number.parseInt(value), }) } /> diff --git a/packages/stories-block/src/block/block-types/single-story/embedControlsInLoop.js b/packages/stories-block/src/block/block-types/single-story/embedControlsInLoop.js index e5cb0b0c7158..1d54e453defd 100644 --- a/packages/stories-block/src/block/block-types/single-story/embedControlsInLoop.js +++ b/packages/stories-block/src/block/block-types/single-story/embedControlsInLoop.js @@ -65,7 +65,9 @@ const EmbedControlsInLoop = (props) => { value={width || ''} min={minWidth} max={maxWidth} - onChange={(value) => setAttributes({ width: parseInt(value) })} + onChange={(value) => + setAttributes({ width: Number.parseInt(value) }) + } /> { max={maxHeight} onChange={(value) => setAttributes({ - height: parseInt(value), + height: Number.parseInt(value), }) } /> diff --git a/packages/stories-block/src/block/components/storiesPreview.js b/packages/stories-block/src/block/components/storiesPreview.js index 56f70b8ec0d6..826a75358c97 100644 --- a/packages/stories-block/src/block/components/storiesPreview.js +++ b/packages/stories-block/src/block/components/storiesPreview.js @@ -113,8 +113,9 @@ function StoriesPreview(props) { const itemStyle = window.getComputedStyle(storyItem); const itemWidth = - parseFloat(itemStyle.width) + - (parseFloat(itemStyle.marginLeft) + parseFloat(itemStyle.marginRight)); + Number.parseFloat(itemStyle.width) + + (Number.parseFloat(itemStyle.marginLeft) + + Number.parseFloat(itemStyle.marginRight)); const instance = new Glider(carouselContainer.current, { slidesToShow: 'auto', diff --git a/packages/stories-carousel/src/index.js b/packages/stories-carousel/src/index.js index b8196ff03148..de5470182543 100644 --- a/packages/stories-carousel/src/index.js +++ b/packages/stories-carousel/src/index.js @@ -57,8 +57,9 @@ domReady(() => { ); const itemWidth = - parseFloat(itemStyle.width) + - (parseFloat(itemStyle.marginLeft) + parseFloat(itemStyle.marginRight)); + Number.parseFloat(itemStyle.width) + + (Number.parseFloat(itemStyle.marginLeft) + + Number.parseFloat(itemStyle.marginRight)); // For circles view we would want to keep it auto. if (isCircles) { diff --git a/packages/story-editor/src/app/highlights/provider.tsx b/packages/story-editor/src/app/highlights/provider.tsx index 530aadb36fe6..cd7571428d6f 100644 --- a/packages/story-editor/src/app/highlights/provider.tsx +++ b/packages/story-editor/src/app/highlights/provider.tsx @@ -30,7 +30,7 @@ import type { HighlightsState, } from '../../types/highlightsProvider'; import Context from './context'; -import { HighlightType, STATES } from './states'; +import { type HighlightType, STATES } from './states'; function HighlightsProvider({ children }: PropsWithChildren) { const [highlighted, setHighlighted] = useState({}); diff --git a/packages/story-editor/src/app/media/local/useContextValueProvider.js b/packages/story-editor/src/app/media/local/useContextValueProvider.js index d79db7534e42..e36a511f709e 100644 --- a/packages/story-editor/src/app/media/local/useContextValueProvider.js +++ b/packages/story-editor/src/app/media/local/useContextValueProvider.js @@ -108,8 +108,8 @@ export default function useContextValueProvider(reducerState, reducerActions) { return; } - const totalPages = parseInt(headers.totalPages); - const totalItems = parseInt(headers.totalItems); + const totalPages = Number.parseInt(headers.totalPages); + const totalItems = Number.parseInt(headers.totalItems); const hasMore = p < totalPages; callback({ diff --git a/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js b/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js index 1e366bd88558..74ddc58a8506 100644 --- a/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js +++ b/packages/story-editor/src/app/media/utils/getResourceFromMedia3p.js @@ -228,7 +228,7 @@ function getImageResourceFromMedia3p(m) { function getVideoResourceFromMedia3p(m) { const videoUrls = getVideoUrls(m); - const length = parseInt(m.videoMetadata.duration.replace(/s$/, '')); + const length = Number.parseInt(m.videoMetadata.duration.replace(/s$/, '')); return createResource({ id: m.name, baseColor: m.color, diff --git a/packages/story-editor/src/app/quickActions/mediaPicker.js b/packages/story-editor/src/app/quickActions/mediaPicker.js index 3421542cc030..4b562b571476 100644 --- a/packages/story-editor/src/app/quickActions/mediaPicker.js +++ b/packages/story-editor/src/app/quickActions/mediaPicker.js @@ -87,8 +87,7 @@ const MediaPicker = ({ render, ...props }) => { [allowedImageMimeTypes, allowedVectorMimeTypes, allowedVideoMimeTypes] ); const allowedFileTypes = useMemo( - () => - allowedMimeTypes.map((type) => getExtensionsFromMimeType(type)).flat(), + () => allowedMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedMimeTypes] ); if (isTranscodingEnabled) { diff --git a/packages/story-editor/src/app/uploader/useUploader.ts b/packages/story-editor/src/app/uploader/useUploader.ts index e11e0cd39af2..ba1e02eb9e51 100644 --- a/packages/story-editor/src/app/uploader/useUploader.ts +++ b/packages/story-editor/src/app/uploader/useUploader.ts @@ -122,9 +122,9 @@ function useUploader() { 'web-stories' ); - const allowedFileTypes = overrideAllowedMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(); + const allowedFileTypes = overrideAllowedMimeTypes.flatMap((type) => + getExtensionsFromMimeType(type) + ); if (allowedFileTypes.length) { /* translators: %s is a list of allowed file extensions. */ diff --git a/packages/story-editor/src/components/canvas/eyedropperLayer.js b/packages/story-editor/src/components/canvas/eyedropperLayer.js index 9caebd638cc2..eff556ca9de1 100644 --- a/packages/story-editor/src/components/canvas/eyedropperLayer.js +++ b/packages/story-editor/src/components/canvas/eyedropperLayer.js @@ -184,7 +184,7 @@ function EyedropperLayer() { return null; } - const magnify = function (x, y) { + const magnify = (x, y) => { const canvas = magnifier.current; if (canvas) { const ctx = canvas.getContext('2d'); diff --git a/packages/story-editor/src/components/canvas/mediaCaptions/parseTimestamp.js b/packages/story-editor/src/components/canvas/mediaCaptions/parseTimestamp.js index 8b0d0afbef1e..2dc09bd0f9b6 100644 --- a/packages/story-editor/src/components/canvas/mediaCaptions/parseTimestamp.js +++ b/packages/story-editor/src/components/canvas/mediaCaptions/parseTimestamp.js @@ -29,10 +29,10 @@ function parseTimestamp(timestamp) { if (!match) { return null; } - const hours = match[1] ? parseInt(match[1]) : 0; - const minutes = parseInt(match[2]); - const seconds = parseInt(match[3]); - const milliseconds = parseInt(match[4]); + const hours = match[1] ? Number.parseInt(match[1]) : 0; + const minutes = Number.parseInt(match[2]); + const seconds = Number.parseInt(match[3]); + const milliseconds = Number.parseInt(match[4]); return hours * 3600 + minutes * 60 + seconds + milliseconds / 1000; } diff --git a/packages/story-editor/src/components/canvas/useInsertElement.ts b/packages/story-editor/src/components/canvas/useInsertElement.ts index 2d129a5abc53..a5534930d2a6 100644 --- a/packages/story-editor/src/components/canvas/useInsertElement.ts +++ b/packages/story-editor/src/components/canvas/useInsertElement.ts @@ -21,7 +21,7 @@ import { useCallback } from '@googleforcreators/react'; import { createNewElement, elementIs, - ElementType, + type ElementType, type Element, } from '@googleforcreators/elements'; diff --git a/packages/story-editor/src/components/canvas/utils/getElementProperties.ts b/packages/story-editor/src/components/canvas/utils/getElementProperties.ts index d4be2e63719d..2d3dbc6d1ac9 100644 --- a/packages/story-editor/src/components/canvas/utils/getElementProperties.ts +++ b/packages/story-editor/src/components/canvas/utils/getElementProperties.ts @@ -21,10 +21,10 @@ import STICKERS from '@googleforcreators/stickers'; import { dataPixels } from '@googleforcreators/units'; import { elementIs, - ElementType, + type ElementType, + type Element, getDefinitionForType, } from '@googleforcreators/elements'; -import type { Element } from '@googleforcreators/elements'; import { DEFAULT_MASK } from '@googleforcreators/masks'; /** diff --git a/packages/story-editor/src/components/checklist/checks/videoOptimization.js b/packages/story-editor/src/components/checklist/checks/videoOptimization.js index 88ae1784b3dc..bd65c893a2a0 100644 --- a/packages/story-editor/src/components/checklist/checks/videoOptimization.js +++ b/packages/story-editor/src/components/checklist/checks/videoOptimization.js @@ -302,9 +302,7 @@ const BulkVideoOptimization = () => { }; const VideoOptimization = () => { - { - /* `isTranscodingEnabled` already checks for `hasUploadMediaAction` */ - } + // `isTranscodingEnabled` already checks for `hasUploadMediaAction`. const { isTranscodingEnabled } = useFFmpeg(); return isTranscodingEnabled ? : null; diff --git a/packages/story-editor/src/components/checklist/karma/firstPageAnimation.karma.js b/packages/story-editor/src/components/checklist/karma/firstPageAnimation.karma.js index 82cb9717e727..acb7acd3e984 100644 --- a/packages/story-editor/src/components/checklist/karma/firstPageAnimation.karma.js +++ b/packages/story-editor/src/components/checklist/karma/firstPageAnimation.karma.js @@ -119,9 +119,7 @@ describe('firstPageAnimation', () => { await openCheckList(); // check for remove animations button - const seeRemoveAnimations = fixture.screen.getByText( - new RegExp(`^Remove Animations`) - ); + const seeRemoveAnimations = fixture.screen.getByText(/^Remove Animations/); expect(seeRemoveAnimations).toBeDefined(); const removeAnimationsBtn = fixture.screen.getByRole('button', { diff --git a/packages/story-editor/src/components/colorPicker/currentColorPicker.js b/packages/story-editor/src/components/colorPicker/currentColorPicker.js index cb8c770f5e95..5075f922f17e 100644 --- a/packages/story-editor/src/components/colorPicker/currentColorPicker.js +++ b/packages/story-editor/src/components/colorPicker/currentColorPicker.js @@ -152,7 +152,7 @@ function CurrentColorPicker({ rgb, hsl, hsv, hex, onChange }) { const handleOpacityInputChange = useCallback( (value) => - onChange({ ...rgb, a: isNaN(value) ? 1 : parseInt(value) / 100 }), + onChange({ ...rgb, a: isNaN(value) ? 1 : Number.parseInt(value) / 100 }), [rgb, onChange] ); diff --git a/packages/story-editor/src/components/footer/karma/zoomSelector.karma.js b/packages/story-editor/src/components/footer/karma/zoomSelector.karma.js index 61fb069329cd..b0f88c5d48ab 100644 --- a/packages/story-editor/src/components/footer/karma/zoomSelector.karma.js +++ b/packages/story-editor/src/components/footer/karma/zoomSelector.karma.js @@ -37,7 +37,7 @@ describe('Zoom selector', () => { // Add some matchers not generally useful, but applicable in this file jasmine.addMatchers({ toBeVerticallyScrollable: () => ({ - compare: function (actual) { + compare: (actual) => { const { scrollHeight, clientHeight } = actual; const pass = scrollHeight > clientHeight; return { @@ -51,7 +51,7 @@ describe('Zoom selector', () => { }, }), toBeHorizontallyScrollable: () => ({ - compare: function (actual) { + compare: (actual) => { const { scrollWidth, clientWidth } = actual; const pass = scrollWidth > clientWidth; return { @@ -65,7 +65,7 @@ describe('Zoom selector', () => { }, }), toHaveSize: () => ({ - compare: function (actual, width, height) { + compare: (actual, width, height) => { const { clientWidth, clientHeight } = actual; // 1px differences due to rounding are OK. const pass = diff --git a/packages/story-editor/src/components/form/dateTime/timePicker.js b/packages/story-editor/src/components/form/dateTime/timePicker.js index d6145c18f4d4..1b967e3b5323 100644 --- a/packages/story-editor/src/components/form/dateTime/timePicker.js +++ b/packages/story-editor/src/components/form/dateTime/timePicker.js @@ -89,7 +89,7 @@ function TimePicker({ const onChangeEvent = (prop) => (_, value) => { let filteredValue = value !== undefined && value !== null - ? parseInt(value) + ? Number.parseInt(value) : localeData[prop]; filteredValue = isNaN(filteredValue) ? '' : filteredValue; filteredValue = filteredValue === '' && value === '-' ? '-' : filteredValue; @@ -122,7 +122,7 @@ function TimePicker({ const updateMinutes = () => { const { minutes, date } = localeData; - const value = parseInt(minutes); + const value = Number.parseInt(minutes); if (isNaN(value) || value < 0 || value > 59) { return; } @@ -135,7 +135,7 @@ function TimePicker({ const updateHours = () => { const { hours, date } = localeData; - const value = parseInt(hours); + const value = Number.parseInt(hours); if (isNaN(value) || value < getMinHours() || value > getMaxHours()) { return; } diff --git a/packages/story-editor/src/components/form/linkIcon.js b/packages/story-editor/src/components/form/linkIcon.js index da8a6b66b199..c89ca7e843d3 100644 --- a/packages/story-editor/src/components/form/linkIcon.js +++ b/packages/story-editor/src/components/form/linkIcon.js @@ -43,9 +43,7 @@ function LinkIcon({ handleChange, icon, isLoading = false, ...rest }) { const allowedImageFileTypes = useMemo( () => - allowedImageMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedImageMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedImageMimeTypes] ); diff --git a/packages/story-editor/src/components/form/mediaUploadButton.js b/packages/story-editor/src/components/form/mediaUploadButton.js index 181157001aea..51f50aa35bbd 100644 --- a/packages/story-editor/src/components/form/mediaUploadButton.js +++ b/packages/story-editor/src/components/form/mediaUploadButton.js @@ -50,9 +50,7 @@ function MediaUploadButton({ onInsert, renderButton, buttonInsertText }) { ); const allowedFileTypes = useMemo( () => - allowedUploadMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedUploadMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedUploadMimeTypes] ); diff --git a/packages/story-editor/src/components/form/useHotlink.js b/packages/story-editor/src/components/form/useHotlink.js index 90381abaa51e..a053d7bff011 100644 --- a/packages/story-editor/src/components/form/useHotlink.js +++ b/packages/story-editor/src/components/form/useHotlink.js @@ -33,7 +33,7 @@ function useHotlink({ onChange, type, canUseProxy }) { const allowedFileTypes = useMemo( () => Array.isArray(type) - ? type.map((_type) => getExtensionsFromMimeType(_type)).flat() + ? type.flatMap((_type) => getExtensionsFromMimeType(_type)) : [], [type] ); diff --git a/packages/story-editor/src/components/library/panes/media/local/hotlink/useInsert.js b/packages/story-editor/src/components/library/panes/media/local/hotlink/useInsert.js index af2f70af2820..7f105f2c064a 100644 --- a/packages/story-editor/src/components/library/panes/media/local/hotlink/useInsert.js +++ b/packages/story-editor/src/components/library/panes/media/local/hotlink/useInsert.js @@ -74,8 +74,7 @@ function useInsert() { [allowedImageMimeTypes, allowedVectorMimeTypes, allowedVideoMimeTypes] ); const allowedFileTypes = useMemo( - () => - allowedMimeTypes.map((type) => getExtensionsFromMimeType(type)).flat(), + () => allowedMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedMimeTypes] ); diff --git a/packages/story-editor/src/components/library/panes/media/media3p/karma/mediaFetching.karma.js b/packages/story-editor/src/components/library/panes/media/media3p/karma/mediaFetching.karma.js index fd87d1770093..7f59bd649240 100644 --- a/packages/story-editor/src/components/library/panes/media/media3p/karma/mediaFetching.karma.js +++ b/packages/story-editor/src/components/library/panes/media/media3p/karma/mediaFetching.karma.js @@ -277,9 +277,7 @@ describe('Media3pPane fetching', () => { listMediaSpy.and.callFake(() => ({ media: [] })); await fixture.events.click(fixture.editor.library.media3pTab); - await expect( - fixture.screen.findByText(new RegExp('^No media found.$')) - ).toBeTruthy(); + await expect(fixture.screen.findByText(/^No media found.$/)).toBeTruthy(); await fixture.snapshot(); }); diff --git a/packages/story-editor/src/components/panels/design/animation/effectInput.js b/packages/story-editor/src/components/panels/design/animation/effectInput.js index a5253abb52cb..e2e9c8008681 100644 --- a/packages/story-editor/src/components/panels/design/animation/effectInput.js +++ b/packages/story-editor/src/components/panels/design/animation/effectInput.js @@ -133,8 +133,8 @@ function EffectInput({ onChange={(evt) => onChange( isFloat - ? parseFloat(evt.target.value) - : parseInt(evt.target.value), + ? Number.parseFloat(evt.target.value) + : Number.parseInt(evt.target.value), true ) } diff --git a/packages/story-editor/src/components/panels/design/textStyle/font.js b/packages/story-editor/src/components/panels/design/textStyle/font.js index 8b87cb5f1ecd..9e3b075f4270 100644 --- a/packages/story-editor/src/components/panels/design/textStyle/font.js +++ b/packages/story-editor/src/components/panels/design/textStyle/font.js @@ -101,7 +101,7 @@ function FontControls({ return { font, fontStyle, - fontWeight: parseInt(value), + fontWeight: Number.parseInt(value), content: stripHTML(content), }; }) diff --git a/packages/story-editor/src/components/panels/design/textStyle/getClosestFontWeight.js b/packages/story-editor/src/components/panels/design/textStyle/getClosestFontWeight.js index e33e59614184..b6f27fa2d4b2 100644 --- a/packages/story-editor/src/components/panels/design/textStyle/getClosestFontWeight.js +++ b/packages/story-editor/src/components/panels/design/textStyle/getClosestFontWeight.js @@ -28,9 +28,9 @@ function getClosestFontWeight( existingWeight = DEFAULT_FONT_WEIGHT, availableWeights ) { - existingWeight = parseInt(existingWeight); + existingWeight = Number.parseInt(existingWeight); // if the passed in existing weight is "(multiple)" we want to reset the value for the new font family in use - if (isNaN(parseInt(existingWeight))) { + if (isNaN(Number.parseInt(existingWeight))) { return DEFAULT_FONT_WEIGHT; } @@ -39,8 +39,8 @@ function getClosestFontWeight( } return availableWeights.reduce((a, b) => { - a = parseInt(a); - b = parseInt(b); + a = Number.parseInt(a); + b = Number.parseInt(b); const aDiff = Math.abs(a - existingWeight); const bDiff = Math.abs(b - existingWeight); diff --git a/packages/story-editor/src/components/panels/design/textStyle/karma/textStyle.other.karma.js b/packages/story-editor/src/components/panels/design/textStyle/karma/textStyle.other.karma.js index dce79f44c3e2..97115c843447 100644 --- a/packages/story-editor/src/components/panels/design/textStyle/karma/textStyle.other.karma.js +++ b/packages/story-editor/src/components/panels/design/textStyle/karma/textStyle.other.karma.js @@ -207,7 +207,7 @@ describe('Text Style Panel', () => { // This verifies it includes correct units. const splits = displayStyle.margin.split('px'); // Verify the top-bottom margin is negative. - expect(parseInt(splits[0].trim())).toBeLessThanOrEqual(0); + expect(Number.parseInt(splits[0].trim())).toBeLessThanOrEqual(0); // Verify the left-right margin is 0. expect(splits[1].trim() || '0').toBe('0'); // Verify units are correctly added to padding. @@ -216,7 +216,7 @@ describe('Text Style Panel', () => { // Verify the same things for the frames layer. const frameStyle = await waitFor(() => window.getComputedStyle(texts[1])); const frameSplits = frameStyle.margin.split('px'); - expect(parseInt(frameSplits[0].trim())).toBeLessThanOrEqual(0); + expect(Number.parseInt(frameSplits[0].trim())).toBeLessThanOrEqual(0); expect(frameSplits[1].trim() || '0').toBe('0'); expect(frameStyle.padding).toContain('px'); diff --git a/packages/story-editor/src/components/panels/design/videoAccessibility/videoAccessibility.js b/packages/story-editor/src/components/panels/design/videoAccessibility/videoAccessibility.js index 574f9d732117..0866fe22f10f 100644 --- a/packages/story-editor/src/components/panels/design/videoAccessibility/videoAccessibility.js +++ b/packages/story-editor/src/components/panels/design/videoAccessibility/videoAccessibility.js @@ -88,9 +88,7 @@ function VideoAccessibilityPanel({ selectedElements, pushUpdate }) { const allowedImageFileTypes = useMemo( () => - allowedImageMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedImageMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedImageMimeTypes] ); diff --git a/packages/story-editor/src/components/panels/document/taxonomies/FlatTermSelector.js b/packages/story-editor/src/components/panels/document/taxonomies/FlatTermSelector.js index 3c40d6c49359..c3ac967a2a41 100644 --- a/packages/story-editor/src/components/panels/document/taxonomies/FlatTermSelector.js +++ b/packages/story-editor/src/components/panels/document/taxonomies/FlatTermSelector.js @@ -159,7 +159,7 @@ function FlatTermSelector({ taxonomy, canCreateTerms }) { ); useEffect(() => { - (async function () { + (async () => { const results = await addSearchResultsToCache({ taxonomy, args: { diff --git a/packages/story-editor/src/components/panels/layer/useLayers.js b/packages/story-editor/src/components/panels/layer/useLayers.js index a27af9e2f24f..003eb6ecafce 100644 --- a/packages/story-editor/src/components/panels/layer/useLayers.js +++ b/packages/story-editor/src/components/panels/layer/useLayers.js @@ -51,7 +51,7 @@ function useLayers() { return ( elementLayers // If an element has a new group, add both group and element - .map((element, index, list) => { + .flatMap((element, index, list) => { const elementLayer = { isGroup: false, isFirstElementAfterGroup: @@ -72,8 +72,6 @@ function useLayers() { }; return [groupLayer, elementLayer]; }) - // Flatten the nested arrays - .flat() ); }, [elementLayers]); diff --git a/packages/story-editor/src/components/panels/shared/media/backgroundAudioPanelContent.js b/packages/story-editor/src/components/panels/shared/media/backgroundAudioPanelContent.js index b017d519fbc6..9ebf35aed63e 100644 --- a/packages/story-editor/src/components/panels/shared/media/backgroundAudioPanelContent.js +++ b/packages/story-editor/src/components/panels/shared/media/backgroundAudioPanelContent.js @@ -99,9 +99,7 @@ function BackgroundAudioPanelContent({ const allowedAudioFileTypes = useMemo( () => - allowedAudioMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedAudioMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedAudioMimeTypes] ); const { resource = {}, tracks = [], loop = true } = backgroundAudio || {}; diff --git a/packages/story-editor/src/components/panels/shared/media/captionsPanelContent.js b/packages/story-editor/src/components/panels/shared/media/captionsPanelContent.js index ae519d6b411f..30107beb9c3f 100644 --- a/packages/story-editor/src/components/panels/shared/media/captionsPanelContent.js +++ b/packages/story-editor/src/components/panels/shared/media/captionsPanelContent.js @@ -80,9 +80,9 @@ function CaptionsPanelContent({ const allowedFileTypes = useMemo( () => - allowedCaptionMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedCaptionMimeTypes.flatMap((type) => + getExtensionsFromMimeType(type) + ), [allowedCaptionMimeTypes] ); diff --git a/packages/story-editor/src/components/publishModal/content/storyPreview.js b/packages/story-editor/src/components/publishModal/content/storyPreview.js index 962cc2a69b0b..0424772fca64 100644 --- a/packages/story-editor/src/components/publishModal/content/storyPreview.js +++ b/packages/story-editor/src/components/publishModal/content/storyPreview.js @@ -202,9 +202,7 @@ const StoryPreview = () => { const allowedImageFileTypes = useMemo( () => - allowedImageMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedImageMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedImageMimeTypes] ); diff --git a/packages/story-editor/src/components/uploadDropTarget/message.js b/packages/story-editor/src/components/uploadDropTarget/message.js index cad37550ca1a..454e3dc32c58 100644 --- a/packages/story-editor/src/components/uploadDropTarget/message.js +++ b/packages/story-editor/src/components/uploadDropTarget/message.js @@ -81,8 +81,7 @@ function UploadDropTargetMessage({ message, ...rest }) { [allowedImageMimeTypes, allowedVideoMimeTypes, allowedVectorMimeTypes] ); const allowedFileTypes = useMemo( - () => - allowedMimeTypes.map((type) => getExtensionsFromMimeType(type)).flat(), + () => allowedMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedMimeTypes] ); diff --git a/packages/story-editor/src/components/videoTrim/slider.js b/packages/story-editor/src/components/videoTrim/slider.js index 2587b3a4106f..ca924a11a88d 100644 --- a/packages/story-editor/src/components/videoTrim/slider.js +++ b/packages/story-editor/src/components/videoTrim/slider.js @@ -60,7 +60,7 @@ function Slider({ onPointerDown?.(); - const handlePointerMove = function (event) { + const handlePointerMove = (event) => { const deltaX = getPageX(event) - getPageX(downEvent); const deltaRatio = deltaX / railWidth; const deltaValue = deltaRatio * (max - min); @@ -71,7 +71,7 @@ function Slider({ event.stopPropagation(); }; - const handlePointerUp = function () { + const handlePointerUp = () => { document.removeEventListener('pointermove', handlePointerMove); document.removeEventListener('pointerup', handlePointerUp); }; diff --git a/packages/story-editor/src/karma/elementTransform.cuj.karma.js b/packages/story-editor/src/karma/elementTransform.cuj.karma.js index 4e8f349b5d40..61666f39b219 100644 --- a/packages/story-editor/src/karma/elementTransform.cuj.karma.js +++ b/packages/story-editor/src/karma/elementTransform.cuj.karma.js @@ -88,9 +88,9 @@ describe('Element transform', () => { ]); const widthAfter = window.getComputedStyle(frame).width; // It should just be within a pixel of correct - expect(parseInt(widthAfter) - parseInt(widthBefore)).toBeOneOf([ - 19, 20, 21, - ]); + expect( + Number.parseInt(widthAfter) - Number.parseInt(widthBefore) + ).toBeOneOf([19, 20, 21]); }); }); diff --git a/packages/story-editor/src/karma/richText/inlineSelection.karma.js b/packages/story-editor/src/karma/richText/inlineSelection.karma.js index 055d9f3d727f..4acad43f7b27 100644 --- a/packages/story-editor/src/karma/richText/inlineSelection.karma.js +++ b/packages/story-editor/src/karma/richText/inlineSelection.karma.js @@ -408,7 +408,9 @@ describe('CUJ: Creator can Add and Write Text: Select an individual word to edit }; await data.fixture.events.click(data.fixture.editor.sidebar.designTab); - const initialLineHeight = parseFloat(getDisplayTextStyles().lineHeight); + const initialLineHeight = Number.parseFloat( + getDisplayTextStyles().lineHeight + ); const { lineHeight } = data.fixture.editor.sidebar.designPanel.textStyle; @@ -432,7 +434,9 @@ describe('CUJ: Creator can Add and Write Text: Select an individual word to edit expect(getTextContent()).toBe('Fill in some text'); // Expect line height to have changed - const currentLineHeight = parseFloat(getDisplayTextStyles().lineHeight); + const currentLineHeight = Number.parseFloat( + getDisplayTextStyles().lineHeight + ); expect(currentLineHeight).not.toBe(initialLineHeight); }); }); diff --git a/packages/story-editor/src/typings/global.d.ts b/packages/story-editor/src/typings/global.d.ts index af3a6d7ca6bc..9355ba725da7 100644 --- a/packages/story-editor/src/typings/global.d.ts +++ b/packages/story-editor/src/typings/global.d.ts @@ -36,5 +36,3 @@ declare global { }; } } - -export {}; diff --git a/packages/story-editor/src/utils/generateBlurhash.worker.js b/packages/story-editor/src/utils/generateBlurhash.worker.js index e799485db461..153bd4be6c71 100644 --- a/packages/story-editor/src/utils/generateBlurhash.worker.js +++ b/packages/story-editor/src/utils/generateBlurhash.worker.js @@ -19,7 +19,7 @@ */ import { encode } from 'blurhash'; -const callback = function (event) { +const callback = (event) => { const { image, width, height, componentX, componentY } = event.data; // Bail early if the message is not for us. diff --git a/packages/story-editor/src/utils/getInUseFonts.ts b/packages/story-editor/src/utils/getInUseFonts.ts index 1f5bee1b1e0e..6733aad42201 100644 --- a/packages/story-editor/src/utils/getInUseFonts.ts +++ b/packages/story-editor/src/utils/getInUseFonts.ts @@ -29,12 +29,11 @@ export function getInUseFontsForPages(pages: Page[]) { Array.from( new Set( pages - .map(({ elements = [] }) => + .flatMap(({ elements = [] }) => elements.map((element) => elementIs.text(element) ? element.font.family : null ) ) - .flat() .filter(Boolean) ) ) || [] diff --git a/packages/story-editor/src/utils/idleCallback.ts b/packages/story-editor/src/utils/idleCallback.ts index 8ade9bdbf1e1..618f01c873d2 100644 --- a/packages/story-editor/src/utils/idleCallback.ts +++ b/packages/story-editor/src/utils/idleCallback.ts @@ -17,7 +17,7 @@ /* Source: https://github.com/behnammodi/polyfill/blob/master/window.polyfill.js */ const requestIdleCallback = window.requestIdleCallback || - function (callback: IdleRequestCallback, options: IdleRequestOptions = {}) { + ((callback: IdleRequestCallback, options: IdleRequestOptions = {}) => { const relaxation = 1; const timeout = options.timeout || relaxation; const start = performance.now(); @@ -28,17 +28,16 @@ const requestIdleCallback = ? false : performance.now() - start - relaxation > timeout; }, - timeRemaining: function () { - return Math.max(0, relaxation + (performance.now() - start)); - }, + timeRemaining: () => + Math.max(0, relaxation + (performance.now() - start)), }); }, relaxation); - }; + }); const cancelIdleCallback = window.cancelIdleCallback || - function (id: number) { + ((id: number) => { clearTimeout(id); - }; + }); export { requestIdleCallback, cancelIdleCallback }; diff --git a/packages/templates/src/utils/memoize.ts b/packages/templates/src/utils/memoize.ts index 4c6fd856cc08..f6f495e09d0a 100644 --- a/packages/templates/src/utils/memoize.ts +++ b/packages/templates/src/utils/memoize.ts @@ -20,7 +20,7 @@ export default function memoize( argsHash: ArgHash = (args) => args.join('-') ) { const memoized = new Map(); - return function (...args: K[]) { + return (...args: K[]) => { const key = argsHash(args); if (!memoized.has(key)) { const result = func(...args); diff --git a/packages/text-sets/src/loadTextSets.ts b/packages/text-sets/src/loadTextSets.ts index 4b67b121b8b1..7ce8878c1f5e 100644 --- a/packages/text-sets/src/loadTextSets.ts +++ b/packages/text-sets/src/loadTextSets.ts @@ -45,9 +45,9 @@ async function loadTextSet(name: string) { const migrated = migrate(data, data.version) as TextSetData; return migrated.pages.reduce((sets: TextSet[], page) => { const minMax = { - minX: Infinity, + minX: Number.POSITIVE_INFINITY, maxX: 0, - minY: Infinity, + minY: Number.POSITIVE_INFINITY, maxY: 0, }; diff --git a/packages/widget/src/index.js b/packages/widget/src/index.js index 2b1beca38f5b..c8c856e05d62 100644 --- a/packages/widget/src/index.js +++ b/packages/widget/src/index.js @@ -37,7 +37,7 @@ const fieldState = window.webStoriesData || {}; * @param {Object} target Event object. * @param {boolean} reset Flag to reset fields value. */ -const reactiveWidget = function (target, reset = false) { +const reactiveWidget = (target, reset = false) => { const currentView = target.value; const widget = target.closest('.widget'); const state = fieldState.fields[currentView]; @@ -80,7 +80,7 @@ const viewSelectors = () => /** * Bind event on view type selection change. */ -const bindEvent = function () { +const bindEvent = () => { const dropdowns = viewSelectors(); if (dropdowns.length) { @@ -95,7 +95,7 @@ const bindEvent = function () { /** * Fire event manually once. */ -const fireEvent = function () { +const fireEvent = () => { const dropdowns = viewSelectors(); const evt = document.createEvent('HTMLEvents'); evt.initEvent('change', false, true); diff --git a/packages/wp-dashboard/src/api/story.js b/packages/wp-dashboard/src/api/story.js index 612254677605..e4555e2796c8 100644 --- a/packages/wp-dashboard/src/api/story.js +++ b/packages/wp-dashboard/src/api/story.js @@ -72,7 +72,7 @@ export function fetchStories(config, queryParams) { return apiFetch({ path: addQueryArgs(config.api.stories, query), }).then(({ body: stories, headers }) => { - const totalPages = headers && parseInt(headers['X-WP-TotalPages']); + const totalPages = headers && Number.parseInt(headers['X-WP-TotalPages']); const totalStoriesByStatus = headers && JSON.parse(headers['X-WP-TotalByStatus']); diff --git a/packages/wp-story-editor/src/api/pageTemplate.js b/packages/wp-story-editor/src/api/pageTemplate.js index 0f1543ca8cb0..5b4145aa08ee 100644 --- a/packages/wp-story-editor/src/api/pageTemplate.js +++ b/packages/wp-story-editor/src/api/pageTemplate.js @@ -73,7 +73,7 @@ export function getCustomPageTemplates(config, page = 1, search) { _embed: TEMPLATE_EMBED, }); return apiFetch({ path }).then(({ headers, body }) => { - const totalPages = parseInt(headers['X-WP-TotalPages']); + const totalPages = Number.parseInt(headers['X-WP-TotalPages']); const templates = body.map(transformResponse); return { templates, diff --git a/packages/wp-story-editor/src/components/documentPane/publish/publish.js b/packages/wp-story-editor/src/components/documentPane/publish/publish.js index 8252c9068ae7..cd33948821e8 100644 --- a/packages/wp-story-editor/src/components/documentPane/publish/publish.js +++ b/packages/wp-story-editor/src/components/documentPane/publish/publish.js @@ -161,9 +161,7 @@ function PublishPanel({ nameOverride }) { const allowedImageFileTypes = useMemo( () => - allowedImageMimeTypes - .map((type) => getExtensionsFromMimeType(type)) - .flat(), + allowedImageMimeTypes.flatMap((type) => getExtensionsFromMimeType(type)), [allowedImageMimeTypes] ); @@ -275,23 +273,21 @@ function PublishPanel({ nameOverride }) { __('Please choose only %s as a poster.', 'web-stories') ); - const publisherLogoOptionRenderer = forwardRef( - ({ option: option, ...rest }, ref) => { - if (option.props) { - return option; - } - return ( - - - - ); + const publisherLogoOptionRenderer = forwardRef(({ option, ...rest }, ref) => { + if (option.props) { + return option; } - ); + return ( + + + + ); + }); const activeItemRenderer = () => { const displayText = publisherLogos.length ? __('Select logo', 'web-stories') diff --git a/packages/wp-story-editor/src/components/mediaUpload/mediaPicker/utils/calculateImageSelectOptions.js b/packages/wp-story-editor/src/components/mediaUpload/mediaPicker/utils/calculateImageSelectOptions.js index 7277488dfe64..620bf27791a7 100644 --- a/packages/wp-story-editor/src/components/mediaUpload/mediaPicker/utils/calculateImageSelectOptions.js +++ b/packages/wp-story-editor/src/components/mediaUpload/mediaPicker/utils/calculateImageSelectOptions.js @@ -26,12 +26,12 @@ const calculateImageSelectOptions = (attachment, controller) => { const control = controller.get('control'); - const flexWidth = Boolean(parseInt(control.params.flex_width)); - const flexHeight = Boolean(parseInt(control.params.flex_height)); + const flexWidth = Boolean(Number.parseInt(control.params.flex_width)); + const flexHeight = Boolean(Number.parseInt(control.params.flex_height)); const realWidth = attachment.get('width'); const realHeight = attachment.get('height'); - let xInit = parseInt(control.params.width); - let yInit = parseInt(control.params.height); + let xInit = Number.parseInt(control.params.width); + let yInit = Number.parseInt(control.params.height); const ratio = xInit / yInit; const xImg = xInit; const yImg = yInit;