-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
docs: check config comments in rule examples #17815
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -962,6 +962,15 @@ class SourceCode extends TokenStore { | |
varsCache.set("configGlobals", configGlobals); | ||
} | ||
|
||
static parseDirective(commentValue) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely! I'll do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, it's updated in in b14bf59. I also took the opportunity to add some unit tests and to remove a duplication in lib/linter/linter.js. |
||
const { directivePart } = extractDirectiveComment(commentValue); | ||
const match = directivesPattern.exec(directivePart); | ||
const directiveText = match[1]; | ||
const directiveValue = directivePart.slice(match.index + directiveText.length); | ||
|
||
return { directiveText, directiveValue }; | ||
} | ||
|
||
/** | ||
* Applies configuration found inside of the source code. This method is only | ||
* called when ESLint is running with inline configuration allowed. | ||
|
@@ -977,10 +986,7 @@ class SourceCode extends TokenStore { | |
|
||
this.getInlineConfigNodes().forEach(comment => { | ||
|
||
const { directivePart } = extractDirectiveComment(comment.value); | ||
const match = directivesPattern.exec(directivePart); | ||
const directiveText = match[1]; | ||
const directiveValue = directivePart.slice(match.index + directiveText.length); | ||
const { directiveText, directiveValue } = SourceCode.parseDirective(comment.value); | ||
|
||
switch (directiveText) { | ||
case "exported": | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some examples in this rule show the functioning of a removed option. These examples cannot be possibly tested in the Playground, so I removed correct/incorrect fences to prevent validation. The disadvantage of this solution is that it also removes the badges from the blocks on the website. Alternatively, we could add a new option to remove the "Open in Playground" buttons but keep the badges. Since this is the only rule I found that shows a removed option, I'm not sure if that effort would be justified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine, as those examples do not represent how the current version of this rule works.