diff --git a/lib/rules/line-comment-position.js b/lib/rules/line-comment-position.js index 99aea02b8f3..4327e70e1af 100644 --- a/lib/rules/line-comment-position.js +++ b/lib/rules/line-comment-position.js @@ -59,7 +59,7 @@ module.exports = { above = !options || options === "above"; } else { - above = options.position === "above"; + above = !options.position || options.position === "above"; ignorePattern = options.ignorePattern; if (options.hasOwnProperty("applyDefaultIgnorePatterns")) { diff --git a/tests/lib/rules/line-comment-position.js b/tests/lib/rules/line-comment-position.js index fcc70c9fa8b..546ca1581b3 100644 --- a/tests/lib/rules/line-comment-position.js +++ b/tests/lib/rules/line-comment-position.js @@ -76,6 +76,10 @@ ruleTester.run("line-comment-position", rule, { { code: "// pragma valid comment\n1 + 1;", options: [{ position: "beside", ignorePattern: "pragma|linter" }] + }, + { + code: "// above\n1 + 1; // ignored", + options: [{ ignorePattern: "ignored" }] } ],