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.

CR - max-len: {ignoreRegExpLiterals: true} is too permissive

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.3.0
  • Node Version: master
  • npm Version: 5.3.0

What parser (default, Babel-ESLint, etc.) are you using? N/A

Please show your full configuration: https://github.com/nodejs/node/blob/master/.eslintrc.yaml https://github.com/nodejs/node/blob/master/lib/.eslintrc.yaml

max-len: [error, {code: 80,
                  ignoreRegExpLiterals: true,
                  ignoreUrls: true,
                  tabWidth: 2}]

What did you do? Please include the actual source code causing the issue.

01: function fatalError(e) {
02:   if (typeof e.stack === 'string') {
03:     process._rawDebug(e.stack);
04:   } else {
05:     const o = { message: e };
06:     Error.captureStackTrace(o, fatalError);
07:     process._rawDebug(o.stack);
08:   }
09:  if (process.execArgv.some((e) => /^--abort[_-]on[_-]uncaught[_-]exception$/.test(e))) {
10:    process.abort();
11:   }
12:   process.exit(1);
13: }

What did you expect to happen? L09 should error. Even though we have ignoreRegExpLiterals: true such cases should not be allowed. It’s not the RegExp that is super long, it’s the multiple expressions in that single line that caused it to be too long. I understand it’s not a straightforward problem to solve, but IMHO it could be minimized with some heuristics.

What actually happened? Please include the actual, raw output from ESLint. Nothing (i.e. lint passed)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
not-an-aardvarkcommented, Aug 6, 2017

Thanks for creating an issue. In https://github.com/eslint/eslint/issues/8189, there was some discussion about changing the behavior of ignoreRegExpLiterals to subtract the length of regex literals from the total line length, rather than ignoring lines with those literals entirely. Would that satisfy your use case?

1reaction
ljharbcommented, Aug 14, 2017

I’m suggesting that an ignore of true means “ignore it” - meaning, disregard its length - I’m not suggesting any non-boolean value be allowed there.

Measuring complexity is imo way out of scope of max-len (which is itself often used as a poor proxy for complexity).

Read more comments on GitHub >

github_iconTop Results From Across the Web

max-len - 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 >

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