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

transformer: add style guide for import order #6637

Closed
Dunqing opened this issue Oct 17, 2024 · 6 comments
Closed

transformer: add style guide for import order #6637

Dunqing opened this issue Oct 17, 2024 · 6 comments
Assignees
Labels
A-transformer Area - Transformer / Transpiler C-docs Category - Documentation. Related to user-facing or internal documentation

Comments

@Dunqing
Copy link
Member

Dunqing commented Oct 17, 2024

As #6582 does, we can write the import order style guide here. This way can help contributors how write transformer plugins that conform to our style.

## Style guide for implementing transforms

@Dunqing Dunqing added A-transformer Area - Transformer / Transpiler C-docs Category - Documentation. Related to user-facing or internal documentation labels Oct 17, 2024
@overlookmotel
Copy link
Contributor

Personally, I think it'd be ideal if we used this same import order convention in all crates, not just transformer.

So we'd need a universal "style guide". Where would that go? https://oxc.rs/docs/contribute/rules.html?

Or, even better, can we do it automatically with rustfmt/clippy/autofix action?

@Dunqing
Copy link
Member Author

Dunqing commented Oct 17, 2024

Or, even better, can we do it automatically with rustfmt/clippy/autofix action?

Yes, please! I can't remember this order.

@overlookmotel
Copy link
Contributor

That was a question, not a statement! I don't know if any of these tools support doing that.

@overlookmotel
Copy link
Contributor

Thanks @camc314. group_imports with StdExternalCrate option gives us some of what we want, and would be an improvement. But:

  1. It's unstable. Do we run rustfmt in nightly mode?
  2. It wouldn't enforce oxc_* crates being grouped together after external crates.

@Boshen
Copy link
Member

Boshen commented Oct 21, 2024

Don't worry too much about the import order. I occassionaly run cargo fmt in nightly with the nightly options

oxc/.rustfmt.toml

Lines 8 to 16 in 6ffdcc0

# All unstable features that we wish for
# unstable_features = true
# version = "Two"
# Provide a cleaner impl order
# reorder_impl_items = true
# Provide a cleaner import sort order
# group_imports = "StdExternalCrate"
# Group "use" statements by crate
# imports_granularity = "Crate"

@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transformer Area - Transformer / Transpiler C-docs Category - Documentation. Related to user-facing or internal documentation
Projects
None yet
Development

No branches or pull requests

4 participants