lintroll 1.20.1 → 1.22.0

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/README.md CHANGED
@@ -37,28 +37,33 @@ The `lintroll` command can be used as drop-in replacement for `eslint`, allowing
37
37
  #### Lint files in the current directory
38
38
 
39
39
  ```sh
40
- lintroll .
40
+ lintroll
41
41
  ```
42
42
 
43
43
  #### Apply auto fix
44
44
 
45
45
  ```sh
46
- lintroll . --fix
46
+ lintroll --fix
47
47
  ```
48
48
 
49
49
  #### Lint with caching enabled
50
50
  ```sh
51
- lintroll --cache .
51
+ lintroll --cache
52
52
  ```
53
53
 
54
54
  #### Lint only staged files
55
55
  ```sh
56
- lintroll --staged .
56
+ lintroll --staged
57
+ ```
58
+
59
+ #### Lint only git tracked files
60
+ ```sh
61
+ lintroll --git
57
62
  ```
58
63
 
59
64
  #### Specify Node.js files
60
65
  ```sh
61
- lintroll --node=./build .
66
+ lintroll --node=./build
62
67
  ```
63
68
 
64
69
  ### Optional `package.json` script
@@ -98,6 +103,7 @@ Flags:
98
103
  --cache Only check changed files
99
104
  --cache-location <string> Path to the cache file or directory
100
105
  --fix Automatically fix problems
106
+ --git Only lint git tracked files within the files passed in
101
107
  -h, --help Show help
102
108
  --ignore-pattern <string> Pattern of files to ignore
103
109
  --node <string> Enable Node.js rules. Pass in a glob to specify files
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var h=Object.defineProperty;var r=(o,t)=>h(o,"name",{value:t,configurable:!0});import m from"node:path";import{cli as b}from"cleye";import{ESLint as p}from"eslint";import g from"nano-spawn";import{n as d,p as y}from"../index-CbF9umZK.mjs";import{pathToFileURL as C}from"node:url";import v from"node:fs/promises";import{tsImport as x}from"tsx/esm/api";import"@eslint/js";import"globals";import"confusing-browser-globals";import"node:module";import"../index-C3zPrSIs.mjs";import"node:process";import"node:fs";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"get-tsconfig";import"eslint-plugin-vue";import"vue-eslint-parser";import"eslint/use-at-your-own-risk";const s=r(async o=>v.access(o).then(()=>o,()=>{}),"exists"),E=r(async o=>{const t=await s("eslint.config.mts")??await s("eslint.config.mjs")??await s("eslint.config.cts")??await s("eslint.config.cjs")??await s("eslint.config.ts")??await s("eslint.config.js");if(t){let i=await x(C(t).toString(),import.meta.url);for(;"default"in i&&i.default;)i=i.default;if(i)return console.log(`[${d}]: Using config file: ${t}`),i}return y(o)},"getConfig"),F=r(o=>{let t=0,i=0,n=0;for(const a of o)t+=a.errorCount,i+=a.fatalErrorCount,n+=a.warningCount;return{errorCount:t,fatalErrorCount:i,warningCount:n}},"countErrors"),P=r(o=>o.fatalErrorCount>0?2:o.errorCount>0?1:0,"getExitCode"),e=b({name:d,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"},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"}}}),A=r(o=>{if(o.length===0)return!1;const t=o.filter(i=>i.length>0);return t.length>0?t:!0},"isNodeEnabled");(async()=>{const o=new p({baseConfig:await E({node:A(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});let{files:t}=e._;if(t.length===0&&(t=["."]),t=t.map(l=>m.resolve(l)),e.flags.staged)try{const{stdout:l}=await g("git",["rev-parse","--show-toplevel"]),{stdout:u}=await g("git",["diff","--staged","--name-only","--diff-filter=ACMR"]);t=u.split(`
3
- `).filter(Boolean).map(f=>m.resolve(l,f)).filter(f=>t.some(w=>f.startsWith(w)))}catch{console.error("Error: Failed to detect staged files from git"),process.exit(1)}const i=await o.lintFiles(t);e.flags.fix&&await p.outputFixes(i);let n=i;e.flags.quiet&&(n=p.getErrorResults(i));const a=F(i),c=await(await o.loadFormatter()).format(n);c&&console.log(c),process.exitCode=P(a)})();
2
+ var y=Object.defineProperty;var s=(i,t)=>y(i,"name",{value:t,configurable:!0});import g from"node:path";import{cli as b}from"cleye";import{ESLint as d}from"eslint";import f from"nano-spawn";import{n as h,p as v}from"../index-CA_1mF09.mjs";import{pathToFileURL as x}from"node:url";import C from"node:fs/promises";import{tsImport as F}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"node:fs";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 n=s(async i=>C.access(i).then(()=>i,()=>{}),"exists"),E=s(async i=>{const t=await n("eslint.config.mts")??await n("eslint.config.mjs")??await n("eslint.config.cts")??await n("eslint.config.cjs")??await n("eslint.config.ts")??await n("eslint.config.js");if(t){let e=await F(x(t).toString(),import.meta.url);for(;"default"in e&&e.default;)e=e.default;if(e)return console.log(`[${h}]: Using config file: ${t}`),e}return v(i)},"getConfig"),P=s(i=>{let t=0,e=0,a=0;for(const l of i)t+=l.errorCount,e+=l.fatalErrorCount,a+=l.warningCount;return{errorCount:t,fatalErrorCount:e,warningCount:a}},"countErrors"),k=s(i=>i.fatalErrorCount>0?2:i.errorCount>0?1:0,"getExitCode"),o=b({name:h,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"}}}),A=s(i=>{if(i.length===0)return!1;const t=i.filter(e=>e.length>0);return t.length>0?t:!0},"isNodeEnabled");(async()=>{const i=new d({baseConfig:await E({node:A(o.flags.node),allowAbbreviations:{exactWords:o.flags.allowAbbreviation,substrings:o.flags.allowAbbreviation}}),overrideConfigFile:!0,fix:o.flags.fix,cache:o.flags.cache,cacheLocation:o.flags.cacheLocation,ignorePatterns:o.flags.ignorePattern});let{files:t}=o._;if(t.length===0&&(t=["."]),t=t.map(c=>g.resolve(c)),o.flags.staged)try{const{stdout:c}=await f("git",["rev-parse","--show-toplevel"]),{stdout:p}=await f("git",["diff","--staged","--name-only","--diff-filter=ACMR"]);t=p.split(`
3
+ `).filter(Boolean).map(r=>g.resolve(c,r)).filter(r=>t.some(m=>r.startsWith(m)))}catch{console.error("Error: Failed to detect staged files from git"),process.exit(1)}if(o.flags.git)try{const{stdout:c}=await f("git",["rev-parse","--show-toplevel"]),{stdout:p}=await f("git",["ls-files"]);t=p.split(`
4
+ `).filter(Boolean).map(r=>g.resolve(c.trim(),r)).filter(r=>t.some(m=>r.startsWith(m)))}catch{console.error("Error: Failed to detect tracked files from git"),process.exit(1)}if(t.length===0){process.exitCode=0;return}const e=await i.lintFiles(t);o.flags.fix&&await d.outputFixes(e);let a=e;o.flags.quiet&&(a=d.getErrorResults(e));const l=P(e),u=await(await i.loadFormatter()).format(a);u&&console.log(u),process.exitCode=k(l)})();