コード例 #1
0
        protected override string CreateHtml(string source, string filename)
        {
            // I override the meaning of this parameter to
            // get the path so that I can find .jshintrc.
            if (!File.Exists(filename))
                throw new ArgumentException("The state parameter to Compile() must be the full path to the file being linted.", "filename");
            if (_options == null)
            {
                _options = new JsHintOptions();
                _options.LoadSettingsFromStorage();
                JsHintOptions.Changed += delegate { _options.LoadSettingsFromStorage(); GenerateGlobalSettings(); };

                GenerateGlobalSettings();
            }

            source = source
                .Replace("\\", "\\\\")
                .Replace("\n", "\\n")
                .Replace("\r", "\\r")
                .Replace("'", "\\'");

            string script = ReadResourceFile("MadsKristensen.EditorExtensions.Resources.Scripts.jshint-2.1.4.js") +
                            "var settings = " + (FindLocalSettings(filename) ?? "{" + _defaultSettings + "}") + ";" +   // If this file has no .jshintrc, fall back to the configured settings
                            "var globals = settings.globals; delete settings.globals;" +  // .jshintrc files have an optional globals section, which becomes the third parameter.  (globals is not a valid option)
                            "JSHINT('" + source + "', settings, globals);" +
                            "window.external.Execute(JSON.stringify(JSHINT.errors), '" + filename.Replace("\\", "\\\\") + "')";

            return "<html><head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\" /><script>" + script + "</script></head><html/>";
        }
コード例 #2
0
        protected override string CreateHtml(string source, string filename)
        {
            // I override the meaning of this parameter to
            // get the path so that I can find .jshintrc.
            if (!File.Exists(filename))
            {
                throw new ArgumentException("The state parameter to Compile() must be the full path to the file being linted.", "filename");
            }
            if (_options == null)
            {
                _options = new JsHintOptions();
                _options.LoadSettingsFromStorage();
                JsHintOptions.Changed += delegate { _options.LoadSettingsFromStorage(); GenerateGlobalSettings(); };

                GenerateGlobalSettings();
            }

            source = source
                     .Replace("\\", "\\\\")
                     .Replace("\n", "\\n")
                     .Replace("\r", "\\r")
                     .Replace("'", "\\'");

            string script = ReadResourceFile("MadsKristensen.EditorExtensions.Resources.Scripts.jshint-2.1.4.js") +
                            "var settings = " + (FindLocalSettings(filename) ?? "{" + _defaultSettings + "}") + ";" + // If this file has no .jshintrc, fall back to the configured settings
                            "var globals = settings.globals; delete settings.globals;" +                              // .jshintrc files have an optional globals section, which becomes the third parameter.  (globals is not a valid option)
                            "JSHINT('" + source + "', settings, globals);" +
                            "window.external.Execute(JSON.stringify(JSHINT.errors), '" + filename.Replace("\\", "\\\\") + "')";

            return("<html><head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\" /><script>" + script + "</script></head><html/>");
        }
コード例 #3
0
    protected override string CreateSource(string source, string state)
    {
        if (_options == null)
        {
            _options = new JsHintOptions();
            _options.LoadSettingsFromStorage();
            JsHintOptions.Changed += delegate { _options.LoadSettingsFromStorage(); GenerateSettings(); };

            GenerateSettings();
        }

        source = source
            .Replace("\\", "\\\\")
            .Replace("\n", "\\n")
            .Replace("\r", "\\r")
            .Replace("'", "\\'");

        string script = ReadResourceFile("MadsKristensen.EditorExtensions.Resources.Scripts.jshint.js") +
                        "JSHINT('" + source + "', {" + _settings + "});" +
                        "external.Execute(JSON.stringify(JSHINT.errors), '" + state.Replace("\\", "\\\\") + "')";

        return script;
    }
コード例 #4
0
    protected override string CreateHtml(string source, string state)
    {
        if (_options == null)
        {
            _options = new JsHintOptions();
            _options.LoadSettingsFromStorage();
            JsHintOptions.Changed += delegate { _options.LoadSettingsFromStorage(); GenerateSettings(); };

            GenerateSettings();
        }

        source = source
            .Replace("\\", "\\\\")
            .Replace("\n", "\\n")
            .Replace("\r", "\\r")
            .Replace("'", "\\'");

        string script = ReadResourceFile("MadsKristensen.EditorExtensions.Resources.Scripts.jshint.js") +
                        "JSHINT('" + source + "', {" + _settings + "});" +
                        "window.external.Execute(JSON.stringify(JSHINT.errors), '" + state.Replace("\\", "\\\\") + "')";

        return "<html><head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\" /><script>" + script + "</script></head><html/>";
    }