Exemplo n.º 1
0
        protected void Initialize()
        {
            _context = new Engines.Neosis();
            //_context = new JavascriptContext();

            if (String.IsNullOrEmpty(Configuration.JsLintCode))
            {
                throw new Exception("No JSLINT/JSHINT code was specified in the configuration.");
            }
            else
            {
                JSLint = Configuration.JsLintCode;
            }

            _context.Run(JSLint);

            string func = Configuration.LinterType == LinterType.JSHint ? "JSHINT" : "JSLINT";

            // a bug (apparently) in the Noesis wrapper causes a StackOverflow exception when returning data sometimes.
            // not sure why but removing "functions" from the returned object resolves it. we don't need that
            // anyway.

            string run =
                @"lintRunner = function (dataCollector, javascript, options) {
                    var data, result = JSLINT(javascript,options);

                    if (!result) {
                        data = JSLINT.data();
                        if (data.functions) {
                            delete data.functions;
                        }
                        dataCollector.ProcessData(data);
                    }
                };
            ".Replace("JSLINT", func);
            _context.Run(run);
        }
Exemplo n.º 2
0
        protected void Initialize()
        {
            _context = new Engines.Neosis();
            //_context = new JavascriptContext();

            if (String.IsNullOrEmpty(Configuration.JsLintCode))
            {
                throw new Exception("No JSLINT/JSHINT code was specified in the configuration.");
            }
            else
            {
                JSLint = Configuration.JsLintCode;
            }

            _context.Run(JSLint);

            string func = Configuration.LinterType == LinterType.JSHint ? "JSHINT" : "JSLINT";
            string run =
                @"lintRunner = function (dataCollector, javascript, options) {
                    JSLINT(javascript,options);

                    var data = JSLINT.data();
                    if  (data) {
                        dataCollector.ProcessData(data);
                    }
                };".Replace("JSLINT", func);
            _context.Run(run);
        }