11// LICENSE : MIT
22"use strict" ;
33import StatusManager from "./StatusManager" ;
4- import { parseRuleIds , getValueFromHTMLComment , isHTMLComment } from "./parse-comment" ;
4+ import { parseRuleIds , getValuesFromHTMLComment , isHTMLComment } from "./parse-comment" ;
55const defaultOptions = {
66 // enable comment directive
77 // if comment has the value, then enable textlint rule
@@ -10,7 +10,7 @@ const defaultOptions = {
1010 // if comment has the value, then disable textlint rule
1111 "disablingComment" : "textlint-disable"
1212} ;
13- module . exports = function ( context , options = defaultOptions ) {
13+ module . exports = function ( context , options = defaultOptions ) {
1414 const { Syntax, shouldIgnore, getSource} = context ;
1515
1616 const enablingComment = options . enablingComment || defaultOptions . enablingComment ;
@@ -42,14 +42,16 @@ This is ignored.
4242 if ( ! isHTMLComment ( nodeValue ) ) {
4343 return ;
4444 }
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+ } ) ;
5355 } ,
5456 [ Syntax . Comment ] ( node ) {
5557 const commentValue = node . value || "" ;
0 commit comments