Commit 51e5b61
authored
Auto-format imports using
Part of #155
This is going to be a fun one 😆
I've pushed two preview commits: the first one imports using the `Crate`
granularity, the other one with `Module` granularity.
Disclaimer: I'm biased 😃 I've used this style since I started
using Rust and it's also being used by vast majority of projects in the
ecosystem that I've used or looked at; it's also used by the Rust
compiler, Cargo and the tools like Rustfmt or Clippy.
Here's a summary of the possible options:
rust-lang/rustfmt#3362.
Here is an RFC discussion about setting on a variant:
rust-lang/style-team#140, I highly recommend
reading it.
To give a brief summary, it seems that people stand behind two options:
- `Module` - good trade-off between readability and conciseness
- `Item` - minimizes conflicts when many people edit the same files
often
To bring back some of the arguments raised in favor of the `Module` and
explain some of my reasoning as well:
- it naturally settles on the module as the, well, module/boundary from
which items can be imported...
- thus, helps build the intuition how to use and structure Rust crates
- less verbose than Java-style (`Item`) imports, which can often explode
and take unreasonable amount of space (and we don't really benefit
enough from minimized conflicts as we probably won't be a team of 50 or
the like)...
- but repeats enough information to quickly trace a module path rather
than having to reconstruct the paths from the `crate`-style use import
tree...
- and already often takes less space in our case, line-wise;
- quite good `grep`pabilityModule granularity (#702)1 parent 1e3ef7a commit 51e5b61
File tree
180 files changed
+665
-800
lines changed- .vscode
- crates
- codegen
- ebnf/src
- grammar/src
- language
- definition/src
- compiler
- analysis
- internals/parse_input_tokens
- model
- utils
- internal_macros/src
- derive
- parser
- generator/src
- runtime/src
- napi
- support
- templates
- schema/src
- types
- validation
- rules
- definitions
- keywords
- operators
- productions
- versions
- lints
- references
- visitors
- yaml
- spec/src
- testing/src
- infra
- cli
- src
- commands
- check
- ci
- lint
- publish
- cargo
- changesets
- github_release
- lock_files
- npm
- run
- setup
- cargo
- npm
- pipenv
- test
- watch
- toolchains
- mkdocs
- napi
- utils/src
- cargo
- codegen
- common
- commands
- errors
- github
- paths
- solidity
- inputs/language
- src
- outputs
- cargo
- build/src
- crate
- src
- generated
- napi
- support
- tests/src
- cst_output
- doc_examples
- scanner
- npm
- build/src
- crate
- src/generated
- napi
- support
- testing
- sanctuary/src
- datasets
- solc/src/utils
- utils/src
- cst_snapshots
- node_extensions
- version_pragmas
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
180 files changed
+665
-800
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 4 | + | |
| 5 | + | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
11 | 7 | | |
12 | 8 | | |
13 | 9 | | |
| |||
Lines changed: 6 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
| |||
0 commit comments