-
Notifications
You must be signed in to change notification settings - Fork 656
feat(rome_js_analyze): new lint rule: useImportRestrictions
#4700
Conversation
❌ Deploy Preview for docs-rometools failed.Built without sensitive environment variables
|
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.
I left some suggestions around:
- documentation
- implementation
Documentation: it should be more beginner-friendly
Implementation: using PathBuf
add complexity that we don't need. I believe working with strings is a more suitable approach where we don't need to deal with OS specific stuff.
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
I think all the PR issues have been addressed, just need to know what to do with the |
Nothing, that's the tool doing its job. Thank you! |
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.
A couple of suggestions, and then we can merge!
crates/rome_js_analyze/tests/specs/nursery/useImportRestrictions/validPackagePrivateImports.js
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/use_import_restrictions.rs
Outdated
Show resolved
Hide resolved
|
||
const INDEX_BASENAMES: &[&str] = &["index", "mod"]; | ||
|
||
const SOURCE_EXTENSIONS: &[&str] = &["js", "ts", "cjs", "cts", "mjs", "mts", "jsx", "tsx"]; |
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.
Should we consider .d.ts
too? Genuine question, I don't know it :)
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.
I don't think it makes sense to be honest, since you can't import "some_file.d.ts"
.
All done 👍 |
Summary
This PR implements the initial version of the new
useImportRestrictions
as discussed in #4678I think I have taken all the feedback from the previous PR into account now.
Test Plan
Tests are included in the PR.