-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a bundler or package.json
exports to provide path exports (and modernize project)
#147
Comments
I think a mixture of those solutions is the best way to move forward. I doubt anyone is using the standalone version other than internally, so it can just be copied over into those internal plugins. Bumping |
This would make developing the plugin easier and also remove any peer dependency warnings/TypeScript complaints (considering |
For sure. Using tsup would also remove the need for having a separate I do have an idea that I think will strike a great balance here. What if we kept the concerns consolidated since the standalone linter is still relevant to the ESLint plugin, and just convert this into a monorepo with both One more suggestion that feels appropriate so as to avoid breaking things any more than is absolutely necessary. I have thought on things and perhaps keeping both ways of using the configs in place for now is prudent, just document both of them, and then later on down the road (once Solid is more prevalent) decide which system to keep at that time. |
Thanks for all your thought and effort in writing this up. Some context in why the package is structured this way: Standalone
ESLint (at least v8) claims that importing only its Furthermore, all of those custom build-time transformations can break any time Why not a monorepo then? It's chiefly because I want the README at the root to be the plugin's README, not just one for the workspace root, for a good experience visiting the repo. But if we can reasonably deal with that, converting to a monorepo would be great. ESM / "exports" / CJSUntil v9, ESLint has been a stick in the mud about ESM support. And upgrading to v9 is a challenge. So for as long as it's relatively feasible, I see no reason not to support version 8 and below (I run tests down to v6). I've written about why I want to support It's a little unclear to me whether switching to use It sounds like Other
Appreciate any thoughts on this. Thanks again! |
Converted to a monorepo in #150 🎉 |
Describe the need
So, as addressed (to some extent) in #137 and (for sure) in #146, the current setup for using the plugin is a bit confusing and a little obtuse. There are currently 2 ways to use the plugin (at least for ESLint 8/9), and neither is particularly great.
Obviously, the first way (I'll call the legacy way) is to import the plugin as shown below and call a flat config directly. This way of using the plugin seems to be discouraged though (despite working flawlessly....mostly), This is also the method that most plugin authors have settled on, since it requires basically no change to existing tooling.
Conversely, the recommended way to use the plugin doesn't work very well. If you include the
.js
extension that node requires to even load the module and not cause ESLint to error out, TypeScript will complain what is being imported is not a module and has no types. This is the exact issue that #146 is describing..js
extension (as shown in docs):.js
extension (required to make the code work, TypeScript now complains):The reason for this discrepancy is related to how modern node handles modules. If your project is a modules project (i.e.
"type": "module"
), then.js
extensions are required. It's complicated, but that's how things work now. Here's a page on the node docs if you want to read more. So why then is TypeScript complaining that what you just imported with that.js
extension is not a module...because it's not. If you open the source.js
file and look at it, it's not a module. It's CommonJS. Welcome to the wacky world of mixing ESModules and CommonJS.Additionally, there are some other...issues...with the codebase. First, the
.nvmrc
calls for Node version14.15.4
, which has long been deprecated, and isn't supported by ESLint, Solid, or PNPM anymore (I suspect nobody tested the repo withnvm --use-on-cd
). Officially, the lowest version of node supported by those 3 is18.18.x
. Next, there is still a peer dependency warning when installingeslint-plugin-solid
with ESLint 9 because the version of@typescript-eslint/utils
used (no harm there, the new version has only been out for 3 days). I'm not trying to be overly critical here, I'm just calling out all the issues I see, and DevOps is kind of my thing.Suggested Solution
From what I can tell, there are a few paths forward. I'm going to discuss what I think should happen here, and we can go from there (that's why I opened an issue and not a PR). I am willing to do all this work myself. I will walk through each change and explain why I think that's the best path forward. (NOTE: the changes I am going to suggest would normally result in a major version bump, but since this project is not
1.0
yet, it'll probably be a minor bump).nvmrc
to call for version18.20.4
@typescript-eslint/utils
to version 8packageManager
topackage.json
package.json
)prettier-plugin-pkg
(just a personal preference, but it keeps yourpackage.json
sorted in the "official" order specified on the NPM docs)Possible Alternatives
Technically, the standalone version could still exist, but shipping a patched version of ESLint seems like a bad idea. Additionally, I doubt it gets much use. In the same vain, it's technically possible to keep both forms of the flat configs, but it's probably best to pick one or the other and stick to it and most other plugins have settled on extending the existing plugin (I provide some examples in the additional context below). There is 1 notable exception I can think of...Prettier, but Prettier has kind of always done their own thing.
Additional context
Plugins that are adding flat configs to the plugin itself (while these are cherry picked, they are cherry picked in that these are some of the more popular ESLint plugins):
eslint-plugin-unicorn
eslint-plugin-jsdoc
eslint-plugin-tailwindcss
eslint-plugin-perfectionist
@stylistic/eslint-plugin
The text was updated successfully, but these errors were encountered: