-
-
Notifications
You must be signed in to change notification settings - Fork 482
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(noUndeclaredDependencies): add availability restriction based on dependency type #4376
feat(noUndeclaredDependencies): add availability restriction based on dependency type #4376
Conversation
… dependency type Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
CodSpeed Performance ReportMerging #4376 will not alter performanceComparing Summary
|
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.
Nice work!
crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/tests/specs/correctness/noUndeclaredDependencies/invalid.js.snap
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs
Outdated
Show resolved
Hide resolved
Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
fc2424a
to
5c3bdc0
Compare
crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs
Outdated
Show resolved
Hide resolved
Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
@ematipico could you please take a look this (and merge if no problem) when you have time? No hurries, just a friendly reminder :) |
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.
Awesome work! ❤️ I left some suggestions for the docs, then we can merge it
crates/biome_js_analyze/src/lint/correctness/no_undeclared_dependencies.rs
Show resolved
Hide resolved
/// You can also use an array of globs instead of literal booleans: | ||
/// ```json | ||
/// { | ||
/// "options": { | ||
/// "devDependencies": ["**/*.test.js", "**/*.spec.js"] | ||
/// } | ||
/// } | ||
/// ``` | ||
/// | ||
/// When using an array of globs, the setting will be set to `true` (no errors reported) | ||
/// if the name of the file being linted (i.e. not the imported file/module) matches a single glob | ||
/// in the array, and `false` otherwise. |
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.
/// You can also use an array of globs instead of literal booleans: | |
/// ```json | |
/// { | |
/// "options": { | |
/// "devDependencies": ["**/*.test.js", "**/*.spec.js"] | |
/// } | |
/// } | |
/// ``` | |
/// | |
/// When using an array of globs, the setting will be set to `true` (no errors reported) | |
/// if the name of the file being linted (i.e. not the imported file/module) matches a single glob | |
/// in the array, and `false` otherwise. | |
/// You can also use an array of globs instead of literal booleans. | |
/// When using an array of globs, the setting will be set to `true` (no errors reported) | |
/// if the name of the file being checked (i.e. not the imported file/module) matches a single glob | |
/// in the array, and `false` otherwise. | |
/// | |
/// TODO: explain the example here | |
/// | |
/// ```json | |
/// { | |
/// "options": { | |
/// "devDependencies": ["tests/*.test.js", "tests/*.spec.js"] | |
/// } | |
/// } | |
/// ``` | |
/// | |
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 a TODO
at line 67. Usually, in our docs, we follow this pattern:
- explain the options
- explain the example
- show code of the example
The TODO
should explain the example of the code. Also, I removed **/
because it usually matches too much and replaced it with a more simple glob
…suggestion Co-authored-by: ematipico <my.burning@gmail.com> Signed-off-by: Naoki Ikeguchi <me@s6n.jp>
# Conflicts: # packages/@biomejs/backend-jsonrpc/src/workspace.ts
@ematipico Thank you for your suggestion! Applied in ba4e63d. (Also merged main resolving conflicts) |
Summary
This pull request adds dependency availability restriction based on their type and the file path.
For example, we don't want to allow imports from
vitest
outside the test suites:When this option is set, dependencies in
devDependencies
will be considered it's available only in**/*.test.ts
files.Inspired from import/no-extraneous-dependencies.
Test Plan
See added test snapshots.