0

I have the following Lint errors with the following javascript function

getColor: function (color) {
    var result = "";
    switch (color) {
    case "RESET":
        result =  "\033[0m";
        break;
    case "BLACK":
        result =  "\033[30m";
        break;
    case "RED":
        result =  "\033[31m";
        break;
    case "GREEN":
        result =  "\033[32m";
        break;
    case "YELLOW":
        result =  "\033[33m";
        break;
    case "BLUE":
        result =  "\033[34m";
        break;
    case "MAGENTA":
        result =  "\033[35m";
        break;
    case "CYAN":
        result =  "\033[36m";
        break;
    case "WHITE":
        result =  "\033[37m";
        break;
    }
    return result;

},

I have tried wrapping it in

 /*ignore jslint start*/  /*ignore jslint end*/

but this doesn't work.

Ive looked at http://jslinterrors.com/octal-literals-are-not-allowed-in-strict-mode/

and it says to implement

/*jshint -W115 */

any ideas on how to do or the jslint equivalent inline as i need the code to pass a Jenkins build ?

Welsh King
  • 3,178
  • 11
  • 38
  • 60
  • I think [you're out of luck](https://github.com/douglascrockford/JSLint/blob/master/jslint.js#L933). JSLint isn't always particularly flexible. Though if you can edit the JSLint source your build is using, you can certainly change the octal hating limitation. – ruffin Jan 26 '14 at 22:47
  • hmm yeah i think your right – Welsh King Jan 27 '14 at 11:56

1 Answers1

0

Why not convert the octal escape sequences to hex or Unicode escape sequences?

For example, "\x1B[0m" and "\u001B[0m" are both the same exact string as "\033[0m", but JSLint is happy with them.

peterflynn
  • 4,667
  • 2
  • 27
  • 40