sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
276 stars 29 forks source link

ESM-only plugin #808

Open benmccann opened 2 days ago

benmccann commented 2 days ago

Description

You can now write eslint plugins in ESM. Their docs demonstrate it here: https://eslint.org/docs/latest/extend/plugins

This would be a nice code modernization. It would also potentially be helpful to the Svelte core project as one the big reasons we've had to distribute a CJS version of the Svelte compiler is to support the eslint plugin. Though the other reason we need it is for the REPL and I'm unsure if we can avoid it there.

I think this may only work in eslint 9, so the plugin would need to drop support for older versions.

ota-meshi commented 2 days ago

I hope to one day change this package and the parser package to ESM. But I'm not sure when that's going to be OK yet. If we make our packages to ESM, users will have to migrate to the flat config of ESLint and write them in ESM.

When do you think it will be OK for us to force our users to use a flat config? Do you think it's ok to ship the next major version soon and drop support for the old config?

I think this may only work in eslint 9, so the plugin would need to drop support for older versions.

ESLint v8 also has an experimental flat config available, so our package can be made into an ESM and still support ESLint v8. (However, I would recommend dropping support for all but the last versions of ESLint v8, as the older ones have more bugs in flat config.)

benmccann commented 2 days ago

create-svelte creates new projects with the flat config. I do think it would be nice to encourage users to switch to the new config format as it's a much nicer experience

I wonder if this plugin could detect if you're using the old config format and print a deprecation warning encouraging users to migrate? Then they'd get some extra notice. We could do that as a 2.42.0 and then do a 3.0.0 afterwards that drops support for the old config format

ota-meshi commented 2 days ago

Thank you for your opinion.

I wonder if this plugin could detect if you're using the old config format and print a deprecation warning encouraging users to migrate?

That's a good idea! I won't know until we try it, but I think it might be possible to warn about the old configuration getter.

Once that's done, I'd like to proceed with the migration to ESM.

If anyone can help us, I'm looking forward to PRs.