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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const path = require( 'path' );
const fs = require( 'fs/promises' );
const os = require( 'os' );
const { v4: uuid } = require( 'uuid' );
const { randomUUID } = require( 'crypto' );

/**
* WordPress dependencies
Expand Down Expand Up @@ -69,7 +69,7 @@ class MediaProcessingUtils {
const tmpDirectory = await fs.mkdtemp(
path.join( os.tmpdir(), 'gutenberg-test-media-' )
);
const uniqueName = uuid();
const uniqueName = randomUUID();
const extension = path.extname( fileName );
const tmpFileName = path.join( tmpDirectory, uniqueName + extension );
await fs.copyFile( path.join( ASSETS_DIR, fileName ), tmpFileName );
Expand Down Expand Up @@ -402,7 +402,7 @@ test.describe( 'Client-side media processing', () => {
const tmpFiles = [];

for ( const file of files ) {
const uniqueName = uuid();
const uniqueName = randomUUID();
const ext = path.extname( file );
const tmpFile = path.join( tmpDirectory, uniqueName + ext );
await fs.copyFile( path.join( ASSETS_DIR, file ), tmpFile );
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/editor/various/gif-to-video.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const path = require( 'path' );
const fs = require( 'fs/promises' );
const os = require( 'os' );
const { v4: uuid } = require( 'uuid' );
const { randomUUID } = require( 'crypto' );

/**
* WordPress dependencies
Expand Down Expand Up @@ -55,7 +55,7 @@ class GifToVideoUtils {
const tmpDirectory = await fs.mkdtemp(
path.join( os.tmpdir(), 'gutenberg-test-gif-' )
);
const uniqueName = uuid();
const uniqueName = randomUUID();
const extension = path.extname( fileName );
const tmpFileName = path.join( tmpDirectory, uniqueName + extension );
await fs.copyFile( path.join( ASSETS_DIR, fileName ), tmpFileName );
Expand Down
6 changes: 3 additions & 3 deletions test/performance/specs/media-upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const path = require( 'path' );
const fs = require( 'fs/promises' );
const os = require( 'os' );
const { v4: uuid } = require( 'uuid' );
const { randomUUID } = require( 'crypto' );

/**
* WordPress dependencies
Expand Down Expand Up @@ -36,7 +36,7 @@ async function createTempImage( sourceFile, ext ) {
const tmpDirectory = await fs.mkdtemp(
path.join( os.tmpdir(), 'gutenberg-perf-media-' )
);
const tmpFileName = path.join( tmpDirectory, uuid() + ext );
const tmpFileName = path.join( tmpDirectory, randomUUID() + ext );
await fs.copyFile( path.join( E2E_ASSETS_PATH, sourceFile ), tmpFileName );
return { tmpFileName, tmpDirectory };
}
Expand Down Expand Up @@ -218,7 +218,7 @@ test.describe( 'Media Upload Performance', () => {
for ( let j = 0; j < 5; j++ ) {
const tmpFileName = path.join(
tmpDirectory,
uuid() + '.jpeg'
randomUUID() + '.jpeg'
);
await fs.copyFile(
path.join(
Expand Down
14 changes: 14 additions & 0 deletions tools/eslint/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,14 @@ export default dedupePlugins( [
rules: {
'@wordpress/no-global-active-element': 'off',
'@wordpress/no-global-get-selection': 'off',
'no-restricted-imports': [
'error',
{
name: 'uuid',
message:
'`uuid` is ESM-only and breaks `require()` call sites (see #77960). Use the built-in `crypto.randomUUID()` instead.',
},
],
'no-restricted-syntax': [
'error',
{
Expand All @@ -531,6 +539,12 @@ export default dedupePlugins( [
'CallExpression[callee.object.name="page"][callee.property.name="waitForTimeout"]',
message: 'Prefer page.locator instead.',
},
{
selector:
'CallExpression[callee.name="require"][arguments.0.value="uuid"]',
message:
'`uuid` is ESM-only and breaks `require()` call sites (see #77960). Use the built-in `crypto.randomUUID()` instead.',
},
],
'playwright/no-conditional-in-test': 'off',
// Playwright fixtures use `use()` which is not a React hook.
Expand Down
Loading