Open
Description
openedon Sep 18, 2024
During the review of #65289, @louwie17 noticed that the ESLint didn't catch some wrong imports order.
I'm able to replicate in other packages too.
/**
* WordPress dependencies
*/
import { SlotFillProvider } from '@wordpress/components';
import {
UnsavedChangesWarning,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { store as noticesStore } from '@wordpress/notices';
import { useDispatch } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
import { PluginArea } from '@wordpress/plugins';
/**
* Internal dependencies
*/
import Layout from '../layout';
import { unlock } from '../../lock-unlock';
import { useCommonCommands } from '../../hooks/commands/use-common-commands';
import { useEditModeCommands } from '../../hooks/commands/use-edit-mode-commands';
import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url';
import useLayoutAreas from '../layout/router';
import useSetCommandContext from '../../hooks/commands/use-set-command-context';
import { privateApis as routerPrivateApis } from '@wordpress/router';
With this list of imports, ESlint should catch the error (privateApis
should be above). You can replicate it moving the privateApis
import in this file.
I checked the unit test of the dependency-group rule
updating the valid case to this one:
valid: [
{
code: `
/**
* External dependencies
*/
import { camelCase } from 'change-case';
import clsx from 'clsx';;
/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
/**
* Internal dependencies
*/
import edit from './edit';
import { privateApis as routerPrivateApis } from '@wordpress/router';
`,
},
{
code: `
/**
* External dependencies
*/
const { camelCase } = require( 'change-case' );
const clsx = require( 'clsx' );
/**
* WordPress dependencies
*/
const { Component } = require( '@wordpress/element' );
/**
* Internal dependencies
*/
const edit = require( './edit' );`,
},
],
The unit test doesn't fail.
It looks like that the rule doesn't work correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment