diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 3a9d31e00111acd399db23ef34f17b9c0ff44281..67338049e39902b46118947a55741e24dd7ff494 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -280,7 +280,7 @@ cookBookTag[270] = 'ArkTS1.2 cannot catch a non Error instance thrown from JS co cookBookTag[274] = 'The subclass constructor must call the parent class\'s parametered constructor (arkts-subclass-must-call-super-constructor-with-args)'; cookBookTag[275] = - 'Custom components with custom layout capability need to add the "@CustomLayout" decorator (arkui-custom-layout-need-add-decorator)'; + 'The Custom component with custom layout capability needs to add the "@CustomLayout" decorator (arkui-custom-layout-need-add-decorator)'; cookBookTag[281] = '"@Prop" decorator is not supported (arkui-no-prop-decorator)'; cookBookTag[282] = '"@StorageProp" decorator is not supported (arkui-no-storageprop-decorator)'; cookBookTag[283] = '"@LocalStorageProp" decorator is not supported (arkui-no-localstorageprop-decorator)'; diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 6bb631d6bbca3e53cdfd683f5a177847c19462f6..cedfe8faf002f8164947eb6cebcabdaa313c6573 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -9555,7 +9555,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const autofix = this.autofixer?.fixCustomLayout(node); - this.incrementCounters(node.name, FaultID.CustomLayoutNeedAddDecorator, autofix); + const name = node.name.getText(); + const errorMsg = + `The Custom component "${name}" with custom layout capability needs to add the "@CustomLayout" decorator ` + + '(arkui-custom-layout-need-add-decorator)'; + this.incrementCounters(node.name, FaultID.CustomLayoutNeedAddDecorator, autofix, errorMsg); } private handleArkTSPropertyAccess(expr: ts.BinaryExpression): void { diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index 9a990259ea0cad8df51146c13bef1ff9342b114f..743f8e7382cc44507ec76503c894f5a676100ac5 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -64,5 +64,6 @@ export const cookBookRefToFixTitle: Map = new Map([ [339, 'Using \'ESValue\' interface call'], [341, 'Create JS objects using instantite'], [358, 'Replace missing attribute'], - [359, '"@LocalBuilder" transform to "@Builder"'] + [359, '"@LocalBuilder" transform to "@Builder"'], + [381, 'StateStyles needs arrow function block'] ]); diff --git a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts index 1f26e36e862aa393385cf635d5b726a41ec9c02c..72a365bbd98abd81efaaa6f51397e0efba432888 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts @@ -149,7 +149,8 @@ export const arkts2Rules: number[] = [ 375, 376, 377, - 378 + 378, + 381 ]; export const onlyArkts2SyntaxRules: Map = new Map([ diff --git a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json index afc0270a6457ad39dcf01aa5d50e4eda3d3181f4..56fe9a275870fdccde477506828d4fa46a5de1b4 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json +++ b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json @@ -111,7 +111,7 @@ "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout1\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -181,7 +181,7 @@ "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout2\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -271,7 +271,7 @@ "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout3\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/custom_layout.ets.autofix.json b/ets2panda/linter/test/main/custom_layout.ets.autofix.json index ffcc8bf530930cdc677e41a2a96bb545843a76a7..23fd6cb93cf96de9e3288cff0f2499cba8f50d71 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.autofix.json +++ b/ets2panda/linter/test/main/custom_layout.ets.autofix.json @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout1\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -368,7 +368,7 @@ } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout2\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -557,7 +557,7 @@ } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout3\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, {