New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RangeError: Invalid string length
with --format=json and a really long source line
#5380
Comments
This is happening because we include the line text whenever there's a lint problem on it. If there are multiple problems on that line, that probably blows out the size of the raw result. About the only workaround I can think of would be to truncate the line if it's greater than some arbitrary length, and I'm unsure if we should do that. Another option is for you to create a custom formatter that omits the |
Hmm. Is there really a strong need to serialize the line, anyway? Some other formatters (stylish, compact) don't bother. Then again, it would be a breaking change to remove it unconditionally, so let me raise one more thought: Could we support formatter-specific CLI or CLIEngine options? These would be ignored by default by all formatters, but the JSON one could have an option for omitting serializing the line; in this particular case, it could be implemented as a replacer function for the |
No, we don't want to complicate formatters by passing additional options into them. We added the JSON formatter so people could pipe that to whatever tools they wanted. See #2989 |
In that case, should we consider adding a new formatter (maybe "simple-json" or "minimal-json") which omits some values in serialization? That would seem to be a good way to help @ahal out. |
Most of our formatters already don't output the source text. Adding another formatter just for this purpose is a bit much, especially when it's easy to create a custom formatter that does exactly what you want. |
It sounds like we're deciding not to fix this in core. Closing as wontfix. @ahal If you would like help writing a custom formatter, please feel free to reach out in our Gitter chat, and we'll do our best to help. |
I am getting lots of errors in version
Is there any way for me to avoid this? |
Failure:
I can consistently reproduce this running eslint on all the files in this directory:
https://dxr.mozilla.org/mozilla-central/source/devtools/client/inspector/markup/test
STR:
Note: the path needs to be absolute to bypass the include/exclude directives in .eslintrc.
I did a bit of digging and the result set isn't terribly large (104 errors) so I found it strange that memory problems would be the issue. It turns out, that JSON.stringify falls over at this really long line:
https://dxr.mozilla.org/mozilla-central/source/devtools/client/inspector/markup/test/browser_markup_copy_image_data.js#12
which appears in the eslint output under the 'source' attribute. Though, if I lint only that specific file, it works fine. I realize this is likely a v8 bug, but might warrant a workaround in eslint to cover this case.
The text was updated successfully, but these errors were encountered: