getify / eslint-plugin-proper-arrows

ESLint rules to ensure proper arrow function definitions
MIT License
305 stars 14 forks source link

`where` rule global option detects passing arrow as callback on module level as violation #32

Closed Guria closed 4 years ago

Guria commented 4 years ago

Given code

const App = React.lazy(() => import('./SomeComponent'));

with config

    "@getify/proper-arrows/where": [
      "error",
      { global: true, property: false, export: true, trivial: false },
    ],

causes violation reported: Arrow function not allowed in global/top-level-module scopeeslint(@getify/proper-arrows/where)

Guria commented 4 years ago
const routes = {
  RELOAD: { thunk: () => window.location.reload() },
}

This also violates global option with above config, even though property option is allowed

getify commented 4 years ago

That's working as intended: those are both "global"-scope arrow functions, which is to say they derive their "lexical this" binding from that global scope.

Guria commented 4 years ago

Ok, thank you for your feedback