lintroll 1.23.3 → 1.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var v=Object.defineProperty;var n=(t,i)=>v(t,"name",{value:i,configurable:!0});import d from"node:path";import f from"node:fs";import{cli as x}from"cleye";import{ESLint as p}from"eslint";import m from"nano-spawn";import{n as u,p as C}from"../index-
|
|
2
|
+
var v=Object.defineProperty;var n=(t,i)=>v(t,"name",{value:i,configurable:!0});import d from"node:path";import f from"node:fs";import{cli as x}from"cleye";import{ESLint as p}from"eslint";import m from"nano-spawn";import{n as u,p as C}from"../index-BzmkU2dI.mjs";import{pathToFileURL as E}from"node:url";import F from"node:fs/promises";import{tsImport as P}from"tsx/esm/api";import"get-tsconfig";import"@eslint/js";import"globals";import"confusing-browser-globals";import"node:module";import"../index-C3zPrSIs.mjs";import"node:process";import"@eslint-community/eslint-plugin-eslint-comments";import"@stylistic/eslint-plugin";import"eslint-plugin-import-x";import"@typescript-eslint/eslint-plugin";import"@typescript-eslint/parser";import"eslint-plugin-regexp";import"eslint-plugin-n";import"os";import"url";import"util";import"eslint-plugin-promise";import"@eslint/markdown";import"eslint-plugin-jsonc";import"eslint-plugin-yml";import"yaml-eslint-parser";import"eslint-plugin-no-use-extend-native";import"eslint-plugin-unicorn";import"eslint-plugin-react";import"eslint-plugin-react-hooks";import"eslint-plugin-vue";import"vue-eslint-parser";import"eslint/use-at-your-own-risk";const a=n(async t=>F.access(t).then(()=>t,()=>{}),"exists"),S=n(async t=>{const i=await a("eslint.config.mts")??await a("eslint.config.mjs")??await a("eslint.config.cts")??await a("eslint.config.cjs")??await a("eslint.config.ts")??await a("eslint.config.js");if(i){let o=await P(E(i).toString(),import.meta.url);for(;"default"in o&&o.default;)o=o.default;if(o)return console.log(`[${u}]: Using config file: ${i}`),o}return C(t)},"getConfig"),A=n(t=>{let i=0,o=0,r=0;for(const s of t)i+=s.errorCount,o+=s.fatalErrorCount,r+=s.warningCount;return{errorCount:i,fatalErrorCount:o,warningCount:r}},"countErrors"),R=n(t=>t.fatalErrorCount>0?2:t.errorCount>0?1:0,"getExitCode"),e=x({name:u,parameters:["[files...]"],help:{description:"Opinionated ESLint by @privatenumber (Hiroki Osame)"},flags:{fix:{type:Boolean,description:"Automatically fix problems"},staged:{type:Boolean,description:"Only lint staged files within the files passed in"},git:{type:Boolean,description:"Only lint git tracked files within the files passed in"},quiet:{type:Boolean,description:"Report errors only"},cache:{type:Boolean,description:"Only check changed files"},cacheLocation:{type:String,description:"Path to the cache file or directory"},ignorePattern:{type:[String],description:"Pattern of files to ignore"},node:{type:[String],description:"Enable Node.js rules. Pass in a glob to specify files"},allowAbbreviation:{type:[String],description:"Allow abbreviations"}}}),B=n(t=>{if(t.length===0)return!1;const i=t.filter(o=>o.length>0);return i.length>0?i:!0},"isNodeEnabled"),h=n(t=>t.replaceAll("\\","/"),"normalizePath"),w=n((t,i,o)=>t.split(`
|
|
3
3
|
`).filter(Boolean).map(r=>h(f.realpathSync.native(d.resolve(i,r)))).filter(r=>o.some(s=>r.startsWith(s))),"filterGitFiles"),y=n(async()=>{const{stdout:t}=await m("git",["rev-parse","--show-toplevel"]);return t.trim()},"gitRootPath");(async()=>{let{files:t}=e._;if(t.length===0&&(t=["."]),t=t.map(l=>h(f.realpathSync.native(d.resolve(l)))),e.flags.staged)try{const l=await y(),{stdout:c}=await m("git",["diff","--staged","--name-only","--diff-filter=ACMR"]);t=w(c,l,t)}catch{console.error("Error: Failed to detect staged files from git"),process.exit(1)}if(e.flags.git)try{const l=await y(),{stdout:c}=await m("git",["ls-files"]);t=w(c,l,t)}catch{console.error("Error: Failed to detect tracked files from git"),process.exit(1)}if(t.length===0){process.exitCode=0;return}const i=f.realpathSync.native(process.cwd()),o=new p({cwd:i,baseConfig:await S({cwd:i,node:B(e.flags.node),allowAbbreviations:{exactWords:e.flags.allowAbbreviation,substrings:e.flags.allowAbbreviation}}),overrideConfigFile:!0,fix:e.flags.fix,cache:e.flags.cache,cacheLocation:e.flags.cacheLocation,ignorePatterns:e.flags.ignorePattern}),r=await o.lintFiles(t);e.flags.fix&&await p.outputFixes(r);let s=r;e.flags.quiet&&(s=p.getErrorResults(r));const b=A(r),g=await(await o.loadFormatter()).format(s);g&&console.log(g),process.exitCode=R(b)})();
|