neuroanatomy / eslint-config-naat

Style rules for js code at NAAT
0 stars 2 forks source link

how to explicitely set property as undefined with the no-undefined and no-void rules? #8

Closed ntraut closed 5 months ago

ntraut commented 2 years ago

We use the rule no-undefined which prevents to set with var x=undefined. A roundabout way to achieve the same result is with var x=void 0, but we can't do this either because of the rule no-void. We are using es6 so undefined problems may occur in only very special cases, shouldn't we authorize the use of undefined and set in place no-global-assign and no-shadow-restricted-names like suggested in https://eslint.org/docs/rules/no-undefined?

r03ert0 commented 2 years ago

Do we do x=undefined anywhere? I wouldn't... If I want to remove the value of x, I'd rather do delete x. I never compare to undefined either, but do if (typeof x === "undefined").

ntraut commented 2 years ago

You do it in https://github.com/neuroanatomy/BrainBox/blob/39f60a952739db5cb7cd4700cfc672ef25ae97a6/view/atlasmaker/src/atlasmaker.js#L62. I guess the goal is not to delete the property but more to enumerate some properties which will have to be defined after.

r03ert0 commented 2 years ago

hmm... there's maybe a better way of doing it. I think the idea there is to describe the structure of the object. Maybe doing x: null would be better.