1
1
// LICENSE : MIT
2
2
"use strict" ;
3
3
import StatusManager from "./StatusManager" ;
4
- import { parseRuleIds , getValueFromHTMLComment , isHTMLComment } from "./parse-comment" ;
4
+ import { parseRuleIds , getValuesFromHTMLComment , isHTMLComment } from "./parse-comment" ;
5
5
const defaultOptions = {
6
6
// enable comment directive
7
7
// if comment has the value, then enable textlint rule
@@ -10,7 +10,7 @@ const defaultOptions = {
10
10
// if comment has the value, then disable textlint rule
11
11
"disablingComment" : "textlint-disable"
12
12
} ;
13
- module . exports = function ( context , options = defaultOptions ) {
13
+ module . exports = function ( context , options = defaultOptions ) {
14
14
const { Syntax, shouldIgnore, getSource} = context ;
15
15
16
16
const enablingComment = options . enablingComment || defaultOptions . enablingComment ;
@@ -42,14 +42,16 @@ This is ignored.
42
42
if ( ! isHTMLComment ( nodeValue ) ) {
43
43
return ;
44
44
}
45
- const commentValue = getValueFromHTMLComment ( nodeValue ) ;
46
- if ( commentValue . indexOf ( enablingComment ) !== - 1 ) {
47
- const configValue = commentValue . replace ( enablingComment , "" ) ;
48
- statusManager . enableReporting ( node , parseRuleIds ( configValue ) ) ;
49
- } else if ( commentValue . indexOf ( disablingComment ) !== - 1 ) {
50
- const configValue = commentValue . replace ( disablingComment , "" ) ;
51
- statusManager . disableReporting ( node , parseRuleIds ( configValue ) ) ;
52
- }
45
+ const comments = getValuesFromHTMLComment ( nodeValue ) ;
46
+ comments . forEach ( commentValue => {
47
+ if ( commentValue . indexOf ( enablingComment ) !== - 1 ) {
48
+ const configValue = commentValue . replace ( enablingComment , "" ) ;
49
+ statusManager . enableReporting ( node , parseRuleIds ( configValue ) ) ;
50
+ } else if ( commentValue . indexOf ( disablingComment ) !== - 1 ) {
51
+ const configValue = commentValue . replace ( disablingComment , "" ) ;
52
+ statusManager . disableReporting ( node , parseRuleIds ( configValue ) ) ;
53
+ }
54
+ } ) ;
53
55
} ,
54
56
[ Syntax . Comment ] ( node ) {
55
57
const commentValue = node . value || "" ;
0 commit comments