Files
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

67 lines
1.7 KiB
JavaScript

/**
* External dependencies
*/
const { sync: spawn } = require( 'cross-spawn' );
const { sync: resolveBin } = require( 'resolve-bin' );
/**
* Internal dependencies
*/
const {
fromConfigRoot,
getArgsFromCLI,
hasArgInCLI,
hasFileArgInCLI,
hasPackageProp,
hasProjectFile,
} = require( '../utils' );
const args = getArgsFromCLI();
const defaultFilesArgs = hasFileArgInCLI() ? [] : [ '.' ];
// See: https://eslint.org/docs/user-guide/configuring#using-configuration-files-1.
const hasLintConfig =
hasArgInCLI( '-c' ) ||
hasArgInCLI( '--config' ) ||
hasProjectFile( '.eslintrc.js' ) ||
hasProjectFile( '.eslintrc.json' ) ||
hasProjectFile( '.eslintrc.yaml' ) ||
hasProjectFile( '.eslintrc.yml' ) ||
hasProjectFile( 'eslintrc.config.js' ) ||
hasProjectFile( '.eslintrc' ) ||
hasPackageProp( 'eslintConfig' );
// When a configuration is not provided by the project, use from the default
// provided with the scripts module. Instruct ESLint to avoid discovering via
// the `--no-eslintrc` flag, as otherwise it will still merge with inherited.
const defaultConfigArgs = ! hasLintConfig
? [ '--no-eslintrc', '--config', fromConfigRoot( '.eslintrc.js' ) ]
: [];
// See: https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories.
const hasIgnoredFiles =
hasArgInCLI( '--ignore-path' ) || hasProjectFile( '.eslintignore' );
const defaultIgnoreArgs = ! hasIgnoredFiles
? [ '--ignore-path', fromConfigRoot( '.eslintignore' ) ]
: [];
const defaultExtArgs = hasArgInCLI( '--ext' )
? []
: [ '--ext', 'js,jsx,ts,tsx' ];
const result = spawn(
resolveBin( 'eslint' ),
[
...defaultConfigArgs,
...defaultIgnoreArgs,
...defaultExtArgs,
...args,
...defaultFilesArgs,
],
{ stdio: 'inherit' }
);
process.exit( result.status );