fix(linter): detect process.env when process is imported from module#9216
Conversation
Extend noProcessEnv to also flag process.env when process is imported from "process" or "node:process", not just when it's a global. Closes biomejs#9061
🦋 Changeset detectedLatest commit: 6521f66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (6)
WalkthroughThis pull request extends the Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fixes #9061
noProcessEnvcurrently only flagsprocess.envwhenprocessis a global. If you import it from"process"or"node:process", the rule stays silent.The original ESLint rule has the same gap (eslint/eslint#12385) — their maintainers intended to catch imported
processtoo, but couldn't due to the limitations of ESLint's static analysis. Since biome's semantic model can distinguish where a binding comes from, we can handle it properly here.This checks the binding's import source when
processis bound, using the same pattern other rules already use (e.g.useQwikMethodUsage). Both"process"and"node:process"are covered, including namespace imports (import * as process). Imports from unrelated modules are left alone.Known limitations (follow-up work):
const process = require("process")— CommonJS require doesn't create aJsImportnode, so it won't be caught. Could be added separately.import { env } from "process"— Noprocess.envexpression exists in this case, so the rule's query type doesn't match it.