Lint warning: ionic is not defined for ionic.Platform


#1

How can I get rid of this lint (jshint) warning? I have a controller that has this statement:

$scope.isIOS = ionic.Platform.isIOS();

It compiles and runs just fine with ionic showing up as an object, but the code is getting a lint warning of “‘ionic’ is not defined.” How can I fix it? (It does not matter whether or not I inject $ionicPlatform into the controller.)


#2

I actually had quite a few lint warnings in my project. But i never figured out what’s wrong. That buggers me a while but i decided to ignore them eventually.


#3

You could try defining global variables in Your jsHint config, like mentioned here:

jsHint and Global Variables


#4

Thanks, psyche! My .jshintrc had a globals section, I just added ionic to it and now I’m clean:

“globals”: {
“ionic”: false,
“angular”: false,
“cordova”: false,
“StatusBar”: false
}


#5

Thanks @psyche and @lannie, you both saved my day :smile: