eslint-plugin-eslint-comments
Advanced tools
Comparing version 3.0.0-beta.0 to 3.0.0-beta.1
@@ -38,5 +38,20 @@ /** | ||
/** | ||
* Get the comment which is at a given message location. | ||
* @param {Message} message The message to get. | ||
* @param {SourceCode|undefined} sourceCode The source code object to get. | ||
* @returns {Comment|undefined} The gotten comment. | ||
*/ | ||
function getCommentAt(message, sourceCode) { | ||
if (sourceCode == null) { | ||
return undefined | ||
} | ||
const index = sourceCode.getIndexFromLoc(message) - 1 | ||
return sourceCode.getTokenByRangeStart(index, { includeComments: true }) | ||
} | ||
/** | ||
* Check whether a given message is a `reportUnusedDisableDirectives` error. | ||
* @param {Message} message The message. | ||
* @param {Comment} comment The comment which existed at the message location. | ||
* @param {Comment|undefined} comment The comment which existed at the message location. | ||
* @returns {boolean} `true` if the message is a `reportUnusedDisableDirectives` error. | ||
@@ -49,4 +64,3 @@ */ | ||
message.message.includes("eslint-disable") && | ||
comment != null && | ||
(comment.type === "Block" || comment.type === "Line") | ||
(comment == null || comment.type === "Block" || comment.type === "Line") | ||
) | ||
@@ -60,3 +74,3 @@ } | ||
* @param {Message} message The original message. | ||
* @param {Comment} comment The directive comment. | ||
* @param {Comment|undefined} comment The directive comment. | ||
* @returns {Message} The created error. | ||
@@ -75,11 +89,13 @@ */ | ||
if (targetRuleId) { | ||
const loc = toRuleIdLocation(comment, targetRuleId) | ||
clone.line = loc.start.line | ||
clone.column = loc.start.column + 1 | ||
clone.endLine = loc.end.line | ||
clone.endColumn = loc.end.column + 1 | ||
} else { | ||
clone.endLine = comment.loc.end.line | ||
clone.endColumn = comment.loc.end.column + 1 | ||
if (comment != null) { | ||
if (targetRuleId) { | ||
const loc = toRuleIdLocation(comment, targetRuleId) | ||
clone.line = loc.start.line | ||
clone.column = loc.start.column + 1 | ||
clone.endLine = loc.end.line | ||
clone.endColumn = loc.end.column + 1 | ||
} else { | ||
clone.endLine = comment.loc.end.line | ||
clone.endColumn = comment.loc.end.column + 1 | ||
} | ||
} | ||
@@ -93,3 +109,3 @@ | ||
* @param {Message[]} messages The original messages. | ||
* @param {SourceCode} sourceCode The source code object. | ||
* @param {SourceCode|undefined} sourceCode The source code object. | ||
* @param {string} ruleId The rule ID to convert. | ||
@@ -103,6 +119,4 @@ * @param {number} severity The severity of the rule. | ||
const message = messages[i] | ||
const rangeStart = sourceCode.getIndexFromLoc(message) - 1 | ||
const comment = sourceCode.getTokenByRangeStart(rangeStart, { | ||
includeComments: true, | ||
}) | ||
const comment = getCommentAt(message, sourceCode) | ||
if (!isUnusedDisableDirectiveError(message, comment)) { | ||
@@ -109,0 +123,0 @@ continue |
@@ -18,3 +18,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/disable-enable-pair.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/disable-enable-pair.md", | ||
}, | ||
@@ -21,0 +21,0 @@ fixable: null, |
@@ -18,3 +18,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-aggregating-enable.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-aggregating-enable.md", | ||
}, | ||
@@ -21,0 +21,0 @@ fixable: null, |
@@ -17,3 +17,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-duplicate-disable.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-duplicate-disable.md", | ||
}, | ||
@@ -20,0 +20,0 @@ fixable: null, |
@@ -19,3 +19,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-restricted-disable.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-restricted-disable.md", | ||
}, | ||
@@ -22,0 +22,0 @@ fixable: null, |
@@ -22,3 +22,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-unlimited-disable.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-unlimited-disable.md", | ||
}, | ||
@@ -25,0 +25,0 @@ fixable: null, |
@@ -17,3 +17,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-unused-disable.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-unused-disable.md", | ||
}, | ||
@@ -20,0 +20,0 @@ fixable: null, |
@@ -17,3 +17,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-unused-enable.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-unused-enable.md", | ||
}, | ||
@@ -20,0 +20,0 @@ fixable: null, |
@@ -20,3 +20,3 @@ /** | ||
url: | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.0/docs/rules/no-use.md", | ||
"https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/v3.0.0-beta.1/docs/rules/no-use.md", | ||
}, | ||
@@ -23,0 +23,0 @@ fixable: null, |
{ | ||
"name": "eslint-plugin-eslint-comments", | ||
"version": "3.0.0-beta.0", | ||
"version": "3.0.0-beta.1", | ||
"description": "Additional ESLint rules for ESLint directive comments.", | ||
@@ -5,0 +5,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36984
852