11/**
2- * @author Toru Nagashima
3- * @copyright 2016 Toru Nagashima. All rights reserved.
2+ * @author Toru Nagashima <https://github.com/mysticatea>
43 * See LICENSE file in root directory for full license.
54 */
65"use strict"
76
8- //------------------------------------------------------------------------------
9- // Requirements
10- //------------------------------------------------------------------------------
11-
127const utils = require ( "./utils" )
13-
14- //------------------------------------------------------------------------------
15- // Helpers
16- //------------------------------------------------------------------------------
17-
188const COMMENT_DIRECTIVE = / ^ \s * ( e s l i n t - (?: e n | d i s ) a b l e (?: (?: - n e x t ) ? - l i n e ) ? ) \s * (?: ( \S | \S [ \s \S ] * \S ) \s * ) ? $ /
199const DELIMITER = / [ \s , ] + / g
2010const pool = new WeakMap ( )
2111
22- //------------------------------------------------------------------------------
23- // Exports
24- //------------------------------------------------------------------------------
25-
2612module . exports = class DisabledArea {
2713 /**
2814 * Get singleton instance for the given source code.
@@ -78,8 +64,7 @@ module.exports = class DisabledArea {
7864 reported : false ,
7965 } )
8066 }
81- }
82- else {
67+ } else {
8368 if ( this . _getArea ( null , location ) != null ) {
8469 this . duplicateDisableDirectives . push ( { comment, ruleId : null } )
8570 }
@@ -115,7 +100,11 @@ module.exports = class DisabledArea {
115100 for ( let i = this . areas . length - 1 ; i >= 0 ; -- i ) {
116101 const area = this . areas [ i ]
117102
118- if ( area . end === null && area . kind === kind && area . ruleId === ruleId ) {
103+ if (
104+ area . end === null &&
105+ area . kind === kind &&
106+ area . ruleId === ruleId
107+ ) {
119108 relatedDisableDirectives . add ( area . comment )
120109 area . end = location
121110 used = true
@@ -126,8 +115,7 @@ module.exports = class DisabledArea {
126115 this . unusedEnableDirectives . push ( { comment, ruleId } )
127116 }
128117 }
129- }
130- else {
118+ } else {
131119 let used = false
132120
133121 for ( let i = this . areas . length - 1 ; i >= 0 ; -- i ) {
@@ -145,7 +133,10 @@ module.exports = class DisabledArea {
145133 }
146134 }
147135
148- this . numberOfRelatedDisableDirectives . set ( comment , relatedDisableDirectives . size )
136+ this . numberOfRelatedDisableDirectives . set (
137+ comment ,
138+ relatedDisableDirectives . size
139+ )
149140 }
150141
151142 /**
@@ -160,7 +151,8 @@ module.exports = class DisabledArea {
160151 for ( let i = this . areas . length - 1 ; i >= 0 ; -- i ) {
161152 const area = this . areas [ i ]
162153
163- if ( ( area . ruleId === null || area . ruleId === ruleId ) &&
154+ if (
155+ ( area . ruleId === null || area . ruleId === ruleId ) &&
164156 utils . lte ( area . start , location ) &&
165157 ( area . end === null || utils . lte ( location , area . end ) )
166158 ) {
@@ -189,19 +181,22 @@ module.exports = class DisabledArea {
189181
190182 if ( comment . type === "Block" && kind === "eslint-disable" ) {
191183 this . _disable ( comment , comment . loc . start , ruleIds , "block" )
192- }
193- else if ( comment . type === "Block" && kind === "eslint-enable" ) {
184+ } else if ( comment . type === "Block" && kind === "eslint-enable" ) {
194185 this . _enable ( comment , comment . loc . start , ruleIds , "block" )
195- }
196- else if ( comment . type === "Line" && kind === "eslint-disable-line" ) {
186+ } else if (
187+ comment . type === "Line" &&
188+ kind === "eslint-disable-line"
189+ ) {
197190 const line = comment . loc . start . line
198191 const start = { line, column : 0 }
199192 const end = { line : line + 1 , column : - 1 }
200193
201194 this . _disable ( comment , start , ruleIds , "line" )
202195 this . _enable ( comment , end , ruleIds , "line" )
203- }
204- else if ( comment . type === "Line" && kind === "eslint-disable-next-line" ) {
196+ } else if (
197+ comment . type === "Line" &&
198+ kind === "eslint-disable-next-line"
199+ ) {
205200 const line = comment . loc . start . line
206201 const start = { line : line + 1 , column : 0 }
207202 const end = { line : line + 2 , column : - 1 }
0 commit comments