Search code examples
phpstorm

Warning on prepending variables with $


When I have a selector that I use several times, I like to prepend it with $ So if I'm using $('body') all over my script, I'll make a variable, $body. The warning arises, in this particular case, when I do $anElement.appendTo($body) I get the warning:

Argument type JQuery|jQuery|html element is not assignable to parameter type JQuery|element|string

I was told this is actually pretty common and acceptable practice, so is there a way I can turn this warning off? I couldn't seem to find any particular entry that disabled this in the inspections.

What I'm doing is this:

$('<div>, 
    {class:"aClass", text: "some text"}
).appendTo($body);

Solution

  • The warning is under Javascript > General > Signature Mismatch.