coderman
coderman

Reputation: 1515

WebStorm - Suppress unused param warning JavaScript

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
  }
};

Upvotes: 10

Views: 10035

Answers (4)

Vitaliy Z
Vitaliy Z

Reputation: 133

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

//noinspection JSUnusedLocalSymbols

Upvotes: 4

Nicholi
Nicholi

Reputation: 1093

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 recommend using jsHint itself above and beyond even just WebStorm's inspection.

Settings

Upvotes: 5

ruffin
ruffin

Reputation: 17453

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.com. 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.

Upvotes: 0

sherb
sherb

Reputation: 6105

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

Upvotes: 3

Related Questions