UNPKG

pneulint

Version:

Static code analysis tool for better code

2 lines 803 B
#!/usr/bin/env node import yargs from"yargs";import{hideBin}from"yargs/helpers";import fs from"fs";import path from"path";import lintFile from"./lintFile.js";function processFiles(t,e){try{fs.statSync(t).isDirectory()?fs.readdirSync(t).forEach((r=>{processFiles(path.join(t,r),e)})):[".js",".ts"].includes(path.extname(t))&&lintFile(t,e)}catch(e){console.error(`Error processing ${t}: ${e.message}`)}}const argv=yargs(hideBin(process.argv)).command("$0 [path]","Lint files in the given path",(t=>{t.positional("path",{describe:"Path to directory or file to lint",type:"string",default:"."})})).option("complexity",{alias:"c",describe:"Complexity threshold",type:"number",default:10}).help().argv,pathToLint=argv.path||".",complexityThreshold=argv.complexity;processFiles(pathToLint,complexityThreshold);