diff --git a/EditorExtensions/Compilers/Lint/TsLintCompiler.cs b/EditorExtensions/Compilers/Lint/TsLintCompiler.cs index 85d9b68c0..a5bc80033 100644 --- a/EditorExtensions/Compilers/Lint/TsLintCompiler.cs +++ b/EditorExtensions/Compilers/Lint/TsLintCompiler.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Web.Helpers; namespace MadsKristensen.EditorExtensions { @@ -22,5 +24,26 @@ protected override string GetArguments(string sourceFileName, string targetFileN , FindLocalSettings(sourceFileName) ?? GlobalSettings(ServiceName) , sourceFileName); } + + protected override IEnumerable ParseErrorsWithJson(string error) + { + if (string.IsNullOrEmpty(error)) + return null; + + try + { + TsLintCompilerError[] results = Json.Decode(error); + + if (results.Length == 0) + Logger.Log(ServiceName + " parse error: " + error); + + return TsLintCompilerError.ToCompilerError(results); + } + catch (ArgumentException) + { + Logger.Log(ServiceName + " parse error: " + error); + return new[] { new CompilerError() { Message = error } }; + } + } } } \ No newline at end of file diff --git a/EditorExtensions/Compilers/Lint/TsLintCompilerError.cs b/EditorExtensions/Compilers/Lint/TsLintCompilerError.cs new file mode 100644 index 000000000..256a77303 --- /dev/null +++ b/EditorExtensions/Compilers/Lint/TsLintCompilerError.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Linq; + +namespace MadsKristensen.EditorExtensions +{ + internal class TsLintCompilerError + { + public string name { get; set; } + public string failure { get; set; } + public StartPosition startPosition { get; set; } + + internal class StartPosition + { + public int line { get; set; } + public int character { get; set; } + public int position { get; set; } + } + + public static IEnumerable ToCompilerError(IEnumerable rawErrors) + { + return rawErrors.Select(error => new CompilerError() + { + Message = error.failure, + Column = error.startPosition.character, + FileName = error.name, + Line = error.startPosition.line + }); + } + } +} diff --git a/EditorExtensions/Compilers/NodeExecutorBase.cs b/EditorExtensions/Compilers/NodeExecutorBase.cs index 0c293dcf4..1a2aa8d72 100644 --- a/EditorExtensions/Compilers/NodeExecutorBase.cs +++ b/EditorExtensions/Compilers/NodeExecutorBase.cs @@ -101,7 +101,7 @@ private void ValidateResult(Process process, string outputFile, string errorText } } - protected IEnumerable ParseErrorsWithJson(string error) + protected virtual IEnumerable ParseErrorsWithJson(string error) { if (string.IsNullOrEmpty(error)) return null; diff --git a/EditorExtensions/Resources/settings-defaults/.tslintrc b/EditorExtensions/Resources/settings-defaults/.tslintrc index d12d20305..4cc7682d8 100644 --- a/EditorExtensions/Resources/settings-defaults/.tslintrc +++ b/EditorExtensions/Resources/settings-defaults/.tslintrc @@ -1,20 +1,48 @@ { - "semicolon": true, - "eqeqeq": true, - "maxlen": 140, - "whitespace": true, - "quotemark": "double", - "oneline": true, - "trailing": true, - "bitwise": true, - "evil": true, - "eofline": true, - "classname": true, - "varname": true, - "noarg": true, - "sub": true, - "debug": true, - "forin": true, - "curly": true, - "indent": 4 + "rules": { + "class-name": true, + "curly": true, + "eofline": true, + "forin": true, + "indent": [true, 4], + "label-position": true, + "label-undefined": true, + "max-line-length": [true, 140], + "no-arg": true, + "no-bitwise": true, + "no-console": [true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-string-literal": true, + "no-trailing-whitespace": true, + "no-unreachable": true, + "one-line": [true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [true, "double"], + "radix": true, + "semicolon": true, + "triple-equals": [true, "allow-null-check"], + "variable-name": false, + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } } \ No newline at end of file diff --git a/EditorExtensions/WebEssentials2013.csproj b/EditorExtensions/WebEssentials2013.csproj index 90bc402f0..c5991a1dd 100644 --- a/EditorExtensions/WebEssentials2013.csproj +++ b/EditorExtensions/WebEssentials2013.csproj @@ -363,6 +363,7 @@ +