private static void CheckProjectLikeImportFromIsNotInV2Specs(INode node, DiagnosticContext context) { var callExpression = node.Cast <ICallExpression>(); // If the project belongs to a module with implicit references and the expression is an importFrom, then the specifier cannot be // project-like if (context.Workspace.SpecBelongsToImplicitSemanticsModule(context.SourceFile.GetAbsolutePath(context.PathTable)) && callExpression.IsImportFrom()) { var moduleSpecifier = callExpression.Arguments[0].Cast <IStringLiteral>(); if (ModuleReferenceResolver.IsValidModuleReference(moduleSpecifier) && !ModuleReferenceResolver.IsModuleReference(moduleSpecifier)) { context.Logger.ReportProjectLikeImportOrExportNotAllowedInModuleWithImplicitSemantics( context.LoggingContext, node.LocationForLogging(context.SourceFile), callExpression.Arguments[0].GetFormattedText()); } } }
private static void CheckProjectLikeImportsOrExportsNotInV2Specs(INode node, DiagnosticContext context) { IExpression specifier = node.GetModuleSpecifier(); var literalExpression = specifier?.As <IStringLiteral>(); // There is a lint rule that enforces this, but it might have not run yet if (literalExpression == null || literalExpression.LiteralKind == LiteralExpressionKind.None) { return; } // If the spec belongs to a module with implicit references, then project-like imports are not allowed if (context.Workspace.SpecBelongsToImplicitSemanticsModule(context.SourceFile.GetAbsolutePath(context.PathTable)) && !ModuleReferenceResolver.IsModuleReference(literalExpression)) { context.Logger.ReportProjectLikeImportOrExportNotAllowedInModuleWithImplicitSemantics( context.LoggingContext, node.LocationForLogging(context.SourceFile), specifier.GetFormattedText()); } }