Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way for jscs to ignore rules per file, block or line?

Tags:

jscs

I'm looking for a way for jscs (JavaScript Code Style) do the same behavior as jshint to ignore certain rules per file with a comment at the top, or per line, with a start and end comment.

jshint example to ignore a specific rule in the file :

/* jshint undef: false */

jshint example to ignore a specific rule in a block:

// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be linted with ignored by JSHint.
/* jshint ignore:end */
like image 303
fernandopasik Avatar asked Aug 09 '14 21:08

fernandopasik


3 Answers

This is available since jscs 1.6.0

For a file scope:

Put this on top of the file to ignore all rules

// jscs:disable

Put this on top of the file to ignore a specific rule:

// jscs:disable specificRule

Also for ignoring the whole file you can add it to .jscsrc, adding an entry to excludeFiles.

For block scope:

To ignore all rules

// Code here will be linted with JSCS.
// jscs:disable
// Code here will be ignored by JSCS.
// jscs:enable

To ignore a specific rule:

// Code here will be linted with JSCS.
// jscs:disable specificRule
// Code here will be ignored by JSCS.
// jscs:enable specificRule
like image 136
fernandopasik Avatar answered Nov 05 '22 16:11

fernandopasik


to disable a particular rule for just the one line

// jscs:ignore maximumLineLength
like image 34
umasudhan Avatar answered Nov 05 '22 16:11

umasudhan


To ignore the whole file just add the following line at the top of the file.

// jscs:disable
like image 3
Andrew Avatar answered Nov 05 '22 17:11

Andrew