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.

ESLint Error 'Invalid count value' when run with --fix

See original GitHub issue

I couldn’t run the lint test with --fix and I am getting the following error.

Run command

> esw -c .eslintrc ./src '.js, .jsx' --color --fix

Error

Invalid count value
RangeError: Invalid count value
    at String.repeat (native)
    at report (/Users/Projects/uni-sh/fr-webapp/node_modules/eslint/lib/rules/indent.js:267:73)
    at checkLastReturnStatementLineIndent (/Users/Projects/uni-sh/fr-webapp/node_modules/eslint/lib/rules/indent.js:430:17)
    at EventEmitter.ReturnStatement (/Users/Projects/uni-sh/fr-webapp/node_modules/eslint/lib/rules/indent.js:1050:21)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/Projects/uni-sh/fr-webapp/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (/Users/Projects/uni-sh/fr-webapp/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (/Users/Projects/uni-sh/fr-webapp/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (/Users/Projects/uniqlo-sh/fr-webapp/node_modules/eslint/lib/eslint.js:927:36)

I have resolved the issue. If there is no blank line before the return statement in anywhere in the code we will get this error message.

I have just put a blank line before the return statement then lint command with --fix is working without any issue

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
btmillscommented, Nov 14, 2016

I was able to narrow down a repro:

// .eslintrc.js
module.exports = {
    "parserOptions": {
        "ecmaFeatures": {
            "globalReturn": true
        }
    },
    "rules": {
        "indent": ["error", 2]
    }
};
// test.js
return (
  42
  );
$ npm ls --depth 0
~/Desktop/7573
└── eslint@3.10.0

$ node_modules/.bin/eslint test.js
Invalid count value
RangeError: Invalid count value
    at String.repeat (native)
    at report (~/Desktop/7573/node_modules/eslint/lib/rules/indent.js:267:73)
    at checkLastReturnStatementLineIndent (~/Desktop/7573/node_modules/eslint/lib/rules/indent.js:430:17)
    at EventEmitter.ReturnStatement (~/Desktop/7573/node_modules/eslint/lib/rules/indent.js:1048:21)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (~/Desktop/7573/node_modules/eslint/lib/util/node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (~/Desktop/7573/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (~/Desktop/7573/node_modules/eslint/lib/util/comment-event-generator.js:97:23)
    at Controller.enter (~/Desktop/7573/node_modules/eslint/lib/eslint.js:925:36)
0reactions
not-an-aardvarkcommented, Nov 14, 2016

The code is able to remove indentations as a fix. The issue is that the desired indent is coming out as a negative number for some reason. The correct behavior would be for the desired indent size to be 0, which would cause desiredIndent to be an empty string.

For what it’s worth, I think this code has the correct behavior:

return (
  42
  ) // <-- same as above example, except no semicolon

So I’m guessing there is an off-by-one error somewhere caused by the semicolon after the closing paren.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint Error 'Invalid count value' when run with --fix
I have resolved the issue. If there is no blank line before the return statement in anywhere in the code we will get...
Read more >
ESLint Error 'Invalid count value' when run with --fix-Reactjs
Coding example for the question ESLint Error 'Invalid count value' when run with --fix-Reactjs.
Read more >
Command Line Interface - 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 >
RangeError: repeat count must be less than infinity - JavaScript
RangeError: Invalid string length (V8-based) RangeError: Invalid count value: Infinity (V8-based) RangeError: repeat count must be less than ...
Read more >
eslint/eslint - Gitter
Receiving the following error when running npm run lint : Oops! Something went wrong! :( ESLint: 6.1.0. ESLint couldn't find the config "prettier"...
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