public List<JSLintError> Lint(string javascript, JSLintOptions configuration, bool isJavaScript) { if (string.IsNullOrEmpty(javascript)) { throw new ArgumentNullException("javascript"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } lock (_lock) { Linters linterToUse = isJavaScript ? configuration.SelectedLinter : Linters.JSLint; JavascriptContext context = GetLinterContext(linterToUse); LintDataCollector dataCollector = new LintDataCollector(configuration.ErrorOnUnused); // Setting the externals parameters of the context context.SetParameter("dataCollector", dataCollector); context.SetParameter("javascript", javascript); context.SetParameter("options", configuration.ToJsOptionVar(linterToUse)); // Running the script context.Run("lintRunner(linterName, dataCollector, javascript, options);"); return dataCollector.Errors; } }
public OptionsViewModel(JSLintOptions jslintoptions) { this._options = jslintoptions; Linters = new ObservableCollection<LinterViewModel>(); Linters.Add(new LinterViewModel(new LinterModel("JSLint", JSLint.VS2010.OptionClasses.Linters.JSLint), jslintoptions)); Linters.Add(new LinterViewModel(new LinterModel("JSLint Old", JSLint.VS2010.OptionClasses.Linters.JSLintOld), jslintoptions)); Linters.Add(new LinterViewModel(new LinterModel("JSHint", JSLint.VS2010.OptionClasses.Linters.JSHint) { HasUnusedVariableOptionBakedIn = true, HasQuotMarkOption = true, HasMaxComplexityOptions = true }, jslintoptions)); LoadSelected(); }
public LintBooleanSettingViewModel(LintBooleanSettingModel model, JSLintOptions jslintOptions) { _model = model; _jslintOptions = jslintOptions; }
private void TestLint(string javascript, List<string> errorsExpected, JSLintOptions lintoptions = null, List<string> todos = null, Options options = null) { if (options == null) { options = new Options(); if (lintoptions != null) { options.JSLintOptions = lintoptions; } } lintoptions = options.JSLintOptions; IgnoreErrorSectionsHandler ignoreErrorHandler = new IgnoreErrorSectionsHandler(javascript); IEnumerable<JSLintError> errors = _linter.Lint(javascript, lintoptions, true); errors = errors.Where(a => !ignoreErrorHandler.IsErrorIgnored(a.Line, a.Column)); if (lintoptions.FindTodos) { errors = errors.Concat(TodoFinder.FindTodos(javascript)); } string errorMessage = "got "; for(var i = 0; i < errors.Count(); i++) { errorMessage += "<" + errors.ElementAt(i).Message + "> "; } for (var i = 0; i < errorsExpected.Count; i++) { if (errors.Count() <= i) { break; } Assert.AreEqual(errorsExpected[i], errors.ElementAt(i).Message, errorMessage); } Assert.AreEqual(errorsExpected.Count, errors.Count(), errorMessage); }
public LinterViewModel(LinterModel linterModel, JSLintOptions jslintOptions) { _linter = linterModel; _jslintOptions = jslintOptions; _booleanSettings = new ObservableCollection<LintBooleanSettingViewModel>(GetBooleanSettings(_linter, _jslintOptions)); }
public IEnumerable<LintBooleanSettingViewModel> GetBooleanSettings(LinterModel linter, JSLintOptions jslintoptions) { return LintBooleanSettingModel.AllOptions .Where(a => ((a.LintersAppliesTo & linter.Type) > 0)) .Select(a => new LintBooleanSettingViewModel(a, jslintoptions)); }