File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,25 @@ impl Analyser {
2626 ) ) ;
2727 }
2828
29+ if dt. alias . is_empty ( ) {
30+ self . reporter . add ( Diagnose :: new (
31+ dt. identifier . clone ( ) ,
32+ adt. original_definition . clone ( ) ,
33+ DiagnosticKind :: MissingTranslation {
34+ translation_field : "alias" . into ( ) ,
35+ } ,
36+ ) ) ;
37+ }
38+
39+ if dt. display_message . is_empty ( ) {
40+ self . reporter . add ( Diagnose :: new (
41+ dt. identifier . clone ( ) ,
42+ adt. original_definition . clone ( ) ,
43+ DiagnosticKind :: MissingTranslation {
44+ translation_field : "displayMessage" . into ( ) ,
45+ } ,
46+ ) ) ;
47+ }
2948 let mut detected: Vec < String > = vec ! [ ] ;
3049 for optional_rule in & dt. rules {
3150 if let Some ( config) = & optional_rule. config {
Original file line number Diff line number Diff line change @@ -8,6 +8,35 @@ impl Analyser {
88 let name = flow. identifier . clone ( ) ;
99 let original = aft. original_definition . clone ( ) ;
1010
11+ if flow. display_icon . is_empty ( ) {
12+ self . reporter . add ( Diagnose :: new (
13+ name. clone ( ) ,
14+ original. clone ( ) ,
15+ DiagnosticKind :: NullField {
16+ field_name : "displayIcon" . into ( ) ,
17+ } ,
18+ ) )
19+ }
20+ if flow. alias . is_empty ( ) {
21+ self . reporter . add ( Diagnose :: new (
22+ name. clone ( ) ,
23+ original. clone ( ) ,
24+ DiagnosticKind :: MissingTranslation {
25+ translation_field : "alias" . into ( ) ,
26+ } ,
27+ ) ) ;
28+ }
29+
30+ if flow. display_message . is_empty ( ) {
31+ self . reporter . add ( Diagnose :: new (
32+ name. clone ( ) ,
33+ original. clone ( ) ,
34+ DiagnosticKind :: MissingTranslation {
35+ translation_field : "displayMessage" . into ( ) ,
36+ } ,
37+ ) ) ;
38+ }
39+
1140 if flow. name . is_empty ( ) {
1241 self . reporter . add ( Diagnose :: new (
1342 name. clone ( ) ,
Original file line number Diff line number Diff line change @@ -10,6 +10,36 @@ impl Analyser {
1010 let function = & af. function ;
1111 let original = af. original_definition . clone ( ) ;
1212
13+ if function. display_icon . is_empty ( ) {
14+ self . reporter . add ( Diagnose :: new (
15+ name. clone ( ) ,
16+ original. clone ( ) ,
17+ DiagnosticKind :: NullField {
18+ field_name : "displayIcon" . into ( ) ,
19+ } ,
20+ ) )
21+ }
22+
23+ if function. alias . is_empty ( ) {
24+ self . reporter . add ( Diagnose :: new (
25+ name. clone ( ) ,
26+ original. clone ( ) ,
27+ DiagnosticKind :: MissingTranslation {
28+ translation_field : "alias" . into ( ) ,
29+ } ,
30+ ) ) ;
31+ }
32+
33+ if function. display_message . is_empty ( ) {
34+ self . reporter . add ( Diagnose :: new (
35+ name. clone ( ) ,
36+ original. clone ( ) ,
37+ DiagnosticKind :: MissingTranslation {
38+ translation_field : "displayMessage" . into ( ) ,
39+ } ,
40+ ) ) ;
41+ }
42+
1343 if function. name . is_empty ( ) {
1444 self . reporter . add ( Diagnose :: new (
1545 name. clone ( ) ,
Original file line number Diff line number Diff line change @@ -111,7 +111,14 @@ impl Diagnose {
111111 ) ,
112112 & path,
113113 ) ,
114- }
114+ MissingTranslation { translation_field } => error (
115+ format ! (
116+ "`{}` has an required empty field (`{}`) of translations!" ,
117+ self . definition_name, translation_field
118+ ) ,
119+ & path,
120+ ) ,
121+ }
115122 }
116123
117124 pub fn severity ( & self ) -> Severity {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ pub enum DiagnosticKind {
1515 UnusedGenericKey { key : String } ,
1616 UndefinedGenericKey { key : String } ,
1717 UndefinedTranslation { translation_field : String } ,
18+ MissingTranslation { translation_field : String } ,
1819}
1920
2021impl DiagnosticKind {
@@ -32,7 +33,8 @@ impl DiagnosticKind {
3233 | NullField { .. }
3334 | ForbiddenVariant
3435 | UnusedGenericKey { .. }
35- | UndefinedGenericKey { .. } => Severity :: Error ,
36+ | UndefinedGenericKey { .. }
37+ | MissingTranslation { .. } => Severity :: Error ,
3638 UndefinedTranslation { .. } => Severity :: Warning ,
3739 }
3840 }
You can’t perform that action at this time.
0 commit comments