Line exceeds 100 characters and arrow body style
I have the following:
export const filteredItems = (state, filter, value) => state.items.filter(item => item.filter === value);
which gives the max-len (100) error.
When I rewrite it by changing the arrow function to the version with { } , naturally I get the error: https://github.com/airbnb/javascript#arrows--implicit-return .
What's the way around this?
export const filteredItems = (state, filter, value) =>
state.items.filter(item => item.filter === value); // new line
it looks worse but hmm yeah if you just wanna get rid of the error message
Edited: or maybe
export function filteredItems(state, filter, value) {
return state.items.filter(item => item.filter === value);
}
@luftywiranda13 I'm definitely then disabling the rule manually.. in fact in that case I'd personally go with the arrow/brace syntax and not the one liner.
@gkatsanos Here's a few options:
export const filteredItems = (state, filter, value) => (
state.items.filter(item => item.filter === value),
);
export const filteredItems = (state, filter, value) => state.items.filter(
item => item.filter === value,
);
export const filteredItems = ({ items }, _, value) => items.filter(({ filter }) => filter === value);
If you do have to disable a rule, disable max-len - line length limits are a really subpar proxy for managing complexity, so imo it's always ok to disable that rule.
export const filteredItems =
({ items }, _, value) => items.filter(i => i.filter === value);
Our style guide does not permit arbitrary linebreaks after assignment; it's always better to have too-long a line than to hit "enter" in a random place.
Hello can you please assign it to me .i would like to work on it thankyou