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

💅 Improve nursery/noNodejsModules detection (ignore type only imports and apply it only on use-client directives) #1674

Closed
1 task done
kevinwolfcr opened this issue Jan 25, 2024 · 3 comments · Fixed by #3674
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@kevinwolfcr
Copy link
Contributor

Environment information

CLI:
  Version:                      1.5.3
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.10.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.0.20"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Workspace:
  Open Documents:               0

Rule name

nursery/noNodejsModules

Playground link

https://biomejs.dev/playground/?lintRules=all&code=aQBtAHAAbwByAHQAIAB0AHkAcABlACAAewAgAEEAcwB5AG4AYwBMAG8AYwBhAGwAUwB0AG8AcgBhAGcAZQAgAH0AIABmAHIAbwBtACAAIgBuAG8AZABlADoAYQBzAHkAbgBjAF8AaABvAG8AawBzACIAOwAKAAoAZQB4AHAAbwByAHQAIAB0AHkAcABlACAAVABlAHMAdAAgAD0AIABBAHMAeQBuAGMATABvAGMAYQBsAFMAdABvAHIAYQBnAGUA

Expected result

  1. On the attached link, I am only importing a type from a Node module, should it report?
  2. A good option to make sure the file includes client-only code is to check if the use client directive is being used.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Conaclos Conaclos added S-Enhancement Status: Improve an existing feature A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Jan 25, 2024
@ematipico ematipico added the S-Help-wanted Status: you're familiar with the code base and want to help the project label Jan 26, 2024
@anonrig
Copy link
Contributor

anonrig commented Feb 21, 2024

Makes sense to me. I'll update the implementation.

@Conaclos
Copy link
Member

A good option to make sure the file includes client-only code is to check if the use client directive is being used.

Should we check this? If we check that we could make the rule recommended?

@ematipico
Copy link
Member

A good option to make sure the file includes client-only code is to check if the use client directive is being used.

Should we check this? If we check that we could make the rule recommended?

Nowadays it isn't about client anymore, but runtime too. Some code doesn't necessarily run on a client, but it could run on Deno, Bun, Cloudflare workers and more. So no, we can't rely on a directive, and we can't make the rule recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants