Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Carl

GSAP Globals for JSHint

Recommended Posts

A few folks have asked about errors they get when they try to run JSHint on their projects that use GSAP. Most often there is nothing wrong with their code but JSHint has no idea about GSAP classes (TweenLite, TweenMax, CSSPlugin, eases and more) defined in external files so it throw errors. The video below illustrates how to define GSAP globals so that JSHint will skip over GSAP classes when looking for errors. If you use JSLint the same concepts apply with a slightly different syntax. We’ve included JSLint resources in the downloadable files below.

 

 

 

The gloabls{} object below can be added to any .jshintrc file.

{
    // Enforces undefined globals
    "undef" : true,
    // Defines common browser globals
    "browser" : true,
    // Also don't enforce these globals
    "globals": {
        //GSAP Globals
        "TimelineLite" : false,
        "TimelineMax" : false,
        "TweenLite" : false,
        "TweenMax" : false,
        "Back" : false,
        "Bounce" : false,
        "Circ" : false,
        "Cubic" : false,
        "Ease" : false,
        "EaseLookup" : false,
        "Elastic" : false,
        "Expo" : false,
        "Linear" : false,
        "Power0" : false,
        "Power1" : false,
        "Power2" : false,
        "Power3" : false,
        "Power4" : false,
        "Quad" : false,
        "Quart" : false,
        "Quint" : false,
        "RoughEase" : false,
        "Sine" : false,
        "SlowMo" : false,
        "SteppedEase" : false,
        "Strong" : false,
        "Draggable" : false,
        "SplitText" : false,
        "VelocityTracker" : false, 
        "CSSPlugin" : false,
        "ThrowPropsPlugin" : false, 
        "BezierPlugin" : false
    }
}

 

The downloadable zip contains .jshintrc, jshint-inline.js, .jslintrc and .jslint-inline.js. The jslint files work in the same fashion as the jshint files. 

 
Remember, .jshintrc and .jslintrc files will be hidden unless your OS is configured to show hidden files.
 
 
These files are provided strictly for your convenience, with limited support. You may need to modify them as new tools are released.
  • Like 4
Link to comment
Share on other sites

  • 1 year later...

FYI, there's a duplicate key for Power3 above...

 

30021221.jpg

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×