diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 55e45ad..168af7c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -19,6 +19,6 @@ jobs: registry-url: 'https://registry.npmjs.org' - run: npm install -g npm - run: npm ci - - run: npm publish --provenance --access public + - run: npm publish --provenance --access public --tag=beta.1 env: NODE_AUTH_TOKEN: ${{secrets.AFUTEAM_LINT_PUBLISH_NPM_TOKEN}} \ No newline at end of file diff --git a/bin/index.js b/bin/index.js index bdca64c..e411ae1 100644 --- a/bin/index.js +++ b/bin/index.js @@ -59,6 +59,7 @@ async function lintFiles(filePaths) { let totalBlankLines = 0; // 空行 let totalCommentLines = 0; // 注释行数 let totalCodeLines = 0; // 代码行数 + let complexityData = []; // 复杂度统计 for (const filePath of filePaths) { const curFileIsIgnored = isFileIgnored(filePath); @@ -85,7 +86,6 @@ async function lintFiles(filePaths) { return } - // console.log(fileGroups[fileType]) const results = await whichEslintInstances.lintFiles( fileGroups[fileType] ); @@ -97,9 +97,18 @@ async function lintFiles(filePaths) { totalErrors += result.errorCount; totalWarnings += result.warningCount; }); + // 这个是给开发者看的,方便结合编辑器直接定位到问题处 console.error(resultText); } + // 复杂度 + if(results?.length > 0) { + results.forEach(result => { + const messageWhichRuleId = 'complexity' + const complexityMsg = result?.messages?.filter(item => item.ruleId === messageWhichRuleId) + complexityData.push(...complexityMsg) + }) + } // 统计进行lint的代码行数 try { @@ -114,9 +123,6 @@ async function lintFiles(filePaths) { }); let filePathsStr = dealNameHasBlank.join(' '); - // let stdout = execSync(`cloc --json ${filePathsStr}`).toString(); - // console.log('wow\n', JSON.parse(stdout)) - let stdout = execSync(`${clocPath} --json ${filePathsStr}`).toString(); totalBlankLines += JSON.parse(stdout)['SUM']?.blank || 0 totalCommentLines += JSON.parse(stdout)['SUM']?.comment || 0 @@ -129,8 +135,8 @@ async function lintFiles(filePaths) { } } - console.log('排除目录列表:\n', JSON.stringify(BlackFilesList)); - console.log('排除文件名:', FileIgnoredList); + // console.log('排除目录列表:\n', JSON.stringify(BlackFilesList)); + // console.log('排除文件名:', FileIgnoredList); console.log('支持文件类型:', supportFileExtNames); console.log('\n') @@ -140,6 +146,8 @@ async function lintFiles(filePaths) { console.log('Total totalBlankLines:', totalBlankLines); console.log('Total totalCommentLines:', totalCommentLines); console.log('Total totalCodeLines:', totalCodeLines); + console.log('Total complexityDataLength:', complexityData.length); + console.log('Total complexityData:', JSON.stringify(complexityData)); console.log('\n') diff --git a/package.json b/package.json index 5a6e8a3..8269d5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@afuteam/eslint-plugin-fe", - "version": "2.0.6", + "version": "2.0.6.beta.1", "description": "AfuTeam ESLint Plugin", "main": "./lib/index.js", "exports": {