-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[[FIX]] Correct CLI's indentation offset logic
Don't attempt to indent errors using data from other files, during extract with multiple files This change will fix the report of `col NaN` and the problem of `NaN` in `error.character` while checking JS code extracted from non-JS files, when more than one file has been passed in and their lengths don't match. The function `extractOffsets` finds the number of characters a JS block must be shifted to show the correct character column for an error. The result is an array consisting of numbers, for the block it checked and, `undefined` for the lines it didn't have to look at. `cli.run` executes `extractOffsets` on each input file but wrongly tries to indent all the errors found so far, across files, using the current file's offsets. This commit makes sure `cli.run` only indents errors of a file against the offsets fetched for the same file. This commit also makes sure that we don't change or ruin the value of `error.character` unnecessarily. I have chosen to trust that `extractOffsets` will return an array with only numbers (as a result of Array.length) and falsy values, to avoid the unnecessary type conversion. A test named `usingMultipleFiles` has been introduced to cli. Fixes #2778
- Loading branch information
1 parent
2f127ef
commit 47daf76
Showing
2 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters