mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-22 19:59:19 +08:00
Add json1 format that ignores tabs
The new json1 format works just like json except that it treats tabs as single characters instead of 8-character tabstops. The main use case is to allow editors to pass -fjson1 so that they can consume the json output in a character-oriented way without breaking backwards compatibility. Also addresses #1048.
This commit is contained in:
@@ -22,6 +22,7 @@ module ShellCheck.Formatter.Format where
|
||||
import ShellCheck.Data
|
||||
import ShellCheck.Interface
|
||||
import ShellCheck.Fixer
|
||||
import Control.Monad
|
||||
import Data.Array
|
||||
|
||||
-- A formatter that carries along an arbitrary piece of data
|
||||
@@ -54,5 +55,10 @@ makeNonVirtual comments contents =
|
||||
where
|
||||
list = lines contents
|
||||
arr = listArray (1, length list) list
|
||||
fix c = removeTabStops c arr
|
||||
untabbedFix f = newFix {
|
||||
fixReplacements = map (\r -> removeTabStops r arr) (fixReplacements f)
|
||||
}
|
||||
fix c = (removeTabStops c arr) {
|
||||
pcFix = liftM untabbedFix (pcFix c)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user