Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Make the plugin work with the new eslint.config.js config format #403

Closed
acommodari opened this issue May 31, 2023 · 4 comments
Closed

Make the plugin work with the new eslint.config.js config format #403

acommodari opened this issue May 31, 2023 · 4 comments
Labels
jira-import_26-04-2024 The issue have been imported to Jira (26/04/2024): https://sonarsource.atlassian.net/browse/ESLINTJS

Comments

@acommodari
Copy link

acommodari commented May 31, 2023

I want to request a feature.

I would like for this plugin to work with the new flat config eslint.config.js file format that will become the default in eslint@9 and that I'm trying to currently use in [email protected]`

I want to report a bug.

Not sure if this is considered a bug since eslint mentioned that all plugins should work out of the box. Maybe this plugin is doing something non-standard?

Reproducer

// eslint.config.js
const js = require('@eslint/js');
const sonarjs = require('eslint-plugin-sonarjs');
const globals = require('globals');

module.exports = [
	{
		ignores: ['**/tests/coverage', '**/.serverless', '**/.esbuild'],
	},
	js.configs.recommended,
	sonarjs.configs.recommended,
	{
		files: ['./services/**/*.js', './packages/**/*.js', './libs/**/*.js', './jest.config.js', 'eslint.config.js'],
		languageOptions: {
			globals: {
				...globals.node,
			},
			ecmaVersion: 2022,
		},
		linterOptions: {
			noInlineConfig: true,
			reportUnusedDisableDirectives: true,
		},
		plugins: {
			sonarjs,
		},
		rules: {},
	},
];

Expected behavior

It should lint correctly however I get the following error message:

Oops! Something went wrong! :(

ESLint: 8.41.0

TypeError: Key "plugins": Key "0": Expected an object.
    at Object.validate (/Users/alessandro.commodari/ssense/dm-shipping/node_modules/eslint/lib/config/flat-config-schema.js:315:23)
    at ObjectSchema.validate (/Users/alessandro.commodari/ssense/dm-shipping/node_modules/@humanwhocodes/object-schema/src/object-schema.js:218:35)
    at /Users/alessandro.commodari/ssense/dm-shipping/node_modules/@humanwhocodes/object-schema/src/object-schema.js:171:18
    at Array.reduce (<anonymous>)
    at ObjectSchema.merge (/Users/alessandro.commodari/ssense/dm-shipping/node_modules/@humanwhocodes/object-schema/src/object-schema.js:169:24)
    at /Users/alessandro.commodari/ssense/dm-shipping/node_modules/@humanwhocodes/config-array/api.js:884:42
    at Array.reduce (<anonymous>)
    at FlatConfigArray.getConfig (/Users/alessandro.commodari/ssense/dm-shipping/node_modules/@humanwhocodes/config-array/api.js:883:39)
    at FlatConfigArray.isFileIgnored (/Users/alessandro.commodari/ssense/dm-shipping/node_modules/@humanwhocodes/config-array/api.js:911:15)
    at /Users/alessandro.commodari/ssense/dm-shipping/node_modules/eslint/lib/eslint/eslint-helpers.js:312:49

I want to provide the following feedback.

For more info on the new format you can look here: https://eslint.org/docs/latest/use/configure/configuration-files-new

Example

eslint-plugin-sonarjs version: 0.19.0

eslint version: 8.41.0

Node.js version: 18.16.0

Rule key:

@saberduck
Copy link
Contributor

Thanks for reporting, we will have a look at this. I also created a related issue in our Sonar plugin repo SonarSource/SonarJS#3968

@erickarnis-tb
Copy link

erickarnis-tb commented Aug 22, 2023

Hi, could you add a warning on your readme somewhere about this? It would save people from trying to debug their eslint.

@mploquin
Copy link

Hi,

I would also appreciate that this plugin work properly with the new flat config..

@Wohops Wohops added the jira-import_26-04-2024 The issue have been imported to Jira (26/04/2024): https://sonarsource.atlassian.net/browse/ESLINTJS label Apr 26, 2024
@Wohops
Copy link
Contributor

Wohops commented Apr 29, 2024

This issue has been migrated to Jira. ESLINTJS-25

@Wohops Wohops closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
jira-import_26-04-2024 The issue have been imported to Jira (26/04/2024): https://sonarsource.atlassian.net/browse/ESLINTJS
Projects
None yet
Development

No branches or pull requests

5 participants