I have two min.js files within my theme and have multiple of the following errors reported.

3 | ERROR | Inline control structures are not allowed
3 | ERROR | Expected 1 space after first semicolon of FOR loop; 0 found

Comments

klausi’s picture

Title: Reporting errors in min.js files » Minified Javascript files should be ignored
Version: 7.x-1.0-alpha2 » 7.x-1.x-dev

Currently drupalcs cannot detect minified javascript files, so you can just ignore those errors.

We should investigate if we can hook into phpcs somehow to prevent minified javascript files from being checked. A javascript file that contains only one line can be considered minified.

klausi’s picture

Another possibility would be to introduce a naming convention for minified JS files. We could define that minified JS file names have to follow the pattern *.min.js. Then it would be very easy to add an exclusion pattern to ruleset.xml so that those files are ignored.

I could not find any documentation resources on JS minification, at least not in the javascript coding standards http://drupal.org/node/172169 . Do we have anything on that?

fluxsauce’s picture

I haven't seen anything relating to standards on minified JS files; I don't think there is a strict standard. Anecdotally, the generally accepted standard is *.min.js.

For whatever it's worth, in D7 and D8 core, the minified files are named with *.min.js:

./core/misc/ui/jquery.effects.blind.min.js
./core/misc/ui/jquery.effects.bounce.min.js
klausi’s picture

Status: Active » Closed (won't fix)

Drupal Code Sniffer has been merged into Coder 7.x-2.x. Please move this issue to the Coder queue and reopen it if the problem still exists.

xiukun.zhou’s picture

Status: Closed (won't fix) » Needs review

The problem still persists http://ventral.org/pareview/httpgitdrupalorgprojectnicemenusgit-7x-2x
see: jquery.bgiframe.min.js

xiukun.zhou’s picture

Project: Drupal Code Sniffer » Coder
Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Active

As per #4, moving issue to coder-7.x-2.x project queue.

I am still having this issue, please take a look at #5.

Any help would be greatly appreciated.
Thanks in advance.

klausi’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Javascript support has been removed from Coder. To check and fix Javascript files please use ESLint and see the Drupal ESLint documentation.