oxc icon indicating copy to clipboard operation
oxc copied to clipboard

feat(linter): create the import/order rule

Open Spoutnik97 opened this issue 1 year ago β€’ 16 comments

all cases are not covered bu the architecture is setup

Spoutnik97 avatar Dec 14 '24 23:12 Spoutnik97

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

graphite-app[bot] avatar Dec 14 '24 23:12 graphite-app[bot]

CodSpeed Instrumentation Performance Report

Merging #7903 will not alter performance

Comparing Spoutnik97:linter/order (62f2753) with main (d936024)

Summary

βœ… 34 untouched benchmarks

codspeed-hq[bot] avatar Dec 14 '24 23:12 codspeed-hq[bot]

@Spoutnik97 thanks for the work πŸ‘

It feels like you are going to the trouble of making your own file with tests. Please have a look how to setup a new rule: https://oxc.rs/docs/contribute/linter/adding-rules.html

The just commands looks to be outdatedπŸ™ƒ . The listed commands can also be found here: https://github.com/oxc-project/oxc/blob/main/justfile#L159-L199

Sysix avatar Dec 15 '24 20:12 Sysix

@Sysix oh great! Indeed I didn't know this refreshed list

Spoutnik97 avatar Dec 15 '24 22:12 Spoutnik97

https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md

@Boshen yes indeed, this is for this rule

It seems that differences are you cannot customize the order/groups with biomejs

Spoutnik97 avatar Dec 16 '24 20:12 Spoutnik97

We've also got https://github.com/oxc-project/oxc/discussions/7197 which we were considering implementing

I would suggest we perhaps make an issue for this with one rule (maybe oxc) to cover all/most cases? my reasoning for this is that we don't really want two rules doing almost the same thing

We cam probable remove a few of the config options from eslint-plugin-import to help it get shipped quicker and to avoid having to support incredibly complex configrations

camc314 avatar Dec 16 '24 22:12 camc314

I just improved the rule by covering more use cases. Indeed, it would be better to don't have duplicate rule effects I fixed tests and move to the right folders

Spoutnik97 avatar Dec 16 '24 23:12 Spoutnik97

Performances issues are fixed. All checks passed

Spoutnik97 avatar Dec 25 '24 14:12 Spoutnik97

Hello βœ‹ we updated the tests for rules in this PR: https://github.com/oxc-project/oxc/pull/8353 Could you please rebase/merge your PR with main foir the needed changes? πŸ™Œ?

Sysix avatar Jan 09 '25 03:01 Sysix

Hi @Sysix ! It's done βœ…

Spoutnik97 avatar Jan 09 '25 21:01 Spoutnik97

Hi @Sysix and @Boshen !

How could I help you to accelerate the merge of this PR?

It's one of the rule I need to fully migrate to oxlint.

I will improve my ci from 56sec to 9 sec ! (x5 per day)

Spoutnik97 avatar Jan 13 '25 20:01 Spoutnik97

Hello @Spoutnik97

I do not feel comfortable when the test generation from just new-import-rule is failing :/ The rules have more options and more test cases too pass. I do not expect it pass it 100% in this PR. Still I would like to have the test cases in the code, ready to be enabled.

And your configuration file test cases are wrong. You need to pass a js array like the auto generated tests here: https://github.com/oxc-project/oxc/blob/52bd0b1004b376c76cb0d808b2cc45930a4bb3d0/crates/oxc_linter/src/rules/eslint/new_cap.rs#L694

PS: I am currently not the person to request :) I just look around and try to help where I can

Sysix avatar Jan 15 '25 22:01 Sysix

Hello @Spoutnik97 Is this job going on? this rule is very useful to many developers, i will be exciting if this PR is merged (πŸ‘

huangtiandi1999 avatar Mar 13 '25 06:03 huangtiandi1999

Yes it is , but I don't have a lot of time the last weeks.

I am reshaping the rule according to the official eslint tests I writed manually.

My code pass the main tests, but there is still some work to be done

Spoutnik97 avatar Mar 13 '25 06:03 Spoutnik97

Converted to draft. Please let us know when PR is ready for review.

Boshen avatar Mar 24 '25 01:03 Boshen

@Boshen a first version is ready to review. Not all config is implemented, but dozens of eslint tests pass, so I think it could be a good start for the next steps. let me know if it seems right for you

Spoutnik97 avatar Apr 25 '25 22:04 Spoutnik97

@camc314 maybe ?

Spoutnik97 avatar Jun 03 '25 19:06 Spoutnik97

Hi, the PR sims to be intact for 3 weeks. Are there any plans to move it from draft to open PR in a short future? Is any help required? @Spoutnik97

vladimir-kuba avatar Jun 24 '25 13:06 vladimir-kuba

@vladimir-kuba I did the job and I am waiting for a reviewer. I don't know if I have the permissions to change the draft label

Spoutnik97 avatar Jun 26 '25 19:06 Spoutnik97

@Spoutnik97 can you resolve the conflicts? :)

Sysix avatar Jun 26 '25 21:06 Sysix

@Spoutnik97 thanks for the reply! I see no settings implemented in the PR. even though the import/internal-regex and import/external-module-folders are mentioned in the How Imports Are Grouped docs.

Is it reasonable to implement the settings in the PR or in a separate one?

vladimir-kuba avatar Jun 29 '25 14:06 vladimir-kuba

@vladimir-kuba I'm not sure about what you mean. In the crates/oxc_linter/src/rules/import/order.rs file, there is a configuration parser to get the specified settings for this rule

Spoutnik97 avatar Jul 14 '25 18:07 Spoutnik97

@Sysix done βœ… !

Spoutnik97 avatar Jul 21 '25 21:07 Spoutnik97

@Sysix or @camc314 I don't understand why the Test Linux CI failed on tests I didn't modified. Why does it failed on linux and now macos or windows ?

Spoutnik97 avatar Jul 22 '25 07:07 Spoutnik97

We address import order properly in the formatter.

Boshen avatar Aug 26 '25 02:08 Boshen