1
1
use super :: PatternLinter ;
2
2
use super :: { Lint , LintKind , Suggestion } ;
3
3
use crate :: make_title_case;
4
- use crate :: patterns:: { EitherPattern , IsNotTitleCase , Pattern , SequencePattern } ;
4
+ use crate :: patterns:: { EitherPattern , IsNotTitleCase , Pattern , SequencePattern , WordSet } ;
5
5
use crate :: FstDictionary ;
6
6
use crate :: { Token , TokenStringExt } ;
7
7
use std:: sync:: Arc ;
@@ -62,10 +62,7 @@ macro_rules! create_linter_for {
62
62
create_linter_for ! (
63
63
Americas ,
64
64
SequencePattern :: default ( )
65
- . then( Box :: new( EitherPattern :: new( vec![
66
- Box :: new( SequencePattern :: aco( "South" ) ) ,
67
- Box :: new( SequencePattern :: aco( "North" ) )
68
- ] ) ) )
65
+ . then( Box :: new( WordSet :: all( & [ "South" , "North" , ] ) ) )
69
66
. then_whitespace( )
70
67
. t_aco( "America" ) ,
71
68
"When referring to the continents, make sure to treat them as a proper noun."
@@ -74,10 +71,7 @@ create_linter_for!(
74
71
create_linter_for ! (
75
72
Koreas ,
76
73
SequencePattern :: default ( )
77
- . then( Box :: new( EitherPattern :: new( vec![
78
- Box :: new( SequencePattern :: aco( "South" ) ) ,
79
- Box :: new( SequencePattern :: aco( "North" ) )
80
- ] ) ) )
74
+ . then( Box :: new( WordSet :: all( & [ "South" , "North" , ] ) ) )
81
75
. then_whitespace( )
82
76
. t_aco( "Korea" ) ,
83
77
"When referring to the nations, make sure to treat them as a proper noun."
@@ -119,25 +113,27 @@ create_linter_for!(
119
113
Box :: new(
120
114
SequencePattern :: default ( )
121
115
. then( Box :: new( EitherPattern :: new( vec![
122
- Box :: new( SequencePattern :: aco( "Presidents'" ) ) ,
123
- Box :: new( SequencePattern :: aco( "Valentines" ) ) ,
124
- Box :: new( SequencePattern :: aco( "Christmas" ) ) ,
125
- Box :: new( SequencePattern :: aco( "Easter" ) ) ,
126
- Box :: new( SequencePattern :: aco( "Flag" ) ) ,
127
- Box :: new( SequencePattern :: aco( "Independence" ) ) ,
128
- Box :: new( SequencePattern :: aco( "Mothers'" ) ) ,
129
- Box :: new( SequencePattern :: aco( "New" ) . t_aco( "Years" ) ) ,
130
- Box :: new( SequencePattern :: aco( "Fathers'" ) ) ,
131
- Box :: new( SequencePattern :: aco( "Columbus" ) ) ,
132
- Box :: new( SequencePattern :: aco( "Thanksgiving" ) ) ,
133
- Box :: new( SequencePattern :: aco( "Memorial" ) ) ,
134
- Box :: new( SequencePattern :: aco( "May" ) ) ,
135
- Box :: new( SequencePattern :: aco( "Halloween" ) ) ,
136
- Box :: new( SequencePattern :: aco( "Tax" ) ) ,
137
- Box :: new( SequencePattern :: aco( "Parents" ) ) ,
138
- Box :: new( SequencePattern :: aco( "Veterans" ) ) ,
139
- Box :: new( SequencePattern :: aco( "Armistice" ) ) ,
140
- Box :: new( SequencePattern :: aco( "Groundhog" ) ) ,
116
+ Box :: new( WordSet :: all( & [
117
+ "Presidents'" ,
118
+ "Valentines" ,
119
+ "Christmas" ,
120
+ "Easter" ,
121
+ "Flag" ,
122
+ "Independence" ,
123
+ "Mothers'" ,
124
+ "Years" ,
125
+ "Fathers'" ,
126
+ "Columbus" ,
127
+ "Thanksgiving" ,
128
+ "Memorial" ,
129
+ "May" ,
130
+ "Halloween" ,
131
+ "Tax" ,
132
+ "Parents" ,
133
+ "Veterans" ,
134
+ "Armistice" ,
135
+ "Groundhog"
136
+ ] ) ) ,
141
137
Box :: new(
142
138
SequencePattern :: default ( )
143
139
. t_aco( "National" )
@@ -249,30 +245,30 @@ create_linter_for!(
249
245
SequencePattern :: default ( )
250
246
. t_aco( "Google" )
251
247
. then_whitespace( )
252
- . then( Box :: new( EitherPattern :: new ( vec! [
253
- Box :: new ( SequencePattern :: aco ( "Search" ) ) ,
254
- Box :: new ( SequencePattern :: aco ( "Cloud" ) ) ,
255
- Box :: new ( SequencePattern :: aco ( "Maps" ) ) ,
256
- Box :: new ( SequencePattern :: aco ( "Docs" ) ) ,
257
- Box :: new ( SequencePattern :: aco ( "Sheets" ) ) ,
258
- Box :: new ( SequencePattern :: aco ( "Slides" ) ) ,
259
- Box :: new ( SequencePattern :: aco ( "Drive" ) ) ,
260
- Box :: new ( SequencePattern :: aco ( "Meet" ) ) ,
261
- Box :: new ( SequencePattern :: aco ( "Gmail" ) ) ,
262
- Box :: new ( SequencePattern :: aco ( "Calendar" ) ) ,
263
- Box :: new ( SequencePattern :: aco ( "Chrome" ) ) ,
264
- Box :: new ( SequencePattern :: aco ( "ChromeOS" ) ) ,
265
- Box :: new ( SequencePattern :: aco ( "Android" ) ) ,
266
- Box :: new ( SequencePattern :: aco ( "Play" ) ) ,
267
- Box :: new ( SequencePattern :: aco ( "Bard" ) ) ,
268
- Box :: new ( SequencePattern :: aco ( "Gemini" ) ) ,
269
- Box :: new ( SequencePattern :: aco ( "YouTube" ) ) ,
270
- Box :: new ( SequencePattern :: aco ( "Photos" ) ) ,
271
- Box :: new ( SequencePattern :: aco ( "Analytics" ) ) ,
272
- Box :: new ( SequencePattern :: aco ( "AdSense" ) ) ,
273
- Box :: new ( SequencePattern :: aco ( "Pixel" ) ) ,
274
- Box :: new ( SequencePattern :: aco ( "Nest" ) ) ,
275
- Box :: new ( SequencePattern :: aco ( "Workspace" ) )
248
+ . then( Box :: new( WordSet :: all ( & [
249
+ "Search" ,
250
+ "Cloud" ,
251
+ "Maps" ,
252
+ "Docs" ,
253
+ "Sheets" ,
254
+ "Slides" ,
255
+ "Drive" ,
256
+ "Meet" ,
257
+ "Gmail" ,
258
+ "Calendar" ,
259
+ "Chrome" ,
260
+ "ChromeOS" ,
261
+ "Android" ,
262
+ "Play" ,
263
+ "Bard" ,
264
+ "Gemini" ,
265
+ "YouTube" ,
266
+ "Photos" ,
267
+ "Analytics" ,
268
+ "AdSense" ,
269
+ "Pixel" ,
270
+ "Nest" ,
271
+ "Workspace" ,
276
272
] ) ) ) ,
277
273
"When referring to Google products and services, make sure to treat them as proper nouns."
278
274
) ;
@@ -357,20 +353,22 @@ create_linter_for!(
357
353
. t_aco( "Microsoft" )
358
354
. then_whitespace( )
359
355
. then( Box :: new( EitherPattern :: new( vec![
360
- Box :: new( SequencePattern :: aco( "Windows" ) ) ,
361
- Box :: new( SequencePattern :: aco( "Office" ) ) ,
362
- Box :: new( SequencePattern :: aco( "Teams" ) ) ,
363
- Box :: new( SequencePattern :: aco( "Excel" ) ) ,
364
- Box :: new( SequencePattern :: aco( "PowerPoint" ) ) ,
365
- Box :: new( SequencePattern :: aco( "Word" ) ) ,
366
- Box :: new( SequencePattern :: aco( "Outlook" ) ) ,
367
- Box :: new( SequencePattern :: aco( "OneDrive" ) ) ,
368
- Box :: new( SequencePattern :: aco( "SharePoint" ) ) ,
369
- Box :: new( SequencePattern :: aco( "Xbox" ) ) ,
370
- Box :: new( SequencePattern :: aco( "Surface" ) ) ,
371
- Box :: new( SequencePattern :: aco( "Edge" ) ) ,
372
- Box :: new( SequencePattern :: aco( "Bing" ) ) ,
373
- Box :: new( SequencePattern :: aco( "Dynamics" ) ) ,
356
+ Box :: new( WordSet :: all( & [
357
+ "Windows" ,
358
+ "Office" ,
359
+ "Teams" ,
360
+ "Excel" ,
361
+ "PowerPoint" ,
362
+ "Word" ,
363
+ "Outlook" ,
364
+ "OneDrive" ,
365
+ "SharePoint" ,
366
+ "Xbox" ,
367
+ "Surface" ,
368
+ "Edge" ,
369
+ "Bing" ,
370
+ "Dynamics" ,
371
+ ] ) ) ,
374
372
Box :: new(
375
373
SequencePattern :: default ( )
376
374
. t_aco( "Visual" )
@@ -387,10 +385,10 @@ create_linter_for!(
387
385
. t_aco( "Apple" )
388
386
. then_whitespace( )
389
387
. then( Box :: new( EitherPattern :: new( vec![
390
- Box :: new( SequencePattern :: aco ( "iPhone" ) ) ,
391
- Box :: new ( SequencePattern :: aco ( " iPad") ) ,
392
- Box :: new ( SequencePattern :: aco ( "iMac" ) ) ,
393
- Box :: new ( SequencePattern :: aco ( "MacBook" ) ) ,
388
+ Box :: new( WordSet :: all ( & [
389
+ "iPhone" , " iPad", "iMac" , "MacBook" , "Watch" , "TV" , "Music" , "Arcade" , "iCloud" ,
390
+ "Safari" , "HomeKit" , "CarPlay" ,
391
+ ] ) ) ,
394
392
Box :: new(
395
393
SequencePattern :: aco( "MacBook" )
396
394
. then_whitespace( )
@@ -414,14 +412,6 @@ create_linter_for!(
414
412
. then_whitespace( )
415
413
. t_aco( "Max" )
416
414
) ,
417
- Box :: new( SequencePattern :: aco( "Watch" ) ) ,
418
- Box :: new( SequencePattern :: aco( "TV" ) ) ,
419
- Box :: new( SequencePattern :: aco( "Music" ) ) ,
420
- Box :: new( SequencePattern :: aco( "Arcade" ) ) ,
421
- Box :: new( SequencePattern :: aco( "iCloud" ) ) ,
422
- Box :: new( SequencePattern :: aco( "Safari" ) ) ,
423
- Box :: new( SequencePattern :: aco( "HomeKit" ) ) ,
424
- Box :: new( SequencePattern :: aco( "CarPlay" ) ) ,
425
415
Box :: new(
426
416
SequencePattern :: default ( )
427
417
. t_aco( "Vision" )
@@ -437,11 +427,9 @@ create_linter_for!(
437
427
SequencePattern :: aco( "Meta" )
438
428
. then_whitespace( )
439
429
. then( Box :: new( EitherPattern :: new( vec![
440
- Box :: new( SequencePattern :: aco( "Oculus" ) ) ,
441
- Box :: new( SequencePattern :: aco( "Portals" ) ) ,
442
- Box :: new( SequencePattern :: aco( "Quest" ) ) ,
443
- Box :: new( SequencePattern :: aco( "Gaming" ) ) ,
444
- Box :: new( SequencePattern :: aco( "Horizon" ) ) ,
430
+ Box :: new( WordSet :: all( & [
431
+ "Oculus" , "Portals" , "Quest" , "Gaming" , "Horizon" ,
432
+ ] ) ) ,
445
433
Box :: new(
446
434
SequencePattern :: default ( )
447
435
. t_aco( "Reality" )
0 commit comments