-
Notifications
You must be signed in to change notification settings - Fork 172
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
proposal: bin_files_must_export_main
#4999
Comments
I love this! Definitely missing. One question: what about files in Anyways, we don't need an official policy for how to split up |
Sidenote: the |
I think it's fine if we focus on files in Though, people really should put their binary implementation files in I suppose it's possible to put files in Side note: Files in |
Somewhat related, I propsoed a validator for But I think this shouldn't look inside the files to see if there is a Actually, on that topic: I think we should consider making |
bin_files_must_export_main
Could also be called:
no_libraries_in_bin
executable_without_main
Description
Dart files in
bin/
should export amain
function that can serve as entrypoint for an executable.Details
Files in the
bin/
folder can be executed usingdart run
in your package, or any package that has a dependency on your package. Private scripts should be placed intool/
and private libraries should be placed inlib/src/
.See package layout conventions.
Kind
This aims to guard against errors.
Bad Examples
Good Examples
or
Discussion
dart run foo
will runbin/foo.dart
frompackage:foo
(requires thatpackage :foo
is either a dependency or the name of the root package).dart run foo:bar
will runbin/bar.dart
frompackage:foo
.dart pub global run foo
will runbin/foo.dart
frompackage:foo
.executables
section inpubspec.yaml
offers the creation of binstubs for files inbin/
.bin/
ashas:executable
.It could be argued that this lint should only be enabled for packages that have a
version
and doesn't featurepublish_to: none
in thepubspec.yaml
.Though, there is no reason for other packages / apps to put libraries in
bin/
, this folder should be reserved for executables.Motiviation
has:executable
search tag on pub.devbin/
.cc @sigurdm, @isoos
The text was updated successfully, but these errors were encountered: