-
-
Notifications
You must be signed in to change notification settings - Fork 53
fix(extensions): always calculate fix
option
#393
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
Conversation
🦋 Changeset detectedLatest commit: bd5a7b5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe test suite for the 'extensions' ESLint rule was updated by adding four new invalid test cases. These cases focus on verifying the rule's autofix behavior regarding '.js' file extensions in import statements, under various configurations of the Changes
Sequence Diagram(s)sequenceDiagram
participant TestRunner
participant ExtensionsRule
TestRunner->>ExtensionsRule: Run with 'never' and various fix options
ExtensionsRule-->>TestRunner: Detects '.js' extension in import
alt fix enabled (default/true)
ExtensionsRule-->>TestRunner: Returns autofixed import (extension removed)
else fix false
ExtensionsRule-->>TestRunner: Returns suggestion, no autofix
end
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. Possibly related PRs
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (21)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed everything up to d51f400 in 1 minute and 20 seconds. Click for details.
- Reviewed
78
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
4
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. test/rules/extensions.spec.ts:177
- Draft comment:
Good test: 'extensions should autofix by default' clearly checks that the autofix output is applied without an explicit fix option. Consider adding an inline comment referencing issue #391. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%
<= threshold50%
The comment is purely informative, acknowledging a good test and suggesting an inline comment for reference. It doesn't provide a specific code suggestion or highlight a potential issue.
2. test/rules/extensions.spec.ts:190
- Draft comment:
The 'fix: true' test is clear and repeats the expected behavior. In future, consider consolidating similar cases to reduce duplication. - Reason this comment was not posted:
Comment looked like it was already resolved.
3. test/rules/extensions.spec.ts:204
- Draft comment:
This test confirms that adding an empty pattern object with fix: true behaves like the basic case. The explicit nature of this test is good for future maintenance. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%
<= threshold50%
This comment is purely informative, as it describes what the test does and praises its explicit nature. It doesn't provide any actionable feedback or suggestions for improvement.
4. test/rules/extensions.spec.ts:218
- Draft comment:
The test for 'extensions should not autofix when fix is set to false' correctly checks that autofix is suppressed and suggestions are provided instead. This use of suggestions is clear and appropriate. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =0%
<= threshold50%
This comment is purely informative, as it simply states that the test is correct and appropriate. It does not provide any actionable feedback or suggestions for improvement.
Workflow ID: wflow_tVc2kLeFJtemCPAM
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Follow-up to un-ts#391 These tests demonstrate that the `import-x/extensions` rule only applies autofixes when both `fix: true` and a `pattern` object are set—even if the pattern is empty. This behavior is unintuitive, undocumented, and inconsistent with how autofix typically works in ESLint. The tests assert on the `output` field to document the current (broken) behavior and provide a basis for resolving the issue. In addition to fixing the logic, I recommend removing the `fix` option entirely, as it is undocumented and not used in any other rule in the plugin.
9c2f168
to
42b062f
Compare
fix
option
Signed-off-by: JounQin <admin@1stg.me>
commit: |
close #391
Initially, it only adds failing test cases that expose the broken autofix behavior of the
extensions
rule.Root issue
Autofix does not work unless both
fix: true
and apattern
object are set — even if the pattern is empty. This behavior is not intuitive, not documented, and not consistent with how autofix works in other ESLint rules.Suggested solution
The rule should apply autofixes by default when it is safe to do so. The
fix
option should be removed entirely.This PR starts by adding tests to document the current (broken) behavior.
Notes
extensions.spec.ts
, but none of the existing tests asserted on the actualoutput
field, which is what validates whether autofixes are being applied. That gap likely contributed to this issue being missed.Important
Add failing tests in
extensions.spec.ts
to expose broken autofix behavior ofextensions
rule requiring bothfix: true
and apattern
object.extensions.spec.ts
to expose broken autofix behavior ofextensions
rule.fix: true
and apattern
object, even if empty, to work.fix: true
,fix: true
with pattern, andfix: false
.This description was created by
for d51f400. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit