From c979cc7aacf221313906961e9300f0e00c414fca Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Thu, 26 Oct 2023 13:06:10 +0300 Subject: [PATCH 01/23] Revert "[arkts linter] fix #14030: add new rule, rework ESObject reporting, #14009" This reverts commit 7864dd1409b500eb8efdbaca72a23e10c05ee0a4. --- linter-4.2/docs/rules/recipe144.md | 3 +- linter-4.2/docs/rules/recipe151.md | 54 ---- linter-4.2/src/CookBookMsg.ts | 1 - linter-4.2/src/Problems.ts | 7 +- linter-4.2/src/TypeScriptLinter.ts | 197 ++++++++----- linter-4.2/src/TypeScriptLinterConfig.ts | 4 +- linter-4.2/src/Utils.ts | 175 +++-------- linter-4.2/test/es_object.ts | 19 +- linter-4.2/test/es_object.ts.relax.json | 269 +++++++---------- linter-4.2/test/es_object.ts.strict.json | 271 +++++++----------- .../test/function_expression.ts.autofix.json | 16 +- .../test/function_expression.ts.relax.json | 4 +- .../test/function_expression.ts.strict.json | 12 +- .../function_object_methods.ts.relax.json | 46 +-- .../function_object_methods.ts.strict.json | 46 +-- linter-4.2/test/limited_stdlib_api.ts | 10 +- .../test/limited_stdlib_api.ts.autofix.json | 268 ++++++++--------- .../test/limited_stdlib_api.ts.relax.json | 248 +++++++--------- .../test/limited_stdlib_api.ts.strict.json | 248 +++++++--------- linter-4.2/test/new_target.ts.relax.json | 2 +- linter-4.2/test/new_target.ts.strict.json | 2 +- linter-4.2/test/oh_modules/ohos_lib.ts | 3 - linter-4.2/test/symbol_api.ts.relax.json | 24 +- linter-4.2/test/symbol_api.ts.strict.json | 24 +- linter-4.2/test/utility_types.ts.relax.json | 4 +- linter-4.2/test/utility_types.ts.strict.json | 4 +- linter-4.2/test_rules/rule132.ts.autofix.json | 2 +- linter-4.2/test_rules/rule132.ts.relax.json | 2 +- linter-4.2/test_rules/rule132.ts.strict.json | 2 +- linter/docs/rules/recipe144.md | 3 +- linter/docs/rules/recipe151.md | 54 ---- linter/src/Autofixer.ts | 2 +- linter/src/CookBookMsg.ts | 1 - linter/src/FaultAttrs.ts | 180 ++++++------ linter/src/FaultDesc.ts | 6 +- linter/src/LinterRunner.ts | 2 +- linter/src/Problems.ts | 39 +++ linter/src/TypeScriptLinter.ts | 195 ++++++++----- linter/src/TypeScriptLinterConfig.ts | 2 +- .../src/ts-diagnostics/TSCCompiledProgram.ts | 2 +- linter/src/utils/TsUtils.ts | 45 ++- .../src/utils/consts/AllowedStdSymbolAPI.ts | 16 ++ .../consts/LimitedStandardUtilityTypes.ts | 20 +- linter/src/utils/consts/LimitedStdApi.ts | 155 ---------- .../utils/consts/LimitedStdArrayBufferAPI.ts | 16 ++ .../src/utils/consts/LimitedStdGlobalFunc.ts | 18 ++ .../src/utils/consts/LimitedStdGlobalVar.ts | 16 ++ .../src/utils/consts/LimitedStdObjectAPI.ts | 22 ++ .../utils/consts/LimitedStdProxyHandlerAPI.ts | 19 ++ .../src/utils/consts/LimitedStdReflectAPI.ts | 19 ++ linter/src/utils/consts/Problems.ts | 104 ------- linter/test/es_object.ts | 19 +- linter/test/es_object.ts.relax.json | 269 +++++++---------- linter/test/es_object.ts.strict.json | 271 +++++++----------- .../test/function_expression.ts.autofix.json | 16 +- linter/test/function_expression.ts.relax.json | 4 +- .../test/function_expression.ts.strict.json | 12 +- .../function_object_methods.ts.relax.json | 46 +-- .../function_object_methods.ts.strict.json | 46 +-- linter/test/limited_stdlib_api.ts | 8 +- .../test/limited_stdlib_api.ts.autofix.json | 254 +++++++--------- linter/test/limited_stdlib_api.ts.relax.json | 234 +++++++-------- linter/test/limited_stdlib_api.ts.strict.json | 234 +++++++-------- linter/test/new_target.ts.relax.json | 2 +- linter/test/new_target.ts.strict.json | 2 +- linter/test/oh_modules/ohos_lib.ts | 3 - linter/test/symbol_api.ts.relax.json | 24 +- linter/test/symbol_api.ts.strict.json | 24 +- linter/test/utility_types.ts.relax.json | 4 +- linter/test/utility_types.ts.strict.json | 4 +- linter/test_rules/rule132.ts.autofix.json | 2 +- linter/test_rules/rule132.ts.relax.json | 2 +- linter/test_rules/rule132.ts.strict.json | 2 +- 73 files changed, 1779 insertions(+), 2606 deletions(-) delete mode 100644 linter-4.2/docs/rules/recipe151.md delete mode 100644 linter/docs/rules/recipe151.md create mode 100644 linter/src/Problems.ts create mode 100644 linter/src/utils/consts/AllowedStdSymbolAPI.ts delete mode 100644 linter/src/utils/consts/LimitedStdApi.ts create mode 100644 linter/src/utils/consts/LimitedStdArrayBufferAPI.ts create mode 100644 linter/src/utils/consts/LimitedStdGlobalFunc.ts create mode 100644 linter/src/utils/consts/LimitedStdGlobalVar.ts create mode 100644 linter/src/utils/consts/LimitedStdObjectAPI.ts create mode 100644 linter/src/utils/consts/LimitedStdProxyHandlerAPI.ts create mode 100644 linter/src/utils/consts/LimitedStdReflectAPI.ts delete mode 100644 linter/src/utils/consts/Problems.ts diff --git a/linter-4.2/docs/rules/recipe144.md b/linter-4.2/docs/rules/recipe144.md index 28acf4a49..975ae2131 100644 --- a/linter-4.2/docs/rules/recipe144.md +++ b/linter-4.2/docs/rules/recipe144.md @@ -9,7 +9,8 @@ The most part of the restricted APIs relates to manipulating objects in a dynamic manner, which is not compatible with static typing. The usage of the following APIs is prohibited: -Properties and functions of the global object: ``eval`` +Properties and functions of the global object: ``eval``, +``Infinity``, ``NaN``, ``isFinite``, ``isNaN``, ``parseFloat``, ``parseInt`` ``Object``: ``__proto__``, ``__defineGetter__``, ``__defineSetter__``, ``__lookupGetter__``, ``__lookupSetter__``, ``assign``, ``create``, diff --git a/linter-4.2/docs/rules/recipe151.md b/linter-4.2/docs/rules/recipe151.md deleted file mode 100644 index 0b00ba643..000000000 --- a/linter-4.2/docs/rules/recipe151.md +++ /dev/null @@ -1,54 +0,0 @@ -# Usage of ``ESObject`` type is restricted - -Rule ``arkts-limited-esobject`` - -**Severity: warning** - -ArkTS does not allow using ``ESObject`` type in some cases. The most part of limitations -are put in place in order to prevent spread of dynamic objects in the static codebase. -The only scenario where it is permited to use ``ESObject`` as type specifier is in local -variable declaration. Initialization of variables with ``ESObject`` type is also limited. -Such variables can only be initialized with values that originate from interop: -other ``ESObject`` typed variables, any, unknown, variables with anonymous type, etc. -It is prohibited to initialize ``ESObject`` typed variable with statically typed value. -Varaible of type ``ESObject`` can only be passed to interop calls and assigned to other -variables of type ``ESObject``. - - -## ArkTS - - -``` - // lib.d.ts - declare function foo(): any; - declare function bar(a: any): number; - - // main.ets - let e0: ESObject = foo(); // CTE - ``ESObject`` typed variable can only be local - - function f() { - let e1 = foo(); // CTE - type of e1 is `any` - let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values - let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values - let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values - let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values - let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject - let e7 = e6; // OK - initialize ESObject with ESObject - e6['prop'] // CTE - can't access dynamic properties of ESObject - e6[1] // CTE - can't access dynamic properties of ESObject - e6.prop // CTE - can't access dynamic properties of ESObject - bar(e6) // OK - ESObject is passed to interop call - } -``` - - -## See also - -- Recipe 001: Objects with property names that are not identifiers are not supported (``arkts-identifiers-as-prop-names``) -- Recipe 002: ``Symbol()`` API is not supported (``arkts-no-symbol``) -- Recipe 029: Indexed access is not supported for fields (``arkts-no-props-by-index``) -- Recipe 060: ``typeof`` operator is allowed only in expression contexts (``arkts-no-type-query``) -- Recipe 066: ``in`` operator is not supported (``arkts-no-in``) -- Recipe 137: ``globalThis`` is not supported (``arkts-no-globalthis``) - - diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index c097345da..6f90d98ea 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -170,4 +170,3 @@ cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (ar cookBookTag[148] = 'No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; -cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobject)'; diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index 98bd4701b..69dab34fb 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -34,7 +34,8 @@ export enum FaultID { NewTarget, DefiniteAssignment, Prototype, GlobalThis, UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ConstAssertion, ImportAssertion, SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, UnsupportedDecorators, ImportAfterStatement, - EsObjectType, LAST_ID, // this should always be last enum + EsObjectType, EsObjectAssignment, EsObjectAccess, + LAST_ID, // this should always be last enum` } export class FaultAttributs { @@ -130,4 +131,6 @@ faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; faultsAttrs[FaultID.UnsupportedDecorators] = {warning: true, cookBookRef: '148',}; faultsAttrs[FaultID.ClassAsObject] = {cookBookRef: '149',}; faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '150',}; -faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '151',}; +faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '8'}; +faultsAttrs[FaultID.EsObjectAssignment] = {warning: true, cookBookRef: '8'}; +faultsAttrs[FaultID.EsObjectAccess] = {warning: true, cookBookRef: '8'}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 27442da9f..34126f27d 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -668,18 +668,25 @@ export class TypeScriptLinter { } private handlePropertyAccessExpression(node: ts.Node) { + if (ts.isCallExpression(node.parent) && node == node.parent.expression) { + return; + } + let propertyAccessNode = node as ts.PropertyAccessExpression; const exprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode); const baseExprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode.expression); const baseExprType = this.tsTypeChecker.getTypeAtLocation(propertyAccessNode.expression); - if (!!baseExprSym && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { - this.incrementCounters(propertyAccessNode, FaultID.EsObjectType); - } if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { this.incrementCounters(propertyAccessNode.name, FaultID.Prototype); } + if (!!exprSym && this.tsUtils.isSymbolAPI(exprSym) && !TsUtils.ALLOWED_STD_SYMBOL_API.includes(exprSym.getName())) { + this.incrementCounters(propertyAccessNode, FaultID.SymbolType); + } + if (baseExprSym !== undefined && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { + this.incrementCounters(propertyAccessNode, FaultID.EsObjectAccess); + } } private handlePropertyAssignmentOrDeclaration(node: ts.Node) { @@ -1187,7 +1194,9 @@ export class TypeScriptLinter { } const typeNode = this.tsUtils.getVariableDeclarationTypeNode(tsLhsExpr); - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); + if (!!typeNode) { + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); + } } } @@ -1230,41 +1239,39 @@ export class TypeScriptLinter { if (this.tsUtils.needToDeduceStructuralIdentity(tsVarType, tsInitType, tsVarInit)) { this.incrementCounters(tsVarDecl, FaultID.StructuralIdentity); } + + this.handleEsObjectAssignment(tsVarDecl, tsVarDecl.type, tsVarInit); } - this.handleEsObjectDelaration(tsVarDecl); this.handleDeclarationInferredType(tsVarDecl); this.handleDefiniteAssignmentAssertion(tsVarDecl); } - private handleEsObjectDelaration(node: ts.VariableDeclaration) { - const isDeclaredESObject = !!node.type && this.tsUtils.isEsObjectType(node.type); - const initalizerTypeNode = node.initializer && this.tsUtils.getVariableDeclarationTypeNode(node.initializer); - const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); - const isLocal = this.tsUtils.isInsideBlock(node) - if ((isDeclaredESObject || isInitializedWithESObject) && !isLocal) { - this.incrementCounters(node, FaultID.EsObjectType); - return; + private handleEsObjectAssignment(node: ts.Node, type: ts.TypeNode, value: ts.Node) { + if (!this.tsUtils.isEsObjectType(type)) { + let valueTypeNode = this.tsUtils.getVariableDeclarationTypeNode(value); + if (!!valueTypeNode && this.tsUtils.isEsObjectType(valueTypeNode)) { + this.incrementCounters(node, FaultID.EsObjectAssignment); + } + + return } - if (node.initializer) { - this.handleEsObjectAssignment(node, node.type, node.initializer); + if (ts.isArrayLiteralExpression(value) || ts.isObjectLiteralExpression(value)) { + this.incrementCounters(node, FaultID.EsObjectAssignment); + return; } - } - private handleEsObjectAssignment(node: ts.Node, nodeDeclType: ts.TypeNode | undefined, initializer: ts.Node) { - const isTypeAnnotated = !!nodeDeclType; - const isDeclaredESObject = !!nodeDeclType && this.tsUtils.isEsObjectType(nodeDeclType); - const initalizerTypeNode = this.tsUtils.getVariableDeclarationTypeNode(initializer); - const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); - if (isTypeAnnotated && !isDeclaredESObject && isInitializedWithESObject) { - this.incrementCounters(node, FaultID.EsObjectType); + const valueType = this.tsTypeChecker.getTypeAtLocation(value); + if (this.tsUtils.isUnsupportedType(valueType)) { return; } - if (isDeclaredESObject && !this.tsUtils.isValueAssignableToESObject(initializer)) { - this.incrementCounters(node, FaultID.EsObjectType); + if (this.tsUtils.isAnonymousType(valueType)) { + return; } + + this.incrementCounters(node, FaultID.EsObjectAssignment); } private handleCatchClause(node: ts.Node) { @@ -1479,18 +1486,18 @@ export class TypeScriptLinter { private handleIdentifier(node: ts.Node) { let tsIdentifier = node as ts.Identifier; let tsIdentSym = this.tsUtils.trueSymbolAtLocation(tsIdentifier); - if (!tsIdentSym) { - return; - } - if ( - (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && - (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && - tsIdentifier.text === 'globalThis' - ) { - this.incrementCounters(tsIdentifier, FaultID.GlobalThis); - } else { - this.checkLimitedStdLib(tsIdentifier, tsIdentSym); - this.handleRestrictedValues(tsIdentifier, tsIdentSym); + + if (tsIdentSym !== undefined) { + if ( + (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && + (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && + tsIdentifier.text === "globalThis" + ) + this.incrementCounters(node, FaultID.GlobalThis); + else if (this.tsUtils.isGlobalSymbol(tsIdentSym) && TsUtils.LIMITED_STD_GLOBAL_VAR.includes(tsIdentSym.getName())) + this.incrementCounters(node, FaultID.LimitedStdLibApi); + else + this.handleRestrictedValues(tsIdentifier, tsIdentSym); } } @@ -1631,7 +1638,7 @@ export class TypeScriptLinter { } if (this.tsUtils.hasEsObjectType(tsElementAccessExpr.expression)) { - this.incrementCounters(node, FaultID.EsObjectType); + this.incrementCounters(node, FaultID.EsObjectAccess); } } @@ -1699,22 +1706,25 @@ export class TypeScriptLinter { this.handleImportCall(tsCallExpr); this.handleRequireCall(tsCallExpr); - if (!!calleeSym) { + // NOTE: Keep handleFunctionApplyBindPropCall above handleGenericCallWithNoTypeArgs here!!! + if (calleeSym !== undefined) { + this.handleStdlibAPICall(tsCallExpr, calleeSym); + this.handleFunctionApplyBindPropCall(tsCallExpr, calleeSym); if (this.tsUtils.symbolHasEsObjectType(calleeSym)) { - this.incrementCounters(tsCallExpr, FaultID.EsObjectType); - } - // need to process Symbol call separatey in order to not report two times when using Symbol API - if (this.tsUtils.isStdSymbol(calleeSym)) { - this.incrementCounters(tsCallExpr, FaultID.SymbolType); + this.incrementCounters(tsCallExpr, FaultID.EsObjectAccess); } } - if (!!callSignature) { + if (callSignature !== undefined) { if (!this.tsUtils.isLibrarySymbol(calleeSym)) { this.handleGenericCallWithNoTypeArgs(tsCallExpr, callSignature); } this.handleStructIdentAndUndefinedInArgs(tsCallExpr, callSignature); } this.handleLibraryTypeCall(tsCallExpr, calleeType); + + if (ts.isPropertyAccessExpression(tsCallExpr.expression) && this.tsUtils.hasEsObjectType(tsCallExpr.expression.expression)) { + this.incrementCounters(node, FaultID.EsObjectAccess); + } } private handleImportCall(tsCallExpr: ts.CallExpression) { @@ -1784,6 +1794,22 @@ export class TypeScriptLinter { } } + + private static listApplyBindCallApis = [ + "Function.apply", + "Function.call", + "Function.bind", + "CallableFunction.apply", + "CallableFunction.call", + "CallableFunction.bind" + ]; + private handleFunctionApplyBindPropCall(tsCallExpr: ts.CallExpression, calleeSym: ts.Symbol) { + const exprName = this.tsTypeChecker.getFullyQualifiedName(calleeSym); + if (TypeScriptLinter.listApplyBindCallApis.includes(exprName)) { + this.incrementCounters(tsCallExpr, FaultID.FunctionApplyBindCall); + } + } + private handleStructIdentAndUndefinedInArgs(tsCallOrNewExpr: ts.CallExpression | ts.NewExpression, callSignature: ts.Signature) { if (!tsCallOrNewExpr.arguments) { return; @@ -1823,17 +1849,37 @@ export class TypeScriptLinter { } } - private checkLimitedStdLib(node: ts.Node, symbol: ts.Symbol) { - const parName = this.tsUtils.getParentSymbolName(symbol); - const res = parName ? TsUtils.LIMITED_STD_API.get(parName) : undefined; - if (res && res.arr.includes(symbol.name)) { - this.incrementCounters(node, res.fault); + + // let re = new RegExp("^(" + arr.reduce((acc, v) => ((acc ? (acc + "|") : "") + v)) +")$") + private static LimitedApis = new Map | null, fault: FaultID}> ([ + ["global", {arr: TsUtils.LIMITED_STD_GLOBAL_FUNC, fault: FaultID.LimitedStdLibApi}], + ["Object", {arr: TsUtils.LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], + ["ObjectConstructor", {arr: TsUtils.LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], + ["Reflect", {arr: TsUtils.LIMITED_STD_REFLECT_API, fault: FaultID.LimitedStdLibApi}], + ["ProxyHandler", {arr: TsUtils.LIMITED_STD_PROXYHANDLER_API, fault: FaultID.LimitedStdLibApi}], + ["ArrayBuffer", {arr: TsUtils.LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], + ["ArrayBufferConstructor", {arr: TsUtils.LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], + ["Symbol", {arr: null, fault: FaultID.SymbolType}], + ["SymbolConstructor", {arr: null, fault: FaultID.SymbolType}], + ]) + + private handleStdlibAPICall(callExpr: ts.CallExpression, calleeSym: ts.Symbol) { + const name = calleeSym.getName(); + const parName = this.tsUtils.getParentSymbolName(calleeSym); + if (parName === undefined) { + if (TsUtils.LIMITED_STD_GLOBAL_FUNC.includes(name)) { + this.incrementCounters(callExpr, FaultID.LimitedStdLibApi); + return; + } + let escapedName = calleeSym.escapedName; + if (escapedName === 'Symbol' || escapedName === 'SymbolConstructor') { + this.incrementCounters(callExpr, FaultID.SymbolType); + } return; } - const name = this.tsTypeChecker.getFullyQualifiedName(symbol); - if (TsUtils.LIMITED_STD_GLOBAL_API.includes(name)) { - this.incrementCounters(node, FaultID.LimitedStdLibApi) - return; + let lookup = TypeScriptLinter.LimitedApis.get(parName); + if (lookup !== undefined && (lookup.arr === null || lookup.arr.includes(name))) { + this.incrementCounters(callExpr, lookup.fault); } } @@ -1916,38 +1962,35 @@ export class TypeScriptLinter { } private handleTypeReference(node: ts.Node) { - const typeRef = node as ts.TypeReferenceNode; + let typeRef = node as ts.TypeReferenceNode; - const isESObject = this.tsUtils.isEsObjectType(typeRef); - const isPossiblyValidContext = this.tsUtils.isEsObjectPossiblyAllowed(typeRef); - if (isESObject && !isPossiblyValidContext) { - this.incrementCounters(node, FaultID.EsObjectType); - return; - } - - const typeName = this.tsUtils.entityNameToString(typeRef.typeName); - const isStdUtilityType = TsUtils.LIMITED_STANDARD_UTILITY_TYPES.includes(typeName); - if (isStdUtilityType) { + if ( + ts.isIdentifier(typeRef.typeName) && + TsUtils.LIMITED_STANDARD_UTILITY_TYPES.includes(typeRef.typeName.text) + ) this.incrementCounters(node, FaultID.UtilityType); - return; + else if (this.tsUtils.isEsObjectType(typeRef) && !this.tsUtils.isEsObjectAllowed(typeRef)) { + this.incrementCounters(node, FaultID.EsObjectType); } - - // Using Partial type is allowed only when its argument type is either Class or Interface. - const isStdPartial = this.tsUtils.entityNameToString(typeRef.typeName) === 'Partial'; - const hasSingleTypeArgument = !!typeRef.typeArguments && typeRef.typeArguments.length === 1; - const firstTypeArg = !!typeRef.typeArguments && hasSingleTypeArgument && typeRef.typeArguments[0]; - const argType = firstTypeArg && this.tsTypeChecker.getTypeFromTypeNode(firstTypeArg); - if (isStdPartial && argType && !argType.isClassOrInterface()) { - this.incrementCounters(node, FaultID.UtilityType); - return; + else if ( + ts.isIdentifier(typeRef.typeName) && + typeRef.typeName.text === "Partial" && + typeRef.typeArguments && + typeRef.typeArguments.length === 1 + ) { + // Using Partial type is allowed only when its argument type is either Class or Interface. + let argType = this.tsTypeChecker.getTypeFromTypeNode( + typeRef.typeArguments[0] + ); + if (!argType || !argType.isClassOrInterface()) + this.incrementCounters(node, FaultID.UtilityType); } } private handleMetaProperty(node: ts.Node) { let tsMetaProperty = node as ts.MetaProperty; - if (tsMetaProperty.name.text === "target") { + if (tsMetaProperty.name.text === "target") this.incrementCounters(node, FaultID.NewTarget); - } } private handleStructDeclaration(node: ts.Node) { diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 1639e5664..fcb5d1988 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -118,7 +118,9 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.StrictDiagnostic] = 'Strict diagnostic'; LinterConfig.nodeDesc[FaultID.UnsupportedDecorators] = 'Unsupported decorators'; LinterConfig.nodeDesc[FaultID.ImportAfterStatement] = 'Import declaration after other declaration or statement'; - LinterConfig.nodeDesc[FaultID.EsObjectType] = 'Restricted "ESObject" type'; + LinterConfig.nodeDesc[FaultID.EsObjectType] = '"ESObject" type'; + LinterConfig.nodeDesc[FaultID.EsObjectAssignment] = '"ESObject" type assignment'; + LinterConfig.nodeDesc[FaultID.EsObjectAccess] = '"ESObject" access'; LinterConfig.initTsSyntaxKindNames(); } diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 03674b19e..360d36bb1 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -18,7 +18,6 @@ import * as ts from 'typescript'; import { ProblemInfo } from './ProblemInfo'; import { AutofixInfo } from './AutofixInfo'; import { LinterConfig } from './TypeScriptLinterConfig' -import { FaultID } from "./Problems"; export function logTscDiagnostic(diagnostics: readonly ts.Diagnostic[], log: (message: any, ...args: any[]) => void) { diagnostics.forEach((diagnostic) => { @@ -106,123 +105,26 @@ export enum CheckType { export class TsUtils { static readonly ES_OBJECT = 'ESObject' - private static readonly LIMITED_STD_ARRAYBUFFER_API = [ - // properties - // methods - 'isView' + static readonly LIMITED_STD_GLOBAL_FUNC = [ + 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt' ]; - - private static readonly LIMITED_STD_OBJECT_API = [ - // properties - '__proto__', - // methods - '__defineGetter__', - '__defineSetter__', - '__lookupGetter__', - '__lookupSetter__', - 'assign', - 'create', - 'defineProperties', - 'defineProperty', - 'freeze', - 'fromEntries', - 'getOwnPropertyDescriptor', - 'getOwnPropertyDescriptors', - 'getOwnPropertySymbols', - 'getPrototypeOf', - 'hasOwnProperty', - 'is', - 'isExtensible', - 'isFrozen', - 'isPrototypeOf', - 'isSealed', - 'preventExtensions', - 'propertyIsEnumerable', - 'seal', - 'setPrototypeOf', - ]; - - private static readonly LIMITED_STD_PROXYHANDLER_API = [ - // properties - // methods - 'apply', - 'construct', - 'defineProperty', - 'deleteProperty', - 'get', - 'getOwnPropertyDescriptor', - 'getPrototypeOf', - 'has', - 'isExtensible', - 'ownKeys', - 'preventExtensions', - 'set', - 'setPrototypeOf' + static readonly LIMITED_STD_GLOBAL_VAR = ['Infinity', 'NaN']; + static readonly LIMITED_STD_OBJECT_API = [ + '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'assign', 'create', + 'defineProperties', 'defineProperty', 'freeze', 'fromEntries', 'getOwnPropertyDescriptor', + 'getOwnPropertyDescriptors', 'getOwnPropertySymbols', 'getPrototypeOf', 'hasOwnProperty', 'is', + 'isExtensible', 'isFrozen', 'isPrototypeOf', 'isSealed', 'preventExtensions', 'propertyIsEnumerable', + 'seal', 'setPrototypeOf' ]; - - private static readonly LIMITED_STD_REFLECT_API = [ - // properties - // methods - 'apply', - 'construct', - 'defineProperty', - 'deleteProperty', - 'getOwnPropertyDescriptor', - 'getPrototypeOf', - 'isExtensible', - 'preventExtensions', - 'setPrototypeOf', + static readonly LIMITED_STD_REFLECT_API = [ + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'isExtensible', 'preventExtensions', 'setPrototypeOf' ]; - - private static readonly LIMITED_STD_SYMBOL_API = [ - 'Symbol', - // properties - 'asyncIterator', - 'description', - 'hasInstance', - 'isConcatSpreadable', - 'match', - 'matchAll', - 'replace', - 'search', - 'species', - 'split', - 'toPrimitive', - 'toStringTag', - 'unscopables', - // methods - 'for', - 'keyFor', - 'toString', - 'valueOf', - ]; - - private static readonly LIMITED_STD_FUNCTION_API = [ - // properties - // methods - 'apply', - 'bind', - 'call', + static readonly LIMITED_STD_PROXYHANDLER_API = [ + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'has', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf' ]; - - static readonly LIMITED_STD_GLOBAL_API = [ - // properties - // methods - 'eval', - ]; - - static readonly LIMITED_STD_API = new Map, fault: FaultID}> ([ - ['Object', {arr: TsUtils.LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], - ['ObjectConstructor', {arr: TsUtils.LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], - ['Reflect', {arr: TsUtils.LIMITED_STD_REFLECT_API, fault: FaultID.LimitedStdLibApi}], - ['ProxyHandler', {arr: TsUtils.LIMITED_STD_PROXYHANDLER_API, fault: FaultID.LimitedStdLibApi}], - ['ArrayBuffer', {arr: TsUtils.LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], - ['ArrayBufferConstructor', {arr: TsUtils.LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], - ['Symbol', {arr: TsUtils.LIMITED_STD_SYMBOL_API, fault: FaultID.SymbolType}], - ['SymbolConstructor', {arr: TsUtils.LIMITED_STD_SYMBOL_API, fault: FaultID.SymbolType}], - ['Function', {arr: TsUtils.LIMITED_STD_FUNCTION_API, fault: FaultID.FunctionApplyBindCall}], - ['CallableFunction', {arr: TsUtils.LIMITED_STD_FUNCTION_API, fault: FaultID.FunctionApplyBindCall}], - ]) + static readonly LIMITED_STD_ARRAYBUFFER_API = ['isView']; static readonly NON_INITIALIZABLE_PROPERTY_DECORATORS = ['Link', 'Consume', 'ObjectLink', 'Prop', 'BuilderParam']; @@ -240,6 +142,8 @@ export class TsUtils { 'ThisType', 'Uppercase', 'Lowercase', 'Capitalize', 'Uncapitalize', ]; + static readonly ALLOWED_STD_SYMBOL_API = ['iterator'] + static readonly ARKUI_DECORATORS = [ 'AnimatableExtend', 'Builder', @@ -1196,7 +1100,7 @@ export class TsUtils { public isStdObjectAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Object'); + return !!parentName && (parentName === 'Object' || parentName === 'ObjectConstructor'); } public isStdReflectAPI(symbol: ts.Symbol): boolean { @@ -1211,22 +1115,18 @@ export class TsUtils { public isStdArrayAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Array'); + return !!parentName && (parentName === 'Array' || parentName === 'ArrayConstructor'); } public isStdArrayBufferAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ArrayBuffer'); - } - - public isStdSymbol(symbol: ts.Symbol): boolean { - const name = this.tsTypeChecker.getFullyQualifiedName(symbol) - return name === 'Symbol'; + return !!parentName && (parentName === 'ArrayBuffer' || parentName === 'ArrayBufferConstructor'); } - public isStdSymbolAPI(symbol: ts.Symbol): boolean { + public isSymbolAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && parentName === 'Symbol'; + let name = parentName ? parentName : symbol.escapedName; + return name === 'Symbol' || name === 'SymbolConstructor'; } public isDefaultImport(importSpec: ts.ImportSpecifier): boolean { @@ -1477,29 +1377,22 @@ export class TsUtils { typeNode.typeName.text == TsUtils.ES_OBJECT; } - public isInsideBlock(node: ts.Node): boolean { - let par = node.parent - while (par) { - if (ts.isBlock(par)) { + public isEsObjectAllowed(typeRef: ts.TypeReferenceNode): boolean { + let node = typeRef.parent; + + if (!this.isVarDeclaration(node)) { + return false; + } + + while (node) { + if (ts.isBlock(node)) { return true; } - par = par.parent; + node = node.parent; } return false; } - public isEsObjectPossiblyAllowed(typeRef: ts.TypeReferenceNode): boolean { - return ts.isVariableDeclaration(typeRef.parent); - } - - public isValueAssignableToESObject(node: ts.Node): boolean { - if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) { - return false; - } - const valueType = this.tsTypeChecker.getTypeAtLocation(node); - return this.isUnsupportedType(valueType) || this.isAnonymousType(valueType) - } - public getVariableDeclarationTypeNode(node: ts.Node): ts.TypeNode | undefined { let sym = this.trueSymbolAtLocation(node); if (sym === undefined) { diff --git a/linter-4.2/test/es_object.ts b/linter-4.2/test/es_object.ts index 445b5c0c0..d9715b772 100644 --- a/linter-4.2/test/es_object.ts +++ b/linter-4.2/test/es_object.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { fooOh, barOh } from './oh_modules/ohos_lib' + type ESObject = any class A {} @@ -174,20 +174,3 @@ interface CL extends ESObject {} export interface CLS extends ESObject {} foo2({ k: 'k', h: {t: 1}}) // we can assign anything to the esobject, even untyped literal -let q1: ESObject = 1; // CTE - ``ESObject`` typed variable can only be local -let q2: ESObject = fooOh(); // CTE - ``ESObject`` typed variable can only be local -let q3: ESObject = q2; // CTE - ``ESObject`` typed variable can only be local -function f() { - let e1 = fooOh(); // CTE - type of e1 is `any` - let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values - let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values - let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values - let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values - let e6: ESObject = fooOh(); // OK - explicitly annotaded as ESObject - let e7: ESObject = e6; // OK - initialize ESObject with ESObject - e6['prop'] // CTE - can't access dynamic properties of ESObject - e6[1] // CTE - can't access dynamic properties of ESObject - e6.prop // CTE - can't access dynamic properties of ESObject - barOh(e6) // OK - ESObject is passed to interop call - e6 = e7 // OK - ESObject is assigned to ESObject -} diff --git a/linter-4.2/test/es_object.ts.relax.json b/linter-4.2/test/es_object.ts.relax.json index f3d5acdb4..10bd5f5bd 100644 --- a/linter-4.2/test/es_object.ts.relax.json +++ b/linter-4.2/test/es_object.ts.relax.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 5, + "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 77, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 78, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 79, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 80, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 82, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 83, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 85, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 86, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 87, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 88, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 90, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 91, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 93, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 94, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 95, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 96, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 98, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 99, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 176, @@ -594,83 +594,6 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" - }, - { - "line": 177, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 178, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 179, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 181, - "column": 9, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 182, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 183, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 184, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 185, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 188, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 189, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 190, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/es_object.ts.strict.json b/linter-4.2/test/es_object.ts.strict.json index 5c869e41f..10bd5f5bd 100644 --- a/linter-4.2/test/es_object.ts.strict.json +++ b/linter-4.2/test/es_object.ts.strict.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 5, + "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 77, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 78, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 79, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 80, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 82, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 83, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 85, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 86, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 87, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 88, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 90, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 91, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 93, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 94, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 95, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 96, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 98, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 99, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 176, @@ -594,83 +594,6 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" - }, - { - "line": 177, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 178, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 179, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 181, - "column": 9, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 182, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 183, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 184, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 185, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 188, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 189, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 190, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } - ] + ] } \ No newline at end of file diff --git a/linter-4.2/test/function_expression.ts.autofix.json b/linter-4.2/test/function_expression.ts.autofix.json index 90e6f3f3b..c571fa05a 100644 --- a/linter-4.2/test/function_expression.ts.autofix.json +++ b/linter-4.2/test/function_expression.ts.autofix.json @@ -335,6 +335,14 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 102, + "column": 15, + "problem": "FunctionApplyBindCall", + "autofixable": false, + "suggest": "", + "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" + }, { "line": 102, "column": 15, @@ -350,14 +358,6 @@ "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, - { - "line": 104, - "column": 7, - "problem": "FunctionApplyBindCall", - "autofixable": false, - "suggest": "", - "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" - }, { "line": 108, "column": 16, diff --git a/linter-4.2/test/function_expression.ts.relax.json b/linter-4.2/test/function_expression.ts.relax.json index 8e6077236..48f6e1a27 100644 --- a/linter-4.2/test/function_expression.ts.relax.json +++ b/linter-4.2/test/function_expression.ts.relax.json @@ -57,8 +57,8 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 104, - "column": 7, + "line": 102, + "column": 15, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" diff --git a/linter-4.2/test/function_expression.ts.strict.json b/linter-4.2/test/function_expression.ts.strict.json index 1233c4e7d..fe4750449 100644 --- a/linter-4.2/test/function_expression.ts.strict.json +++ b/linter-4.2/test/function_expression.ts.strict.json @@ -206,16 +206,16 @@ { "line": 102, "column": 15, - "problem": "FunctionExpression", + "problem": "FunctionApplyBindCall", "suggest": "", - "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { - "line": 104, - "column": 7, - "problem": "FunctionApplyBindCall", + "line": 102, + "column": 15, + "problem": "FunctionExpression", "suggest": "", - "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { "line": 108, diff --git a/linter-4.2/test/function_object_methods.ts.relax.json b/linter-4.2/test/function_object_methods.ts.relax.json index 790856d4f..96e3fcaf1 100644 --- a/linter-4.2/test/function_object_methods.ts.relax.json +++ b/linter-4.2/test/function_object_methods.ts.relax.json @@ -23,7 +23,7 @@ }, { "line": 29, - "column": 35, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -37,21 +37,21 @@ }, { "line": 30, - "column": 45, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 37, - "column": 37, + "column": 23, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 38, - "column": 40, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -65,7 +65,7 @@ }, { "line": 68, - "column": 44, + "column": 22, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -79,42 +79,42 @@ }, { "line": 70, - "column": 35, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 75, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 78, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 81, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 82, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 87, - "column": 32, + "column": 16, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -128,7 +128,7 @@ }, { "line": 94, - "column": 37, + "column": 20, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -142,42 +142,42 @@ }, { "line": 96, - "column": 30, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 101, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 104, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 107, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 108, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 113, - "column": 21, + "column": 10, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -226,35 +226,35 @@ }, { "line": 136, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 137, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 138, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 139, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 141, - "column": 5, + "column": 1, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" diff --git a/linter-4.2/test/function_object_methods.ts.strict.json b/linter-4.2/test/function_object_methods.ts.strict.json index 2a7c8ccd9..e90572ea9 100644 --- a/linter-4.2/test/function_object_methods.ts.strict.json +++ b/linter-4.2/test/function_object_methods.ts.strict.json @@ -23,7 +23,7 @@ }, { "line": 29, - "column": 35, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -37,21 +37,21 @@ }, { "line": 30, - "column": 45, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 37, - "column": 37, + "column": 23, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 38, - "column": 40, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -65,7 +65,7 @@ }, { "line": 68, - "column": 44, + "column": 22, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -79,42 +79,42 @@ }, { "line": 70, - "column": 35, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 75, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 78, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 81, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 82, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 87, - "column": 32, + "column": 16, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -128,7 +128,7 @@ }, { "line": 94, - "column": 37, + "column": 20, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -142,42 +142,42 @@ }, { "line": 96, - "column": 30, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 101, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 104, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 107, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 108, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 113, - "column": 21, + "column": 10, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -254,35 +254,35 @@ }, { "line": 136, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 137, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 138, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 139, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 141, - "column": 5, + "column": 1, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" diff --git a/linter-4.2/test/limited_stdlib_api.ts b/linter-4.2/test/limited_stdlib_api.ts index 0cc445fe7..918ecda77 100644 --- a/linter-4.2/test/limited_stdlib_api.ts +++ b/linter-4.2/test/limited_stdlib_api.ts @@ -28,7 +28,7 @@ decodeURIComponent(''); escape(''); unescape(''); -// global and window are not portabe, so they are excluded from test suite +global.eval('console.log("foo")'); globalThis.eval('console.log("foo")'); class C {} @@ -90,10 +90,4 @@ if (handler.set) handler.set(c, "prop", 1, c); if (handler.setPrototypeOf) handler.setPrototypeOf(c, null); /// Array -ArrayBuffer.isView({}); - -Number.NaN; -Number.isFinite(1); -Number.isNaN(2); -Number.parseFloat('3'); -Number.parseInt('4', 10); +ArrayBuffer.isView({}); \ No newline at end of file diff --git a/linter-4.2/test/limited_stdlib_api.ts.autofix.json b/linter-4.2/test/limited_stdlib_api.ts.autofix.json index 6286f4c5d..7c2eb1d35 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.autofix.json +++ b/linter-4.2/test/limited_stdlib_api.ts.autofix.json @@ -1,4 +1,18 @@ { + "copyright": [ + "Copyright (c) 2023-2023 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." + ], "nodes": [ { "line": 17, @@ -9,24 +23,80 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 18, + "column": 11, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 19, + "column": 11, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 20, "column": 1, - "problem": "GlobalThis", + "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 21, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 22, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 23, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 32, - "column": 12, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "autofixable": false, + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, { "line": 43, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -34,7 +104,7 @@ }, { "line": 44, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -42,7 +112,7 @@ }, { "line": 45, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -58,7 +128,7 @@ }, { "line": 46, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -66,7 +136,7 @@ }, { "line": 48, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -74,7 +144,7 @@ }, { "line": 49, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -82,7 +152,7 @@ }, { "line": 50, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -90,7 +160,7 @@ }, { "line": 51, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -98,7 +168,7 @@ }, { "line": 52, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -106,7 +176,7 @@ }, { "line": 53, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -114,7 +184,7 @@ }, { "line": 54, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -122,7 +192,7 @@ }, { "line": 55, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -130,7 +200,7 @@ }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -138,7 +208,7 @@ }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -146,7 +216,7 @@ }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -154,7 +224,7 @@ }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -162,7 +232,7 @@ }, { "line": 60, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -170,7 +240,7 @@ }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -178,7 +248,7 @@ }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -186,7 +256,7 @@ }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -194,7 +264,7 @@ }, { "line": 66, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -202,7 +272,7 @@ }, { "line": 67, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -218,7 +288,7 @@ }, { "line": 68, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -234,7 +304,7 @@ }, { "line": 69, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -242,7 +312,7 @@ }, { "line": 70, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -250,7 +320,7 @@ }, { "line": 71, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -258,7 +328,7 @@ }, { "line": 72, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -266,7 +336,7 @@ }, { "line": 73, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -274,7 +344,7 @@ }, { "line": 74, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -290,15 +360,7 @@ }, { "line": 78, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 78, - "column": 28, + "column": 20, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -306,23 +368,7 @@ }, { "line": 79, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 79, - "column": 32, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 80, - "column": 13, + "column": 24, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -330,7 +376,7 @@ }, { "line": 80, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -346,15 +392,7 @@ }, { "line": 81, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 81, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -362,23 +400,7 @@ }, { "line": 82, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 82, - "column": 26, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 83, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -386,15 +408,7 @@ }, { "line": 83, - "column": 47, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 84, - "column": 13, + "column": 39, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -402,7 +416,7 @@ }, { "line": 84, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -410,23 +424,7 @@ }, { "line": 85, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 85, - "column": 26, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 86, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -434,7 +432,7 @@ }, { "line": 86, - "column": 35, + "column": 27, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -442,23 +440,7 @@ }, { "line": 87, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 87, - "column": 30, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 88, - "column": 13, + "column": 22, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -466,15 +448,7 @@ }, { "line": 88, - "column": 40, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 89, - "column": 13, + "column": 32, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -482,7 +456,7 @@ }, { "line": 89, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -490,15 +464,7 @@ }, { "line": 90, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 90, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -506,7 +472,7 @@ }, { "line": 93, - "column": 13, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", diff --git a/linter-4.2/test/limited_stdlib_api.ts.relax.json b/linter-4.2/test/limited_stdlib_api.ts.relax.json index 7f5db9e71..2cca52540 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.relax.json +++ b/linter-4.2/test/limited_stdlib_api.ts.relax.json @@ -1,4 +1,18 @@ { + "copyright": [ + "Copyright (c) 2023-2023 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." + ], "nodes": [ { "line": 17, @@ -8,36 +22,85 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 18, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 19, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 20, "column": 1, - "problem": "GlobalThis", + "problem": "LimitedStdLibApi", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 21, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 22, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 23, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 32, - "column": 12, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, { "line": 43, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 44, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 45, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -51,133 +114,133 @@ }, { "line": 46, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 48, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 49, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 50, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 51, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 52, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 53, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 54, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 55, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 60, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 66, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 67, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -191,7 +254,7 @@ }, { "line": 68, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -205,42 +268,42 @@ }, { "line": 69, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 70, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 71, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 72, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 73, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 74, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -254,42 +317,21 @@ }, { "line": 78, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 78, - "column": 28, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 79, - "column": 13, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 79, - "column": 32, + "column": 24, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 80, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 80, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -303,147 +345,77 @@ }, { "line": 81, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 81, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 82, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 82, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 83, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 83, - "column": 47, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 84, - "column": 13, + "column": 39, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 84, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 85, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 85, - "column": 26, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 86, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 86, - "column": 35, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 87, - "column": 13, + "column": 27, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 87, - "column": 30, + "column": 22, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 88, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 88, - "column": 40, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 89, - "column": 13, + "column": 32, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 89, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 90, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 90, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 93, - "column": 13, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter-4.2/test/limited_stdlib_api.ts.strict.json b/linter-4.2/test/limited_stdlib_api.ts.strict.json index 7f5db9e71..2cca52540 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.strict.json +++ b/linter-4.2/test/limited_stdlib_api.ts.strict.json @@ -1,4 +1,18 @@ { + "copyright": [ + "Copyright (c) 2023-2023 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." + ], "nodes": [ { "line": 17, @@ -8,36 +22,85 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 18, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 19, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 20, "column": 1, - "problem": "GlobalThis", + "problem": "LimitedStdLibApi", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 21, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 22, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 23, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 32, - "column": 12, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, { "line": 43, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 44, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 45, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -51,133 +114,133 @@ }, { "line": 46, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 48, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 49, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 50, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 51, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 52, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 53, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 54, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 55, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 60, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 66, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 67, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -191,7 +254,7 @@ }, { "line": 68, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -205,42 +268,42 @@ }, { "line": 69, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 70, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 71, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 72, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 73, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 74, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -254,42 +317,21 @@ }, { "line": 78, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 78, - "column": 28, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 79, - "column": 13, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 79, - "column": 32, + "column": 24, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 80, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 80, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -303,147 +345,77 @@ }, { "line": 81, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 81, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 82, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 82, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 83, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 83, - "column": 47, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 84, - "column": 13, + "column": 39, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 84, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 85, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 85, - "column": 26, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 86, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 86, - "column": 35, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 87, - "column": 13, + "column": 27, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 87, - "column": 30, + "column": 22, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 88, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 88, - "column": 40, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 89, - "column": 13, + "column": 32, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 89, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 90, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 90, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 93, - "column": 13, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter-4.2/test/new_target.ts.relax.json b/linter-4.2/test/new_target.ts.relax.json index 0b83a1198..5ec99daa2 100644 --- a/linter-4.2/test/new_target.ts.relax.json +++ b/linter-4.2/test/new_target.ts.relax.json @@ -16,7 +16,7 @@ "nodes": [ { "line": 19, - "column": 12, + "column": 5, "problem": "LimitedStdLibApi" }, { diff --git a/linter-4.2/test/new_target.ts.strict.json b/linter-4.2/test/new_target.ts.strict.json index 0b83a1198..5ec99daa2 100644 --- a/linter-4.2/test/new_target.ts.strict.json +++ b/linter-4.2/test/new_target.ts.strict.json @@ -16,7 +16,7 @@ "nodes": [ { "line": 19, - "column": 12, + "column": 5, "problem": "LimitedStdLibApi" }, { diff --git a/linter-4.2/test/oh_modules/ohos_lib.ts b/linter-4.2/test/oh_modules/ohos_lib.ts index c69856185..a0aa74c87 100644 --- a/linter-4.2/test/oh_modules/ohos_lib.ts +++ b/linter-4.2/test/oh_modules/ohos_lib.ts @@ -20,6 +20,3 @@ export interface OhosI { export function ohFunction1({d: OhosI}): void {} // incorrect usage, but it was an issue, so we check it too export function ohFunction2(p: {d: OhosI}): void {} - -export function fooOh(): any {} -export function barOh(a: any) {} diff --git a/linter-4.2/test/symbol_api.ts.relax.json b/linter-4.2/test/symbol_api.ts.relax.json index e62c8c7b7..c2211cf10 100644 --- a/linter-4.2/test/symbol_api.ts.relax.json +++ b/linter-4.2/test/symbol_api.ts.relax.json @@ -16,77 +16,77 @@ "nodes": [ { "line": 16, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 17, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 18, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 20, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 21, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 22, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 23, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 24, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 25, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 26, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 27, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" @@ -107,7 +107,7 @@ }, { "line": 33, - "column": 17, + "column": 10, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" diff --git a/linter-4.2/test/symbol_api.ts.strict.json b/linter-4.2/test/symbol_api.ts.strict.json index e62c8c7b7..c2211cf10 100644 --- a/linter-4.2/test/symbol_api.ts.strict.json +++ b/linter-4.2/test/symbol_api.ts.strict.json @@ -16,77 +16,77 @@ "nodes": [ { "line": 16, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 17, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 18, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 20, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 21, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 22, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 23, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 24, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 25, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 26, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 27, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" @@ -107,7 +107,7 @@ }, { "line": 33, - "column": 17, + "column": 10, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" diff --git a/linter-4.2/test/utility_types.ts.relax.json b/linter-4.2/test/utility_types.ts.relax.json index fe6131546..63a56e5cd 100644 --- a/linter-4.2/test/utility_types.ts.relax.json +++ b/linter-4.2/test/utility_types.ts.relax.json @@ -266,7 +266,7 @@ }, { "line": 178, - "column": 18, + "column": 12, "problem": "FunctionApplyBindCall" }, { @@ -286,7 +286,7 @@ }, { "line": 187, - "column": 60, + "column": 54, "problem": "FunctionApplyBindCall" }, { diff --git a/linter-4.2/test/utility_types.ts.strict.json b/linter-4.2/test/utility_types.ts.strict.json index c5686de4b..cb2916b9d 100644 --- a/linter-4.2/test/utility_types.ts.strict.json +++ b/linter-4.2/test/utility_types.ts.strict.json @@ -291,7 +291,7 @@ }, { "line": 178, - "column": 18, + "column": 12, "problem": "FunctionApplyBindCall" }, { @@ -316,7 +316,7 @@ }, { "line": 187, - "column": 60, + "column": 54, "problem": "FunctionApplyBindCall" }, { diff --git a/linter-4.2/test_rules/rule132.ts.autofix.json b/linter-4.2/test_rules/rule132.ts.autofix.json index d1868ca7f..9002b4276 100644 --- a/linter-4.2/test_rules/rule132.ts.autofix.json +++ b/linter-4.2/test_rules/rule132.ts.autofix.json @@ -2,7 +2,7 @@ "nodes": [ { "line": 7, - "column": 16, + "column": 9, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", diff --git a/linter-4.2/test_rules/rule132.ts.relax.json b/linter-4.2/test_rules/rule132.ts.relax.json index 21468ce90..192c3aa10 100644 --- a/linter-4.2/test_rules/rule132.ts.relax.json +++ b/linter-4.2/test_rules/rule132.ts.relax.json @@ -2,7 +2,7 @@ "nodes": [ { "line": 7, - "column": 16, + "column": 9, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter-4.2/test_rules/rule132.ts.strict.json b/linter-4.2/test_rules/rule132.ts.strict.json index 21468ce90..192c3aa10 100644 --- a/linter-4.2/test_rules/rule132.ts.strict.json +++ b/linter-4.2/test_rules/rule132.ts.strict.json @@ -2,7 +2,7 @@ "nodes": [ { "line": 7, - "column": 16, + "column": 9, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter/docs/rules/recipe144.md b/linter/docs/rules/recipe144.md index 0bbcfefd4..b28c181c5 100644 --- a/linter/docs/rules/recipe144.md +++ b/linter/docs/rules/recipe144.md @@ -9,7 +9,8 @@ The most part of the restricted APIs relates to manipulating objects in a dynamic manner, which is not compatible with static typing. The usage of the following APIs is prohibited: -Properties and functions of the global object: ``eval`` +Properties and functions of the global object: ``eval``, +``Infinity``, ``NaN``, ``isFinite``, ``isNaN``, ``parseFloat``, ``parseInt`` ``Object``: ``__proto__``, ``__defineGetter__``, ``__defineSetter__``, ``__lookupGetter__``, ``__lookupSetter__``, ``assign``, ``create``, diff --git a/linter/docs/rules/recipe151.md b/linter/docs/rules/recipe151.md deleted file mode 100644 index 0b00ba643..000000000 --- a/linter/docs/rules/recipe151.md +++ /dev/null @@ -1,54 +0,0 @@ -# Usage of ``ESObject`` type is restricted - -Rule ``arkts-limited-esobject`` - -**Severity: warning** - -ArkTS does not allow using ``ESObject`` type in some cases. The most part of limitations -are put in place in order to prevent spread of dynamic objects in the static codebase. -The only scenario where it is permited to use ``ESObject`` as type specifier is in local -variable declaration. Initialization of variables with ``ESObject`` type is also limited. -Such variables can only be initialized with values that originate from interop: -other ``ESObject`` typed variables, any, unknown, variables with anonymous type, etc. -It is prohibited to initialize ``ESObject`` typed variable with statically typed value. -Varaible of type ``ESObject`` can only be passed to interop calls and assigned to other -variables of type ``ESObject``. - - -## ArkTS - - -``` - // lib.d.ts - declare function foo(): any; - declare function bar(a: any): number; - - // main.ets - let e0: ESObject = foo(); // CTE - ``ESObject`` typed variable can only be local - - function f() { - let e1 = foo(); // CTE - type of e1 is `any` - let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values - let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values - let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values - let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values - let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject - let e7 = e6; // OK - initialize ESObject with ESObject - e6['prop'] // CTE - can't access dynamic properties of ESObject - e6[1] // CTE - can't access dynamic properties of ESObject - e6.prop // CTE - can't access dynamic properties of ESObject - bar(e6) // OK - ESObject is passed to interop call - } -``` - - -## See also - -- Recipe 001: Objects with property names that are not identifiers are not supported (``arkts-identifiers-as-prop-names``) -- Recipe 002: ``Symbol()`` API is not supported (``arkts-no-symbol``) -- Recipe 029: Indexed access is not supported for fields (``arkts-no-props-by-index``) -- Recipe 060: ``typeof`` operator is allowed only in expression contexts (``arkts-no-type-query``) -- Recipe 066: ``in`` operator is not supported (``arkts-no-in``) -- Recipe 137: ``globalThis`` is not supported (``arkts-no-globalthis``) - - diff --git a/linter/src/Autofixer.ts b/linter/src/Autofixer.ts index 59c1cc2d3..f6dc5129d 100644 --- a/linter/src/Autofixer.ts +++ b/linter/src/Autofixer.ts @@ -15,7 +15,7 @@ import * as ts from 'typescript'; import { AutofixInfo } from './autofixes/AutofixInfo'; -import { FaultID } from './utils/consts/Problems'; +import { FaultID } from './Problems'; import { isAssignmentOperator } from './utils/functions/isAssignmentOperator'; export const AUTOFIX_ALL: AutofixInfo = { diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index e977c8e19..aba65028d 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -170,4 +170,3 @@ cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (ar cookBookTag[148] = 'No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; -cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobject)'; diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index d4bb026cf..a40ad5b38 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -1,19 +1,19 @@ /* * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); + * 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, + * 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 { FaultID } from './utils/consts/Problems'; +import { FaultID } from './Problems'; export class FaultAttributs { migratable?: boolean; @@ -23,89 +23,91 @@ export class FaultAttributs { export const faultsAttrs: FaultAttributs[] = []; -faultsAttrs[FaultID.LiteralAsPropertyName] = { migratable: true, cookBookRef: '1' }; -faultsAttrs[FaultID.ComputedPropertyName] = { cookBookRef: '1' }; -faultsAttrs[FaultID.SymbolType] = { cookBookRef: '2' }; -faultsAttrs[FaultID.PrivateIdentifier] = { migratable: true, cookBookRef: '3' }; -faultsAttrs[FaultID.DeclWithDuplicateName] = { migratable: true, cookBookRef: '4' }; -faultsAttrs[FaultID.VarDeclaration] = { migratable: true, cookBookRef: '5' }; -faultsAttrs[FaultID.AnyType] = { cookBookRef: '8' }; -faultsAttrs[FaultID.UnknownType] = { cookBookRef: '8' }; -faultsAttrs[FaultID.CallSignature] = { cookBookRef: '14' }; -faultsAttrs[FaultID.ConstructorType] = { cookBookRef: '15' }; -faultsAttrs[FaultID.MultipleStaticBlocks] = { cookBookRef: '16' }; -faultsAttrs[FaultID.IndexMember] = { cookBookRef: '17' }; -faultsAttrs[FaultID.IntersectionType] = { cookBookRef: '19' }; -faultsAttrs[FaultID.ThisType] = { cookBookRef: '21' }; -faultsAttrs[FaultID.ConditionalType] = { cookBookRef: '22' }; -faultsAttrs[FaultID.ParameterProperties] = { migratable: true, cookBookRef: '25' }; -faultsAttrs[FaultID.ConstructorIface] = { cookBookRef: '27' }; -faultsAttrs[FaultID.IndexedAccessType] = { cookBookRef: '28' }; -faultsAttrs[FaultID.PropertyAccessByIndex] = { migratable: true, cookBookRef: '29' }; -faultsAttrs[FaultID.StructuralIdentity] = { cookBookRef: '30' }; -faultsAttrs[FaultID.GenericCallNoTypeArgs] = { cookBookRef: '34' }; -faultsAttrs[FaultID.RegexLiteral] = { cookBookRef: '37' }; -faultsAttrs[FaultID.ObjectLiteralNoContextType] = { cookBookRef: '38' }; -faultsAttrs[FaultID.ObjectTypeLiteral] = { cookBookRef: '40' }; -faultsAttrs[FaultID.ArrayLiteralNoContextType] = { cookBookRef: '43' }; -faultsAttrs[FaultID.FunctionExpression] = { migratable: true, cookBookRef: '46' }; -faultsAttrs[FaultID.LambdaWithTypeParameters] = { migratable: true, cookBookRef: '49' }; -faultsAttrs[FaultID.ClassExpression] = { migratable: true, cookBookRef: '50' }; -faultsAttrs[FaultID.ImplementsClass] = { cookBookRef: '51' }; -faultsAttrs[FaultID.MethodReassignment] = { cookBookRef: '52' }; -faultsAttrs[FaultID.TypeAssertion] = { migratable: true, cookBookRef: '53' }; -faultsAttrs[FaultID.JsxElement] = { cookBookRef: '54' }; -faultsAttrs[FaultID.UnaryArithmNotNumber] = { cookBookRef: '55' }; -faultsAttrs[FaultID.DeleteOperator] = { cookBookRef: '59' }; -faultsAttrs[FaultID.TypeQuery] = { cookBookRef: '60' }; -faultsAttrs[FaultID.InstanceofUnsupported] = { cookBookRef: '65' }; -faultsAttrs[FaultID.InOperator] = { cookBookRef: '66' }; -faultsAttrs[FaultID.DestructuringAssignment] = { migratable: true, cookBookRef: '69' }; -faultsAttrs[FaultID.CommaOperator] = { cookBookRef: '71' }; -faultsAttrs[FaultID.DestructuringDeclaration] = { migratable: true, cookBookRef: '74' }; -faultsAttrs[FaultID.CatchWithUnsupportedType] = { migratable: true, cookBookRef: '79' }; -faultsAttrs[FaultID.ForInStatement] = { cookBookRef: '80' }; -faultsAttrs[FaultID.MappedType] = { cookBookRef: '83' }; -faultsAttrs[FaultID.WithStatement] = { cookBookRef: '84' }; -faultsAttrs[FaultID.ThrowStatement] = { migratable: true, cookBookRef: '87' }; -faultsAttrs[FaultID.LimitedReturnTypeInference] = { migratable: true, cookBookRef: '90'}; -faultsAttrs[FaultID.DestructuringParameter] = { cookBookRef: '91' }; -faultsAttrs[FaultID.LocalFunction] = { migratable: true, cookBookRef: '92' }; -faultsAttrs[FaultID.FunctionContainsThis] = { cookBookRef: '93' }; -faultsAttrs[FaultID.GeneratorFunction] = { cookBookRef: '94' }; -faultsAttrs[FaultID.YieldExpression] = { cookBookRef: '94' }; -faultsAttrs[FaultID.IsOperator] = { cookBookRef: '96' }; -faultsAttrs[FaultID.SpreadOperator] = { cookBookRef: '99' }; -faultsAttrs[FaultID.IntefaceExtendDifProps] = { cookBookRef: '102' }; -faultsAttrs[FaultID.InterfaceMerging] = { cookBookRef: '103' }; -faultsAttrs[FaultID.InterfaceExtendsClass] = { cookBookRef: '104' }; -faultsAttrs[FaultID.ConstructorFuncs] = { cookBookRef: '106' }; -faultsAttrs[FaultID.EnumMemberNonConstInit] = { cookBookRef: '111' }; -faultsAttrs[FaultID.EnumMerging] = { cookBookRef: '113' }; -faultsAttrs[FaultID.NamespaceAsObject] = { cookBookRef: '114' }; -faultsAttrs[FaultID.NonDeclarationInNamespace] = { cookBookRef: '116' }; -faultsAttrs[FaultID.ImportFromPath] = { cookBookRef: '119' }; -faultsAttrs[FaultID.TypeOnlyImport] = { migratable: true, cookBookRef: '118' }; -faultsAttrs[FaultID.DefaultImport] = { migratable: true, cookBookRef: '120' }; -faultsAttrs[FaultID.ImportAssignment] = { cookBookRef: '121' }; -faultsAttrs[FaultID.ExportAssignment] = { cookBookRef: '126' }; -faultsAttrs[FaultID.TypeOnlyExport] = { migratable: true, cookBookRef: '127' }; -faultsAttrs[FaultID.ShorthandAmbientModuleDecl] = { cookBookRef: '128' }; -faultsAttrs[FaultID.WildcardsInModuleName] = { cookBookRef: '129' }; -faultsAttrs[FaultID.UMDModuleDefinition] = { cookBookRef: '130' }; -faultsAttrs[FaultID.NewTarget] = { cookBookRef: '132' }; -faultsAttrs[FaultID.DefiniteAssignment] = { warning: true, cookBookRef: '134' }; -faultsAttrs[FaultID.Prototype] = { cookBookRef: '136' }; -faultsAttrs[FaultID.GlobalThis] = { cookBookRef: '137' }; -faultsAttrs[FaultID.UtilityType] = { cookBookRef: '138' }; -faultsAttrs[FaultID.PropertyDeclOnFunction] = { cookBookRef: '139' }; -faultsAttrs[FaultID.FunctionApplyBindCall] = { cookBookRef: '140' }; -faultsAttrs[FaultID.ConstAssertion] = { cookBookRef: '142' }; -faultsAttrs[FaultID.ImportAssertion] = { cookBookRef: '143' }; -faultsAttrs[FaultID.LimitedStdLibApi] = { cookBookRef: '144' }; -faultsAttrs[FaultID.StrictDiagnostic] = { cookBookRef: '145' }; -faultsAttrs[FaultID.ErrorSuppression] = { cookBookRef: '146' }; -faultsAttrs[FaultID.UnsupportedDecorators] = { warning: true, cookBookRef: '148' }; -faultsAttrs[FaultID.ClassAsObject] = { cookBookRef: '149' }; -faultsAttrs[FaultID.ImportAfterStatement] = { cookBookRef: '150' }; -faultsAttrs[FaultID.EsObjectType] = { warning: true, cookBookRef: '151' }; +faultsAttrs[FaultID.LiteralAsPropertyName] = {migratable: true, cookBookRef: '1',}; +faultsAttrs[FaultID.ComputedPropertyName] = {cookBookRef: '1',}; +faultsAttrs[FaultID.SymbolType] = {cookBookRef: '2',}; +faultsAttrs[FaultID.PrivateIdentifier] = {migratable: true, cookBookRef: '3',}; +faultsAttrs[FaultID.DeclWithDuplicateName] = {migratable: true, cookBookRef: '4',}; +faultsAttrs[FaultID.VarDeclaration] = {migratable: true, cookBookRef: '5',}; +faultsAttrs[FaultID.AnyType] = {cookBookRef: '8'}; +faultsAttrs[FaultID.UnknownType] = {cookBookRef: '8',}; +faultsAttrs[FaultID.CallSignature] = {cookBookRef: '14',}; +faultsAttrs[FaultID.ConstructorType] = {cookBookRef: '15',}; +faultsAttrs[FaultID.MultipleStaticBlocks] = {cookBookRef: '16',}; +faultsAttrs[FaultID.IndexMember] = {cookBookRef: '17',}; +faultsAttrs[FaultID.IntersectionType] = {cookBookRef: '19',}; +faultsAttrs[FaultID.ThisType] = {cookBookRef: '21',}; +faultsAttrs[FaultID.ConditionalType] = {cookBookRef: '22',}; +faultsAttrs[FaultID.ParameterProperties] = {migratable: true, cookBookRef: '25',}; +faultsAttrs[FaultID.ConstructorIface] = {cookBookRef: '27',}; +faultsAttrs[FaultID.IndexedAccessType] = {cookBookRef: '28',}; +faultsAttrs[FaultID.PropertyAccessByIndex] = {migratable: true, cookBookRef: '29',}; +faultsAttrs[FaultID.StructuralIdentity] = {cookBookRef: '30',}; +faultsAttrs[FaultID.GenericCallNoTypeArgs] = {cookBookRef: '34',}; +faultsAttrs[FaultID.RegexLiteral] = {cookBookRef: '37',}; +faultsAttrs[FaultID.ObjectLiteralNoContextType] = {cookBookRef: '38',}; +faultsAttrs[FaultID.ObjectTypeLiteral] = {cookBookRef: '40',}; +faultsAttrs[FaultID.ArrayLiteralNoContextType] = {cookBookRef: '43',}; +faultsAttrs[FaultID.FunctionExpression] = {migratable: true, cookBookRef: '46',}; +faultsAttrs[FaultID.LambdaWithTypeParameters] = {migratable: true, cookBookRef: '49',}; +faultsAttrs[FaultID.ClassExpression] = {migratable: true, cookBookRef: '50',}; +faultsAttrs[FaultID.ImplementsClass] = {cookBookRef: '51',}; +faultsAttrs[FaultID.MethodReassignment] = {cookBookRef: '52',}; +faultsAttrs[FaultID.TypeAssertion] = {migratable: true, cookBookRef: '53',}; +faultsAttrs[FaultID.JsxElement] = {cookBookRef: '54',}; +faultsAttrs[FaultID.UnaryArithmNotNumber] = {cookBookRef: '55',}; +faultsAttrs[FaultID.DeleteOperator] = {cookBookRef: '59',}; +faultsAttrs[FaultID.TypeQuery] = {cookBookRef: '60',}; +faultsAttrs[FaultID.InstanceofUnsupported] = {cookBookRef: '65',}; +faultsAttrs[FaultID.InOperator] = {cookBookRef: '66',}; +faultsAttrs[FaultID.DestructuringAssignment] = {migratable: true, cookBookRef: '69',}; +faultsAttrs[FaultID.CommaOperator] = {cookBookRef: '71',}; +faultsAttrs[FaultID.DestructuringDeclaration] = {migratable: true, cookBookRef: '74',}; +faultsAttrs[FaultID.CatchWithUnsupportedType] = {migratable: true, cookBookRef: '79',}; +faultsAttrs[FaultID.ForInStatement] = {cookBookRef: '80',}; +faultsAttrs[FaultID.MappedType] = {cookBookRef: '83',}; +faultsAttrs[FaultID.WithStatement] = {cookBookRef: '84',}; +faultsAttrs[FaultID.ThrowStatement] = {migratable: true, cookBookRef: '87',}; +faultsAttrs[FaultID.LimitedReturnTypeInference] = {migratable: true, cookBookRef: '90',}; +faultsAttrs[FaultID.DestructuringParameter] = {cookBookRef: '91',}; +faultsAttrs[FaultID.LocalFunction] = {migratable: true, cookBookRef: '92',}; +faultsAttrs[FaultID.FunctionContainsThis] = {cookBookRef: '93',}; +faultsAttrs[FaultID.GeneratorFunction] = {cookBookRef: '94',}; +faultsAttrs[FaultID.YieldExpression] = {cookBookRef: '94',}; +faultsAttrs[FaultID.IsOperator] = {cookBookRef: '96',}; +faultsAttrs[FaultID.SpreadOperator] = {cookBookRef: '99',}; +faultsAttrs[FaultID.IntefaceExtendDifProps] = {cookBookRef: '102',}; +faultsAttrs[FaultID.InterfaceMerging] = {cookBookRef: '103',}; +faultsAttrs[FaultID.InterfaceExtendsClass] = {cookBookRef: '104',}; +faultsAttrs[FaultID.ConstructorFuncs] = {cookBookRef: '106',}; +faultsAttrs[FaultID.EnumMemberNonConstInit] = {cookBookRef: '111',}; +faultsAttrs[FaultID.EnumMerging] = {cookBookRef: '113',}; +faultsAttrs[FaultID.NamespaceAsObject] = {cookBookRef: '114',}; +faultsAttrs[FaultID.NonDeclarationInNamespace] = {cookBookRef: '116',}; +faultsAttrs[FaultID.ImportFromPath] = {cookBookRef: '119',}; +faultsAttrs[FaultID.TypeOnlyImport] = {migratable: true, cookBookRef: '118',}; +faultsAttrs[FaultID.DefaultImport] = {migratable: true, cookBookRef: '120',}; +faultsAttrs[FaultID.ImportAssignment] = {cookBookRef: '121',}; +faultsAttrs[FaultID.ExportAssignment] = {cookBookRef: '126',}; +faultsAttrs[FaultID.TypeOnlyExport] = {migratable: true, cookBookRef: '127',}; +faultsAttrs[FaultID.ShorthandAmbientModuleDecl] = {cookBookRef: '128',}; +faultsAttrs[FaultID.WildcardsInModuleName] = {cookBookRef: '129',}; +faultsAttrs[FaultID.UMDModuleDefinition] = {cookBookRef: '130',}; +faultsAttrs[FaultID.NewTarget] = {cookBookRef: '132',}; +faultsAttrs[FaultID.DefiniteAssignment] = {warning: true, cookBookRef: '134',}; +faultsAttrs[FaultID.Prototype] = {cookBookRef: '136',}; +faultsAttrs[FaultID.GlobalThis] = {cookBookRef: '137',}; +faultsAttrs[FaultID.UtilityType] = {cookBookRef: '138',}; +faultsAttrs[FaultID.PropertyDeclOnFunction] = {cookBookRef: '139',}; +faultsAttrs[FaultID.FunctionApplyBindCall] = {cookBookRef: '140',}; +faultsAttrs[FaultID.ConstAssertion] = {cookBookRef: '142',}; +faultsAttrs[FaultID.ImportAssertion] = {cookBookRef: '143',}; +faultsAttrs[FaultID.LimitedStdLibApi] = {cookBookRef: '144',}; +faultsAttrs[FaultID.StrictDiagnostic] = {cookBookRef: '145',}; +faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; +faultsAttrs[FaultID.UnsupportedDecorators] = {warning: true, cookBookRef: '148',}; +faultsAttrs[FaultID.ClassAsObject] = {cookBookRef: '149',}; +faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '150',}; +faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '8'}; +faultsAttrs[FaultID.EsObjectAssignment] = {warning: true, cookBookRef: '8'}; +faultsAttrs[FaultID.EsObjectAccess] = {warning: true, cookBookRef: '8'}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index c61b136e7..c49b1f3bc 100644 --- a/linter/src/FaultDesc.ts +++ b/linter/src/FaultDesc.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { FaultID } from './utils/consts/Problems'; +import { FaultID } from './Problems'; export const faultDesc: string[] = []; @@ -102,4 +102,6 @@ faultDesc[FaultID.ErrorSuppression] = 'Error suppression annotation'; faultDesc[FaultID.StrictDiagnostic] = 'Strict diagnostic'; faultDesc[FaultID.UnsupportedDecorators] = 'Unsupported decorators'; faultDesc[FaultID.ImportAfterStatement] = 'Import declaration after other declaration or statement'; -faultDesc[FaultID.EsObjectType] = 'Restricted "ESObject" type'; +faultDesc[FaultID.EsObjectType] = '"ESObject" type'; +faultDesc[FaultID.EsObjectAssignment] = '"ESObject" type assignment'; +faultDesc[FaultID.EsObjectAccess] = '"ESObject" access'; diff --git a/linter/src/LinterRunner.ts b/linter/src/LinterRunner.ts index 0e701f2ba..1494b65fd 100644 --- a/linter/src/LinterRunner.ts +++ b/linter/src/LinterRunner.ts @@ -16,7 +16,7 @@ import * as ts from 'typescript'; import { ProblemInfo } from './ProblemInfo'; import { TypeScriptLinter, consoleLog } from './TypeScriptLinter'; -import { FaultID } from './utils/consts/Problems'; +import { FaultID } from './Problems'; import { faultDesc } from './FaultDesc'; import { faultsAttrs } from './FaultAttrs'; import { LintRunResult } from './LintRunResult'; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts new file mode 100644 index 000000000..245ea31e7 --- /dev/null +++ b/linter/src/Problems.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022-2023 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. + */ + +export enum FaultID { + AnyType, SymbolType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, + ComputedPropertyName, LiteralAsPropertyName, TypeQuery, RegexLiteral, IsOperator, + DestructuringParameter, YieldExpression, InterfaceMerging, EnumMerging, InterfaceExtendsClass, IndexMember, WithStatement, + ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator, + ImportFromPath, FunctionExpression, IntersectionType, + ObjectTypeLiteral, CommaOperator, LimitedReturnTypeInference, + LambdaWithTypeParameters, ClassExpression, DestructuringAssignment, + DestructuringDeclaration, VarDeclaration, CatchWithUnsupportedType, DeleteOperator, + DeclWithDuplicateName, UnaryArithmNotNumber, ConstructorType, ConstructorIface, ConstructorFuncs, CallSignature, + TypeAssertion, PrivateIdentifier, LocalFunction, + ConditionalType, MappedType, NamespaceAsObject, ClassAsObject, + NonDeclarationInNamespace, GeneratorFunction, FunctionContainsThis, PropertyAccessByIndex, JsxElement, + EnumMemberNonConstInit, ImplementsClass, MethodReassignment, MultipleStaticBlocks, ThisType, + IntefaceExtendDifProps, StructuralIdentity, TypeOnlyImport, TypeOnlyExport, DefaultImport, + ExportAssignment, ImportAssignment, + GenericCallNoTypeArgs, ParameterProperties, + InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, + NewTarget, DefiniteAssignment, Prototype, GlobalThis, + UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ConstAssertion, ImportAssertion, + SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, UnsupportedDecorators, ImportAfterStatement, + EsObjectType, EsObjectAssignment, EsObjectAccess, + LAST_ID, // this should always be last enum` +} diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 15d018ed5..0b26d2f95 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -16,7 +16,7 @@ import * as ts from 'typescript'; import * as path from 'node:path'; import { TsUtils, CheckType } from './utils/TsUtils'; -import { FaultID } from './utils/consts/Problems'; +import { FaultID } from './Problems'; import { faultsAttrs } from './FaultAttrs'; import { faultDesc } from './FaultDesc'; import { cookBookMsg, cookBookTag } from './CookBookMsg'; @@ -27,6 +27,13 @@ import { ProblemInfo } from './ProblemInfo'; import { ProblemSeverity } from './ProblemSeverity'; import Logger from '../utils/logger'; import { ARKUI_DECORATORS } from './utils/consts/ArkUIDecorators'; +import { LIMITED_STD_GLOBAL_FUNC } from './utils/consts/LimitedStdGlobalFunc'; +import { LIMITED_STD_GLOBAL_VAR } from './utils/consts/LimitedStdGlobalVar'; +import { LIMITED_STD_OBJECT_API } from './utils/consts/LimitedStdObjectAPI'; +import { LIMITED_STD_REFLECT_API } from './utils/consts/LimitedStdReflectAPI'; +import { LIMITED_STD_PROXYHANDLER_API } from './utils/consts/LimitedStdProxyHandlerAPI'; +import { LIMITED_STD_ARRAYBUFFER_API } from './utils/consts/LimitedStdArrayBufferAPI'; +import { ALLOWED_STD_SYMBOL_API } from './utils/consts/AllowedStdSymbolAPI'; import { NON_INITIALIZABLE_PROPERTY_DECORATORS, NON_INITIALIZABLE_PROPERTY_CLASS_DECORATORS } from './utils/consts/NonInitializablePropertyDecorators'; import { NON_RETURN_FUNCTION_DECORATORS } from './utils/consts/NonReturnFunctionDecorators'; @@ -48,7 +55,6 @@ import { TYPE_0_IS_NOT_ASSIGNABLE_TO_TYPE_1_ERROR_CODE, LibraryTypeCallDiagnosticChecker } from './utils/functions/LibraryTypeCallDiagnosticChecker'; -import { LIMITED_STD_API, LIMITED_STD_GLOBAL_API } from './utils/consts/LimitedStdApi'; const logger = Logger.getLogger(); @@ -573,22 +579,29 @@ export class TypeScriptLinter { } private handlePropertyAccessExpression(node: ts.Node) { + if (ts.isCallExpression(node.parent) && node == node.parent.expression) { + return; + } + let propertyAccessNode = node as ts.PropertyAccessExpression; const exprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode); const baseExprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode.expression); const baseExprType = this.tsTypeChecker.getTypeAtLocation(propertyAccessNode.expression); - if (!!baseExprSym && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { - this.incrementCounters(propertyAccessNode, FaultID.EsObjectType); - } if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { this.incrementCounters(propertyAccessNode.name, FaultID.Prototype); } + if (!!exprSym && this.tsUtils.isSymbolAPI(exprSym) && !ALLOWED_STD_SYMBOL_API.includes(exprSym.getName())) { + this.incrementCounters(propertyAccessNode, FaultID.SymbolType); + } if (TypeScriptLinter.advancedClassChecks && this.tsUtils.isClassObjectExpression(propertyAccessNode.expression)) { // missing exact rule this.incrementCounters(propertyAccessNode.expression, FaultID.ClassAsObject); } + if (baseExprSym !== undefined && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { + this.incrementCounters(propertyAccessNode, FaultID.EsObjectAccess); + } } private handlePropertyAssignmentOrDeclaration(node: ts.Node) { @@ -908,7 +921,9 @@ export class TypeScriptLinter { if (this.tsUtils.needToDeduceStructuralIdentity(leftOperandType, rightOperandType, tsRhsExpr)) { this.incrementCounters(tsBinaryExpr, FaultID.StructuralIdentity); } - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); + if (typeNode) { + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); + } break; default: return; @@ -995,40 +1010,38 @@ export class TypeScriptLinter { if (this.tsUtils.needToDeduceStructuralIdentity(tsVarType, tsInitType, tsVarInit)) { this.incrementCounters(tsVarDecl, FaultID.StructuralIdentity); } + + this.handleEsObjectAssignment(tsVarDecl, tsVarDecl.type, tsVarInit); } - this.handleEsObjectDelaration(tsVarDecl); this.handleDeclarationInferredType(tsVarDecl); this.handleDefiniteAssignmentAssertion(tsVarDecl); } - private handleEsObjectDelaration(node: ts.VariableDeclaration) { - const isDeclaredESObject = !!node.type && this.tsUtils.isEsObjectType(node.type); - const initalizerTypeNode = node.initializer && this.tsUtils.getVariableDeclarationTypeNode(node.initializer); - const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); - const isLocal = this.tsUtils.isInsideBlock(node) - if ((isDeclaredESObject || isInitializedWithESObject) && !isLocal) { - this.incrementCounters(node, FaultID.EsObjectType); - return; + private handleEsObjectAssignment(node: ts.Node, type: ts.TypeNode, value: ts.Node) { + if (!this.tsUtils.isEsObjectType(type)) { + let valueTypeNode = this.tsUtils.getVariableDeclarationTypeNode(value); + if (!!valueTypeNode && this.tsUtils.isEsObjectType(valueTypeNode)) { + this.incrementCounters(node, FaultID.EsObjectAssignment); + } + + return } - if (node.initializer) { - this.handleEsObjectAssignment(node, node.type, node.initializer); + if (ts.isArrayLiteralExpression(value) || ts.isObjectLiteralExpression(value)) { + this.incrementCounters(node, FaultID.EsObjectAssignment); + return; } - } - private handleEsObjectAssignment(node: ts.Node, nodeDeclType: ts.TypeNode | undefined, initializer: ts.Node) { - const isTypeAnnotated = !!nodeDeclType; - const isDeclaredESObject = isTypeAnnotated && this.tsUtils.isEsObjectType(nodeDeclType); - const initalizerTypeNode = this.tsUtils.getVariableDeclarationTypeNode(initializer); - const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); - if (isTypeAnnotated && !isDeclaredESObject && isInitializedWithESObject) { - this.incrementCounters(node, FaultID.EsObjectType); + const valueType = this.tsTypeChecker.getTypeAtLocation(value); + if (this.tsUtils.isUnsupportedType(valueType)) { return; } - if (isDeclaredESObject && !this.tsUtils.isValueAssignableToESObject(initializer)) { - this.incrementCounters(node, FaultID.EsObjectType); + if (this.tsUtils.isAnonymousType(valueType)) { + return; } + + this.incrementCounters(node, FaultID.EsObjectAssignment); } private handleCatchClause(node: ts.Node) { @@ -1233,18 +1246,17 @@ export class TypeScriptLinter { private handleIdentifier(node: ts.Node) { let tsIdentifier = node as ts.Identifier; let tsIdentSym = this.tsUtils.trueSymbolAtLocation(tsIdentifier); - if (!tsIdentSym) { - return; - } - if ( - (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && - (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && - tsIdentifier.text === 'globalThis' - ) { - this.incrementCounters(tsIdentifier, FaultID.GlobalThis); - } else { - this.checkLimitedStdLib(tsIdentifier, tsIdentSym); - this.handleRestrictedValues(tsIdentifier, tsIdentSym); + if (tsIdentSym !== undefined) { + if ( + (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && + (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && + tsIdentifier.text === 'globalThis' + ) + this.incrementCounters(node, FaultID.GlobalThis); + else if (this.tsUtils.isGlobalSymbol(tsIdentSym) && LIMITED_STD_GLOBAL_VAR.includes(tsIdentSym.getName())) + this.incrementCounters(node, FaultID.LimitedStdLibApi); + else + this.handleRestrictedValues(tsIdentifier, tsIdentSym); } } @@ -1326,7 +1338,7 @@ export class TypeScriptLinter { } if (this.tsUtils.hasEsObjectType(tsElementAccessExpr.expression)) { - this.incrementCounters(node, FaultID.EsObjectType); + this.incrementCounters(node, FaultID.EsObjectAccess); } } @@ -1391,22 +1403,25 @@ export class TypeScriptLinter { this.handleImportCall(tsCallExpr); this.handleRequireCall(tsCallExpr); - if (!!calleeSym) { + // NOTE: Keep handleFunctionApplyBindPropCall above handleGenericCallWithNoTypeArgs here!!! + if (calleeSym !== undefined) { + this.handleStdlibAPICall(tsCallExpr, calleeSym); + this.handleFunctionApplyBindPropCall(tsCallExpr, calleeSym); if (this.tsUtils.symbolHasEsObjectType(calleeSym)) { - this.incrementCounters(tsCallExpr, FaultID.EsObjectType); - } - // need to process Symbol call separatey in order to not report two times when using Symbol API - if (this.tsUtils.isStdSymbol(calleeSym)) { - this.incrementCounters(tsCallExpr, FaultID.SymbolType); + this.incrementCounters(tsCallExpr, FaultID.EsObjectAccess); } } - if (!!callSignature) { + if (callSignature !== undefined) { if (!this.tsUtils.isLibrarySymbol(calleeSym)) { this.handleGenericCallWithNoTypeArgs(tsCallExpr, callSignature); } this.handleStructIdentAndUndefinedInArgs(tsCallExpr, callSignature); } this.handleLibraryTypeCall(tsCallExpr, calleeType); + + if (ts.isPropertyAccessExpression(tsCallExpr.expression) && this.tsUtils.hasEsObjectType(tsCallExpr.expression.expression)) { + this.incrementCounters(node, FaultID.EsObjectAccess); + } } private handleImportCall(tsCallExpr: ts.CallExpression) { @@ -1467,6 +1482,21 @@ export class TypeScriptLinter { } } + private static listApplyBindCallApis = [ + 'Function.apply', + 'Function.call', + 'Function.bind', + 'CallableFunction.apply', + 'CallableFunction.call', + 'CallableFunction.bind' + ]; + private handleFunctionApplyBindPropCall(tsCallExpr: ts.CallExpression, calleeSym: ts.Symbol) { + const exprName = this.tsTypeChecker.getFullyQualifiedName(calleeSym); + if (TypeScriptLinter.listApplyBindCallApis.includes(exprName)) { + this.incrementCounters(tsCallExpr, FaultID.FunctionApplyBindCall); + } + } + private handleStructIdentAndUndefinedInArgs(tsCallOrNewExpr: ts.CallExpression | ts.NewExpression, callSignature: ts.Signature) { if (!tsCallOrNewExpr.arguments) { return; @@ -1498,17 +1528,35 @@ export class TypeScriptLinter { } } - private checkLimitedStdLib(node: ts.Node, symbol: ts.Symbol) { - const parName = this.tsUtils.getParentSymbolName(symbol); - const res = parName ? LIMITED_STD_API.get(parName) : undefined; - if (res && res.arr.includes(symbol.name)) { - this.incrementCounters(node, res.fault); + private static LimitedApis = new Map | null, fault: FaultID}> ([ + ['global', {arr: LIMITED_STD_GLOBAL_FUNC, fault: FaultID.LimitedStdLibApi}], + ['Object', {arr: LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], + ['ObjectConstructor', {arr: LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], + ['Reflect', {arr: LIMITED_STD_REFLECT_API, fault: FaultID.LimitedStdLibApi}], + ['ProxyHandler', {arr: LIMITED_STD_PROXYHANDLER_API, fault: FaultID.LimitedStdLibApi}], + ['ArrayBuffer', {arr: LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], + ['ArrayBufferConstructor', {arr: LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], + ['Symbol', {arr: null, fault: FaultID.SymbolType}], + ['SymbolConstructor', {arr: null, fault: FaultID.SymbolType}], + ]) + + private handleStdlibAPICall(callExpr: ts.CallExpression, calleeSym: ts.Symbol) { + const name = calleeSym.getName(); + const parName = this.tsUtils.getParentSymbolName(calleeSym); + if (parName === undefined) { + if (LIMITED_STD_GLOBAL_FUNC.includes(name)) { + this.incrementCounters(callExpr, FaultID.LimitedStdLibApi); + return; + } + let escapedName = calleeSym.escapedName; + if (escapedName === 'Symbol' || escapedName === 'SymbolConstructor') { + this.incrementCounters(callExpr, FaultID.SymbolType); + } return; } - const name = this.tsTypeChecker.getFullyQualifiedName(symbol); - if (LIMITED_STD_GLOBAL_API.includes(name)) { - this.incrementCounters(node, FaultID.LimitedStdLibApi) - return; + let lookup = TypeScriptLinter.LimitedApis.get(parName); + if (lookup !== undefined && (lookup.arr === null || lookup.arr.includes(name))) { + this.incrementCounters(callExpr, lookup.fault); } } @@ -1600,37 +1648,26 @@ export class TypeScriptLinter { } private handleTypeReference(node: ts.Node) { - const typeRef = node as ts.TypeReferenceNode; - - const isESObject = this.tsUtils.isEsObjectType(typeRef); - const isPossiblyValidContext = this.tsUtils.isEsObjectPossiblyAllowed(typeRef); - if (isESObject && !isPossiblyValidContext) { + let typeRef = node as ts.TypeReferenceNode; + if (this.tsUtils.isEsObjectType(typeRef) && !this.tsUtils.isEsObjectAllowed(typeRef)) { this.incrementCounters(node, FaultID.EsObjectType); - return; - } - - const typeName = this.tsUtils.entityNameToString(typeRef.typeName); - const isStdUtilityType = LIMITED_STANDARD_UTILITY_TYPES.includes(typeName); - if (isStdUtilityType) { - this.incrementCounters(node, FaultID.UtilityType); - return; - } - - // Using Partial type is allowed only when its argument type is either Class or Interface. - const isStdPartial = this.tsUtils.entityNameToString(typeRef.typeName) === 'Partial'; - const hasSingleTypeArgument = !!typeRef.typeArguments && typeRef.typeArguments.length === 1; - const argType = hasSingleTypeArgument && this.tsTypeChecker.getTypeFromTypeNode(typeRef.typeArguments[0]); - if (isStdPartial && argType && !argType.isClassOrInterface()) { + } else if (ts.isIdentifier(typeRef.typeName) && LIMITED_STANDARD_UTILITY_TYPES.includes(typeRef.typeName.text)) this.incrementCounters(node, FaultID.UtilityType); - return; + else if ( + ts.isIdentifier(typeRef.typeName) && typeRef.typeName.text === 'Partial' && + typeRef.typeArguments && typeRef.typeArguments.length === 1 + ) { + // Using Partial type is allowed only when its argument type is either Class or Interface. + let argType = this.tsTypeChecker.getTypeFromTypeNode(typeRef.typeArguments[0]); + if (!argType || !argType.isClassOrInterface()) + this.incrementCounters(node, FaultID.UtilityType); } } private handleMetaProperty(node: ts.Node) { let tsMetaProperty = node as ts.MetaProperty; - if (tsMetaProperty.name.text === 'target') { + if (tsMetaProperty.name.text === 'target') this.incrementCounters(node, FaultID.NewTarget); - } } private handleStructDeclaration(node: ts.Node) { diff --git a/linter/src/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index 58f32df62..83427d5e6 100644 --- a/linter/src/TypeScriptLinterConfig.ts +++ b/linter/src/TypeScriptLinterConfig.ts @@ -14,7 +14,7 @@ */ import * as ts from 'typescript'; -import { FaultID } from './utils/consts/Problems'; +import { FaultID } from './Problems'; export class LinterConfig { // The SyntaxKind enum defines additional elements at the end of the enum diff --git a/linter/src/ts-diagnostics/TSCCompiledProgram.ts b/linter/src/ts-diagnostics/TSCCompiledProgram.ts index 36faaf7c3..9ebcb1fab 100644 --- a/linter/src/ts-diagnostics/TSCCompiledProgram.ts +++ b/linter/src/ts-diagnostics/TSCCompiledProgram.ts @@ -19,7 +19,7 @@ import { ProblemSeverity } from '../ProblemSeverity'; import { LintOptions } from '../LintOptions'; import { TypeScriptDiagnosticsExtractor } from './TypeScriptDiagnosticsExtractor'; import { compile } from '../CompilerWrapper'; -import { FaultID } from '../utils/consts/Problems'; +import { FaultID } from '../Problems'; import { faultsAttrs } from '../FaultAttrs'; export interface TSCCompiledProgram { diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index c2ee9fef0..17d2f6e7b 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -902,7 +902,7 @@ export class TsUtils { public isStdObjectAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Object'); + return !!parentName && (parentName === 'Object' || parentName === 'ObjectConstructor'); } public isStdReflectAPI(symbol: ts.Symbol): boolean { @@ -917,22 +917,18 @@ export class TsUtils { public isStdArrayAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Array'); + return !!parentName && (parentName === 'Array' || parentName === 'ArrayConstructor'); } public isStdArrayBufferAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ArrayBuffer'); + return !!parentName && (parentName === 'ArrayBuffer' || parentName === 'ArrayBufferConstructor'); } - public isStdSymbol(symbol: ts.Symbol): boolean { - const name = this.tsTypeChecker.getFullyQualifiedName(symbol) - return name === 'Symbol'; - } - - public isStdSymbolAPI(symbol: ts.Symbol): boolean { + public isSymbolAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Symbol'); + let name = parentName ? parentName : symbol.escapedName; + return name === 'Symbol' || name === 'SymbolConstructor'; } public isDefaultImport(importSpec: ts.ImportSpecifier): boolean { @@ -1141,29 +1137,22 @@ export class TsUtils { typeNode.typeName.text == ES_OBJECT; } - public isInsideBlock(node: ts.Node): boolean { - let par = node.parent - while (par) { - if (ts.isBlock(par)) { + public isEsObjectAllowed(typeRef: ts.TypeReferenceNode): boolean { + let node = typeRef.parent; + + if (!this.isVarDeclaration(node)) { + return false; + } + + while (node) { + if (ts.isBlock(node)) { return true; } - par = par.parent; + node = node.parent; } return false; } - public isEsObjectPossiblyAllowed(typeRef: ts.TypeReferenceNode): boolean { - return ts.isVariableDeclaration(typeRef.parent); - } - - public isValueAssignableToESObject(node: ts.Node): boolean { - if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) { - return false; - } - const valueType = this.tsTypeChecker.getTypeAtLocation(node); - return this.isUnsupportedType(valueType) || this.isAnonymousType(valueType) - } - public getVariableDeclarationTypeNode(node: ts.Node): ts.TypeNode | undefined { let sym = this.trueSymbolAtLocation(node); if (sym === undefined) { @@ -1193,7 +1182,7 @@ export class TsUtils { public isEsObjectSymbol(sym: ts.Symbol): boolean { let decl = this.getDeclaration(sym); return !!decl && ts.isTypeAliasDeclaration(decl) && decl.name.escapedText == ES_OBJECT && - decl.type.kind === ts.SyntaxKind.AnyKeyword; + decl.type.kind == ts.SyntaxKind.AnyKeyword; } public isAnonymousType(type: ts.Type): boolean { diff --git a/linter/src/utils/consts/AllowedStdSymbolAPI.ts b/linter/src/utils/consts/AllowedStdSymbolAPI.ts new file mode 100644 index 000000000..69c95812a --- /dev/null +++ b/linter/src/utils/consts/AllowedStdSymbolAPI.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const ALLOWED_STD_SYMBOL_API = ['iterator']; diff --git a/linter/src/utils/consts/LimitedStandardUtilityTypes.ts b/linter/src/utils/consts/LimitedStandardUtilityTypes.ts index 259443d99..ba9181506 100644 --- a/linter/src/utils/consts/LimitedStandardUtilityTypes.ts +++ b/linter/src/utils/consts/LimitedStandardUtilityTypes.ts @@ -14,21 +14,7 @@ */ export const LIMITED_STANDARD_UTILITY_TYPES = [ - 'Awaited', - 'Pick', - 'Omit', - 'Exclude', - 'Extract', - 'NonNullable', - 'Parameters', - 'ConstructorParameters', - 'ReturnType', - 'InstanceType', - 'ThisParameterType', - 'OmitThisParameter', - 'ThisType', - 'Uppercase', - 'Lowercase', - 'Capitalize', - 'Uncapitalize', + 'Awaited', 'Pick', 'Omit', 'Exclude', 'Extract', 'NonNullable', 'Parameters', + 'ConstructorParameters', 'ReturnType', 'InstanceType', 'ThisParameterType', 'OmitThisParameter', + 'ThisType', 'Uppercase', 'Lowercase', 'Capitalize', 'Uncapitalize', ]; diff --git a/linter/src/utils/consts/LimitedStdApi.ts b/linter/src/utils/consts/LimitedStdApi.ts deleted file mode 100644 index 1599fbfe9..000000000 --- a/linter/src/utils/consts/LimitedStdApi.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2023-2023 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 { FaultID } from "./Problems"; - -/** - * ArrayBuffer - */ -const LIMITED_STD_ARRAYBUFFER_API = [ - // properties - // methods - 'isView' -]; - -/** - * Object - */ -const LIMITED_STD_OBJECT_API = [ - // properties - '__proto__', - // methods - '__defineGetter__', - '__defineSetter__', - '__lookupGetter__', - '__lookupSetter__', - 'assign', - 'create', - 'defineProperties', - 'defineProperty', - 'freeze', - 'fromEntries', - 'getOwnPropertyDescriptor', - 'getOwnPropertyDescriptors', - 'getOwnPropertySymbols', - 'getPrototypeOf', - 'hasOwnProperty', - 'is', - 'isExtensible', - 'isFrozen', - 'isPrototypeOf', - 'isSealed', - 'preventExtensions', - 'propertyIsEnumerable', - 'seal', - 'setPrototypeOf', -]; - -/** - * Proxy - */ -const LIMITED_STD_PROXYHANDLER_API = [ - // properties - // methods - 'apply', - 'construct', - 'defineProperty', - 'deleteProperty', - 'get', - 'getOwnPropertyDescriptor', - 'getPrototypeOf', - 'has', - 'isExtensible', - 'ownKeys', - 'preventExtensions', - 'set', - 'setPrototypeOf' -]; - -/** - * Reflect - */ -const LIMITED_STD_REFLECT_API = [ - // properties - // methods - 'apply', - 'construct', - 'defineProperty', - 'deleteProperty', - 'getOwnPropertyDescriptor', - 'getPrototypeOf', - 'isExtensible', - 'preventExtensions', - 'setPrototypeOf', -]; - -/** - * Symbol - */ -const LIMITED_STD_SYMBOL_API = [ - 'Symbol', - // properties - 'asyncIterator', - 'description', - 'hasInstance', - 'isConcatSpreadable', - 'match', - 'matchAll', - 'replace', - 'search', - 'species', - 'split', - 'toPrimitive', - 'toStringTag', - 'unscopables', - // methods - 'for', - 'keyFor', - 'toString', - 'valueOf', -]; - -/** - * Function - */ -const LIMITED_STD_FUNCTION_API = [ - // properties - // methods - 'apply', - 'bind', - 'call', -]; - -/** - * Global - */ -export const LIMITED_STD_GLOBAL_API = [ - // properties - // methods - 'eval', -]; - -export const LIMITED_STD_API = new Map, fault: FaultID}> ([ - ['Object', {arr: LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], - ['ObjectConstructor', {arr: LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], - ['Reflect', {arr: LIMITED_STD_REFLECT_API, fault: FaultID.LimitedStdLibApi}], - ['ProxyHandler', {arr: LIMITED_STD_PROXYHANDLER_API, fault: FaultID.LimitedStdLibApi}], - ['ArrayBuffer', {arr: LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], - ['ArrayBufferConstructor', {arr: LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], - ['Symbol', {arr: LIMITED_STD_SYMBOL_API, fault: FaultID.SymbolType}], - ['SymbolConstructor', {arr: LIMITED_STD_SYMBOL_API, fault: FaultID.SymbolType}], - ['Function', {arr: LIMITED_STD_FUNCTION_API, fault: FaultID.FunctionApplyBindCall}], - ['CallableFunction', {arr: LIMITED_STD_FUNCTION_API, fault: FaultID.FunctionApplyBindCall}], -]) diff --git a/linter/src/utils/consts/LimitedStdArrayBufferAPI.ts b/linter/src/utils/consts/LimitedStdArrayBufferAPI.ts new file mode 100644 index 000000000..39605128f --- /dev/null +++ b/linter/src/utils/consts/LimitedStdArrayBufferAPI.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const LIMITED_STD_ARRAYBUFFER_API = ['isView']; diff --git a/linter/src/utils/consts/LimitedStdGlobalFunc.ts b/linter/src/utils/consts/LimitedStdGlobalFunc.ts new file mode 100644 index 000000000..eec858299 --- /dev/null +++ b/linter/src/utils/consts/LimitedStdGlobalFunc.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const LIMITED_STD_GLOBAL_FUNC = [ + 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt' +]; diff --git a/linter/src/utils/consts/LimitedStdGlobalVar.ts b/linter/src/utils/consts/LimitedStdGlobalVar.ts new file mode 100644 index 000000000..fd0b48816 --- /dev/null +++ b/linter/src/utils/consts/LimitedStdGlobalVar.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const LIMITED_STD_GLOBAL_VAR = ['Infinity', 'NaN']; diff --git a/linter/src/utils/consts/LimitedStdObjectAPI.ts b/linter/src/utils/consts/LimitedStdObjectAPI.ts new file mode 100644 index 000000000..55b7ffede --- /dev/null +++ b/linter/src/utils/consts/LimitedStdObjectAPI.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const LIMITED_STD_OBJECT_API = [ + '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'assign', 'create', + 'defineProperties', 'defineProperty', 'freeze', 'fromEntries', 'getOwnPropertyDescriptor', + 'getOwnPropertyDescriptors', 'getOwnPropertySymbols', 'getPrototypeOf', + 'hasOwnProperty', 'is', 'isExtensible', 'isFrozen', 'isPrototypeOf', 'isSealed', 'preventExtensions', + 'propertyIsEnumerable', 'seal', 'setPrototypeOf' +]; diff --git a/linter/src/utils/consts/LimitedStdProxyHandlerAPI.ts b/linter/src/utils/consts/LimitedStdProxyHandlerAPI.ts new file mode 100644 index 000000000..7113b2b5c --- /dev/null +++ b/linter/src/utils/consts/LimitedStdProxyHandlerAPI.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const LIMITED_STD_PROXYHANDLER_API = [ + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'has', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf' +]; diff --git a/linter/src/utils/consts/LimitedStdReflectAPI.ts b/linter/src/utils/consts/LimitedStdReflectAPI.ts new file mode 100644 index 000000000..e1f58f802 --- /dev/null +++ b/linter/src/utils/consts/LimitedStdReflectAPI.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +export const LIMITED_STD_REFLECT_API = [ + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'isExtensible', 'preventExtensions', 'setPrototypeOf' +]; diff --git a/linter/src/utils/consts/Problems.ts b/linter/src/utils/consts/Problems.ts deleted file mode 100644 index 3d1def20d..000000000 --- a/linter/src/utils/consts/Problems.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2022-2023 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. - */ - -export enum FaultID { - AnyType, - SymbolType, - ObjectLiteralNoContextType, - ArrayLiteralNoContextType, - ComputedPropertyName, - LiteralAsPropertyName, - TypeQuery, - RegexLiteral, - IsOperator, - DestructuringParameter, - YieldExpression, - InterfaceMerging, - EnumMerging, - InterfaceExtendsClass, - IndexMember, - WithStatement, - ThrowStatement, - IndexedAccessType, - UnknownType, - ForInStatement, - InOperator, - ImportFromPath, - FunctionExpression, - IntersectionType, - ObjectTypeLiteral, - CommaOperator, - LimitedReturnTypeInference, - LambdaWithTypeParameters, - ClassExpression, - DestructuringAssignment, - DestructuringDeclaration, - VarDeclaration, - CatchWithUnsupportedType, - DeleteOperator, - DeclWithDuplicateName, - UnaryArithmNotNumber, - ConstructorType, - ConstructorIface, - ConstructorFuncs, - CallSignature, - TypeAssertion, - PrivateIdentifier, - LocalFunction, - ConditionalType, - MappedType, - NamespaceAsObject, - ClassAsObject, - NonDeclarationInNamespace, - GeneratorFunction, - FunctionContainsThis, - PropertyAccessByIndex, - JsxElement, - EnumMemberNonConstInit, - ImplementsClass, - MethodReassignment, - MultipleStaticBlocks, - ThisType, - IntefaceExtendDifProps, - StructuralIdentity, - TypeOnlyImport, - TypeOnlyExport, - DefaultImport, - ExportAssignment, - ImportAssignment, - GenericCallNoTypeArgs, - ParameterProperties, - InstanceofUnsupported, - ShorthandAmbientModuleDecl, - WildcardsInModuleName, - UMDModuleDefinition, - NewTarget, - DefiniteAssignment, - Prototype, - GlobalThis, - UtilityType, - PropertyDeclOnFunction, - FunctionApplyBindCall, - ConstAssertion, - ImportAssertion, - SpreadOperator, - LimitedStdLibApi, - ErrorSuppression, - StrictDiagnostic, - UnsupportedDecorators, - ImportAfterStatement, - EsObjectType, - LAST_ID, // this should always be last enum` -} diff --git a/linter/test/es_object.ts b/linter/test/es_object.ts index 445b5c0c0..d9715b772 100644 --- a/linter/test/es_object.ts +++ b/linter/test/es_object.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { fooOh, barOh } from './oh_modules/ohos_lib' + type ESObject = any class A {} @@ -174,20 +174,3 @@ interface CL extends ESObject {} export interface CLS extends ESObject {} foo2({ k: 'k', h: {t: 1}}) // we can assign anything to the esobject, even untyped literal -let q1: ESObject = 1; // CTE - ``ESObject`` typed variable can only be local -let q2: ESObject = fooOh(); // CTE - ``ESObject`` typed variable can only be local -let q3: ESObject = q2; // CTE - ``ESObject`` typed variable can only be local -function f() { - let e1 = fooOh(); // CTE - type of e1 is `any` - let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values - let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values - let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values - let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values - let e6: ESObject = fooOh(); // OK - explicitly annotaded as ESObject - let e7: ESObject = e6; // OK - initialize ESObject with ESObject - e6['prop'] // CTE - can't access dynamic properties of ESObject - e6[1] // CTE - can't access dynamic properties of ESObject - e6.prop // CTE - can't access dynamic properties of ESObject - barOh(e6) // OK - ESObject is passed to interop call - e6 = e7 // OK - ESObject is assigned to ESObject -} diff --git a/linter/test/es_object.ts.relax.json b/linter/test/es_object.ts.relax.json index f3d5acdb4..10bd5f5bd 100644 --- a/linter/test/es_object.ts.relax.json +++ b/linter/test/es_object.ts.relax.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 5, + "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 77, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 78, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 79, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 80, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 82, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 83, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 85, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 86, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 87, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 88, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 90, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 91, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 93, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 94, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 95, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 96, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 98, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 99, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 176, @@ -594,83 +594,6 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" - }, - { - "line": 177, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 178, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 179, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 181, - "column": 9, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 182, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 183, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 184, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 185, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 188, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 189, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 190, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } ] } \ No newline at end of file diff --git a/linter/test/es_object.ts.strict.json b/linter/test/es_object.ts.strict.json index 5c869e41f..10bd5f5bd 100644 --- a/linter/test/es_object.ts.strict.json +++ b/linter/test/es_object.ts.strict.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 5, + "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 77, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 78, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 79, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 80, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAccess", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 82, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 83, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 85, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 86, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 87, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 88, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 90, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 91, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 93, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 94, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 95, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 96, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 98, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 99, "column": 5, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectType", + "problem": "EsObjectAssignment", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 176, @@ -594,83 +594,6 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" - }, - { - "line": 177, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 178, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 179, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 181, - "column": 9, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 182, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 183, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 184, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 185, - "column": 9, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 188, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 189, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" - }, - { - "line": 190, - "column": 5, - "problem": "EsObjectType", - "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } - ] + ] } \ No newline at end of file diff --git a/linter/test/function_expression.ts.autofix.json b/linter/test/function_expression.ts.autofix.json index 90e6f3f3b..c571fa05a 100644 --- a/linter/test/function_expression.ts.autofix.json +++ b/linter/test/function_expression.ts.autofix.json @@ -335,6 +335,14 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 102, + "column": 15, + "problem": "FunctionApplyBindCall", + "autofixable": false, + "suggest": "", + "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" + }, { "line": 102, "column": 15, @@ -350,14 +358,6 @@ "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, - { - "line": 104, - "column": 7, - "problem": "FunctionApplyBindCall", - "autofixable": false, - "suggest": "", - "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" - }, { "line": 108, "column": 16, diff --git a/linter/test/function_expression.ts.relax.json b/linter/test/function_expression.ts.relax.json index 8e6077236..48f6e1a27 100644 --- a/linter/test/function_expression.ts.relax.json +++ b/linter/test/function_expression.ts.relax.json @@ -57,8 +57,8 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 104, - "column": 7, + "line": 102, + "column": 15, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" diff --git a/linter/test/function_expression.ts.strict.json b/linter/test/function_expression.ts.strict.json index 1233c4e7d..fe4750449 100644 --- a/linter/test/function_expression.ts.strict.json +++ b/linter/test/function_expression.ts.strict.json @@ -206,16 +206,16 @@ { "line": 102, "column": 15, - "problem": "FunctionExpression", + "problem": "FunctionApplyBindCall", "suggest": "", - "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { - "line": 104, - "column": 7, - "problem": "FunctionApplyBindCall", + "line": 102, + "column": 15, + "problem": "FunctionExpression", "suggest": "", - "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { "line": 108, diff --git a/linter/test/function_object_methods.ts.relax.json b/linter/test/function_object_methods.ts.relax.json index 790856d4f..96e3fcaf1 100644 --- a/linter/test/function_object_methods.ts.relax.json +++ b/linter/test/function_object_methods.ts.relax.json @@ -23,7 +23,7 @@ }, { "line": 29, - "column": 35, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -37,21 +37,21 @@ }, { "line": 30, - "column": 45, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 37, - "column": 37, + "column": 23, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 38, - "column": 40, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -65,7 +65,7 @@ }, { "line": 68, - "column": 44, + "column": 22, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -79,42 +79,42 @@ }, { "line": 70, - "column": 35, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 75, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 78, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 81, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 82, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 87, - "column": 32, + "column": 16, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -128,7 +128,7 @@ }, { "line": 94, - "column": 37, + "column": 20, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -142,42 +142,42 @@ }, { "line": 96, - "column": 30, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 101, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 104, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 107, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 108, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 113, - "column": 21, + "column": 10, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -226,35 +226,35 @@ }, { "line": 136, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 137, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 138, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 139, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 141, - "column": 5, + "column": 1, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" diff --git a/linter/test/function_object_methods.ts.strict.json b/linter/test/function_object_methods.ts.strict.json index 2a7c8ccd9..e90572ea9 100644 --- a/linter/test/function_object_methods.ts.strict.json +++ b/linter/test/function_object_methods.ts.strict.json @@ -23,7 +23,7 @@ }, { "line": 29, - "column": 35, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -37,21 +37,21 @@ }, { "line": 30, - "column": 45, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 37, - "column": 37, + "column": 23, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 38, - "column": 40, + "column": 21, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -65,7 +65,7 @@ }, { "line": 68, - "column": 44, + "column": 22, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -79,42 +79,42 @@ }, { "line": 70, - "column": 35, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 75, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 78, - "column": 48, + "column": 26, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 81, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 82, - "column": 31, + "column": 9, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 87, - "column": 32, + "column": 16, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -128,7 +128,7 @@ }, { "line": 94, - "column": 37, + "column": 20, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -142,42 +142,42 @@ }, { "line": 96, - "column": 30, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 101, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 104, - "column": 42, + "column": 25, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 107, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 108, - "column": 20, + "column": 3, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 113, - "column": 21, + "column": 10, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" @@ -254,35 +254,35 @@ }, { "line": 136, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 137, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 138, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 139, - "column": 23, + "column": 13, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" }, { "line": 141, - "column": 5, + "column": 1, "problem": "FunctionApplyBindCall", "suggest": "", "rule": "\"Function.apply\", \"Function.bind\", \"Function.call\" are not supported (arkts-no-func-apply-bind-call)" diff --git a/linter/test/limited_stdlib_api.ts b/linter/test/limited_stdlib_api.ts index 500c10c9b..e0213de3b 100644 --- a/linter/test/limited_stdlib_api.ts +++ b/linter/test/limited_stdlib_api.ts @@ -28,7 +28,7 @@ decodeURIComponent(''); escape(''); unescape(''); -// global and window are not portable, so they are excluded from test suite. +global.eval('console.log("foo")'); globalThis.eval('console.log("foo")'); const evl = "eval('console.log(1)')"; const res: void = Function(evl)(); @@ -121,9 +121,3 @@ ArrayBuffer.isView({}); let a: number[] = []; let b = new ArrayBuffer(1); Array.isArray(a); - -Number.NaN; -Number.isFinite(1); -Number.isNaN(2); -Number.parseFloat('3'); -Number.parseInt('4', 10); diff --git a/linter/test/limited_stdlib_api.ts.autofix.json b/linter/test/limited_stdlib_api.ts.autofix.json index ddabd1f89..e4aca6e3c 100644 --- a/linter/test/limited_stdlib_api.ts.autofix.json +++ b/linter/test/limited_stdlib_api.ts.autofix.json @@ -23,24 +23,80 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 18, + "column": 11, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 19, + "column": 11, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 20, "column": 1, - "problem": "GlobalThis", + "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 21, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 22, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 23, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 32, - "column": 12, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "autofixable": false, + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -48,7 +104,7 @@ }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -56,7 +112,7 @@ }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -72,7 +128,7 @@ }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -80,7 +136,7 @@ }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -88,7 +144,7 @@ }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -96,7 +152,7 @@ }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -104,7 +160,7 @@ }, { "line": 64, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -112,7 +168,7 @@ }, { "line": 65, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -120,7 +176,7 @@ }, { "line": 66, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -128,7 +184,7 @@ }, { "line": 67, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -136,7 +192,7 @@ }, { "line": 68, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -144,7 +200,7 @@ }, { "line": 69, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -152,7 +208,7 @@ }, { "line": 70, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -160,7 +216,7 @@ }, { "line": 71, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -168,7 +224,7 @@ }, { "line": 72, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -176,7 +232,7 @@ }, { "line": 73, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -184,7 +240,7 @@ }, { "line": 74, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -192,7 +248,7 @@ }, { "line": 75, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -200,7 +256,7 @@ }, { "line": 76, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -208,7 +264,7 @@ }, { "line": 85, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -216,7 +272,7 @@ }, { "line": 86, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -232,7 +288,7 @@ }, { "line": 87, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -248,7 +304,7 @@ }, { "line": 88, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -256,7 +312,7 @@ }, { "line": 90, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -264,7 +320,7 @@ }, { "line": 91, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -272,7 +328,7 @@ }, { "line": 92, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -280,7 +336,7 @@ }, { "line": 93, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -288,7 +344,7 @@ }, { "line": 94, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -304,15 +360,7 @@ }, { "line": 105, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 105, - "column": 28, + "column": 20, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -320,23 +368,7 @@ }, { "line": 106, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 106, - "column": 32, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 107, - "column": 13, + "column": 24, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -344,7 +376,7 @@ }, { "line": 107, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -360,15 +392,7 @@ }, { "line": 108, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 108, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -376,23 +400,7 @@ }, { "line": 109, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 109, - "column": 26, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 110, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -400,15 +408,7 @@ }, { "line": 110, - "column": 47, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 111, - "column": 13, + "column": 39, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -416,7 +416,7 @@ }, { "line": 111, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -424,23 +424,7 @@ }, { "line": 112, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 112, - "column": 26, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 113, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -448,7 +432,7 @@ }, { "line": 113, - "column": 35, + "column": 27, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -456,23 +440,7 @@ }, { "line": 114, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 114, - "column": 30, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 115, - "column": 13, + "column": 22, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -480,15 +448,7 @@ }, { "line": 115, - "column": 40, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 116, - "column": 13, + "column": 32, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -496,7 +456,7 @@ }, { "line": 116, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -504,15 +464,7 @@ }, { "line": 117, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 117, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -520,7 +472,7 @@ }, { "line": 120, - "column": 13, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", diff --git a/linter/test/limited_stdlib_api.ts.relax.json b/linter/test/limited_stdlib_api.ts.relax.json index d77e760a8..055ef99ee 100644 --- a/linter/test/limited_stdlib_api.ts.relax.json +++ b/linter/test/limited_stdlib_api.ts.relax.json @@ -22,36 +22,85 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 18, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 19, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 20, "column": 1, - "problem": "GlobalThis", + "problem": "LimitedStdLibApi", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 21, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 22, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 23, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 32, - "column": 12, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -65,133 +114,133 @@ }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 64, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 65, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 66, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 67, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 68, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 69, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 70, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 71, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 72, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 73, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 74, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 75, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 76, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 85, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 86, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -205,7 +254,7 @@ }, { "line": 87, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -219,42 +268,42 @@ }, { "line": 88, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 90, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 91, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 92, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 93, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 94, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -268,42 +317,21 @@ }, { "line": 105, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 105, - "column": 28, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 106, - "column": 13, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 106, - "column": 32, + "column": 24, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 107, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 107, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -317,147 +345,77 @@ }, { "line": 108, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 108, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 109, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 109, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 110, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 110, - "column": 47, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 111, - "column": 13, + "column": 39, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 111, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 112, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 112, - "column": 26, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 113, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 113, - "column": 35, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 114, - "column": 13, + "column": 27, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 114, - "column": 30, + "column": 22, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 115, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 115, - "column": 40, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 116, - "column": 13, + "column": 32, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 116, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 117, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 117, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 120, - "column": 13, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter/test/limited_stdlib_api.ts.strict.json b/linter/test/limited_stdlib_api.ts.strict.json index d77e760a8..055ef99ee 100644 --- a/linter/test/limited_stdlib_api.ts.strict.json +++ b/linter/test/limited_stdlib_api.ts.strict.json @@ -22,36 +22,85 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 18, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 19, + "column": 11, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 20, "column": 1, - "problem": "GlobalThis", + "problem": "LimitedStdLibApi", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 21, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 22, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 23, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 32, - "column": 12, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -65,133 +114,133 @@ }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 64, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 65, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 66, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 67, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 68, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 69, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 70, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 71, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 72, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 73, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 74, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 75, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 76, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 85, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 86, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -205,7 +254,7 @@ }, { "line": 87, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -219,42 +268,42 @@ }, { "line": 88, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 90, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 91, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 92, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 93, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 94, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -268,42 +317,21 @@ }, { "line": 105, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 105, - "column": 28, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 106, - "column": 13, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 106, - "column": 32, + "column": 24, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 107, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 107, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -317,147 +345,77 @@ }, { "line": 108, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 108, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 109, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 109, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 110, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 110, - "column": 47, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 111, - "column": 13, + "column": 39, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 111, - "column": 37, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 112, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 112, - "column": 26, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 113, - "column": 13, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 113, - "column": 35, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 114, - "column": 13, + "column": 27, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 114, - "column": 30, + "column": 22, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 115, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 115, - "column": 40, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 116, - "column": 13, + "column": 32, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 116, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 117, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 117, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 120, - "column": 13, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter/test/new_target.ts.relax.json b/linter/test/new_target.ts.relax.json index 0b83a1198..5ec99daa2 100644 --- a/linter/test/new_target.ts.relax.json +++ b/linter/test/new_target.ts.relax.json @@ -16,7 +16,7 @@ "nodes": [ { "line": 19, - "column": 12, + "column": 5, "problem": "LimitedStdLibApi" }, { diff --git a/linter/test/new_target.ts.strict.json b/linter/test/new_target.ts.strict.json index 0b83a1198..5ec99daa2 100644 --- a/linter/test/new_target.ts.strict.json +++ b/linter/test/new_target.ts.strict.json @@ -16,7 +16,7 @@ "nodes": [ { "line": 19, - "column": 12, + "column": 5, "problem": "LimitedStdLibApi" }, { diff --git a/linter/test/oh_modules/ohos_lib.ts b/linter/test/oh_modules/ohos_lib.ts index c69856185..a0aa74c87 100644 --- a/linter/test/oh_modules/ohos_lib.ts +++ b/linter/test/oh_modules/ohos_lib.ts @@ -20,6 +20,3 @@ export interface OhosI { export function ohFunction1({d: OhosI}): void {} // incorrect usage, but it was an issue, so we check it too export function ohFunction2(p: {d: OhosI}): void {} - -export function fooOh(): any {} -export function barOh(a: any) {} diff --git a/linter/test/symbol_api.ts.relax.json b/linter/test/symbol_api.ts.relax.json index e62c8c7b7..c2211cf10 100644 --- a/linter/test/symbol_api.ts.relax.json +++ b/linter/test/symbol_api.ts.relax.json @@ -16,77 +16,77 @@ "nodes": [ { "line": 16, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 17, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 18, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 20, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 21, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 22, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 23, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 24, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 25, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 26, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 27, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" @@ -107,7 +107,7 @@ }, { "line": 33, - "column": 17, + "column": 10, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" diff --git a/linter/test/symbol_api.ts.strict.json b/linter/test/symbol_api.ts.strict.json index e62c8c7b7..c2211cf10 100644 --- a/linter/test/symbol_api.ts.strict.json +++ b/linter/test/symbol_api.ts.strict.json @@ -16,77 +16,77 @@ "nodes": [ { "line": 16, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 17, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 18, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 20, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 21, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 22, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 23, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 24, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 25, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 26, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { "line": 27, - "column": 16, + "column": 9, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" @@ -107,7 +107,7 @@ }, { "line": 33, - "column": 17, + "column": 10, "problem": "SymbolType", "suggest": "", "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" diff --git a/linter/test/utility_types.ts.relax.json b/linter/test/utility_types.ts.relax.json index fe6131546..63a56e5cd 100644 --- a/linter/test/utility_types.ts.relax.json +++ b/linter/test/utility_types.ts.relax.json @@ -266,7 +266,7 @@ }, { "line": 178, - "column": 18, + "column": 12, "problem": "FunctionApplyBindCall" }, { @@ -286,7 +286,7 @@ }, { "line": 187, - "column": 60, + "column": 54, "problem": "FunctionApplyBindCall" }, { diff --git a/linter/test/utility_types.ts.strict.json b/linter/test/utility_types.ts.strict.json index c5686de4b..cb2916b9d 100644 --- a/linter/test/utility_types.ts.strict.json +++ b/linter/test/utility_types.ts.strict.json @@ -291,7 +291,7 @@ }, { "line": 178, - "column": 18, + "column": 12, "problem": "FunctionApplyBindCall" }, { @@ -316,7 +316,7 @@ }, { "line": 187, - "column": 60, + "column": 54, "problem": "FunctionApplyBindCall" }, { diff --git a/linter/test_rules/rule132.ts.autofix.json b/linter/test_rules/rule132.ts.autofix.json index d1868ca7f..9002b4276 100644 --- a/linter/test_rules/rule132.ts.autofix.json +++ b/linter/test_rules/rule132.ts.autofix.json @@ -2,7 +2,7 @@ "nodes": [ { "line": 7, - "column": 16, + "column": 9, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", diff --git a/linter/test_rules/rule132.ts.relax.json b/linter/test_rules/rule132.ts.relax.json index 21468ce90..192c3aa10 100644 --- a/linter/test_rules/rule132.ts.relax.json +++ b/linter/test_rules/rule132.ts.relax.json @@ -2,7 +2,7 @@ "nodes": [ { "line": 7, - "column": 16, + "column": 9, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter/test_rules/rule132.ts.strict.json b/linter/test_rules/rule132.ts.strict.json index 21468ce90..192c3aa10 100644 --- a/linter/test_rules/rule132.ts.strict.json +++ b/linter/test_rules/rule132.ts.strict.json @@ -2,7 +2,7 @@ "nodes": [ { "line": 7, - "column": 16, + "column": 9, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" -- Gitee From 5601721a633789160ec409e90b381bb65e4ff8e5 Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Fri, 20 Oct 2023 13:23:49 +0300 Subject: [PATCH 02/23] [ArkTS Linter] #13972: Iterate over all child nodes to not miss comment directives between punctuation tokens. Change-Id: I9b820591bc9cb82cdd2045e12315390eba0b05a3 Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 26 +++++++++-- linter-4.2/src/TypeScriptLinterConfig.ts | 2 +- linter-4.2/test/ts_ignore.ts.relax.json | 57 ++++++++++++++++++------ linter-4.2/test/ts_ignore.ts.strict.json | 57 ++++++++++++++++++------ linter/src/TypeScriptLinter.ts | 11 ++++- linter/src/TypeScriptLinterConfig.ts | 2 +- linter/test/ts_ignore.ts.relax.json | 57 ++++++++++++++++++------ linter/test/ts_ignore.ts.strict.json | 57 ++++++++++++++++++------ 8 files changed, 211 insertions(+), 58 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 34126f27d..77cd2fa72 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -61,6 +61,7 @@ export class TypeScriptLinter { currentErrorLine: number; currentWarningLine: number; staticBlocks: Set; + walkedComments: Set; libraryTypeCallDiagnosticChecker: LibraryTypeCallDiagnosticChecker; private sourceFile?: ts.SourceFile; @@ -83,6 +84,7 @@ export class TypeScriptLinter { this.currentErrorLine = 0; this.currentWarningLine = 0; this.staticBlocks = new Set(); + this.walkedComments = new Set(); this.libraryTypeCallDiagnosticChecker = new LibraryTypeCallDiagnosticChecker(TypeScriptLinter.filteredDiagnosticMessages); for (let i = 0; i < FaultID.LAST_ID; i++) { @@ -254,7 +256,12 @@ export class TypeScriptLinter { } } - ts.forEachChild(node, visitTSNodeImpl); + // #13972: The 'ts.forEachChild' doesn't iterate over in-between punctuation tokens. + // As result, we can miss comment directives attached to those. Instead, use 'node.getChildren()'. + // to traverse child nodes. + for (const child of node.getChildren()) { + visitTSNodeImpl(child); + } } } @@ -1188,6 +1195,8 @@ export class TypeScriptLinter { ) { this.incrementCounters(node, FaultID.InstanceofUnsupported); } + } else if (tsBinaryExpr.operatorToken.kind === ts.SyntaxKind.InKeyword) { + this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); } else if (tsBinaryExpr.operatorToken.kind === ts.SyntaxKind.EqualsToken) { if (this.tsUtils.needToDeduceStructuralIdentity(leftOperandType, rightOperandType, tsRhsExpr)) { this.incrementCounters(tsBinaryExpr, FaultID.StructuralIdentity); @@ -2059,7 +2068,12 @@ export class TypeScriptLinter { ); if (leadingComments) { for (const comment of leadingComments) { - this.checkErrorSuppressingAnnotation(comment, srcText); + // In the real-time linter comment from the first line is double proccessed. + // It may be caused by tsc, but it should be investigated. This is a workaround + if (!this.walkedComments.has(comment.pos) && comment.pos !== comment.end) { + this.walkedComments.add(comment.pos); + this.checkErrorSuppressingAnnotation(comment, srcText); + } } } } @@ -2071,7 +2085,12 @@ export class TypeScriptLinter { ); if (trailingComments) { for (const comment of trailingComments) { - this.checkErrorSuppressingAnnotation(comment, srcText); + // In the real-time linter comment from the first line is double proccessed. + // It may be caused by tsc, but it should be investigated. This is a workaround + if (!this.walkedComments.has(comment.pos) && comment.pos !== comment.end) { + this.walkedComments.add(comment.pos); + this.checkErrorSuppressingAnnotation(comment, srcText); + } } } } @@ -2240,6 +2259,7 @@ export class TypeScriptLinter { } public lint(sourceFile: ts.SourceFile) { + this.walkedComments.clear(); this.sourceFile = sourceFile; this.visitTSNode(this.sourceFile); } diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index fcb5d1988..423c18076 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -175,7 +175,7 @@ export class LinterConfig { [ts.SyntaxKind.TypePredicate, FaultID.IsOperator], [ts.SyntaxKind.YieldExpression, FaultID.YieldExpression], [ts.SyntaxKind.IndexSignature, FaultID.IndexMember], [ts.SyntaxKind.WithStatement, FaultID.WithStatement], [ts.SyntaxKind.IndexedAccessType, FaultID.IndexedAccessType],[ts.SyntaxKind.UnknownKeyword, FaultID.UnknownType], - [ts.SyntaxKind.InKeyword, FaultID.InOperator], [ts.SyntaxKind.CallSignature, FaultID.CallSignature], + [ts.SyntaxKind.CallSignature, FaultID.CallSignature], [ts.SyntaxKind.IntersectionType, FaultID.IntersectionType], [ts.SyntaxKind.TypeLiteral, FaultID.ObjectTypeLiteral], [ts.SyntaxKind.ConstructorType, FaultID.ConstructorFuncs], [ts.SyntaxKind.PrivateIdentifier, FaultID.PrivateIdentifier], diff --git a/linter-4.2/test/ts_ignore.ts.relax.json b/linter-4.2/test/ts_ignore.ts.relax.json index d1f517671..8342e1744 100644 --- a/linter-4.2/test/ts_ignore.ts.relax.json +++ b/linter-4.2/test/ts_ignore.ts.relax.json @@ -17,62 +17,93 @@ { "line": 16, "column": 1, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 21, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 25, "column": 19, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 30, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 33, "column": 2, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 43, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 52, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 53, "column": 3, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 55, "column": 22, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 58, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 75, + "column": 1, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 18, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." } ] -} +} \ No newline at end of file diff --git a/linter-4.2/test/ts_ignore.ts.strict.json b/linter-4.2/test/ts_ignore.ts.strict.json index d1f517671..8342e1744 100644 --- a/linter-4.2/test/ts_ignore.ts.strict.json +++ b/linter-4.2/test/ts_ignore.ts.strict.json @@ -17,62 +17,93 @@ { "line": 16, "column": 1, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 21, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 25, "column": 19, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 30, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 33, "column": 2, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 43, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 52, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 53, "column": 3, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 55, "column": 22, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 58, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 75, + "column": 1, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 18, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." } ] -} +} \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 0b26d2f95..a8910ce93 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -268,7 +268,13 @@ export class TypeScriptLinter { handler.call(self, node); } } - ts.forEachChild(node, visitTSNodeImpl); + + // #13972: The 'ts.forEachChild' doesn't iterate over in-between punctuation tokens. + // As result, we can miss comment directives attached to those. Instead, use 'node.getChildren()'. + // to traverse child nodes. + for (const child of node.getChildren()) { + visitTSNodeImpl(child); + } } } @@ -917,6 +923,9 @@ export class TypeScriptLinter { case ts.SyntaxKind.InstanceOfKeyword: this.processBinaryInstanceOf(node, tsLhsExpr, leftOperandType); break; + case ts.SyntaxKind.InKeyword: + this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); + break; case ts.SyntaxKind.EqualsToken: if (this.tsUtils.needToDeduceStructuralIdentity(leftOperandType, rightOperandType, tsRhsExpr)) { this.incrementCounters(tsBinaryExpr, FaultID.StructuralIdentity); diff --git a/linter/src/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index 83427d5e6..03ebd743e 100644 --- a/linter/src/TypeScriptLinterConfig.ts +++ b/linter/src/TypeScriptLinterConfig.ts @@ -81,7 +81,7 @@ export class LinterConfig { [ts.SyntaxKind.TypePredicate, FaultID.IsOperator], [ts.SyntaxKind.YieldExpression, FaultID.YieldExpression], [ts.SyntaxKind.IndexSignature, FaultID.IndexMember], [ts.SyntaxKind.WithStatement, FaultID.WithStatement], [ts.SyntaxKind.IndexedAccessType, FaultID.IndexedAccessType], [ts.SyntaxKind.UnknownKeyword, FaultID.UnknownType], - [ts.SyntaxKind.InKeyword, FaultID.InOperator], [ts.SyntaxKind.CallSignature, FaultID.CallSignature], + [ts.SyntaxKind.CallSignature, FaultID.CallSignature], [ts.SyntaxKind.IntersectionType, FaultID.IntersectionType], [ts.SyntaxKind.TypeLiteral, FaultID.ObjectTypeLiteral], [ts.SyntaxKind.ConstructorType, FaultID.ConstructorFuncs], [ts.SyntaxKind.PrivateIdentifier, FaultID.PrivateIdentifier], diff --git a/linter/test/ts_ignore.ts.relax.json b/linter/test/ts_ignore.ts.relax.json index d1f517671..8342e1744 100644 --- a/linter/test/ts_ignore.ts.relax.json +++ b/linter/test/ts_ignore.ts.relax.json @@ -17,62 +17,93 @@ { "line": 16, "column": 1, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 21, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 25, "column": 19, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 30, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 33, "column": 2, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 43, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 52, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 53, "column": 3, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 55, "column": 22, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 58, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 75, + "column": 1, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 18, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." } ] -} +} \ No newline at end of file diff --git a/linter/test/ts_ignore.ts.strict.json b/linter/test/ts_ignore.ts.strict.json index d1f517671..8342e1744 100644 --- a/linter/test/ts_ignore.ts.strict.json +++ b/linter/test/ts_ignore.ts.strict.json @@ -17,62 +17,93 @@ { "line": 16, "column": 1, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 21, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 25, "column": 19, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 30, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 33, "column": 2, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 43, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 52, "column": 3, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 53, "column": 3, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 55, "column": 22, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { "line": 56, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 58, "column": 9, - "problem": "ErrorSuppression" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 75, + "column": 1, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "line": 18, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." } ] -} +} \ No newline at end of file -- Gitee From 90a207788f3a30c71659ce224ad621d4f3ef77ca Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Mon, 23 Oct 2023 13:41:10 +0300 Subject: [PATCH 03/23] [ArkTS Linter] Fix #14071: Check generic type constraint for element access expression. Change-Id: If469236ae117f681976f589dffca12bc4c4bb9d0 Signed-off-by: Evgeniy Okolnov --- linter-4.2/scripts/update-test-results.mjs | 24 +++++++------ linter-4.2/src/TypeScriptLinter.ts | 4 +-- linter-4.2/src/Utils.ts | 11 ++++++ linter-4.2/test/property_access_by_index.ts | 30 ++++++++++++++++ .../property_access_by_index.ts.autofix.json | 34 +++++++++++++++++++ .../property_access_by_index.ts.relax.json | 17 ++++++++++ .../property_access_by_index.ts.strict.json | 32 +++++++++++++++++ linter/scripts/update-test-results.mjs | 24 +++++++------ linter/src/TypeScriptLinter.ts | 2 +- linter/src/utils/TsUtils.ts | 11 ++++++ linter/test/property_access_by_index.ts | 30 ++++++++++++++++ .../property_access_by_index.ts.autofix.json | 34 +++++++++++++++++++ .../property_access_by_index.ts.relax.json | 17 ++++++++++ .../property_access_by_index.ts.strict.json | 32 +++++++++++++++++ 14 files changed, 278 insertions(+), 24 deletions(-) create mode 100644 linter-4.2/test/property_access_by_index.ts create mode 100644 linter-4.2/test/property_access_by_index.ts.autofix.json create mode 100644 linter-4.2/test/property_access_by_index.ts.relax.json create mode 100644 linter-4.2/test/property_access_by_index.ts.strict.json create mode 100644 linter/test/property_access_by_index.ts create mode 100644 linter/test/property_access_by_index.ts.autofix.json create mode 100644 linter/test/property_access_by_index.ts.relax.json create mode 100644 linter/test/property_access_by_index.ts.strict.json diff --git a/linter-4.2/scripts/update-test-results.mjs b/linter-4.2/scripts/update-test-results.mjs index dc579e424..45029c37e 100644 --- a/linter-4.2/scripts/update-test-results.mjs +++ b/linter-4.2/scripts/update-test-results.mjs @@ -37,7 +37,7 @@ const RESULTS_DIR = 'results' let testDirs = []; // forces to update all tests regardless of whether there was diff in a test result -const force_update = false; +let force_update = false; for (let arg of process.argv.slice(2)) { if (arg === '--force') @@ -72,33 +72,37 @@ function readTestFile(filePath) { function updateTest(testDir, testFile, mode) { let resultExt = RESULT_EXT[mode]; - let testFileWithExt = testFile + resultExt; + let resultFileWithExt = testFile + resultExt; + let resultFilePath = path.join(testDir, resultFileWithExt); // Do not update autofix result if test is skipped - if (mode === Mode.AUTOFIX && fs.existsSync(path.join(testDir, testFileWithExt + AUTOFIX_SKIP_EXT))) { + if (mode === Mode.AUTOFIX && fs.existsSync(path.join(testDir, testFile + AUTOFIX_SKIP_EXT))) { return; } - // Update test result when 'diff' exists or the 'force' option is enabled. - if (!fs.existsSync(path.join(testDir, RESULTS_DIR, testFileWithExt + DIFF_EXT)) && !force_update) { + // Update test result when: + // - '.diff' exists + // - expected '.json' doesn't exist + // - 'force' option is enabled + if (fs.existsSync(resultFilePath) && !fs.existsSync(path.join(testDir, RESULTS_DIR, resultFileWithExt + DIFF_EXT)) && !force_update) { return; } - let expectedResult = readTestFile(path.join(testDir, testFileWithExt)); + let expectedResult = readTestFile(resultFilePath); const copyright = expectedResult?.copyright ?? DEFAULT_COPYRIGHT; - let actualResult = readTestFile(path.join(testDir, RESULTS_DIR, testFileWithExt)); + let actualResult = readTestFile(path.join(testDir, RESULTS_DIR, resultFileWithExt)); if (!actualResult || !actualResult.nodes) { - console.log(`Failed to update ${testFileWithExt}: couldn't read ACTUAL result file.`); + console.log(`Failed to update ${resultFileWithExt}: couldn't read ACTUAL result file.`); return; } // Write file with actual test results. let newResultJSON = JSON.stringify({ copyright, nodes: actualResult.nodes }, null, 4); - fs.writeFileSync(path.join(testDir, testFileWithExt), newResultJSON); + fs.writeFileSync(resultFilePath, newResultJSON); - console.log(`Updated ${testFileWithExt}`); + console.log(`Updated ${resultFileWithExt}`); } for (let testDir of testDirs) { diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 77cd2fa72..44bc9657e 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1602,9 +1602,7 @@ export class TypeScriptLinter { private handleElementAccessExpression(node: ts.Node) { const tsElementAccessExpr = node as ts.ElementAccessExpression; - const tsElemAccessBaseExprType = this.tsTypeChecker.getTypeAtLocation( - tsElementAccessExpr.expression - ); + const tsElemAccessBaseExprType = this.tsUtils.getTypeOrTypeConstraintAtLocation(tsElementAccessExpr.expression); const tsElemAccessBaseExprTypeNode = this.tsTypeChecker.typeToTypeNode( tsElemAccessBaseExprType, undefined, diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 360d36bb1..1414a71b9 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -1507,4 +1507,15 @@ export class TsUtils { visitNode(funcExpr); return found; } + + public getTypeOrTypeConstraintAtLocation(expr: ts.Expression): ts.Type { + let type = this.tsTypeChecker.getTypeAtLocation(expr); + if (type.isTypeParameter()) { + let constraint = type.getConstraint(); + if (constraint) { + return constraint; + } + } + return type; + } } diff --git a/linter-4.2/test/property_access_by_index.ts b/linter-4.2/test/property_access_by_index.ts new file mode 100644 index 000000000..3911b881b --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +// #14071 +class A { + v: string = ''; +} +function SetProperty(oldObj: T, str: string, obj: Object): void { + oldObj[str] = obj; // Should report error +} +function GetProperty(oldObj: T, str: string): U { + return oldObj[str]; // Should report error +} +function test() { + let a: A = { v: 'abc' }; + SetProperty(a, 'u', 'def'); + return GetProperty(a, 'v') + GetProperty(a, 'u'); +} diff --git a/linter-4.2/test/property_access_by_index.ts.autofix.json b/linter-4.2/test/property_access_by_index.ts.autofix.json new file mode 100644 index 000000000..90d724616 --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 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." + ], + "nodes": [ + { + "line": 21, + "column": 3, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 24, + "column": 10, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test/property_access_by_index.ts.relax.json b/linter-4.2/test/property_access_by_index.ts.relax.json new file mode 100644 index 000000000..e7d2d6779 --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts.relax.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 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." + ], + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test/property_access_by_index.ts.strict.json b/linter-4.2/test/property_access_by_index.ts.strict.json new file mode 100644 index 000000000..816f247c7 --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts.strict.json @@ -0,0 +1,32 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 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." + ], + "nodes": [ + { + "line": 21, + "column": 3, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 24, + "column": 10, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter/scripts/update-test-results.mjs b/linter/scripts/update-test-results.mjs index dc579e424..45029c37e 100644 --- a/linter/scripts/update-test-results.mjs +++ b/linter/scripts/update-test-results.mjs @@ -37,7 +37,7 @@ const RESULTS_DIR = 'results' let testDirs = []; // forces to update all tests regardless of whether there was diff in a test result -const force_update = false; +let force_update = false; for (let arg of process.argv.slice(2)) { if (arg === '--force') @@ -72,33 +72,37 @@ function readTestFile(filePath) { function updateTest(testDir, testFile, mode) { let resultExt = RESULT_EXT[mode]; - let testFileWithExt = testFile + resultExt; + let resultFileWithExt = testFile + resultExt; + let resultFilePath = path.join(testDir, resultFileWithExt); // Do not update autofix result if test is skipped - if (mode === Mode.AUTOFIX && fs.existsSync(path.join(testDir, testFileWithExt + AUTOFIX_SKIP_EXT))) { + if (mode === Mode.AUTOFIX && fs.existsSync(path.join(testDir, testFile + AUTOFIX_SKIP_EXT))) { return; } - // Update test result when 'diff' exists or the 'force' option is enabled. - if (!fs.existsSync(path.join(testDir, RESULTS_DIR, testFileWithExt + DIFF_EXT)) && !force_update) { + // Update test result when: + // - '.diff' exists + // - expected '.json' doesn't exist + // - 'force' option is enabled + if (fs.existsSync(resultFilePath) && !fs.existsSync(path.join(testDir, RESULTS_DIR, resultFileWithExt + DIFF_EXT)) && !force_update) { return; } - let expectedResult = readTestFile(path.join(testDir, testFileWithExt)); + let expectedResult = readTestFile(resultFilePath); const copyright = expectedResult?.copyright ?? DEFAULT_COPYRIGHT; - let actualResult = readTestFile(path.join(testDir, RESULTS_DIR, testFileWithExt)); + let actualResult = readTestFile(path.join(testDir, RESULTS_DIR, resultFileWithExt)); if (!actualResult || !actualResult.nodes) { - console.log(`Failed to update ${testFileWithExt}: couldn't read ACTUAL result file.`); + console.log(`Failed to update ${resultFileWithExt}: couldn't read ACTUAL result file.`); return; } // Write file with actual test results. let newResultJSON = JSON.stringify({ copyright, nodes: actualResult.nodes }, null, 4); - fs.writeFileSync(path.join(testDir, testFileWithExt), newResultJSON); + fs.writeFileSync(resultFilePath, newResultJSON); - console.log(`Updated ${testFileWithExt}`); + console.log(`Updated ${resultFileWithExt}`); } for (let testDir of testDirs) { diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index a8910ce93..3b5ed579f 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1323,7 +1323,7 @@ export class TypeScriptLinter { private handleElementAccessExpression(node: ts.Node) { const tsElementAccessExpr = node as ts.ElementAccessExpression; - const tsElemAccessBaseExprType = this.tsTypeChecker.getTypeAtLocation(tsElementAccessExpr.expression); + const tsElemAccessBaseExprType = this.tsUtils.getTypeOrTypeConstraintAtLocation(tsElementAccessExpr.expression); const tsElemAccessBaseExprTypeNode = this.tsTypeChecker.typeToTypeNode(tsElemAccessBaseExprType, undefined, ts.NodeBuilderFlags.None); const checkClassOrInterface = tsElemAccessBaseExprType.isClassOrInterface() && diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index 17d2f6e7b..83e3683c1 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -1287,4 +1287,15 @@ export class TsUtils { visitNode(funcExpr); return found; } + + public getTypeOrTypeConstraintAtLocation(expr: ts.Expression): ts.Type { + let type = this.tsTypeChecker.getTypeAtLocation(expr); + if (type.isTypeParameter()) { + let constraint = type.getConstraint(); + if (constraint) { + return constraint; + } + } + return type; + } } diff --git a/linter/test/property_access_by_index.ts b/linter/test/property_access_by_index.ts new file mode 100644 index 000000000..3911b881b --- /dev/null +++ b/linter/test/property_access_by_index.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023-2023 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. + */ + +// #14071 +class A { + v: string = ''; +} +function SetProperty(oldObj: T, str: string, obj: Object): void { + oldObj[str] = obj; // Should report error +} +function GetProperty(oldObj: T, str: string): U { + return oldObj[str]; // Should report error +} +function test() { + let a: A = { v: 'abc' }; + SetProperty(a, 'u', 'def'); + return GetProperty(a, 'v') + GetProperty(a, 'u'); +} diff --git a/linter/test/property_access_by_index.ts.autofix.json b/linter/test/property_access_by_index.ts.autofix.json new file mode 100644 index 000000000..90d724616 --- /dev/null +++ b/linter/test/property_access_by_index.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 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." + ], + "nodes": [ + { + "line": 21, + "column": 3, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 24, + "column": 10, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.relax.json b/linter/test/property_access_by_index.ts.relax.json new file mode 100644 index 000000000..e7d2d6779 --- /dev/null +++ b/linter/test/property_access_by_index.ts.relax.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 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." + ], + "nodes": [] +} \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.strict.json b/linter/test/property_access_by_index.ts.strict.json new file mode 100644 index 000000000..816f247c7 --- /dev/null +++ b/linter/test/property_access_by_index.ts.strict.json @@ -0,0 +1,32 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 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." + ], + "nodes": [ + { + "line": 21, + "column": 3, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 24, + "column": 10, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file -- Gitee From 9e73ae10b69e9846fc6e1b86d638684af93947e0 Mon Sep 17 00:00:00 2001 From: Igor Rossinski Date: Wed, 18 Oct 2023 01:57:36 +0300 Subject: [PATCH 04/23] [ArkTS Linter] fix err#13851 Signed-off-by: Igor Rossinski --- linter-4.2/src/TypeScriptLinter.ts | 12 +++++++----- linter-4.2/test/ts_ignore.ts.relax.json | 7 ------- linter-4.2/test/ts_ignore.ts.strict.json | 7 ------- linter/src/TypeScriptLinter.ts | 21 ++++++++++++--------- linter/test/ts_ignore.ts.relax.json | 7 ------- linter/test/ts_ignore.ts.strict.json | 7 ------- 6 files changed, 19 insertions(+), 42 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 44bc9657e..250cec440 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -685,7 +685,7 @@ export class TypeScriptLinter { const baseExprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode.expression); const baseExprType = this.tsTypeChecker.getTypeAtLocation(propertyAccessNode.expression); - if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { + if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { this.incrementCounters(propertyAccessNode.name, FaultID.Prototype); } if (!!exprSym && this.tsUtils.isSymbolAPI(exprSym) && !TsUtils.ALLOWED_STD_SYMBOL_API.includes(exprSym.getName())) { @@ -773,7 +773,7 @@ export class TypeScriptLinter { ts.isIdentifier(x.expression.expression) ) decoratorName = x.expression.expression.text; - + // special case for property of type CustomDialogController of the @CustomDialog-decorated class if (expectedDecorators.includes(TsUtils.NON_INITIALIZABLE_PROPERTY_CLASS_DECORATORS[0])) { return expectedDecorators.includes(decoratorName) && propType === 'CustomDialogController' @@ -1610,7 +1610,7 @@ export class TypeScriptLinter { ); const checkClassOrInterface = tsElemAccessBaseExprType.isClassOrInterface() && !this.tsUtils.isGenericArrayType(tsElemAccessBaseExprType) && - !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); + !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); const checkThisOrSuper = this.tsUtils.isThisOrSuperExpr(tsElementAccessExpr.expression) && !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); @@ -1728,7 +1728,7 @@ export class TypeScriptLinter { this.handleStructIdentAndUndefinedInArgs(tsCallExpr, callSignature); } this.handleLibraryTypeCall(tsCallExpr, calleeType); - + if (ts.isPropertyAccessExpression(tsCallExpr.expression) && this.tsUtils.hasEsObjectType(tsCallExpr.expression.expression)) { this.incrementCounters(node, FaultID.EsObjectAccess); } @@ -2110,7 +2110,9 @@ export class TypeScriptLinter { comment.kind === ts.SyntaxKind.MultiLineCommentTrivia ? srcText.slice(comment.pos + 2, comment.end - 2) : srcText.slice(comment.pos + 2, comment.end); - + //if comment is multiline end closing '*/' is not at the same line as '@ts-xxx' - do nothing (see #13851) + if (commentContent.endsWith('\n')) + return; let trimmedContent = commentContent.trim(); if ( trimmedContent.startsWith("@ts-ignore") || diff --git a/linter-4.2/test/ts_ignore.ts.relax.json b/linter-4.2/test/ts_ignore.ts.relax.json index 8342e1744..8e4a16c18 100644 --- a/linter-4.2/test/ts_ignore.ts.relax.json +++ b/linter-4.2/test/ts_ignore.ts.relax.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 33, - "column": 2, - "problem": "ErrorSuppression", - "suggest": "", - "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" - }, { "line": 43, "column": 9, diff --git a/linter-4.2/test/ts_ignore.ts.strict.json b/linter-4.2/test/ts_ignore.ts.strict.json index 8342e1744..8e4a16c18 100644 --- a/linter-4.2/test/ts_ignore.ts.strict.json +++ b/linter-4.2/test/ts_ignore.ts.strict.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 33, - "column": 2, - "problem": "ErrorSuppression", - "suggest": "", - "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" - }, { "line": 43, "column": 9, diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 3b5ed579f..e5b475fe0 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -595,7 +595,7 @@ export class TypeScriptLinter { const baseExprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode.expression); const baseExprType = this.tsTypeChecker.getTypeAtLocation(propertyAccessNode.expression); - if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { + if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { this.incrementCounters(propertyAccessNode.name, FaultID.Prototype); } if (!!exprSym && this.tsUtils.isSymbolAPI(exprSym) && !ALLOWED_STD_SYMBOL_API.includes(exprSym.getName())) { @@ -636,7 +636,7 @@ export class TypeScriptLinter { this.handleDecorators(decorators); this.filterOutDecoratorsDiagnostics(decorators, NON_INITIALIZABLE_PROPERTY_DECORATORS, {begin: propName.getStart(), end: propName.getStart()}, PROPERTY_HAS_NO_INITIALIZER_ERROR_CODE); - + const classDecorators = ts.getDecorators(node.parent); const propType = (node as ts.PropertyDeclaration).type?.getText(); this.filterOutDecoratorsDiagnostics(classDecorators, NON_INITIALIZABLE_PROPERTY_CLASS_DECORATORS, @@ -1294,7 +1294,7 @@ export class TypeScriptLinter { private handleRestrictedValues(tsIdentifier: ts.Identifier, tsIdentSym: ts.Symbol) { const illegalValues = ts.SymbolFlags.ConstEnum | ts.SymbolFlags.RegularEnum | ts.SymbolFlags.ValueModule | (TypeScriptLinter.advancedClassChecks? 0 : ts.SymbolFlags.Class); - + // If module name is duplicated by another declaration, this increases the possibility // of finding a lot of false positives. Thus, do not check further in that case. if ((tsIdentSym.flags & ts.SymbolFlags.ValueModule) != 0) { @@ -1328,7 +1328,7 @@ export class TypeScriptLinter { const checkClassOrInterface = tsElemAccessBaseExprType.isClassOrInterface() && !this.tsUtils.isGenericArrayType(tsElemAccessBaseExprType) && - !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); + !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); const checkThisOrSuper = this.tsUtils.isThisOrSuperExpr(tsElementAccessExpr.expression) && !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); @@ -1427,7 +1427,7 @@ export class TypeScriptLinter { this.handleStructIdentAndUndefinedInArgs(tsCallExpr, callSignature); } this.handleLibraryTypeCall(tsCallExpr, calleeType); - + if (ts.isPropertyAccessExpression(tsCallExpr.expression) && this.tsUtils.hasEsObjectType(tsCallExpr.expression.expression)) { this.incrementCounters(node, FaultID.EsObjectAccess); } @@ -1466,8 +1466,8 @@ export class TypeScriptLinter { private handleGenericCallWithNoTypeArgs(callLikeExpr: ts.CallExpression | ts.NewExpression, callSignature: ts.Signature) { // Note: The PR!716 has led to a significant performance degradation. // Since initial problem was fixed in a more general way, this change - // became redundant. Therefore, it was reverted. See #13721 comments - // for a detailed analysis. + // became redundant. Therefore, it was reverted. See #13721 comments + // for a detailed analysis. const tsSyntaxKind = ts.isNewExpression(callLikeExpr) ? ts.SyntaxKind.Constructor : ts.SyntaxKind.FunctionDeclaration; const signFlags = ts.NodeBuilderFlags.WriteTypeArgumentsOfSignature | ts.NodeBuilderFlags.IgnoreErrors; @@ -1767,9 +1767,12 @@ export class TypeScriptLinter { const commentContent = comment.kind === ts.SyntaxKind.MultiLineCommentTrivia ? srcText.slice(comment.pos + 2, comment.end - 2) : srcText.slice(comment.pos + 2, comment.end); - const trimmedContent = commentContent.trim() + //if comment is multiline end closing '*/' is not at the same line as '@ts-xxx' - do nothing (see #13851) + if (commentContent.endsWith('\n')) + return; + const trimmedContent = commentContent.trim(); if (trimmedContent.startsWith('@ts-ignore') || - trimmedContent.startsWith('@ts-nocheck') || + trimmedContent.startsWith('@ts-nocheck') || trimmedContent.startsWith('@ts-expect-error')) this.incrementCounters(comment, FaultID.ErrorSuppression); } diff --git a/linter/test/ts_ignore.ts.relax.json b/linter/test/ts_ignore.ts.relax.json index 8342e1744..8e4a16c18 100644 --- a/linter/test/ts_ignore.ts.relax.json +++ b/linter/test/ts_ignore.ts.relax.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 33, - "column": 2, - "problem": "ErrorSuppression", - "suggest": "", - "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" - }, { "line": 43, "column": 9, diff --git a/linter/test/ts_ignore.ts.strict.json b/linter/test/ts_ignore.ts.strict.json index 8342e1744..8e4a16c18 100644 --- a/linter/test/ts_ignore.ts.strict.json +++ b/linter/test/ts_ignore.ts.strict.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 33, - "column": 2, - "problem": "ErrorSuppression", - "suggest": "", - "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" - }, { "line": 43, "column": 9, -- Gitee From b30e8f90e5fd4e4e7f94b4a01e62ad0fb8f88015 Mon Sep 17 00:00:00 2001 From: Denis Slynko Date: Tue, 24 Oct 2023 11:25:43 +0300 Subject: [PATCH 05/23] [ArkTS Linter] #14129 Specify semicolons as forbidden empty non-declaration statements in namespaces Signed-off-by: Denis Slynko --- linter-4.2/src/CookBookMsg.ts | 2 +- linter-4.2/test/ambient_module.ts.relax.json | 4 ++-- linter-4.2/test/ambient_module.ts.strict.json | 4 ++-- linter-4.2/test_rules/rule116.ts.autofix.json | 2 +- linter-4.2/test_rules/rule116.ts.relax.json | 2 +- linter-4.2/test_rules/rule116.ts.strict.json | 2 +- linter-4.2/test_rules/rule129.ts.autofix.json | 2 +- linter-4.2/test_rules/rule129.ts.relax.json | 2 +- linter-4.2/test_rules/rule129.ts.strict.json | 2 +- linter/src/CookBookMsg.ts | 2 +- linter/test/ambient_module.ts.relax.json | 4 ++-- linter/test/ambient_module.ts.strict.json | 4 ++-- linter/test_rules/rule116.ts.autofix.json | 2 +- linter/test_rules/rule116.ts.relax.json | 2 +- linter/test_rules/rule116.ts.strict.json | 2 +- linter/test_rules/rule129.ts.autofix.json | 2 +- linter/test_rules/rule129.ts.relax.json | 2 +- linter/test_rules/rule129.ts.strict.json | 2 +- 18 files changed, 22 insertions(+), 22 deletions(-) diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index 6f90d98ea..28b8b77f9 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -135,7 +135,7 @@ cookBookTag[112] = ''; cookBookTag[113] = '"enum" declaration merging is not supported (arkts-no-enum-merging)'; cookBookTag[114] = 'Namespaces cannot be used as objects (arkts-no-ns-as-obj)'; cookBookTag[115] = ''; -cookBookTag[116] = 'Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)'; +cookBookTag[116] = 'Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)'; cookBookTag[117] = ''; cookBookTag[118] = 'Special import type declarations are not supported (arkts-no-special-imports)'; cookBookTag[119] = 'Importing a module for side-effects only is not supported (arkts-no-side-effects-imports)'; diff --git a/linter-4.2/test/ambient_module.ts.relax.json b/linter-4.2/test/ambient_module.ts.relax.json index a02ca7fc8..543d0a12a 100644 --- a/linter-4.2/test/ambient_module.ts.relax.json +++ b/linter-4.2/test/ambient_module.ts.relax.json @@ -26,7 +26,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 20, @@ -47,7 +47,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 25, diff --git a/linter-4.2/test/ambient_module.ts.strict.json b/linter-4.2/test/ambient_module.ts.strict.json index a02ca7fc8..543d0a12a 100644 --- a/linter-4.2/test/ambient_module.ts.strict.json +++ b/linter-4.2/test/ambient_module.ts.strict.json @@ -26,7 +26,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 20, @@ -47,7 +47,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 25, diff --git a/linter-4.2/test_rules/rule116.ts.autofix.json b/linter-4.2/test_rules/rule116.ts.autofix.json index 8449964f6..f3a5f41b3 100644 --- a/linter-4.2/test_rules/rule116.ts.autofix.json +++ b/linter-4.2/test_rules/rule116.ts.autofix.json @@ -6,7 +6,7 @@ "problem": "NonDeclarationInNamespace", "autofixable": false, "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule116.ts.relax.json b/linter-4.2/test_rules/rule116.ts.relax.json index a5030d64e..3259498ae 100644 --- a/linter-4.2/test_rules/rule116.ts.relax.json +++ b/linter-4.2/test_rules/rule116.ts.relax.json @@ -5,7 +5,7 @@ "column": 5, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule116.ts.strict.json b/linter-4.2/test_rules/rule116.ts.strict.json index a5030d64e..3259498ae 100644 --- a/linter-4.2/test_rules/rule116.ts.strict.json +++ b/linter-4.2/test_rules/rule116.ts.strict.json @@ -5,7 +5,7 @@ "column": 5, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule129.ts.autofix.json b/linter-4.2/test_rules/rule129.ts.autofix.json index 6708658ae..80fc9c4b1 100644 --- a/linter-4.2/test_rules/rule129.ts.autofix.json +++ b/linter-4.2/test_rules/rule129.ts.autofix.json @@ -6,7 +6,7 @@ "problem": "NonDeclarationInNamespace", "autofixable": false, "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 2, diff --git a/linter-4.2/test_rules/rule129.ts.relax.json b/linter-4.2/test_rules/rule129.ts.relax.json index cc8823193..ab877e8e9 100644 --- a/linter-4.2/test_rules/rule129.ts.relax.json +++ b/linter-4.2/test_rules/rule129.ts.relax.json @@ -5,7 +5,7 @@ "column": 9, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 2, diff --git a/linter-4.2/test_rules/rule129.ts.strict.json b/linter-4.2/test_rules/rule129.ts.strict.json index cc8823193..ab877e8e9 100644 --- a/linter-4.2/test_rules/rule129.ts.strict.json +++ b/linter-4.2/test_rules/rule129.ts.strict.json @@ -5,7 +5,7 @@ "column": 9, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 2, diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index aba65028d..bf9f4b132 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -135,7 +135,7 @@ cookBookTag[112] = ''; cookBookTag[113] = '"enum" declaration merging is not supported (arkts-no-enum-merging)'; cookBookTag[114] = 'Namespaces cannot be used as objects (arkts-no-ns-as-obj)'; cookBookTag[115] = ''; -cookBookTag[116] = 'Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)'; +cookBookTag[116] = 'Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)'; cookBookTag[117] = ''; cookBookTag[118] = 'Special import type declarations are not supported (arkts-no-special-imports)'; cookBookTag[119] = 'Importing a module for side-effects only is not supported (arkts-no-side-effects-imports)'; diff --git a/linter/test/ambient_module.ts.relax.json b/linter/test/ambient_module.ts.relax.json index a02ca7fc8..543d0a12a 100755 --- a/linter/test/ambient_module.ts.relax.json +++ b/linter/test/ambient_module.ts.relax.json @@ -26,7 +26,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 20, @@ -47,7 +47,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 25, diff --git a/linter/test/ambient_module.ts.strict.json b/linter/test/ambient_module.ts.strict.json index a02ca7fc8..543d0a12a 100755 --- a/linter/test/ambient_module.ts.strict.json +++ b/linter/test/ambient_module.ts.strict.json @@ -26,7 +26,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 20, @@ -47,7 +47,7 @@ "column": 3, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 25, diff --git a/linter/test_rules/rule116.ts.autofix.json b/linter/test_rules/rule116.ts.autofix.json index 8449964f6..f3a5f41b3 100644 --- a/linter/test_rules/rule116.ts.autofix.json +++ b/linter/test_rules/rule116.ts.autofix.json @@ -6,7 +6,7 @@ "problem": "NonDeclarationInNamespace", "autofixable": false, "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule116.ts.relax.json b/linter/test_rules/rule116.ts.relax.json index a5030d64e..3259498ae 100644 --- a/linter/test_rules/rule116.ts.relax.json +++ b/linter/test_rules/rule116.ts.relax.json @@ -5,7 +5,7 @@ "column": 5, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule116.ts.strict.json b/linter/test_rules/rule116.ts.strict.json index a5030d64e..3259498ae 100644 --- a/linter/test_rules/rule116.ts.strict.json +++ b/linter/test_rules/rule116.ts.strict.json @@ -5,7 +5,7 @@ "column": 5, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule129.ts.autofix.json b/linter/test_rules/rule129.ts.autofix.json index 6708658ae..80fc9c4b1 100644 --- a/linter/test_rules/rule129.ts.autofix.json +++ b/linter/test_rules/rule129.ts.autofix.json @@ -6,7 +6,7 @@ "problem": "NonDeclarationInNamespace", "autofixable": false, "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 2, diff --git a/linter/test_rules/rule129.ts.relax.json b/linter/test_rules/rule129.ts.relax.json index cc8823193..ab877e8e9 100644 --- a/linter/test_rules/rule129.ts.relax.json +++ b/linter/test_rules/rule129.ts.relax.json @@ -5,7 +5,7 @@ "column": 9, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 2, diff --git a/linter/test_rules/rule129.ts.strict.json b/linter/test_rules/rule129.ts.strict.json index cc8823193..ab877e8e9 100644 --- a/linter/test_rules/rule129.ts.strict.json +++ b/linter/test_rules/rule129.ts.strict.json @@ -5,7 +5,7 @@ "column": 9, "problem": "NonDeclarationInNamespace", "suggest": "", - "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + "rule": "Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)" }, { "line": 2, -- Gitee From ad1206aa1667a3ed2db267413872f08d270eaeb5 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Mon, 23 Oct 2023 12:20:44 +0300 Subject: [PATCH 06/23] [arkts-linter] allow use of ArrayBuffer.isView #14121 Signed-off-by: Nazarov Konstantin --- linter-4.2/docs/rules/recipe144.md | 2 -- linter-4.2/src/TypeScriptLinter.ts | 2 -- linter-4.2/src/Utils.ts | 1 - .../test/limited_stdlib_api.ts.autofix.json | 8 -------- linter-4.2/test/limited_stdlib_api.ts.relax.json | 7 ------- .../test/limited_stdlib_api.ts.strict.json | 7 ------- linter/docs/rules/recipe144.md | 2 -- linter/src/TypeScriptLinter.ts | 3 --- .../src/utils/consts/LimitedStdArrayBufferAPI.ts | 16 ---------------- linter/test/limited_stdlib_api.ts.autofix.json | 8 -------- linter/test/limited_stdlib_api.ts.relax.json | 7 ------- linter/test/limited_stdlib_api.ts.strict.json | 7 ------- 12 files changed, 70 deletions(-) delete mode 100644 linter/src/utils/consts/LimitedStdArrayBufferAPI.ts diff --git a/linter-4.2/docs/rules/recipe144.md b/linter-4.2/docs/rules/recipe144.md index 975ae2131..4d3585851 100644 --- a/linter-4.2/docs/rules/recipe144.md +++ b/linter-4.2/docs/rules/recipe144.md @@ -30,8 +30,6 @@ Properties and functions of the global object: ``eval``, ``handler.has()``, ``handler.isExtensible()``, ``handler.ownKeys()``, ``handler.preventExtensions()``, ``handler.set()``, ``handler.setPrototypeOf()`` -``ArrayBuffer``: ``isView`` - ## See also diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 250cec440..d284c3283 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1864,8 +1864,6 @@ export class TypeScriptLinter { ["ObjectConstructor", {arr: TsUtils.LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], ["Reflect", {arr: TsUtils.LIMITED_STD_REFLECT_API, fault: FaultID.LimitedStdLibApi}], ["ProxyHandler", {arr: TsUtils.LIMITED_STD_PROXYHANDLER_API, fault: FaultID.LimitedStdLibApi}], - ["ArrayBuffer", {arr: TsUtils.LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], - ["ArrayBufferConstructor", {arr: TsUtils.LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], ["Symbol", {arr: null, fault: FaultID.SymbolType}], ["SymbolConstructor", {arr: null, fault: FaultID.SymbolType}], ]) diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 1414a71b9..486c60842 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -124,7 +124,6 @@ export class TsUtils { 'apply', 'construct', 'defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'getPrototypeOf', 'has', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf' ]; - static readonly LIMITED_STD_ARRAYBUFFER_API = ['isView']; static readonly NON_INITIALIZABLE_PROPERTY_DECORATORS = ['Link', 'Consume', 'ObjectLink', 'Prop', 'BuilderParam']; diff --git a/linter-4.2/test/limited_stdlib_api.ts.autofix.json b/linter-4.2/test/limited_stdlib_api.ts.autofix.json index 7c2eb1d35..d22507c45 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.autofix.json +++ b/linter-4.2/test/limited_stdlib_api.ts.autofix.json @@ -469,14 +469,6 @@ "autofixable": false, "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 93, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/limited_stdlib_api.ts.relax.json b/linter-4.2/test/limited_stdlib_api.ts.relax.json index 2cca52540..42695e72f 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.relax.json +++ b/linter-4.2/test/limited_stdlib_api.ts.relax.json @@ -412,13 +412,6 @@ "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 93, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/limited_stdlib_api.ts.strict.json b/linter-4.2/test/limited_stdlib_api.ts.strict.json index 2cca52540..42695e72f 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.strict.json +++ b/linter-4.2/test/limited_stdlib_api.ts.strict.json @@ -412,13 +412,6 @@ "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 93, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" } ] } \ No newline at end of file diff --git a/linter/docs/rules/recipe144.md b/linter/docs/rules/recipe144.md index b28c181c5..95dafd1dd 100644 --- a/linter/docs/rules/recipe144.md +++ b/linter/docs/rules/recipe144.md @@ -31,8 +31,6 @@ Properties and functions of the global object: ``eval``, ``handler.has()``, ``handler.isExtensible()``, ``handler.ownKeys()``, ``handler.preventExtensions()``, ``handler.set()``, ``handler.setPrototypeOf()`` -``ArrayBuffer``: ``isView`` - ## See also diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index e5b475fe0..8d4d17fc8 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -32,7 +32,6 @@ import { LIMITED_STD_GLOBAL_VAR } from './utils/consts/LimitedStdGlobalVar'; import { LIMITED_STD_OBJECT_API } from './utils/consts/LimitedStdObjectAPI'; import { LIMITED_STD_REFLECT_API } from './utils/consts/LimitedStdReflectAPI'; import { LIMITED_STD_PROXYHANDLER_API } from './utils/consts/LimitedStdProxyHandlerAPI'; -import { LIMITED_STD_ARRAYBUFFER_API } from './utils/consts/LimitedStdArrayBufferAPI'; import { ALLOWED_STD_SYMBOL_API } from './utils/consts/AllowedStdSymbolAPI'; import { NON_INITIALIZABLE_PROPERTY_DECORATORS, NON_INITIALIZABLE_PROPERTY_CLASS_DECORATORS } from './utils/consts/NonInitializablePropertyDecorators'; @@ -1543,8 +1542,6 @@ export class TypeScriptLinter { ['ObjectConstructor', {arr: LIMITED_STD_OBJECT_API, fault: FaultID.LimitedStdLibApi}], ['Reflect', {arr: LIMITED_STD_REFLECT_API, fault: FaultID.LimitedStdLibApi}], ['ProxyHandler', {arr: LIMITED_STD_PROXYHANDLER_API, fault: FaultID.LimitedStdLibApi}], - ['ArrayBuffer', {arr: LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], - ['ArrayBufferConstructor', {arr: LIMITED_STD_ARRAYBUFFER_API, fault: FaultID.LimitedStdLibApi}], ['Symbol', {arr: null, fault: FaultID.SymbolType}], ['SymbolConstructor', {arr: null, fault: FaultID.SymbolType}], ]) diff --git a/linter/src/utils/consts/LimitedStdArrayBufferAPI.ts b/linter/src/utils/consts/LimitedStdArrayBufferAPI.ts deleted file mode 100644 index 39605128f..000000000 --- a/linter/src/utils/consts/LimitedStdArrayBufferAPI.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2023-2023 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. - */ - -export const LIMITED_STD_ARRAYBUFFER_API = ['isView']; diff --git a/linter/test/limited_stdlib_api.ts.autofix.json b/linter/test/limited_stdlib_api.ts.autofix.json index e4aca6e3c..be0f7b9fb 100644 --- a/linter/test/limited_stdlib_api.ts.autofix.json +++ b/linter/test/limited_stdlib_api.ts.autofix.json @@ -469,14 +469,6 @@ "autofixable": false, "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 120, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" } ] } diff --git a/linter/test/limited_stdlib_api.ts.relax.json b/linter/test/limited_stdlib_api.ts.relax.json index 055ef99ee..12f323b61 100644 --- a/linter/test/limited_stdlib_api.ts.relax.json +++ b/linter/test/limited_stdlib_api.ts.relax.json @@ -412,13 +412,6 @@ "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 120, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" } ] } diff --git a/linter/test/limited_stdlib_api.ts.strict.json b/linter/test/limited_stdlib_api.ts.strict.json index 055ef99ee..12f323b61 100644 --- a/linter/test/limited_stdlib_api.ts.strict.json +++ b/linter/test/limited_stdlib_api.ts.strict.json @@ -412,13 +412,6 @@ "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 120, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" } ] } -- Gitee From 712a97b7c464b2a5c57179c4ec391e637abb7015 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Tue, 24 Oct 2023 14:09:46 +0300 Subject: [PATCH 07/23] [arkts-linter] #14155 allow computed property name in case of Symbol.iterator Signed-off-by: Nazarov Konstantin --- linter-4.2/src/TypeScriptLinter.ts | 14 +++++++-- linter-4.2/src/TypeScriptLinterConfig.ts | 1 - linter-4.2/src/Utils.ts | 31 +++++--------------- linter-4.2/test/symbol_api.ts | 6 ++++ linter/src/TypeScriptLinter.ts | 14 +++++++-- linter/src/TypeScriptLinterConfig.ts | 1 - linter/src/utils/TsUtils.ts | 36 +++++------------------- linter/test/symbol_api.ts | 6 ++++ 8 files changed, 50 insertions(+), 59 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index d284c3283..8eebb3614 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -150,6 +150,7 @@ export class TypeScriptLinter { [ts.SyntaxKind.SetAccessor, this.handleSetAccessor], [ts.SyntaxKind.ConstructSignature, this.handleConstructSignature], [ts.SyntaxKind.ExpressionWithTypeArguments, this.handleExpressionWithTypeArguments], + [ts.SyntaxKind.ComputedPropertyName, this.handleComputedPropertyName], ]); public incrementCounters( @@ -2093,13 +2094,22 @@ export class TypeScriptLinter { } private handleExpressionWithTypeArguments(node: ts.Node) { - let tsTypeExpr = node as ts.ExpressionWithTypeArguments; - let symbol = this.tsUtils.trueSymbolAtLocation(tsTypeExpr.expression); + const tsTypeExpr = node as ts.ExpressionWithTypeArguments; + const symbol = this.tsUtils.trueSymbolAtLocation(tsTypeExpr.expression); if (!!symbol && this.tsUtils.isEsObjectSymbol(symbol)) { this.incrementCounters(tsTypeExpr, FaultID.EsObjectType); } } + private handleComputedPropertyName(node: ts.Node) { + const computedProperty = node as ts.ComputedPropertyName; + const symbol = this.tsUtils.trueSymbolAtLocation(computedProperty.expression); + if (!!symbol && this.tsUtils.isSymbolIterator(symbol)) { + return + } + this.incrementCounters(node, FaultID.ComputedPropertyName); + } + private checkErrorSuppressingAnnotation( comment: ts.CommentRange, srcText: string diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 423c18076..f91b02180 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -168,7 +168,6 @@ export class LinterConfig { static incrementOnlyTokens: Map = new Map([ [ts.SyntaxKind.AnyKeyword, FaultID.AnyType], [ts.SyntaxKind.SymbolKeyword, FaultID.SymbolType], [ts.SyntaxKind.ThisType, FaultID.ThisType], - [ts.SyntaxKind.ComputedPropertyName, FaultID.ComputedPropertyName], [ts.SyntaxKind.TypeQuery, FaultID.TypeQuery], [ts.SyntaxKind.DeleteExpression, FaultID.DeleteOperator], [ts.SyntaxKind.RegularExpressionLiteral, FaultID.RegexLiteral], diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 486c60842..2cb4369ea 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -1097,35 +1097,18 @@ export class TsUtils { return !parentName || parentName === 'global'; } - public isStdObjectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Object' || parentName === 'ObjectConstructor'); - } - - public isStdReflectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Reflect'); - } - - public isStdProxyHandlerAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ProxyHandler'); - } - - public isStdArrayAPI(symbol: ts.Symbol): boolean { + public isSymbolAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Array' || parentName === 'ArrayConstructor'); + return !!parentName && (parentName === 'Symbol' || parentName === 'SymbolConstructor'); } - public isStdArrayBufferAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ArrayBuffer' || parentName === 'ArrayBufferConstructor'); + public isStdSymbol(symbol: ts.Symbol): boolean { + const name = this.tsTypeChecker.getFullyQualifiedName(symbol) + return name === 'Symbol' && this.isGlobalSymbol(symbol); } - public isSymbolAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - let name = parentName ? parentName : symbol.escapedName; - return name === 'Symbol' || name === 'SymbolConstructor'; + public isSymbolIterator(symbol: ts.Symbol): boolean { + return this.isSymbolAPI(symbol) && symbol.name === 'iterator' } public isDefaultImport(importSpec: ts.ImportSpecifier): boolean { diff --git a/linter-4.2/test/symbol_api.ts b/linter-4.2/test/symbol_api.ts index 2d33c448f..8d7d25d3e 100644 --- a/linter-4.2/test/symbol_api.ts +++ b/linter-4.2/test/symbol_api.ts @@ -50,3 +50,9 @@ class TestClass { return Symbol(); } } + +class BIter { + [Symbol.iterator] = () => { + return 1; + }; +} diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 8d4d17fc8..31a922b5d 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -171,6 +171,7 @@ export class TypeScriptLinter { [ts.SyntaxKind.SetAccessor, this.handleSetAccessor], [ts.SyntaxKind.ConstructSignature, this.handleConstructSignature], [ts.SyntaxKind.ExpressionWithTypeArguments, this.handleExpressionWithTypeArguments], + [ts.SyntaxKind.ComputedPropertyName, this.handleComputedPropertyName], ]); public incrementCounters(node: ts.Node | ts.CommentRange, faultId: number, autofixable: boolean = false, autofix?: Autofix[],) { @@ -1753,13 +1754,22 @@ export class TypeScriptLinter { } private handleExpressionWithTypeArguments(node: ts.Node) { - let tsTypeExpr = node as ts.ExpressionWithTypeArguments; - let symbol = this.tsUtils.trueSymbolAtLocation(tsTypeExpr.expression); + const tsTypeExpr = node as ts.ExpressionWithTypeArguments; + const symbol = this.tsUtils.trueSymbolAtLocation(tsTypeExpr.expression); if (!!symbol && this.tsUtils.isEsObjectSymbol(symbol)) { this.incrementCounters(tsTypeExpr, FaultID.EsObjectType); } } + private handleComputedPropertyName(node: ts.Node) { + const computedProperty = node as ts.ComputedPropertyName; + const symbol = this.tsUtils.trueSymbolAtLocation(computedProperty.expression); + if (!!symbol && this.tsUtils.isSymbolIterator(symbol)) { + return + } + this.incrementCounters(node, FaultID.ComputedPropertyName); + } + private checkErrorSuppressingAnnotation(comment: ts.CommentRange, srcText: string) { const commentContent = comment.kind === ts.SyntaxKind.MultiLineCommentTrivia ? srcText.slice(comment.pos + 2, comment.end - 2) diff --git a/linter/src/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index 03ebd743e..64c2c1126 100644 --- a/linter/src/TypeScriptLinterConfig.ts +++ b/linter/src/TypeScriptLinterConfig.ts @@ -74,7 +74,6 @@ export class LinterConfig { static incrementOnlyTokens: Map = new Map([ [ts.SyntaxKind.AnyKeyword, FaultID.AnyType], [ts.SyntaxKind.SymbolKeyword, FaultID.SymbolType], [ts.SyntaxKind.ThisType, FaultID.ThisType], - [ts.SyntaxKind.ComputedPropertyName, FaultID.ComputedPropertyName], [ts.SyntaxKind.TypeQuery, FaultID.TypeQuery], [ts.SyntaxKind.DeleteExpression, FaultID.DeleteOperator], [ts.SyntaxKind.RegularExpressionLiteral, FaultID.RegexLiteral], diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index 83e3683c1..fbe9f0452 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -900,35 +900,18 @@ export class TsUtils { return !parentName || parentName === 'global'; } - public isStdObjectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Object' || parentName === 'ObjectConstructor'); - } - - public isStdReflectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Reflect'); - } - - public isStdProxyHandlerAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ProxyHandler'); - } - - public isStdArrayAPI(symbol: ts.Symbol): boolean { + public isSymbolAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Array' || parentName === 'ArrayConstructor'); + return !!parentName && (parentName === 'Symbol' || parentName === 'SymbolConstructor'); } - public isStdArrayBufferAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ArrayBuffer' || parentName === 'ArrayBufferConstructor'); + public isStdSymbol(symbol: ts.Symbol): boolean { + const name = this.tsTypeChecker.getFullyQualifiedName(symbol) + return name === 'Symbol' && this.isGlobalSymbol(symbol); } - public isSymbolAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - let name = parentName ? parentName : symbol.escapedName; - return name === 'Symbol' || name === 'SymbolConstructor'; + public isSymbolIterator(symbol: ts.Symbol): boolean { + return this.isSymbolAPI(symbol) && symbol.name === 'iterator' } public isDefaultImport(importSpec: ts.ImportSpecifier): boolean { @@ -1020,11 +1003,6 @@ export class TsUtils { return false; } - public isStdFunctionType(type: ts.Type) { - const sym = type.getSymbol(); - return sym && sym.getName() === 'Function' && this.isGlobalSymbol(sym); - } - public isDynamicType(type: ts.Type | undefined): boolean | undefined { if (type === undefined) { return false; diff --git a/linter/test/symbol_api.ts b/linter/test/symbol_api.ts index 2d33c448f..8d7d25d3e 100644 --- a/linter/test/symbol_api.ts +++ b/linter/test/symbol_api.ts @@ -50,3 +50,9 @@ class TestClass { return Symbol(); } } + +class BIter { + [Symbol.iterator] = () => { + return 1; + }; +} -- Gitee From 023fe7331c533a4e70cb74332483d02b46accdc7 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Tue, 24 Oct 2023 20:32:45 +0300 Subject: [PATCH 08/23] [arkts-linter] fix 14031 Signed-off-by: Nazarov Konstantin --- linter/src/ts-diagnostics/TSCCompiledProgram.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/linter/src/ts-diagnostics/TSCCompiledProgram.ts b/linter/src/ts-diagnostics/TSCCompiledProgram.ts index 9ebcb1fab..d1ece2fc6 100644 --- a/linter/src/ts-diagnostics/TSCCompiledProgram.ts +++ b/linter/src/ts-diagnostics/TSCCompiledProgram.ts @@ -46,11 +46,13 @@ export class TSCCompiledProgramSimple implements TSCCompiledProgram { export class TSCCompiledProgramWithDiagnostics implements TSCCompiledProgram { private diagnosticsExtractor: TypeScriptDiagnosticsExtractor; private wasStrict: boolean; + private cachedDiagnostics: Map; constructor(program: ts.Program, options: LintOptions) { const { strict, nonStrict, wasStrict } = getTwoCompiledVersions(program, options); this.diagnosticsExtractor = new TypeScriptDiagnosticsExtractor(strict, nonStrict); this.wasStrict = wasStrict; + this.cachedDiagnostics = new Map(); } public getOriginalProgram(): ts.Program { @@ -58,7 +60,13 @@ export class TSCCompiledProgramWithDiagnostics implements TSCCompiledProgram { } public getStrictDiagnostics(fileName: string): ts.Diagnostic[] { - return this.diagnosticsExtractor.getStrictDiagnostics(fileName); + const cachedDiagnostic = this.cachedDiagnostics.get(fileName); + if (!!cachedDiagnostic) { + return cachedDiagnostic + } + const diagnostic = this.diagnosticsExtractor.getStrictDiagnostics(fileName); + this.cachedDiagnostics.set(fileName, diagnostic) + return diagnostic; } } -- Gitee From 0e99322c31f7f9b95005be21a61f07647abfa978 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Wed, 25 Oct 2023 11:41:56 +0300 Subject: [PATCH 09/23] [arkts-linter] fix 14124 - relax arkts-no-special-imports/exports Signed-off-by: Nazarov Konstantin --- linter-4.2/docs/rules/recipe118.md | 39 ---------- linter-4.2/docs/rules/recipe127.md | 48 ------------ linter-4.2/src/Problems.ts | 4 +- linter-4.2/src/TypeScriptLinter.ts | 18 ----- linter-4.2/src/TypeScriptLinterConfig.ts | 2 - linter-4.2/test/modules.ts.autofix.json | 39 ---------- linter-4.2/test/modules.ts.strict.json | 15 ---- linter-4.2/test_rules/rule118.ts.autofix.json | 18 +---- linter-4.2/test_rules/rule118.ts.strict.json | 10 +-- linter-4.2/test_rules/rule127.ts.autofix.json | 18 +---- linter-4.2/test_rules/rule127.ts.strict.json | 10 +-- linter/docs/rules/recipe118.md | 39 ---------- linter/docs/rules/recipe127.md | 48 ------------ linter/src/CookBookMsg.ts | 4 +- linter/src/FaultAttrs.ts | 2 - linter/src/FaultDesc.ts | 2 - linter/src/Problems.ts | 2 +- linter/src/TypeScriptLinter.ts | 38 --------- linter/test/default_imports.ts.autofix.json | 39 ---------- linter/test/default_imports.ts.strict.json | 25 ------ linter/test/modules.ts.autofix.json | 78 ------------------- linter/test/modules.ts.strict.json | 30 ------- linter/test_rules/rule118.ts.autofix.json | 18 +---- linter/test_rules/rule118.ts.strict.json | 10 +-- linter/test_rules/rule127.ts.autofix.json | 18 +---- linter/test_rules/rule127.ts.strict.json | 10 +-- 26 files changed, 12 insertions(+), 572 deletions(-) delete mode 100644 linter-4.2/docs/rules/recipe118.md delete mode 100644 linter-4.2/docs/rules/recipe127.md delete mode 100644 linter/docs/rules/recipe118.md delete mode 100644 linter/docs/rules/recipe127.md diff --git a/linter-4.2/docs/rules/recipe118.md b/linter-4.2/docs/rules/recipe118.md deleted file mode 100644 index f625bc3e9..000000000 --- a/linter-4.2/docs/rules/recipe118.md +++ /dev/null @@ -1,39 +0,0 @@ -# Special import type declarations are not supported - -Rule ``arkts-no-special-imports`` - -**Severity: error** - -ArkTS does not have a special notation for importing types. -Use ordinary import instead. - - -## TypeScript - - -``` - - // Re-using the same import - import { APIResponseType } from "api" - - // Explicitly use import type - import type { APIResponseType } from "api" - -``` - -## ArkTS - - -``` - - import { APIResponseType } from "api" - -``` - -## See also - -- Recipe 119: Importing a module for side-effects only is not supported (``arkts-no-side-effects-imports``) -- Recipe 120: ``import default as ...`` is not supported (``arkts-no-import-default-as``) -- Recipe 121: ``require`` and ``import`` assignment are not supported (``arkts-no-require``) - - diff --git a/linter-4.2/docs/rules/recipe127.md b/linter-4.2/docs/rules/recipe127.md deleted file mode 100644 index c89d24fba..000000000 --- a/linter-4.2/docs/rules/recipe127.md +++ /dev/null @@ -1,48 +0,0 @@ -# Special ``export type`` declarations are not supported - -Rule ``arkts-no-special-exports`` - -**Severity: error** - -ArkTS does not have a special notation for exporting types through -``export type ...``. Use ordinary export instead. - - -## TypeScript - - -``` - - // Explicitly exported class: - export class Class1 { - // ... - } - - // Declared class later exported through export type ... - class Class2 { - // ... - } - - // This is not supported: - export type { Class2 } - -``` - -## ArkTS - - -``` - - // Explicitly exported class: - export class Class1 { - // ... - } - - // Explicitly exported class: - export class Class2 { - // ... - } - -``` - - diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index 69dab34fb..df9623d67 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -27,7 +27,7 @@ export enum FaultID { ConditionalType, MappedType, NamespaceAsObject, ClassAsObject, NonDeclarationInNamespace, GeneratorFunction, FunctionContainsThis, PropertyAccessByIndex, JsxElement, EnumMemberNonConstInit, ImplementsClass, MethodReassignment, MultipleStaticBlocks, ThisType, - IntefaceExtendDifProps, StructuralIdentity, TypeOnlyImport, TypeOnlyExport, DefaultImport, + IntefaceExtendDifProps, StructuralIdentity, DefaultImport, ExportAssignment, ImportAssignment, GenericCallNoTypeArgs, ParameterProperties, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, @@ -108,11 +108,9 @@ faultsAttrs[FaultID.EnumMerging] = {cookBookRef: '113',}; faultsAttrs[FaultID.NamespaceAsObject] = {cookBookRef: '114',}; faultsAttrs[FaultID.NonDeclarationInNamespace] = {cookBookRef: '116',}; faultsAttrs[FaultID.ImportFromPath] = {cookBookRef: '119',}; -faultsAttrs[FaultID.TypeOnlyImport] = {migratable: true, cookBookRef: '118',}; faultsAttrs[FaultID.DefaultImport] = {migratable: true, cookBookRef: '120',}; faultsAttrs[FaultID.ImportAssignment] = {cookBookRef: '121',}; faultsAttrs[FaultID.ExportAssignment] = {cookBookRef: '126',}; -faultsAttrs[FaultID.TypeOnlyExport] = {migratable: true, cookBookRef: '127',}; faultsAttrs[FaultID.ShorthandAmbientModuleDecl] = {cookBookRef: '128',}; faultsAttrs[FaultID.WildcardsInModuleName] = {cookBookRef: '129',}; faultsAttrs[FaultID.UMDModuleDefinition] = {cookBookRef: '130',}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 8eebb3614..0800b2c38 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -138,7 +138,6 @@ export class TypeScriptLinter { [ts.SyntaxKind.ElementAccessExpression, this.handleElementAccessExpression], [ts.SyntaxKind.EnumMember, this.handleEnumMember], [ts.SyntaxKind.TypeReference, this.handleTypeReference], - [ts.SyntaxKind.ExportDeclaration, this.handleExportDeclaration], [ts.SyntaxKind.ExportAssignment, this.handleExportAssignment], [ts.SyntaxKind.CallExpression, this.handleCallExpression], [ts.SyntaxKind.MetaProperty, this.handleMetaProperty], @@ -1428,13 +1427,6 @@ export class TypeScriptLinter { ); } } - - if (tsImportClause.isTypeOnly) { - let autofix: Autofix[] | undefined; - if (this.autofixesInfo.shouldAutofix(node, FaultID.TypeOnlyImport)) - autofix = [Autofixer.dropTypeOnlyFlag(tsImportClause)]; - this.incrementCounters(node, FaultID.TypeOnlyImport, true, autofix); - } } private handleImportSpecifier(node: ts.Node) { @@ -1688,16 +1680,6 @@ export class TypeScriptLinter { } } - private handleExportDeclaration(node: ts.Node) { - let tsExportDecl = node as ts.ExportDeclaration; - if (tsExportDecl.isTypeOnly) { - let autofix: Autofix[] | undefined; - if (this.autofixesInfo.shouldAutofix(node, FaultID.TypeOnlyExport)) - autofix = [Autofixer.dropTypeOnlyFlag(tsExportDecl)]; - this.incrementCounters(node, FaultID.TypeOnlyExport, true, autofix); - } - } - private handleExportAssignment(node: ts.Node) { const exportAssignment = node as ts.ExportAssignment; if (exportAssignment.isExportEquals) { diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index f91b02180..179738f65 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -92,8 +92,6 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.ThisType] = '"this" type'; LinterConfig.nodeDesc[FaultID.IntefaceExtendDifProps] = 'Extends same properties with different types'; LinterConfig.nodeDesc[FaultID.StructuralIdentity] = 'Use of type structural identity'; - LinterConfig.nodeDesc[FaultID.TypeOnlyImport] = 'Type-only imports'; - LinterConfig.nodeDesc[FaultID.TypeOnlyExport] = 'Type-only exports'; LinterConfig.nodeDesc[FaultID.DefaultImport] = 'Default import declarations'; LinterConfig.nodeDesc[FaultID.ExportAssignment] = 'Export assignments (export = ..)'; LinterConfig.nodeDesc[FaultID.ImportAssignment] = 'Import assignments (import = ..)'; diff --git a/linter-4.2/test/modules.ts.autofix.json b/linter-4.2/test/modules.ts.autofix.json index 567b9a523..476aed0b6 100644 --- a/linter-4.2/test/modules.ts.autofix.json +++ b/linter-4.2/test/modules.ts.autofix.json @@ -111,51 +111,12 @@ "problem": "ImportAfterStatement", "autofixable": false }, - { - "line": 92, - "column": 8, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 1923, - "end": 1947, - "replacementText": "{ APIResponseType }" - } - ] - }, { "line": 93, "column": 1, "problem": "ImportAfterStatement", "autofixable": false }, - { - "line": 93, - "column": 8, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 1969, - "end": 1980, - "replacementText": "* as P" - } - ] - }, - { - "line": 96, - "column": 1, - "problem": "TypeOnlyExport", - "autofixable": true, - "autofix": [ - { - "start": 2014, - "end": 2045, - "replacementText": "export { TypeA as TypeB };" - } - ] - }, { "line": 104, "column": 1, diff --git a/linter-4.2/test/modules.ts.strict.json b/linter-4.2/test/modules.ts.strict.json index 9481d07d8..88de58388 100644 --- a/linter-4.2/test/modules.ts.strict.json +++ b/linter-4.2/test/modules.ts.strict.json @@ -89,26 +89,11 @@ "column": 1, "problem": "ImportAfterStatement" }, - { - "line": 92, - "column": 8, - "problem": "TypeOnlyImport" - }, { "line": 93, "column": 1, "problem": "ImportAfterStatement" }, - { - "line": 93, - "column": 8, - "problem": "TypeOnlyImport" - }, - { - "line": 96, - "column": 1, - "problem": "TypeOnlyExport" - }, { "line": 104, "column": 1, diff --git a/linter-4.2/test_rules/rule118.ts.autofix.json b/linter-4.2/test_rules/rule118.ts.autofix.json index 3ff68f6c7..13f13363f 100644 --- a/linter-4.2/test_rules/rule118.ts.autofix.json +++ b/linter-4.2/test_rules/rule118.ts.autofix.json @@ -1,19 +1,3 @@ { - "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 120, - "end": 144, - "replacementText": "{ APIResponseType }" - } - ], - "suggest": "", - "rule": "Special import type declarations are not supported (arkts-no-special-imports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule118.ts.strict.json b/linter-4.2/test_rules/rule118.ts.strict.json index d30836a74..13f13363f 100644 --- a/linter-4.2/test_rules/rule118.ts.strict.json +++ b/linter-4.2/test_rules/rule118.ts.strict.json @@ -1,11 +1,3 @@ { - "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TypeOnlyImport", - "suggest": "", - "rule": "Special import type declarations are not supported (arkts-no-special-imports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule127.ts.autofix.json b/linter-4.2/test_rules/rule127.ts.autofix.json index c32c0f461..13f13363f 100644 --- a/linter-4.2/test_rules/rule127.ts.autofix.json +++ b/linter-4.2/test_rules/rule127.ts.autofix.json @@ -1,19 +1,3 @@ { - "nodes": [ - { - "line": 12, - "column": 5, - "problem": "TypeOnlyExport", - "autofixable": true, - "autofix": [ - { - "start": 218, - "end": 240, - "replacementText": "export { Class2 };" - } - ], - "suggest": "", - "rule": "Special \"export type\" declarations are not supported (arkts-no-special-exports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule127.ts.strict.json b/linter-4.2/test_rules/rule127.ts.strict.json index 35f1a5889..13f13363f 100644 --- a/linter-4.2/test_rules/rule127.ts.strict.json +++ b/linter-4.2/test_rules/rule127.ts.strict.json @@ -1,11 +1,3 @@ { - "nodes": [ - { - "line": 12, - "column": 5, - "problem": "TypeOnlyExport", - "suggest": "", - "rule": "Special \"export type\" declarations are not supported (arkts-no-special-exports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter/docs/rules/recipe118.md b/linter/docs/rules/recipe118.md deleted file mode 100644 index f625bc3e9..000000000 --- a/linter/docs/rules/recipe118.md +++ /dev/null @@ -1,39 +0,0 @@ -# Special import type declarations are not supported - -Rule ``arkts-no-special-imports`` - -**Severity: error** - -ArkTS does not have a special notation for importing types. -Use ordinary import instead. - - -## TypeScript - - -``` - - // Re-using the same import - import { APIResponseType } from "api" - - // Explicitly use import type - import type { APIResponseType } from "api" - -``` - -## ArkTS - - -``` - - import { APIResponseType } from "api" - -``` - -## See also - -- Recipe 119: Importing a module for side-effects only is not supported (``arkts-no-side-effects-imports``) -- Recipe 120: ``import default as ...`` is not supported (``arkts-no-import-default-as``) -- Recipe 121: ``require`` and ``import`` assignment are not supported (``arkts-no-require``) - - diff --git a/linter/docs/rules/recipe127.md b/linter/docs/rules/recipe127.md deleted file mode 100644 index c89d24fba..000000000 --- a/linter/docs/rules/recipe127.md +++ /dev/null @@ -1,48 +0,0 @@ -# Special ``export type`` declarations are not supported - -Rule ``arkts-no-special-exports`` - -**Severity: error** - -ArkTS does not have a special notation for exporting types through -``export type ...``. Use ordinary export instead. - - -## TypeScript - - -``` - - // Explicitly exported class: - export class Class1 { - // ... - } - - // Declared class later exported through export type ... - class Class2 { - // ... - } - - // This is not supported: - export type { Class2 } - -``` - -## ArkTS - - -``` - - // Explicitly exported class: - export class Class1 { - // ... - } - - // Explicitly exported class: - export class Class2 { - // ... - } - -``` - - diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index bf9f4b132..d71982547 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -137,7 +137,7 @@ cookBookTag[114] = 'Namespaces cannot be used as objects (arkts-no-ns-as-obj)'; cookBookTag[115] = ''; cookBookTag[116] = 'Non-declaration statements in namespaces are not supported (single semicolons are considered as empty non-declaration statement) (arkts-no-ns-statements)'; cookBookTag[117] = ''; -cookBookTag[118] = 'Special import type declarations are not supported (arkts-no-special-imports)'; +cookBookTag[118] = ''; cookBookTag[119] = 'Importing a module for side-effects only is not supported (arkts-no-side-effects-imports)'; cookBookTag[120] = '"import default as ..." is not supported (arkts-no-import-default-as)'; cookBookTag[121] = '"require" and "import" assignment are not supported (arkts-no-require)'; @@ -146,7 +146,7 @@ cookBookTag[123] = ''; cookBookTag[124] = ''; cookBookTag[125] = ''; cookBookTag[126] = '"export = ..." assignment is not supported (arkts-no-export-assignment)'; -cookBookTag[127] = 'Special "export type" declarations are not supported (arkts-no-special-exports)'; +cookBookTag[127] = ''; cookBookTag[128] = 'Ambient module declaration is not supported (arkts-no-ambient-decls)'; cookBookTag[129] = 'Wildcards in module names are not supported (arkts-no-module-wildcards)'; cookBookTag[130] = 'Universal module definitions (UMD) are not supported (arkts-no-umd)'; diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index a40ad5b38..e567b1f60 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -85,11 +85,9 @@ faultsAttrs[FaultID.EnumMerging] = {cookBookRef: '113',}; faultsAttrs[FaultID.NamespaceAsObject] = {cookBookRef: '114',}; faultsAttrs[FaultID.NonDeclarationInNamespace] = {cookBookRef: '116',}; faultsAttrs[FaultID.ImportFromPath] = {cookBookRef: '119',}; -faultsAttrs[FaultID.TypeOnlyImport] = {migratable: true, cookBookRef: '118',}; faultsAttrs[FaultID.DefaultImport] = {migratable: true, cookBookRef: '120',}; faultsAttrs[FaultID.ImportAssignment] = {cookBookRef: '121',}; faultsAttrs[FaultID.ExportAssignment] = {cookBookRef: '126',}; -faultsAttrs[FaultID.TypeOnlyExport] = {migratable: true, cookBookRef: '127',}; faultsAttrs[FaultID.ShorthandAmbientModuleDecl] = {cookBookRef: '128',}; faultsAttrs[FaultID.WildcardsInModuleName] = {cookBookRef: '129',}; faultsAttrs[FaultID.UMDModuleDefinition] = {cookBookRef: '130',}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index c49b1f3bc..407fd7a05 100644 --- a/linter/src/FaultDesc.ts +++ b/linter/src/FaultDesc.ts @@ -76,8 +76,6 @@ faultDesc[FaultID.MultipleStaticBlocks] = 'Multiple static blocks'; faultDesc[FaultID.ThisType] = '"this" type'; faultDesc[FaultID.IntefaceExtendDifProps] = 'Extends same properties with different types'; faultDesc[FaultID.StructuralIdentity] = 'Use of type structural identity'; -faultDesc[FaultID.TypeOnlyImport] = 'Type-only imports'; -faultDesc[FaultID.TypeOnlyExport] = 'Type-only exports'; faultDesc[FaultID.DefaultImport] = 'Default import declarations'; faultDesc[FaultID.ExportAssignment] = 'Export assignments (export = ..)'; faultDesc[FaultID.ImportAssignment] = 'Import assignments (import = ..)'; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index 245ea31e7..ea9407728 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -27,7 +27,7 @@ export enum FaultID { ConditionalType, MappedType, NamespaceAsObject, ClassAsObject, NonDeclarationInNamespace, GeneratorFunction, FunctionContainsThis, PropertyAccessByIndex, JsxElement, EnumMemberNonConstInit, ImplementsClass, MethodReassignment, MultipleStaticBlocks, ThisType, - IntefaceExtendDifProps, StructuralIdentity, TypeOnlyImport, TypeOnlyExport, DefaultImport, + IntefaceExtendDifProps, StructuralIdentity, DefaultImport, ExportAssignment, ImportAssignment, GenericCallNoTypeArgs, ParameterProperties, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 31a922b5d..9fc9e315b 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -159,7 +159,6 @@ export class TypeScriptLinter { [ts.SyntaxKind.ElementAccessExpression, this.handleElementAccessExpression], [ts.SyntaxKind.EnumMember, this.handleEnumMember], [ts.SyntaxKind.TypeReference, this.handleTypeReference], - [ts.SyntaxKind.ExportDeclaration, this.handleExportDeclaration], [ts.SyntaxKind.ExportAssignment, this.handleExportAssignment], [ts.SyntaxKind.CallExpression, this.handleCallExpression], [ts.SyntaxKind.MetaProperty, this.handleMetaProperty], @@ -1165,27 +1164,11 @@ export class TypeScriptLinter { this.incrementCounters(defaultSpec, FaultID.DefaultImport, true, autofix); } } - if (tsImportClause.isTypeOnly) { - let autofix: Autofix[] | undefined; - if (this.autofixesInfo.shouldAutofix(node, FaultID.TypeOnlyImport)) - autofix = [ Autofixer.dropTypeOnlyFlag(tsImportClause) ]; - this.incrementCounters(node, FaultID.TypeOnlyImport, true, autofix); - } } private handleImportSpecifier(node: ts.Node) { let importSpec = node as ts.ImportSpecifier; this.countDeclarationsWithDuplicateName(importSpec.name, importSpec); - // Don't report or autofix type-only flag on default import if the latter has been autofixed already. - if ( - importSpec.isTypeOnly && - (!this.tsUtils.isDefaultImport(importSpec) || !this.autofixesInfo.shouldAutofix(importSpec, FaultID.DefaultImport)) - ) { - let autofix: Autofix[] | undefined; - if (this.autofixesInfo.shouldAutofix(node, FaultID.TypeOnlyImport)) - autofix = [ Autofixer.dropTypeOnlyFlag(importSpec) ]; - this.incrementCounters(node, FaultID.TypeOnlyImport, true, autofix); - } } private handleNamespaceImport(node: ts.Node) { @@ -1375,27 +1358,6 @@ export class TypeScriptLinter { } } - private handleExportDeclaration(node: ts.Node) { - let tsExportDecl = node as ts.ExportDeclaration; - if (tsExportDecl.isTypeOnly) { - let autofix: Autofix[] | undefined; - if (this.autofixesInfo.shouldAutofix(node, FaultID.TypeOnlyExport)) - autofix = [ Autofixer.dropTypeOnlyFlag(tsExportDecl) ]; - this.incrementCounters(node, FaultID.TypeOnlyExport, true, autofix); - } - let exportClause = tsExportDecl.exportClause; - if (exportClause && ts.isNamedExports(exportClause)) { - for (const exportSpec of exportClause.elements) { - if (exportSpec.isTypeOnly) { - let autofix: Autofix[] | undefined; - if (this.autofixesInfo.shouldAutofix(exportSpec, FaultID.TypeOnlyExport)) - autofix = [ Autofixer.dropTypeOnlyFlag(exportSpec) ]; - this.incrementCounters(exportSpec, FaultID.TypeOnlyExport, true, autofix); - } - } - } - } - private handleExportAssignment(node: ts.Node) { const exportAssignment = node as ts.ExportAssignment; if (exportAssignment.isExportEquals) { diff --git a/linter/test/default_imports.ts.autofix.json b/linter/test/default_imports.ts.autofix.json index f666c003d..b083d587f 100755 --- a/linter/test/default_imports.ts.autofix.json +++ b/linter/test/default_imports.ts.autofix.json @@ -40,19 +40,6 @@ } ] }, - { - "line": 17, - "column": 8, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 655, - "end": 675, - "replacementText": "{ default as D2 }" - } - ] - }, { "line": 18, "column": 9, @@ -92,19 +79,6 @@ } ] }, - { - "line": 20, - "column": 8, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 785, - "end": 811, - "replacementText": "{ C, default as D5, D }" - } - ] - }, { "line": 21, "column": 17, @@ -117,19 +91,6 @@ "replacementText": "D5, { type E, F }" } ] - }, - { - "line": 21, - "column": 9, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 835, - "end": 841, - "replacementText": "E" - } - ] } ] } \ No newline at end of file diff --git a/linter/test/default_imports.ts.strict.json b/linter/test/default_imports.ts.strict.json index 07471ba2b..ffea8cd37 100755 --- a/linter/test/default_imports.ts.strict.json +++ b/linter/test/default_imports.ts.strict.json @@ -24,21 +24,11 @@ "column": 14, "problem": "DefaultImport" }, - { - "line": 17, - "column": 8, - "problem": "TypeOnlyImport" - }, { "line": 18, "column": 9, "problem": "DefaultImport" }, - { - "line": 18, - "column": 9, - "problem": "TypeOnlyImport" - }, { "line": 19, "column": 12, @@ -49,25 +39,10 @@ "column": 17, "problem": "DefaultImport" }, - { - "line": 20, - "column": 8, - "problem": "TypeOnlyImport" - }, { "line": 21, "column": 17, "problem": "DefaultImport" - }, - { - "line": 21, - "column": 9, - "problem": "TypeOnlyImport" - }, - { - "line": 21, - "column": 17, - "problem": "TypeOnlyImport" } ] } \ No newline at end of file diff --git a/linter/test/modules.ts.autofix.json b/linter/test/modules.ts.autofix.json index 3c5ec13d6..c78c78603 100755 --- a/linter/test/modules.ts.autofix.json +++ b/linter/test/modules.ts.autofix.json @@ -111,96 +111,18 @@ "problem": "ImportAfterStatement", "autofixable": false }, - { - "line": 92, - "column": 8, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 1923, - "end": 1947, - "replacementText": "{ APIResponseType }" - } - ] - }, { "line": 93, "column": 1, "problem": "ImportAfterStatement", "autofixable": false }, - { - "line": 93, - "column": 8, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 1969, - "end": 1980, - "replacementText": "* as P" - } - ] - }, { "line": 94, "column": 1, "problem": "ImportAfterStatement", "autofixable": false }, - { - "line": 94, - "column": 10, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 2002, - "end": 2009, - "replacementText": "T1" - } - ] - }, - { - "line": 94, - "column": 19, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 2011, - "end": 2024, - "replacementText": "T2 as T3" - } - ] - }, - { - "line": 97, - "column": 1, - "problem": "TypeOnlyExport", - "autofixable": true, - "autofix": [ - { - "start": 2063, - "end": 2094, - "replacementText": "export { TypeA as TypeB };" - } - ] - }, - { - "line": 98, - "column": 10, - "problem": "TypeOnlyExport", - "autofixable": true, - "autofix": [ - { - "start": 2104, - "end": 2127, - "replacementText": "TypeFoo as TypeBar" - } - ] - }, { "line": 106, "column": 1, diff --git a/linter/test/modules.ts.strict.json b/linter/test/modules.ts.strict.json index c13f8f250..273338ee9 100644 --- a/linter/test/modules.ts.strict.json +++ b/linter/test/modules.ts.strict.json @@ -89,46 +89,16 @@ "column": 1, "problem": "ImportAfterStatement" }, - { - "line": 92, - "column": 8, - "problem": "TypeOnlyImport" - }, { "line": 93, "column": 1, "problem": "ImportAfterStatement" }, - { - "line": 93, - "column": 8, - "problem": "TypeOnlyImport" - }, { "line": 94, "column": 1, "problem": "ImportAfterStatement" }, - { - "line": 94, - "column": 10, - "problem": "TypeOnlyImport" - }, - { - "line": 94, - "column": 19, - "problem": "TypeOnlyImport" - }, - { - "line": 97, - "column": 1, - "problem": "TypeOnlyExport" - }, - { - "line": 98, - "column": 10, - "problem": "TypeOnlyExport" - }, { "line": 106, "column": 1, diff --git a/linter/test_rules/rule118.ts.autofix.json b/linter/test_rules/rule118.ts.autofix.json index 3ff68f6c7..13f13363f 100644 --- a/linter/test_rules/rule118.ts.autofix.json +++ b/linter/test_rules/rule118.ts.autofix.json @@ -1,19 +1,3 @@ { - "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TypeOnlyImport", - "autofixable": true, - "autofix": [ - { - "start": 120, - "end": 144, - "replacementText": "{ APIResponseType }" - } - ], - "suggest": "", - "rule": "Special import type declarations are not supported (arkts-no-special-imports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter/test_rules/rule118.ts.strict.json b/linter/test_rules/rule118.ts.strict.json index d30836a74..13f13363f 100644 --- a/linter/test_rules/rule118.ts.strict.json +++ b/linter/test_rules/rule118.ts.strict.json @@ -1,11 +1,3 @@ { - "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TypeOnlyImport", - "suggest": "", - "rule": "Special import type declarations are not supported (arkts-no-special-imports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter/test_rules/rule127.ts.autofix.json b/linter/test_rules/rule127.ts.autofix.json index c32c0f461..13f13363f 100644 --- a/linter/test_rules/rule127.ts.autofix.json +++ b/linter/test_rules/rule127.ts.autofix.json @@ -1,19 +1,3 @@ { - "nodes": [ - { - "line": 12, - "column": 5, - "problem": "TypeOnlyExport", - "autofixable": true, - "autofix": [ - { - "start": 218, - "end": 240, - "replacementText": "export { Class2 };" - } - ], - "suggest": "", - "rule": "Special \"export type\" declarations are not supported (arkts-no-special-exports)" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter/test_rules/rule127.ts.strict.json b/linter/test_rules/rule127.ts.strict.json index 35f1a5889..13f13363f 100644 --- a/linter/test_rules/rule127.ts.strict.json +++ b/linter/test_rules/rule127.ts.strict.json @@ -1,11 +1,3 @@ { - "nodes": [ - { - "line": 12, - "column": 5, - "problem": "TypeOnlyExport", - "suggest": "", - "rule": "Special \"export type\" declarations are not supported (arkts-no-special-exports)" - } - ] + "nodes": [] } \ No newline at end of file -- Gitee From 68e554311b9c17c04f0348a7f851f6938817658c Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Wed, 25 Oct 2023 16:58:41 +0300 Subject: [PATCH 10/23] [ArkTS Linter] Relax 'identifier-as-property-name' report for anonymous types from interop. Change-Id: I25b10f026bac0e585f2efbdbd890c952637463f3 Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 18 +++++++----------- linter-4.2/test/dynamic_lib.d.ts | 4 ++++ linter-4.2/test/dynamic_object_literals.ts | 14 ++++++++++++-- linter/src/TypeScriptLinter.ts | 10 ++++++---- linter/test/dynamic_lib.d.ts | 4 ++++ linter/test/dynamic_object_literals.ts | 14 ++++++++++++-- 6 files changed, 45 insertions(+), 19 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 0800b2c38..d9e35a7b5 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -707,20 +707,16 @@ export class TypeScriptLinter { ) { // We can use literals as property names only when creating Record or any interop instances. let isRecordObjectInitializer = false; - let isDynamicLiteralInitializer = false; + let isDynamic = false; if (ts.isPropertyAssignment(node)) { - let objectLiteralType = this.tsTypeChecker.getContextualType( - node.parent - ); - isRecordObjectInitializer = - !!objectLiteralType && - this.tsUtils.isStdRecordType(objectLiteralType); - isDynamicLiteralInitializer = this.tsUtils.isDynamicLiteralInitializer( - node.parent - ); + let objectLiteralType = this.tsTypeChecker.getContextualType(node.parent); + if (objectLiteralType) { + isRecordObjectInitializer = this.tsUtils.isStdRecordType(objectLiteralType); + isDynamic = this.tsUtils.isLibraryType(objectLiteralType) || this.tsUtils.isDynamicLiteralInitializer(node.parent); + } } - if (!isRecordObjectInitializer && !isDynamicLiteralInitializer) { + if (!isRecordObjectInitializer && !isDynamic) { let autofix: Autofix[] | undefined = Autofixer.fixLiteralAsPropertyName(node); let autofixable = autofix != undefined; diff --git a/linter-4.2/test/dynamic_lib.d.ts b/linter-4.2/test/dynamic_lib.d.ts index e3da589b5..843931397 100644 --- a/linter-4.2/test/dynamic_lib.d.ts +++ b/linter-4.2/test/dynamic_lib.d.ts @@ -93,3 +93,7 @@ declare class B { } export declare function bad_func(): A & B; + +export type IndexedSignatureType = { + [key: string]: string; +} \ No newline at end of file diff --git a/linter-4.2/test/dynamic_object_literals.ts b/linter-4.2/test/dynamic_object_literals.ts index ea7f9759a..fae9413ea 100644 --- a/linter-4.2/test/dynamic_object_literals.ts +++ b/linter-4.2/test/dynamic_object_literals.ts @@ -24,7 +24,8 @@ import { dynamic_array, padding, margin, - position + position, + IndexedSignatureType } from "./dynamic_lib" function main(): void { @@ -84,4 +85,13 @@ dynamic_array.splice(2, 0, {a: 1, b: '2'}); // #13550 - allow literals as property names in dynamic context padding({'top': '0px', 'right': '5px', 'bottom': '10px', 'left': '15px'}); margin({'top': '10px', 'right': '20px', 'bottom': '30px', 'left': '40px'}); -position({'x': '20', 'y': '40'}); \ No newline at end of file +position({'x': '20', 'y': '40'}); + +// allow literal as property name for type aliases that come from interop +function typeAliasLitAsPropName(): IndexedSignatureType { + return { + 'a': '1', + 'b': '2', + 'c': '3' + } +} \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 9fc9e315b..eb88c473b 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -614,14 +614,16 @@ export class TypeScriptLinter { if (propName && (propName.kind === ts.SyntaxKind.NumericLiteral || propName.kind === ts.SyntaxKind.StringLiteral)) { // We can use literals as property names only when creating Record or any interop instances. let isRecordObjectInitializer = false; - let isDynamicLiteralInitializer = false; + let isDynamic = false; if (ts.isPropertyAssignment(node)) { let objectLiteralType = this.tsTypeChecker.getContextualType(node.parent); - isRecordObjectInitializer = !!objectLiteralType && this.tsUtils.isStdRecordType(objectLiteralType); - isDynamicLiteralInitializer = this.tsUtils.isDynamicLiteralInitializer(node.parent); + if (objectLiteralType) { + isRecordObjectInitializer = this.tsUtils.isStdRecordType(objectLiteralType); + isDynamic = this.tsUtils.isLibraryType(objectLiteralType) || this.tsUtils.isDynamicLiteralInitializer(node.parent); + } } - if (!isRecordObjectInitializer && !isDynamicLiteralInitializer) { + if (!isRecordObjectInitializer && !isDynamic) { let autofix : Autofix[] | undefined = Autofixer.fixLiteralAsPropertyName(node); let autofixable = autofix != undefined; if (!this.autofixesInfo.shouldAutofix(node, FaultID.LiteralAsPropertyName)) { diff --git a/linter/test/dynamic_lib.d.ts b/linter/test/dynamic_lib.d.ts index e3da589b5..843931397 100644 --- a/linter/test/dynamic_lib.d.ts +++ b/linter/test/dynamic_lib.d.ts @@ -93,3 +93,7 @@ declare class B { } export declare function bad_func(): A & B; + +export type IndexedSignatureType = { + [key: string]: string; +} \ No newline at end of file diff --git a/linter/test/dynamic_object_literals.ts b/linter/test/dynamic_object_literals.ts index ea7f9759a..fae9413ea 100644 --- a/linter/test/dynamic_object_literals.ts +++ b/linter/test/dynamic_object_literals.ts @@ -24,7 +24,8 @@ import { dynamic_array, padding, margin, - position + position, + IndexedSignatureType } from "./dynamic_lib" function main(): void { @@ -84,4 +85,13 @@ dynamic_array.splice(2, 0, {a: 1, b: '2'}); // #13550 - allow literals as property names in dynamic context padding({'top': '0px', 'right': '5px', 'bottom': '10px', 'left': '15px'}); margin({'top': '10px', 'right': '20px', 'bottom': '30px', 'left': '40px'}); -position({'x': '20', 'y': '40'}); \ No newline at end of file +position({'x': '20', 'y': '40'}); + +// allow literal as property name for type aliases that come from interop +function typeAliasLitAsPropName(): IndexedSignatureType { + return { + 'a': '1', + 'b': '2', + 'c': '3' + } +} \ No newline at end of file -- Gitee From 6b8aff2770063cdd578bdb63ac41caa7741fde6d Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Thu, 26 Oct 2023 18:21:26 +0300 Subject: [PATCH 11/23] [arkts-linter] #14009 - remove stdlib functions restrictions Signed-off-by: Nazarov Konstantin --- linter-4.2/docs/rules/recipe144.md | 3 +- linter-4.2/src/TypeScriptLinter.ts | 7 ++- linter-4.2/src/Utils.ts | 3 +- .../test/limited_stdlib_api.ts.autofix.json | 48 ------------------- .../test/limited_stdlib_api.ts.relax.json | 42 ---------------- .../test/limited_stdlib_api.ts.strict.json | 42 ---------------- linter/docs/rules/recipe144.md | 3 +- linter/src/TypeScriptLinter.ts | 8 ++-- .../src/utils/consts/LimitedStdGlobalFunc.ts | 2 +- .../src/utils/consts/LimitedStdGlobalVar.ts | 16 ------- .../test/limited_stdlib_api.ts.autofix.json | 48 ------------------- linter/test/limited_stdlib_api.ts.relax.json | 42 ---------------- linter/test/limited_stdlib_api.ts.strict.json | 42 ---------------- 13 files changed, 10 insertions(+), 296 deletions(-) delete mode 100644 linter/src/utils/consts/LimitedStdGlobalVar.ts diff --git a/linter-4.2/docs/rules/recipe144.md b/linter-4.2/docs/rules/recipe144.md index 4d3585851..ec36a4ffb 100644 --- a/linter-4.2/docs/rules/recipe144.md +++ b/linter-4.2/docs/rules/recipe144.md @@ -9,8 +9,7 @@ The most part of the restricted APIs relates to manipulating objects in a dynamic manner, which is not compatible with static typing. The usage of the following APIs is prohibited: -Properties and functions of the global object: ``eval``, -``Infinity``, ``NaN``, ``isFinite``, ``isNaN``, ``parseFloat``, ``parseInt`` +Properties and functions of the global object: ``eval`` ``Object``: ``__proto__``, ``__defineGetter__``, ``__defineSetter__``, ``__lookupGetter__``, ``__lookupSetter__``, ``assign``, ``create``, diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index d9e35a7b5..7bc4b23e6 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1490,12 +1490,11 @@ export class TypeScriptLinter { (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && tsIdentifier.text === "globalThis" - ) + ) { this.incrementCounters(node, FaultID.GlobalThis); - else if (this.tsUtils.isGlobalSymbol(tsIdentSym) && TsUtils.LIMITED_STD_GLOBAL_VAR.includes(tsIdentSym.getName())) - this.incrementCounters(node, FaultID.LimitedStdLibApi); - else + } else { this.handleRestrictedValues(tsIdentifier, tsIdentSym); + } } } diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 2cb4369ea..ed6992f74 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -106,9 +106,8 @@ export class TsUtils { static readonly ES_OBJECT = 'ESObject' static readonly LIMITED_STD_GLOBAL_FUNC = [ - 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt' + 'eval' ]; - static readonly LIMITED_STD_GLOBAL_VAR = ['Infinity', 'NaN']; static readonly LIMITED_STD_OBJECT_API = [ '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'assign', 'create', 'defineProperties', 'defineProperty', 'freeze', 'fromEntries', 'getOwnPropertyDescriptor', diff --git a/linter-4.2/test/limited_stdlib_api.ts.autofix.json b/linter-4.2/test/limited_stdlib_api.ts.autofix.json index d22507c45..eb0a98815 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.autofix.json +++ b/linter-4.2/test/limited_stdlib_api.ts.autofix.json @@ -22,54 +22,6 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, - { - "line": 18, - "column": 11, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 19, - "column": 11, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 20, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 21, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 22, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 23, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, { "line": 31, "column": 1, diff --git a/linter-4.2/test/limited_stdlib_api.ts.relax.json b/linter-4.2/test/limited_stdlib_api.ts.relax.json index 42695e72f..2e0b7e736 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.relax.json +++ b/linter-4.2/test/limited_stdlib_api.ts.relax.json @@ -21,48 +21,6 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, - { - "line": 18, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 19, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 20, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 21, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 22, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 23, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, { "line": 31, "column": 1, diff --git a/linter-4.2/test/limited_stdlib_api.ts.strict.json b/linter-4.2/test/limited_stdlib_api.ts.strict.json index 42695e72f..2e0b7e736 100644 --- a/linter-4.2/test/limited_stdlib_api.ts.strict.json +++ b/linter-4.2/test/limited_stdlib_api.ts.strict.json @@ -21,48 +21,6 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, - { - "line": 18, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 19, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 20, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 21, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 22, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 23, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, { "line": 31, "column": 1, diff --git a/linter/docs/rules/recipe144.md b/linter/docs/rules/recipe144.md index 95dafd1dd..371513d07 100644 --- a/linter/docs/rules/recipe144.md +++ b/linter/docs/rules/recipe144.md @@ -9,8 +9,7 @@ The most part of the restricted APIs relates to manipulating objects in a dynamic manner, which is not compatible with static typing. The usage of the following APIs is prohibited: -Properties and functions of the global object: ``eval``, -``Infinity``, ``NaN``, ``isFinite``, ``isNaN``, ``parseFloat``, ``parseInt`` +Properties and functions of the global object: ``eval`` ``Object``: ``__proto__``, ``__defineGetter__``, ``__defineSetter__``, ``__lookupGetter__``, ``__lookupSetter__``, ``assign``, ``create``, diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index eb88c473b..c93553509 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -28,7 +28,6 @@ import { ProblemSeverity } from './ProblemSeverity'; import Logger from '../utils/logger'; import { ARKUI_DECORATORS } from './utils/consts/ArkUIDecorators'; import { LIMITED_STD_GLOBAL_FUNC } from './utils/consts/LimitedStdGlobalFunc'; -import { LIMITED_STD_GLOBAL_VAR } from './utils/consts/LimitedStdGlobalVar'; import { LIMITED_STD_OBJECT_API } from './utils/consts/LimitedStdObjectAPI'; import { LIMITED_STD_REFLECT_API } from './utils/consts/LimitedStdReflectAPI'; import { LIMITED_STD_PROXYHANDLER_API } from './utils/consts/LimitedStdProxyHandlerAPI'; @@ -1245,12 +1244,11 @@ export class TypeScriptLinter { (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && tsIdentifier.text === 'globalThis' - ) + ) { this.incrementCounters(node, FaultID.GlobalThis); - else if (this.tsUtils.isGlobalSymbol(tsIdentSym) && LIMITED_STD_GLOBAL_VAR.includes(tsIdentSym.getName())) - this.incrementCounters(node, FaultID.LimitedStdLibApi); - else + } else { this.handleRestrictedValues(tsIdentifier, tsIdentSym); + } } } diff --git a/linter/src/utils/consts/LimitedStdGlobalFunc.ts b/linter/src/utils/consts/LimitedStdGlobalFunc.ts index eec858299..841b81dda 100644 --- a/linter/src/utils/consts/LimitedStdGlobalFunc.ts +++ b/linter/src/utils/consts/LimitedStdGlobalFunc.ts @@ -14,5 +14,5 @@ */ export const LIMITED_STD_GLOBAL_FUNC = [ - 'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt' + 'eval' ]; diff --git a/linter/src/utils/consts/LimitedStdGlobalVar.ts b/linter/src/utils/consts/LimitedStdGlobalVar.ts deleted file mode 100644 index fd0b48816..000000000 --- a/linter/src/utils/consts/LimitedStdGlobalVar.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2023-2023 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. - */ - -export const LIMITED_STD_GLOBAL_VAR = ['Infinity', 'NaN']; diff --git a/linter/test/limited_stdlib_api.ts.autofix.json b/linter/test/limited_stdlib_api.ts.autofix.json index be0f7b9fb..5fa775012 100644 --- a/linter/test/limited_stdlib_api.ts.autofix.json +++ b/linter/test/limited_stdlib_api.ts.autofix.json @@ -22,54 +22,6 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, - { - "line": 18, - "column": 11, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 19, - "column": 11, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 20, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 21, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 22, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 23, - "column": 1, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, { "line": 31, "column": 1, diff --git a/linter/test/limited_stdlib_api.ts.relax.json b/linter/test/limited_stdlib_api.ts.relax.json index 12f323b61..22ad3a0ad 100644 --- a/linter/test/limited_stdlib_api.ts.relax.json +++ b/linter/test/limited_stdlib_api.ts.relax.json @@ -21,48 +21,6 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, - { - "line": 18, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 19, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 20, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 21, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 22, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 23, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, { "line": 31, "column": 1, diff --git a/linter/test/limited_stdlib_api.ts.strict.json b/linter/test/limited_stdlib_api.ts.strict.json index 12f323b61..22ad3a0ad 100644 --- a/linter/test/limited_stdlib_api.ts.strict.json +++ b/linter/test/limited_stdlib_api.ts.strict.json @@ -21,48 +21,6 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, - { - "line": 18, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 19, - "column": 11, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 20, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 21, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 22, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 23, - "column": 1, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, { "line": 31, "column": 1, -- Gitee From 34ff05475e6b5a30dc91f317d9075555960d8ee2 Mon Sep 17 00:00:00 2001 From: Denis Slynko Date: Thu, 26 Oct 2023 18:25:32 +0300 Subject: [PATCH 12/23] [ArkTS Linter] Fix codestyle Signed-off-by: Denis Slynko --- linter-4.2/src/TypeScriptLinter.ts | 16 ++++++++-------- .../TypeScriptDiagnosticsExtractor.ts | 2 +- linter/src/TypeScriptLinter.ts | 16 ++++++++-------- linter/src/ts-diagnostics/TSCCompiledProgram.ts | 2 +- .../TypeScriptDiagnosticsExtractor.ts | 2 +- linter/src/utils/functions/ContainsThis.ts | 3 +-- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index d9e35a7b5..0ce94a063 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1901,14 +1901,14 @@ export class TypeScriptLinter { } this.filterStrictDiagnostics({ - [ARGUMENT_OF_TYPE_0_IS_NOT_ASSIGNABLE_TO_PARAMETER_OF_TYPE_1_ERROR_CODE]: (pos: number) => { - return this.checkInRange(rangesToFilter, pos); - }, - [TYPE_0_IS_NOT_ASSIGNABLE_TO_TYPE_1_ERROR_CODE]: (pos: number) => { - return this.checkInRange(rangesToFilter, pos); - } + [ARGUMENT_OF_TYPE_0_IS_NOT_ASSIGNABLE_TO_PARAMETER_OF_TYPE_1_ERROR_CODE]: (pos: number) => { + return this.checkInRange(rangesToFilter, pos); }, - this.libraryTypeCallDiagnosticChecker + [TYPE_0_IS_NOT_ASSIGNABLE_TO_TYPE_1_ERROR_CODE]: (pos: number) => { + return this.checkInRange(rangesToFilter, pos); + } + }, + this.libraryTypeCallDiagnosticChecker ); for (const msgChain of diagnosticMessages) { @@ -2096,7 +2096,7 @@ export class TypeScriptLinter { comment.kind === ts.SyntaxKind.MultiLineCommentTrivia ? srcText.slice(comment.pos + 2, comment.end - 2) : srcText.slice(comment.pos + 2, comment.end); - //if comment is multiline end closing '*/' is not at the same line as '@ts-xxx' - do nothing (see #13851) + // if comment is multiline end closing '*/' is not at the same line as '@ts-xxx' - do nothing (see #13851) if (commentContent.endsWith('\n')) return; let trimmedContent = commentContent.trim(); diff --git a/linter-4.2/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts b/linter-4.2/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts index 0d5106dd9..89380f130 100644 --- a/linter-4.2/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts +++ b/linter-4.2/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts @@ -25,7 +25,7 @@ export class TypeScriptDiagnosticsExtractor { public getStrictDiagnostics(fileName: string): ts.Diagnostic[] { // applying filter is a workaround for tsc bug const strict = getAllDiagnostics(this.strictProgram, fileName) - .filter(diag => !(diag.length === 0 && diag.start === 0)); + .filter(diag => !(diag.length === 0 && diag.start === 0)); const nonStrict = getAllDiagnostics(this.nonStrictProgram, fileName); // collect hashes for later easier comparison diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index eb88c473b..bfadb7fc9 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1565,14 +1565,14 @@ export class TypeScriptLinter { } this.filterStrictDiagnostics({ - [ARGUMENT_OF_TYPE_0_IS_NOT_ASSIGNABLE_TO_PARAMETER_OF_TYPE_1_ERROR_CODE]: (pos: number) => { - return this.checkInRange(rangesToFilter, pos); - }, - [TYPE_0_IS_NOT_ASSIGNABLE_TO_TYPE_1_ERROR_CODE]: (pos: number) => { - return this.checkInRange(rangesToFilter, pos); - } + [ARGUMENT_OF_TYPE_0_IS_NOT_ASSIGNABLE_TO_PARAMETER_OF_TYPE_1_ERROR_CODE]: (pos: number) => { + return this.checkInRange(rangesToFilter, pos); }, - this.libraryTypeCallDiagnosticChecker + [TYPE_0_IS_NOT_ASSIGNABLE_TO_TYPE_1_ERROR_CODE]: (pos: number) => { + return this.checkInRange(rangesToFilter, pos); + } + }, + this.libraryTypeCallDiagnosticChecker ); for (const msgChain of diagnosticMessages) { @@ -1738,7 +1738,7 @@ export class TypeScriptLinter { const commentContent = comment.kind === ts.SyntaxKind.MultiLineCommentTrivia ? srcText.slice(comment.pos + 2, comment.end - 2) : srcText.slice(comment.pos + 2, comment.end); - //if comment is multiline end closing '*/' is not at the same line as '@ts-xxx' - do nothing (see #13851) + // if comment is multiline end closing '*/' is not at the same line as '@ts-xxx' - do nothing (see #13851) if (commentContent.endsWith('\n')) return; const trimmedContent = commentContent.trim(); diff --git a/linter/src/ts-diagnostics/TSCCompiledProgram.ts b/linter/src/ts-diagnostics/TSCCompiledProgram.ts index d1ece2fc6..cee480fd8 100644 --- a/linter/src/ts-diagnostics/TSCCompiledProgram.ts +++ b/linter/src/ts-diagnostics/TSCCompiledProgram.ts @@ -61,7 +61,7 @@ export class TSCCompiledProgramWithDiagnostics implements TSCCompiledProgram { public getStrictDiagnostics(fileName: string): ts.Diagnostic[] { const cachedDiagnostic = this.cachedDiagnostics.get(fileName); - if (!!cachedDiagnostic) { + if (cachedDiagnostic) { return cachedDiagnostic } const diagnostic = this.diagnosticsExtractor.getStrictDiagnostics(fileName); diff --git a/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts b/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts index 0d5106dd9..89380f130 100644 --- a/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts +++ b/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts @@ -25,7 +25,7 @@ export class TypeScriptDiagnosticsExtractor { public getStrictDiagnostics(fileName: string): ts.Diagnostic[] { // applying filter is a workaround for tsc bug const strict = getAllDiagnostics(this.strictProgram, fileName) - .filter(diag => !(diag.length === 0 && diag.start === 0)); + .filter(diag => !(diag.length === 0 && diag.start === 0)); const nonStrict = getAllDiagnostics(this.nonStrictProgram, fileName); // collect hashes for later easier comparison diff --git a/linter/src/utils/functions/ContainsThis.ts b/linter/src/utils/functions/ContainsThis.ts index 958553f28..a0cccbb1c 100644 --- a/linter/src/utils/functions/ContainsThis.ts +++ b/linter/src/utils/functions/ContainsThis.ts @@ -39,5 +39,4 @@ export function scopeContainsThis(tsNode: ts.Node): boolean { } visitNode(tsNode); return found; -} - \ No newline at end of file +} \ No newline at end of file -- Gitee From 48a4c5f5a5ef53e9004279efc61553284c36e4a9 Mon Sep 17 00:00:00 2001 From: Ilya Trubachev Date: Thu, 26 Oct 2023 18:44:39 +0300 Subject: [PATCH 13/23] Fix strict error filtering Signed-off-by: Ilya Trubachev --- linter-4.2/src/TypeScriptLinter.ts | 6 ++--- linter-4.2/test/functions.ts | 21 ++++++++++++++- linter-4.2/test/functions.ts.autofix.json | 32 +++++++++++++++++++++++ linter-4.2/test/functions.ts.relax.json | 28 ++++++++++++++++++++ linter-4.2/test/functions.ts.strict.json | 28 ++++++++++++++++++++ linter/src/TypeScriptLinter.ts | 6 ++--- linter/test/functions.ts | 21 ++++++++++++++- linter/test/functions.ts.autofix.json | 32 +++++++++++++++++++++++ linter/test/functions.ts.relax.json | 28 ++++++++++++++++++++ linter/test/functions.ts.strict.json | 28 ++++++++++++++++++++ 10 files changed, 222 insertions(+), 8 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 27442da9f..dc4c76a9d 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1861,13 +1861,13 @@ export class TypeScriptLinter { let rangesToFilter: { begin: number, end: number }[] = []; if (nonFilteringRanges.length !== 0) { let rangesSize = nonFilteringRanges.length; - rangesToFilter.push({ begin: callExpr.pos, end: nonFilteringRanges[0].begin }) - rangesToFilter.push({ begin: nonFilteringRanges[rangesSize - 1].end, end: callExpr.end }) + rangesToFilter.push({ begin: callExpr.arguments.pos, end: nonFilteringRanges[0].begin }) + rangesToFilter.push({ begin: nonFilteringRanges[rangesSize - 1].end, end: callExpr.arguments.end }) for (let i = 0; i < rangesSize - 1; i++) { rangesToFilter.push({ begin: nonFilteringRanges[i].end, end: nonFilteringRanges[i + 1].begin }) } } else { - rangesToFilter.push({ begin: callExpr.pos, end: callExpr.end }) + rangesToFilter.push({ begin: callExpr.arguments.pos, end: callExpr.arguments.end }) } this.filterStrictDiagnostics({ diff --git a/linter-4.2/test/functions.ts b/linter-4.2/test/functions.ts index 8d67f99ff..fd8646324 100644 --- a/linter-4.2/test/functions.ts +++ b/linter-4.2/test/functions.ts @@ -105,4 +105,23 @@ bar(() => { bar(() => { f(null); }, null, f(null)); -}, null, foo(f(null))); \ No newline at end of file +}, null, foo(f(null))); + +type PropDecorator = () => void; +let Builder: PropDecorator; + +// this test is useless until we use custom tsc +@Builder +function buildSwiper() { + f(null) + foo(null) { + f(null) + foo(null) { + f(null) + foo(() => { + f(null) + }) + } + .foo(null) + } +} diff --git a/linter-4.2/test/functions.ts.autofix.json b/linter-4.2/test/functions.ts.autofix.json index bdec3c538..944c5bf6b 100644 --- a/linter-4.2/test/functions.ts.autofix.json +++ b/linter-4.2/test/functions.ts.autofix.json @@ -157,6 +157,38 @@ "autofixable": false, "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 116, + "column": 5, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 118, + "column": 7, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 120, + "column": 11, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 122, + "column": 11, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." } ] } \ No newline at end of file diff --git a/linter-4.2/test/functions.ts.relax.json b/linter-4.2/test/functions.ts.relax.json index e11f7f9c4..1e86ab2f1 100644 --- a/linter-4.2/test/functions.ts.relax.json +++ b/linter-4.2/test/functions.ts.relax.json @@ -125,6 +125,34 @@ "problem": "StrictDiagnostic", "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 116, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 118, + "column": 7, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 120, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 122, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." } ] } \ No newline at end of file diff --git a/linter-4.2/test/functions.ts.strict.json b/linter-4.2/test/functions.ts.strict.json index d39199ff0..a1c2214e5 100644 --- a/linter-4.2/test/functions.ts.strict.json +++ b/linter-4.2/test/functions.ts.strict.json @@ -139,6 +139,34 @@ "problem": "StrictDiagnostic", "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 116, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 118, + "column": 7, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 120, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 122, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." } ] } \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 15d018ed5..caae84222 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1536,13 +1536,13 @@ export class TypeScriptLinter { let rangesToFilter: { begin: number, end: number }[] = []; if (nonFilteringRanges.length !== 0) { let rangesSize = nonFilteringRanges.length; - rangesToFilter.push({ begin: callExpr.pos, end: nonFilteringRanges[0].begin }) - rangesToFilter.push({ begin: nonFilteringRanges[rangesSize - 1].end, end: callExpr.end }) + rangesToFilter.push({ begin: callExpr.arguments.pos, end: nonFilteringRanges[0].begin }) + rangesToFilter.push({ begin: nonFilteringRanges[rangesSize - 1].end, end: callExpr.arguments.end }) for (let i = 0; i < rangesSize - 1; i++) { rangesToFilter.push({ begin: nonFilteringRanges[i].end, end: nonFilteringRanges[i + 1].begin }) } } else { - rangesToFilter.push({ begin: callExpr.pos, end: callExpr.end }) + rangesToFilter.push({ begin: callExpr.arguments.pos, end: callExpr.arguments.end }) } this.filterStrictDiagnostics({ diff --git a/linter/test/functions.ts b/linter/test/functions.ts index 8d67f99ff..fd8646324 100644 --- a/linter/test/functions.ts +++ b/linter/test/functions.ts @@ -105,4 +105,23 @@ bar(() => { bar(() => { f(null); }, null, f(null)); -}, null, foo(f(null))); \ No newline at end of file +}, null, foo(f(null))); + +type PropDecorator = () => void; +let Builder: PropDecorator; + +// this test is useless until we use custom tsc +@Builder +function buildSwiper() { + f(null) + foo(null) { + f(null) + foo(null) { + f(null) + foo(() => { + f(null) + }) + } + .foo(null) + } +} diff --git a/linter/test/functions.ts.autofix.json b/linter/test/functions.ts.autofix.json index bdec3c538..944c5bf6b 100755 --- a/linter/test/functions.ts.autofix.json +++ b/linter/test/functions.ts.autofix.json @@ -157,6 +157,38 @@ "autofixable": false, "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 116, + "column": 5, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 118, + "column": 7, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 120, + "column": 11, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 122, + "column": 11, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." } ] } \ No newline at end of file diff --git a/linter/test/functions.ts.relax.json b/linter/test/functions.ts.relax.json index e11f7f9c4..1e86ab2f1 100644 --- a/linter/test/functions.ts.relax.json +++ b/linter/test/functions.ts.relax.json @@ -125,6 +125,34 @@ "problem": "StrictDiagnostic", "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 116, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 118, + "column": 7, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 120, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 122, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." } ] } \ No newline at end of file diff --git a/linter/test/functions.ts.strict.json b/linter/test/functions.ts.strict.json index d39199ff0..a1c2214e5 100644 --- a/linter/test/functions.ts.strict.json +++ b/linter/test/functions.ts.strict.json @@ -139,6 +139,34 @@ "problem": "StrictDiagnostic", "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 116, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 118, + "column": 7, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 120, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." + }, + { + "line": 122, + "column": 11, + "problem": "StrictDiagnostic", + "suggest": "Argument of type 'null' is not assignable to parameter of type 'string'.", + "rule": "Argument of type 'null' is not assignable to parameter of type 'string'." } ] } \ No newline at end of file -- Gitee From bbd8f8f17d2c97ded1ccfd00fbb4bd0f077b18a8 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Thu, 26 Oct 2023 19:24:24 +0300 Subject: [PATCH 14/23] [arkts-linter] fix 14033 14030 - double ESObject reporting Signed-off-by: Nazarov Konstantin --- linter-4.2/docs/rules/recipe151.md | 54 +++++ linter-4.2/src/CookBookMsg.ts | 1 + linter-4.2/src/Problems.ts | 6 +- linter-4.2/src/TypeScriptLinter.ts | 121 +++++----- linter-4.2/src/TypeScriptLinterConfig.ts | 4 +- linter-4.2/src/Utils.ts | 27 ++- linter-4.2/test/es_object.ts | 19 +- linter-4.2/test/es_object.ts.relax.json | 269 ++++++++++++++-------- linter-4.2/test/es_object.ts.strict.json | 271 +++++++++++++++-------- linter-4.2/test/oh_modules/ohos_lib.ts | 3 + linter/docs/rules/recipe151.md | 54 +++++ linter/src/CookBookMsg.ts | 1 + linter/src/FaultAttrs.ts | 4 +- linter/src/FaultDesc.ts | 4 +- linter/src/Problems.ts | 2 +- linter/src/TypeScriptLinter.ts | 114 +++++----- linter/src/utils/TsUtils.ts | 29 ++- linter/test/es_object.ts | 19 +- linter/test/es_object.ts.relax.json | 269 ++++++++++++++-------- linter/test/es_object.ts.strict.json | 271 +++++++++++++++-------- linter/test/oh_modules/ohos_lib.ts | 3 + 21 files changed, 1013 insertions(+), 532 deletions(-) create mode 100644 linter-4.2/docs/rules/recipe151.md create mode 100644 linter/docs/rules/recipe151.md diff --git a/linter-4.2/docs/rules/recipe151.md b/linter-4.2/docs/rules/recipe151.md new file mode 100644 index 000000000..bcc54e997 --- /dev/null +++ b/linter-4.2/docs/rules/recipe151.md @@ -0,0 +1,54 @@ + +# Usage of ``ESObject`` type is restricted + +Rule ``arkts-limited-esobject`` + +**Severity: warning** + +ArkTS does not allow using ``ESObject`` type in some cases. The most part of limitations +are put in place in order to prevent spread of dynamic objects in the static codebase. +The only scenario where it is permited to use ``ESObject`` as type specifier is in local +variable declaration. Initialization of variables with ``ESObject`` type is also limited. +Such variables can only be initialized with values that originate from interop: +other ``ESObject`` typed variables, any, unknown, variables with anonymous type, etc. +It is prohibited to initialize ``ESObject`` typed variable with statically typed value. +Varaible of type ``ESObject`` can only be passed to interop calls and assigned to other +variables of type ``ESObject``. + + +## ArkTS + + +``` + // lib.d.ts + declare function foo(): any; + declare function bar(a: any): number; + + // main.ets + let e0: ESObject = foo(); // CTE - ``ESObject`` typed variable can only be local + + function f() { + let e1 = foo(); // CTE - type of e1 is `any` + let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values + let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values + let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values + let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject + let e7 = e6; // OK - initialize ESObject with ESObject + e6['prop'] // CTE - can't access dynamic properties of ESObject + e6[1] // CTE - can't access dynamic properties of ESObject + e6.prop // CTE - can't access dynamic properties of ESObject + bar(e6) // OK - ESObject is passed to interop call + } +``` + + +## See also + +- Recipe 001: Objects with property names that are not identifiers are not supported (``arkts-identifiers-as-prop-names``) +- Recipe 002: ``Symbol()`` API is not supported (``arkts-no-symbol``) +- Recipe 029: Indexed access is not supported for fields (``arkts-no-props-by-index``) +- Recipe 060: ``typeof`` operator is allowed only in expression contexts (``arkts-no-type-query``) +- Recipe 066: ``in`` operator is not supported (``arkts-no-in``) +- Recipe 137: ``globalThis`` is not supported (``arkts-no-globalthis``) + diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index 28b8b77f9..0f7b312b1 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -170,3 +170,4 @@ cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (ar cookBookTag[148] = 'No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; +cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobject)'; diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index df9623d67..61d08d5cb 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -34,7 +34,7 @@ export enum FaultID { NewTarget, DefiniteAssignment, Prototype, GlobalThis, UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ConstAssertion, ImportAssertion, SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, UnsupportedDecorators, ImportAfterStatement, - EsObjectType, EsObjectAssignment, EsObjectAccess, + EsObjectType, LAST_ID, // this should always be last enum` } @@ -129,6 +129,4 @@ faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; faultsAttrs[FaultID.UnsupportedDecorators] = {warning: true, cookBookRef: '148',}; faultsAttrs[FaultID.ClassAsObject] = {cookBookRef: '149',}; faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '150',}; -faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '8'}; -faultsAttrs[FaultID.EsObjectAssignment] = {warning: true, cookBookRef: '8'}; -faultsAttrs[FaultID.EsObjectAccess] = {warning: true, cookBookRef: '8'}; +faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '151'}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 39e52a88b..e3bfd0807 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -691,8 +691,8 @@ export class TypeScriptLinter { if (!!exprSym && this.tsUtils.isSymbolAPI(exprSym) && !TsUtils.ALLOWED_STD_SYMBOL_API.includes(exprSym.getName())) { this.incrementCounters(propertyAccessNode, FaultID.SymbolType); } - if (baseExprSym !== undefined && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { - this.incrementCounters(propertyAccessNode, FaultID.EsObjectAccess); + if (!!baseExprSym && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { + this.incrementCounters(propertyAccessNode, FaultID.EsObjectType); } } @@ -1199,9 +1199,7 @@ export class TypeScriptLinter { } const typeNode = this.tsUtils.getVariableDeclarationTypeNode(tsLhsExpr); - if (!!typeNode) { - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - } + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } } @@ -1244,39 +1242,42 @@ export class TypeScriptLinter { if (this.tsUtils.needToDeduceStructuralIdentity(tsVarType, tsInitType, tsVarInit)) { this.incrementCounters(tsVarDecl, FaultID.StructuralIdentity); } - - this.handleEsObjectAssignment(tsVarDecl, tsVarDecl.type, tsVarInit); } + this.handleEsObjectDelaration(tsVarDecl); this.handleDeclarationInferredType(tsVarDecl); this.handleDefiniteAssignmentAssertion(tsVarDecl); } - private handleEsObjectAssignment(node: ts.Node, type: ts.TypeNode, value: ts.Node) { - if (!this.tsUtils.isEsObjectType(type)) { - let valueTypeNode = this.tsUtils.getVariableDeclarationTypeNode(value); - if (!!valueTypeNode && this.tsUtils.isEsObjectType(valueTypeNode)) { - this.incrementCounters(node, FaultID.EsObjectAssignment); - } - - return - } - - if (ts.isArrayLiteralExpression(value) || ts.isObjectLiteralExpression(value)) { - this.incrementCounters(node, FaultID.EsObjectAssignment); + private handleEsObjectDelaration(node: ts.VariableDeclaration) { + const isDeclaredESObject = !!node.type && this.tsUtils.isEsObjectType(node.type); + const initalizerTypeNode = node.initializer && this.tsUtils.getVariableDeclarationTypeNode(node.initializer); + const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); + const isLocal = this.tsUtils.isInsideBlock(node) + if ((isDeclaredESObject || isInitializedWithESObject) && !isLocal) { + this.incrementCounters(node, FaultID.EsObjectType); return; } - const valueType = this.tsTypeChecker.getTypeAtLocation(value); - if (this.tsUtils.isUnsupportedType(valueType)) { + if (node.initializer) { + this.handleEsObjectAssignment(node, node.type, node.initializer); return; } + } - if (this.tsUtils.isAnonymousType(valueType)) { + private handleEsObjectAssignment(node: ts.Node, nodeDeclType: ts.TypeNode | undefined, initializer: ts.Node) { + const isTypeAnnotated = !!nodeDeclType; + const isDeclaredESObject = !!nodeDeclType && this.tsUtils.isEsObjectType(nodeDeclType); + const initalizerTypeNode = this.tsUtils.getVariableDeclarationTypeNode(initializer); + const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); + if (isTypeAnnotated && !isDeclaredESObject && isInitializedWithESObject) { + this.incrementCounters(node, FaultID.EsObjectType); return; } - this.incrementCounters(node, FaultID.EsObjectAssignment); + if (isDeclaredESObject && !this.tsUtils.isValueAssignableToESObject(initializer)) { + this.incrementCounters(node, FaultID.EsObjectType); + } } private handleCatchClause(node: ts.Node) { @@ -1482,19 +1483,21 @@ export class TypeScriptLinter { } private handleIdentifier(node: ts.Node) { - let tsIdentifier = node as ts.Identifier; - let tsIdentSym = this.tsUtils.trueSymbolAtLocation(tsIdentifier); + const tsIdentifier = node as ts.Identifier; + const tsIdentSym = this.tsUtils.trueSymbolAtLocation(tsIdentifier); - if (tsIdentSym !== undefined) { - if ( - (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && - (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && - tsIdentifier.text === "globalThis" - ) { - this.incrementCounters(node, FaultID.GlobalThis); - } else { - this.handleRestrictedValues(tsIdentifier, tsIdentSym); - } + if (!tsIdentSym) { + return; + } + + if ( + (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && + (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && + tsIdentifier.text === "globalThis" + ) { + this.incrementCounters(node, FaultID.GlobalThis); + } else { + this.handleRestrictedValues(tsIdentifier, tsIdentSym); } } @@ -1633,7 +1636,7 @@ export class TypeScriptLinter { } if (this.tsUtils.hasEsObjectType(tsElementAccessExpr.expression)) { - this.incrementCounters(node, FaultID.EsObjectAccess); + this.incrementCounters(node, FaultID.EsObjectType); } } @@ -1696,7 +1699,7 @@ export class TypeScriptLinter { this.handleStdlibAPICall(tsCallExpr, calleeSym); this.handleFunctionApplyBindPropCall(tsCallExpr, calleeSym); if (this.tsUtils.symbolHasEsObjectType(calleeSym)) { - this.incrementCounters(tsCallExpr, FaultID.EsObjectAccess); + this.incrementCounters(tsCallExpr, FaultID.EsObjectType); } } if (callSignature !== undefined) { @@ -1708,7 +1711,7 @@ export class TypeScriptLinter { this.handleLibraryTypeCall(tsCallExpr, calleeType); if (ts.isPropertyAccessExpression(tsCallExpr.expression) && this.tsUtils.hasEsObjectType(tsCallExpr.expression.expression)) { - this.incrementCounters(node, FaultID.EsObjectAccess); + this.incrementCounters(node, FaultID.EsObjectType); } } @@ -1945,35 +1948,37 @@ export class TypeScriptLinter { } private handleTypeReference(node: ts.Node) { - let typeRef = node as ts.TypeReferenceNode; + const typeRef = node as ts.TypeReferenceNode; - if ( - ts.isIdentifier(typeRef.typeName) && - TsUtils.LIMITED_STANDARD_UTILITY_TYPES.includes(typeRef.typeName.text) - ) - this.incrementCounters(node, FaultID.UtilityType); - else if (this.tsUtils.isEsObjectType(typeRef) && !this.tsUtils.isEsObjectAllowed(typeRef)) { + const isESObject = this.tsUtils.isEsObjectType(typeRef); + const isPossiblyValidContext = this.tsUtils.isEsObjectPossiblyAllowed(typeRef); + if (isESObject && !isPossiblyValidContext) { this.incrementCounters(node, FaultID.EsObjectType); + return; } - else if ( - ts.isIdentifier(typeRef.typeName) && - typeRef.typeName.text === "Partial" && - typeRef.typeArguments && - typeRef.typeArguments.length === 1 - ) { - // Using Partial type is allowed only when its argument type is either Class or Interface. - let argType = this.tsTypeChecker.getTypeFromTypeNode( - typeRef.typeArguments[0] - ); - if (!argType || !argType.isClassOrInterface()) - this.incrementCounters(node, FaultID.UtilityType); + const typeName = this.tsUtils.entityNameToString(typeRef.typeName); + const isStdUtilityType = TsUtils.LIMITED_STANDARD_UTILITY_TYPES.includes(typeName); + if (isStdUtilityType) { + this.incrementCounters(node, FaultID.UtilityType); + return; + } + + // Using Partial type is allowed only when its argument type is either Class or Interface. + const isStdPartial = this.tsUtils.entityNameToString(typeRef.typeName) === 'Partial'; + const hasSingleTypeArgument = !!typeRef.typeArguments && typeRef.typeArguments.length === 1; + const firstTypeArg = !!typeRef.typeArguments && hasSingleTypeArgument && typeRef.typeArguments[0]; + const argType = firstTypeArg && this.tsTypeChecker.getTypeFromTypeNode(firstTypeArg); + if (isStdPartial && argType && !argType.isClassOrInterface()) { + this.incrementCounters(node, FaultID.UtilityType); + return; } } private handleMetaProperty(node: ts.Node) { let tsMetaProperty = node as ts.MetaProperty; - if (tsMetaProperty.name.text === "target") + if (tsMetaProperty.name.text === "target") { this.incrementCounters(node, FaultID.NewTarget); + } } private handleStructDeclaration(node: ts.Node) { diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 179738f65..f549a8718 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -116,9 +116,7 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.StrictDiagnostic] = 'Strict diagnostic'; LinterConfig.nodeDesc[FaultID.UnsupportedDecorators] = 'Unsupported decorators'; LinterConfig.nodeDesc[FaultID.ImportAfterStatement] = 'Import declaration after other declaration or statement'; - LinterConfig.nodeDesc[FaultID.EsObjectType] = '"ESObject" type'; - LinterConfig.nodeDesc[FaultID.EsObjectAssignment] = '"ESObject" type assignment'; - LinterConfig.nodeDesc[FaultID.EsObjectAccess] = '"ESObject" access'; + LinterConfig.nodeDesc[FaultID.EsObjectType] = 'Restricted "ESObject" type'; LinterConfig.initTsSyntaxKindNames(); } diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index ed6992f74..5f519cba0 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -1358,22 +1358,29 @@ export class TsUtils { typeNode.typeName.text == TsUtils.ES_OBJECT; } - public isEsObjectAllowed(typeRef: ts.TypeReferenceNode): boolean { - let node = typeRef.parent; - - if (!this.isVarDeclaration(node)) { - return false; - } - - while (node) { - if (ts.isBlock(node)) { + public isInsideBlock(node: ts.Node): boolean { + let par = node.parent + while (par) { + if (ts.isBlock(par)) { return true; } - node = node.parent; + par = par.parent; } return false; } + public isEsObjectPossiblyAllowed(typeRef: ts.TypeReferenceNode): boolean { + return ts.isVariableDeclaration(typeRef.parent); + } + + public isValueAssignableToESObject(node: ts.Node): boolean { + if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) { + return false; + } + const valueType = this.tsTypeChecker.getTypeAtLocation(node); + return this.isUnsupportedType(valueType) || this.isAnonymousType(valueType) + } + public getVariableDeclarationTypeNode(node: ts.Node): ts.TypeNode | undefined { let sym = this.trueSymbolAtLocation(node); if (sym === undefined) { diff --git a/linter-4.2/test/es_object.ts b/linter-4.2/test/es_object.ts index d9715b772..445b5c0c0 100644 --- a/linter-4.2/test/es_object.ts +++ b/linter-4.2/test/es_object.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { fooOh, barOh } from './oh_modules/ohos_lib' type ESObject = any class A {} @@ -174,3 +174,20 @@ interface CL extends ESObject {} export interface CLS extends ESObject {} foo2({ k: 'k', h: {t: 1}}) // we can assign anything to the esobject, even untyped literal +let q1: ESObject = 1; // CTE - ``ESObject`` typed variable can only be local +let q2: ESObject = fooOh(); // CTE - ``ESObject`` typed variable can only be local +let q3: ESObject = q2; // CTE - ``ESObject`` typed variable can only be local +function f() { + let e1 = fooOh(); // CTE - type of e1 is `any` + let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values + let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values + let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values + let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + let e6: ESObject = fooOh(); // OK - explicitly annotaded as ESObject + let e7: ESObject = e6; // OK - initialize ESObject with ESObject + e6['prop'] // CTE - can't access dynamic properties of ESObject + e6[1] // CTE - can't access dynamic properties of ESObject + e6.prop // CTE - can't access dynamic properties of ESObject + barOh(e6) // OK - ESObject is passed to interop call + e6 = e7 // OK - ESObject is assigned to ESObject +} diff --git a/linter-4.2/test/es_object.ts.relax.json b/linter-4.2/test/es_object.ts.relax.json index 10bd5f5bd..f3d5acdb4 100644 --- a/linter-4.2/test/es_object.ts.relax.json +++ b/linter-4.2/test/es_object.ts.relax.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 9, + "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 77, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 78, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 79, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 80, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 82, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 83, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 85, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 86, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 87, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 88, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 90, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 91, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 93, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 94, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 95, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 96, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 98, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 99, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 176, @@ -594,6 +594,83 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 177, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 178, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 179, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 181, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 182, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 183, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 184, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 185, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 188, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 189, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 190, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/es_object.ts.strict.json b/linter-4.2/test/es_object.ts.strict.json index 10bd5f5bd..5c869e41f 100644 --- a/linter-4.2/test/es_object.ts.strict.json +++ b/linter-4.2/test/es_object.ts.strict.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 9, + "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 77, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 78, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 79, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 80, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 82, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 83, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 85, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 86, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 87, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 88, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 90, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 91, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 93, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 94, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 95, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 96, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 98, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 99, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 176, @@ -594,6 +594,83 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 177, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 178, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 179, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 181, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 182, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 183, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 184, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 185, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 188, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 189, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 190, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } - ] + ] } \ No newline at end of file diff --git a/linter-4.2/test/oh_modules/ohos_lib.ts b/linter-4.2/test/oh_modules/ohos_lib.ts index a0aa74c87..c69856185 100644 --- a/linter-4.2/test/oh_modules/ohos_lib.ts +++ b/linter-4.2/test/oh_modules/ohos_lib.ts @@ -20,3 +20,6 @@ export interface OhosI { export function ohFunction1({d: OhosI}): void {} // incorrect usage, but it was an issue, so we check it too export function ohFunction2(p: {d: OhosI}): void {} + +export function fooOh(): any {} +export function barOh(a: any) {} diff --git a/linter/docs/rules/recipe151.md b/linter/docs/rules/recipe151.md new file mode 100644 index 000000000..bcc54e997 --- /dev/null +++ b/linter/docs/rules/recipe151.md @@ -0,0 +1,54 @@ + +# Usage of ``ESObject`` type is restricted + +Rule ``arkts-limited-esobject`` + +**Severity: warning** + +ArkTS does not allow using ``ESObject`` type in some cases. The most part of limitations +are put in place in order to prevent spread of dynamic objects in the static codebase. +The only scenario where it is permited to use ``ESObject`` as type specifier is in local +variable declaration. Initialization of variables with ``ESObject`` type is also limited. +Such variables can only be initialized with values that originate from interop: +other ``ESObject`` typed variables, any, unknown, variables with anonymous type, etc. +It is prohibited to initialize ``ESObject`` typed variable with statically typed value. +Varaible of type ``ESObject`` can only be passed to interop calls and assigned to other +variables of type ``ESObject``. + + +## ArkTS + + +``` + // lib.d.ts + declare function foo(): any; + declare function bar(a: any): number; + + // main.ets + let e0: ESObject = foo(); // CTE - ``ESObject`` typed variable can only be local + + function f() { + let e1 = foo(); // CTE - type of e1 is `any` + let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values + let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values + let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values + let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject + let e7 = e6; // OK - initialize ESObject with ESObject + e6['prop'] // CTE - can't access dynamic properties of ESObject + e6[1] // CTE - can't access dynamic properties of ESObject + e6.prop // CTE - can't access dynamic properties of ESObject + bar(e6) // OK - ESObject is passed to interop call + } +``` + + +## See also + +- Recipe 001: Objects with property names that are not identifiers are not supported (``arkts-identifiers-as-prop-names``) +- Recipe 002: ``Symbol()`` API is not supported (``arkts-no-symbol``) +- Recipe 029: Indexed access is not supported for fields (``arkts-no-props-by-index``) +- Recipe 060: ``typeof`` operator is allowed only in expression contexts (``arkts-no-type-query``) +- Recipe 066: ``in`` operator is not supported (``arkts-no-in``) +- Recipe 137: ``globalThis`` is not supported (``arkts-no-globalthis``) + diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index d71982547..80d6030bf 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -170,3 +170,4 @@ cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (ar cookBookTag[148] = 'No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; +cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobject)'; diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index e567b1f60..1346c84b3 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -106,6 +106,4 @@ faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; faultsAttrs[FaultID.UnsupportedDecorators] = {warning: true, cookBookRef: '148',}; faultsAttrs[FaultID.ClassAsObject] = {cookBookRef: '149',}; faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '150',}; -faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '8'}; -faultsAttrs[FaultID.EsObjectAssignment] = {warning: true, cookBookRef: '8'}; -faultsAttrs[FaultID.EsObjectAccess] = {warning: true, cookBookRef: '8'}; +faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '151'}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index 407fd7a05..d4555c10a 100644 --- a/linter/src/FaultDesc.ts +++ b/linter/src/FaultDesc.ts @@ -100,6 +100,4 @@ faultDesc[FaultID.ErrorSuppression] = 'Error suppression annotation'; faultDesc[FaultID.StrictDiagnostic] = 'Strict diagnostic'; faultDesc[FaultID.UnsupportedDecorators] = 'Unsupported decorators'; faultDesc[FaultID.ImportAfterStatement] = 'Import declaration after other declaration or statement'; -faultDesc[FaultID.EsObjectType] = '"ESObject" type'; -faultDesc[FaultID.EsObjectAssignment] = '"ESObject" type assignment'; -faultDesc[FaultID.EsObjectAccess] = '"ESObject" access'; +faultDesc[FaultID.EsObjectType] = 'Restricted "ESObject" type'; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index ea9407728..4008210e4 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -34,6 +34,6 @@ export enum FaultID { NewTarget, DefiniteAssignment, Prototype, GlobalThis, UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ConstAssertion, ImportAssertion, SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, UnsupportedDecorators, ImportAfterStatement, - EsObjectType, EsObjectAssignment, EsObjectAccess, + EsObjectType, LAST_ID, // this should always be last enum` } diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index bfceb036c..d97a49cf2 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -603,8 +603,8 @@ export class TypeScriptLinter { // missing exact rule this.incrementCounters(propertyAccessNode.expression, FaultID.ClassAsObject); } - if (baseExprSym !== undefined && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { - this.incrementCounters(propertyAccessNode, FaultID.EsObjectAccess); + if (!!baseExprSym && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { + this.incrementCounters(propertyAccessNode, FaultID.EsObjectType); } } @@ -930,9 +930,7 @@ export class TypeScriptLinter { if (this.tsUtils.needToDeduceStructuralIdentity(leftOperandType, rightOperandType, tsRhsExpr)) { this.incrementCounters(tsBinaryExpr, FaultID.StructuralIdentity); } - if (typeNode) { - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - } + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); break; default: return; @@ -1019,38 +1017,40 @@ export class TypeScriptLinter { if (this.tsUtils.needToDeduceStructuralIdentity(tsVarType, tsInitType, tsVarInit)) { this.incrementCounters(tsVarDecl, FaultID.StructuralIdentity); } - - this.handleEsObjectAssignment(tsVarDecl, tsVarDecl.type, tsVarInit); } + this.handleEsObjectDelaration(tsVarDecl); this.handleDeclarationInferredType(tsVarDecl); this.handleDefiniteAssignmentAssertion(tsVarDecl); } - private handleEsObjectAssignment(node: ts.Node, type: ts.TypeNode, value: ts.Node) { - if (!this.tsUtils.isEsObjectType(type)) { - let valueTypeNode = this.tsUtils.getVariableDeclarationTypeNode(value); - if (!!valueTypeNode && this.tsUtils.isEsObjectType(valueTypeNode)) { - this.incrementCounters(node, FaultID.EsObjectAssignment); - } - - return - } - - if (ts.isArrayLiteralExpression(value) || ts.isObjectLiteralExpression(value)) { - this.incrementCounters(node, FaultID.EsObjectAssignment); + private handleEsObjectDelaration(node: ts.VariableDeclaration) { + const isDeclaredESObject = !!node.type && this.tsUtils.isEsObjectType(node.type); + const initalizerTypeNode = node.initializer && this.tsUtils.getVariableDeclarationTypeNode(node.initializer); + const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); + const isLocal = this.tsUtils.isInsideBlock(node) + if ((isDeclaredESObject || isInitializedWithESObject) && !isLocal) { + this.incrementCounters(node, FaultID.EsObjectType); return; } - const valueType = this.tsTypeChecker.getTypeAtLocation(value); - if (this.tsUtils.isUnsupportedType(valueType)) { - return; + if (node.initializer) { + this.handleEsObjectAssignment(node, node.type, node.initializer); } + } - if (this.tsUtils.isAnonymousType(valueType)) { + private handleEsObjectAssignment(node: ts.Node, nodeDeclType: ts.TypeNode | undefined, initializer: ts.Node) { + const isTypeAnnotated = !!nodeDeclType; + const isDeclaredESObject = isTypeAnnotated && this.tsUtils.isEsObjectType(nodeDeclType); + const initalizerTypeNode = this.tsUtils.getVariableDeclarationTypeNode(initializer); + const isInitializedWithESObject = !!initalizerTypeNode && this.tsUtils.isEsObjectType(initalizerTypeNode); + if (isTypeAnnotated && !isDeclaredESObject && isInitializedWithESObject) { + this.incrementCounters(node, FaultID.EsObjectType); return; } - this.incrementCounters(node, FaultID.EsObjectAssignment); + if (isDeclaredESObject && !this.tsUtils.isValueAssignableToESObject(initializer)) { + this.incrementCounters(node, FaultID.EsObjectType); + } } private handleCatchClause(node: ts.Node) { @@ -1237,18 +1237,19 @@ export class TypeScriptLinter { } private handleIdentifier(node: ts.Node) { - let tsIdentifier = node as ts.Identifier; - let tsIdentSym = this.tsUtils.trueSymbolAtLocation(tsIdentifier); - if (tsIdentSym !== undefined) { - if ( - (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && - (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && - tsIdentifier.text === 'globalThis' - ) { - this.incrementCounters(node, FaultID.GlobalThis); - } else { - this.handleRestrictedValues(tsIdentifier, tsIdentSym); - } + const tsIdentifier = node as ts.Identifier; + const tsIdentSym = this.tsUtils.trueSymbolAtLocation(tsIdentifier); + if (!tsIdentSym) { + return + } + if ( + (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && + (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && + tsIdentifier.text === 'globalThis' + ) { + this.incrementCounters(node, FaultID.GlobalThis); + } else { + this.handleRestrictedValues(tsIdentifier, tsIdentSym); } } @@ -1330,7 +1331,7 @@ export class TypeScriptLinter { } if (this.tsUtils.hasEsObjectType(tsElementAccessExpr.expression)) { - this.incrementCounters(node, FaultID.EsObjectAccess); + this.incrementCounters(node, FaultID.EsObjectType); } } @@ -1379,7 +1380,7 @@ export class TypeScriptLinter { this.handleStdlibAPICall(tsCallExpr, calleeSym); this.handleFunctionApplyBindPropCall(tsCallExpr, calleeSym); if (this.tsUtils.symbolHasEsObjectType(calleeSym)) { - this.incrementCounters(tsCallExpr, FaultID.EsObjectAccess); + this.incrementCounters(tsCallExpr, FaultID.EsObjectType); } } if (callSignature !== undefined) { @@ -1391,7 +1392,7 @@ export class TypeScriptLinter { this.handleLibraryTypeCall(tsCallExpr, calleeType); if (ts.isPropertyAccessExpression(tsCallExpr.expression) && this.tsUtils.hasEsObjectType(tsCallExpr.expression.expression)) { - this.incrementCounters(node, FaultID.EsObjectAccess); + this.incrementCounters(node, FaultID.EsObjectType); } } @@ -1617,26 +1618,37 @@ export class TypeScriptLinter { } private handleTypeReference(node: ts.Node) { - let typeRef = node as ts.TypeReferenceNode; - if (this.tsUtils.isEsObjectType(typeRef) && !this.tsUtils.isEsObjectAllowed(typeRef)) { + const typeRef = node as ts.TypeReferenceNode; + + const isESObject = this.tsUtils.isEsObjectType(typeRef); + const isPossiblyValidContext = this.tsUtils.isEsObjectPossiblyAllowed(typeRef); + if (isESObject && !isPossiblyValidContext) { this.incrementCounters(node, FaultID.EsObjectType); - } else if (ts.isIdentifier(typeRef.typeName) && LIMITED_STANDARD_UTILITY_TYPES.includes(typeRef.typeName.text)) + return; + } + + const typeName = this.tsUtils.entityNameToString(typeRef.typeName); + const isStdUtilityType = LIMITED_STANDARD_UTILITY_TYPES.includes(typeName); + if (isStdUtilityType) { this.incrementCounters(node, FaultID.UtilityType); - else if ( - ts.isIdentifier(typeRef.typeName) && typeRef.typeName.text === 'Partial' && - typeRef.typeArguments && typeRef.typeArguments.length === 1 - ) { - // Using Partial type is allowed only when its argument type is either Class or Interface. - let argType = this.tsTypeChecker.getTypeFromTypeNode(typeRef.typeArguments[0]); - if (!argType || !argType.isClassOrInterface()) - this.incrementCounters(node, FaultID.UtilityType); + return; + } + + // Using Partial type is allowed only when its argument type is either Class or Interface. + const isStdPartial = this.tsUtils.entityNameToString(typeRef.typeName) === 'Partial'; + const hasSingleTypeArgument = !!typeRef.typeArguments && typeRef.typeArguments.length === 1; + const argType = hasSingleTypeArgument && this.tsTypeChecker.getTypeFromTypeNode(typeRef.typeArguments[0]); + if (isStdPartial && argType && !argType.isClassOrInterface()) { + this.incrementCounters(node, FaultID.UtilityType); + return; } } private handleMetaProperty(node: ts.Node) { let tsMetaProperty = node as ts.MetaProperty; - if (tsMetaProperty.name.text === 'target') + if (tsMetaProperty.name.text === 'target') { this.incrementCounters(node, FaultID.NewTarget); + } } private handleStructDeclaration(node: ts.Node) { diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index fbe9f0452..39d31eed8 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -1115,22 +1115,29 @@ export class TsUtils { typeNode.typeName.text == ES_OBJECT; } - public isEsObjectAllowed(typeRef: ts.TypeReferenceNode): boolean { - let node = typeRef.parent; - - if (!this.isVarDeclaration(node)) { - return false; - } - - while (node) { - if (ts.isBlock(node)) { + public isInsideBlock(node: ts.Node): boolean { + let par = node.parent + while (par) { + if (ts.isBlock(par)) { return true; } - node = node.parent; + par = par.parent; } return false; } + public isEsObjectPossiblyAllowed(typeRef: ts.TypeReferenceNode): boolean { + return ts.isVariableDeclaration(typeRef.parent); + } + + public isValueAssignableToESObject(node: ts.Node): boolean { + if (ts.isArrayLiteralExpression(node) || ts.isObjectLiteralExpression(node)) { + return false; + } + const valueType = this.tsTypeChecker.getTypeAtLocation(node); + return this.isUnsupportedType(valueType) || this.isAnonymousType(valueType) + } + public getVariableDeclarationTypeNode(node: ts.Node): ts.TypeNode | undefined { let sym = this.trueSymbolAtLocation(node); if (sym === undefined) { @@ -1160,7 +1167,7 @@ export class TsUtils { public isEsObjectSymbol(sym: ts.Symbol): boolean { let decl = this.getDeclaration(sym); return !!decl && ts.isTypeAliasDeclaration(decl) && decl.name.escapedText == ES_OBJECT && - decl.type.kind == ts.SyntaxKind.AnyKeyword; + decl.type.kind === ts.SyntaxKind.AnyKeyword; } public isAnonymousType(type: ts.Type): boolean { diff --git a/linter/test/es_object.ts b/linter/test/es_object.ts index d9715b772..445b5c0c0 100644 --- a/linter/test/es_object.ts +++ b/linter/test/es_object.ts @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { fooOh, barOh } from './oh_modules/ohos_lib' type ESObject = any class A {} @@ -174,3 +174,20 @@ interface CL extends ESObject {} export interface CLS extends ESObject {} foo2({ k: 'k', h: {t: 1}}) // we can assign anything to the esobject, even untyped literal +let q1: ESObject = 1; // CTE - ``ESObject`` typed variable can only be local +let q2: ESObject = fooOh(); // CTE - ``ESObject`` typed variable can only be local +let q3: ESObject = q2; // CTE - ``ESObject`` typed variable can only be local +function f() { + let e1 = fooOh(); // CTE - type of e1 is `any` + let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values + let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values + let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values + let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + let e6: ESObject = fooOh(); // OK - explicitly annotaded as ESObject + let e7: ESObject = e6; // OK - initialize ESObject with ESObject + e6['prop'] // CTE - can't access dynamic properties of ESObject + e6[1] // CTE - can't access dynamic properties of ESObject + e6.prop // CTE - can't access dynamic properties of ESObject + barOh(e6) // OK - ESObject is passed to interop call + e6 = e7 // OK - ESObject is assigned to ESObject +} diff --git a/linter/test/es_object.ts.relax.json b/linter/test/es_object.ts.relax.json index 10bd5f5bd..f3d5acdb4 100644 --- a/linter/test/es_object.ts.relax.json +++ b/linter/test/es_object.ts.relax.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 9, + "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 77, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 78, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 79, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 80, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 82, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 83, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 85, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 86, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 87, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 88, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 90, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 91, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 93, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 94, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 95, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 96, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 98, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 99, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 176, @@ -594,6 +594,83 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 177, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 178, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 179, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 181, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 182, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 183, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 184, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 185, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 188, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 189, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 190, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } ] } \ No newline at end of file diff --git a/linter/test/es_object.ts.strict.json b/linter/test/es_object.ts.strict.json index 10bd5f5bd..5c869e41f 100644 --- a/linter/test/es_object.ts.strict.json +++ b/linter/test/es_object.ts.strict.json @@ -23,234 +23,234 @@ }, { "line": 20, - "column": 9, + "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 77, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 78, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 79, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 80, "column": 5, - "problem": "EsObjectAccess", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 82, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 83, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 85, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 86, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 87, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 88, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 90, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 91, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 93, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 94, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 95, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 96, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 98, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 99, "column": 5, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 114, @@ -486,37 +486,37 @@ { "line": 115, "column": 9, - "problem": "EsObjectAssignment", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" }, { "line": 176, @@ -594,6 +594,83 @@ "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 177, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 178, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 179, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 181, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 182, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 183, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 184, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 185, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 188, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 189, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + }, + { + "line": 190, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" } - ] + ] } \ No newline at end of file diff --git a/linter/test/oh_modules/ohos_lib.ts b/linter/test/oh_modules/ohos_lib.ts index a0aa74c87..c69856185 100644 --- a/linter/test/oh_modules/ohos_lib.ts +++ b/linter/test/oh_modules/ohos_lib.ts @@ -20,3 +20,6 @@ export interface OhosI { export function ohFunction1({d: OhosI}): void {} // incorrect usage, but it was an issue, so we check it too export function ohFunction2(p: {d: OhosI}): void {} + +export function fooOh(): any {} +export function barOh(a: any) {} -- Gitee From 2b756ee2b90e1be8d45775dcc6c53178a5c9603e Mon Sep 17 00:00:00 2001 From: Denis Slynko Date: Mon, 30 Oct 2023 13:15:42 +0300 Subject: [PATCH 15/23] [ArkTS Linter] Fix possible type mismatch in validateDeclInferredType Signed-off-by: Denis Slynko --- linter-4.2/src/TypeScriptLinter.ts | 4 +--- linter/src/TypeScriptLinter.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index e90316f2b..bc9dd25c4 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -2226,9 +2226,7 @@ export class TypeScriptLinter { if (type.aliasSymbol != undefined) { return; } - const isObject = type.flags & ts.TypeFlags.Object; - const isReference = (type as ts.ObjectType).objectFlags & ts.ObjectFlags.Reference; - if (isObject && isReference) { + if (this.tsUtils.isObjectType(type) && !!(type.objectFlags & ts.ObjectFlags.Reference)) { this.handleInferredObjectreference(type, decl); return; } diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 135475594..a33d4740f 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1864,9 +1864,7 @@ export class TypeScriptLinter { if (type.aliasSymbol != undefined) { return; } - const isObject = type.flags & ts.TypeFlags.Object; - const isReference = (type as ts.ObjectType).objectFlags & ts.ObjectFlags.Reference; - if (isObject && isReference) { + if (this.tsUtils.isObjectType(type) && !!(type.objectFlags & ts.ObjectFlags.Reference)) { this.handleInferredObjectreference(type, decl); return; } -- Gitee From 7762cb25bc0fa2edce6741fc535bc0eed57a8827 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Tue, 31 Oct 2023 16:50:34 +0300 Subject: [PATCH 16/23] [arkts-linter] update description for recipe 151 Signed-off-by: Nazarov Konstantin --- linter-4.2/docs/rules/recipe151.md | 29 ++-- linter-4.2/src/CookBookMsg.ts | 2 +- linter-4.2/test/es_object.ts.relax.json | 172 +++++++++++------------ linter-4.2/test/es_object.ts.strict.json | 172 +++++++++++------------ linter/docs/rules/recipe151.md | 29 ++-- linter/src/CookBookMsg.ts | 2 +- linter/test/es_object.ts.relax.json | 172 +++++++++++------------ linter/test/es_object.ts.strict.json | 172 +++++++++++------------ 8 files changed, 376 insertions(+), 374 deletions(-) diff --git a/linter-4.2/docs/rules/recipe151.md b/linter-4.2/docs/rules/recipe151.md index bcc54e997..2e7fd2d46 100644 --- a/linter-4.2/docs/rules/recipe151.md +++ b/linter-4.2/docs/rules/recipe151.md @@ -1,18 +1,18 @@ - # Usage of ``ESObject`` type is restricted -Rule ``arkts-limited-esobject`` +Rule ``arkts-limited-esobj`` **Severity: warning** -ArkTS does not allow using ``ESObject`` type in some cases. The most part of limitations -are put in place in order to prevent spread of dynamic objects in the static codebase. -The only scenario where it is permited to use ``ESObject`` as type specifier is in local -variable declaration. Initialization of variables with ``ESObject`` type is also limited. -Such variables can only be initialized with values that originate from interop: -other ``ESObject`` typed variables, any, unknown, variables with anonymous type, etc. -It is prohibited to initialize ``ESObject`` typed variable with statically typed value. -Varaible of type ``ESObject`` can only be passed to interop calls and assigned to other +ArkTS does not allow using ``ESObject`` type in some cases. The most part of +limitations are put in place in order to prevent spread of dynamic objects in +the static codebase. The only scenario where it is permited to use ``ESObject`` +as type specifier is in local variable declaration. Initialization of variables +with ``ESObject`` type is also limited. Such variables can only be initialized +with values that originate from interop: other ``ESObject`` typed variables, +any, unknown, variables with anonymous type, etc. It is prohibited to +initialize ``ESObject`` typed variable with statically typed value. Varaible +of type ``ESObject`` can only be passed to interop calls and assigned to other variables of type ``ESObject``. @@ -33,12 +33,13 @@ variables of type ``ESObject``. let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + e5['prop'] // CTE - can't access dynamic properties of ESObject + e5[1] // CTE - can't access dynamic properties of ESObject + e5.prop // CTE - can't access dynamic properties of ESObject + let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject let e7 = e6; // OK - initialize ESObject with ESObject - e6['prop'] // CTE - can't access dynamic properties of ESObject - e6[1] // CTE - can't access dynamic properties of ESObject - e6.prop // CTE - can't access dynamic properties of ESObject - bar(e6) // OK - ESObject is passed to interop call + bar(e7) // OK - ESObject is passed to interop call } ``` diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index 0f7b312b1..a5897f0e2 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -170,4 +170,4 @@ cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (ar cookBookTag[148] = 'No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; -cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobject)'; +cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobj)'; diff --git a/linter-4.2/test/es_object.ts.relax.json b/linter-4.2/test/es_object.ts.relax.json index f3d5acdb4..7450fc30f 100644 --- a/linter-4.2/test/es_object.ts.relax.json +++ b/linter-4.2/test/es_object.ts.relax.json @@ -26,231 +26,231 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 77, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 78, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 79, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 80, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 82, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 83, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 85, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 86, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 87, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 88, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 90, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 91, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 93, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 94, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 95, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 96, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 98, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 99, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 114, @@ -488,35 +488,35 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 176, @@ -600,21 +600,21 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 178, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 179, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 181, @@ -628,49 +628,49 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 183, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 184, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 185, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 188, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 189, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 190, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/es_object.ts.strict.json b/linter-4.2/test/es_object.ts.strict.json index 5c869e41f..4909f595f 100644 --- a/linter-4.2/test/es_object.ts.strict.json +++ b/linter-4.2/test/es_object.ts.strict.json @@ -26,231 +26,231 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 77, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 78, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 79, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 80, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 82, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 83, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 85, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 86, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 87, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 88, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 90, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 91, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 93, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 94, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 95, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 96, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 98, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 99, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 114, @@ -488,35 +488,35 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 176, @@ -600,21 +600,21 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 178, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 179, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 181, @@ -628,49 +628,49 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 183, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 184, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 185, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 188, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 189, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 190, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" } ] } \ No newline at end of file diff --git a/linter/docs/rules/recipe151.md b/linter/docs/rules/recipe151.md index bcc54e997..2e7fd2d46 100644 --- a/linter/docs/rules/recipe151.md +++ b/linter/docs/rules/recipe151.md @@ -1,18 +1,18 @@ - # Usage of ``ESObject`` type is restricted -Rule ``arkts-limited-esobject`` +Rule ``arkts-limited-esobj`` **Severity: warning** -ArkTS does not allow using ``ESObject`` type in some cases. The most part of limitations -are put in place in order to prevent spread of dynamic objects in the static codebase. -The only scenario where it is permited to use ``ESObject`` as type specifier is in local -variable declaration. Initialization of variables with ``ESObject`` type is also limited. -Such variables can only be initialized with values that originate from interop: -other ``ESObject`` typed variables, any, unknown, variables with anonymous type, etc. -It is prohibited to initialize ``ESObject`` typed variable with statically typed value. -Varaible of type ``ESObject`` can only be passed to interop calls and assigned to other +ArkTS does not allow using ``ESObject`` type in some cases. The most part of +limitations are put in place in order to prevent spread of dynamic objects in +the static codebase. The only scenario where it is permited to use ``ESObject`` +as type specifier is in local variable declaration. Initialization of variables +with ``ESObject`` type is also limited. Such variables can only be initialized +with values that originate from interop: other ``ESObject`` typed variables, +any, unknown, variables with anonymous type, etc. It is prohibited to +initialize ``ESObject`` typed variable with statically typed value. Varaible +of type ``ESObject`` can only be passed to interop calls and assigned to other variables of type ``ESObject``. @@ -33,12 +33,13 @@ variables of type ``ESObject``. let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + e5['prop'] // CTE - can't access dynamic properties of ESObject + e5[1] // CTE - can't access dynamic properties of ESObject + e5.prop // CTE - can't access dynamic properties of ESObject + let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject let e7 = e6; // OK - initialize ESObject with ESObject - e6['prop'] // CTE - can't access dynamic properties of ESObject - e6[1] // CTE - can't access dynamic properties of ESObject - e6.prop // CTE - can't access dynamic properties of ESObject - bar(e6) // OK - ESObject is passed to interop call + bar(e7) // OK - ESObject is passed to interop call } ``` diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index 80d6030bf..c62bafe14 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -170,4 +170,4 @@ cookBookTag[147] = 'No dependencies on TypeScript code are currently allowed (ar cookBookTag[148] = 'No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)'; cookBookTag[149] = 'Classes cannot be used as objects (arkts-no-classes-as-obj)'; cookBookTag[150] = '"import" statements after other statements are not allowed (arkts-no-misplaced-imports)'; -cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobject)'; +cookBookTag[151] = 'Usage of "ESObject" type is restricted (arkts-limited-esobj)'; diff --git a/linter/test/es_object.ts.relax.json b/linter/test/es_object.ts.relax.json index f3d5acdb4..7450fc30f 100644 --- a/linter/test/es_object.ts.relax.json +++ b/linter/test/es_object.ts.relax.json @@ -26,231 +26,231 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 77, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 78, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 79, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 80, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 82, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 83, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 85, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 86, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 87, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 88, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 90, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 91, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 93, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 94, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 95, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 96, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 98, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 99, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 114, @@ -488,35 +488,35 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 176, @@ -600,21 +600,21 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 178, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 179, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 181, @@ -628,49 +628,49 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 183, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 184, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 185, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 188, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 189, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 190, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" } ] } \ No newline at end of file diff --git a/linter/test/es_object.ts.strict.json b/linter/test/es_object.ts.strict.json index 5c869e41f..4909f595f 100644 --- a/linter/test/es_object.ts.strict.json +++ b/linter/test/es_object.ts.strict.json @@ -26,231 +26,231 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 21, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 22, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 25, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 26, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 27, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 21, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 35, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 29, "column": 53, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 35, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 39, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 14, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 46, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 43, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 48, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 52, "column": 63, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 19, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 33, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 51, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 56, "column": 65, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 60, @@ -271,175 +271,175 @@ "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 64, "column": 50, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 66, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 67, "column": 17, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 70, "column": 13, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 71, "column": 15, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 77, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 78, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 79, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 80, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 82, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 83, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 85, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 86, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 87, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 88, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 90, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 91, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 93, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 94, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 95, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 96, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 98, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 99, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 103, @@ -453,28 +453,28 @@ "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 106, "column": 11, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 108, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 109, "column": 18, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 114, @@ -488,35 +488,35 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 119, "column": 36, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 25, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 136, "column": 38, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 148, @@ -530,63 +530,63 @@ "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 45, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, "column": 58, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 32, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 47, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 162, "column": 60, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 170, "column": 28, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 172, "column": 22, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 174, "column": 30, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 176, @@ -600,21 +600,21 @@ "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 178, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 179, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 181, @@ -628,49 +628,49 @@ "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 183, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 184, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 185, "column": 9, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 188, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 189, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 190, "column": 5, "problem": "EsObjectType", "suggest": "", - "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobject)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" } ] } \ No newline at end of file -- Gitee From 3a20dff2875172938857b71af3147523b791a899 Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Tue, 31 Oct 2023 21:47:07 +0300 Subject: [PATCH 17/23] [ArkTS Linter] Fix #14228: relax 'class-as-object' rule when passing class to method call of the object of 'any' type. Change-Id: Iaf7ef42da534b78af554bc4111cc37a4576a6d0d Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 3 +- linter-4.2/test/class_as_object.ts | 8 ++- linter-4.2/test/class_as_object.ts.relax.json | 70 +++++++++++++++---- .../test/class_as_object.ts.strict.json | 70 +++++++++++++++---- linter-4.2/test/oh_modules/ohos_factory.ts | 15 ++++ linter/src/TypeScriptLinter.ts | 3 +- linter/test/class_as_object.ts | 8 ++- linter/test/class_as_object.ts.relax.json | 70 +++++++++++++++---- linter/test/class_as_object.ts.strict.json | 70 +++++++++++++++---- linter/test/oh_modules/ohos_factory.ts | 15 ++++ 10 files changed, 272 insertions(+), 60 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index bc9dd25c4..2dd4ea42e 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1515,7 +1515,8 @@ export class TypeScriptLinter { if (ts.isCallExpression(ctx.parent) || ts.isNewExpression(ctx.parent)) { let callee = ctx.parent.expression; - if (callee != ctx && this.tsUtils.hasLibraryType(callee)) { + if (callee != ctx && (this.tsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(callee)) || + this.tsUtils.hasLibraryType(callee))) { return true; } } diff --git a/linter-4.2/test/class_as_object.ts b/linter-4.2/test/class_as_object.ts index 302432975..0cdc57d50 100644 --- a/linter-4.2/test/class_as_object.ts +++ b/linter-4.2/test/class_as_object.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Something, SomethingFactory, SomethingBar, Bar } from "./oh_modules/ohos_factory"; +import { Something, SomethingFactory, SomethingBar, Bar, Select } from "./oh_modules/ohos_factory"; class C { static a = 5; @@ -91,3 +91,9 @@ for (let item = 0; item < Object.keys(Color).length; item++) { foo2(() => C); export { C as H }; + +// #14228 +let data = new Select().from(C).eq('key').query(C); // Ok +invalid_func(C); // Ok +let a: any; +a.foo(C); // Ok \ No newline at end of file diff --git a/linter-4.2/test/class_as_object.ts.relax.json b/linter-4.2/test/class_as_object.ts.relax.json index fbae23bf5..7032f676c 100644 --- a/linter-4.2/test/class_as_object.ts.relax.json +++ b/linter-4.2/test/class_as_object.ts.relax.json @@ -15,72 +15,114 @@ { "line": 27, "column": 9, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 28, "column": 5, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 29, "column": 11, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 30, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 38, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 39, "column": 6, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 42, "column": 10, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 45, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 46, "column": 8, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 49, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 58, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 60, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 87, "column": 39, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 91, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 96, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 98, + "column": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/class_as_object.ts.strict.json b/linter-4.2/test/class_as_object.ts.strict.json index fbae23bf5..7032f676c 100644 --- a/linter-4.2/test/class_as_object.ts.strict.json +++ b/linter-4.2/test/class_as_object.ts.strict.json @@ -15,72 +15,114 @@ { "line": 27, "column": 9, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 28, "column": 5, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 29, "column": 11, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 30, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 38, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 39, "column": 6, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 42, "column": 10, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 45, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 46, "column": 8, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 49, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 58, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 60, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 87, "column": 39, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 91, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 96, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 98, + "column": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/oh_modules/ohos_factory.ts b/linter-4.2/test/oh_modules/ohos_factory.ts index e26c4c911..b4fc3d2d2 100644 --- a/linter-4.2/test/oh_modules/ohos_factory.ts +++ b/linter-4.2/test/oh_modules/ohos_factory.ts @@ -16,3 +16,18 @@ export declare class SomethingBar extends Something { } export declare class Bar { constructor(arg: { new(): T }); } + +export class Select { + public from(cls: any) { + return this; + } + + // we intentionally omit generic argument of 'Select', see #14228 + public eq(name: string): Select { + return this; + } + + public query(cls: any): Promise { + return cls.foo(); + } +} \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index a33d4740f..9c27f9a69 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1268,7 +1268,8 @@ export class TypeScriptLinter { if (ts.isCallExpression(ctx.parent) || ts.isNewExpression(ctx.parent)) { let callee = ctx.parent.expression; - if (callee != ctx && this.tsUtils.hasLibraryType(callee)) { + if (callee != ctx && (this.tsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(callee)) || + this.tsUtils.hasLibraryType(callee))) { return true; } } diff --git a/linter/test/class_as_object.ts b/linter/test/class_as_object.ts index e91d6c024..8a13dbfaa 100644 --- a/linter/test/class_as_object.ts +++ b/linter/test/class_as_object.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Something, SomethingFactory, SomethingBar, Bar } from "./oh_modules/ohos_factory"; +import { Something, SomethingFactory, SomethingBar, Bar, Select } from "./oh_modules/ohos_factory"; class C { static a = 5 @@ -91,3 +91,9 @@ for (let item = 0; item < Object.keys(Color).length; item++) { foo2(() => C); export { C as H }; + +// #14228 +let data = new Select().from(C).eq('key').query(C); // Ok +invalid_func(C); // Ok +let a: any; +a.foo(C); // Ok \ No newline at end of file diff --git a/linter/test/class_as_object.ts.relax.json b/linter/test/class_as_object.ts.relax.json index 0fdca9072..75576a35f 100644 --- a/linter/test/class_as_object.ts.relax.json +++ b/linter/test/class_as_object.ts.relax.json @@ -15,72 +15,114 @@ { "line": 27, "column": 9, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 28, "column": 5, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 29, "column": 11, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 30, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 38, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 39, "column": 6, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 42, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 45, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 46, "column": 8, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 49, "column": 14, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 58, "column": 22, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 60, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 87, "column": 39, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 91, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 96, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 98, + "column": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/test/class_as_object.ts.strict.json b/linter/test/class_as_object.ts.strict.json index 0fdca9072..75576a35f 100644 --- a/linter/test/class_as_object.ts.strict.json +++ b/linter/test/class_as_object.ts.strict.json @@ -15,72 +15,114 @@ { "line": 27, "column": 9, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 28, "column": 5, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 29, "column": 11, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 30, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 38, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 39, "column": 6, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 42, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 45, "column": 20, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 46, "column": 8, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 49, "column": 14, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 58, "column": 22, - "problem": "TypeQuery" + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" }, { "line": 60, "column": 7, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 87, "column": 39, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" }, { "line": 91, "column": 12, - "problem": "ClassAsObject" + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 96, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 98, + "column": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/test/oh_modules/ohos_factory.ts b/linter/test/oh_modules/ohos_factory.ts index e26c4c911..b4fc3d2d2 100644 --- a/linter/test/oh_modules/ohos_factory.ts +++ b/linter/test/oh_modules/ohos_factory.ts @@ -16,3 +16,18 @@ export declare class SomethingBar extends Something { } export declare class Bar { constructor(arg: { new(): T }); } + +export class Select { + public from(cls: any) { + return this; + } + + // we intentionally omit generic argument of 'Select', see #14228 + public eq(name: string): Select { + return this; + } + + public query(cls: any): Promise { + return cls.foo(); + } +} \ No newline at end of file -- Gitee From 6123c08ced8a09761b7fd00a95dd1c86869435c2 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Fri, 27 Oct 2023 16:43:27 +0300 Subject: [PATCH 18/23] [arkts-linter] fix #14183 - fix reporting of indexed access Signed-off-by: Nazarov Konstantin --- linter-4.2/docs/rules/recipe29.md | 10 +- linter-4.2/src/TypeScriptLinter.ts | 49 +++------- linter-4.2/src/Utils.ts | 92 +++++++++++------- linter-4.2/test/es_object.ts | 2 +- linter-4.2/test/es_object.ts.relax.json | 11 ++- linter-4.2/test/es_object.ts.strict.json | 32 ++++++- .../test/function_expression.ts.autofix.json | 8 ++ .../test/function_expression.ts.strict.json | 7 ++ linter-4.2/test/property_access_by_index.ts | 72 ++++++++++++++ .../property_access_by_index.ts.autofix.json | 24 +++++ .../property_access_by_index.ts.relax.json | 10 +- .../property_access_by_index.ts.strict.json | 21 +++++ linter-4.2/test/types.ts.autofix.json | 8 ++ linter-4.2/test/types.ts.strict.json | 7 ++ linter/docs/rules/recipe29.md | 10 +- linter/src/TypeScriptLinter.ts | 30 +++--- linter/src/utils/TsUtils.ts | 93 ++++++++++++------- linter/test/array_literals.ts | 1 - linter/test/es_object.ts | 2 +- linter/test/es_object.ts.relax.json | 11 ++- linter/test/es_object.ts.strict.json | 32 ++++++- .../test/function_expression.ts.autofix.json | 8 ++ .../test/function_expression.ts.strict.json | 7 ++ linter/test/property_access_by_index.ts | 72 ++++++++++++++ .../property_access_by_index.ts.autofix.json | 24 +++++ .../property_access_by_index.ts.relax.json | 10 +- .../property_access_by_index.ts.strict.json | 21 +++++ linter/test/types.ts.autofix.json | 8 ++ linter/test/types.ts.strict.json | 7 ++ 29 files changed, 545 insertions(+), 144 deletions(-) diff --git a/linter-4.2/docs/rules/recipe29.md b/linter-4.2/docs/rules/recipe29.md index c7be978d6..7af61c43e 100644 --- a/linter-4.2/docs/rules/recipe29.md +++ b/linter-4.2/docs/rules/recipe29.md @@ -10,9 +10,13 @@ that are either declared in the class, or accessible via inheritance. Accessing any other fields is prohibited, and causes compile-time errors. To access a field, use ``obj.field`` syntax, indexed access (``obj["field"]``) -is not supported. An exception are all typed arrays from the standard library -(for example, ``Int32Array``), which support access to their elements through -``container[index]`` syntax. +is not supported. An exception are: + +- All typed arrays from the standard library (for example, ``Int32Array``), which +support access to their elements through ``container[index]`` syntax. +- Tuples. +- Records. +- Enums. ## TypeScript diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 2dd4ea42e..dbed0dc62 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -617,7 +617,7 @@ export class TypeScriptLinter { ); if ( !throwExprType.isClassOrInterface() || - !this.tsUtils.isDerivedFrom(throwExprType, CheckType.Error) + !this.tsUtils.isOrDerivedFrom(throwExprType, this.tsUtils.isStdErrorType) ) { this.incrementCounters(node, FaultID.ThrowStatement, false, undefined); } @@ -1600,34 +1600,20 @@ export class TypeScriptLinter { undefined, ts.NodeBuilderFlags.None ); - const checkClassOrInterface = tsElemAccessBaseExprType.isClassOrInterface() && - !this.tsUtils.isGenericArrayType(tsElemAccessBaseExprType) && - !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); - const checkThisOrSuper = this.tsUtils.isThisOrSuperExpr(tsElementAccessExpr.expression) && - !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); - - // if (this.tsUtils.isEnumType(tsElemAccessBaseExprType)) { - // implement argument expression type check - // let argType = this.tsTypeChecker.getTypeAtLocation(tsElementAccessExpr.argumentExpression); - // if (argType.aliasSymbol == this.tsUtils.trueSymbolAtLocation(tsElementAccessExpr.expression)) { - // return; - // } - // check if constant EnumMember inferred ... - // this.incrementCounters(node, FaultID.PropertyAccessByIndex, autofixable, autofix); - // } if ( !this.tsUtils.isLibraryType(tsElemAccessBaseExprType) && - !this.tsUtils.isTypedArray(tsElemAccessBaseExprTypeNode) && - ( checkClassOrInterface || - this.tsUtils.isObjectLiteralType(tsElemAccessBaseExprType) || checkThisOrSuper) + !ts.isArrayLiteralExpression(tsElementAccessExpr.expression) && + !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isArray) && + !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isTuple) && + !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isStdRecordType) && + !this.tsUtils.isEnumType(tsElemAccessBaseExprType) && + !this.tsUtils.isEsObjectType(tsElemAccessBaseExprTypeNode) ) { let autofix = Autofixer.fixPropertyAccessByIndex(node); const autofixable = autofix != undefined; - if ( - !this.autofixesInfo.shouldAutofix(node, FaultID.PropertyAccessByIndex) - ) + if (!this.autofixesInfo.shouldAutofix(node, FaultID.PropertyAccessByIndex)) { autofix = undefined; - + } this.incrementCounters( node, FaultID.PropertyAccessByIndex, @@ -1998,21 +1984,8 @@ export class TypeScriptLinter { spreadElemNode.expression ); if (spreadExprType) { - const spreadExprTypeNode = this.tsTypeChecker.typeToTypeNode( - spreadExprType, - undefined, - ts.NodeBuilderFlags.None - ); - if ( - spreadExprTypeNode !== undefined && - (ts.isCallLikeExpression(node.parent) || - ts.isArrayLiteralExpression(node.parent)) - ) { - if ( - ts.isArrayTypeNode(spreadExprTypeNode) || - this.tsUtils.isTypedArray(spreadExprTypeNode) || - this.tsUtils.isDerivedFrom(spreadExprType, CheckType.Array) - ) { + if (ts.isCallLikeExpression(node.parent) || ts.isArrayLiteralExpression(node.parent)) { + if (this.tsUtils.isOrDerivedFrom(spreadExprType, this.tsUtils.isArray)) { return; } } diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 5f519cba0..c2f32b89a 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -94,13 +94,7 @@ export function isAssignmentOperator(tsBinOp: ts.BinaryOperatorToken): boolean { return tsBinOp.kind >= ts.SyntaxKind.FirstAssignment && tsBinOp.kind <= ts.SyntaxKind.LastAssignment; } -export enum CheckType { - Array, - String = "String", - Set = "Set", - Map = "Map", - Error = "Error", -}; +export type CheckType = ((t: ts.Type) => boolean); export class TsUtils { static readonly ES_OBJECT = 'ESObject' @@ -205,13 +199,6 @@ export class TsUtils { constructor(private tsTypeChecker: ts.TypeChecker, private testMode: boolean) { } - public isTypedArray(tsType: ts.TypeNode | undefined): boolean { - if (tsType === undefined || !ts.isTypeReferenceNode(tsType)) { - return false; - } - return TsUtils.TYPED_ARRAYS.includes(this.entityNameToString(tsType.typeName)); - } - public isType(tsType: ts.TypeNode | undefined, checkType: string): boolean { if (tsType === undefined || !ts.isTypeReferenceNode(tsType)) { return false; @@ -451,24 +438,48 @@ export class TsUtils { ); } + public isTypedArray(tsType: ts.Type): boolean { + const symbol = tsType.symbol; + if (!symbol) { + return false; + } + const name = this.tsTypeChecker.getFullyQualifiedName(symbol); + return this.isGlobalSymbol(symbol) && TsUtils.TYPED_ARRAYS.includes(name); + } + + public isArray(tsType: ts.Type): boolean { + return this.isGenericArrayType(tsType) || this.isTypedArray(tsType); + } + + public isTuple(tsType: ts.Type): boolean { + return this.isTypeReference(tsType) && !!(tsType.objectFlags & ts.ObjectFlags.Tuple); + } + // does something similar to relatedByInheritanceOrIdentical function - public isDerivedFrom(tsType: ts.Type, checkType: CheckType): tsType is ts.TypeReference { - if (this.isTypeReference(tsType) && tsType.target !== tsType) tsType = tsType.target; + public isOrDerivedFrom(tsType: ts.Type, checkType: CheckType): tsType is ts.TypeReference { + if (this.isTypeReference(tsType) && tsType.target !== tsType) { + tsType = tsType.target; + } - const tsTypeNode = this.tsTypeChecker.typeToTypeNode(tsType, undefined, ts.NodeBuilderFlags.None); - if (checkType == CheckType.Array && (this.isGenericArrayType(tsType) || this.isTypedArray(tsTypeNode))) - return true; - if (checkType != CheckType.Array && this.isType(tsTypeNode, checkType.toString())) + if (checkType.call(this, tsType)) { return true; - if (!tsType.symbol || !tsType.symbol.declarations) return false; + } - for (let tsTypeDecl of tsType.symbol.declarations) { - if ( - (!ts.isClassDeclaration(tsTypeDecl) && !ts.isInterfaceDeclaration(tsTypeDecl)) || - !tsTypeDecl.heritageClauses - ) continue; + if (!tsType.symbol || !tsType.symbol.declarations) { + return false; + } + + for (const tsTypeDecl of tsType.symbol.declarations) { + if (!ts.isClassDeclaration(tsTypeDecl) && !ts.isInterfaceDeclaration(tsTypeDecl)) { + continue; + } + if (!tsTypeDecl.heritageClauses) { + continue; + } for (let heritageClause of tsTypeDecl.heritageClauses) { - if (this.processParentTypesCheck(heritageClause.types, checkType)) return true; + if (this.processParentTypesCheck(heritageClause.types, checkType)) { + return true; + } } } @@ -771,10 +782,14 @@ export class TsUtils { } private processParentTypesCheck(parentTypes: ts.NodeArray, checkType: CheckType): boolean { - for (let baseTypeExpr of parentTypes) { + for (const baseTypeExpr of parentTypes) { let baseType = this.tsTypeChecker.getTypeAtLocation(baseTypeExpr); - if (this.isTypeReference(baseType) && baseType.target !== baseType) baseType = baseType.target; - if (baseType && this.isDerivedFrom(baseType, checkType)) return true; + if (this.isTypeReference(baseType) && baseType.target !== baseType) { + baseType = baseType.target; + } + if (baseType && this.isOrDerivedFrom(baseType, checkType)) { + return true; + } } return false; } @@ -1141,6 +1156,15 @@ export class TsUtils { return false; } + public isStdErrorType(type: ts.Type): boolean { + const symbol = type.symbol; + if (!symbol) { + return false; + } + const name = this.tsTypeChecker.getFullyQualifiedName(symbol); + return name === 'Error' && this.isGlobalSymbol(symbol); + } + public isStdPartialType(type: ts.Type): boolean { const sym = type.aliasSymbol; return !!sym && sym.getName() === 'Partial' && this.isGlobalSymbol(sym); @@ -1191,11 +1215,11 @@ export class TsUtils { const isEts = (ext === '.ets'); const isTs = (ext === '.ts' && !srcFile.isDeclarationFile); const isStatic = (isEts || (isTs && this.testMode)) && !isThirdPartyCode; + const isStdLib = TsUtils.STANDARD_LIBRARIES.includes(path.basename(fileName).toLowerCase()); // We still need to confirm support for certain API from the // TypeScript standard library in ArkTS. Thus, for now do not // count standard library modules. - return !isStatic && - !TsUtils.STANDARD_LIBRARIES.includes(path.basename(srcFile.fileName).toLowerCase()); + return !isStatic && !isStdLib; } return false; @@ -1353,8 +1377,8 @@ export class TsUtils { return false; } - public isEsObjectType(typeNode: ts.TypeNode): boolean { - return ts.isTypeReferenceNode(typeNode) && ts.isIdentifier(typeNode.typeName) && + public isEsObjectType(typeNode: ts.TypeNode | undefined): boolean { + return !!typeNode && ts.isTypeReferenceNode(typeNode) && ts.isIdentifier(typeNode.typeName) && typeNode.typeName.text == TsUtils.ES_OBJECT; } diff --git a/linter-4.2/test/es_object.ts b/linter-4.2/test/es_object.ts index 445b5c0c0..8b62f20f8 100644 --- a/linter-4.2/test/es_object.ts +++ b/linter-4.2/test/es_object.ts @@ -145,7 +145,7 @@ foo4([2, 3]) foo5([2, 3]) foo4(["str1", "str2"]) foo5(["str1", "str2"]) -let n = new ESObject[0] +let n: ESObject; n = null foo4(n) diff --git a/linter-4.2/test/es_object.ts.relax.json b/linter-4.2/test/es_object.ts.relax.json index 7450fc30f..5bab1a3ee 100644 --- a/linter-4.2/test/es_object.ts.relax.json +++ b/linter-4.2/test/es_object.ts.relax.json @@ -521,9 +521,16 @@ { "line": 148, "column": 5, - "problem": "AnyType", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 149, + "column": 1, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, diff --git a/linter-4.2/test/es_object.ts.strict.json b/linter-4.2/test/es_object.ts.strict.json index 4909f595f..c0ef7ba37 100644 --- a/linter-4.2/test/es_object.ts.strict.json +++ b/linter-4.2/test/es_object.ts.strict.json @@ -329,6 +329,13 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, + { + "line": 79, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 79, "column": 5, @@ -521,9 +528,16 @@ { "line": 148, "column": 5, - "problem": "AnyType", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 149, + "column": 1, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, @@ -651,6 +665,13 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, + { + "line": 188, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 188, "column": 5, @@ -658,6 +679,13 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, + { + "line": 189, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 189, "column": 5, diff --git a/linter-4.2/test/function_expression.ts.autofix.json b/linter-4.2/test/function_expression.ts.autofix.json index c571fa05a..e005781ad 100644 --- a/linter-4.2/test/function_expression.ts.autofix.json +++ b/linter-4.2/test/function_expression.ts.autofix.json @@ -267,6 +267,14 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 82, + "column": 19, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 82, "column": 19, diff --git a/linter-4.2/test/function_expression.ts.strict.json b/linter-4.2/test/function_expression.ts.strict.json index fe4750449..48723e4cd 100644 --- a/linter-4.2/test/function_expression.ts.strict.json +++ b/linter-4.2/test/function_expression.ts.strict.json @@ -168,6 +168,13 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 82, + "column": 19, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 82, "column": 19, diff --git a/linter-4.2/test/property_access_by_index.ts b/linter-4.2/test/property_access_by_index.ts index 3911b881b..407d70553 100644 --- a/linter-4.2/test/property_access_by_index.ts +++ b/linter-4.2/test/property_access_by_index.ts @@ -28,3 +28,75 @@ function test() { SetProperty(a, 'u', 'def'); return GetProperty(a, 'v') + GetProperty(a, 'u'); } + +let ar1 = [1, 2, 3, 4]; +let ar2 = [1, '2', 3, 4]; +let ar3: number[] = []; + +ar1[2]; +ar2[2]; +ar3[2]; + +const r0 = [1, 2, 3][1]; +let r1 = [1, 2, 3, 4][0] +let r2 = [1, '2', 3, 4][0] + +function fobject1(o: object) { + o['j'] +} + +function fobject2(o: Object) { + o['k'] +} + +let array1 = [0,1] +let array2 = [1,2,3,4,5] +let array3: number[] = [1,2,3,4,5] +let array4: Array = [1,2,3,4,5] +let array5 = new Array(10) +let array6 = new Int8Array(10) +let array7 = new Uint8Array(10) +let array8 = new Uint8ClampedArray(10) +let array9 = new Int16Array(10) +let array10 = new Uint16Array(10) +let array11 = new Int32Array(10) +let array12 = new Uint32Array(10) +let array13 = new Float32Array(10) +let array14 = new Float64Array(10) +let array15 = new BigInt64Array(10) +let array16 = new BigUint64Array(10) + +array1[0]; +array2[0]; +array3[0]; +array4[0]; +array5[0]; +array6[0]; +array7[0]; +array8[0]; +array9[0]; +array10[0]; +array11[0]; +array12[0]; +array13[0]; +array14[0]; +array15[0]; +array16[0]; + +function fff1(r: Record) { + r['bob'] +} + +enum CCCCCCCCC { + KATE, + BOB, + ROB, +} + +CCCCCCCCC['KATE'] +CCCCCCCCC['BOB'] +CCCCCCCCC['ROB'] + +CCCCCCCCC[CCCCCCCCC.KATE] +CCCCCCCCC[CCCCCCCCC.BOB] +CCCCCCCCC[CCCCCCCCC.ROB] diff --git a/linter-4.2/test/property_access_by_index.ts.autofix.json b/linter-4.2/test/property_access_by_index.ts.autofix.json index 90d724616..2c4552959 100644 --- a/linter-4.2/test/property_access_by_index.ts.autofix.json +++ b/linter-4.2/test/property_access_by_index.ts.autofix.json @@ -29,6 +29,30 @@ "autofixable": false, "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 45, + "column": 3, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 49, + "column": 3, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 56, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/property_access_by_index.ts.relax.json b/linter-4.2/test/property_access_by_index.ts.relax.json index e7d2d6779..6cefe0230 100644 --- a/linter-4.2/test/property_access_by_index.ts.relax.json +++ b/linter-4.2/test/property_access_by_index.ts.relax.json @@ -13,5 +13,13 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [] + "nodes": [ + { + "line": 56, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] } \ No newline at end of file diff --git a/linter-4.2/test/property_access_by_index.ts.strict.json b/linter-4.2/test/property_access_by_index.ts.strict.json index 816f247c7..6bb2b0400 100644 --- a/linter-4.2/test/property_access_by_index.ts.strict.json +++ b/linter-4.2/test/property_access_by_index.ts.strict.json @@ -27,6 +27,27 @@ "problem": "PropertyAccessByIndex", "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 45, + "column": 3, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 49, + "column": 3, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 56, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/types.ts.autofix.json b/linter-4.2/test/types.ts.autofix.json index 7833b9da0..3263fe492 100644 --- a/linter-4.2/test/types.ts.autofix.json +++ b/linter-4.2/test/types.ts.autofix.json @@ -214,6 +214,14 @@ "suggest": "", "rule": "\"in\" operator is not supported (arkts-no-in)" }, + { + "line": 78, + "column": 5, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 92, "column": 22, diff --git a/linter-4.2/test/types.ts.strict.json b/linter-4.2/test/types.ts.strict.json index 12af0241f..509711199 100644 --- a/linter-4.2/test/types.ts.strict.json +++ b/linter-4.2/test/types.ts.strict.json @@ -189,6 +189,13 @@ "suggest": "", "rule": "\"in\" operator is not supported (arkts-no-in)" }, + { + "line": 78, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 92, "column": 22, diff --git a/linter/docs/rules/recipe29.md b/linter/docs/rules/recipe29.md index c7be978d6..7af61c43e 100644 --- a/linter/docs/rules/recipe29.md +++ b/linter/docs/rules/recipe29.md @@ -10,9 +10,13 @@ that are either declared in the class, or accessible via inheritance. Accessing any other fields is prohibited, and causes compile-time errors. To access a field, use ``obj.field`` syntax, indexed access (``obj["field"]``) -is not supported. An exception are all typed arrays from the standard library -(for example, ``Int32Array``), which support access to their elements through -``container[index]`` syntax. +is not supported. An exception are: + +- All typed arrays from the standard library (for example, ``Int32Array``), which +support access to their elements through ``container[index]`` syntax. +- Tuples. +- Records. +- Enums. ## TypeScript diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 9c27f9a69..2280f0e45 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -527,7 +527,7 @@ export class TypeScriptLinter { private handleThrowStatement(node: ts.Node) { let throwStmt = node as ts.ThrowStatement; let throwExprType = this.tsTypeChecker.getTypeAtLocation(throwStmt.expression); - if (!throwExprType.isClassOrInterface() || !this.tsUtils.isDerivedFrom(throwExprType, CheckType.Error)) { + if (!throwExprType.isClassOrInterface() || !this.tsUtils.isOrDerivedFrom(throwExprType, this.tsUtils.isStdErrorType)) { this.incrementCounters(node, FaultID.ThrowStatement, false, undefined); } } @@ -1310,24 +1310,20 @@ export class TypeScriptLinter { const tsElementAccessExpr = node as ts.ElementAccessExpression; const tsElemAccessBaseExprType = this.tsUtils.getTypeOrTypeConstraintAtLocation(tsElementAccessExpr.expression); const tsElemAccessBaseExprTypeNode = this.tsTypeChecker.typeToTypeNode(tsElemAccessBaseExprType, undefined, ts.NodeBuilderFlags.None); - - const checkClassOrInterface = tsElemAccessBaseExprType.isClassOrInterface() && - !this.tsUtils.isGenericArrayType(tsElemAccessBaseExprType) && - !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); - const checkThisOrSuper = this.tsUtils.isThisOrSuperExpr(tsElementAccessExpr.expression) && - !this.tsUtils.isDerivedFrom(tsElemAccessBaseExprType, CheckType.Array); - - // implement check for enum argument expression - if ( - !this.tsUtils.isLibraryType(tsElemAccessBaseExprType) && !this.tsUtils.isTypedArray(tsElemAccessBaseExprTypeNode) && - (checkClassOrInterface || this.tsUtils.isObjectLiteralType(tsElemAccessBaseExprType) || checkThisOrSuper) + !this.tsUtils.isLibraryType(tsElemAccessBaseExprType) && + !ts.isArrayLiteralExpression(tsElementAccessExpr.expression) && + !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isArray) && + !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isTuple) && + !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isStdRecordType) && + !this.tsUtils.isEnumType(tsElemAccessBaseExprType) && + !this.tsUtils.isEsObjectType(tsElemAccessBaseExprTypeNode) ) { let autofix = Autofixer.fixPropertyAccessByIndex(node); const autofixable = autofix != undefined; - if (!this.autofixesInfo.shouldAutofix(node, FaultID.PropertyAccessByIndex)) + if (!this.autofixesInfo.shouldAutofix(node, FaultID.PropertyAccessByIndex)) { autofix = undefined; - + } this.incrementCounters(node, FaultID.PropertyAccessByIndex, autofixable, autofix); } @@ -1669,10 +1665,8 @@ export class TypeScriptLinter { let spreadElemNode = node as ts.SpreadElement; let spreadExprType = this.tsTypeChecker.getTypeAtLocation(spreadElemNode.expression); if (spreadExprType) { - const spreadExprTypeNode = this.tsTypeChecker.typeToTypeNode(spreadExprType, undefined, ts.NodeBuilderFlags.None); - if (spreadExprTypeNode !== undefined && (ts.isCallLikeExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) { - if (ts.isArrayTypeNode(spreadExprTypeNode) || this.tsUtils.isTypedArray(spreadExprTypeNode) || - this.tsUtils.isDerivedFrom(spreadExprType, CheckType.Array)) { + if (ts.isCallLikeExpression(node.parent) || ts.isArrayLiteralExpression(node.parent)) { + if (this.tsUtils.isOrDerivedFrom(spreadExprType, this.tsUtils.isArray)) { return } } diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index 39d31eed8..5bff6b0aa 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -25,24 +25,11 @@ import { pathContainsDirectory } from './functions/PathHelper'; import { ARKTS_IGNORE_DIRS, ARKTS_IGNORE_FILES } from './consts/ArktsIgnorePaths'; import { isAssignmentOperator } from './functions/isAssignmentOperator'; -export enum CheckType { - Array, - String = 'String', - Set = 'Set', - Map = 'Map', - Error = 'Error' -}; +export type CheckType = ((t: ts.Type) => boolean); export class TsUtils { constructor(private tsTypeChecker: ts.TypeChecker, private testMode: boolean, private advancedClassChecks: boolean) { } - public isTypedArray(tsType: ts.TypeNode | undefined): boolean { - if (tsType === undefined || !ts.isTypeReferenceNode(tsType)) { - return false; - } - return TYPED_ARRAYS.includes(this.entityNameToString(tsType.typeName)); - } - public isType(tsType: ts.TypeNode | undefined, checkType: string): boolean { if (tsType === undefined || !ts.isTypeReferenceNode(tsType)) { return false; @@ -282,24 +269,47 @@ export class TsUtils { ); } + public isTypedArray(tsType: ts.Type): boolean { + const symbol = tsType.symbol; + if (!symbol) { + return false; + } + const name = this.tsTypeChecker.getFullyQualifiedName(symbol); + return this.isGlobalSymbol(symbol) && TYPED_ARRAYS.includes(name); + } + + public isArray(tsType: ts.Type): boolean { + return this.isGenericArrayType(tsType) || this.isTypedArray(tsType); + } + + public isTuple(tsType: ts.Type): boolean { + return this.isTypeReference(tsType) && !!(tsType.objectFlags & ts.ObjectFlags.Tuple); + } + // does something similar to relatedByInheritanceOrIdentical function - public isDerivedFrom(tsType: ts.Type, checkType: CheckType): tsType is ts.TypeReference { - if (this.isTypeReference(tsType) && tsType.target !== tsType) tsType = tsType.target; + public isOrDerivedFrom(tsType: ts.Type, checkType: CheckType): tsType is ts.TypeReference { + if (this.isTypeReference(tsType) && tsType.target !== tsType) { + tsType = tsType.target; + } - const tsTypeNode = this.tsTypeChecker.typeToTypeNode(tsType, undefined, ts.NodeBuilderFlags.None); - if (checkType == CheckType.Array && (this.isGenericArrayType(tsType) || this.isTypedArray(tsTypeNode))) - return true; - if (checkType != CheckType.Array && this.isType(tsTypeNode, checkType.toString())) + if (checkType.call(this, tsType)) { return true; - if (!tsType.symbol || !tsType.symbol.declarations) return false; + } - for (let tsTypeDecl of tsType.symbol.declarations) { - if ( - (!ts.isClassDeclaration(tsTypeDecl) && !ts.isInterfaceDeclaration(tsTypeDecl)) || - !tsTypeDecl.heritageClauses - ) continue; + if (!tsType.symbol || !tsType.symbol.declarations) { + return false; + } + + for (const tsTypeDecl of tsType.symbol.declarations) { + const isClassOrInterfaceDecl = ts.isClassDeclaration(tsTypeDecl) || ts.isInterfaceDeclaration(tsTypeDecl); + const isDerived = isClassOrInterfaceDecl && !!tsTypeDecl.heritageClauses; + if (!isDerived) { + continue; + } for (let heritageClause of tsTypeDecl.heritageClauses) { - if (this.processParentTypesCheck(heritageClause.types, checkType)) return true; + if (this.processParentTypesCheck(heritageClause.types, checkType)) { + return true; + } } } @@ -595,10 +605,14 @@ export class TsUtils { } private processParentTypesCheck(parentTypes: ts.NodeArray, checkType: CheckType): boolean { - for (let baseTypeExpr of parentTypes) { + for (const baseTypeExpr of parentTypes) { let baseType = this.tsTypeChecker.getTypeAtLocation(baseTypeExpr); - if (this.isTypeReference(baseType) && baseType.target !== baseType) baseType = baseType.target; - if (baseType && this.isDerivedFrom(baseType, checkType)) return true; + if (this.isTypeReference(baseType) && baseType.target !== baseType) { + baseType = baseType.target; + } + if (baseType && this.isOrDerivedFrom(baseType, checkType)) { + return true; + } } return false; } @@ -945,6 +959,15 @@ export class TsUtils { return false; } + public isStdErrorType(type: ts.Type): boolean { + const symbol = type.symbol; + if (!symbol) { + return false; + } + const name = this.tsTypeChecker.getFullyQualifiedName(symbol); + return name === 'Error' && this.isGlobalSymbol(symbol); + } + public isStdPartialType(type: ts.Type): boolean { const sym = type.aliasSymbol; return !!sym && sym.getName() === 'Partial' && this.isGlobalSymbol(sym); @@ -994,11 +1017,11 @@ export class TsUtils { const isEts = (ext === '.ets'); const isTs = (ext === '.ts' && !srcFile.isDeclarationFile); const isStatic = (isEts || (isTs && this.testMode)) && !isThirdPartyCode; + const isStdLib = STANDARD_LIBRARIES.includes(path.basename(fileName).toLowerCase()); // We still need to confirm support for certain API from the // TypeScript standard library in ArkTS. Thus, for now do not - // count standard library modules. - return !isStatic && - !STANDARD_LIBRARIES.includes(path.basename(fileName).toLowerCase()); + // count standard library modules as dynamic. + return !isStatic && !isStdLib; } return false; } @@ -1110,8 +1133,8 @@ export class TsUtils { return false; } - public isEsObjectType(typeNode: ts.TypeNode): boolean { - return ts.isTypeReferenceNode(typeNode) && ts.isIdentifier(typeNode.typeName) && + public isEsObjectType(typeNode: ts.TypeNode | undefined): boolean { + return !!typeNode && ts.isTypeReferenceNode(typeNode) && ts.isIdentifier(typeNode.typeName) && typeNode.typeName.text == ES_OBJECT; } diff --git a/linter/test/array_literals.ts b/linter/test/array_literals.ts index 4c5e9de19..5889b08ba 100644 --- a/linter/test/array_literals.ts +++ b/linter/test/array_literals.ts @@ -124,4 +124,3 @@ class P { let a1 = [ { n:1, s:"1" } as P, { n:2, s:"2" } as P ]; // OK let a2: P[] = [ { n:3, s:"3" }, { n:4, s:"4" } ]; // OK let a3 = [ { n:1, s:"1" }, { n:2, s:"2" } ]; // NOT OK - \ No newline at end of file diff --git a/linter/test/es_object.ts b/linter/test/es_object.ts index 445b5c0c0..cd1e530ca 100644 --- a/linter/test/es_object.ts +++ b/linter/test/es_object.ts @@ -145,7 +145,7 @@ foo4([2, 3]) foo5([2, 3]) foo4(["str1", "str2"]) foo5(["str1", "str2"]) -let n = new ESObject[0] +let n: ESObject n = null foo4(n) diff --git a/linter/test/es_object.ts.relax.json b/linter/test/es_object.ts.relax.json index 7450fc30f..5bab1a3ee 100644 --- a/linter/test/es_object.ts.relax.json +++ b/linter/test/es_object.ts.relax.json @@ -521,9 +521,16 @@ { "line": 148, "column": 5, - "problem": "AnyType", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 149, + "column": 1, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, diff --git a/linter/test/es_object.ts.strict.json b/linter/test/es_object.ts.strict.json index 4909f595f..c0ef7ba37 100644 --- a/linter/test/es_object.ts.strict.json +++ b/linter/test/es_object.ts.strict.json @@ -329,6 +329,13 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, + { + "line": 79, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 79, "column": 5, @@ -521,9 +528,16 @@ { "line": 148, "column": 5, - "problem": "AnyType", + "problem": "EsObjectType", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 149, + "column": 1, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, { "line": 154, @@ -651,6 +665,13 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, + { + "line": 188, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 188, "column": 5, @@ -658,6 +679,13 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, + { + "line": 189, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 189, "column": 5, diff --git a/linter/test/function_expression.ts.autofix.json b/linter/test/function_expression.ts.autofix.json index c571fa05a..e005781ad 100644 --- a/linter/test/function_expression.ts.autofix.json +++ b/linter/test/function_expression.ts.autofix.json @@ -267,6 +267,14 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 82, + "column": 19, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 82, "column": 19, diff --git a/linter/test/function_expression.ts.strict.json b/linter/test/function_expression.ts.strict.json index fe4750449..48723e4cd 100644 --- a/linter/test/function_expression.ts.strict.json +++ b/linter/test/function_expression.ts.strict.json @@ -168,6 +168,13 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 82, + "column": 19, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 82, "column": 19, diff --git a/linter/test/property_access_by_index.ts b/linter/test/property_access_by_index.ts index 3911b881b..407d70553 100644 --- a/linter/test/property_access_by_index.ts +++ b/linter/test/property_access_by_index.ts @@ -28,3 +28,75 @@ function test() { SetProperty(a, 'u', 'def'); return GetProperty(a, 'v') + GetProperty(a, 'u'); } + +let ar1 = [1, 2, 3, 4]; +let ar2 = [1, '2', 3, 4]; +let ar3: number[] = []; + +ar1[2]; +ar2[2]; +ar3[2]; + +const r0 = [1, 2, 3][1]; +let r1 = [1, 2, 3, 4][0] +let r2 = [1, '2', 3, 4][0] + +function fobject1(o: object) { + o['j'] +} + +function fobject2(o: Object) { + o['k'] +} + +let array1 = [0,1] +let array2 = [1,2,3,4,5] +let array3: number[] = [1,2,3,4,5] +let array4: Array = [1,2,3,4,5] +let array5 = new Array(10) +let array6 = new Int8Array(10) +let array7 = new Uint8Array(10) +let array8 = new Uint8ClampedArray(10) +let array9 = new Int16Array(10) +let array10 = new Uint16Array(10) +let array11 = new Int32Array(10) +let array12 = new Uint32Array(10) +let array13 = new Float32Array(10) +let array14 = new Float64Array(10) +let array15 = new BigInt64Array(10) +let array16 = new BigUint64Array(10) + +array1[0]; +array2[0]; +array3[0]; +array4[0]; +array5[0]; +array6[0]; +array7[0]; +array8[0]; +array9[0]; +array10[0]; +array11[0]; +array12[0]; +array13[0]; +array14[0]; +array15[0]; +array16[0]; + +function fff1(r: Record) { + r['bob'] +} + +enum CCCCCCCCC { + KATE, + BOB, + ROB, +} + +CCCCCCCCC['KATE'] +CCCCCCCCC['BOB'] +CCCCCCCCC['ROB'] + +CCCCCCCCC[CCCCCCCCC.KATE] +CCCCCCCCC[CCCCCCCCC.BOB] +CCCCCCCCC[CCCCCCCCC.ROB] diff --git a/linter/test/property_access_by_index.ts.autofix.json b/linter/test/property_access_by_index.ts.autofix.json index 90d724616..2c4552959 100644 --- a/linter/test/property_access_by_index.ts.autofix.json +++ b/linter/test/property_access_by_index.ts.autofix.json @@ -29,6 +29,30 @@ "autofixable": false, "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 45, + "column": 3, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 49, + "column": 3, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 56, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.relax.json b/linter/test/property_access_by_index.ts.relax.json index e7d2d6779..6cefe0230 100644 --- a/linter/test/property_access_by_index.ts.relax.json +++ b/linter/test/property_access_by_index.ts.relax.json @@ -13,5 +13,13 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [] + "nodes": [ + { + "line": 56, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] } \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.strict.json b/linter/test/property_access_by_index.ts.strict.json index 816f247c7..6bb2b0400 100644 --- a/linter/test/property_access_by_index.ts.strict.json +++ b/linter/test/property_access_by_index.ts.strict.json @@ -27,6 +27,27 @@ "problem": "PropertyAccessByIndex", "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 45, + "column": 3, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 49, + "column": 3, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 56, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/test/types.ts.autofix.json b/linter/test/types.ts.autofix.json index 7833b9da0..3263fe492 100644 --- a/linter/test/types.ts.autofix.json +++ b/linter/test/types.ts.autofix.json @@ -214,6 +214,14 @@ "suggest": "", "rule": "\"in\" operator is not supported (arkts-no-in)" }, + { + "line": 78, + "column": 5, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 92, "column": 22, diff --git a/linter/test/types.ts.strict.json b/linter/test/types.ts.strict.json index 12af0241f..509711199 100644 --- a/linter/test/types.ts.strict.json +++ b/linter/test/types.ts.strict.json @@ -189,6 +189,13 @@ "suggest": "", "rule": "\"in\" operator is not supported (arkts-no-in)" }, + { + "line": 78, + "column": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, { "line": 92, "column": 22, -- Gitee From 214d1b1e0e87d8b259f85c7c905abe6f2f958fa1 Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Fri, 27 Oct 2023 11:24:59 +0300 Subject: [PATCH 19/23] [ArkTS Linter] #14184: Do not report 'Class used as object' for 'property access' on enum in namespace. Change-Id: I098a6d0ece73add8c0f259aa62b9389e71b38adc Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 14 +++++++++---- linter-4.2/test/class_as_object.ts | 21 ++++++++++++++++++- linter-4.2/test/class_as_object.ts.relax.json | 7 +++++++ .../test/class_as_object.ts.strict.json | 7 +++++++ linter/src/TypeScriptLinter.ts | 5 +++-- .../functions/identiferUseInValueContext.ts | 7 +++---- linter/test/class_as_object.ts | 21 ++++++++++++++++++- linter/test/class_as_object.ts.relax.json | 7 +++++++ linter/test/class_as_object.ts.strict.json | 7 +++++++ 9 files changed, 84 insertions(+), 12 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index dbed0dc62..b83c5eba8 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1515,8 +1515,9 @@ export class TypeScriptLinter { if (ts.isCallExpression(ctx.parent) || ts.isNewExpression(ctx.parent)) { let callee = ctx.parent.expression; - if (callee != ctx && (this.tsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(callee)) || - this.tsUtils.hasLibraryType(callee))) { + const isAny = this.tsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(callee)); + const isDynamic = isAny || this.tsUtils.hasLibraryType(callee); + if (callee != ctx && isDynamic) { return true; } } @@ -1567,8 +1568,7 @@ export class TypeScriptLinter { // treat TypeQuery as valid because it's already forbidden (FaultID.TypeQuery) (ts.isTypeNode(parent) && !ts.isTypeOfExpression(parent)) || // ElementAccess is allowed for enum types - (ts.isElementAccessExpression(parent) - && (parent as ts.ElementAccessExpression).expression == ident && (tsSym.flags & ts.SymbolFlags.Enum)) || + this.isEnumPropAccess(ident, tsSym, parent) || ts.isExpressionWithTypeArguments(parent) || ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) || @@ -1592,6 +1592,12 @@ export class TypeScriptLinter { ); } + private isEnumPropAccess(ident: ts.Identifier, tsSym: ts.Symbol, context: ts.Node): boolean { + return ts.isElementAccessExpression(context) && !!(tsSym.flags & ts.SymbolFlags.Enum) && + (context.expression == ident || + (ts.isPropertyAccessExpression(context.expression) && context.expression.name == ident)); + } + private handleElementAccessExpression(node: ts.Node) { const tsElementAccessExpr = node as ts.ElementAccessExpression; const tsElemAccessBaseExprType = this.tsUtils.getTypeOrTypeConstraintAtLocation(tsElementAccessExpr.expression); diff --git a/linter-4.2/test/class_as_object.ts b/linter-4.2/test/class_as_object.ts index 0cdc57d50..195c076ec 100644 --- a/linter-4.2/test/class_as_object.ts +++ b/linter-4.2/test/class_as_object.ts @@ -96,4 +96,23 @@ export { C as H }; let data = new Select().from(C).eq('key').query(C); // Ok invalid_func(C); // Ok let a: any; -a.foo(C); // Ok \ No newline at end of file +a.foo(C); // Ok + +let col = 'WHITE'; +console.log(Color[col]) + +// #14184 +namespace NS { + export enum E { + A = 'A', + B = 'B', + C = 'C' + } +} + +let s: string = 'B'; +let s2: string = NS.E[s]; + +for (let item = 0; item < Object.keys(NS.E).length; item++) { + console.log(item); +} \ No newline at end of file diff --git a/linter-4.2/test/class_as_object.ts.relax.json b/linter-4.2/test/class_as_object.ts.relax.json index 7032f676c..87b0d7889 100644 --- a/linter-4.2/test/class_as_object.ts.relax.json +++ b/linter-4.2/test/class_as_object.ts.relax.json @@ -123,6 +123,13 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 116, + "column": 42, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/class_as_object.ts.strict.json b/linter-4.2/test/class_as_object.ts.strict.json index 7032f676c..87b0d7889 100644 --- a/linter-4.2/test/class_as_object.ts.strict.json +++ b/linter-4.2/test/class_as_object.ts.strict.json @@ -123,6 +123,13 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 116, + "column": 42, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" } ] } \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 2280f0e45..be639762e 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1268,8 +1268,9 @@ export class TypeScriptLinter { if (ts.isCallExpression(ctx.parent) || ts.isNewExpression(ctx.parent)) { let callee = ctx.parent.expression; - if (callee != ctx && (this.tsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(callee)) || - this.tsUtils.hasLibraryType(callee))) { + const isAny = this.tsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(callee)); + const isDynamic = isAny || this.tsUtils.hasLibraryType(callee); + if (callee != ctx && isDynamic) { return true; } } diff --git a/linter/src/utils/functions/identiferUseInValueContext.ts b/linter/src/utils/functions/identiferUseInValueContext.ts index 43c1389a9..96a762c2d 100644 --- a/linter/src/utils/functions/identiferUseInValueContext.ts +++ b/linter/src/utils/functions/identiferUseInValueContext.ts @@ -43,11 +43,10 @@ function getQualifiedStart(ident: ts.Node): ts.Node { } function isEnumPropAccess(ident: ts.Identifier, tsSym: ts.Symbol, context: ts.Node): boolean { - return ts.isElementAccessExpression(context) && - (context as ts.ElementAccessExpression).expression == ident && - !!(tsSym.flags & ts.SymbolFlags.Enum); + return ts.isElementAccessExpression(context) && !!(tsSym.flags & ts.SymbolFlags.Enum) && + (context.expression == ident || + (ts.isPropertyAccessExpression(context.expression) && context.expression.name == ident)); } - function isValidTypeNode(node: ts.TypeNode): boolean { return !ts.isTypeOfExpression(node); } diff --git a/linter/test/class_as_object.ts b/linter/test/class_as_object.ts index 8a13dbfaa..6fa062cdc 100644 --- a/linter/test/class_as_object.ts +++ b/linter/test/class_as_object.ts @@ -96,4 +96,23 @@ export { C as H }; let data = new Select().from(C).eq('key').query(C); // Ok invalid_func(C); // Ok let a: any; -a.foo(C); // Ok \ No newline at end of file +a.foo(C); // Ok + +let col = 'WHITE'; +console.log(Color[col]) + +// #14184 +namespace NS { + export enum E { + A = 'A', + B = 'B', + C = 'C' + } +} + +let s: string = 'B'; +let s2: string = NS.E[s]; + +for (let item = 0; item < Object.keys(NS.E).length; item++) { + console.log(item); +} \ No newline at end of file diff --git a/linter/test/class_as_object.ts.relax.json b/linter/test/class_as_object.ts.relax.json index 75576a35f..ebe30080e 100644 --- a/linter/test/class_as_object.ts.relax.json +++ b/linter/test/class_as_object.ts.relax.json @@ -123,6 +123,13 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 116, + "column": 42, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" } ] } \ No newline at end of file diff --git a/linter/test/class_as_object.ts.strict.json b/linter/test/class_as_object.ts.strict.json index 75576a35f..ebe30080e 100644 --- a/linter/test/class_as_object.ts.strict.json +++ b/linter/test/class_as_object.ts.strict.json @@ -123,6 +123,13 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 116, + "column": 42, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" } ] } \ No newline at end of file -- Gitee From f32f4eeae7c55aefc473cebe1e7f3ce5909680eb Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Wed, 1 Nov 2023 14:34:06 +0300 Subject: [PATCH 20/23] [arkts-linter] update error count in CookBookMessage.ts Signed-off-by: Nazarov Konstantin --- linter-4.2/src/CookBookMsg.ts | 2 +- linter/src/CookBookMsg.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index a5897f0e2..e505f59a8 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -16,7 +16,7 @@ export const cookBookMsg: string[] = []; export const cookBookTag: string[] = []; -for (let i = 0; i <= 150; i++) { +for (let i = 0; i <= 151; i++) { cookBookMsg[i] = ''; } diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index c62bafe14..d8f053a4e 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -16,7 +16,7 @@ export const cookBookMsg: string[] = []; export const cookBookTag: string[] = []; -for (let i = 0; i <= 150; i++) { +for (let i = 0; i <= 151; i++) { cookBookMsg[i] = ''; } -- Gitee From 09bd7137bbe760e77287696895bf91169234d9c3 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Thu, 2 Nov 2023 13:42:26 +0300 Subject: [PATCH 21/23] [arkts-linter] follow-up for #14183 - allow indexed access for any Signed-off-by: Nazarov Konstantin --- linter-4.2/src/TypeScriptLinter.ts | 1 + linter-4.2/test/es_object.ts.strict.json | 21 ------------------- linter-4.2/test/property_access_by_index.ts | 19 +++++++++++++++++ .../property_access_by_index.ts.autofix.json | 16 ++++++++++++++ .../property_access_by_index.ts.relax.json | 14 +++++++++++++ .../property_access_by_index.ts.strict.json | 14 +++++++++++++ linter/src/TypeScriptLinter.ts | 1 + linter/test/es_object.ts.strict.json | 21 ------------------- linter/test/property_access_by_index.ts | 19 +++++++++++++++++ .../property_access_by_index.ts.autofix.json | 16 ++++++++++++++ .../property_access_by_index.ts.relax.json | 14 +++++++++++++ .../property_access_by_index.ts.strict.json | 14 +++++++++++++ 12 files changed, 128 insertions(+), 42 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index b83c5eba8..7c90cb2d4 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -1608,6 +1608,7 @@ export class TypeScriptLinter { ); if ( !this.tsUtils.isLibraryType(tsElemAccessBaseExprType) && + !this.tsUtils.isAnyType(tsElemAccessBaseExprType) && !ts.isArrayLiteralExpression(tsElementAccessExpr.expression) && !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isArray) && !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isTuple) && diff --git a/linter-4.2/test/es_object.ts.strict.json b/linter-4.2/test/es_object.ts.strict.json index c0ef7ba37..86c0f49ac 100644 --- a/linter-4.2/test/es_object.ts.strict.json +++ b/linter-4.2/test/es_object.ts.strict.json @@ -329,13 +329,6 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, - { - "line": 79, - "column": 5, - "problem": "PropertyAccessByIndex", - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" - }, { "line": 79, "column": 5, @@ -665,13 +658,6 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, - { - "line": 188, - "column": 5, - "problem": "PropertyAccessByIndex", - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" - }, { "line": 188, "column": 5, @@ -679,13 +665,6 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, - { - "line": 189, - "column": 5, - "problem": "PropertyAccessByIndex", - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" - }, { "line": 189, "column": 5, diff --git a/linter-4.2/test/property_access_by_index.ts b/linter-4.2/test/property_access_by_index.ts index 407d70553..03b2c8f71 100644 --- a/linter-4.2/test/property_access_by_index.ts +++ b/linter-4.2/test/property_access_by_index.ts @@ -100,3 +100,22 @@ CCCCCCCCC['ROB'] CCCCCCCCC[CCCCCCCCC.KATE] CCCCCCCCC[CCCCCCCCC.BOB] CCCCCCCCC[CCCCCCCCC.ROB] + +let arr32 = new Float32Array([1,2,3]) + +let iter_arr32 = arr32[Symbol.iterator]() +let tmp_arr32 = iter_arr32.next().value; +while (!!tmp_arr32) { + console.log(tmp_arr32[0]) + + tmp_arr32 = iter_arr32.next().value +} + +let arr = new Array() +arr = ['a','f','g'] +let iter_arr = arr[Symbol.iterator]() +let tmp_arr = iter_arr.next().value; +while (!!tmp_arr) { + console.log(tmp_arr[0]) + tmp_arr = iter_arr.next().value +} diff --git a/linter-4.2/test/property_access_by_index.ts.autofix.json b/linter-4.2/test/property_access_by_index.ts.autofix.json index 2c4552959..df5e23653 100644 --- a/linter-4.2/test/property_access_by_index.ts.autofix.json +++ b/linter-4.2/test/property_access_by_index.ts.autofix.json @@ -53,6 +53,22 @@ "autofixable": false, "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 107, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 117, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/property_access_by_index.ts.relax.json b/linter-4.2/test/property_access_by_index.ts.relax.json index 6cefe0230..b492ed738 100644 --- a/linter-4.2/test/property_access_by_index.ts.relax.json +++ b/linter-4.2/test/property_access_by_index.ts.relax.json @@ -20,6 +20,20 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 107, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 117, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter-4.2/test/property_access_by_index.ts.strict.json b/linter-4.2/test/property_access_by_index.ts.strict.json index 6bb2b0400..daf068f0d 100644 --- a/linter-4.2/test/property_access_by_index.ts.strict.json +++ b/linter-4.2/test/property_access_by_index.ts.strict.json @@ -48,6 +48,20 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 107, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 117, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index be639762e..0877b7bda 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1313,6 +1313,7 @@ export class TypeScriptLinter { const tsElemAccessBaseExprTypeNode = this.tsTypeChecker.typeToTypeNode(tsElemAccessBaseExprType, undefined, ts.NodeBuilderFlags.None); if ( !this.tsUtils.isLibraryType(tsElemAccessBaseExprType) && + !this.tsUtils.isAnyType(tsElemAccessBaseExprType) && !ts.isArrayLiteralExpression(tsElementAccessExpr.expression) && !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isArray) && !this.tsUtils.isOrDerivedFrom(tsElemAccessBaseExprType, this.tsUtils.isTuple) && diff --git a/linter/test/es_object.ts.strict.json b/linter/test/es_object.ts.strict.json index c0ef7ba37..86c0f49ac 100644 --- a/linter/test/es_object.ts.strict.json +++ b/linter/test/es_object.ts.strict.json @@ -329,13 +329,6 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, - { - "line": 79, - "column": 5, - "problem": "PropertyAccessByIndex", - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" - }, { "line": 79, "column": 5, @@ -665,13 +658,6 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, - { - "line": 188, - "column": 5, - "problem": "PropertyAccessByIndex", - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" - }, { "line": 188, "column": 5, @@ -679,13 +665,6 @@ "suggest": "", "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" }, - { - "line": 189, - "column": 5, - "problem": "PropertyAccessByIndex", - "suggest": "", - "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" - }, { "line": 189, "column": 5, diff --git a/linter/test/property_access_by_index.ts b/linter/test/property_access_by_index.ts index 407d70553..d7cd6781f 100644 --- a/linter/test/property_access_by_index.ts +++ b/linter/test/property_access_by_index.ts @@ -100,3 +100,22 @@ CCCCCCCCC['ROB'] CCCCCCCCC[CCCCCCCCC.KATE] CCCCCCCCC[CCCCCCCCC.BOB] CCCCCCCCC[CCCCCCCCC.ROB] + +let arr32 = new Float32Array([1,2,3]) + +let iter_arr32 = arr32[Symbol.iterator]() +let tmp_arr32 = iter_arr32.next().value; +while (!!tmp_arr32) { + console.log(tmp_arr32[0]) + + tmp_arr32 = iter_arr32.next().value +} + +let arr = new Array() +arr = ['a','f','g'] +let iter_arr = arr[Symbol.iterator]() +let tmp_arr = iter_arr.next().value; +while (!!tmp_arr) { + console.log(tmp_arr[0]) + tmp_arr = iter_arr.next().value +} \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.autofix.json b/linter/test/property_access_by_index.ts.autofix.json index 2c4552959..df5e23653 100644 --- a/linter/test/property_access_by_index.ts.autofix.json +++ b/linter/test/property_access_by_index.ts.autofix.json @@ -53,6 +53,22 @@ "autofixable": false, "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 107, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 117, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.relax.json b/linter/test/property_access_by_index.ts.relax.json index 6cefe0230..b492ed738 100644 --- a/linter/test/property_access_by_index.ts.relax.json +++ b/linter/test/property_access_by_index.ts.relax.json @@ -20,6 +20,20 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 107, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 117, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file diff --git a/linter/test/property_access_by_index.ts.strict.json b/linter/test/property_access_by_index.ts.strict.json index 6bb2b0400..daf068f0d 100644 --- a/linter/test/property_access_by_index.ts.strict.json +++ b/linter/test/property_access_by_index.ts.strict.json @@ -48,6 +48,20 @@ "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 107, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 117, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" } ] } \ No newline at end of file -- Gitee From 2fb32cb819968b3183ca11bff0bf98ba16365f6c Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Thu, 2 Nov 2023 14:32:07 +0300 Subject: [PATCH 22/23] [ArkTS Linter] Fix #14305: Retrieve list of unsupported comment directives from SourceFile node. Change-Id: Id390b41dea000f09bd36a7237a345db475f70d6b Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 40 ++++++++++++++++++++++-- linter-4.2/test/ts_ignore.ts | 15 +++++++-- linter-4.2/test/ts_ignore.ts.relax.json | 28 ++++++++--------- linter-4.2/test/ts_ignore.ts.strict.json | 28 ++++++++--------- linter/src/TypeScriptLinter.ts | 40 +++++++++++++++++++++++- linter/test/ts_ignore.ts | 15 +++++++-- linter/test/ts_ignore.ts.relax.json | 28 ++++++++--------- linter/test/ts_ignore.ts.strict.json | 28 ++++++++--------- 8 files changed, 159 insertions(+), 63 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index b83c5eba8..7f1e4bdbb 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -242,8 +242,6 @@ export class TypeScriptLinter { return; } - self.handleComments(node); - if (LinterConfig.terminalTokens.has(node.kind)) return; let incrementedType = LinterConfig.incrementOnlyTokens.get(node.kind); @@ -2226,9 +2224,47 @@ export class TypeScriptLinter { this.incrementCounters(decl, FaultID.UnknownType); } + private handleCommentDirectives(sourceFile: ts.SourceFile) { + // We use a dirty hack to retrieve list of parsed comment directives by accessing + // internal properties of SourceFile node. + + // Handle comment directive '@ts-nocheck' + let pragmas = (sourceFile as any)['pragmas']; + if (pragmas && pragmas instanceof Map) { + for (const pragma of pragmas) { + if (pragma[0] !== 'ts-nocheck' || !pragma[1]?.range.kind || !pragma[1]?.range.pos || !pragma[1]?.range.end) { + continue; + } + + this.incrementCounters(pragma[1].range as ts.CommentRange, FaultID.ErrorSuppression); + } + } + + // Handle comment directives '@ts-ignore' and '@ts-expect-error' + let commentDirectives = (sourceFile as any)['commentDirectives']; + if (commentDirectives && Array.isArray(commentDirectives)) { + for (const directive of commentDirectives) { + if (!directive.range?.pos || !directive.range?.end) continue; + + const range = directive.range as ts.TextRange; + const kind: ts.SyntaxKind = sourceFile.text.slice(range.pos, range.pos + 2) === '/*' + ? ts.SyntaxKind.MultiLineCommentTrivia + : ts.SyntaxKind.SingleLineCommentTrivia; + let commentRange: ts.CommentRange = { + pos: range.pos, + end: range.end, + kind + }; + + this.incrementCounters(commentRange, FaultID.ErrorSuppression); + } + } + } + public lint(sourceFile: ts.SourceFile) { this.walkedComments.clear(); this.sourceFile = sourceFile; this.visitTSNode(this.sourceFile); + this.handleCommentDirectives(this.sourceFile); } } diff --git a/linter-4.2/test/ts_ignore.ts b/linter-4.2/test/ts_ignore.ts index 3676a1550..5cee01903 100644 --- a/linter-4.2/test/ts_ignore.ts +++ b/linter-4.2/test/ts_ignore.ts @@ -31,11 +31,11 @@ let b: number = null; console.log("Hello" * 42); /* - @ts-expect-error + @ts-expect-error (shouldn't be reported) */ console.log("Hello" * 42); -// no @ts-expect-error +// no @ts-expect-error (shouldn't be reported) console.log("Hello" * 42); const l1 = (): void => { @@ -74,3 +74,14 @@ class ChainedCallsClass { let cc = new ChainedCallsClass() // @ts-ignore .methodOne().methodTwo(); + +// #14305 +/* +@ts-ignore (shouldn't be reported) + */ +let c: number = '1'; + +/* + @ts-ignore (shouldn't be reported) + */ +let d: number = '1'; \ No newline at end of file diff --git a/linter-4.2/test/ts_ignore.ts.relax.json b/linter-4.2/test/ts_ignore.ts.relax.json index 8e4a16c18..f802c561b 100644 --- a/linter-4.2/test/ts_ignore.ts.relax.json +++ b/linter-4.2/test/ts_ignore.ts.relax.json @@ -14,6 +14,20 @@ "limitations under the License." ], "nodes": [ + { + "line": 53, + "column": 3, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 55, + "column": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, { "line": 16, "column": 1, @@ -56,20 +70,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 53, - "column": 3, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, { "line": 56, "column": 9, diff --git a/linter-4.2/test/ts_ignore.ts.strict.json b/linter-4.2/test/ts_ignore.ts.strict.json index 8e4a16c18..f802c561b 100644 --- a/linter-4.2/test/ts_ignore.ts.strict.json +++ b/linter-4.2/test/ts_ignore.ts.strict.json @@ -14,6 +14,20 @@ "limitations under the License." ], "nodes": [ + { + "line": 53, + "column": 3, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 55, + "column": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, { "line": 16, "column": 1, @@ -56,20 +70,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 53, - "column": 3, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, { "line": 56, "column": 9, diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index be639762e..9b9569c1d 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -251,7 +251,7 @@ export class TypeScriptLinter { self.handleStructDeclaration(node); return; } - self.handleComments(node); + if (LinterConfig.terminalTokens.has(node.kind)) { return; } @@ -1880,9 +1880,47 @@ export class TypeScriptLinter { } } + private handleCommentDirectives(sourceFile: ts.SourceFile) { + // We use a dirty hack to retrieve list of parsed comment directives by accessing + // internal properties of SourceFile node. + + // Handle comment directive '@ts-nocheck' + let pragmas = (sourceFile as any)['pragmas']; + if (pragmas && pragmas instanceof Map) { + for (const pragma of pragmas) { + if (pragma[0] !== 'ts-nocheck' || !pragma[1]?.range.kind || !pragma[1]?.range.pos || !pragma[1]?.range.end) { + continue; + } + + this.incrementCounters(pragma[1].range as ts.CommentRange, FaultID.ErrorSuppression); + } + } + + // Handle comment directives '@ts-ignore' and '@ts-expect-error' + let commentDirectives = (sourceFile as any)['commentDirectives']; + if (commentDirectives && Array.isArray(commentDirectives)) { + for (const directive of commentDirectives) { + if (!directive.range?.pos || !directive.range?.end) continue; + + const range = directive.range as ts.TextRange; + const kind: ts.SyntaxKind = sourceFile.text.slice(range.pos, range.pos + 2) === '/*' + ? ts.SyntaxKind.MultiLineCommentTrivia + : ts.SyntaxKind.SingleLineCommentTrivia; + let commentRange: ts.CommentRange = { + pos: range.pos, + end: range.end, + kind + }; + + this.incrementCounters(commentRange, FaultID.ErrorSuppression); + } + } + } + public lint(sourceFile: ts.SourceFile) { this.walkedComments.clear(); this.sourceFile = sourceFile; this.visitTSNode(this.sourceFile); + this.handleCommentDirectives(this.sourceFile); } } diff --git a/linter/test/ts_ignore.ts b/linter/test/ts_ignore.ts index 3676a1550..5cee01903 100644 --- a/linter/test/ts_ignore.ts +++ b/linter/test/ts_ignore.ts @@ -31,11 +31,11 @@ let b: number = null; console.log("Hello" * 42); /* - @ts-expect-error + @ts-expect-error (shouldn't be reported) */ console.log("Hello" * 42); -// no @ts-expect-error +// no @ts-expect-error (shouldn't be reported) console.log("Hello" * 42); const l1 = (): void => { @@ -74,3 +74,14 @@ class ChainedCallsClass { let cc = new ChainedCallsClass() // @ts-ignore .methodOne().methodTwo(); + +// #14305 +/* +@ts-ignore (shouldn't be reported) + */ +let c: number = '1'; + +/* + @ts-ignore (shouldn't be reported) + */ +let d: number = '1'; \ No newline at end of file diff --git a/linter/test/ts_ignore.ts.relax.json b/linter/test/ts_ignore.ts.relax.json index 8e4a16c18..f802c561b 100644 --- a/linter/test/ts_ignore.ts.relax.json +++ b/linter/test/ts_ignore.ts.relax.json @@ -14,6 +14,20 @@ "limitations under the License." ], "nodes": [ + { + "line": 53, + "column": 3, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 55, + "column": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, { "line": 16, "column": 1, @@ -56,20 +70,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 53, - "column": 3, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, { "line": 56, "column": 9, diff --git a/linter/test/ts_ignore.ts.strict.json b/linter/test/ts_ignore.ts.strict.json index 8e4a16c18..f802c561b 100644 --- a/linter/test/ts_ignore.ts.strict.json +++ b/linter/test/ts_ignore.ts.strict.json @@ -14,6 +14,20 @@ "limitations under the License." ], "nodes": [ + { + "line": 53, + "column": 3, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 55, + "column": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, { "line": 16, "column": 1, @@ -56,20 +70,6 @@ "suggest": "", "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, - { - "line": 53, - "column": 3, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, { "line": 56, "column": 9, -- Gitee From fbf67f4f6e5c13dabb8e8a1ac157a518e3797c35 Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Fri, 3 Nov 2023 03:44:07 +0300 Subject: [PATCH 23/23] [arkts-linter] fix #14330 Signed-off-by: Nazarov Konstantin --- linter/src/TypeScriptLinter.ts | 188 +++++++++--------- linter/src/utils/functions/ContainsThis.ts | 46 ++--- linter/test/classB.ts.relax.json | 4 +- linter/test/classB.ts.strict.json | 4 +- .../function_object_methods.ts.relax.json | 16 +- .../function_object_methods.ts.strict.json | 16 +- linter/test/functions.ts.autofix.json | 4 +- linter/test/functions.ts.relax.json | 4 +- linter/test/functions.ts.strict.json | 4 +- .../test/prototype_assignment.ts.autofix.json | 12 +- .../test/prototype_assignment.ts.relax.json | 12 +- .../test/prototype_assignment.ts.strict.json | 12 +- linter/test/this_type.ts.relax.json | 20 +- linter/test/this_type.ts.strict.json | 20 +- linter/test/utility_types.ts.relax.json | 17 +- linter/test/utility_types.ts.strict.json | 17 +- linter/test_rules/rule136.ts.autofix.json | 8 +- linter/test_rules/rule136.ts.relax.json | 8 +- linter/test_rules/rule136.ts.strict.json | 8 +- linter/test_rules/rule93.ts.autofix.json | 4 +- linter/test_rules/rule93.ts.relax.json | 4 +- linter/test_rules/rule93.ts.strict.json | 4 +- 22 files changed, 225 insertions(+), 207 deletions(-) diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 863cd0542..ff736aa8d 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -235,45 +235,55 @@ export class TypeScriptLinter { } } - private visitTSNode(node: ts.Node): void { - const self = this; - visitTSNodeImpl(node); - function visitTSNodeImpl(node: ts.Node): void { - if (node === null || node.kind === null) { - return; - } - if (self.incrementalLintInfo?.shouldSkipCheck(node)) { - return; - } + private forEachNodeInSubtree(node: ts.Node, cb: (n: ts.Node) => void, stopCond?: (n: ts.Node) => boolean) { + cb.call(this, node); + if (stopCond?.call(this, node)) { + return; + } + // #13972: The 'ts.forEachChild' doesn't iterate over in-between punctuation tokens. + // As result, we can miss comment directives attached to those. Instead, use 'node.getChildren()'. + // to traverse child nodes. + for (const child of node.getChildren()) { + this.forEachNodeInSubtree(child, cb, stopCond) + } + } - self.totalVisitedNodes++; + private visitSourceFile(sf: ts.SourceFile): void { + const callback = (node: ts.Node) => { + this.totalVisitedNodes++; if (isStructDeclaration(node)) { - self.handleStructDeclaration(node); - return; - } - - if (LinterConfig.terminalTokens.has(node.kind)) { - return; + // early exit via exception if cancellation was requested + this.cancellationToken?.throwIfCancellationRequested(); } - let incrementedType = LinterConfig.incrementOnlyTokens.get(node.kind); + const incrementedType = LinterConfig.incrementOnlyTokens.get(node.kind); if (incrementedType !== undefined) { - self.incrementCounters(node, incrementedType); + this.incrementCounters(node, incrementedType); } else { - let handler = self.handlersMap.get(node.kind); + const handler = this.handlersMap.get(node.kind); if (handler !== undefined) { // possibly requested cancellation will be checked in a limited number of handlers // checked nodes are selected as construct nodes, similar to how TSC does - handler.call(self, node); + handler.call(this, node); } } - - // #13972: The 'ts.forEachChild' doesn't iterate over in-between punctuation tokens. - // As result, we can miss comment directives attached to those. Instead, use 'node.getChildren()'. - // to traverse child nodes. - for (const child of node.getChildren()) { - visitTSNodeImpl(child); + } + const stopCondition = (node: ts.Node) => { + if (node === null || node.kind === null) { + return true; + } + if (this.incrementalLintInfo?.shouldSkipCheck(node)) { + return true; + } + // Skip synthetic constructor in Struct declaration. + if (node.parent && isStructDeclaration(node.parent) && ts.isConstructorDeclaration(node)) { + return true; + } + if (LinterConfig.terminalTokens.has(node.kind)) { + return true; } + return false; } + this.forEachNodeInSubtree(sf, callback, stopCondition); } private countInterfaceExtendsDifferentPropertyTypes( @@ -736,30 +746,31 @@ export class TypeScriptLinter { return true; } + private static isClassLikeOrIface(node: ts.Node): boolean { + return ts.isClassLike(node) || ts.isInterfaceDeclaration(node); + } + private handleFunctionExpression(node: ts.Node) { const funcExpr = node as ts.FunctionExpression; - const isGenerator = funcExpr.asteriskToken !== undefined; - const containsThis = scopeContainsThis(funcExpr.body); - const hasValidContext = hasPredecessor(funcExpr, ts.isClassLike) || - hasPredecessor(funcExpr, ts.isInterfaceDeclaration); const isGeneric = funcExpr.typeParameters !== undefined && funcExpr.typeParameters.length > 0; + const isGenerator = funcExpr.asteriskToken !== undefined; + const hasThisKeyword = scopeContainsThis(funcExpr.body); const isCalledRecursively = this.tsUtils.isFunctionCalledRecursively(funcExpr); const [hasUnfixableReturnType, newRetTypeNode] = this.handleMissingReturnType(funcExpr); - const autofixable = !isGeneric && !isGenerator && !containsThis && !hasUnfixableReturnType && - !isCalledRecursively; + const autofixable = !isGeneric && !isGenerator && !hasThisKeyword && !isCalledRecursively && !hasUnfixableReturnType; let autofix: Autofix[] | undefined; - if (autofixable && this.autofixesInfo.shouldAutofix(node, FaultID.FunctionExpression)) { - autofix = [ Autofixer.fixFunctionExpression(funcExpr, funcExpr.parameters, newRetTypeNode, ts.getModifiers(funcExpr)) ]; + if (autofixable && this.autofixesInfo.shouldAutofix(funcExpr, FaultID.FunctionExpression)) { + autofix = [Autofixer.fixFunctionExpression(funcExpr, funcExpr.parameters, newRetTypeNode, ts.getModifiers(funcExpr))]; } - this.incrementCounters(node, FaultID.FunctionExpression, autofixable, autofix); + this.incrementCounters(funcExpr, FaultID.FunctionExpression, autofixable, autofix); if (isGeneric) { this.incrementCounters(funcExpr, FaultID.LambdaWithTypeParameters); } if (isGenerator) { this.incrementCounters(funcExpr, FaultID.GeneratorFunction); } - if (containsThis && !hasValidContext) { - this.incrementCounters(funcExpr, FaultID.FunctionContainsThis); + if (!hasPredecessor(funcExpr, TypeScriptLinter.isClassLikeOrIface)) { + this.reportThisKeywordsInScope(funcExpr.body); } if (hasUnfixableReturnType) { this.incrementCounters(funcExpr, FaultID.LimitedReturnTypeInference); @@ -768,11 +779,8 @@ export class TypeScriptLinter { private handleArrowFunction(node: ts.Node) { const arrowFunc = node as ts.ArrowFunction; - const containsThis = scopeContainsThis(arrowFunc.body); - const hasValidContext = hasPredecessor(arrowFunc, ts.isClassLike) || - hasPredecessor(arrowFunc, ts.isInterfaceDeclaration); - if (containsThis && !hasValidContext) { - this.incrementCounters(arrowFunc, FaultID.FunctionContainsThis); + if (!hasPredecessor(arrowFunc, TypeScriptLinter.isClassLikeOrIface)) { + this.reportThisKeywordsInScope(arrowFunc.body); } const contextType = this.tsTypeChecker.getContextualType(arrowFunc); if (!(contextType && this.tsUtils.isLibraryType(contextType))) { @@ -795,17 +803,18 @@ export class TypeScriptLinter { // early exit via exception if cancellation was requested this.cancellationToken?.throwIfCancellationRequested(); - let tsFunctionDeclaration = node as ts.FunctionDeclaration; + const tsFunctionDeclaration = node as ts.FunctionDeclaration; if (!tsFunctionDeclaration.type) { this.handleMissingReturnType(tsFunctionDeclaration); } if (tsFunctionDeclaration.name) { this.countDeclarationsWithDuplicateName(tsFunctionDeclaration.name, tsFunctionDeclaration); } - if (tsFunctionDeclaration.body && scopeContainsThis(tsFunctionDeclaration.body)) { - this.incrementCounters(node, FaultID.FunctionContainsThis); + if (tsFunctionDeclaration.body) { + this.reportThisKeywordsInScope(tsFunctionDeclaration.body); } - if (!ts.isSourceFile(tsFunctionDeclaration.parent) && !ts.isModuleBlock(tsFunctionDeclaration.parent)) { + const funcDeclParent = tsFunctionDeclaration.parent; + if (!ts.isSourceFile(funcDeclParent) && !ts.isModuleBlock(funcDeclParent)) { this.incrementCounters(tsFunctionDeclaration, FaultID.LocalFunction); } if (tsFunctionDeclaration.asteriskToken) { @@ -857,30 +866,27 @@ export class TypeScriptLinter { private hasLimitedTypeInferenceFromReturnExpr(funBody: ts.ConciseBody): boolean { let hasLimitedTypeInference = false; - const self = this; - function visitNode(tsNode: ts.Node): void { + const callback = (node: ts.Node) => { if (hasLimitedTypeInference) { return; } if ( - ts.isReturnStatement(tsNode) && tsNode.expression && - self.tsUtils.isCallToFunctionWithOmittedReturnType(self.tsUtils.unwrapParenthesized(tsNode.expression)) + ts.isReturnStatement(node) && node.expression && + this.tsUtils.isCallToFunctionWithOmittedReturnType(this.tsUtils.unwrapParenthesized(node.expression)) ) { hasLimitedTypeInference = true; - return; } - // Visit children nodes. Don't traverse other nested function-like declarations. - if ( - !ts.isFunctionDeclaration(tsNode) && - !ts.isFunctionExpression(tsNode) && - !ts.isMethodDeclaration(tsNode) && - !ts.isAccessor(tsNode) && - !ts.isArrowFunction(tsNode) - ) - tsNode.forEachChild(visitNode); + } + // Don't traverse other nested function-like declarations. + const stopCondition = (node: ts.Node) => { + return ts.isFunctionDeclaration(node) || + ts.isFunctionExpression(node) || + ts.isMethodDeclaration(node) || + ts.isAccessor(node) || + ts.isArrowFunction(node); } if (ts.isBlock(funBody)) { - visitNode(funBody); + this.forEachNodeInSubtree(funBody, callback, stopCondition); } else { const tsExpr = this.tsUtils.unwrapParenthesized(funBody); hasLimitedTypeInference = this.tsUtils.isCallToFunctionWithOmittedReturnType(tsExpr); @@ -1187,18 +1193,17 @@ export class TypeScriptLinter { private handleMethodDeclaration(node: ts.Node) { const tsMethodDecl = node as ts.MethodDeclaration; - const hasThis = scopeContainsThis(tsMethodDecl); let isStatic = false if (tsMethodDecl.modifiers) { - for (let mod of tsMethodDecl.modifiers) { + for (const mod of tsMethodDecl.modifiers) { if (mod.kind === ts.SyntaxKind.StaticKeyword) { isStatic = true; break; } } } - if (isStatic && hasThis) { - this.incrementCounters(node, FaultID.FunctionContainsThis); + if (tsMethodDecl.body && isStatic) { + this.reportThisKeywordsInScope(tsMethodDecl.body); } if (!tsMethodDecl.type) { this.handleMissingReturnType(tsMethodDecl); @@ -1220,19 +1225,18 @@ export class TypeScriptLinter { } private handleClassStaticBlockDeclaration(node: ts.Node) { - if (ts.isClassDeclaration(node.parent)) { - const tsClassDecl = node.parent as ts.ClassDeclaration; - let className = ''; - if (tsClassDecl.name) - // May be undefined in `export default class { ... }`. - className = tsClassDecl.name.text; - if (scopeContainsThis(node)) { - this.incrementCounters(node, FaultID.FunctionContainsThis); - } - if (this.staticBlocks.has(className)) - this.incrementCounters(node, FaultID.MultipleStaticBlocks); - else - this.staticBlocks.add(className); + const classStaticBlockDecl = node as ts.ClassStaticBlockDeclaration; + const parent = classStaticBlockDecl.parent; + if (!ts.isClassDeclaration(parent)) { + return; + } + this.reportThisKeywordsInScope(classStaticBlockDecl.body); + // May be undefined in `export default class { ... }`. + const className = parent.name?.text ?? ''; + if (this.staticBlocks.has(className)) { + this.incrementCounters(classStaticBlockDecl, FaultID.MultipleStaticBlocks); + } else { + this.staticBlocks.add(className); } } @@ -1650,16 +1654,6 @@ export class TypeScriptLinter { } } - private handleStructDeclaration(node: ts.Node) { - // early exit via exception if cancellation was requested - this.cancellationToken?.throwIfCancellationRequested(); - - node.forEachChild(child => { - // Skip synthetic constructor in Struct declaration. - if (!ts.isConstructorDeclaration(child)) this.visitTSNode(child); - }); - } - private handleSpreadOp(node: ts.Node) { // spread assignment is disabled // spread element is allowed only for arrays as rest parameter @@ -1917,11 +1911,25 @@ export class TypeScriptLinter { } } } + private reportThisKeywordsInScope(scope: ts.Block | ts.Expression): void { + const callback = (node: ts.Node) => { + if (node.kind === ts.SyntaxKind.ThisKeyword) { + this.incrementCounters(node, FaultID.FunctionContainsThis); + } + } + const stopCondition = (node: ts.Node) => { + const isClassLike = ts.isClassDeclaration(node) || ts.isClassExpression(node); + const isFunctionLike = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node); + const isModuleDecl = ts.isModuleDeclaration(node); + return isClassLike || isFunctionLike || isModuleDecl; + } + this.forEachNodeInSubtree(scope, callback, stopCondition); + } public lint(sourceFile: ts.SourceFile) { this.walkedComments.clear(); this.sourceFile = sourceFile; - this.visitTSNode(this.sourceFile); + this.visitSourceFile(this.sourceFile); this.handleCommentDirectives(this.sourceFile); } } diff --git a/linter/src/utils/functions/ContainsThis.ts b/linter/src/utils/functions/ContainsThis.ts index a0cccbb1c..b5a199765 100644 --- a/linter/src/utils/functions/ContainsThis.ts +++ b/linter/src/utils/functions/ContainsThis.ts @@ -15,28 +15,28 @@ import * as ts from 'typescript'; -export function scopeContainsThis(tsNode: ts.Node): boolean { - let found = false; - function visitNode(tsNode: ts.Node) { - // Stop visiting child nodes if finished searching. - if (found) { - return; - } - if (tsNode.kind === ts.SyntaxKind.ThisKeyword) { - found = true; - return; +function scopeContainsThisVisitor(tsNode: ts.Node): boolean { + const isThis = tsNode.kind === ts.SyntaxKind.ThisKeyword; + if (isThis) { + return true; + } + + const isClassLike = ts.isClassDeclaration(tsNode) || ts.isClassExpression(tsNode); + const isFunctionLike = ts.isFunctionDeclaration(tsNode) || ts.isFunctionExpression(tsNode); + const isModuleDecl = ts.isModuleDeclaration(tsNode); + if (isClassLike || isFunctionLike || isModuleDecl) { + return false; + } + + for (const child of tsNode.getChildren()) { + if (scopeContainsThisVisitor(child)) { + return true; } - // Visit children nodes. Skip any local declaration that defines - // its own scope as it needs to be checked separately. - if ( - !ts.isClassDeclaration(tsNode) && - !ts.isClassExpression(tsNode) && - !ts.isModuleDeclaration(tsNode) && - !ts.isFunctionDeclaration(tsNode) && - !ts.isFunctionExpression(tsNode) - ) - tsNode.forEachChild(visitNode); } - visitNode(tsNode); - return found; -} \ No newline at end of file + + return false; +} + +export function scopeContainsThis(tsNode: ts.Expression | ts.Block): boolean { + return scopeContainsThisVisitor(tsNode); +} diff --git a/linter/test/classB.ts.relax.json b/linter/test/classB.ts.relax.json index e44fd80c4..dc2b9ced4 100644 --- a/linter/test/classB.ts.relax.json +++ b/linter/test/classB.ts.relax.json @@ -15,8 +15,8 @@ ], "nodes": [ { - "line": 24, - "column": 5, + "line": 25, + "column": 16, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/classB.ts.strict.json b/linter/test/classB.ts.strict.json index e44fd80c4..dc2b9ced4 100644 --- a/linter/test/classB.ts.strict.json +++ b/linter/test/classB.ts.strict.json @@ -15,8 +15,8 @@ ], "nodes": [ { - "line": 24, - "column": 5, + "line": 25, + "column": 16, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/function_object_methods.ts.relax.json b/linter/test/function_object_methods.ts.relax.json index 96e3fcaf1..8b8fe68fe 100644 --- a/linter/test/function_object_methods.ts.relax.json +++ b/linter/test/function_object_methods.ts.relax.json @@ -190,29 +190,29 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 118, - "column": 7, + "line": 119, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 121, - "column": 7, + "line": 122, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 124, - "column": 7, + "line": 125, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 127, - "column": 7, + "line": 128, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/function_object_methods.ts.strict.json b/linter/test/function_object_methods.ts.strict.json index e90572ea9..a73e4ace1 100644 --- a/linter/test/function_object_methods.ts.strict.json +++ b/linter/test/function_object_methods.ts.strict.json @@ -197,8 +197,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 118, - "column": 7, + "line": 119, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -218,15 +218,15 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 121, - "column": 7, + "line": 122, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 124, - "column": 7, + "line": 125, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -239,8 +239,8 @@ "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" }, { - "line": 127, - "column": 7, + "line": 128, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/functions.ts.autofix.json b/linter/test/functions.ts.autofix.json index 944c5bf6b..0b6af45e6 100755 --- a/linter/test/functions.ts.autofix.json +++ b/linter/test/functions.ts.autofix.json @@ -87,8 +87,8 @@ "rule": "Use generic functions instead of generic arrow functions (arkts-no-generic-lambdas)" }, { - "line": 63, - "column": 1, + "line": 64, + "column": 3, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", diff --git a/linter/test/functions.ts.relax.json b/linter/test/functions.ts.relax.json index 1e86ab2f1..6729c50d2 100644 --- a/linter/test/functions.ts.relax.json +++ b/linter/test/functions.ts.relax.json @@ -64,8 +64,8 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 63, - "column": 1, + "line": 64, + "column": 3, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/functions.ts.strict.json b/linter/test/functions.ts.strict.json index a1c2214e5..d57b74aa3 100644 --- a/linter/test/functions.ts.strict.json +++ b/linter/test/functions.ts.strict.json @@ -78,8 +78,8 @@ "rule": "Use generic functions instead of generic arrow functions (arkts-no-generic-lambdas)" }, { - "line": 63, - "column": 1, + "line": 64, + "column": 3, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/prototype_assignment.ts.autofix.json b/linter/test/prototype_assignment.ts.autofix.json index 381cadf69..c1e3b5c63 100755 --- a/linter/test/prototype_assignment.ts.autofix.json +++ b/linter/test/prototype_assignment.ts.autofix.json @@ -15,8 +15,8 @@ ], "nodes": [ { - "line": 19, - "column": 1, + "line": 26, + "column": 19, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", @@ -31,8 +31,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 20, - "column": 20, + "line": 21, + "column": 5, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", @@ -71,8 +71,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 30, - "column": 26, + "line": 31, + "column": 12, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", diff --git a/linter/test/prototype_assignment.ts.relax.json b/linter/test/prototype_assignment.ts.relax.json index dc1c5be2c..79345f433 100644 --- a/linter/test/prototype_assignment.ts.relax.json +++ b/linter/test/prototype_assignment.ts.relax.json @@ -15,15 +15,15 @@ ], "nodes": [ { - "line": 19, - "column": 1, + "line": 26, + "column": 19, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 20, - "column": 20, + "line": 21, + "column": 5, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -50,8 +50,8 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 30, - "column": 26, + "line": 31, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/prototype_assignment.ts.strict.json b/linter/test/prototype_assignment.ts.strict.json index ad3f54292..f1ebe772d 100644 --- a/linter/test/prototype_assignment.ts.strict.json +++ b/linter/test/prototype_assignment.ts.strict.json @@ -15,8 +15,8 @@ ], "nodes": [ { - "line": 19, - "column": 1, + "line": 26, + "column": 19, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -29,8 +29,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 20, - "column": 20, + "line": 21, + "column": 5, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -64,8 +64,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 30, - "column": 26, + "line": 31, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test/this_type.ts.relax.json b/linter/test/this_type.ts.relax.json index 1508e5c96..7afe8f170 100644 --- a/linter/test/this_type.ts.relax.json +++ b/linter/test/this_type.ts.relax.json @@ -50,28 +50,28 @@ "problem": "ThisType" }, { - "line": 72, - "column": 3, + "line": 73, + "column": 5, "problem": "FunctionContainsThis" }, { - "line": 77, - "column": 9, + "line": 78, + "column": 3, "problem": "FunctionContainsThis" }, { - "line": 80, - "column": 10, + "line": 81, + "column": 3, "problem": "FunctionContainsThis" }, { - "line": 83, - "column": 1, + "line": 84, + "column": 3, "problem": "FunctionContainsThis" }, { - "line": 88, - "column": 3, + "line": 89, + "column": 5, "problem": "FunctionContainsThis" } ] diff --git a/linter/test/this_type.ts.strict.json b/linter/test/this_type.ts.strict.json index 1631a08e6..1e2f8ec86 100644 --- a/linter/test/this_type.ts.strict.json +++ b/linter/test/this_type.ts.strict.json @@ -50,13 +50,13 @@ "problem": "ThisType" }, { - "line": 72, - "column": 3, + "line": 73, + "column": 5, "problem": "FunctionContainsThis" }, { - "line": 77, - "column": 9, + "line": 78, + "column": 3, "problem": "FunctionContainsThis" }, { @@ -65,18 +65,18 @@ "problem": "FunctionExpression" }, { - "line": 80, - "column": 10, + "line": 81, + "column": 3, "problem": "FunctionContainsThis" }, { - "line": 83, - "column": 1, + "line": 84, + "column": 3, "problem": "FunctionContainsThis" }, { - "line": 88, - "column": 3, + "line": 89, + "column": 5, "problem": "FunctionContainsThis" } ] diff --git a/linter/test/utility_types.ts.relax.json b/linter/test/utility_types.ts.relax.json index 63a56e5cd..b274ba451 100644 --- a/linter/test/utility_types.ts.relax.json +++ b/linter/test/utility_types.ts.relax.json @@ -250,8 +250,8 @@ "problem": "UtilityType" }, { - "line": 173, - "column": 3, + "line": 174, + "column": 12, "problem": "FunctionContainsThis" }, { @@ -270,8 +270,8 @@ "problem": "FunctionApplyBindCall" }, { - "line": 183, - "column": 3, + "line": 184, + "column": 12, "problem": "FunctionContainsThis" }, { @@ -290,8 +290,13 @@ "problem": "FunctionApplyBindCall" }, { - "line": 192, - "column": 1, + "line": 208, + "column": 9, + "problem": "FunctionContainsThis" + }, + { + "line": 209, + "column": 9, "problem": "FunctionContainsThis" }, { diff --git a/linter/test/utility_types.ts.strict.json b/linter/test/utility_types.ts.strict.json index cb2916b9d..bbda8979a 100644 --- a/linter/test/utility_types.ts.strict.json +++ b/linter/test/utility_types.ts.strict.json @@ -260,8 +260,8 @@ "problem": "UtilityType" }, { - "line": 173, - "column": 3, + "line": 174, + "column": 12, "problem": "FunctionContainsThis" }, { @@ -295,8 +295,8 @@ "problem": "FunctionApplyBindCall" }, { - "line": 183, - "column": 3, + "line": 184, + "column": 12, "problem": "FunctionContainsThis" }, { @@ -320,8 +320,13 @@ "problem": "FunctionApplyBindCall" }, { - "line": 192, - "column": 1, + "line": 208, + "column": 9, + "problem": "FunctionContainsThis" + }, + { + "line": 209, + "column": 9, "problem": "FunctionContainsThis" }, { diff --git a/linter/test_rules/rule136.ts.autofix.json b/linter/test_rules/rule136.ts.autofix.json index fb3ab2780..2f60e039c 100644 --- a/linter/test_rules/rule136.ts.autofix.json +++ b/linter/test_rules/rule136.ts.autofix.json @@ -17,8 +17,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 1, - "column": 9, + "line": 2, + "column": 5, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", @@ -49,8 +49,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 11, - "column": 17, + "line": 12, + "column": 12, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", diff --git a/linter/test_rules/rule136.ts.relax.json b/linter/test_rules/rule136.ts.relax.json index d9d652719..ccffcfe55 100644 --- a/linter/test_rules/rule136.ts.relax.json +++ b/linter/test_rules/rule136.ts.relax.json @@ -1,8 +1,8 @@ { "nodes": [ { - "line": 1, - "column": 9, + "line": 2, + "column": 5, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -22,8 +22,8 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 11, - "column": 17, + "line": 12, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test_rules/rule136.ts.strict.json b/linter/test_rules/rule136.ts.strict.json index 1df9367d3..03f0cbbe5 100644 --- a/linter/test_rules/rule136.ts.strict.json +++ b/linter/test_rules/rule136.ts.strict.json @@ -15,8 +15,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 1, - "column": 9, + "line": 2, + "column": 5, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" @@ -43,8 +43,8 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 11, - "column": 17, + "line": 12, + "column": 12, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test_rules/rule93.ts.autofix.json b/linter/test_rules/rule93.ts.autofix.json index 872acd394..819c25194 100644 --- a/linter/test_rules/rule93.ts.autofix.json +++ b/linter/test_rules/rule93.ts.autofix.json @@ -1,8 +1,8 @@ { "nodes": [ { - "line": 1, - "column": 1, + "line": 2, + "column": 5, "problem": "FunctionContainsThis", "autofixable": false, "suggest": "", diff --git a/linter/test_rules/rule93.ts.relax.json b/linter/test_rules/rule93.ts.relax.json index a16283a18..772a1f628 100644 --- a/linter/test_rules/rule93.ts.relax.json +++ b/linter/test_rules/rule93.ts.relax.json @@ -1,8 +1,8 @@ { "nodes": [ { - "line": 1, - "column": 1, + "line": 2, + "column": 5, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" diff --git a/linter/test_rules/rule93.ts.strict.json b/linter/test_rules/rule93.ts.strict.json index a16283a18..772a1f628 100644 --- a/linter/test_rules/rule93.ts.strict.json +++ b/linter/test_rules/rule93.ts.strict.json @@ -1,8 +1,8 @@ { "nodes": [ { - "line": 1, - "column": 1, + "line": 2, + "column": 5, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" -- Gitee