eslint-plugin-microsoft-typescript
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -32,22 +32,28 @@ "use strict"; | ||
|| token.type === experimental_utils_1.AST_TOKEN_TYPES.String); }; | ||
var checkSoubleSpace = function () { | ||
var checkDoubleSpaceInComment = function (comment, token) { | ||
var firstNonSpace = /\S/.exec(comment); | ||
if (!firstNonSpace) { | ||
return; | ||
} | ||
var rgx = /[^/*. ] {2,}[^-!/= ]/g; | ||
rgx.lastIndex = firstNonSpace.index; | ||
var doubleSpace = rgx.exec(comment); | ||
if (doubleSpace && !comment.includes(PARAM)) { | ||
context.report({ | ||
messageId: 'noDoubleSpaceError', | ||
node: token, | ||
loc: { line: token.loc.start.line, column: doubleSpace.index + 1 }, | ||
}); | ||
} | ||
}; | ||
var checkDoubleSpace = function () { | ||
tokensAndComments.forEach(function (leftToken, leftIndex) { | ||
if (isComment(leftToken)) { | ||
var _a = leftToken.range, start = _a[0], end = _a[1]; | ||
var comment = sourceCodeText.slice(start, end); | ||
if (comment.includes(PARAM)) { | ||
return; | ||
} | ||
var column = comment.indexOf(DOUBLE_SPACE); | ||
if (column >= 0) { | ||
context.report({ | ||
messageId: 'noDoubleSpaceError', | ||
node: leftToken, | ||
loc: { line: leftToken.loc.start.line, column: column }, | ||
}); | ||
} | ||
sourceCodeText.slice(start, end).split('\n') | ||
.forEach(function (comment) { return checkDoubleSpaceInComment(comment, leftToken); }); | ||
return; | ||
} | ||
var rightToken = tokensAndComments[leftIndex + 1]; | ||
if (shouldSkipToken(leftToken, leftIndex) || leftToken.loc.start.line < rightToken.loc.end.line) { | ||
if (shouldSkipToken(leftToken, leftIndex) || isComment(rightToken) || leftToken.loc.start.line < rightToken.loc.end.line) { | ||
return; | ||
@@ -66,5 +72,5 @@ } | ||
return { | ||
Program: checkSoubleSpace, | ||
Program: checkDoubleSpace, | ||
}; | ||
}, | ||
}); |
{ | ||
"name": "eslint-plugin-microsoft-typescript", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "ESlint rules for TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
22285
423
13