最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

WebStorm - Suppress unused param warning JavaScript - Stack Overflow

programmeradmin7浏览0评论

Does anyone know how to suppress unused parameter warning in WebStorm? I tried jslint, but that does not work

/*jslint node: true, unparam: true*/
/*global __dirname: false */
"use strict";
var
  util = require('../util'),
  logger = util.getLogger(module.filename),
  ;

var UserHelper = module.exports = function () {
};

/**
 * Helper object for user facade 
 */
UserHelper.prototype = {
  doSomething : function(unusedParam) {
    //do something implementation
  }
};

Does anyone know how to suppress unused parameter warning in WebStorm? I tried jslint, but that does not work

/*jslint node: true, unparam: true*/
/*global __dirname: false */
"use strict";
var
  util = require('../util'),
  logger = util.getLogger(module.filename),
  ;

var UserHelper = module.exports = function () {
};

/**
 * Helper object for user facade 
 */
UserHelper.prototype = {
  doSomething : function(unusedParam) {
    //do something implementation
  }
};
Share Improve this question edited Oct 27, 2014 at 21:47 coderman asked Oct 27, 2014 at 19:57 codermancoderman 1,5152 gold badges16 silver badges16 bronze badges 2
  • unparam should work. Can you post your code? – ruffin Commented Oct 27, 2014 at 20:34
  • 1 Consider using jshint instead of jslint. – Dan Dascalescu Commented Oct 27, 2014 at 21:42
Add a ment  | 

4 Answers 4

Reset to default 5

You can modify WebStorm's builtin code inspections under File->Settings->Editor->Inspections. Then in Javascript->General area look for "Unused JavaScript / ActionScript global symbol".

That is likely the setting which is causing the "unused property" warning, though it might be one of the others. I am using 2016.1.3 and noticed a lot of my anonymous functions defined like this had the same buggy warning. Like most others I'd still remend using jsHint itself above and beyond even just WebStorm's inspection.

For WebStorm with JSLint/JSHint disabled, you need to add this line before the line triggering the error:

//noinspection JSUnusedLocalSymbols

jshint instead of jslint works for me on WebStorm 8 and WebStorm 9 beta:

/*jshint node:true, unused:false */

Also, make sure you have JSHint (or JSLint) enabled in your preferences. JSHint has "Warn about unused variables". NOTE: This JSHint check does not distinguish between variables and function parameters unless JSHint is configured with unused:vars.

You can also uncheck the "Unused parameters" option under the JSLint configuration screen.

Relevant JSHint doc

unparam should work -- and if I clean the other lint issues your sample, it does.

/*jslint node: true, unparam: true, sloppy:true, white:true, nomen:true */
/*global __dirname: false */
"use strict";
var util = require('../util'),
  logger = util.getLogger(module.filename),
  UserHelper;

UserHelper = module.exports = function () {
    console.log('this is a function');
};

/**
 * Helper object for user facade 
 */
UserHelper.prototype = {
  doSomething : function(unusedParam) {
    //do something implementation
    console.log('alert');
  }
};

That passes cleanly on jslint.. Sounds like a WebStorm configuration issue. I have PhpStorm 6.x, but I'm assuming you're on the latest version of WebStorm, so I can't guarantee I could debug it.

But it certainly seems like a WebStorm issue rather than a JSLint one.

发布评论

评论列表(0)

  1. 暂无评论