wookiehangover / jshint.vim

JSHint fork of jslint.vim
Other
194 stars 45 forks source link

Fix reading jshintrc files with comments in them. #28

Closed eventualbuddha closed 10 years ago

eventualbuddha commented 10 years ago

This was failing with the jshintrc file from the charlatan library. Backreferences do not seem to work in character classes, so we can't collapse single and double quotes into a single test. This commit splits them out to work separately.

> /(a)[^\1]/.test('aa')
true
> /(a)[^\1]/.test('ab')
true
> /(a)[^\1]/.test('a\u0001')
false

In the above example the first line should have returned false if backreferences worked in character classes, but it did not. The second example works as you'd think, but for the wrong reason. The third example shows what's really going on. Rather than being treated as a backreference, \1 is being interpreted as the character code 1.

ukch commented 10 years ago

I get the error Invalid ~/.jshintrc file when I have comments in my jshintrc. Although comments are technically not allowed in JSON, they are pretty standard in jshintrc files.

eventualbuddha commented 10 years ago

ping @wookiehangover.

wookiehangover commented 10 years ago

@eventualbuddha thanks for the ping, had forgotten about this one (looking at vim-script makes me sad inside.)