From 53184098820eb63478167d1d7440638fa92994eb Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sun, 7 Jan 2018 16:29:26 +0900 Subject: [PATCH] Fix: unintentional disabling --- lib/rules/comment-directive.js | 4 ++-- tests/lib/rules/comment-directive.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/rules/comment-directive.js b/lib/rules/comment-directive.js index 4afe81095..1e53749d4 100644 --- a/lib/rules/comment-directive.js +++ b/lib/rules/comment-directive.js @@ -8,8 +8,8 @@ // Helpers // ----------------------------------------------------------------------------- -const COMMENT_DIRECTIVE_B = /^\s*(eslint-(?:en|dis)able)\s*(?:(\S|\S[\s\S]*\S)\s*)?$/ -const COMMENT_DIRECTIVE_L = /^\s*(eslint-disable(?:-next)?-line)\s*(?:(\S|\S[\s\S]*\S)\s*)?$/ +const COMMENT_DIRECTIVE_B = /^\s*(eslint-(?:en|dis)able)(?:\s+(\S|\S[\s\S]*\S))?\s*$/ +const COMMENT_DIRECTIVE_L = /^\s*(eslint-disable(?:-next)?-line)(?:\s+(\S|\S[\s\S]*\S))?\s*$/ /** * Parse a given comment. diff --git a/tests/lib/rules/comment-directive.js b/tests/lib/rules/comment-directive.js index 32de76a68..367d29dd8 100644 --- a/tests/lib/rules/comment-directive.js +++ b/tests/lib/rules/comment-directive.js @@ -191,5 +191,22 @@ describe('comment-directive', () => { assert.deepEqual(messages[0].ruleId, 'vue/no-parsing-error') assert.deepEqual(messages[1].ruleId, 'vue/no-duplicate-attributes') }) + + it('should affect only the next line', () => { + const code = ` + + ` + const messages = linter.executeOnText(code, 'test.vue').results[0].messages + + assert.deepEqual(messages.length, 2) + assert.deepEqual(messages[0].ruleId, 'vue/no-parsing-error') + assert.deepEqual(messages[0].line, 5) + assert.deepEqual(messages[1].ruleId, 'vue/no-duplicate-attributes') + assert.deepEqual(messages[1].line, 5) + }) }) })