eslint / eslintrc

The legacy ESLintRC config file format for ESLint
MIT License
119 stars 43 forks source link

Unable to use `plugin:es/restrict-to-es2019` #172

Open seahindeniz opened 2 hours ago

seahindeniz commented 2 hours ago

Hi, I'm trying to use https://eslint-plugin-es.mysticatea.dev/ in a project and I'm not sure how to implement it. The problem is, library suggests to use es/restrict-to-es2019 as plugin

const compat = new FlatCompat({
  baseDirectory: dirname(fileURLToPath(import.meta.url)),
});

compat.plugins('import', '@stylistic', '@cspell', 'es/restrict-to-es2019')

and when I do, ESLint throws the following error

eslint . --quiet

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-es/restrict-to-es2019".

(The package "eslint-plugin-es/restrict-to-es2019" was not found when loaded as a Node module from the directory "C:\Users\Sahin\projects\project1\config\eslint".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:        

    npm install eslint-plugin-es/restrict-to-es2019@latest --save-dev

The plugin "eslint-plugin-es/restrict-to-es2019" was referenced from the config file in "".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
seahindeniz commented 2 hours ago

🤦🏻 I think found a solution:

compat.plugins('import', '@stylistic', '@cspell', 'es')
compat.config({
  extends: ['plugin:es/restrict-to-es2019']
})

This wasn't documented anywhere, so it is kind of confusing, actually. I wish the plugin parser could work respectively to / delimited plugins

voxpelli commented 1 hour ago

Use the maintained fork of the plugin instead: https://github.com/eslint-community/eslint-plugin-es-x

mdjermanovic commented 7 minutes ago

🤦🏻 I think found a solution:

compat.plugins('import', '@stylistic', '@cspell', 'es') compat.config({ extends: ['plugin:es/restrict-to-es2019'] }) This wasn't documented anywhere, so it is kind of confusing, actually. I wish the plugin parser could work respectively to / delimited plugins

That's correct. 'plugin:es/restrict-to-es2019' is a config specifier. As stated in the plugin's docs, it should be used in extends in eslintrc config files, thus with compat.extends() in eslint.config.js files.

I prepared a PR to update the docs with an example: https://github.com/eslint/eslintrc/pull/173