0

I have a plugin in my plugins.js file that looks like this:

var ShowCredits=function(){var a={addEvent:function(b,c,d,e){if(b.addEventList ...etc

Over in my functions.js file I have this:

var credits = new ShowCredits();
credits.code = function() { ...etc

When I lint, I get the following error message:

var credits = new ShowCredits();
'ShowCredits' is not defined.

Which makes sense because of the way the plugin is written.

Is there a way to re-write this so that the code validates?

Thanks a lot,

-Yahreen

1 Answer 1

1

The keyword new is to instantiate an object of the given class. Obviously, you don't define a class but a function. So just remove "new"

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, but because that function lives in the plugins file (at least as currently written), the code doesn't lint properly since it's not defined. I'm wondering if there's a cleaner way to write it so that it lints properly? I'd have to assume this is how the jQuery plugins system works, but I'm not that familiar with it?
Use /*jsl:import PathToOtherScript*/ to tell lint to load an external file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.