Skip to content

💅noDelete suggest assigning undefined instead of delete for process.env vars #4093

Open
@robrat

Description

@robrat

Environment information

Assigning undefined to process.env vars does not work since it will be converted to a string ('undefined'):

$ node
Welcome to Node.js v20.17.0.
Type ".help" for more information.
> process.env.FOO
undefined
> process.env.FOO = 'bar'
'bar'
> process.env.FOO = undefined
undefined
> typeof process.env.FOO
'string'
> delete process.env.FOO
true
> typeof process.env.FOO
'undefined'

See https://nodejs.org/docs/latest-v20.x/api/process.html#processenv for additional details. It also states "Use delete to delete a property from process.env." Please also note that an assignment of undefined is deprecated and future versions will throw an error.

Rule name

lint/performance/noDelete

Playground link

https://biomejs.dev/playground/?code=ZABlAGwAZQB0AGUAIABwAHIAbwBjAGUAcwBzAC4AZQBuAHYALgBGAE8ATwA7AA%3D%3D

Expected result

The rule should not suggest assigning undefined to process.env vars, but instead an assignment of undefined should be reported as error.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-LinterArea: linterL-JavaScriptLanguage: JavaScript and super languagesS-EnhancementStatus: Improve an existing featureS-Help-wantedStatus: you're familiar with the code base and want to help the projectgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions