[Phpmyadmin-devel] jshint errors

Ayush Chaudhary ayushchd at gmail.com
Tue Apr 16 08:51:55 CEST 2013


Hi,

On Monday, 15 April 2013 at 10:09 PM, Marc Delisle wrote:  
> Michal Čihař a écrit :
> > Hi all
> >  
> > I've took some time to look at jshint checks found on our code:
> >  
> > http://ci.phpmyadmin.net/job/phpMyAdmin-continuous/3132/violations/?#jslint
> >  
> > I've fixed some obvious ones (like missing ;, typecast safe comparing,
> > missing radix for parseInt), but there are still many of them. Most of
> > them fit into following case:
> >  
> >  
> > - ['strSave'] is better written in dot notation.
> >  
> > This error is raised to highlight an unnecessarily verbose and
> > potentially confusing piece of code. More detailed explanation is at:
> >  
> > http://jslinterrors.com/a-is-better-written-in-dot-notation/
> >  
> >  
> > - 'type' is already defined. / 'type' used out of scope.
> >  
> > Most of these come from following constructs:
> >  
> > if (foo) {
> > var bar = 1;
> > } else {
> > var bar = 1;
> > }
> > alert(bar);
> >  
> > This is not an issue for javascript (it has no block scope for
> > variables), it can be confusing, more details at:
> >  
> > http://www.jshint.com/docs/#funcscope
> >  
> >  
> > So both are more just matter of coding style rather than real bug and
> > can be disabled in jshint. The question is whether we would prefer to
> > hide these warnings or fix them.
> >  
>  
>  
> Another question: which coding style do we prefer, the one with the dot  
> notation or with the square brackets?
>  
>  

Logically, dot notation seems better for the reasons mentioned in the link explaining the error. The only problem that I see with dot notation is that we will still have to use the square bracket notation for reserved words. So that could lead to inconsistency in the convention if we have a lot of such cases where the member names are also reserved words.

The same reserved words issue might cause problems if we decide to automate the fix like Michal mentioned. However, if there are not many such cases in our code base, then we can go for the dot notation and in the future, we can make sure that we don't use reserved words as member names.
>  
> --  
> Marc Delisle
> http://infomarc.info
>  
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter
> _______________________________________________
> Phpmyadmin-devel mailing list
> Phpmyadmin-devel at lists.sourceforge.net (mailto:Phpmyadmin-devel at lists.sourceforge.net)
> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
>  
>  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20130416/530266a1/attachment.html>


More information about the Developers mailing list