Skip to content

ESLint configuration applies Node globals to browser-targeted JavaScript files #10023

@Abderrahmane-MERSTANI

Description

@Abderrahmane-MERSTANI

Description
The ESLint configuration applies globals.node to all *.js files.
This can cause incorrect linting results when some JavaScript files are intended to run in a browser environment, as Node-specific globals (e.g. process, Buffer) will be considered valid even where they should not be used.

Code concerned

{
files: ['*.js'],
languageOptions: {
globals: {
...globals.node,
},
},
},

Problems

Browser code may incorrectly pass linting

Environment intent (Node vs Browser) is unclear

Potential hidden runtime errors in browsers

Reduced linting accuracy

Expected Behavior

Node globals should only apply to server-side files

Browser files should use globals.browser

Clear separation of environments

Suggested Fix

{
files: ['.js'],
languageOptions: {
globals: {
...globals.browser,
},
},
},
{
files: ['scripts/**/
.js'],
languageOptions: {
globals: {
...globals.node,
},
},
},

Impact

More accurate linting

Clearer project structure

Fewer environment-related bugs

Better long-term maintainability

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions