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); } }
private static void MigrateOptions(JSLintOptions jsLintOptions, IDictionary <string, object> options) { if (options.ContainsKey("evil")) { var evil = options["evil"] as bool?; if (evil.HasValue) { jsLintOptions.TolerateEval = evil; } } }
public void Spec03() { var target = new JSLintOptions(); target.PredefinedGlobals.Add("jasmine", false); var merge = new JSLintOptions(); merge.PredefinedGlobals.Add("jasmine", true); target.Merge(merge); I.Expect(target.PredefinedGlobals["jasmine"]).ToBeTrue(); }
public void Spec02() { var target = new JSLintOptions(); target.PredefinedGlobals.Add("jQuery", false); var merge = new JSLintOptions(); merge.PredefinedGlobals.Add("$", false); target.Merge(merge); I.Expect(target.PredefinedGlobals).ToContainKey("$"); I.Expect(target.PredefinedGlobals).ToContainKey("jQuery"); }
public OptionsViewModel(JSLintOptions jslintoptions) { this._options = jslintoptions; Linters = new ObservableCollection <LinterViewModel>(); Linters.Add(new LinterViewModel(new LinterModel("JSLint", JSLint.Framework.OptionClasses.Linters.JSLint), jslintoptions)); Linters.Add(new LinterViewModel(new LinterModel("JSLint Old", JSLint.Framework.OptionClasses.Linters.JSLintOld), jslintoptions)); Linters.Add(new LinterViewModel(new LinterModel("JSHint", JSLint.Framework.OptionClasses.Linters.JSHint) { HasUnusedVariableOptionBakedIn = true, HasQuotMarkOption = true, HasMaxComplexityOptions = true }, jslintoptions)); LoadSelected(); }
private void MergeOptions(JSLintNetSettings merge) { if (merge.Options == null) { return; } if (this.Options == null) { this.Options = merge.Options; return; } this.Options.Merge(merge.Options); }
public void Spec02() { using (var testable = new LintTestable()) { var options = new JSLintOptions() { TolerateStupidPractices = true }; testable.GetMock <IJsonProvider>() .Setup(x => x.SerializeOptions(options)) .Returns(@"{""some"":""json""}"); testable.Instance.Lint("some source", options); testable.Verify <IJsonProvider>(x => x.DeserializeData(@"some source_{""some"":""json""}")); } }
public void LoadOptions(Options options) { outputAsError.IsChecked = options.ErrorCategory == ErrorCategory.Error; outputAsWarning.IsChecked = options.ErrorCategory == ErrorCategory.Warning; outputAsMessage.IsChecked = options.ErrorCategory == ErrorCategory.Message; outputAsTask.IsChecked = options.ErrorCategory == ErrorCategory.Task; todoAsError.IsChecked = options.TODOCategory == ErrorCategory.Error; todoAsWarning.IsChecked = options.TODOCategory == ErrorCategory.Warning; todoAsMessage.IsChecked = options.TODOCategory == ErrorCategory.Message; todoAsTask.IsChecked = options.TODOCategory == ErrorCategory.Task; findTODOs.IsChecked = options.TODOEnabled; runOnSave.IsChecked = options.RunOnSave; runOnBuild.IsChecked = options.RunOnBuild; cancelBuildOnError.IsChecked = options.CancelBuildOnError; includeJS.IsChecked = (options.BuildFileTypes & IncludeFileType.JS) == IncludeFileType.JS; includeCSS.IsChecked = (options.BuildFileTypes & IncludeFileType.CSS) == IncludeFileType.CSS; includeHTML.IsChecked = (options.BuildFileTypes & IncludeFileType.HTML) == IncludeFileType.HTML; onSaveJs.IsChecked = (options.SaveFileTypes & IncludeFileType.JS) == IncludeFileType.JS; onSaveCss.IsChecked = (options.SaveFileTypes & IncludeFileType.CSS) == IncludeFileType.CSS; onSaveHtml.IsChecked = (options.SaveFileTypes & IncludeFileType.HTML) == IncludeFileType.HTML; fakeAtCharset.IsChecked = options.FakeCSSCharset; ignoreErrorStart.Text = options.IgnoreErrorStart; ignoreErrorEnd.Text = options.IgnoreErrorEnd; IgnoreErrorLine.Text = options.IgnoreErrorLine; JSLintOptions jslint = options.JSLintOptions; _optionsVM.LoadLinterSettings(jslint.SelectedLinter, jslint.BoolOptions2); warnOnUnused.IsChecked = jslint.ErrorOnUnused; indentSize.Text = jslint.IndentSize.ToString(); maxlen.Text = jslint.MaxLength.ToString(); if (jslint.PreDefined != null && jslint.PreDefined.Count > 0) { predefined.Text = string.Join(", ", jslint.PreDefined); } }
public void Spec01() { var target = new JSLintOptions() { MaximumErrors = 22, AssumeBrowser = false, TolerateUnusedParameters = true }; var merge = new JSLintOptions() { MaximumErrors = 33, AssumeBrowser = true, TolerateDebuggerStatements = false }; target.Merge(merge); I.Expect(target.MaximumErrors).ToBe(33); I.Expect(target.AssumeBrowser).ToBeTrue(); I.Expect(target.TolerateUnusedParameters).ToBeTrue(); I.Expect(target.TolerateDebuggerStatements).ToBeFalse(); I.Expect(target.TolerateStupidPractices).ToBeNull(); }
public void Spec01() { var target = new JSLintOptions() { MaximumErrors = 22, AssumeBrowser = false, TolerateBitwiseOperators = true }; var merge = new JSLintOptions() { MaximumErrors = 33, AssumeBrowser = true, TolerateEval = false }; target.Merge(merge); I.Expect(target.MaximumErrors).ToBe(33); I.Expect(target.AssumeBrowser).ToBeTrue(); I.Expect(target.TolerateBitwiseOperators).ToBeTrue(); I.Expect(target.TolerateEval).ToBeFalse(); I.Expect(target.TolerateMessyWhitespace).ToBeNull(); }
public LinterViewModel(LinterModel linterModel, JSLintOptions jslintOptions) { _linter = linterModel; _jslintOptions = jslintOptions; _booleanSettings = new ObservableCollection <LintBooleanSettingViewModel>(GetBooleanSettings(_linter, _jslintOptions)); }
public LintBooleanSettingViewModel(LintBooleanSettingModel model, JSLintOptions jslintOptions) { _model = model; _jslintOptions = 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))); }
/// <summary> /// Serializes the options. /// </summary> /// <param name="value">The value.</param> /// <returns> /// A serialized string. /// </returns> public string SerializeOptions(JSLintOptions value) { return JsonConvert.SerializeObject(value, serializerSettings); }
/// <summary> /// Serializes the options. /// </summary> /// <param name="value">The value.</param> /// <returns> /// A serialized JSON string. /// </returns> public string SerializeOptions(JSLintOptions value) { return(JsonConvert.SerializeObject(value, SerializerSettings)); }
private static void MigrateOptions(JSLintOptions jsLintOptions, IDictionary<string, object> options) { if (options.ContainsKey("evil")) { var evil = options["evil"] as bool?; if (evil.HasValue) { jsLintOptions.TolerateEval = evil; } } }
public List <JSLintError> Lint(string javascript, JSLintOptions configuration, bool isJavaScript) { return(this.linter.Lint(javascript, configuration, isJavaScript)); }