How to suppress “{variable} is better written in dot notation.”

后端 未结 3 1128
死守一世寂寞
死守一世寂寞 2021-02-01 00:41

Is there an option to and/or how do I suppress errors like the following?

175,14:[\'tracker\'] is better written in dot notation.

3条回答
  •  你的背包
    2021-02-01 01:14

    In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W069.

    This means you can tell JSHint to not issue this warning with the /*jshint -W069 */ directive.

    You can even wrap several lines of code and then reenable the warning as the example below (with a note to future you why it was a good idea):

    /*jshint -W069 */
    /*Disable Warning Justification:
        Using bracket notation so Google Closure Compiler 
        ADVANCED_OPTIMIZATIONS will keep the original property names. */
    obj['prop1'] ='foo';
    obj['prop2'] ='bar';
    /*jshint +W069 */
    

提交回复
热议问题