proposal: bin_files_must_export_main
#57130
Labels
analyzer-linter
Issues with the analyzer's support for the linter package
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
linter-lint-proposal
linter-status-pending
type-enhancement
A request for a change that isn't a bug
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: