Closed aruZeta closed 2 years ago
If one import does not fit in one line, it should be divided at convenience, but trying to make it not look very bad, for example:
This is prefered:
import
"."/[reallyLongName,
reallyReallyLongName,
reallyReallyReallyLongName]
To this:
import
"."/[reallyLongName, reallyReallyLongName,
reallyReallyReallyLongName]
Also, if the module to be imported can be separated by /
(like std/foo
or ".."/foo
) always put the modules imported, even if it's one, between []
, so:
import
std/[foo]
And not:
import
std/foo
Always separate the import
keyword and the imported modules by a new line, even if it's only one.
As can be seen from previous rules and examples, there can only be 1 import
statement in each module.
Imports should be ordered alphabetically, both the part before the /
and the items inside the []
. When ordering alphabetically, uppercase letters go before lowercase letters and .
goes before ..
which goes before any other alphabetical character:
import
".."/[A, a, B, b]
If importing a nimble package, pkg
should be used as a prefix, the same way as done with std
.
Check https://nim-lang.org/docs/manual.html#modules-pseudo-importslashinclude-paths.
Regarding exporting only the newline, ordering and only one statement per module rules should be followed while also, if possible, writing the fully qualified name of what's exported (exception being when exporting a whole module). Each exported symbol should be on a different line for better differentiation.
There are some messy imports around, and I would like to rewrite them all in the same way. I think this is the best approach, which I encountered while doing #14: