diff --git a/linter-4.2/docs/rules/recipe118.md b/linter-4.2/docs/rules/recipe118.md deleted file mode 100644 index f625bc3e982353617c9dd28f7c6d67ff886e1e6d..0000000000000000000000000000000000000000 --- 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 c89d24fbac4b50b1e68937ea99e7e979ae8c1452..0000000000000000000000000000000000000000 --- 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/docs/rules/recipe144.md b/linter-4.2/docs/rules/recipe144.md index 28acf4a49c2d12c132c77f1e840a1d5de12e0f0d..ec36a4ffbf2f7a833502932ffc2010f44f6e2d24 100644 --- a/linter-4.2/docs/rules/recipe144.md +++ b/linter-4.2/docs/rules/recipe144.md @@ -29,8 +29,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/docs/rules/recipe151.md b/linter-4.2/docs/rules/recipe151.md index 0b00ba64328b8da460cba56c63a6dd63fd050e23..2e7fd2d46a7c1a86d1c9ac02edd38945f5cfd0b1 100644 --- a/linter-4.2/docs/rules/recipe151.md +++ b/linter-4.2/docs/rules/recipe151.md @@ -1,17 +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``. @@ -32,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 } ``` @@ -51,4 +53,3 @@ variables of type ``ESObject``. - 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/docs/rules/recipe29.md b/linter-4.2/docs/rules/recipe29.md index c7be978d6962ce635842df26f13c20591f59b060..7af61c43e6cc5976617e17be86598978444d8ebe 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/scripts/update-test-results.mjs b/linter-4.2/scripts/update-test-results.mjs index dc579e42453a4416215504af7d0e3133221a4f33..45029c37eb3f2858d3a3848b5eebc2453598d268 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/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index c097345da5b47ffe0f98b7215329933df4889a14..e505f59a8b627c612a0313735ea504974a93f052 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] = ''; } @@ -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)'; @@ -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/src/Problems.ts b/linter-4.2/src/Problems.ts index 98bd4701b9054be916c8f229cada1cde816e8dad..61d08d5cb247a8194b204c836b50aa4e0d2c4d4f 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -27,14 +27,15 @@ 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, 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, + LAST_ID, // this should always be last enum` } export class FaultAttributs { @@ -107,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',}; @@ -130,4 +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: '151',}; +faultsAttrs[FaultID.EsObjectType] = {warning: true, cookBookRef: '151'}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 27442da9f6353270955b0c54de49988c6273e5b3..cde04f2322510a954bc8222967bedca8fa38e1a8 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++) { @@ -136,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], @@ -148,6 +149,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( @@ -240,8 +242,6 @@ export class TypeScriptLinter { return; } - self.handleComments(node); - if (LinterConfig.terminalTokens.has(node.kind)) return; let incrementedType = LinterConfig.incrementOnlyTokens.get(node.kind); @@ -254,7 +254,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); + } } } @@ -610,7 +615,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); } @@ -668,18 +673,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 (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 && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { this.incrementCounters(propertyAccessNode, FaultID.EsObjectType); } - if (this.isPrototypePropertyAccess(propertyAccessNode, exprSym, baseExprSym, baseExprType)) { - this.incrementCounters(propertyAccessNode.name, FaultID.Prototype); - } } private handlePropertyAssignmentOrDeclaration(node: ts.Node) { @@ -693,20 +705,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; @@ -759,7 +767,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' @@ -1181,6 +1189,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); @@ -1249,6 +1259,7 @@ export class TypeScriptLinter { if (node.initializer) { this.handleEsObjectAssignment(node, node.type, node.initializer); + return; } } @@ -1411,13 +1422,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) { @@ -1477,19 +1481,20 @@ 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) { return; } + if ( (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && - tsIdentifier.text === 'globalThis' + tsIdentifier.text === "globalThis" ) { - this.incrementCounters(tsIdentifier, FaultID.GlobalThis); + this.incrementCounters(node, FaultID.GlobalThis); } else { - this.checkLimitedStdLib(tsIdentifier, tsIdentSym); this.handleRestrictedValues(tsIdentifier, tsIdentSym); } } @@ -1508,7 +1513,9 @@ export class TypeScriptLinter { if (ts.isCallExpression(ctx.parent) || ts.isNewExpression(ctx.parent)) { let callee = ctx.parent.expression; - if (callee != ctx && 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; } } @@ -1559,8 +1566,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) || @@ -1584,44 +1590,35 @@ 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.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() && - !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) + !this.tsUtils.isAnyType(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, @@ -1673,16 +1670,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) { @@ -1699,22 +1686,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); - } } - 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.EsObjectType); + } } private handleImportCall(tsCallExpr: ts.CallExpression) { @@ -1784,6 +1774,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 +1829,35 @@ 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}], + ["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); } } @@ -1861,24 +1885,24 @@ 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({ - [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) { @@ -1924,7 +1948,6 @@ export class TypeScriptLinter { this.incrementCounters(node, FaultID.EsObjectType); return; } - const typeName = this.tsUtils.entityNameToString(typeRef.typeName); const isStdUtilityType = TsUtils.LIMITED_STANDARD_UTILITY_TYPES.includes(typeName); if (isStdUtilityType) { @@ -1966,21 +1989,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; } } @@ -2016,7 +2026,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); + } } } } @@ -2028,20 +2043,34 @@ 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); + } } } } } 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 @@ -2050,7 +2079,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") || @@ -2174,9 +2205,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; } @@ -2196,8 +2225,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/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 1639e5664f9758c32dc413580caf9e94ec5956d9..f549a87180081804dd9b25fc775af05d968b7b11 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 = ..)'; @@ -166,14 +164,13 @@ 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], [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/src/Utils.ts b/linter-4.2/src/Utils.ts index 03674b19e96459a3e9915e7d392180fe2561becc..c2f32b89a37d00409d77cf95485f2d7db085366a 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) => { @@ -95,135 +94,30 @@ 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' - private static readonly LIMITED_STD_ARRAYBUFFER_API = [ - // properties - // methods - 'isView' + static readonly LIMITED_STD_GLOBAL_FUNC = [ + 'eval' ]; - - 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' - ]; - - private static readonly LIMITED_STD_REFLECT_API = [ - // properties - // methods - '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', + 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_FUNCTION_API = [ - // properties - // methods - 'apply', - 'bind', - 'call', + static readonly LIMITED_STD_REFLECT_API = [ + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'isExtensible', 'preventExtensions', 'setPrototypeOf' ]; - - static readonly LIMITED_STD_GLOBAL_API = [ - // properties - // methods - 'eval', + static readonly LIMITED_STD_PROXYHANDLER_API = [ + 'apply', 'construct', 'defineProperty', 'deleteProperty', 'get', 'getOwnPropertyDescriptor', 'getPrototypeOf', + 'has', 'isExtensible', 'ownKeys', 'preventExtensions', 'set', 'setPrototypeOf' ]; - 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 NON_INITIALIZABLE_PROPERTY_DECORATORS = ['Link', 'Consume', 'ObjectLink', 'Prop', 'BuilderParam']; static readonly NON_INITIALIZABLE_PROPERTY_CLASS_DECORATORS = ['CustomDialog'] @@ -240,6 +134,8 @@ export class TsUtils { 'ThisType', 'Uppercase', 'Lowercase', 'Capitalize', 'Uncapitalize', ]; + static readonly ALLOWED_STD_SYMBOL_API = ['iterator'] + static readonly ARKUI_DECORATORS = [ 'AnimatableExtend', 'Builder', @@ -303,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; @@ -549,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))) + if (checkType.call(this, tsType)) { return true; - if (checkType != CheckType.Array && this.isType(tsTypeNode, checkType.toString())) - 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; + } } } @@ -869,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; } @@ -1194,39 +1111,18 @@ export class TsUtils { return !parentName || parentName === 'global'; } - public isStdObjectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Object'); - } - - public isStdReflectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Reflect'); - } - - public isStdProxyHandlerAPI(symbol: ts.Symbol): boolean { + public isSymbolAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ProxyHandler'); - } - - public isStdArrayAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Array'); - } - - public isStdArrayBufferAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ArrayBuffer'); + return !!parentName && (parentName === 'Symbol' || parentName === 'SymbolConstructor'); } public isStdSymbol(symbol: ts.Symbol): boolean { const name = this.tsTypeChecker.getFullyQualifiedName(symbol) - return name === 'Symbol'; + return name === 'Symbol' && this.isGlobalSymbol(symbol); } - public isStdSymbolAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && parentName === 'Symbol'; + public isSymbolIterator(symbol: ts.Symbol): boolean { + return this.isSymbolAPI(symbol) && symbol.name === 'iterator' } public isDefaultImport(importSpec: ts.ImportSpecifier): boolean { @@ -1260,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); @@ -1310,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; @@ -1472,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; } @@ -1614,4 +1519,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/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts b/linter-4.2/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts index 0d5106dd9f116531b356ca406fc9f4fff8ef053a..89380f130488617551e54b2f6f080d120b104535 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-4.2/test/ambient_module.ts.relax.json b/linter-4.2/test/ambient_module.ts.relax.json index a02ca7fc8935464e83947500d0dfc1e6558752dd..543d0a12ae515b61dfce8f85cf2bb8a33b955d0f 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 a02ca7fc8935464e83947500d0dfc1e6558752dd..543d0a12ae515b61dfce8f85cf2bb8a33b955d0f 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/class_as_object.ts b/linter-4.2/test/class_as_object.ts index 302432975cbb76c7c446fa410aad9b6220153f5d..195c076eca476d678de2b42436dfc076ab07f54b 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,28 @@ 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 + +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 fbae23bf5543a366a545d54810c03be11b97a304..87b0d7889dcea4ea46095d741c38bf3a6555c40e 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,121 @@ { "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)" + }, + { + "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 fbae23bf5543a366a545d54810c03be11b97a304..87b0d7889dcea4ea46095d741c38bf3a6555c40e 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,121 @@ { "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)" + }, + { + "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/dynamic_lib.d.ts b/linter-4.2/test/dynamic_lib.d.ts index e3da589b5418ec259aa310a41fea0f454f17ede3..843931397eaf4c1fce6ff89f458826d49642771c 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 ea7f9759a2e8cf76d1eb0dd81536959bfcf1beeb..fae9413ea1d4ccb581327bddbdda25cb9c805912 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-4.2/test/es_object.ts b/linter-4.2/test/es_object.ts index 445b5c0c07e1db8eb18c4006d860e3476659f6ae..8b62f20f81b12743f1c4fb4aa2025ee6c99cd454 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 f3d5acdb48589622baa499e265b74a732fa003f6..5bab1a3eee7a781b35c0996be116badfe9617820 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,105 +488,112 @@ "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, "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, "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 +607,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 +635,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 5c869e41f36b202e2f7537f9bfa7a312c7073b8a..86c0f49acf614ff7fd4b654983ee1a6684b0d3a3 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,105 +488,112 @@ "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, "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, "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 +607,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 +635,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/function_expression.ts.autofix.json b/linter-4.2/test/function_expression.ts.autofix.json index 90e6f3f3b1843e1b27a91717ae8ec47ced32aeaa..e005781ad91e4c1a3c375d88874c9f64811e06bb 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, @@ -335,6 +343,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 +366,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 8e60772364f880a2b1734887f006e79ab0075cdd..48f6e1a27f9cde8a9f97bd009fcf972843b37619 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 1233c4e7db472396252e3157aac380db56d8e583..48723e4cddfa69f67dde850ebe2d3b944276fb9e 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, @@ -206,16 +213,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 790856d4f7ac64e42723ba8be5a20b7ae18f32a2..96e3fcaf15c33d5b989eb091c20e1961ab3994b9 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 2a7c8ccd943aded4391752c20d2e26ecc66b4c29..e90572ea9fa1ff6f639076c45d74320d7d9469d6 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/functions.ts b/linter-4.2/test/functions.ts index 8d67f99ff3292a00005ed662c0798ca5ab08801e..fd8646324ae5cec720ba4c189a8dfdac408f85ff 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 bdec3c538a0a38afa2968f452019ea0cc98ccffe..944c5bf6b00aa3659df8313054492cb1ea47856f 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 e11f7f9c4b4ba8fd83a515d2609ee21e3b7f6c08..1e86ab2f19832ca9bf8a34ad0e3cf11cea54bb8e 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 d39199ff0024aa2f8a01d89ad214a4e3c83e8212..a1c2214e52d001dfb28b51cd6867ddd774c91cdb 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-4.2/test/limited_stdlib_api.ts b/linter-4.2/test/limited_stdlib_api.ts index 0cc445fe759022f5cd6bcd7850aa3f018cf33849..918ecda770245ba60c156d10007ee46572f40e45 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 6286f4c5d0b3ddb032dd27a3d39d87bfee9170f9..eb0a98815448f5fa65bb3aae2c053f8697d69296 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,32 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 31, "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": 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 +56,7 @@ }, { "line": 44, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -42,7 +64,7 @@ }, { "line": 45, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -58,7 +80,7 @@ }, { "line": 46, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -66,7 +88,7 @@ }, { "line": 48, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -74,7 +96,7 @@ }, { "line": 49, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -82,7 +104,7 @@ }, { "line": 50, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -90,7 +112,7 @@ }, { "line": 51, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -98,7 +120,7 @@ }, { "line": 52, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -106,7 +128,7 @@ }, { "line": 53, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -114,7 +136,7 @@ }, { "line": 54, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -122,7 +144,7 @@ }, { "line": 55, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -130,7 +152,7 @@ }, { "line": 56, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -138,7 +160,7 @@ }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -146,7 +168,7 @@ }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -154,7 +176,7 @@ }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -162,7 +184,7 @@ }, { "line": 60, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -170,7 +192,7 @@ }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -178,7 +200,7 @@ }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -186,7 +208,7 @@ }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -194,7 +216,7 @@ }, { "line": 66, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -202,7 +224,7 @@ }, { "line": 67, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -218,7 +240,7 @@ }, { "line": 68, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -234,7 +256,7 @@ }, { "line": 69, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -242,7 +264,7 @@ }, { "line": 70, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -250,7 +272,7 @@ }, { "line": 71, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -258,7 +280,7 @@ }, { "line": 72, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -266,7 +288,7 @@ }, { "line": 73, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -274,7 +296,7 @@ }, { "line": 74, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -290,15 +312,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,15 +320,7 @@ }, { "line": 79, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 79, - "column": 32, + "column": 24, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -322,15 +328,7 @@ }, { "line": 80, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 80, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -346,15 +344,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 +352,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 +360,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,15 +368,7 @@ }, { "line": 84, - "column": 37, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 85, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -418,15 +376,7 @@ }, { "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 +384,7 @@ }, { "line": 86, - "column": 35, + "column": 27, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -442,23 +392,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 +400,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 +408,7 @@ }, { "line": 89, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -490,23 +416,7 @@ }, { "line": 90, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 90, - "column": 37, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 93, - "column": 13, + "column": 29, "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 7f5db9e71c7cb9e6dfc0b80057cfd409ad490712..2e0b7e73690290d2698de6e85687986aa11d15cf 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,43 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 31, "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": 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 +72,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 +212,7 @@ }, { "line": 68, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -205,42 +226,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 +275,21 @@ }, { "line": 78, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 78, - "column": 28, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 79, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 79, - "column": 32, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 80, - "column": 13, + "column": 24, "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 +303,70 @@ }, { "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 83, - "column": 13, + "column": 18, "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, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 86, - "column": 13, - "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 88, - "column": 13, + "column": 22, "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 93, - "column": 13, + "column": 29, "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 7f5db9e71c7cb9e6dfc0b80057cfd409ad490712..2e0b7e73690290d2698de6e85687986aa11d15cf 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,43 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 31, "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": 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 +72,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 +212,7 @@ }, { "line": 68, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -205,42 +226,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 +275,21 @@ }, { "line": 78, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 78, - "column": 28, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 79, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 79, - "column": 32, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 80, - "column": 13, + "column": 24, "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 +303,70 @@ }, { "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 83, - "column": 13, + "column": 18, "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, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 86, - "column": 13, - "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 88, - "column": 13, + "column": 22, "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 93, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter-4.2/test/modules.ts.autofix.json b/linter-4.2/test/modules.ts.autofix.json index 567b9a523a2bc47149edca0b119738a94115535a..476aed0b64742d7aba1b026823c41bba6d4f7cb9 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 9481d07d8d642c6b8d190fbe9ae603a826ac99a8..88de583880c7d9279cda15172273567053297ae4 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/new_target.ts.relax.json b/linter-4.2/test/new_target.ts.relax.json index 0b83a11983237ced2f41aa64eaaeb370019ee51f..5ec99daa29eeeccfa7c6b5bdcdcefea2f5999fe5 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 0b83a11983237ced2f41aa64eaaeb370019ee51f..5ec99daa29eeeccfa7c6b5bdcdcefea2f5999fe5 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_factory.ts b/linter-4.2/test/oh_modules/ohos_factory.ts index e26c4c911ba886e1d930a38404f9a87434d454b3..b4fc3d2d2fe025f7deb68faa0cf3374beece71ee 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-4.2/test/property_access_by_index.ts b/linter-4.2/test/property_access_by_index.ts new file mode 100644 index 0000000000000000000000000000000000000000..03b2c8f7181ef8473016961141ec364fbd3588fb --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts @@ -0,0 +1,121 @@ +/* + * 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'); +} + +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] + +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 new file mode 100644 index 0000000000000000000000000000000000000000..df5e23653813b324741d7d9ee9d2eb375a2a3f05 --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts.autofix.json @@ -0,0 +1,74 @@ +{ + "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)" + }, + { + "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)" + }, + { + "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 new file mode 100644 index 0000000000000000000000000000000000000000..b492ed7380feb4b306433cd940c731223e71b0ad --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts.relax.json @@ -0,0 +1,39 @@ +{ + "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": 56, + "column": 5, + "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 new file mode 100644 index 0000000000000000000000000000000000000000..daf068f0d12f2dbc7b586c5f5033406a0b814f6f --- /dev/null +++ b/linter-4.2/test/property_access_by_index.ts.strict.json @@ -0,0 +1,67 @@ +{ + "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)" + }, + { + "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)" + }, + { + "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/symbol_api.ts b/linter-4.2/test/symbol_api.ts index 2d33c448f2d46c9150ee43b838b41f7dc5d98a37..8d7d25d3e16a892137741335ce918d61bd964a59 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-4.2/test/symbol_api.ts.relax.json b/linter-4.2/test/symbol_api.ts.relax.json index e62c8c7b772eb72b7c1c2e435f564313f0be758a..c2211cf10708b2fa141fd797dc845a3553c2e98a 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 e62c8c7b772eb72b7c1c2e435f564313f0be758a..c2211cf10708b2fa141fd797dc845a3553c2e98a 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/ts_ignore.ts b/linter-4.2/test/ts_ignore.ts index 3676a1550465e43c9205d6645b9262154c268fe3..5cee019035189a17a674aee7a28e83590af1420c 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 d1f5176718b5277f4744fd1d2237f1bec3ddae0e..f802c561b84b47c7e4c752428ed86cd5c76e97ae 100644 --- a/linter-4.2/test/ts_ignore.ts.relax.json +++ b/linter-4.2/test/ts_ignore.ts.relax.json @@ -14,65 +14,89 @@ "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, - "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" - }, - { - "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" - }, - { - "line": 53, - "column": 3, - "problem": "AnyType" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "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 d1f5176718b5277f4744fd1d2237f1bec3ddae0e..f802c561b84b47c7e4c752428ed86cd5c76e97ae 100644 --- a/linter-4.2/test/ts_ignore.ts.strict.json +++ b/linter-4.2/test/ts_ignore.ts.strict.json @@ -14,65 +14,89 @@ "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, - "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" - }, - { - "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" - }, - { - "line": 53, - "column": 3, - "problem": "AnyType" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "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/types.ts.autofix.json b/linter-4.2/test/types.ts.autofix.json index 7833b9da06c47271168dc5b463b35b669eed9910..3263fe4927404003fa9338dcc7806eb519432e2c 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 12af0241f0080993d1207515856d070dd647e821..50971119921dde92707a4fc5e30b91fe2d2fa2ee 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-4.2/test/utility_types.ts.relax.json b/linter-4.2/test/utility_types.ts.relax.json index fe6131546f4334735729e5e3c1ab931d44572443..63a56e5cd84e9305c8c9235b62a945faa1f8a75f 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 c5686de4b4c5b53e4bfe52a623bec80e0c788296..cb2916b9d5d09ea06f98df2322cb84b2bf0d83ae 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/rule116.ts.autofix.json b/linter-4.2/test_rules/rule116.ts.autofix.json index 8449964f6b0aebed7a3a412a87e959afbcb33487..f3a5f41b3b987383c1f652c7373135cda5df7173 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 a5030d64e8a3e5c962cfc25bcfc7d49e88e73a86..3259498ae75cd5e1f5d128bfeacd40f997681159 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 a5030d64e8a3e5c962cfc25bcfc7d49e88e73a86..3259498ae75cd5e1f5d128bfeacd40f997681159 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/rule118.ts.autofix.json b/linter-4.2/test_rules/rule118.ts.autofix.json index 3ff68f6c73f0870b0af431b06348497a9bf6a784..13f13363f579325755e8954b4011963971667481 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 d30836a74acd706fd8fe37f455f2cb38b9d30f96..13f13363f579325755e8954b4011963971667481 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 c32c0f461dd55626cd83972b7aa2a8d7bff66f60..13f13363f579325755e8954b4011963971667481 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 35f1a58896b2262887e713eb7ea091a5342d8b98..13f13363f579325755e8954b4011963971667481 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-4.2/test_rules/rule129.ts.autofix.json b/linter-4.2/test_rules/rule129.ts.autofix.json index 6708658aec6699b02802c0afa208ab7c076c39a4..80fc9c4b1fa0b7d2af2c6a19111f4c1a8102ef3d 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 cc882319377db9e73f996ceb24a77cc508180fdd..ab877e8e921e03d48ab1603fd2146e3f4fe9557f 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 cc882319377db9e73f996ceb24a77cc508180fdd..ab877e8e921e03d48ab1603fd2146e3f4fe9557f 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-4.2/test_rules/rule132.ts.autofix.json b/linter-4.2/test_rules/rule132.ts.autofix.json index d1868ca7f895576a790a872e83c05b3f7b619086..9002b4276ade0505b91332d17e0d7c64608c6e8f 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 21468ce90773221bb8d0e37917a8f9a5eb974223..192c3aa101f830da08961e07bd44fabed0c97d54 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 21468ce90773221bb8d0e37917a8f9a5eb974223..192c3aa101f830da08961e07bd44fabed0c97d54 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/recipe118.md b/linter/docs/rules/recipe118.md deleted file mode 100644 index f625bc3e982353617c9dd28f7c6d67ff886e1e6d..0000000000000000000000000000000000000000 --- 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 c89d24fbac4b50b1e68937ea99e7e979ae8c1452..0000000000000000000000000000000000000000 --- 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/docs/rules/recipe144.md b/linter/docs/rules/recipe144.md index 0bbcfefd413a1b7fc5b4e07cf9bb7d5487c669b7..371513d07946355b28a85f8bd976626c553e2f92 100644 --- a/linter/docs/rules/recipe144.md +++ b/linter/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/docs/rules/recipe151.md b/linter/docs/rules/recipe151.md index 0b00ba64328b8da460cba56c63a6dd63fd050e23..2e7fd2d46a7c1a86d1c9ac02edd38945f5cfd0b1 100644 --- a/linter/docs/rules/recipe151.md +++ b/linter/docs/rules/recipe151.md @@ -1,17 +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``. @@ -32,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 } ``` @@ -51,4 +53,3 @@ variables of type ``ESObject``. - Recipe 066: ``in`` operator is not supported (``arkts-no-in``) - Recipe 137: ``globalThis`` is not supported (``arkts-no-globalthis``) - diff --git a/linter/docs/rules/recipe29.md b/linter/docs/rules/recipe29.md index c7be978d6962ce635842df26f13c20591f59b060..7af61c43e6cc5976617e17be86598978444d8ebe 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/scripts/update-test-results.mjs b/linter/scripts/update-test-results.mjs index dc579e42453a4416215504af7d0e3133221a4f33..45029c37eb3f2858d3a3848b5eebc2453598d268 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/Autofixer.ts b/linter/src/Autofixer.ts index 59c1cc2d36a1986ab0400c64cec971b706faaa36..f6dc5129da1825c3fc74db497fa1d78de953e770 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 e977c8e19103a387bf789f4e820ab671e73ac312..d8f053a4eb1546b8b9292bf9245ff11e60b653bc 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] = ''; } @@ -135,9 +135,9 @@ 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[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)'; @@ -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/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index d4bb026cfd1778fd803000dc21e7b10ca3422bff..1346c84b3f6e712b89b923f7ff4cd5cb60e68588 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,87 @@ 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.DefaultImport] = {migratable: true, cookBookRef: '120',}; +faultsAttrs[FaultID.ImportAssignment] = {cookBookRef: '121',}; +faultsAttrs[FaultID.ExportAssignment] = {cookBookRef: '126',}; +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'}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index c61b136e7b1aabf1c36ce96c92a0b4c5bf039df3..d4555c10ae9bb77336755d24ffd086e275619c03 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[] = []; @@ -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/LinterRunner.ts b/linter/src/LinterRunner.ts index 0e701f2baa717d06dc4c66a680990d66d8c508c9..1494b65fd687171c5cf908b7e259e9113cb0cf00 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 0000000000000000000000000000000000000000..4008210e4f681f899084cba130e3966c0dc35c26 --- /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, 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/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 15d018ed5999142bb38be27095e9792ba21f180b..ff736aa8d7215c28a1fe441454cefc2a070e6952 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,11 @@ 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_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 { 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 +53,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(); @@ -154,7 +158,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], @@ -166,6 +169,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[],) { @@ -231,39 +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; + // early exit via exception if cancellation was requested + this.cancellationToken?.throwIfCancellationRequested(); } - self.handleComments(node); - if (LinterConfig.terminalTokens.has(node.kind)) { - return; - } - 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); } } - ts.forEachChild(node, visitTSNodeImpl); } + 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( @@ -517,7 +537,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); } } @@ -573,22 +593,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)) { + 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 && this.tsUtils.symbolHasEsObjectType(baseExprSym)) { + this.incrementCounters(propertyAccessNode, FaultID.EsObjectType); + } } private handlePropertyAssignmentOrDeclaration(node: ts.Node) { @@ -596,14 +623,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)) { @@ -617,7 +646,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, @@ -717,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); @@ -749,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))) { @@ -776,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) { @@ -838,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); @@ -904,6 +929,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); @@ -1143,27 +1171,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) { @@ -1181,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); @@ -1214,36 +1225,34 @@ 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); } } 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) { - return; + return } if ( (tsIdentSym.flags & ts.SymbolFlags.Module) !== 0 && (tsIdentSym.flags & ts.SymbolFlags.Transient) !== 0 && tsIdentifier.text === 'globalThis' ) { - this.incrementCounters(tsIdentifier, FaultID.GlobalThis); + this.incrementCounters(node, FaultID.GlobalThis); } else { - this.checkLimitedStdLib(tsIdentifier, tsIdentSym); this.handleRestrictedValues(tsIdentifier, tsIdentSym); } } @@ -1263,7 +1272,9 @@ export class TypeScriptLinter { if (ts.isCallExpression(ctx.parent) || ts.isNewExpression(ctx.parent)) { let callee = ctx.parent.expression; - if (callee != ctx && 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; } } @@ -1273,7 +1284,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) { @@ -1302,26 +1313,23 @@ 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() && - !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) && + !this.tsUtils.isAnyType(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); } @@ -1354,27 +1362,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) { @@ -1391,22 +1378,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); - } } - 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.EsObjectType); + } } private handleImportCall(tsCallExpr: ts.CallExpression) { @@ -1442,8 +1432,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; @@ -1467,6 +1457,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 +1503,33 @@ 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}], + ['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); } } @@ -1536,24 +1557,24 @@ 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({ - [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) { @@ -1633,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 @@ -1650,10 +1661,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 } } @@ -1710,20 +1719,32 @@ 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) : 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); } @@ -1834,9 +1855,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; } @@ -1856,9 +1875,61 @@ 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); + } + } + } + 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/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index 58f32df628769245048013901d2624b994e3946b..64c2c11265a33fe5d4f0cb9b73e72a305fd6b2f3 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 @@ -74,14 +74,13 @@ 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], [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/src/ts-diagnostics/TSCCompiledProgram.ts b/linter/src/ts-diagnostics/TSCCompiledProgram.ts index 36faaf7c35e1906207c214a9a0c7958dbc002593..cee480fd80730645a74eb53e97d9ed16e38fe79f 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 { @@ -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; } } diff --git a/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts b/linter/src/ts-diagnostics/TypeScriptDiagnosticsExtractor.ts index 0d5106dd9f116531b356ca406fc9f4fff8ef053a..89380f130488617551e54b2f6f080d120b104535 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/TsUtils.ts b/linter/src/utils/TsUtils.ts index c2ee9fef0a07aa042a99b1a72659d54ba6aa9ad1..5bff6b0aa75d7074b76e0def68c4a1e28c41c132 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; } @@ -900,39 +914,18 @@ export class TsUtils { return !parentName || parentName === 'global'; } - public isStdObjectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Object'); - } - - public isStdReflectAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Reflect'); - } - - public isStdProxyHandlerAPI(symbol: ts.Symbol): boolean { + public isSymbolAPI(symbol: ts.Symbol): boolean { let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ProxyHandler'); - } - - public isStdArrayAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Array'); - } - - public isStdArrayBufferAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'ArrayBuffer'); + return !!parentName && (parentName === 'Symbol' || parentName === 'SymbolConstructor'); } public isStdSymbol(symbol: ts.Symbol): boolean { const name = this.tsTypeChecker.getFullyQualifiedName(symbol) - return name === 'Symbol'; + return name === 'Symbol' && this.isGlobalSymbol(symbol); } - public isStdSymbolAPI(symbol: ts.Symbol): boolean { - let parentName = this.getParentSymbolName(symbol); - return !!parentName && (parentName === 'Symbol'); + public isSymbolIterator(symbol: ts.Symbol): boolean { + return this.isSymbolAPI(symbol) && symbol.name === 'iterator' } public isDefaultImport(importSpec: ts.ImportSpecifier): boolean { @@ -966,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); @@ -1015,20 +1017,15 @@ 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; } - 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; @@ -1136,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; } @@ -1298,4 +1295,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/src/utils/consts/AllowedStdSymbolAPI.ts b/linter/src/utils/consts/AllowedStdSymbolAPI.ts new file mode 100644 index 0000000000000000000000000000000000000000..69c95812ae78d764600c9ea0425c43fc7171d9b4 --- /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 259443d9933fed46f4f6ea269251428b9f40db93..ba9181506b874c33b7d5751157b05cbed1dc06e2 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 1599fbfe9210a7b902bfffac2596ea6a87fe3a28..0000000000000000000000000000000000000000 --- 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/LimitedStdGlobalFunc.ts b/linter/src/utils/consts/LimitedStdGlobalFunc.ts new file mode 100644 index 0000000000000000000000000000000000000000..841b81dda7c65018039a2abc79dcc0c22ba7d148 --- /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' +]; diff --git a/linter/src/utils/consts/LimitedStdObjectAPI.ts b/linter/src/utils/consts/LimitedStdObjectAPI.ts new file mode 100644 index 0000000000000000000000000000000000000000..55b7ffede637a06200ad988b6ce55aab5ad3aeda --- /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 0000000000000000000000000000000000000000..7113b2b5c6cf765ba2c2403d70b1530952501ed5 --- /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 0000000000000000000000000000000000000000..e1f58f802c8711b6b4c8febba6f35acd2b9991eb --- /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 3d1def20dcb9e9f650dd85af93e81eff6643be04..0000000000000000000000000000000000000000 --- 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/src/utils/functions/ContainsThis.ts b/linter/src/utils/functions/ContainsThis.ts index 958553f2808093b08b518cb2a1a7ec8a9928819c..b5a1997655a23523b67c5e3ea02b111a454617d1 100644 --- a/linter/src/utils/functions/ContainsThis.ts +++ b/linter/src/utils/functions/ContainsThis.ts @@ -15,29 +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; + + return false; +} + +export function scopeContainsThis(tsNode: ts.Expression | ts.Block): boolean { + return scopeContainsThisVisitor(tsNode); } - \ No newline at end of file diff --git a/linter/src/utils/functions/identiferUseInValueContext.ts b/linter/src/utils/functions/identiferUseInValueContext.ts index 43c1389a96b66fc1843d3fc26fc7d0d8415258e1..96a762c2d854c5bcb32a1d520fc79aedcd81972f 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/ambient_module.ts.relax.json b/linter/test/ambient_module.ts.relax.json index a02ca7fc8935464e83947500d0dfc1e6558752dd..543d0a12ae515b61dfce8f85cf2bb8a33b955d0f 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 a02ca7fc8935464e83947500d0dfc1e6558752dd..543d0a12ae515b61dfce8f85cf2bb8a33b955d0f 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/array_literals.ts b/linter/test/array_literals.ts index 4c5e9de197ab904fc53feb06cf4e440e81808066..5889b08baa937a07d7b5130bb742110c9f34fe22 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/classB.ts.relax.json b/linter/test/classB.ts.relax.json index e44fd80c47fb55cd43e0a82e2db3b2b8cf8c8858..dc2b9ced44f0b0fed43aafdf3a49426c859daf07 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 e44fd80c47fb55cd43e0a82e2db3b2b8cf8c8858..dc2b9ced44f0b0fed43aafdf3a49426c859daf07 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/class_as_object.ts b/linter/test/class_as_object.ts index e91d6c0246cd4f7ae5b14a230acadc3ae820e676..6fa062cdc16a2496a89a38e2f90b5fd362972d1b 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,28 @@ 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 + +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 0fdca907248f03f85893c5f89d279959c5953271..ebe30080e0920cd92ae2320990d9786929a655f9 100644 --- a/linter/test/class_as_object.ts.relax.json +++ b/linter/test/class_as_object.ts.relax.json @@ -15,72 +15,121 @@ { "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)" + }, + { + "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 0fdca907248f03f85893c5f89d279959c5953271..ebe30080e0920cd92ae2320990d9786929a655f9 100644 --- a/linter/test/class_as_object.ts.strict.json +++ b/linter/test/class_as_object.ts.strict.json @@ -15,72 +15,121 @@ { "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)" + }, + { + "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/default_imports.ts.autofix.json b/linter/test/default_imports.ts.autofix.json index f666c003d98fa83eedd2bc41c6331a7158c3fff2..b083d587f19d1116c31f7ac1486b08dc89500359 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 07471ba2bafabe3b366b8d2655a8d79ad90895e7..ffea8cd37a136b792cb2a77f05e5caa14c7634b3 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/dynamic_lib.d.ts b/linter/test/dynamic_lib.d.ts index e3da589b5418ec259aa310a41fea0f454f17ede3..843931397eaf4c1fce6ff89f458826d49642771c 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 ea7f9759a2e8cf76d1eb0dd81536959bfcf1beeb..fae9413ea1d4ccb581327bddbdda25cb9c805912 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 diff --git a/linter/test/es_object.ts b/linter/test/es_object.ts index 445b5c0c07e1db8eb18c4006d860e3476659f6ae..cd1e530caa0989a80f1226c8b1a1d9a6c6a7c8f3 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 f3d5acdb48589622baa499e265b74a732fa003f6..5bab1a3eee7a781b35c0996be116badfe9617820 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,105 +488,112 @@ "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, "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, "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 +607,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 +635,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 5c869e41f36b202e2f7537f9bfa7a312c7073b8a..86c0f49acf614ff7fd4b654983ee1a6684b0d3a3 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,105 +488,112 @@ "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, "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, "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 +607,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 +635,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/function_expression.ts.autofix.json b/linter/test/function_expression.ts.autofix.json index 90e6f3f3b1843e1b27a91717ae8ec47ced32aeaa..e005781ad91e4c1a3c375d88874c9f64811e06bb 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, @@ -335,6 +343,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 +366,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 8e60772364f880a2b1734887f006e79ab0075cdd..48f6e1a27f9cde8a9f97bd009fcf972843b37619 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 1233c4e7db472396252e3157aac380db56d8e583..48723e4cddfa69f67dde850ebe2d3b944276fb9e 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, @@ -206,16 +213,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 790856d4f7ac64e42723ba8be5a20b7ae18f32a2..8b8fe68fe5a18f11f6df28e55d3574eb5d6d6b68 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)" @@ -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)" @@ -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 2a7c8ccd943aded4391752c20d2e26ecc66b4c29..a73e4ace1b5e021f8adb1f81fdb32357132b4ce3 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)" @@ -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)" @@ -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/functions.ts b/linter/test/functions.ts index 8d67f99ff3292a00005ed662c0798ca5ab08801e..fd8646324ae5cec720ba4c189a8dfdac408f85ff 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 bdec3c538a0a38afa2968f452019ea0cc98ccffe..0b6af45e6e03484b2768c01a8afaeb72405fa74d 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": "", @@ -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 e11f7f9c4b4ba8fd83a515d2609ee21e3b7f6c08..6729c50d23c446b1835bbe8bb90355aa46755ce6 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)" @@ -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 d39199ff0024aa2f8a01d89ad214a4e3c83e8212..d57b74aa35f727c11969750a8ddbd117512ecf46 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)" @@ -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/test/limited_stdlib_api.ts b/linter/test/limited_stdlib_api.ts index 500c10c9b1d179d12501a1cd57028ecfddda560e..e0213de3b393291674d76f750d8f818bcfe3f3de 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 ddabd1f8994bb6f656b118c4383596b762abe056..5fa775012fb48f18a4851216424f369122f42dfb 100644 --- a/linter/test/limited_stdlib_api.ts.autofix.json +++ b/linter/test/limited_stdlib_api.ts.autofix.json @@ -23,24 +23,32 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 31, "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": 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 +56,7 @@ }, { "line": 57, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -56,7 +64,7 @@ }, { "line": 58, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -72,7 +80,7 @@ }, { "line": 59, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -80,7 +88,7 @@ }, { "line": 61, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -88,7 +96,7 @@ }, { "line": 62, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -96,7 +104,7 @@ }, { "line": 63, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -104,7 +112,7 @@ }, { "line": 64, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -112,7 +120,7 @@ }, { "line": 65, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -120,7 +128,7 @@ }, { "line": 66, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -128,7 +136,7 @@ }, { "line": 67, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -136,7 +144,7 @@ }, { "line": 68, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -144,7 +152,7 @@ }, { "line": 69, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -152,7 +160,7 @@ }, { "line": 70, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -160,7 +168,7 @@ }, { "line": 71, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -168,7 +176,7 @@ }, { "line": 72, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -176,7 +184,7 @@ }, { "line": 73, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -184,7 +192,7 @@ }, { "line": 74, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -192,7 +200,7 @@ }, { "line": 75, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -200,7 +208,7 @@ }, { "line": 76, - "column": 8, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -208,7 +216,7 @@ }, { "line": 85, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -216,7 +224,7 @@ }, { "line": 86, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -232,7 +240,7 @@ }, { "line": 87, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -248,7 +256,7 @@ }, { "line": 88, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -256,7 +264,7 @@ }, { "line": 90, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -264,7 +272,7 @@ }, { "line": 91, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -272,7 +280,7 @@ }, { "line": 92, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -280,7 +288,7 @@ }, { "line": 93, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -288,7 +296,7 @@ }, { "line": 94, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -304,15 +312,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,15 +320,7 @@ }, { "line": 106, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 106, - "column": 32, + "column": 24, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -336,15 +328,7 @@ }, { "line": 107, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 107, - "column": 37, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -360,15 +344,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 +352,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 +360,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,15 +368,7 @@ }, { "line": 111, - "column": 37, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 112, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -432,15 +376,7 @@ }, { "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 +384,7 @@ }, { "line": 113, - "column": 35, + "column": 27, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -456,23 +392,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 +400,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 +408,7 @@ }, { "line": 116, - "column": 26, + "column": 18, "problem": "LimitedStdLibApi", "autofixable": false, "suggest": "", @@ -504,23 +416,7 @@ }, { "line": 117, - "column": 13, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 117, - "column": 37, - "problem": "LimitedStdLibApi", - "autofixable": false, - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 120, - "column": 13, + "column": 29, "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 d77e760a87296a86fded6e3d9e77ffd7fa7ffc76..22ad3a0ad0db9e8392f7e99130b121aff255248c 100644 --- a/linter/test/limited_stdlib_api.ts.relax.json +++ b/linter/test/limited_stdlib_api.ts.relax.json @@ -22,36 +22,43 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 31, "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": 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 +72,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 +212,7 @@ }, { "line": 87, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -219,42 +226,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 +275,21 @@ }, { "line": 105, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 105, - "column": 28, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 106, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 106, - "column": 32, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 107, - "column": 13, + "column": 24, "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 +303,70 @@ }, { "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 110, - "column": 13, + "column": 18, "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, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 113, - "column": 13, - "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 115, - "column": 13, + "column": 22, "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 120, - "column": 13, + "column": 29, "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 d77e760a87296a86fded6e3d9e77ffd7fa7ffc76..22ad3a0ad0db9e8392f7e99130b121aff255248c 100644 --- a/linter/test/limited_stdlib_api.ts.strict.json +++ b/linter/test/limited_stdlib_api.ts.strict.json @@ -22,36 +22,43 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { - "line": 32, + "line": 31, "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": 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 +72,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 +212,7 @@ }, { "line": 87, - "column": 9, + "column": 1, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" @@ -219,42 +226,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 +275,21 @@ }, { "line": 105, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 105, - "column": 28, + "column": 20, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 106, - "column": 13, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 106, - "column": 32, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 107, - "column": 13, + "column": 24, "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 +303,70 @@ }, { "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 110, - "column": 13, + "column": 18, "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, + "column": 18, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" }, { "line": 113, - "column": 13, - "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 115, - "column": 13, + "column": 22, "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, - "problem": "LimitedStdLibApi", - "suggest": "", - "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" - }, - { - "line": 120, - "column": 13, + "column": 29, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" diff --git a/linter/test/modules.ts.autofix.json b/linter/test/modules.ts.autofix.json index 3c5ec13d6f685451e8553fcdd3948471d0dd5d16..c78c786038a4bbdbe0aa25169ef04201cde936c3 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 c13f8f250c733e4a83febe03b93c51b08f61dae7..273338ee9f32ab2cf5c5e1280ab9e3371f9aaa13 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/new_target.ts.relax.json b/linter/test/new_target.ts.relax.json index 0b83a11983237ced2f41aa64eaaeb370019ee51f..5ec99daa29eeeccfa7c6b5bdcdcefea2f5999fe5 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 0b83a11983237ced2f41aa64eaaeb370019ee51f..5ec99daa29eeeccfa7c6b5bdcdcefea2f5999fe5 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_factory.ts b/linter/test/oh_modules/ohos_factory.ts index e26c4c911ba886e1d930a38404f9a87434d454b3..b4fc3d2d2fe025f7deb68faa0cf3374beece71ee 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 diff --git a/linter/test/property_access_by_index.ts b/linter/test/property_access_by_index.ts new file mode 100644 index 0000000000000000000000000000000000000000..d7cd6781fa202b2c0b4edda7ff3e532b162607e4 --- /dev/null +++ b/linter/test/property_access_by_index.ts @@ -0,0 +1,121 @@ +/* + * 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'); +} + +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] + +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 new file mode 100644 index 0000000000000000000000000000000000000000..df5e23653813b324741d7d9ee9d2eb375a2a3f05 --- /dev/null +++ b/linter/test/property_access_by_index.ts.autofix.json @@ -0,0 +1,74 @@ +{ + "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)" + }, + { + "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)" + }, + { + "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 new file mode 100644 index 0000000000000000000000000000000000000000..b492ed7380feb4b306433cd940c731223e71b0ad --- /dev/null +++ b/linter/test/property_access_by_index.ts.relax.json @@ -0,0 +1,39 @@ +{ + "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": 56, + "column": 5, + "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 new file mode 100644 index 0000000000000000000000000000000000000000..daf068f0d12f2dbc7b586c5f5033406a0b814f6f --- /dev/null +++ b/linter/test/property_access_by_index.ts.strict.json @@ -0,0 +1,67 @@ +{ + "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)" + }, + { + "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)" + }, + { + "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/prototype_assignment.ts.autofix.json b/linter/test/prototype_assignment.ts.autofix.json index 381cadf69d898a62ea6f5b7b50ff017f9d8c06d8..c1e3b5c631a1796b036aa3c90164158e70e21a2a 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 dc1c5be2ce6b380ee0700c0881a6314027de7d9b..79345f433f3e59b20e1a36a003d330eb58c5f4eb 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 ad3f542923b0e6db48ebf7877232046f1b070e7e..f1ebe772db7f34dbdfb39e3ff7cf91c80121ccde 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/symbol_api.ts b/linter/test/symbol_api.ts index 2d33c448f2d46c9150ee43b838b41f7dc5d98a37..8d7d25d3e16a892137741335ce918d61bd964a59 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; + }; +} diff --git a/linter/test/symbol_api.ts.relax.json b/linter/test/symbol_api.ts.relax.json index e62c8c7b772eb72b7c1c2e435f564313f0be758a..c2211cf10708b2fa141fd797dc845a3553c2e98a 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 e62c8c7b772eb72b7c1c2e435f564313f0be758a..c2211cf10708b2fa141fd797dc845a3553c2e98a 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/this_type.ts.relax.json b/linter/test/this_type.ts.relax.json index 1508e5c96b34e3b3431b1e03e2e7fa645a1210a7..7afe8f170d0efa17b22cc362e19f4a8275a6fb4f 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 1631a08e64978ecc086b96469881274e1f9c2747..1e2f8ec865ed7f6ed4f21e8993d3e71c67fdcf08 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/ts_ignore.ts b/linter/test/ts_ignore.ts index 3676a1550465e43c9205d6645b9262154c268fe3..5cee019035189a17a674aee7a28e83590af1420c 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 d1f5176718b5277f4744fd1d2237f1bec3ddae0e..f802c561b84b47c7e4c752428ed86cd5c76e97ae 100644 --- a/linter/test/ts_ignore.ts.relax.json +++ b/linter/test/ts_ignore.ts.relax.json @@ -14,65 +14,89 @@ "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, - "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" - }, - { - "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" - }, - { - "line": 53, - "column": 3, - "problem": "AnyType" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "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 d1f5176718b5277f4744fd1d2237f1bec3ddae0e..f802c561b84b47c7e4c752428ed86cd5c76e97ae 100644 --- a/linter/test/ts_ignore.ts.strict.json +++ b/linter/test/ts_ignore.ts.strict.json @@ -14,65 +14,89 @@ "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, - "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" - }, - { - "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" - }, - { - "line": 53, - "column": 3, - "problem": "AnyType" - }, - { - "line": 55, - "column": 22, - "problem": "AnyType" + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" }, { "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/types.ts.autofix.json b/linter/test/types.ts.autofix.json index 7833b9da06c47271168dc5b463b35b669eed9910..3263fe4927404003fa9338dcc7806eb519432e2c 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 12af0241f0080993d1207515856d070dd647e821..50971119921dde92707a4fc5e30b91fe2d2fa2ee 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, diff --git a/linter/test/utility_types.ts.relax.json b/linter/test/utility_types.ts.relax.json index fe6131546f4334735729e5e3c1ab931d44572443..b274ba451f7d4a73935b58506cb0afec12c13887 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" }, { @@ -266,12 +266,12 @@ }, { "line": 178, - "column": 18, + "column": 12, "problem": "FunctionApplyBindCall" }, { - "line": 183, - "column": 3, + "line": 184, + "column": 12, "problem": "FunctionContainsThis" }, { @@ -286,12 +286,17 @@ }, { "line": 187, - "column": 60, + "column": 54, "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 c5686de4b4c5b53e4bfe52a623bec80e0c788296..bbda8979a0c7b2d3dd266266257286f349161cf6 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" }, { @@ -291,12 +291,12 @@ }, { "line": 178, - "column": 18, + "column": 12, "problem": "FunctionApplyBindCall" }, { - "line": 183, - "column": 3, + "line": 184, + "column": 12, "problem": "FunctionContainsThis" }, { @@ -316,12 +316,17 @@ }, { "line": 187, - "column": 60, + "column": 54, "problem": "FunctionApplyBindCall" }, { - "line": 192, - "column": 1, + "line": 208, + "column": 9, + "problem": "FunctionContainsThis" + }, + { + "line": 209, + "column": 9, "problem": "FunctionContainsThis" }, { diff --git a/linter/test_rules/rule116.ts.autofix.json b/linter/test_rules/rule116.ts.autofix.json index 8449964f6b0aebed7a3a412a87e959afbcb33487..f3a5f41b3b987383c1f652c7373135cda5df7173 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 a5030d64e8a3e5c962cfc25bcfc7d49e88e73a86..3259498ae75cd5e1f5d128bfeacd40f997681159 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 a5030d64e8a3e5c962cfc25bcfc7d49e88e73a86..3259498ae75cd5e1f5d128bfeacd40f997681159 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/rule118.ts.autofix.json b/linter/test_rules/rule118.ts.autofix.json index 3ff68f6c73f0870b0af431b06348497a9bf6a784..13f13363f579325755e8954b4011963971667481 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 d30836a74acd706fd8fe37f455f2cb38b9d30f96..13f13363f579325755e8954b4011963971667481 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 c32c0f461dd55626cd83972b7aa2a8d7bff66f60..13f13363f579325755e8954b4011963971667481 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 35f1a58896b2262887e713eb7ea091a5342d8b98..13f13363f579325755e8954b4011963971667481 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 diff --git a/linter/test_rules/rule129.ts.autofix.json b/linter/test_rules/rule129.ts.autofix.json index 6708658aec6699b02802c0afa208ab7c076c39a4..80fc9c4b1fa0b7d2af2c6a19111f4c1a8102ef3d 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 cc882319377db9e73f996ceb24a77cc508180fdd..ab877e8e921e03d48ab1603fd2146e3f4fe9557f 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 cc882319377db9e73f996ceb24a77cc508180fdd..ab877e8e921e03d48ab1603fd2146e3f4fe9557f 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, diff --git a/linter/test_rules/rule132.ts.autofix.json b/linter/test_rules/rule132.ts.autofix.json index d1868ca7f895576a790a872e83c05b3f7b619086..9002b4276ade0505b91332d17e0d7c64608c6e8f 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 21468ce90773221bb8d0e37917a8f9a5eb974223..192c3aa101f830da08961e07bd44fabed0c97d54 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 21468ce90773221bb8d0e37917a8f9a5eb974223..192c3aa101f830da08961e07bd44fabed0c97d54 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)" diff --git a/linter/test_rules/rule136.ts.autofix.json b/linter/test_rules/rule136.ts.autofix.json index fb3ab2780e7b41d6ce964d9fdaae740e3df24cb2..2f60e039c03a5cd1e052d62c694d5d436c7e70ba 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 d9d652719abe74c16916a18a344c7bc48bb31a1c..ccffcfe551a88c8e82bca56d747278ad00fca438 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 1df9367d3575996793782d76b077665c8275a070..03f0cbbe59c03d3056550c6e1f16e031b8f18718 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 872acd394066cbc9e387b56a855037bb74ddc8ab..819c25194284cf48a8701462d1c1c31871221d4f 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 a16283a186b51f9545d9a78a95a673bbd7acbd15..772a1f628e47461607ed2422e22212586394fbc1 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 a16283a186b51f9545d9a78a95a673bbd7acbd15..772a1f628e47461607ed2422e22212586394fbc1 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)"