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

JS-54 Add rule S7060 Modules should not import themselves #4810

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

saberduck
Copy link
Contributor

@saberduck saberduck commented Sep 10, 2024

Fix JS-54

@saberduck saberduck force-pushed the tibor/JS-54 branch 3 times, most recently from 36ee97b to 7fffc10 Compare September 11, 2024 10:22
@saberduck saberduck marked this pull request as ready for review September 11, 2024 10:22
@saberduck saberduck requested a review from a team September 11, 2024 10:22
return;
}
const { node } = reportDescriptor;
let suggestion: Rule.SuggestionReportDescriptor | undefined;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we could turn the suggestion variable into an array that we would initialize to an empty array? By doing so, we could

  • make it constant,
  • push to it a quick fix only if possible, and
  • avoid the ternary expression that conditionally injects the quickfix.

I am not entirely sure, but this should work since the suggest property of the report expects an array. We would report an empty array of suggestions if no quickfix applies.


// DO NOT EDIT! This file is autogenerated by "npm run generate-meta"

export const meta = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @victor-diez-sonarsource because I am not sure.

  • Since the rule provides a quickfix, should the rule metadata include the key-value fixable: 'code'?
  • Do we need to update the eslint-plugin README to include an entry for this new rule no-self-import? If yes, how?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Yes, it should. npm run generate-meta should put that field in the meta.ts file if the rspec contains the quickfix === 'covered' attribute. Link
  • Yes, that is part of also of the generate-meta script. You will see that it calls cd packages/jsts/src/rules && npm run eslint-docs, which updates the README file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -215,6 +215,7 @@ SonarJS rules for ESLint to help developers produce [Clean Code](https://www.son
| [no-same-argument-assert](https://sonarsource.github.io/rspec/#/rspec/S5863/javascript) | Assertions should not be given twice the same argument | ✅ | | | | | |
| [no-same-line-conditional](https://sonarsource.github.io/rspec/#/rspec/S3972/javascript) | Conditionals should start on new lines | ✅ | | 🔧 | 💡 | | |
| [no-self-compare](https://sonarsource.github.io/rspec/#/rspec/S6679/javascript) | "Number.isNaN()" should be used to check for "NaN" value | ✅ | | 🔧 | 💡 | | |
| [no-self-import](https://sonarsource.github.io/rspec/#/rspec/S7060/javascript) | Module should not import itself | ✅ | | | 💡 | | |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| [no-self-import](https://sonarsource.github.io/rspec/#/rspec/S7060/javascript) | Module should not import itself || | | 💡 | | |
| [no-self-import](https://sonarsource.github.io/rspec/#/rspec/S7060/javascript) | Module should not import itself || | 🔧 | 💡 | | |

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually not - this rule doesn't provide the fix , it's a bug in metadata generation

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
88.9% Coverage on New Code (required ≥ 90%)

See analysis details on SonarQube

@saberduck saberduck merged commit 7e6035f into master Sep 11, 2024
14 of 16 checks passed
@saberduck saberduck deleted the tibor/JS-54 branch September 11, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants