Skip to content

prefer-global-this should ignore typeof window === 'undefined' #2468

@belgattitude

Description

@belgattitude

Hey thanks for the plugin, it's so useful !

I recently updated to v56 and was surprised about the autofix

It's very common to have

const isServer = typeof window === 'undefined';
const isBrowser = typeof window !== 'undefined'

It fixes to

const isServer = typeof globalThis === 'undefined';
const isBrowser = typeof globalThis !== 'undefined';

Which isn't valid

Interested to know your advices.

PS: Thanks to @fregant comment below: window' in globalThis

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions