Skip to content

Commit

Permalink
test: beta版,增加复杂度输出参数
Browse files Browse the repository at this point in the history
  • Loading branch information
eyea committed Mar 11, 2024
1 parent 82a60a0 commit ead9b2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
20 changes: 14 additions & 6 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -85,7 +86,6 @@ async function lintFiles(filePaths) {
return
}

// console.log(fileGroups[fileType])
const results = await whichEslintInstances.lintFiles(
fileGroups[fileType]
);
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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')

Expand All @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit ead9b2b

Please sign in to comment.