Re: [textadept] Re: Javascript lexer modification

From: Brian Schott <briancsch....at.gmail.com>
Date: Fri, 24 Feb 2012 11:45:20 -0800

Jshint does check for trailing commas. It's also a bit of a pain to
set up since it's written in JS and every interpreter handles input
differently. My problem with these JS analysis tools is that they want
you to copy and paste all of your code into a browser window. Not very
efficient. That's the reason that I modified the lexer.

I ended up finding someone's jshint VIM plugin that I can use as a
reference for running it from the command line. I'll probably add
support for it to my JS module this weekend.

On Fri, Feb 24, 2012 at 11:01 AM, Robert <ro....at.web.de> wrote:
> On Fri, Feb 24, 2012 at 7:51 PM, mitchell <c....at.caladbolg.net> wrote:
>> Brian,
>>
>>
>> On Fri, 24 Feb 2012, Brian Schott wrote:
>>
>>> I'm not sure. There are a lot of ways that we could add similar error
>>> detection to other languages. It depends on how narrow or wide the
>>> purpose of a lexer is.
>>
>>
>> Is there some sort of jslint utility that would catch something like this?
>> If so, then the lexer has no place for it.
>>
> The linked article [1] mentions that JSLint can be configured to check
> for these.
> I use something similar in the coffeescript module.
>
> There is also a variant of the JS and coffeescript modules on GitHub [2] that
> uses jshint, though I am not sure whether it checks for trailing commas.
>
> Robert
>
> [2] https://github.com/clux/.textadept
>
>> mitchell
>>
>>
>>>
>>> On Fri, Feb 24, 2012 at 6:06 AM, mitchell <c....at.caladbolg.net> wrote:
>>>>
>>>> Brian,
>>>>
>>>>
>>>> On Thu, 16 Feb 2012, Brian Schott wrote:
>>>>
>>>>> Make that
>>>>>
>>>>> local trailing_comma_of_death = token(l.ERROR, ',' * l.space^0 * '}')
>>>>
>>>>
>>>>
>>>> Do you think this should this be added to the official Javascript lexer?
>>>>
>>>> mitchell
>>>>
>>>>>
>>>>> On Thu, Feb 16, 2012 at 12:57 PM, Brian Schott <briancsch....at.gmail.com>
>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> After being hit by the "trailing comma of death"[1] too many times on
>>>>>> a project at work, I've modified the javascript lexer to make my life
>>>>>> a bit better.
>>>>>>
>>>>>> Add this somewhere in the lexer file:
>>>>>> local trailing_comma_of_death = token(l.ERROR, ',' * ws^0 * '}')
>>>>>>
>>>>>> and this in the M._rules table:
>>>>>> { 'error', trailing_comma_of_death},
>>>>>>
>>>>>> [1]
>>>>>>
>>>>>> http://www.enterprisedojo.com/2010/12/19/beware-the-trailing-comma-of-death/
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups
>>>>> "textadept" group.
>>>>> To post to this group, send email to textadept.at.googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> textadept+unsubscribe.at.googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/textadept?hl=en.
>>>>>
>>>>>
>>>>
>>>> mitchell
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups
>>>> "textadept" group.
>>>> To post to this group, send email to textadept.at.googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> textadept+unsubscribe.at.googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/textadept?hl=en.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "textadept" group.
>>> To post to this group, send email to textadept.at.googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> textadept+unsubscribe.at.googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/textadept?hl=en.
>>>
>>>
>>
>> mitchell
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "textadept" group.
>> To post to this group, send email to textadept.at.googlegroups.com.
>> To unsubscribe from this group, send email to
>> textadept+unsubscribe.at.googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/textadept?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/textadept?hl=en.
>
Received on Fri 24 Feb 2012 - 14:45:20 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:30:06 EST