question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Line exceeds 100 characters and arrow body style

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

33reactions
ljharbcommented, Aug 22, 2017

@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.

7reactions
ljharbcommented, Sep 2, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

arrow-body-style - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
How to disable eslint rule max line length for paragraph in ...
I am using airbnb eslint and currently I am getting error: error: Line 6 exceeds the maximum line ...
Read more >
eslint-config-prettier/README.md - UNPKG
Tip: First, you might be interested in installing [eslint-plugin-prettier]. 45, Follow the instructions over there. This is optional, though. 46.
Read more >
Arrow function expressions - JavaScript - MDN Web Docs
Arrow functions cannot use yield within their body and cannot be created ... Traditional anonymous function (function (a) { return a + 100;...
Read more >
Airbnb JavaScript Style Guide()
6.2 Strings that cause the line to go over 100 characters should not be ... braces and use a return statement. eslint: arrow-parens...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found