web-ext: Show context and line numbers for JSON syntax errors

Is this a bug or feature request?

feature

What is the current behavior?

If you introduce a syntax error in your manifest.json (or in another JSON file), you will see an informative error pointing to the problem like this:

$ web-ext build -s extension/
Building web extension from /Users/kumar/dev/sound-control/extension

build: InvalidManifest: Error parsing manifest.json at /Users/kumar/dev/sound-control/extension/manifest.json: JSONError: Unexpected token 'p' at 49:4 in /Users/kumar/dev/sound-control/extension/manifest.json
  "permissions": ["activeTab", "tabs"],
   ^

What is the expected or desired behavior?

This is helpful but I think the display should be enhanced to show a bit more context and to show line numbers. Maybe something like this:

$ web-ext build -s extension/
Building web extension from /Users/kumar/dev/sound-control/extension

build: InvalidManifest: Error parsing manifest.json at /Users/kumar/dev/sound-control/extension/manifest.json: 
JSONError: Unexpected token 'p' at 49:4 in /Users/kumar/dev/sound-control/extension/manifest.json
43.        "default": "Ctrl+Shift+K"
44.      },
45.      "description": "Go to the selected audible tab"
46.    }
47.  }
48.
49.  "permissions": ["activeTab", "tabs"],
      ^
50.
51.  "manifest_version": 2

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 16 (14 by maintainers)

Most upvoted comments

I came across this a while back, thought it might be useful for this issue: https://github.com/babel/babel/issues/5064