From d22ddb9b50552a2921acc37079c47177fa128ecd Mon Sep 17 00:00:00 2001 From: Charles Lee Date: Fri, 29 Mar 2019 16:19:39 +0800 Subject: [PATCH] fix: update warning message --- .lintstagedrc | 3 ++- packages/zent/scripts/cruiser/mapping.ts | 14 +++++--------- packages/zent/scripts/cruiser/registry.ts | 14 +++++++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.lintstagedrc b/.lintstagedrc index 05b1b2cc03..93c1b635b2 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,5 +1,6 @@ { "*.js": ["yarn format", "eslint", "git add"], - "*.{ts,tsx}": ["yarn format", "tslint --format stylish --project packages/zent/tsconfig.json", "git add"], + "packages/zent/src/*.{ts,tsx}": ["yarn format", "tslint --format stylish --project packages/zent/tsconfig.json", "git add"], + "packages/zent/scripts/cruiser/*.{ts,tsx}": ["yarn format", "tslint --format stylish --project packages/zent/scripts/cruiser/tsconfig.json", "git add"], "*.scss": ["yarn format", "sass-lint -vq", "git add"] } diff --git a/packages/zent/scripts/cruiser/mapping.ts b/packages/zent/scripts/cruiser/mapping.ts index 76bb397ec7..5ede5d911d 100644 --- a/packages/zent/scripts/cruiser/mapping.ts +++ b/packages/zent/scripts/cruiser/mapping.ts @@ -120,7 +120,7 @@ function tsort(edges: Graph): string[] { }; // 1. build data structures - edges.forEach(function(v) { + edges.forEach(v => { const from = v[0]; const to = v[1]; if (!nodes[from]) nodes[from] = new Node(from); @@ -147,19 +147,15 @@ function tsort(edges: Graph): string[] { visited[idstr] = true; - node.afters.forEach(function(afterID) { + node.afters.forEach(afterID => { const ances = ancestors as string[]; - if (ances.indexOf(afterID) >= 0) + if (ances.indexOf(afterID) >= 0) { // if already in ancestors, a closed chain exists. throw new Error('closed chain : ' + afterID + ' is in ' + id); + } - visit( - afterID.toString(), - ances.map(function(v) { - return v; - }) - ); // recursive call + visit(afterID.toString(), ances.map(v => v)); // recursive call }); sorted.unshift(id); diff --git a/packages/zent/scripts/cruiser/registry.ts b/packages/zent/scripts/cruiser/registry.ts index bffe8feaff..a182489d1b 100644 --- a/packages/zent/scripts/cruiser/registry.ts +++ b/packages/zent/scripts/cruiser/registry.ts @@ -11,7 +11,7 @@ export interface IRegistry { [key: string]: { exports: Set; dependencies: Set }; } -interface SourceFile extends ts.SourceFile { +interface ISourceFile extends ts.SourceFile { imports?: ts.StringLiteral[]; } @@ -82,7 +82,7 @@ function parseValueExports( * Excludes export ... from './x' */ function getModuleLocalExportedValueNames( - sourceFile: SourceFile + sourceFile: ISourceFile ): Set { const exportedVariables = new Set(); sourceFile.statements.forEach(stmt => { @@ -124,7 +124,7 @@ function getModuleLocalExportedValueNames( * 4. imports of 1,2,3 */ function getModuleValueNames( - sourceFile: SourceFile, + sourceFile: ISourceFile, cwd: string, registry: IRegistry, exportedLocalVariables: Set @@ -207,7 +207,7 @@ function getModuleValueNames( * 4. re-exports of 1,2,3 from other modules */ function getModuleValueExportNames( - sourceFile: SourceFile, + sourceFile: ISourceFile, cwd: string, registry: IRegistry, localValueVariables: Set @@ -216,7 +216,7 @@ function getModuleValueExportNames( sourceFile.statements.forEach(stmt => { if (ts.isVariableStatement(stmt)) { // export const A = 1 - if (isNodeExported((stmt) as ts.Declaration)) { + if (isNodeExported((stmt as unknown) as ts.Declaration)) { const vars = getVariableNames(stmt.declarationList.declarations); for (const v of vars) { if (localValueVariables.has(v)) { @@ -278,7 +278,7 @@ function getModuleValueExportNames( } else if (stmt.moduleSpecifier) { console.warn( chalk.yellow( - `Named export '${propertyName}' not found in module ${dependentModulePath}` + `Named export '${propertyName}' not found in module ${dependentModulePath}\nYou can safely ignore this warning if it is an exported type` ) ); } @@ -384,7 +384,7 @@ function getBindingNames( /** * Parse a module */ -function createSourceFile(filename: string): SourceFile { +function createSourceFile(filename: string): ISourceFile { /** ts.CompilerHost */ const compilerHost = { fileExists: () => true,