Skip to content

[eslint] Config (unnamed): Unexpected key "0" found. #273

@daniel-stoian-lgp

Description

@daniel-stoian-lgp

Bug report

Hello,
After migrating to eslint 9 with flat config, the Eslint webpack plugin throws the following error:
[eslint] Config (unnamed): Unexpected key "0" found.

Actual Behavior

[eslint] Config (unnamed): Unexpected key "0" found.

Expected Behavior

No error should be shown

How Do We Reproduce?

Former configuration for eslintrc

		new ESLintPlugin({
			// Plugin options
			extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
			formatter: require.resolve('react-dev-utils/eslintFormatter'),
			eslintPath: require.resolve('eslint'),
			// ESLint class options
			resolvePluginsRelativeTo: __dirname,
			// @remove-on-eject-begin
			baseConfig: {
				extends: [require.resolve('eslint-config-enact/index.js')],
				rules: {
					...(!hasJsxRuntime && {
						'react/jsx-uses-react': 'warn',
						'react/react-in-jsx-scope': 'warn'
					})
				}
			},
			useEslintrc: false,
			// @remove-on-eject-end
			cache: true
		})

Current config for flat config:

		const eslintConfig = require('eslint-config-enact/index.js');

		new ESLintPlugin({
			// Plugin options
			configType: 'flat',
			extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
			formatter: require.resolve('react-dev-utils/eslintFormatter'),
			eslintPath: require.resolve('eslint'),
			// @remove-on-eject-begin
			baseConfig: [{
				...eslintConfig,
				rules: {
					...(!hasJsxRuntime && {
						'react/jsx-uses-react': 'warn',
						'react/react-in-jsx-scope': 'warn'
					})
				}
			}],
			overrideConfigFile: true,
			// @remove-on-eject-end
			cache: true
		})

The index.js looks like this:

	const eslint = require('@eslint/js');

	module.exports = [
		eslint.configs.recommended,
		{
			ignores: [
				'**/node_modules/',
				'**/node_modules/*',
				'**/build/',
				'**/build/*'
			]
		}
	];

I checked the API reference and the configuration should work https://eslint.org/docs/latest/integrate/nodejs-api#-new-eslintoptions . The configuration is pretty basic, it only reuses eslint recommended rules and ignores certain paths.

Eslint command using the above configuration works well. No errors.
When I try to build an app with webpack, I get the error mentioned in the description.

Please paste the results of npx webpack-cli info here, and mention other relevant information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions