Skip to content

Commit

Permalink
fix: 代码统计使用项目依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxudong13804 committed Feb 21, 2024
1 parent 2770dcd commit a1773d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ let allowInlineConfig = false
const filesToLint = [];

const eslintInstances = {};
//指定cloc在node_modules里面的路径
const clocPath = path.join('./', 'node_modules/cloc', 'lib', 'cloc');

function generateEslintInstances() {
const lintnames = Object.keys(LibRulesAndConfigs.configsFilePaths);
Expand Down Expand Up @@ -104,7 +106,7 @@ async function lintFiles(filePaths) {
// let stdout = execSync(`cloc --json ${filePathsStr}`).toString();
// console.log('wow\n', JSON.parse(stdout))

let stdout = execSync(`cloc --json ${filePathsStr}`).toString();
let stdout = execSync(`${clocPath} --json ${filePathsStr}`).toString();
totalBlankLines += JSON.parse(stdout)['SUM']?.blank || 0
totalCommentLines += JSON.parse(stdout)['SUM']?.comment || 0
totalCodeLines += JSON.parse(stdout)['SUM']?.code || 0
Expand All @@ -117,7 +119,7 @@ async function lintFiles(filePaths) {
console.log('支持文件类型:', supportFileExtNames);
console.log('\n')

// WARN 这三行不可以省略,npx 统计结果用
// WARN 这三行不可以省略和更改,npx 统计结果用
console.log('Total errors:', totalErrors);
console.log('Total warnings:', totalWarnings);
console.log('Total totalBlankLines:', totalBlankLines);
Expand Down
13 changes: 11 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 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.5-beta.6",
"version": "2.0.5-beta.7",
"description": "AfuTeam ESLint Plugin",
"main": "./lib/index.js",
"exports": {
Expand Down Expand Up @@ -49,6 +49,7 @@
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@vue/eslint-config-typescript": "^11.0.2",
"cloc": "^2.0.0-cloc",
"eslint": ">=7",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-eslint-plugin": "^5.0.0",
Expand Down

0 comments on commit a1773d0

Please sign in to comment.