-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
feat(noExportedImports): add lint rule #3097
Conversation
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
819ff72
to
bdcbda9
Compare
CodSpeed Performance ReportMerging #3097 will not alter performanceComparing Summary
|
ce9d922
to
83565f9
Compare
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.
Looks good!
I have some use cases like this: import { A } from "mod";
// do something with A
export { A }; Does this rule allow it? What if I mutate |
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.
Would this rule go in conflict with the barrel file rule?
"An import should not be exported. Use "<Emphasis>"export from"</Emphasis>"instead." | ||
}, | ||
) | ||
.note(markup! { | ||
<Emphasis>"export from"</Emphasis>" makes it clearer that the intention is to re-export a variable." |
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.
Nit:
Based on our rule pillars, we usually do: error, explain the error, suggest a fix
You should swap the notes
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.
Swap the notes?
The first diagnostic is the error and the suggestion. The second is the explanation.
In an IDE settings it is sometimes confusing to only have the error without any suggestion or explanation.
I don't think so. |
Have you a more precise example? |
I was thinking something like this:
export const user = {
name: undefined,
};
import { user } from "./a.js";
user.name = "John";
export { user };
import { user } from "./b.js";
console.log(user); But it seems I can use |
Yes you can write: import { user } from "./a.js";
user.name = "John";
export { user } from "./a.js"; |
Sorry I didn't understand very well. I understood that the suggested fix could trigger |
Yes, this is expected. |
83565f9
to
1033263
Compare
1033263
to
413e850
Compare
Summary
Add a new exclusive rule for Biome.
The rule disallows exporting an imported variable and suggests using
export from
.This is an implementation I had done some time ago. I had intended to add a code fix before submitting a PR.
However, I now think that the rule is ok without a code ix.
Test Plan
I added some tests.