Question

Why does jshint warn that gConfiguration is not defined? I have it defined before the start of the func. I also tried placing it inside. I know I can declare it as a global variable in the configuration but I don't see what this is wrong? requirejs uses a similar pattern at the top of its declaration.

/*jshint strict:true, undef:true */
/*global Backbone: true, $: true */

var gConfiguraton;
(function (global) {
    'use strict';
    var MYAPP = global.MYAPP = {};

    MYAPP.version = '0.0.1';

    // Defaults
    MYAPP.settings = {

        // Authorization
        authorizationKey: null,

        authorizationTokenType: 'Bearer',

        authorizationTimestamp: null,

        // Proxy
        proxyUrl: null

    };

    // Depend on jQuery and Backbone
    if (typeof $ !== 'undefined' && typeof Backbone !== 'undefined') {

        // Look for global configuration provided by user and merge their settings
        if (typeof gConfiguration !== 'undefined') {
            $.extend(MYAPP.settings, gConfiguration);
        }

        MYAPP.Events = $.extend({}, Backbone.Events);
    }

} (this));
Was it helpful?

Solution

Because you've misspelled it in the var statement (missing i near the end). You have

var gConfiguraton;

you meant

var gConfiguration;
//             ^--- i here

OTHER TIPS

Just a simple typo: var gConfiguraton; needs to change to var gConfiguration;.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top