@@ -54,6 +54,7 @@ type Options = [
5454 {
5555 readonly boundTextAllowedPattern ?: string ;
5656 readonly checkAttributes ?: boolean ;
57+ readonly checkDuplicateId ?: boolean ;
5758 readonly checkId ?: boolean ;
5859 readonly checkText ?: boolean ;
5960 readonly ignoreAttributes ?: readonly string [ ] ;
@@ -91,6 +92,7 @@ export const RULE_NAME = 'i18n';
9192const DEFAULT_OPTIONS : Options [ number ] = {
9293 checkAttributes : true ,
9394 checkId : true ,
95+ checkDuplicateId : true ,
9496 checkText : true ,
9597 ignoreAttributes : [ ...DEFAULT_ALLOWED_ATTRIBUTES ] ,
9698} ;
@@ -129,6 +131,10 @@ export default createESLintRule<Options, MessageIds>({
129131 type : 'boolean' ,
130132 default : DEFAULT_OPTIONS . checkAttributes ,
131133 } ,
134+ checkDuplicateId : {
135+ type : 'boolean' ,
136+ default : DEFAULT_OPTIONS . checkDuplicateId ,
137+ } ,
132138 checkId : {
133139 type : 'boolean' ,
134140 default : DEFAULT_OPTIONS . checkId ,
@@ -176,6 +182,7 @@ export default createESLintRule<Options, MessageIds>({
176182 boundTextAllowedPattern,
177183 checkAttributes,
178184 checkId,
185+ checkDuplicateId,
179186 checkText,
180187 ignoreAttributes,
181188 ignoreTags,
@@ -307,18 +314,20 @@ export default createESLintRule<Options, MessageIds>({
307314 }
308315
309316 function reportDuplicatedCustomIds ( ) {
310- for ( const [ customId , sourceSpans ] of collectedCustomIds ) {
311- if ( sourceSpans . length <= 1 ) {
312- break ;
313- }
314-
315- for ( const sourceSpan of sourceSpans ) {
316- const loc = parserServices . convertNodeSourceSpanToLoc ( sourceSpan ) ;
317- context . report ( {
318- messageId : 'i18nDuplicateCustomId' ,
319- loc,
320- data : { customId } ,
321- } ) ;
317+ if ( checkDuplicateId ) {
318+ for ( const [ customId , sourceSpans ] of collectedCustomIds ) {
319+ if ( sourceSpans . length <= 1 ) {
320+ break ;
321+ }
322+
323+ for ( const sourceSpan of sourceSpans ) {
324+ const loc = parserServices . convertNodeSourceSpanToLoc ( sourceSpan ) ;
325+ context . report ( {
326+ messageId : 'i18nDuplicateCustomId' ,
327+ loc,
328+ data : { customId } ,
329+ } ) ;
330+ }
322331 }
323332 }
324333
0 commit comments