src/extensions/default/JSLint/main.js
function lintOneFile(text, fullPath) {
        // If a line contains only whitespace (here spaces or tabs), remove the whitespace
        text = text.replace(/^[ \t]+$/gm, "");

        var options = prefs.get("options");

        _lastRunOptions = _.clone(options);

        if (!options) {
            options = {};
        } else {
            options = _.clone(options);
        }

        if (!options.indent) {
            // default to using the same indentation value that the editor is using
            options.indent = _getIndentSize(fullPath);
        }

        // If the user has not defined the environment, we use browser by default.
        var hasEnvironment = _.some(ENVIRONMENTS, function (env) {
            return options[env] !== undefined;
        });

        if (!hasEnvironment) {
            options.browser = true;
        }

        var jslintResult = JSLINT(text, options);

        if (!jslintResult) {
            // Remove any trailing null placeholder (early-abort indicator)
            var errors = JSLINT.errors.filter(function (err) { return err !== null; });

            errors = errors.map(function (jslintError) {
                return {
                    // JSLint returns 1-based line/col numbers
                    pos: { line: jslintError.line - 1, ch: jslintError.character - 1 },
                    message: jslintError.reason,
                    type: CodeInspection.Type.WARNING
                };
            });

            var result = { errors: errors };

            // If array terminated in a null it means there was a stop notice
            if (errors.length !== JSLINT.errors.length) {
                result.aborted = true;
                errors[errors.length - 1].type = CodeInspection.Type.META;
            }

            return result;
        }
        return null;
    }
function lintOneFile(text, fullPath) {
        // If a line contains only whitespace (here spaces or tabs), remove the whitespace
        text = text.replace(/^[ \t]+$/gm, "");

        var options = prefs.get("options");

        _lastRunOptions = _.clone(options);

        if (!options) {
            options = {};
        } else {
            options = _.clone(options);
        }

        if (!options.indent) {
            // default to using the same indentation value that the editor is using
            options.indent = _getIndentSize(fullPath);
        }

        // If the user has not defined the environment, we use browser by default.
        var hasEnvironment = _.some(ENVIRONMENTS, function (env) {
            return options[env] !== undefined;
        });

        if (!hasEnvironment) {
            options.browser = true;
        }

        var jslintResult = JSLINT(text, options);

        if (!jslintResult) {
            // Remove any trailing null placeholder (early-abort indicator)
            var errors = JSLINT.errors.filter(function (err) { return err !== null; });

            errors = errors.map(function (jslintError) {
                return {
                    // JSLint returns 1-based line/col numbers
                    pos: { line: jslintError.line - 1, ch: jslintError.character - 1 },
                    message: jslintError.reason,
                    type: CodeInspection.Type.WARNING
                };
            });

            var result = { errors: errors };

            // If array terminated in a null it means there was a stop notice
            if (errors.length !== JSLINT.errors.length) {
                result.aborted = true;
                errors[errors.length - 1].type = CodeInspection.Type.META;
            }

            return result;
        }
        return null;
    }
function lintOneFile ( text , fullPath ) { // If a line contains only whitespace (here spaces or tabs), remove the whitespace text = text . replace ( / ^[ \t]+$ / gm , "" ) ; var options = prefs . get ( "options" ) ; _lastRunOptions = _ . clone ( options ) ; if ( ! options ) { options = { } ; } else { options = _ . clone ( options ) ; } if ( ! options . indent ) { // default to using the same indentation value that the editor is using options . indent = _getIndentSize ( fullPath ) ; } // If the user has not defined the environment, we use browser by default. var hasEnvironment = _ . some ( ENVIRONMENTS , function ( env ) { return options [ env ] !== undefined ; } ) ; if ( ! hasEnvironment ) { options . browser = true ; } var jslintResult = JSLINT ( text , options ) ; if ( ! jslintResult ) { // Remove any trailing null placeholder (early-abort indicator) var errors = JSLINT . errors . filter ( function ( err ) { return err !== null ; } ) ; errors = errors . map ( function ( jslintError ) { return { // JSLint returns 1-based line/col numbers pos : { line : jslintError . line - 1 , ch : jslintError . character - 1 } , message : jslintError . reason , type : CodeInspection . Type . WARNING } ; } ) ; var result = { errors : errors } ; // If array terminated in a null it means there was a stop notice if ( errors . length !== JSLINT . errors . length ) { result . aborted = true ; errors [ errors . length - 1 ] . type = CodeInspection . Type . META ; } return result ; } return null ; }
Run JSLint on the current document. Reports results to the main UI. Displays
a gold star when no errors are found.
Run JSLint on the current document . Reports results to the main UI . Displays a gold star when no errors are found .