Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "vrms-server",
"version": "0.3.0",
"description": "VRMS Server",
"type": "module",
"scripts": {
"start": "concurrently \"cd backend && npm run start\" \"cd client && npm run start\"",
"mvp": "concurrently \"cd backend && npm run start\" \"cd client-mvp-04 && npm run start\"",
Expand All @@ -16,7 +17,8 @@
"test:backend": "cd backend && npm run test",
"test:client": "cd client && npm run test",
"test:all": "cross-env NODE_ENV=test npm run test:client && npm run test:backend",
"prepare": "husky install"
"prepare": "husky install",
"lint:files": "node scripts/list-lint-files.js"
},
"dependencies": {
"@mui/icons-material": "^5.14.19",
Expand Down
46 changes: 46 additions & 0 deletions scripts/list-lint-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//import node modules for running shell commands and handling files, define file names
import { execSync } from "child_process";
import fs from "fs";
const reportFile = "lint-report.json";
const countFile = "lint-files.count.txt";

// Generate report
const generateReports = (results, exitCode) => {
const countContent = `After running the lint found total number of the files has linting problems: ${results.length}`;
fs.writeFileSync(countFile, countContent, "utf-8");
console.log(
`Found ${results.length} files with linting errors. Total written to ${countFile}`,
);

const modifiedResults = results.map((result) => {
const vrmsIndex = result.filePath.indexOf("VRMS");
const relativePath = result.filePath.substring(vrmsIndex + 4);
return { ...result, filePath: relativePath };
});

const formattedJson = JSON.stringify(modifiedResults, null, 2);
fs.writeFileSync(reportFile, formattedJson, "utf-8");

console.log(`Lint report created: ${reportFile}`);
process.exit(exitCode);
};

try {
const stdout = execSync("npx eslint . --format json").toString();
const results = JSON.parse(stdout);
generateReports(results, 0);
} catch (error) {
let results;
try {
const stdout = error.stdout.toString();
results = JSON.parse(stdout);
} catch (parseError) {
console.error(
"Failed to parse ESLint output. The output was not valid JSON.",
);
console.error("Error details:", parseError.message);
console.error("Raw output:", error.stdout.toString());
process.exit(1);
}
generateReports(results, 1);
}
Loading