interactivethings / eslint-config-interactivethings

The Interactive Things ESLint config
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Add eslint-plugin-immutable rules #7

Open jstcki opened 8 years ago

jstcki commented 8 years ago

At least the no-mutation rule looks quite useful.

https://github.com/jhusain/eslint-plugin-immutable

tpreusse commented 8 years ago

I think it's too early for this. Also what about mutating in self contained functions? E.g. reducers?

But interesting way to be immutable without library overhead.

jstcki commented 8 years ago

You can always disable rules per line if you know what you're doing (like console.log in dev mode). This doesn't prevent you from doing anything. It's just linting :smile:

Why's this too early? Because of the plugin's maturity or something else?

jstcki commented 8 years ago

E.g. this should do the trick

const arrIndex = arr.reduce((index, d) => {
 index[d.id] = d; //eslint-disable-line no-mutation
 return index;
}, {});
tpreusse commented 8 years ago

Yeah plugin maturity and I'd like to see how it works in real applications. I'm aware that I can disable it on a line, file and project basis ;-)

I do like it conceptional. But it is a major step to say we write everything immutably by default. I'd like to see how big the impact is on a average data visualization component where we're not just using react.

wereHamster commented 8 years ago

Does the plugin detect mutation through functions? e.g. arr.reduce((acc, d) => { acc.set(d.id, id); return acc; }, new Map())

On Thu, Mar 10, 2016 at 12:29 PM Thomas Preusse notifications@github.com wrote:

Yeah plugin maturity and I'd like to see how it works in real applications. I'm aware that I can disable it on a line, file and project basis ;-)

I do like it conceptional. But it is a major step to say we write everything immutably by default. I'd like to see how big the impact is on a average data visualization component where we're not just using react.

— Reply to this email directly or view it on GitHub https://github.com/interactivethings/eslint-config-interactivethings/issues/7#issuecomment-194800496 .