@@ -332,8 +332,74 @@ export default createEslintRule<SortClassesOptions, MESSAGE_ID>({
332
332
let selectors : Selector [ ] = [ ]
333
333
let addSafetySemicolonWhenInline : boolean = true
334
334
switch ( member . type ) {
335
+ case 'TSAbstractPropertyDefinition' :
336
+ case 'PropertyDefinition' :
337
+ /**
338
+ * Member is necessarily a property similarly to above for methods,
339
+ * prioritize 'static', 'declare', 'decorated', 'abstract',
340
+ * 'override' and 'readonly' over accessibility modifiers.
341
+ */
342
+ if ( 'static' in member && member . static ) {
343
+ modifiers . push ( 'static' )
344
+ }
345
+
346
+ if ( 'declare' in member && member . declare ) {
347
+ modifiers . push ( 'declare' )
348
+ }
349
+
350
+ if ( member . type === 'TSAbstractPropertyDefinition' ) {
351
+ modifiers . push ( 'abstract' )
352
+ }
353
+
354
+ if ( decorated ) {
355
+ modifiers . push ( 'decorated' )
356
+ }
357
+
358
+ if ( 'override' in member && member . override ) {
359
+ modifiers . push ( 'override' )
360
+ }
361
+
362
+ if ( 'readonly' in member && member . readonly ) {
363
+ modifiers . push ( 'readonly' )
364
+ }
365
+
366
+ if (
367
+ 'accessibility' in member &&
368
+ member . accessibility === 'protected'
369
+ ) {
370
+ modifiers . push ( 'protected' )
371
+ } else if (
372
+ ( 'accessibility' in member &&
373
+ member . accessibility === 'private' ) ||
374
+ isPrivateHash
375
+ ) {
376
+ modifiers . push ( 'private' )
377
+ } else {
378
+ modifiers . push ( 'public' )
379
+ }
380
+
381
+ if ( 'optional' in member && member . optional ) {
382
+ modifiers . push ( 'optional' )
383
+ }
384
+
385
+ if (
386
+ member . value ?. type === 'ArrowFunctionExpression' ||
387
+ member . value ?. type === 'FunctionExpression'
388
+ ) {
389
+ if ( member . value . async ) {
390
+ modifiers . push ( 'async' )
391
+ }
392
+ selectors . push ( 'function-property' )
393
+ } else if ( member . value ) {
394
+ memberValue = sourceCode . getText ( member . value )
395
+ dependencies = extractDependencies ( member . value , member . static )
396
+ }
397
+
398
+ selectors . push ( 'property' )
399
+ break
400
+
335
401
case 'TSAbstractMethodDefinition' :
336
- case 'MethodDefinition' : {
402
+ case 'MethodDefinition' :
337
403
/**
338
404
* By putting the static modifier before accessibility modifiers, we
339
405
* prioritize 'static' over those in cases like:
@@ -389,9 +455,9 @@ export default createEslintRule<SortClassesOptions, MESSAGE_ID>({
389
455
selectors . push ( 'method' )
390
456
391
457
break
392
- }
458
+
393
459
case 'TSAbstractAccessorProperty' :
394
- case 'AccessorProperty' : {
460
+ case 'AccessorProperty' :
395
461
if ( member . static ) {
396
462
modifiers . push ( 'static' )
397
463
}
@@ -418,8 +484,8 @@ export default createEslintRule<SortClassesOptions, MESSAGE_ID>({
418
484
selectors . push ( 'accessor-property' )
419
485
420
486
break
421
- }
422
- case 'TSIndexSignature' : {
487
+
488
+ case 'TSIndexSignature' :
423
489
if ( member . static ) {
424
490
modifiers . push ( 'static' )
425
491
}
@@ -431,87 +497,15 @@ export default createEslintRule<SortClassesOptions, MESSAGE_ID>({
431
497
selectors . push ( 'index-signature' )
432
498
433
499
break
434
- }
435
- case 'StaticBlock' : {
500
+
501
+ case 'StaticBlock' :
436
502
addSafetySemicolonWhenInline = false
437
503
438
504
selectors . push ( 'static-block' )
439
505
440
506
dependencies = extractDependencies ( member , true )
441
507
442
508
break
443
- }
444
- default : {
445
- /**
446
- * Member is necessarily a property similarly to above for methods,
447
- * prioritize 'static', 'declare', 'decorated', 'abstract',
448
- * 'override' and 'readonly' over accessibility modifiers.
449
- */
450
- if ( 'static' in member && member . static ) {
451
- modifiers . push ( 'static' )
452
- }
453
-
454
- if ( 'declare' in member && member . declare ) {
455
- modifiers . push ( 'declare' )
456
- }
457
-
458
- if ( member . type === 'TSAbstractPropertyDefinition' ) {
459
- modifiers . push ( 'abstract' )
460
- }
461
-
462
- if ( decorated ) {
463
- modifiers . push ( 'decorated' )
464
- }
465
-
466
- if ( 'override' in member && member . override ) {
467
- modifiers . push ( 'override' )
468
- }
469
-
470
- if ( 'readonly' in member && member . readonly ) {
471
- modifiers . push ( 'readonly' )
472
- }
473
-
474
- if (
475
- 'accessibility' in member &&
476
- member . accessibility === 'protected'
477
- ) {
478
- modifiers . push ( 'protected' )
479
- } else if (
480
- ( 'accessibility' in member &&
481
- member . accessibility === 'private' ) ||
482
- isPrivateHash
483
- ) {
484
- modifiers . push ( 'private' )
485
- } else {
486
- modifiers . push ( 'public' )
487
- }
488
-
489
- if ( 'optional' in member && member . optional ) {
490
- modifiers . push ( 'optional' )
491
- }
492
-
493
- if ( 'value' in member && member . value ) {
494
- if (
495
- member . value . type === 'ArrowFunctionExpression' ||
496
- member . value . type === 'FunctionExpression'
497
- ) {
498
- if ( member . value . async ) {
499
- modifiers . push ( 'async' )
500
- }
501
- selectors . push ( 'function-property' )
502
- } else {
503
- memberValue = sourceCode . getText ( member . value )
504
- }
505
- if ( member . value . type !== 'TSEmptyBodyFunctionExpression' ) {
506
- dependencies = extractDependencies (
507
- member . value ,
508
- member . static ,
509
- )
510
- }
511
- }
512
-
513
- selectors . push ( 'property' )
514
- }
515
509
}
516
510
517
511
let predefinedGroups = generatePredefinedGroups ( {
0 commit comments