diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 21370cd2c5561668c1b7c661954c394a028bef3a..52426d571d9f7901042e4bf516026a5951cae8c9 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -114,7 +114,8 @@ "arkui-no-setandprop-function", "arkui-prop-need-call-method-for-deep-copy", "arkui-no-localbuilder-decorator", - "arkui-statestyles-block-need-arrow-func" + "arkui-statestyles-block-need-arrow-func", + "arkui-repeat-disable-default-virtualscroll" ], "builtin": [ "arkts-builtin-thisArgs", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index f888fd4f5d4cb15ad5450bf0d1c5d33659e65015..d94ca192177f4f481714eef8d4acf822e3510c6d 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -371,6 +371,8 @@ cookBookTag[357] = 'Worker are not supported(arkts-no-need-stdlib-worker)'; cookBookTag[358] = 'Using "Object.getOwnPropertyNames" is not allowed in this API (arkts-builtin-object-getOwnPropertyNames))'; cookBookTag[359] = '"@LocalBuilder" Decorator is not supported (arkui-no-localbuilder-decorator)'; +cookBookTag[360] = + '"Repeat" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)'; cookBookTag[370] = 'Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)'; cookBookTag[371] = 'Enum elements cannot be types in ArkTS1.2 (arkts-no-enum-prop-as-type)'; cookBookTag[372] = 'Smart type differences (arkts-no-ts-like-smart-type)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index c183485e36625039dc9841133f3648365539596e..faeb575025c45d935602171d85292961ec6e4996 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -256,6 +256,7 @@ faultsAttrs[FaultID.LimitedStdLibNoDoncurrentDecorator] = new FaultAttributes(35 faultsAttrs[FaultID.NoNeedStdlibWorker] = new FaultAttributes(357); faultsAttrs[FaultID.BuiltinGetOwnPropertyNames] = new FaultAttributes(358); faultsAttrs[FaultID.LocalBuilderDecoratorNotSupported] = new FaultAttributes(359); +faultsAttrs[FaultID.RepeatDisableVirtualScroll] = new FaultAttributes(360); faultsAttrs[FaultID.NosparseArray] = new FaultAttributes(370); faultsAttrs[FaultID.NoEnumPropAsType] = new FaultAttributes(371); faultsAttrs[FaultID.NoTsLikeSmartType] = new FaultAttributes(372); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 2ae56f2bd19b33b9636c705f35b6bd8629a06975..33cb74aca333d02802159e6e128a1f2ca4e21833 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -256,3 +256,4 @@ faultDesc[FaultID.SetAndPropFunctionNotSupported] = '"setAndProp" function is no faultDesc[FaultID.PropNeedCallMethodForDeepCopy] = 'Deep copy needs to call the specific method'; faultDesc[FaultID.StateStylesBlockNeedArrowFunc] = 'StateStyles needs arrow function block'; faultDesc[FaultID.PromiseVoidNeedResolveArg] = 'Promiseconstructor only supports using resolve (undefined)'; +faultDesc[FaultID.RepeatDisableVirtualScroll] = '"Repeat" disable default "virtualScroll"'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index e8a9b611d3a9f494526d756a744014f060d82252..9225ec1dce5d60894eac5a3e69d95b4742c289f0 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -256,6 +256,7 @@ export enum FaultID { PropNeedCallMethodForDeepCopy, StateStylesBlockNeedArrowFunc, PromiseVoidNeedResolveArg, + RepeatDisableVirtualScroll, // this should always be last enum LAST_ID } diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index ca04dbcfcd70cd084c01b8f28c23f983dd279534..50b2fbc071df93c6c0ab8675978fedda78d4416c 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -92,7 +92,7 @@ import { DOUBLE_DOLLAR_IDENTIFIER, THIS_IDENTIFIER, STATE_STYLES, - CustomDecoratorName, + CustomInterfaceName, observedDecoratorName, skipImportDecoratorName, ENTRY_DECORATOR_NAME, @@ -104,7 +104,8 @@ import { PropDecoratorName, PropFunctionName, StorageTypeName, - customLayoutFunctionName + customLayoutFunctionName, + VIRTUAL_SCROLL_IDENTIFIER } from './utils/consts/ArkuiConstants'; import { arkuiImportList } from './utils/consts/ArkuiImportList'; import type { IdentifierAndArguments, ForbidenAPICheckResult } from './utils/consts/InteropAPI'; @@ -4386,7 +4387,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleCallExpression(node: ts.Node): void { const tsCallExpr = node as ts.CallExpression; this.checkSdkAbilityLifecycleMonitor(tsCallExpr); - this.handleStateStyles(tsCallExpr); + this.handleCallExpressionForUI(tsCallExpr); this.handleBuiltinCtorCallSignature(tsCallExpr); this.handleSdkConstructorIfaceForCallExpression(tsCallExpr); if (this.options.arkts2 && tsCallExpr.typeArguments !== undefined) { @@ -4428,6 +4429,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkRestrictedAPICall(tsCallExpr); } + private handleCallExpressionForUI(node: ts.CallExpression): void { + this.handleStateStyles(node); + this.handleCallExpressionForRepeat(node); + } + handleNoTsLikeFunctionCall(callExpr: ts.CallExpression): void { if (!this.options.arkts2) { return; @@ -6904,10 +6910,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } if (ts.isCallExpression(node.expression) && ts.isIdentifier(node.expression.expression)) { - if (node.expression.expression.text === CustomDecoratorName.Extend) { + if (node.expression.expression.text === CustomInterfaceName.Extend) { const autofix = this.autofixer?.fixExtendDecorator(node, false, this.interfacesNeedToImport); this.incrementCounters(node.parent, FaultID.ExtendDecoratorNotSupported, autofix); - } else if (node.expression.expression.text === CustomDecoratorName.AnimatableExtend) { + } else if (node.expression.expression.text === CustomInterfaceName.AnimatableExtend) { const autofix = this.autofixer?.fixExtendDecorator(node, true, this.interfacesNeedToImport); this.incrementCounters(node.parent, FaultID.AnimatableExtendDecoratorTransform, autofix); } @@ -7279,10 +7285,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private static isWrappedByExtendDecorator(node: ts.Identifier): boolean { - const wrappedSkipComponents = new Set([CustomDecoratorName.AnimatableExtend, CustomDecoratorName.Extend]); + const wrappedSkipComponents = new Set([CustomInterfaceName.AnimatableExtend, CustomInterfaceName.Extend]); if (ts.isCallExpression(node.parent)) { const expr = node.parent.expression; - if (wrappedSkipComponents.has(expr.getText()) && node.getText() !== CustomDecoratorName.AnimatableExtend) { + if (wrappedSkipComponents.has(expr.getText()) && node.getText() !== CustomInterfaceName.AnimatableExtend) { return true; } } @@ -7381,7 +7387,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if (!ts.isIdentifier(node.expression) || node.expression.text !== CustomDecoratorName.Styles) { + if (!ts.isIdentifier(node.expression) || node.expression.text !== CustomInterfaceName.Styles) { return; } @@ -7565,7 +7571,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return true; }); if (filteredClassDecls.length !== 0) { - this.interfacesNeedToImport.add(CustomDecoratorName.Observed); + this.interfacesNeedToImport.add(CustomInterfaceName.Observed); } const autofix = this.autofixer?.fixDataObservation(filteredClassDecls); this.incrementCounters(node, FaultID.DataObservation, autofix); @@ -7627,7 +7633,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private static hasObservedDecorator(classDecl: ts.ClassDeclaration): boolean { return ( ts.getDecorators(classDecl)?.some((decorator) => { - return decorator.getText() === '@' + CustomDecoratorName.Observed; + return decorator.getText() === '@' + CustomInterfaceName.Observed; }) ?? false ); } @@ -9434,7 +9440,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } const decoratorName = node.expression.getText(); - if (decoratorName === CustomDecoratorName.LocalBuilder) { + if (decoratorName === CustomInterfaceName.LocalBuilder) { const autofix = this.autofixer?.fixBuilderDecorators(node); this.incrementCounters(node, FaultID.LocalBuilderDecoratorNotSupported, autofix); } @@ -10014,7 +10020,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (decorators) { for (const decorator of decorators) { const decoratorName = TsUtils.getDecoratorName(decorator); - if (decoratorName && decoratorName === CustomDecoratorName.CustomLayout) { + if (decoratorName && decoratorName === CustomInterfaceName.CustomLayout) { return; } } @@ -11002,4 +11008,26 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } + + private handleCallExpressionForRepeat(node: ts.CallExpression): void { + if (!this.options.arkts2) { + return; + } + + if ( + !ts.isIdentifier(node.expression) || + node.expression.getText() !== CustomInterfaceName.Repeat || + this.isDeclarationInSameFile(node.expression) + ) { + return; + } + + const stmt = ts.findAncestor(node, ts.isExpressionStatement); + if (!stmt || TsUtils.checkStmtHasTargetIdentifier(stmt, VIRTUAL_SCROLL_IDENTIFIER)) { + return; + } + + const autofix = this.autofixer?.fixRepeat(stmt); + this.incrementCounters(node, FaultID.RepeatDisableVirtualScroll, autofix); + } } diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index 743f8e7382cc44507ec76503c894f5a676100ac5..375831c9a731489a8201edb6e69f1b31f35ffb47 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -65,5 +65,6 @@ export const cookBookRefToFixTitle: Map = new Map([ [341, 'Create JS objects using instantite'], [358, 'Replace missing attribute'], [359, '"@LocalBuilder" transform to "@Builder"'], + [360, '"Repeat" disable default "virtualScroll"'], [381, 'StateStyles needs arrow function block'] ]); diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index c3cab4c0e3a2cf92b64c47f689fe98fcf4a64839..18d56b61eefd74ae8f789978ebbecc021c623fa2 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -29,7 +29,7 @@ import { INSTANCE_IDENTIFIER, COMMON_METHOD_IDENTIFIER, APPLY_STYLES_IDENTIFIER, - CustomDecoratorName, + CustomInterfaceName, ARKUI_PACKAGE_NAME, VALUE_IDENTIFIER, INDENT_STEP, @@ -40,7 +40,9 @@ import { PROVIDE_DECORATOR_NAME, PROVIDE_ALIAS_PROPERTY_NAME, PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME, - NEW_PROP_DECORATOR_SUFFIX + NEW_PROP_DECORATOR_SUFFIX, + VIRTUAL_SCROLL_IDENTIFIER, + DISABLE_VIRTUAL_SCROLL_IDENTIFIER } from '../utils/consts/ArkuiConstants'; import { ES_VALUE } from '../utils/consts/ESObject'; import type { IncrementDecrementNodeInfo } from '../utils/consts/InteropAPI'; @@ -2904,7 +2906,7 @@ export class Autofixer { const newFuncDecl = Autofixer.createFunctionDeclaration(funcDecl, undefined, parameDecl, returnType, newBlock); let text = this.printer.printNode(ts.EmitHint.Unspecified, newFuncDecl, funcDecl.getSourceFile()); if (preserveDecorator) { - text = '@' + CustomDecoratorName.AnimatableExtend + this.getNewLine() + text; + text = '@' + CustomInterfaceName.AnimatableExtend + this.getNewLine() + text; } return [{ start: funcDecl.getStart(), end: funcDecl.getEnd(), replacementText: text }]; } @@ -3767,7 +3769,7 @@ export class Autofixer { const values: ts.Expression[][] = []; const statements = block?.statements; const type = ts.factory.createTypeReferenceNode( - ts.factory.createIdentifier(CustomDecoratorName.CustomStyles), + ts.factory.createIdentifier(CustomInterfaceName.CustomStyles), undefined ); Autofixer.getParamsAndValues(statements, parameters, values); @@ -3789,7 +3791,7 @@ export class Autofixer { newBlock ); const newModifiers = ts.getModifiers(methodDecl)?.filter((modifier) => { - return !(ts.isDecorator(modifier) && TsUtils.getDecoratorName(modifier) === CustomDecoratorName.Styles); + return !(ts.isDecorator(modifier) && TsUtils.getDecoratorName(modifier) === CustomInterfaceName.Styles); }); const expr = ts.factory.createPropertyDeclaration(newModifiers, methodDecl.name, undefined, type, arrowFunc); needImport.add(COMMON_METHOD_IDENTIFIER); @@ -3928,7 +3930,7 @@ export class Autofixer { fixDataObservation(classDecls: ts.ClassDeclaration[]): Autofix[] | undefined { const autofixes: Autofix[] = []; classDecls.forEach((classDecl) => { - const observedDecorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomDecoratorName.Observed)); + const observedDecorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomInterfaceName.Observed)); const sourceFile = classDecl.getSourceFile(); const text = this.printer.printNode(ts.EmitHint.Unspecified, observedDecorator, sourceFile) + this.getNewLine(); const autofix = { start: classDecl.getStart(), end: classDecl.getStart(), replacementText: text }; @@ -5069,7 +5071,7 @@ export class Autofixer { fixCustomLayout(node: ts.StructDeclaration): Autofix[] { const startPos = Autofixer.getStartPositionWithoutDecorators(node); - const decorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomDecoratorName.CustomLayout)); + const decorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomInterfaceName.CustomLayout)); const text = this.getNewLine() + this.printer.printNode(ts.EmitHint.Unspecified, decorator, node.getSourceFile()); return [{ start: startPos, end: startPos, replacementText: text }]; @@ -5140,4 +5142,38 @@ export class Autofixer { replacementText: newText }]; } + + fixRepeat(stmt: ts.ExpressionStatement): Autofix[] { + const newExpr = ts.factory.createCallExpression(ts.factory.createIdentifier(VIRTUAL_SCROLL_IDENTIFIER), undefined, [ + ts.factory.createObjectLiteralExpression( + [ + ts.factory.createPropertyAssignment( + ts.factory.createIdentifier(DISABLE_VIRTUAL_SCROLL_IDENTIFIER), + ts.factory.createTrue() + ) + ], + false + ) + ]); + + let identifier: ts.Identifier | undefined; + const expression = stmt.expression; + if ( + ts.isCallExpression(expression) && + ts.isPropertyAccessExpression(expression.expression) && + ts.isIdentifier(expression.expression.name) + ) { + identifier = expression.expression.name; + } + + const startPos = identifier ? identifier.getStart() : stmt.getStart(); + const lineAndCharacter = this.sourceFile.getLineAndCharacterOfPosition(startPos); + const indent = identifier ? lineAndCharacter.character - 1 : lineAndCharacter.character + INDENT_STEP; + const text = + this.getNewLine() + + ' '.repeat(indent) + + '.' + + this.printer.printNode(ts.EmitHint.Unspecified, newExpr, stmt.getSourceFile()); + return [{ start: stmt.getEnd(), end: stmt.getEnd(), replacementText: text }]; + } } diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index db9e766033add2d72cf30c8f2f477b363aa9e1d9..479705c83fb51bb672bc581e70dcaa6e71531c26 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -3804,4 +3804,27 @@ export class TsUtils { const sym = type.getSymbol(); return !!sym && sym.getName() === 'PromiseLike' && isStdLibrarySymbol(sym); } + + static checkStmtHasTargetIdentifier(stmt: ts.ExpressionStatement, target: string): boolean { + let current: ts.Node | undefined = stmt.expression; + + while (current) { + if (ts.isCallExpression(current)) { + current = current.expression; + continue; + } + + if (ts.isPropertyAccessExpression(current)) { + if (current.name.getText() === target) { + return true; + } + current = current.expression; + continue; + } + + break; + } + + return false; + } } diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index 5405ffe91fbad020ed6821eed61444cea308736f..22e7943117e3c7488d2ca2a88ba0ec0b833004e9 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -27,7 +27,7 @@ export const MAKE_OBSERVED = 'makeObserved'; export const ARKUI_STATE_MANAGEMENT = '@ohos.arkui.StateManagement'; export const NEW_PROP_DECORATOR_SUFFIX = 'Ref'; -export enum CustomDecoratorName { +export enum CustomInterfaceName { Extend = 'Extend', LocalBuilder = 'LocalBuilder', Styles = 'Styles', @@ -35,7 +35,8 @@ export enum CustomDecoratorName { Memo = 'Memo', Observed = 'Observed', CustomLayout = 'CustomLayout', - CustomStyles = 'CustomStyles' + CustomStyles = 'CustomStyles', + Repeat = 'Repeat' } export enum StorageTypeName { @@ -88,3 +89,6 @@ export const GET_LOCAL_STORAGE_FUNC_NAME = '__get_local_storage__'; export const PROVIDE_DECORATOR_NAME = 'Provide'; export const PROVIDE_ALIAS_PROPERTY_NAME = 'alias'; export const PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME = 'allowOverride'; + +export const VIRTUAL_SCROLL_IDENTIFIER = 'virtualScroll'; +export const DISABLE_VIRTUAL_SCROLL_IDENTIFIER = 'disableVirtualScroll'; diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets b/ets2panda/linter/test/main/repeat_virtualscroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..62dcc3104ad0cf3c21f69ec908f3bb2b23b37851 --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@ComponentV2 +struct RepeatExampleWithTemplates { + @Local dataArr: Array = []; + + aboutToAppear(): void { + for (let i = 0; i < 50; i++) { + this.dataArr.push(`data_${i}`); + } + } + + build() { + Column() { + List() { + Repeat(this.dataArr) + .each((ri: RepeatItem) => { + ListItem() { + Text('each_' + ri.item).fontSize(30).fontColor('rgb(161,10,33)') + } + }) + .key((item: string, index: number): string => JSON.stringify(item)) + .virtualScroll({ disableVirtualScroll: true }) + + + Repeat(this.dataArr) + .each((ri: RepeatItem) => { + ListItem() { + Text('each_' + ri.item).fontSize(30).fontColor('rgb(161,10,33)') + } + }) + .key((item: string, index: number): string => JSON.stringify(item)) + + Repeat(this.dataArr) + .each((ri: RepeatItem) => { + ListItem() { + Text('each_' + ri.item).fontSize(30).fontColor('rgb(161,10,33)') + } + }) + + Repeat(this.dataArr) + } + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.args.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ee0734c0fc5b9a918bfdd7245e6ef1efeb8ad7e6 --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..5a4a43a78f299ab36493580dcc6b0626e18d7f71 --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.arkts2.json @@ -0,0 +1,288 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 22, + "column": 14, + "endLine": 22, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 18, + "endLine": 22, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 25, + "endLine": 22, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 48, + "endLine": 33, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 9, + "endLine": 40, + "endColumn": 37, + "problem": "RepeatDisableVirtualScroll", + "suggest": "", + "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 48, + "endLine": 43, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 37, + "problem": "RepeatDisableVirtualScroll", + "suggest": "", + "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 48, + "endLine": 51, + "endColumn": 50, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 37, + "problem": "RepeatDisableVirtualScroll", + "suggest": "", + "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 5, + "endLine": 28, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 22, + "endLine": 31, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 13, + "endLine": 32, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 15, + "endLine": 33, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 9, + "endLine": 40, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 22, + "endLine": 41, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 15, + "endLine": 43, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 22, + "endLine": 49, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 13, + "endLine": 50, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 15, + "endLine": 51, + "endColumn": 19, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..e7463248c2903dda6e2372790d0e73ed95392b24 --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json @@ -0,0 +1,585 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 22, + "column": 14, + "endLine": 22, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 739, + "end": 744, + "replacementText": "i: number = 0", + "line": 22, + "column": 14, + "endLine": 22, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 18, + "endLine": 22, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 743, + "end": 744, + "replacementText": "0.0", + "line": 22, + "column": 18, + "endLine": 22, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 25, + "endLine": 22, + "endColumn": 27, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 750, + "end": 752, + "replacementText": "50.0", + "line": 22, + "column": 25, + "endLine": 22, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 48, + "endLine": 33, + "endColumn": 50, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1007, + "end": 1009, + "replacementText": "30.0", + "line": 33, + "column": 48, + "endLine": 33, + "endColumn": 50 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 9, + "endLine": 40, + "endColumn": 37, + "problem": "RepeatDisableVirtualScroll", + "autofix": [ + { + "start": 1494, + "end": 1494, + "replacementText": "\n .virtualScroll({ disableVirtualScroll: true })", + "line": 40, + "column": 9, + "endLine": 40, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 48, + "endLine": 43, + "endColumn": 50, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1358, + "end": 1360, + "replacementText": "30.0", + "line": 43, + "column": 48, + "endLine": 43, + "endColumn": 50 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 37, + "problem": "RepeatDisableVirtualScroll", + "autofix": [ + { + "start": 1717, + "end": 1717, + "replacementText": "\n .virtualScroll({ disableVirtualScroll: true })", + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 48, + "endLine": 51, + "endColumn": 50, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1659, + "end": 1661, + "replacementText": "30.0", + "line": 51, + "column": 48, + "endLine": 51, + "endColumn": 50 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 37, + "problem": "RepeatDisableVirtualScroll", + "autofix": [ + { + "start": 1755, + "end": 1755, + "replacementText": "\n .virtualScroll({ disableVirtualScroll: true })", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "\"Repeat\" natively supports virtual scrolling capability in ArkTS1.2, so the default virtual scrolling should be disabled (arkui-repeat-disable-default-virtualscroll)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 5, + "endLine": 28, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 9, + "endLine": 30, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 22, + "endLine": 31, + "endColumn": 32, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 13, + "endLine": 32, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 15, + "endLine": 33, + "endColumn": 19, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 9, + "endLine": 40, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 22, + "endLine": 41, + "endColumn": 32, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 13, + "endLine": 42, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 15, + "endLine": 43, + "endColumn": 19, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 9, + "endLine": 48, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 22, + "endLine": 49, + "endColumn": 32, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 13, + "endLine": 50, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 15, + "endLine": 51, + "endColumn": 19, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport {\n Entry,\n ComponentV2,\n Local,\n Column,\n List,\n Repeat,\n RepeatItem,\n ListItem,\n Text,\n} from '@kit.ArkUI';", + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.ets b/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..07d143184dce9a58b1e6f5ce0a5358c8410765bc --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.ets @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + Entry, + ComponentV2, + Local, + Column, + List, + Repeat, + RepeatItem, + ListItem, + Text, +} from '@kit.ArkUI'; + +@Entry +@ComponentV2 +struct RepeatExampleWithTemplates { + @Local dataArr: Array = []; + + aboutToAppear(): void { + for (let i: number = 0.0; i < 50.0; i++) { + this.dataArr.push(`data_${i}`); + } + } + + build() { + Column() { + List() { + Repeat(this.dataArr) + .each((ri: RepeatItem) => { + ListItem() { + Text('each_' + ri.item).fontSize(30.0).fontColor('rgb(161,10,33)') + } + }) + .key((item: string, index: number): string => JSON.stringify(item)) + .virtualScroll({ disableVirtualScroll: true }) + + + Repeat(this.dataArr) + .each((ri: RepeatItem) => { + ListItem() { + Text('each_' + ri.item).fontSize(30.0).fontColor('rgb(161,10,33)') + } + }) + .key((item: string, index: number): string => JSON.stringify(item)) + .virtualScroll({ disableVirtualScroll: true }) + + Repeat(this.dataArr) + .each((ri: RepeatItem) => { + ListItem() { + Text('each_' + ri.item).fontSize(30.0).fontColor('rgb(161,10,33)') + } + }) + .virtualScroll({ disableVirtualScroll: true }) + + Repeat(this.dataArr) + .virtualScroll({ disableVirtualScroll: true }) + } + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.migrate.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file