Skip to content
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

Make config.yaml optional #286

Open
rrousselGit opened this issue Jul 16, 2024 · 7 comments
Open

Make config.yaml optional #286

rrousselGit opened this issue Jul 16, 2024 · 7 comments

Comments

@rrousselGit
Copy link

Hello!

I was working on a tool that needs plugins (custom_lint) and considered using extension_discovery. But in my case, the config.yaml is useless, as plugins will provide separate files inside (a lib/main.dart).
Asking my users to specify a non-empty config.yaml just for the sake of it feels wrong.

Could we make it optional?
The presence of that extension/<name> folder appears to be enough to detect plugins.

@rrousselGit
Copy link
Author

I'm open to making a PR for this. It appears straightforward.

@devoncarew
Copy link
Member

devoncarew commented Jul 17, 2024

cc @kenzieschmoll, @jonasfj

@jonasfj
Copy link
Member

jonasfj commented Jul 17, 2024

I would suggest not doing this.

The code in package:extension_discovery relies quite a bit on modification timestamps in order to do things fast. Especially, if you have path-dependencies which are mutable, meaning it's not enough to check the timestamp of package_config.json (against the cache file).

I'd suggest that an empty config.yaml isn't the worst thing we could do.


How about finding something to use config.yaml for? 🤣 🙈 🤣
(yes, that sounds a little bit stupid, hehe)

But it's kind of likely that in some future you'll find a need for it.

If a package includes more than one lint rule, then maybe it'd be nice if those are declared in a config.yaml. Ideally, custom_lint could avoid loading lints that aren't enabled.

Or maybe, you decide that custom lints should implement a different interface, or they should put the lint implementation in lib/src/custom_lint.dart instead of lib/main.dart, or whatever.

If you decide to make such a change you'd have to make a breaking change. Unless, you add a version number in config.yaml, then custom_lint could be made such that it can load both the new style lints and the old style lints.

Of course, that might not be super relevant to you right now, because breaking changes probably happen relatively frequently due to the package:analyzer dependency.

@jonasfj
Copy link
Member

jonasfj commented Jul 17, 2024

also, checking empty folders into git can be a bit less fun. So you might end up with a different empty file (like a .gitkeep file).

Until recently pub publish also had an issue with empty folders, I think we've fixed that, but it might not be in stable until Dart 3.5

@jonasfj
Copy link
Member

jonasfj commented Jul 17, 2024

Actually, in your case, if config.yaml listed all the rules that a lint-package provides, then it'd possible to make a command that can quickly list all the custom lint rules you can enable.

Loading all the custom lints just to print out what the names of the rules are is probably a bit slow.

@rrousselGit
Copy link
Author

Actually, in your case, if config.yaml listed all the rules that a lint-package provides, then it'd possible to make a command that can quickly list all the custom lint rules you can enable.

That's redundant. I can list lint rules and configure them without such a file.
I truly have no use for the file.
The only thing this file would do for me is make things worse for package authors by requiring extra steps.

I'd suggest that an empty config.yaml isn't the worst thing we could do.

An empty file doesn't work ;)
Due to how the package filters "null" configs (and an empty file will be parsed as null), the config file has to be non-empty

also, checking empty folders into git can be a bit less fun. So you might end up with a different empty file (like a .gitkeep file).

Sure but the directory is bound to have something it is. Otherwise what's the point of the plugin?
It's just that the config.yaml is useless in our case.

@jonasfj
Copy link
Member

jonasfj commented Jul 17, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants