Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9183385

Browse files
committed
fix(eslint-plugin)!: [sort-keys-in-type-decorator] default orders now include all known keys
1 parente2b46ef commit9183385

File tree

5 files changed

+290
-38
lines changed

5 files changed

+290
-38
lines changed

‎packages/eslint-plugin-template/docs/rules/prefer-template-literal.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,32 +2310,6 @@ The rule does not have any configuration options.
23102310

23112311
####✅ Valid Code
23122312

2313-
```html
2314-
@let bugWithQuote = `${`'`}`
2315-
```
2316-
2317-
<br>
2318-
2319-
---
2320-
2321-
<br>
2322-
2323-
####Default Config
2324-
2325-
```json
2326-
{
2327-
"rules": {
2328-
"@angular-eslint/template/prefer-template-literal": [
2329-
"error"
2330-
]
2331-
}
2332-
}
2333-
```
2334-
2335-
<br>
2336-
2337-
####✅ Valid Code
2338-
23392313
```html
23402314
<h1>{{ `prefix-${value}-suffix` }}</h1>
23412315
```

‎packages/eslint-plugin-template/src/rules/prefer-template-literal.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ export default createESLintRule<Options, MessageIds>({
133133
// Fix the left side - handle parenthesized expressions specially
134134
if(originalLeftinstanceofParenthesizedExpression){
135135
fixes.push(
136-
...getLeftSideFixesForParenthesized(fixer,left,originalLeft,quote),
136+
...getLeftSideFixesForParenthesized(
137+
fixer,
138+
left,
139+
originalLeft,
140+
quote,
141+
),
137142
);
138143
}else{
139144
fixes.push(...getLeftSideFixes(fixer,left,quote));
@@ -185,7 +190,11 @@ export default createESLintRule<Options, MessageIds>({
185190
},
186191
});
187192

188-
functiongetLeftSideFixes(fixer:RuleFixer,left:AST,quote:Quote|''):readonlyRuleFix[]{
193+
functiongetLeftSideFixes(
194+
fixer:RuleFixer,
195+
left:AST,
196+
quote:Quote|'',
197+
):readonlyRuleFix[]{
189198
const{ start, end}=left.sourceSpan;
190199

191200
if(leftinstanceofTemplateLiteral){
@@ -253,7 +262,11 @@ function getLeftSideFixesForParenthesized(
253262
];
254263
}
255264

256-
functiongetRightSideFixes(fixer:RuleFixer,right:AST,quote:Quote|''):readonlyRuleFix[]{
265+
functiongetRightSideFixes(
266+
fixer:RuleFixer,
267+
right:AST,
268+
quote:Quote|'',
269+
):readonlyRuleFix[]{
257270
const{ start, end}=right.sourceSpan;
258271

259272
if(rightinstanceofTemplateLiteral){

‎packages/eslint-plugin/docs/rules/sort-keys-in-type-decorator.md

Lines changed: 161 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ The rule accepts an options object with the following properties:
2929
```ts
3030
interfaceOptions {
3131
/**
32-
* Default: `["selector","imports","standalone","templateUrl","template","styleUrl","styleUrls","styles","encapsulation","changeDetection"]`
32+
* Default: `["selector","imports","standalone","templateUrl","template","styleUrl","styleUrls","styles","providers","changeDetection","encapsulation","viewProviders","host","hostDirectives","inputs","outputs","animations","schemas","exportAs","queries","preserveWhitespaces","jit","moduleId","interpolation"]`
3333
*/
3434
Component?:string[];
3535
/**
36-
* Default: `["selector","standalone"]`
36+
* Default: `["selector","standalone","providers","host","hostDirectives","inputs","outputs","exportAs","queries","jit"]`
3737
*/
3838
Directive?:string[];
3939
/**
40-
* Default: `["declarations","imports","exports","providers","bootstrap"]`
40+
* Default: `["id","imports","declarations","providers","exports","bootstrap","schemas","jit"]`
4141
*/
4242
NgModule?:string[];
4343
/**
44-
* Default: `["name","standalone"]`
44+
* Default: `["name","standalone","pure"]`
4545
*/
4646
Pipe?:string[];
4747
}
@@ -553,6 +553,163 @@ class Test {
553553

554554
####✅ Valid Code
555555

556+
```ts
557+
@Component({
558+
selector:'app-test',
559+
imports: [CommonModule],
560+
standalone:true,
561+
templateUrl:'./test.component.html',
562+
template:'<div>Test</div>',
563+
styleUrl:'./test.component.css',
564+
styleUrls: ['./test.component.css'],
565+
styles: ['div { color: red; }'],
566+
providers: [TestService],
567+
changeDetection:ChangeDetectionStrategy.OnPush,
568+
encapsulation:ViewEncapsulation.None,
569+
viewProviders: [ViewService],
570+
host: {'[class.test]':'true' },
571+
hostDirectives: [TestDirective],
572+
inputs: ['value'],
573+
outputs: ['change'],
574+
animations: [trigger('test', [])],
575+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
576+
exportAs:'appTest',
577+
queries: { contentChild:newContentChild('test') },
578+
preserveWhitespaces:false,
579+
jit:true,
580+
moduleId:'test-module',
581+
interpolation: ['{{','}}']
582+
})
583+
exportclassTestComponent {}
584+
```
585+
586+
<br>
587+
588+
---
589+
590+
<br>
591+
592+
####Default Config
593+
594+
```json
595+
{
596+
"rules": {
597+
"@angular-eslint/sort-keys-in-type-decorator": [
598+
"error"
599+
]
600+
}
601+
}
602+
```
603+
604+
<br>
605+
606+
####✅ Valid Code
607+
608+
```ts
609+
@Directive({
610+
selector:'[appTest]',
611+
standalone:true,
612+
providers: [TestService],
613+
host: {'[class.test]':'true' },
614+
hostDirectives: [OtherDirective],
615+
inputs: ['value'],
616+
outputs: ['change'],
617+
exportAs:'appTest',
618+
queries: { contentChild:newContentChild('test') },
619+
jit:true
620+
})
621+
exportclassTestDirective {}
622+
```
623+
624+
<br>
625+
626+
---
627+
628+
<br>
629+
630+
####Default Config
631+
632+
```json
633+
{
634+
"rules": {
635+
"@angular-eslint/sort-keys-in-type-decorator": [
636+
"error"
637+
]
638+
}
639+
}
640+
```
641+
642+
<br>
643+
644+
####✅ Valid Code
645+
646+
```ts
647+
@NgModule({
648+
id:'test-module',
649+
imports: [CommonModule],
650+
declarations: [TestComponent],
651+
providers: [TestService],
652+
exports: [TestComponent],
653+
bootstrap: [AppComponent],
654+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
655+
jit:true
656+
})
657+
exportclassTestModule {}
658+
```
659+
660+
<br>
661+
662+
---
663+
664+
<br>
665+
666+
####Default Config
667+
668+
```json
669+
{
670+
"rules": {
671+
"@angular-eslint/sort-keys-in-type-decorator": [
672+
"error"
673+
]
674+
}
675+
}
676+
```
677+
678+
<br>
679+
680+
####✅ Valid Code
681+
682+
```ts
683+
@Pipe({
684+
name:'testPipe',
685+
standalone:true,
686+
pure:false
687+
})
688+
exportclassTestPipe {}
689+
```
690+
691+
<br>
692+
693+
---
694+
695+
<br>
696+
697+
####Default Config
698+
699+
```json
700+
{
701+
"rules": {
702+
"@angular-eslint/sort-keys-in-type-decorator": [
703+
"error"
704+
]
705+
}
706+
}
707+
```
708+
709+
<br>
710+
711+
####✅ Valid Code
712+
556713
```ts
557714
@Type({
558715
a:'a',

‎packages/eslint-plugin/src/rules/sort-keys-in-type-decorator.ts

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type Options = [
1111
exporttypeMessageIds='incorrectOrder';
1212

1313
constDEFAULT_ORDER={
14+
// https://angular.dev/api/core/Component
1415
Component:[
1516
'selector',
1617
'imports',
@@ -20,12 +21,50 @@ const DEFAULT_ORDER = {
2021
'styleUrl',
2122
'styleUrls',
2223
'styles',
23-
'encapsulation',
24+
'providers',
2425
'changeDetection',
26+
'encapsulation',
27+
'viewProviders',
28+
'host',
29+
'hostDirectives',
30+
'inputs',
31+
'outputs',
32+
'animations',
33+
'schemas',
34+
'exportAs',
35+
'queries',
36+
'preserveWhitespaces',
37+
'jit',
38+
// Deprecated properties according to https://angular.dev/api/core/Component
39+
'moduleId',
40+
'interpolation',
41+
],
42+
// https://angular.dev/api/core/Directive
43+
Directive:[
44+
'selector',
45+
'standalone',
46+
'providers',
47+
'host',
48+
'hostDirectives',
49+
'inputs',
50+
'outputs',
51+
'exportAs',
52+
'queries',
53+
'jit',
54+
],
55+
// https://angular.dev/api/core/NgModule
56+
NgModule:[
57+
'id',// rarely used but good to have first if set
58+
'imports',
59+
'declarations',
60+
'providers',
61+
'exports',
62+
'bootstrap',
63+
'schemas',
64+
'jit',
2565
],
26-
Directive:['selector','standalone'],
27-
NgModule:['declarations','imports','exports','providers','bootstrap'],
28-
Pipe:['name','standalone'],
66+
// https://angular.dev/api/core/Pipe
67+
Pipe:['name','standalone','pure'],
2968
};
3069

3170
exportconstRULE_NAME='sort-keys-in-type-decorator';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp