Skip to content

New rule directive-comment doesn't work as expected #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bozzaj opened this issue Jan 8, 2018 · 1 comment
Closed

New rule directive-comment doesn't work as expected #334

bozzaj opened this issue Jan 8, 2018 · 1 comment

Comments

@bozzaj
Copy link

bozzaj commented Jan 8, 2018

eslint-plugin-vue Version: 4.1.0
eslint Version: 4.14.0

The directive-comment rule has an issue with the way the regular expressions are calculated. Consider the following line:
<!-- eslint-disable-next-line max-len -->

This should disable the rule max-len for the next line only. However, the current implementation disables the rule for the remainder of the file. This seems to be with the block regexp:
const COMMENT_DIRECTIVE_B = /^\s*(eslint-(?:en|dis)able)\s*(?:(\S|\S[\s\S]*\S)\s*)?$/

This matches the above line as such:
match[1] = 'eslint-disable'
match[2] = '-next-line max-len'

and that gets passed as a successful parse, causing eslint to disable max-len for the remainder of the file.

I couldn't work out a good regexp that would match "eslint-disable" (with no space between the statement and the --> for the comment) correctly so another alternative fix would be to call processLine() first and if that is successful, don't call processBlock().

@mysticatea
Copy link
Member

mysticatea commented Jan 8, 2018

Thank you for the report.

It has been fixed on master: #331. Please wait for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants