eslint-plugin-ssr-friendly icon indicating copy to clipboard operation
eslint-plugin-ssr-friendly copied to clipboard

[Feature request] A rule to disallow calling expressions in module scope

Open Finesse opened this issue 4 years ago • 0 comments

It will protect from:

Please note that we can't detect if you're still calling this function without properly checking upfront if typeof window !== "undefined".

Not allowed example

function myFunction() {
  // Doesn't matter what's inside
}

myFunction(); // Linting error

(() => { /* Doesn't matter what's inside */ })(); // Linting error

Allowed example

function myFunction() {
  // Doesn't matter what's inside
}

// The library user will call it
export { myFunction };

Finesse avatar Feb 08 '21 09:02 Finesse