Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESLint]: dependency-group rule doesn't work correctly #65440

Open
gigitux opened this issue Sep 18, 2024 · 0 comments · May be fixed by #69361
Open

[ESLint]: dependency-group rule doesn't work correctly #65440

gigitux opened this issue Sep 18, 2024 · 0 comments · May be fixed by #69361
Labels
[Status] In Progress Tracking issues with work in progress [Tool] ESLint plugin /packages/eslint-plugin [Type] Bug An existing feature does not function as intended

Comments

@gigitux
Copy link
Contributor

gigitux commented 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.

@gziolo gziolo added [Tool] ESLint plugin /packages/eslint-plugin [Type] Bug An existing feature does not function as intended labels Sep 21, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Tool] ESLint plugin /packages/eslint-plugin [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants