@blitz/eslint-plugin
Advanced tools
Comparing version 0.0.42 to 0.0.43
@@ -19,2 +19,3 @@ "use strict"; | ||
const LIST_ITEM = /^\s*\*\s*(?:-|\d\.)/; | ||
const LIST_ITEM_INDENTATION = /^\s*\*(\s*(?:-|\d[.:)])\s*)/; | ||
const LINE_INFO = '\n\nLine: {{line}}'; | ||
@@ -102,3 +103,3 @@ function isCapital(char) { | ||
Program() { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
const { ignoredWords, allowedParagraphEndings } = Object.assign(Object.assign({}, exports.defaultOptions), options); | ||
@@ -141,2 +142,3 @@ const source = context.getSourceCode(); | ||
let jsdocContinuation = false; | ||
let prevListItemIndentation; | ||
for (let i = 0; i < lines.length; i++) { | ||
@@ -175,3 +177,3 @@ const line = lines[i]; | ||
} | ||
if (isCurrentLineJSDoc) { | ||
if (isCurrentLineJSDoc && !insideCodeBlock) { | ||
if (prevLine && !EMPTY_BLOCK_COMMENT_LINE.test(prevLine) && !JS_DOC_REGEX.test(prevLine)) { | ||
@@ -192,3 +194,5 @@ context.report({ node: comment, messageId: 'spaceBeforeJSDoc', data: Object.assign({}, lineData) }); | ||
const listItemText = line.replace(LIST_ITEM, ''); | ||
if (listItemText[0] !== ' ') { | ||
const spaces = (_b = listItemText.match(/^(\s+)/g)) === null || _b === void 0 ? void 0 : _b[0].length; | ||
prevListItemIndentation = (_c = line.match(LIST_ITEM_INDENTATION)) === null || _c === void 0 ? void 0 : _c[1].length; | ||
if (spaces !== 1) { | ||
context.report({ node: comment, messageId: 'invalidListItem', data: Object.assign({}, lineData) }); | ||
@@ -199,2 +203,16 @@ break; | ||
} | ||
/** | ||
* If we saw a list item before we check if the current line has the same indentation. | ||
* If not, we simply continue. | ||
*/ | ||
if (prevListItemIndentation != null && prevListItemIndentation > 0) { | ||
const currentLineIdentation = (_d = line.match(/^\s*\*(\s*)/)) === null || _d === void 0 ? void 0 : _d[1].length; | ||
if (currentLineIdentation === prevListItemIndentation) { | ||
continue; | ||
} | ||
else { | ||
// indentation is different so we reset the state and continue with checking other rules | ||
prevListItemIndentation = undefined; | ||
} | ||
} | ||
if (newParagraph && !jsdocContinuation) { | ||
@@ -201,0 +219,0 @@ const text = line.replace(/^\s*\*\s*/, ''); |
{ | ||
"name": "@blitz/eslint-plugin", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"description": "An ESLint config to enforce a consistent code styles across StackBlitz projects", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
71657
28
889
3