lintroll 1.21.0 → 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
|
|
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
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`).filter(Boolean).map(
|
|
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)})();
|