@jsse/eslint-config 0.9.1 → 0.9.3
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/CHANGELOG.md +17 -0
- package/README.md +68 -23
- package/dist/cli.js +2 -3
- package/dist/dist-DS02OtwI.js +143 -0
- package/dist/fixable-rules-map-Cdv6wg6P.d.ts +488 -0
- package/dist/fixable.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1153 -615
- package/dist/{fixable-rules-map-DICjDbU8.d.ts → rule-types-DKF8Uy8X.d.ts} +668 -1164
- package/dist/rule-types.d.ts +2 -0
- package/dist/rule-types.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +58 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @jsse/eslint-config
|
|
2
2
|
|
|
3
|
+
## 0.9.3
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- Update lint defaults for JSDoc and TypeScript.
|
|
7
|
+
|
|
8
|
+
- Configure `jsdoc/tag-lines` to only remove trailing empty JSDoc lines.
|
|
9
|
+
- Tighten TypeScript assertions, unused expression handling, and useless
|
|
10
|
+
constructor checks with TypeScript-aware rules.
|
|
11
|
+
- Reuse shared plugin exports in the plugin registry to avoid duplicate package
|
|
12
|
+
imports.
|
|
13
|
+
|
|
14
|
+
## 0.9.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- updated eslint react configuration styule
|
|
19
|
+
|
|
3
20
|
## 0.9.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ import jsse from "@jsse/eslint-config";
|
|
|
64
64
|
|
|
65
65
|
export default jsse({
|
|
66
66
|
typescript: {
|
|
67
|
+
presets: "recommended-type-checked",
|
|
67
68
|
tsconfig: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
|
|
68
69
|
},
|
|
69
70
|
});
|
|
@@ -71,29 +72,29 @@ export default jsse({
|
|
|
71
72
|
|
|
72
73
|
### Common Options
|
|
73
74
|
|
|
74
|
-
| Option | Default | Notes
|
|
75
|
-
| ----------------- | ------------------------------ |
|
|
76
|
-
| `typescript` | auto-detect | Enabled when `typescript` is installed. Passing `{ tsconfig }` enables type-aware rules unless `typeAware: false` is set. |
|
|
77
|
-
| `typeAware` | `false` | Explicit override for type-aware TypeScript rules.
|
|
78
|
-
| `react` | `false` | Enables React rules; accepts `
|
|
79
|
-
| `reactRefresh` | `true` when `react` is enabled |
|
|
80
|
-
| `antfu` | `true` | Enables `eslint-plugin-antfu`; accepts `topLevelFunction` and `overrides`.
|
|
81
|
-
| `demorgan` | `true` | Enables `eslint-plugin-de-morgan`; accepts `overrides`.
|
|
82
|
-
| `e18e` | `true` | Enables `@e18e/eslint-plugin`.
|
|
83
|
-
| `jsdoc` | `true` | Enables `eslint-plugin-jsdoc`; accepts `overrides`.
|
|
84
|
-
| `n` | `true` | Enables Node.js rules from `eslint-plugin-n`; accepts `overrides`.
|
|
85
|
-
| `nodeTest` | `false` | Enables `eslint-node-test` (Node.js built-in test runner rules); accepts `{ preset, overrides }`.
|
|
86
|
-
| `unicorn` | `true` | Enables `eslint-plugin-unicorn`; accepts `{ preset, overrides }`.
|
|
87
|
-
| `vitest` | auto-detect | Enabled when `vitest` is installed. Enables `@vitest/eslint-plugin`; accepts `overrides`.
|
|
88
|
-
| `prettier` | `true` | Disables known ESLint/Prettier conflicts. This does not run Prettier.
|
|
89
|
-
| `stylistic` | `true` | Enables selected `@stylistic` rules. Supports `indent`, `quotes`, and `jsx`.
|
|
90
|
-
| `jsonc` | `true` | Enables JSON/JSONC rules.
|
|
91
|
-
| `markdown` | `false` | Enables Markdown processing and fenced-code linting.
|
|
92
|
-
| `yaml` | `false` | Enables YAML rules.
|
|
93
|
-
| `sortImports` | `false` | Enables import/export sorting via Perfectionist.
|
|
94
|
-
| `sortPackageJson` | `true` | Requires `jsonc` to be enabled.
|
|
95
|
-
| `sortTsconfig` | `true` | Requires `jsonc`; accepts `extendTsconfigGlobs`.
|
|
96
|
-
| `tailwind` | `false` | Deprecated. Passing it only prints a warning.
|
|
75
|
+
| Option | Default | Notes |
|
|
76
|
+
| ----------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `typescript` | auto-detect | Enabled when `typescript` is installed. Accepts `{ presets, tsconfig, overrides }`. Passing `{ tsconfig }` enables type-aware rules unless `typeAware: false` is set. |
|
|
78
|
+
| `typeAware` | `false` | Explicit override for type-aware TypeScript rules. |
|
|
79
|
+
| `react` | `false` | Enables React rules; accepts `refresh`, `preset`, and `overrides`. TS/TSX parsing comes entirely from `typescript`/`tsconfig`. |
|
|
80
|
+
| `reactRefresh` | `true` when `react` is enabled | Legacy top-level alias. Prefer `react.refresh: false` to disable React Refresh rules. |
|
|
81
|
+
| `antfu` | `true` | Enables `eslint-plugin-antfu`; accepts `topLevelFunction` and `overrides`. |
|
|
82
|
+
| `demorgan` | `true` | Enables `eslint-plugin-de-morgan`; accepts `overrides`. |
|
|
83
|
+
| `e18e` | `true` | Enables `@e18e/eslint-plugin`. |
|
|
84
|
+
| `jsdoc` | `true` | Enables `eslint-plugin-jsdoc`; accepts `overrides`. |
|
|
85
|
+
| `n` | `true` | Enables Node.js rules from `eslint-plugin-n`; accepts `overrides`. |
|
|
86
|
+
| `nodeTest` | `false` | Enables `eslint-node-test` (Node.js built-in test runner rules); accepts `{ preset, overrides }`. |
|
|
87
|
+
| `unicorn` | `true` | Enables `eslint-plugin-unicorn`; accepts `{ preset, overrides }`. |
|
|
88
|
+
| `vitest` | auto-detect | Enabled when `vitest` is installed. Enables `@vitest/eslint-plugin`; accepts `overrides`. |
|
|
89
|
+
| `prettier` | `true` | Disables known ESLint/Prettier conflicts. This does not run Prettier. |
|
|
90
|
+
| `stylistic` | `true` | Enables selected `@stylistic` rules. Supports `indent`, `quotes`, and `jsx`. |
|
|
91
|
+
| `jsonc` | `true` | Enables JSON/JSONC rules. |
|
|
92
|
+
| `markdown` | `false` | Enables Markdown processing and fenced-code linting. |
|
|
93
|
+
| `yaml` | `false` | Enables YAML rules. |
|
|
94
|
+
| `sortImports` | `false` | Enables import/export sorting via Perfectionist. |
|
|
95
|
+
| `sortPackageJson` | `true` | Requires `jsonc` to be enabled. |
|
|
96
|
+
| `sortTsconfig` | `true` | Requires `jsonc`; accepts `extendTsconfigGlobs`. |
|
|
97
|
+
| `tailwind` | `false` | Deprecated. Passing it only prints a warning. |
|
|
97
98
|
|
|
98
99
|
Rule overrides belong to the corresponding config option:
|
|
99
100
|
|
|
@@ -106,6 +107,50 @@ jsse({
|
|
|
106
107
|
});
|
|
107
108
|
```
|
|
108
109
|
|
|
110
|
+
### TypeScript Presets
|
|
111
|
+
|
|
112
|
+
The `typescript.presets` option selects the upstream `typescript-eslint` preset
|
|
113
|
+
rules before jsse's local TypeScript rules and user overrides are applied.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
jsse({
|
|
117
|
+
typescript: {
|
|
118
|
+
presets: ["strict-type-checked", "stylistic-type-checked"],
|
|
119
|
+
tsconfig: "tsconfig.json",
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Preset names match `typescript-eslint`'s kebab-case config names: `recommended`,
|
|
125
|
+
`recommended-type-checked`, `strict`, `strict-type-checked`, `stylistic`,
|
|
126
|
+
`stylistic-type-checked`, `all`, `base`, `disable-type-checked`,
|
|
127
|
+
`eslint-recommended`, and the `*-only` variants.
|
|
128
|
+
|
|
129
|
+
The older `typescript.strict` option is still supported for compatibility, but
|
|
130
|
+
new configs should use `presets`.
|
|
131
|
+
|
|
132
|
+
### React Preset
|
|
133
|
+
|
|
134
|
+
The `react.preset` option selects the upstream `@eslint-react/eslint-plugin`
|
|
135
|
+
preset rules before user overrides are applied. It defaults to `"recommended"`.
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
jsse({ react: { preset: "strict-type-checked" } });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
React Refresh can be disabled with `react.refresh`:
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
jsse({ react: { refresh: false } });
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Preset names match `@eslint-react`'s kebab-case config names: `recommended`,
|
|
148
|
+
`recommended-typescript`, `recommended-type-checked`, `strict`,
|
|
149
|
+
`strict-typescript`, and `strict-type-checked`. Unlike `typescript.presets`,
|
|
150
|
+
this only accepts a single preset — the `@eslint-react` presets are mutually
|
|
151
|
+
exclusive points on one severity/TS-awareness scale rather than composable
|
|
152
|
+
layers (`strict` is already a superset of `recommended`'s rules).
|
|
153
|
+
|
|
109
154
|
## Thanks
|
|
110
155
|
|
|
111
156
|
- [antfu](https://github.com/antfu) and [sxzz](https://github.com/sxzz) for
|
package/dist/cli.js
CHANGED
|
@@ -1145,7 +1145,7 @@ ${n?` \$completionArgs += @(${n})
|
|
|
1145
1145
|
`),n.kind===`literal`){let e=n.description==null?``:$(k(n.description,{colors:!1})),t=$(n.text);yield`${t}\t${t}\t${e}`}else{let e=Da(n.extensions),t=n.includeHidden?`1`:`0`,r=n.description==null?``:$(k(n.description,{colors:!1})),i=Ea(n.pattern??``);yield`__FILE__:${n.type}:${e}:${i}:${t}\t[file]\t${r}`}t++}}};function Na(...e){let t={[Gn]:!0};return Xr(...e,t)}const Pa=typeof SuppressedError==`function`?SuppressedError:(()=>{class e extends Error{error;suppressed;constructor(e,t,n){super(n),this.name=`SuppressedError`,this.error=e,this.suppressed=t}}return e})();function Fa(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ia(e,t,n){if(!t)return e;if(!(n!=null&&n.size===0&&typeof e==`object`&&e)&&!(n!=null&&n.size>0&&typeof e==`object`&&e&&!Fa(e)&&!Array.isArray(e))){if(n!=null&&n.size>0&&typeof e==`object`&&e&&(Fa(e)||Array.isArray(e))){let t=e=>{let t=n.get(e);if(t!==void 0)return t;if(typeof e==`string`){let t=Number(e);if(Number.isInteger(t))return n.get(t)}else if(typeof e==`number`)return n.get(String(e))},r=Reflect.ownKeys(e),i=!1;for(let e of r)if(t(e)!==void 0){i=!0;break}if(i){let n=Array.isArray(e),i=!0;for(let a of r){if(n&&a===`length`)continue;let r=Object.getOwnPropertyDescriptor(e,a);if(r!=null&&`value`in r&&t(a)===void 0){i=!1;break}}if(i)return;let a=n?Array(e.length):Object.create(Object.getPrototypeOf(e));for(let n of r){let r=Object.getOwnPropertyDescriptor(e,n);if(r==null)continue;let i=t(n);`value`in r&&i!==void 0?i===null?Object.defineProperty(a,n,{...r,value:void 0}):Object.defineProperty(a,n,{...r,value:Ia(r.value,!0,i)}):Object.defineProperty(a,n,r)}return a}return}if(!(typeof e!=`object`||!e))return e}}function La(e,t){return t.length>0&&t.length===e.length&&t.every((t,n)=>t===e[n])}function Ra(e,t,n){return{remainingArgs:t.slice(n),consumedCount:e.length-t.length+n}}function za(e){return{usage:e.usage,phase:`parse`,path:[],commandPath:[],trace:Ct()}}function Ba(e){return e?.commandPath??[]}function Va(e,t){let n=R();return{...e,phase:`complete`,dependencyRuntime:n,dependencyRegistry:n.registry,commandPath:Ba(t.exec)??e.commandPath,trace:t.exec?.trace??t.trace??e.trace}}function Ha(e,t,n=`complete`){let r=g(e.initialState),i=za(e),a=Dt({buffer:t,state:e.initialState,optionsTerminated:!1},i);do{let n=e.parse(a);if(!n.success){let e=Ra(t,a.buffer,n.consumed);return{kind:`failure`,error:n.error,remainingArgs:e.remainingArgs,consumedCount:e.consumedCount,optionsTerminated:a.optionsTerminated,commandPath:Ba(a.exec)}}let r=a.buffer;if(a=n.next,La(r,a.buffer)){let e=Ra(t,r,n.consumed.length);return{kind:`failure`,error:w`Unexpected option or argument: ${a.buffer[0]}.`,remainingArgs:e.remainingArgs,consumedCount:e.consumedCount,optionsTerminated:a.optionsTerminated,commandPath:Ba(a.exec)}}}while(a.buffer.length>0);if(n===`parse-only`)return{kind:`success`,value:void 0};let o=e.complete(a.state,Va(i,a));return o.success?{kind:`success`,value:r?h(o.value):o.value}:{kind:`failure`,error:o.error,remainingArgs:[],consumedCount:t.length,optionsTerminated:a.optionsTerminated,commandPath:Ba(a.exec)}}async function Ua(e,t,n=`complete`){let r=g(e.initialState),i=za(e),a=Dt({buffer:t,state:e.initialState,optionsTerminated:!1},i);do{let n=await e.parse(a);if(!n.success){let e=Ra(t,a.buffer,n.consumed);return{kind:`failure`,error:n.error,remainingArgs:e.remainingArgs,consumedCount:e.consumedCount,optionsTerminated:a.optionsTerminated,commandPath:Ba(a.exec)}}let r=a.buffer;if(a=n.next,La(r,a.buffer)){let e=Ra(t,r,n.consumed.length);return{kind:`failure`,error:w`Unexpected option or argument: ${a.buffer[0]}.`,remainingArgs:e.remainingArgs,consumedCount:e.consumedCount,optionsTerminated:a.optionsTerminated,commandPath:Ba(a.exec)}}}while(a.buffer.length>0);if(n===`parse-only`)return{kind:`success`,value:void 0};let o=await e.complete(a.state,Va(i,a));return o.success?{kind:`success`,value:r?h(o.value):o.value}:{kind:`failure`,error:o.error,remainingArgs:[],consumedCount:t.length,optionsTerminated:a.optionsTerminated,commandPath:Ba(a.exec)}}function Wa(e,t){let n={usage:e.usage,phase:`parse`,path:[],commandPath:[],trace:Ct()},r=R();return{...n,phase:`complete`,dependencyRuntime:r,dependencyRegistry:r.registry,commandPath:Ba(t.exec),trace:t.exec?.trace??t.trace??n.trace}}function Ga(e,t){let n={usage:e.usage,phase:`parse`,path:[],commandPath:[],trace:Ct()};return Dt({buffer:t,state:e.initialState,optionsTerminated:!1},n)}function Ka(e,t){let n=Ga(e,t);do{let t=e.parse(n);if(!t.success)return K(e,n.state,Wa(e,n));let r=n.buffer;if(n=t.next,La(r,n.buffer))return K(e,n.state,Wa(e,n))}while(n.buffer.length>0);return K(e,n.state,Wa(e,n))}async function qa(e,t){let n=Ga(e,t);do{let t=await e.parse(n);if(!t.success)return await K(e,n.state,Wa(e,n));let r=n.buffer;if(n=t.next,La(r,n.buffer))return await K(e,n.state,Wa(e,n))}while(n.buffer.length>0);return await K(e,n.state,Wa(e,n))}function Ja(e){let[,t,...n]=e;return t==null?void 0:[t,...n]}function Ya(e,t){let n=null,r=null;if(e){let t=e.names??[`help`],r=Hi(da(Gi({metavar:`COMMAND`}),{description:w`Command name to show help for.`})),i=Ja(t);n=Ca(t[0],r,{description:w`Show help information.`,...i==null?{}:{[Kn]:i},hidden:e.hidden})}return t&&(r=ua(...t.names??[`--help`],{description:w`Show help information.`,hidden:t.hidden})),{helpCommand:n,helpOption:r}}function Xa(e,t){let n=null,r=null;if(e){let t=e.names??[`version`],r=di({}),i=Ja(t);n=Ca(t[0],r,{description:w`Show version information.`,...i==null?{}:{[Kn]:i},hidden:e.hidden})}return t&&(r=ua(...t.names??[`--version`],{description:w`Show version information.`,hidden:t.hidden})),{versionCommand:n,versionOption:r}}const Za=Symbol(`@optique/core/facade/meta`);function Qa(e,t,n,r){let i=null,a=null,o=[];for(let e in t)o.length>0&&o.push(T(`, `)),o.push(O(e));let s=di({shell:zi(da(Gi({metavar:`SHELL`}),{description:w`Shell type (${o}). Generate completion script when used alone, or provide completions when followed by arguments.`})),args:Hi(da(Gi({metavar:`ARG`}),{description:w`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).`}))});if(n){let t=n.names??[`completion`],r=t[0],a={brief:w`Generate shell completion script or provide completions.`,description:w`Generate shell completion script or provide completions.`,footer:w`Examples:${le()} Bash: ${ce(`eval "$(${e} ${r} bash)"`)}${le()} zsh: ${ce(`eval "$(${e} ${r} zsh)"`)}${le()} fish: ${ce(`eval "$(${e} ${r} fish)"`)}${le()} PowerShell: ${ce(`${e} ${r} pwsh > ${e}-completion.ps1; . ./${e}-completion.ps1`)}${le()} Nushell: ${ce(`${e} ${r} nu | save ${e}-completion.nu; source ./${e}-completion.nu`)}`},o=Ja(t);i=Ca(t[0],s,{...a,...o==null?{}:{[Kn]:o},hidden:n.hidden})}if(r){let e=r.names??[`--completion`],t=[];for(let n of e)t.push(la(n,Gi({metavar:`SHELL`}),{description:w`Generate shell completion script.`,hidden:r.hidden}));a=di({shell:t.length===1?t[0]:Xr(...t),args:Vi(Hi(da(Gi({metavar:`ARG`}),{description:w`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).`})),[])})}return{completionCommand:i,completionOption:a}}function $a(e){return{mode:`sync`,$valueType:[],$stateType:[],priority:200,usage:e.usage,leadingNames:e.leadingNames,acceptingAnyToken:!1,initialState:null,parse:()=>({success:!1,error:w`Documentation-only meta option.`,consumed:0}),complete:e=>({success:!0,value:e}),suggest:function*(){},getDocFragments:(t,n)=>e.getDocFragments({kind:`available`,state:e.initialState},n)}}function eo(e,t,n,r,i){let a=[];if(t.helpOption){let e=$a(t.helpOption),n=i?.helpOptionGroup?pi(i.helpOptionGroup,e):e;a.push(n)}if(n.versionOption){let e=$a(n.versionOption),t=i?.versionOptionGroup?pi(i.versionOptionGroup,e):e;a.push(t)}if(n.versionCommand){let e=di({[Za]:Z(!0),help:Z(!1),version:Z(!0),completion:Z(!1),result:n.versionCommand,helpFlag:t.helpOption?zi(t.helpOption):Z(!1)});a.push(i?.versionCommandGroup?pi(i.versionCommandGroup,e):e)}if(r.completionCommand){let e=di({[Za]:Z(!0),help:Z(!1),version:Z(!1),completion:Z(!0),completionData:r.completionCommand,helpFlag:t.helpOption?zi(t.helpOption):Z(!1)});a.push(i?.completionCommandGroup?pi(i.completionCommandGroup,e):e)}if(t.helpCommand){let e=di({[Za]:Z(!0),help:Z(!0),version:Z(!1),completion:Z(!1),commands:t.helpCommand});a.push(i?.helpCommandGroup?pi(i.helpCommandGroup,e):e)}a.push(di({[Za]:Z(!0),help:Z(!1),version:Z(!1),completion:Z(!1),result:e}));let o=a.length-1;if(a.length===1)return a[0];let s=Na(...a),c=s.usage[0];if(c?.type===`exclusive`&&o>0){let e=[...c.terms],[r]=e.splice(o,1),i=+!!t.helpOption+ +!!n.versionOption;e.splice(i,0,r),s={...s,usage:[{...c,terms:e}]}}return s}function to(e,t,n,r,i){let a;for(let o=0;o<e.length;o++){let s=e[o];n.includes(s)?a={index:o,kind:`help`}:r.includes(s)&&(a={index:o,kind:`version`});let c=i.find(e=>s.startsWith(e+`=`));if(c!=null)return{lastHelpVersion:a,completion:{index:o,shell:s.slice(c.length+1),args:t.slice(o+1)}};if(i.includes(s)){let n=e[o+1]??``;return{lastHelpVersion:a,completion:{index:o,shell:n,args:n===``?[]:t.slice(o+2)}}}}return{lastHelpVersion:a}}function no(e,t,n){let r=[...e];for(let e=0;e<n;e++){let n=t[e];n.startsWith(`-`)||r.push(n)}return r}function ro(e,t,n,r,i,a,o){if(e.remainingArgs.length<1)return{type:`error`,error:e.error};let s=e.consumedCount>0,c=e.remainingArgs[0];if(!s&&o.includes(c)){let n=e.remainingArgs[1];return t.includes(n)?{type:`help`,commands:[c]}:{type:`completion`,source:`command`,shell:n??``,args:e.remainingArgs.slice(2)}}let{lastHelpVersion:l,completion:u}=to(e.optionsTerminated?[]:(()=>{let t=e.remainingArgs.indexOf(`--`);return t>=0?e.remainingArgs.slice(0,t):e.remainingArgs})(),e.remainingArgs,t,r,a);if(!s&&i.includes(c)){let n=e.remainingArgs[1];if(t.includes(n))return{type:`help`,commands:[c]};let r=u?.index===1;return n==null||r||l?.index===1&&l.kind===`version`?{type:`version`}:{type:`error`,error:e.error}}let d;!s&&n.includes(c)&&(d={index:0,kind:`help`});let f=l==null?d:d==null||l.index>=d.index?l:d;return f?.kind===`help`?f===d?{type:`help`,commands:e.remainingArgs.slice(1)}:{type:`help`,commands:no(e.commandPath,e.remainingArgs,f.index),preferUserCommandDocs:e.commandPath.length>0}:f?.kind===`version`?{type:`version`}:u==null?{type:`error`,error:e.error}:{type:`completion`,source:`option`,shell:u.shell,commandPath:e.commandPath,args:u.args}}function io(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h=[]){let g=e[0]||``,_=e.slice(1),v=e=>s(e),y=e=>o(e);if(!g){if(a(`Error: Missing shell name for completion.
|
|
1146
1146
|
`),r){let e=Bt(r,[p?f??`--completion`:d??`completion`]);e&&a(Ue(t,e,{colors:l,maxWidth:u,sectionOrder:m}))}return P(n.mode,()=>{let e=v(1);if(e instanceof Promise)throw new Do(`Synchronous parser returned async result.`);return e},async()=>v(1))}let b=c[g];if(!b){let e=[];for(let t in c)e.length>0&&e.push(T(`, `)),e.push(O(t));return a(k(w`Error: Unsupported shell ${g}. Available shells: ${e}.`,{colors:l,quotes:!l})),P(n.mode,()=>{let e=v(1);if(e instanceof Promise)throw new Do(`Synchronous parser returned async result.`);return e},async()=>v(1))}if(_.length===0){let e=p?f??`--completion`:d??`completion`;return i(b.generateScript(t,[e,g])),P(n.mode,()=>{let e=y(0);if(e instanceof Promise)throw new Do(`Synchronous parser returned async result.`);return e},async()=>y(0))}return P(n.mode,()=>{let e=oo(n,_,h),t=ao(e.suggestions,_,h,e.argumentContext);for(let e of b.encodeSuggestions(t))i(e);let r=y(0);if(r instanceof Promise)throw new Do(`Synchronous parser returned async result.`);return r},async()=>{let e=await so(n,_,h);for(let t of b.encodeSuggestions(ao(e.suggestions,_,h,e.argumentContext)))i(t);return y(0)})}function ao(e,t,n,r){if(n.length===0)return e;let i=t.at(-1)??``;if(r.optionsTerminated||r.completingOptionValue||r.completedRootOption||!(i===``||i.startsWith(`--`)||i.startsWith(`-`)||i.startsWith(`/`)||i.startsWith(`+`)))return e;let a=new Set(e.flatMap(e=>e.kind===`literal`?[e.text]:[])),o=[...e];for(let e of n)i===`-`&&e.text.startsWith(`--`)||i!==``&&!e.text.startsWith(i)||a.has(e.text)||(o.push(e),a.add(e.text));return o}function oo(e,t,n){let r=t.at(-1)??``,i=mo(e,t.slice(0,-1));for(;i.buffer.length>0;){let t=e.parse(i);if(t instanceof Promise)throw new Do(`Synchronous parser returned async result.`);if(!t.success){let a=ho(t,i,e,n);return{suggestions:Array.from(e.suggest(lo(e,i),r)),argumentContext:a}}let a=i.buffer;if(i=t.next,go(a,i.buffer))return{suggestions:[],argumentContext:co(i)}}return{suggestions:Array.from(e.suggest(lo(e,i),r)),argumentContext:co(i)}}async function so(e,t,n){let r=t.at(-1)??``,i=mo(e,t.slice(0,-1));for(;i.buffer.length>0;){let t=await e.parse(i);if(!t.success){let a=ho(t,i,e,n),o=[],s=await uo(e,i);for await(let t of e.suggest(s,r))o.push(t);return{suggestions:o,argumentContext:a}}let a=i.buffer;if(i=t.next,go(a,i.buffer))return{suggestions:[],argumentContext:co(i)}}let a=[],o=await uo(e,i);for await(let t of e.suggest(o,r))a.push(t);return{suggestions:a,argumentContext:co(i)}}function co(e){return{completingOptionValue:!1,completedRootOption:!1,optionsTerminated:e.optionsTerminated}}function lo(e,t){let n=R(),r=po(e,t.state,t.exec?.path??[]);return r.length>0&&ln(r,n),fo(t,n)}async function uo(e,t){let n=R(),r=po(e,t.state,t.exec?.path??[]);return r.length>0&&await fn(r,n),fo(t,n)}function fo(e,t){return{...e,dependencyRegistry:t.registry,exec:e.exec?{...e.exec,dependencyRuntime:t,dependencyRegistry:t.registry}:void 0}}function po(e,t,n){return typeof e.getSuggestRuntimeNodes==`function`?e.getSuggestRuntimeNodes(t,n):e.dependencyMetadata?.source==null?[]:[{path:n,parser:e,state:t}]}function mo(e,t){return Dt({buffer:t,state:e.initialState,optionsTerminated:!1},{usage:e.usage,phase:`suggest`,path:[],trace:Ct()})}function ho(e,t,n,r){let i=_o(n.usage,t.exec?.commandPath??[],e.consumed>0,n.leadingNames),a=t.buffer[0];return{completingOptionValue:(e.consumed===0||e.consumed===1)&&i.has(a),completedRootOption:e.consumed===0&&xo(a,r),optionsTerminated:t.optionsTerminated}}function go(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function _o(e,t,n,r){let i={value:new Set,flag:new Set};if(t.length===0)return vo(e,i,r),i.value;bo(e,t,i,!1,n);let a=new Set(i.value);for(let e of i.flag)a.delete(e);return a}function vo(e,t,n){for(let r of e)yo(r,t,n)}function yo(e,t,n){switch(e.type){case`option`:for(let r of e.names)n.has(r)&&(e.metavar==null?t.flag.add(r):t.value.add(r));return;case`optional`:case`multiple`:case`sequence`:vo(e.terms,t,n);return;case`exclusive`:for(let r of e.terms)vo(r,t,n);return;case`argument`:case`command`:case`literal`:case`passthrough`:case`ellipsis`:return}}function bo(e,t,n,r,i){if(t.length===0){So(e,n,!1);return}let[a,...o]=t;for(let s=0;s<e.length;s++){let c=e[s];if(c.type===`command`&&c.name===a){let t=e.slice(s+1);o.length===0?So(t,n,!r&&i):bo(t,o,n,r,i)}else if(c.type===`exclusive`)for(let e of c.terms)bo(e,t,n,!0,i);else(c.type===`optional`||c.type===`multiple`||c.type===`sequence`)&&bo(c.terms,t,n,r,i)}}function xo(e,t){return e!=null&&t.some(t=>e===t.text||e.startsWith(`${t.text}=`))}function So(e,t,n){for(let r of e)if(Co(r,t,n))return}function Co(e,t,n){switch(e.type){case`command`:return!n;case`option`:if(e.metavar!=null)for(let n of e.names)t.value.add(n);else for(let n of e.names)t.flag.add(n);return!1;case`optional`:case`multiple`:case`sequence`:return So(e.terms,t,n),!1;case`exclusive`:for(let n of e.terms)So(n,t,!1);return!1;case`argument`:case`literal`:case`passthrough`:case`ellipsis`:return!1}}function wo(e,t,n,r){let i=[];return e!=null&&!M(e.hidden)&&i.push(...t.map(e=>({kind:`literal`,text:e}))),n!=null&&!M(n.hidden)&&i.push(...r.map(e=>({kind:`literal`,text:e}))),i}function To(e){if(typeof e!=`string`)throw TypeError(`Expected version value to be a string, but got ${Array.isArray(e)?`array`:typeof e}.`);if(e===``)throw TypeError(`Version value must not be empty.`);if(/[\x00-\x1f\x7f]/.test(e))throw TypeError(`Version value must not contain control characters.`);return e}function Eo(e,t,n,r){let i=typeof t!=`string`,a,o,s,c;if(i){let r=e;a=r.parser,o=r.metadata.name,s=t,c=n??{},c={...c,brief:c.brief??r.metadata.brief,description:c.description??r.metadata.description,examples:c.examples??r.metadata.examples,author:c.author??r.metadata.author,bugs:c.bugs??r.metadata.bugs,footer:c.footer??r.metadata.footer}}else a=e,o=t,s=n,c=r??{};_e(o);let{colors:l,maxWidth:u,showDefault:d,showChoices:f,sectionOrder:p,aboveError:m=`usage`,onError:h=()=>{throw new Do(`Failed to parse command line arguments.`)},stderr:g=console.error,stdout:_=console.log,brief:v,description:y,examples:b,author:ee,bugs:te,footer:ne}=c,re=e=>e===!0?{}:e,x=re(c.help?.command),S=re(c.help?.option),ie=c.help?.onShow??(()=>({})),ae=re(c.version?.command),C=re(c.version?.option),T=c.version?To(c.version.value):void 0,oe=c.version?.onShow??(()=>({})),D=re(c.completion?.command),O=re(c.completion?.option),se=c.completion?.onShow??(()=>({})),ce=e=>se(e),le=e=>h(e);S?.names&&pe(S.names,`Help option`),x?.names&&me(x.names,`Help command`),C?.names&&pe(C.names,`Version option`),ae?.names&&me(ae.names,`Version command`),O?.names&&pe(O.names,`Completion option`),D?.names&&me(D.names,`Completion command`);let ue=S?.names??[`--help`],de=x?.names??[`help`],fe=C?.names??[`--version`],A=ae?.names??[`version`],ge=D?.names??[`completion`],ve=O?.names??[`--completion`],ye=wo(S,ue,C,fe),j=[];c.help&&S&&j.push([`option`,`help option`,ue]),c.help&&x&&j.push([`command`,`help command`,de]),c.version&&C&&j.push([`option`,`version option`,fe]),c.version&&ae&&j.push([`command`,`version command`,A]),c.completion&&O&&j.push([`option`,`completion option`,ve,!0]),c.completion&&D&&j.push([`command`,`completion command`,ge]),he(j);let be={bash:Oa,fish:Aa,nu:ja,pwsh:Ma,zsh:ka},M=c.completion?.shells?{...be,...c.completion.shells}:be,xe=c.help?Ya(x,S):{helpCommand:null,helpOption:null},Se=c.version?Xa(ae,C):{versionCommand:null,versionOption:null},N=c.completion?Qa(o,M,D,O):{completionCommand:null,completionOption:null},Ce=!c.help&&!c.version&&!c.completion?a:eo(a,xe,Se,N,{helpCommandGroup:x?.group,helpOptionGroup:S?.group,versionCommandGroup:ae?.group,versionOptionGroup:C?.group,completionCommandGroup:D?.group,completionOptionGroup:O?.group}),Te=e=>{switch(e.type){case`success`:return e.value;case`version`:return _(T),oe(0);case`completion`:return io([e.shell,...e.commandPath??[],...e.args],o,a,e.source===`command`?N.completionCommand:N.completionOption,_,g,ce,le,M,l,u,ge[0],ve[0],e.source===`option`,p,ye);case`help`:{let t,n,r=x!=null,i=ae!=null,s=D!=null,c=S!=null,m=C!=null,re=O!=null,T=e.commands[0];if(T!=null&&!e.preferUserCommandDocs&&ge.includes(T)&&s&&N.completionCommand)t=N.completionCommand,n=t;else if(T!=null&&!e.preferUserCommandDocs&&de.includes(T)&&r&&xe.helpCommand)t=xe.helpCommand,n=t;else if(T!=null&&!e.preferUserCommandDocs&&A.includes(T)&&i&&Se.versionCommand)t=Se.versionCommand,n=t;else{let o=[a],l={},u=[],d=(e,t)=>{t?(l[t]??=[]).push(e):u.push(e)};r&&xe.helpCommand&&d(xe.helpCommand,x?.group),i&&Se.versionCommand&&d(Se.versionCommand,ae?.group),s&&N.completionCommand&&d(N.completionCommand,D?.group),o.push(...u);for(let[e,t]of Object.entries(l))t.length===1?o.push(pi(e,t[0])):o.push(pi(e,Xr(...t)));let f={},p=[],h=(e,t)=>{t?(f[t]??=[]).push(e):p.push(e)};c&&xe.helpOption&&h(xe.helpOption,S?.group),m&&Se.versionOption&&h(Se.versionOption,C?.group),re&&N.completionOption&&h(N.completionOption,O?.group),o.push(...p);for(let[e,t]of Object.entries(f))t.length===1?o.push(pi(e,t[0])):o.push(pi(e,Xr(...t)));t=o.length===1?o[0]:Na(...o),n=e.commands.length>0?a:t}let oe=e=>{g(`Usage: ${Oo(we(o,Ce.usage,{colors:l,maxWidth:u==null?void 0:u-7,expandCommands:!0}),7)}`);let t=k(e,{colors:l,quotes:!l});return g(`Error: ${t}`),h(1)},se=t=>{if(t!=null){let n=T!=null&&ge.includes(T)||T!=null&&de.includes(T)||T!=null&&A.includes(T),r=e.commands.length>0,i=!r,a=!n&&!r,s={...t,brief:a?v??t.brief:t.brief,description:a?y??t.description:t.description,examples:i&&!n?b??t.examples:void 0,author:i&&!n?ee??t.author:void 0,bugs:i&&!n?te??t.bugs:void 0,footer:a?ne??t.footer:t.footer??ne};_(Ue(o,s,{colors:l,maxWidth:u,showDefault:d,showChoices:f,sectionOrder:p}))}return ie(0)};if(e.commands.length>0){let r={buffer:[...e.commands],optionsTerminated:!1,state:t.initialState,usage:t.usage},i=e=>e.success?e.consumed.length<1?w`Unexpected option or subcommand: ${E(r.buffer[0])}.`:(r={...r,buffer:e.next.buffer,optionsTerminated:e.next.optionsTerminated,state:e.next.state,usage:e.next.usage??r.usage},r.buffer.length>0?`continue`:null):e.error,a=`continue`;for(;a===`continue`;){let o=t.parse(r);if(o instanceof Promise)return o.then(async a=>{let o=i(a);for(;o===`continue`;){let e=t.parse(r),n=e instanceof Promise?await e:e;o=i(n)}if(o!=null)return oe(o);let s=Bt(n,e.commands);return s instanceof Promise?s.then(se):se(s)});a=i(o)}if(a!=null)return oe(a)}let ce=Bt(n,e.commands);return ce instanceof Promise?ce.then(se):se(ce)}case`error`:{let t=(t,n)=>{let r=n;if(r===`help`)if(t==null)r=`usage`;else{let e={...t,brief:v??t.brief,description:y??t.description,examples:b??t.examples,author:ee??t.author,bugs:te??t.bugs,footer:ne??t.footer};g(Ue(o,e,{colors:l,maxWidth:u,showDefault:d,showChoices:f}))}r===`usage`&&g(`Usage: ${Oo(we(o,Ce.usage,{colors:l,maxWidth:u==null?void 0:u-7,expandCommands:!0}),7)}`);let i=k(e.error,{colors:l,quotes:!l});return g(`Error: ${i}`),h(1)};if(m===`help`){let e=Bt(s.length<1?Ce:a,s);return e instanceof Promise?e.then(e=>t(e,m)):t(e,m)}return t(void 0,m)}default:throw new Do(`Unexpected parse result type`)}},Ee=a.mode;return P(Ee,()=>{let e=Ha(a,s),t=e.kind===`success`?{type:`success`,value:e.value}:ro(e,S?[...ue]:[],x?[...de]:[],C?[...fe]:[],ae?[...A]:[],O?[...ve]:[],D?[...ge]:[]),n=Te(t);if(n instanceof Promise)throw new Do(`Synchronous parser returned async result.`);return n},async()=>{let e=await Ua(a,s),t=e.kind===`success`?{type:`success`,value:e.value}:ro(e,S?[...ue]:[],x?[...de]:[],C?[...fe]:[],ae?[...A]:[],O?[...ve]:[],D?[...ge]:[]),n=Te(t);return n instanceof Promise?await n:n})}var Do=class extends Error{constructor(e){super(e),this.name=`RunParserError`}};function Oo(e,t){return e.split(`
|
|
1147
1147
|
`).join(`
|
|
1148
|
-
`+` `.repeat(t))}function ko(e){return e.type===`help`||e.type===`version`||e.type===`completion`}function Ao(e,t){let n=e=>e===!0?{}:e,r=n(t.help?.option),i=n(t.help?.command),a=n(t.version?.option),o=n(t.version?.command),s=n(t.completion?.option),c=n(t.completion?.command);return ro(e,r?[...r.names??[`--help`]]:[],i?[...i.names??[`help`]]:[],a?[...a.names??[`--version`]]:[],o?[...o.names??[`version`]]:[],s?[...s.names??[`--completion`]]:[],c?[...c.names??[`completion`]]:[])}function jo(e,t){return t&&(e.help!=null||e.version!=null||e.completion!=null)}async function Mo(e,t,n){let r=await Ua(e,t,`parse-only`);return r.kind===`success`?!1:ko(Ao(r,n))}function No(e){let t={};for(let n=e.length-1;n>=0;n--){let r=e[n];for(let e of Object.getOwnPropertySymbols(r))t[e]=r[e]}return t}function Po(e){for(let t of e){let e=t.phase;if(e!==`single-pass`&&e!==`two-pass`)throw TypeError(`Context ${String(t.id)} must declare phase as "single-pass" or "two-pass".`)}}async function Fo(e,t){let n=[],r;for(let i of e){let e={phase:`phase1`},a=i.getAnnotations(e,t),o=a instanceof Promise?await a:a,s=i.getInternalAnnotations?.(e,o),c=s==null?o:No([o,s]);n.push(c),r==null?i.phase===`two-pass`&&(r=[...n]):r.push(c)}return{annotations:No(n),needsTwoPhase:r!=null,snapshots:r??[]}}async function Io(e,t,n,r,i,a){let o=[],s=Ia(n,i,a);for(let n=0;n<e.length;n++){let i=e[n];if(i.phase===`single-pass`){o.push(t[n]);continue}let a={phase:`phase2`,parsed:s},c=i.getAnnotations(a,r),l=c instanceof Promise?await c:c,u=i.getInternalAnnotations?.(a,l),d=u==null?l:No([l,u]);o.push(d)}return{annotations:No(o)}}async function Lo(e){let t=[];for(let n of e)try{Symbol.asyncDispose in n&&typeof n[Symbol.asyncDispose]==`function`?await n[Symbol.asyncDispose]():Symbol.dispose in n&&typeof n[Symbol.dispose]==`function`&&n[Symbol.dispose]()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Failed to dispose one or more source contexts.`)}async function Ro(e,t,n,r,i){ye(n),Po(n);let a=i.contextOptions,{annotations:o,needsTwoPhase:s,snapshots:c}=await Fo(n,a);if(jo(i,s)){let n=Bo(e,o);if(await Mo(n,r,i))return e.mode===`async`?Eo(n,t,r,i):Promise.resolve(Eo(n,t,r,i))}let l=Bo(e,o);if(!s)return e.mode===`async`?Eo(l,t,r,i):Promise.resolve(Eo(l,t,r,i));let u=await P(e.mode,()=>Ka(l,r),()=>qa(l,r));if(u==null){let n=Bo(e,o);return e.mode===`async`?Eo(n,t,r,i):Promise.resolve(Eo(n,t,r,i))}let{annotations:d}=await Io(n,c,u.value,a,u.deferred,u.deferredKeys),f=Bo(e,d);return e.mode===`async`?Eo(f,t,r,i):Promise.resolve(Eo(f,t,r,i))}async function zo(e,t,n,r){let i=r?.args??[];if(n.length===0)return e.mode===`async`?Eo(e,t,i,r):Promise.resolve(Eo(e,t,i,r));let a,o,s=!1;try{a=await Ro(e,t,n,i,r)}catch(e){s=!0,o=e}try{await Lo(n)}catch(e){throw s?new Pa(e,o,`An error was suppressed during context disposal.`):e}if(s)throw o;return a}function Bo(e,t){let n=m(e.initialState,t),r={...Object.getOwnPropertyDescriptors(e)},i=r.initialState;return r.initialState=i==null?{value:n,writable:!0,enumerable:!0,configurable:!0}:`get`in i||`set`in i?{value:n,writable:!0,enumerable:i.enumerable??!0,configurable:i.configurable??!0}:{value:n,writable:i.writable??!0,enumerable:i.enumerable??!0,configurable:i.configurable??!0},Object.create(Object.getPrototypeOf(e),r)}function Vo(e){return{brief:e.brief,description:e.description,examples:e.examples,author:e.author,bugs:e.bugs,footer:e.footer}}function Ho(e,t){return`parser`in e&&`metadata`in e?{parser:e.parser,options:t.programName==null?{...t,programName:e.metadata.name}:t,programMetadata:Vo(e.metadata)}:{parser:e,options:t}}function Uo(e,t={}){return Go(e,t)}function Wo(e,t){let i=e.programName??r.basename(n.argv[1]??`cli`),a=e.args??n.argv.slice(2),o=e.stdout??(e=>{n.stdout.write(`${e}\n`)}),s=e.stderr??(e=>{n.stderr.write(`${e}\n`)}),c=e.onExit??(e=>n.exit(e)),l=e.colors??n.stdout.isTTY,u=e.maxWidth??n.stdout.columns,d=e.showDefault,f=e.showChoices,p=e.sectionOrder,m=e.help,h=e.version,g=e.completion,_=e.aboveError??`usage`,v=e.errorExitCode??1,y=e.brief??t?.brief,b=e.description??t?.description,ee=e.examples??t?.examples,te=e.author??t?.author,ne=e.bugs??t?.bugs,re=e.footer??t?.footer,x=()=>c(0);return{programName:i,args:a,coreOptions:{stderr:s,stdout:o,colors:l,maxWidth:u,showDefault:d,showChoices:f,sectionOrder:p,help:(()=>{if(m){if(typeof m==`string`)switch(m){case`command`:return{command:!0,onShow:x};case`option`:return{option:!0,onShow:x};case`both`:return{command:!0,option:!0,onShow:x}}return{...m,onShow:x}}})(),version:(()=>{if(h)return typeof h==`string`?{value:h,option:!0,onShow:x}:{...h,onShow:x}})(),completion:(()=>{if(g){if(typeof g==`string`)switch(g){case`command`:return{command:!0,onShow:x};case`option`:return{option:!0,onShow:x};case`both`:return{command:!0,option:!0,onShow:x}}return{...g,onShow:x}}})(),aboveError:_,brief:y,description:b,examples:ee,author:te,bugs:ne,footer:re,onError(){return c(v)}}}}function Go(e,t={}){let n=Ho(e,t),{parser:r,programMetadata:i}=n;t=n.options;let a=t.contexts;if(a&&a.length>0){let{programName:e,args:n,coreOptions:o}=Wo(t,i);return zo(r,e,a,{...o,contextOptions:t.contextOptions,args:n})}let{programName:o,args:s,coreOptions:c}=Wo(t,i);return Eo(r,o,s,c)}const Ko=`0.9.
|
|
1148
|
+
`+` `.repeat(t))}function ko(e){return e.type===`help`||e.type===`version`||e.type===`completion`}function Ao(e,t){let n=e=>e===!0?{}:e,r=n(t.help?.option),i=n(t.help?.command),a=n(t.version?.option),o=n(t.version?.command),s=n(t.completion?.option),c=n(t.completion?.command);return ro(e,r?[...r.names??[`--help`]]:[],i?[...i.names??[`help`]]:[],a?[...a.names??[`--version`]]:[],o?[...o.names??[`version`]]:[],s?[...s.names??[`--completion`]]:[],c?[...c.names??[`completion`]]:[])}function jo(e,t){return t&&(e.help!=null||e.version!=null||e.completion!=null)}async function Mo(e,t,n){let r=await Ua(e,t,`parse-only`);return r.kind===`success`?!1:ko(Ao(r,n))}function No(e){let t={};for(let n=e.length-1;n>=0;n--){let r=e[n];for(let e of Object.getOwnPropertySymbols(r))t[e]=r[e]}return t}function Po(e){for(let t of e){let e=t.phase;if(e!==`single-pass`&&e!==`two-pass`)throw TypeError(`Context ${String(t.id)} must declare phase as "single-pass" or "two-pass".`)}}async function Fo(e,t){let n=[],r;for(let i of e){let e={phase:`phase1`},a=i.getAnnotations(e,t),o=a instanceof Promise?await a:a,s=i.getInternalAnnotations?.(e,o),c=s==null?o:No([o,s]);n.push(c),r==null?i.phase===`two-pass`&&(r=[...n]):r.push(c)}return{annotations:No(n),needsTwoPhase:r!=null,snapshots:r??[]}}async function Io(e,t,n,r,i,a){let o=[],s=Ia(n,i,a);for(let n=0;n<e.length;n++){let i=e[n];if(i.phase===`single-pass`){o.push(t[n]);continue}let a={phase:`phase2`,parsed:s},c=i.getAnnotations(a,r),l=c instanceof Promise?await c:c,u=i.getInternalAnnotations?.(a,l),d=u==null?l:No([l,u]);o.push(d)}return{annotations:No(o)}}async function Lo(e){let t=[];for(let n of e)try{Symbol.asyncDispose in n&&typeof n[Symbol.asyncDispose]==`function`?await n[Symbol.asyncDispose]():Symbol.dispose in n&&typeof n[Symbol.dispose]==`function`&&n[Symbol.dispose]()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Failed to dispose one or more source contexts.`)}async function Ro(e,t,n,r,i){ye(n),Po(n);let a=i.contextOptions,{annotations:o,needsTwoPhase:s,snapshots:c}=await Fo(n,a);if(jo(i,s)){let n=Bo(e,o);if(await Mo(n,r,i))return e.mode===`async`?Eo(n,t,r,i):Promise.resolve(Eo(n,t,r,i))}let l=Bo(e,o);if(!s)return e.mode===`async`?Eo(l,t,r,i):Promise.resolve(Eo(l,t,r,i));let u=await P(e.mode,()=>Ka(l,r),()=>qa(l,r));if(u==null){let n=Bo(e,o);return e.mode===`async`?Eo(n,t,r,i):Promise.resolve(Eo(n,t,r,i))}let{annotations:d}=await Io(n,c,u.value,a,u.deferred,u.deferredKeys),f=Bo(e,d);return e.mode===`async`?Eo(f,t,r,i):Promise.resolve(Eo(f,t,r,i))}async function zo(e,t,n,r){let i=r?.args??[];if(n.length===0)return e.mode===`async`?Eo(e,t,i,r):Promise.resolve(Eo(e,t,i,r));let a,o,s=!1;try{a=await Ro(e,t,n,i,r)}catch(e){s=!0,o=e}try{await Lo(n)}catch(e){throw s?new Pa(e,o,`An error was suppressed during context disposal.`):e}if(s)throw o;return a}function Bo(e,t){let n=m(e.initialState,t),r={...Object.getOwnPropertyDescriptors(e)},i=r.initialState;return r.initialState=i==null?{value:n,writable:!0,enumerable:!0,configurable:!0}:`get`in i||`set`in i?{value:n,writable:!0,enumerable:i.enumerable??!0,configurable:i.configurable??!0}:{value:n,writable:i.writable??!0,enumerable:i.enumerable??!0,configurable:i.configurable??!0},Object.create(Object.getPrototypeOf(e),r)}function Vo(e){return{brief:e.brief,description:e.description,examples:e.examples,author:e.author,bugs:e.bugs,footer:e.footer}}function Ho(e,t){return`parser`in e&&`metadata`in e?{parser:e.parser,options:t.programName==null?{...t,programName:e.metadata.name}:t,programMetadata:Vo(e.metadata)}:{parser:e,options:t}}function Uo(e,t={}){return Go(e,t)}function Wo(e,t){let i=e.programName??r.basename(n.argv[1]??`cli`),a=e.args??n.argv.slice(2),o=e.stdout??(e=>{n.stdout.write(`${e}\n`)}),s=e.stderr??(e=>{n.stderr.write(`${e}\n`)}),c=e.onExit??(e=>n.exit(e)),l=e.colors??n.stdout.isTTY,u=e.maxWidth??n.stdout.columns,d=e.showDefault,f=e.showChoices,p=e.sectionOrder,m=e.help,h=e.version,g=e.completion,_=e.aboveError??`usage`,v=e.errorExitCode??1,y=e.brief??t?.brief,b=e.description??t?.description,ee=e.examples??t?.examples,te=e.author??t?.author,ne=e.bugs??t?.bugs,re=e.footer??t?.footer,x=()=>c(0);return{programName:i,args:a,coreOptions:{stderr:s,stdout:o,colors:l,maxWidth:u,showDefault:d,showChoices:f,sectionOrder:p,help:(()=>{if(m){if(typeof m==`string`)switch(m){case`command`:return{command:!0,onShow:x};case`option`:return{option:!0,onShow:x};case`both`:return{command:!0,option:!0,onShow:x}}return{...m,onShow:x}}})(),version:(()=>{if(h)return typeof h==`string`?{value:h,option:!0,onShow:x}:{...h,onShow:x}})(),completion:(()=>{if(g){if(typeof g==`string`)switch(g){case`command`:return{command:!0,onShow:x};case`option`:return{option:!0,onShow:x};case`both`:return{command:!0,option:!0,onShow:x}}return{...g,onShow:x}}})(),aboveError:_,brief:y,description:b,examples:ee,author:te,bugs:ne,footer:re,onError(){return c(v)}}}}function Go(e,t={}){let n=Ho(e,t),{parser:r,programMetadata:i}=n;t=n.options;let a=t.contexts;if(a&&a.length>0){let{programName:e,args:n,coreOptions:o}=Wo(t,i);return zo(r,e,a,{...o,contextOptions:t.contextOptions,args:n})}let{programName:o,args:s,coreOptions:c}=Wo(t,i);return Eo(r,o,s,c)}const Ko=`0.9.3`,qo=[`DEBUG`,`JSSE_DEBUG`,`JSSEDEBUG`].some(e=>{let t=n.env[e];return[`1`,`true`,`t`,`on`,`yes`,`y`].includes(t??``)}),Jo=di({debug:la(`-d`,`--debug`,{description:w`Print parsed command options.`})}),Yo=Ca(`init`,di({action:Z(`init`),filepath:zi(la(`-p`,`--filepath`,Gi({metavar:`FILEPATH`}),{description:w`Path to the ESLint config file to create.`})),force:la(`-f`,`--force`,{description:w`Overwrite an existing ESLint config file.`})}),{brief:w`Create an ESLint config file.`}),Xo=Ca(`dev`,di({action:Z(`dev`)}),{brief:w`cli-dev`});function Zo(){console.log(`cli-dev`)}const Qo=fi(Jo,Yr(Yo,Xo));async function $o(n){if(console.log(`init`),!e.existsSync(`package.json`)){let e=`package.json not found`;throw console.warn(e),Error(e)}let r=await t.readFile(`package.json`,`utf8`),i=JSON.parse(r).type===`module`,a=n.filepath??(i?`eslint.config.js`:`eslint.config.mjs`);if(e.existsSync(a)){let e=`${a} already exists`;if(console.warn(e),!n.force)throw Error(e)}await t.writeFile(a,`// @ts-check
|
|
1149
1149
|
import jsse from "@jsse/eslint-config";
|
|
1150
1150
|
|
|
1151
1151
|
export default jsse(
|
|
@@ -1181,8 +1181,7 @@ export default jsse(
|
|
|
1181
1181
|
// pnpm: false,
|
|
1182
1182
|
// prettier: true,
|
|
1183
1183
|
// preReturn: (configs) => configs,
|
|
1184
|
-
// react: false,
|
|
1185
|
-
// reactRefresh: false,
|
|
1184
|
+
// react: { refresh: false },
|
|
1186
1185
|
// regexp: true,
|
|
1187
1186
|
// reportUnusedDisableDirectives: true,
|
|
1188
1187
|
// rootId: "jsse",
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path, { dirname, join, relative, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
//#region node_modules/.pnpm/@eslint+compat@2.1.0_eslint@10.6.0_jiti@2.7.0_/node_modules/@eslint/compat/dist/esm/index.js
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview Ignore file utilities for the compat package.
|
|
8
|
+
* @author Nicholas C. Zakas
|
|
9
|
+
*/
|
|
10
|
+
/** @typedef {import("@eslint/core").ConfigObject} FlatConfig */
|
|
11
|
+
/**
|
|
12
|
+
* Converts an ESLint ignore pattern to a minimatch pattern.
|
|
13
|
+
* @param {string} pattern The .eslintignore or .gitignore pattern to convert.
|
|
14
|
+
* @returns {string} The converted pattern.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Use the `convertIgnorePatternToMinimatch()` function exported by
|
|
17
|
+
* `@eslint/config-helpers` instead.
|
|
18
|
+
*/
|
|
19
|
+
function convertIgnorePatternToMinimatch(pattern) {
|
|
20
|
+
const isNegated = pattern.startsWith("!");
|
|
21
|
+
const negatedPrefix = isNegated ? "!" : "";
|
|
22
|
+
const patternToTest = (isNegated ? pattern.slice(1) : pattern).trimEnd();
|
|
23
|
+
if ([
|
|
24
|
+
"",
|
|
25
|
+
"**",
|
|
26
|
+
"/**",
|
|
27
|
+
"**/"
|
|
28
|
+
].includes(patternToTest)) return `${negatedPrefix}${patternToTest}`;
|
|
29
|
+
const firstIndexOfSlash = patternToTest.indexOf("/");
|
|
30
|
+
return `${negatedPrefix}${firstIndexOfSlash < 0 || firstIndexOfSlash === patternToTest.length - 1 ? "**/" : ""}${(firstIndexOfSlash === 0 ? patternToTest.slice(1) : patternToTest).replaceAll(/(?=((?:\\.|[^{(])*))\1([{(])/guy, "$1\\$2")}${patternToTest.endsWith("/**") ? "/*" : ""}`;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region node_modules/.pnpm/eslint-config-flat-gitignore@2.3.0_eslint@10.6.0_jiti@2.7.0_/node_modules/eslint-config-flat-gitignore/dist/index.mjs
|
|
34
|
+
function toArray(array) {
|
|
35
|
+
array = array ?? [];
|
|
36
|
+
return Array.isArray(array) ? array : [array];
|
|
37
|
+
}
|
|
38
|
+
const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
39
|
+
function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
40
|
+
let directory = path.resolve(toPath(cwd) ?? "");
|
|
41
|
+
const { root } = path.parse(directory);
|
|
42
|
+
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
|
43
|
+
const isAbsoluteName = path.isAbsolute(name);
|
|
44
|
+
while (directory) {
|
|
45
|
+
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
46
|
+
try {
|
|
47
|
+
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
48
|
+
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
49
|
+
} catch {}
|
|
50
|
+
if (directory === stopAt || directory === root) break;
|
|
51
|
+
directory = path.dirname(directory);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const GITIGNORE = ".gitignore";
|
|
55
|
+
const GITMODULES = ".gitmodules";
|
|
56
|
+
const RE_NEWLINE = /\r?\n/u;
|
|
57
|
+
const RE_PARENT_PATH = /^(?:\.\.\/)+$/;
|
|
58
|
+
const RE_PATH_SEP = /[/\\]/;
|
|
59
|
+
const RE_SUBMODULE_PATH = /path\s*=\s*(.+)/u;
|
|
60
|
+
function ignore(options = {}) {
|
|
61
|
+
const ignores = [];
|
|
62
|
+
const { cwd = process.cwd(), root = false, recursive = false, files: _files = root ? GITIGNORE : findUpSync(GITIGNORE, { cwd }) || [], filesGitModules: _filesGitModules = root ? fs.existsSync(join(cwd, GITMODULES)) ? GITMODULES : [] : findUpSync(GITMODULES, { cwd }) || [], strict = true } = options;
|
|
63
|
+
const files = new Set(toArray(_files).map((file) => resolve(cwd, file)));
|
|
64
|
+
if (recursive) {
|
|
65
|
+
const additionalIgnoreDirs = typeof recursive === "boolean" ? [] : recursive.skipDirs;
|
|
66
|
+
for (const file of findNestedFiles(cwd, GITIGNORE, additionalIgnoreDirs)) files.add(file);
|
|
67
|
+
}
|
|
68
|
+
const filesList = [...files];
|
|
69
|
+
const filesGitModules = toArray(_filesGitModules).map((file) => resolve(cwd, file));
|
|
70
|
+
for (const file of filesList) {
|
|
71
|
+
let content = "";
|
|
72
|
+
try {
|
|
73
|
+
content = fs.readFileSync(file, "utf8");
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (strict) throw error;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const relativePath = relative(cwd, dirname(file)).replaceAll("\\", "/");
|
|
79
|
+
const globs = content.split(RE_NEWLINE).filter((line) => line && !line.startsWith("#")).map((line) => convertIgnorePatternToMinimatch(line)).map((glob) => relativeMinimatch(glob, relativePath, cwd)).filter((glob) => glob !== null);
|
|
80
|
+
ignores.push(...globs);
|
|
81
|
+
}
|
|
82
|
+
for (const file of filesGitModules) {
|
|
83
|
+
let content = "";
|
|
84
|
+
try {
|
|
85
|
+
content = fs.readFileSync(file, "utf8");
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (strict) throw error;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const dirs = parseGitSubmodules(content);
|
|
91
|
+
ignores.push(...dirs.map((dir) => `${dir}/**`));
|
|
92
|
+
}
|
|
93
|
+
if (strict && filesList.length === 0) throw new Error("No .gitignore file found");
|
|
94
|
+
return {
|
|
95
|
+
name: options.name || "gitignore",
|
|
96
|
+
ignores
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function findNestedFiles(cwd, fileName, additionalIgnoreDirs) {
|
|
100
|
+
const files = [];
|
|
101
|
+
const directoriesToSkip = /* @__PURE__ */ new Set([
|
|
102
|
+
".git",
|
|
103
|
+
"node_modules",
|
|
104
|
+
...additionalIgnoreDirs
|
|
105
|
+
]);
|
|
106
|
+
const queue = [cwd];
|
|
107
|
+
while (queue.length) {
|
|
108
|
+
const directory = queue.shift();
|
|
109
|
+
const entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
110
|
+
for (const entry of entries) {
|
|
111
|
+
const absolutePath = join(directory, entry.name);
|
|
112
|
+
if (entry.isFile() && entry.name === fileName) files.push(absolutePath);
|
|
113
|
+
if (entry.isDirectory() && !directoriesToSkip.has(entry.name)) queue.push(absolutePath);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return files;
|
|
117
|
+
}
|
|
118
|
+
function relativeMinimatch(pattern, relativePath, cwd) {
|
|
119
|
+
if ([
|
|
120
|
+
"",
|
|
121
|
+
".",
|
|
122
|
+
"/"
|
|
123
|
+
].includes(relativePath)) return pattern;
|
|
124
|
+
const negated = pattern.startsWith("!") ? "!" : "";
|
|
125
|
+
let cleanPattern = negated ? pattern.slice(1) : pattern;
|
|
126
|
+
if (!relativePath.endsWith("/")) relativePath = `${relativePath}/`;
|
|
127
|
+
if (!relativePath.startsWith("..")) return `${negated}${relativePath}${cleanPattern}`;
|
|
128
|
+
if (!RE_PARENT_PATH.test(relativePath)) throw new Error("The ignore file location should be either a parent or child directory");
|
|
129
|
+
if (cleanPattern.startsWith("**")) return pattern;
|
|
130
|
+
const parents = relative(resolve(cwd, relativePath), cwd).split(RE_PATH_SEP);
|
|
131
|
+
while (parents.length && cleanPattern.startsWith(`${parents[0]}/`)) {
|
|
132
|
+
cleanPattern = cleanPattern.slice(parents[0].length + 1);
|
|
133
|
+
parents.shift();
|
|
134
|
+
}
|
|
135
|
+
if (cleanPattern.startsWith("**")) return `${negated}${cleanPattern}`;
|
|
136
|
+
if (parents.length === 0) return `${negated}${cleanPattern}`;
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function parseGitSubmodules(content) {
|
|
140
|
+
return content.split(RE_NEWLINE).map((line) => RE_SUBMODULE_PATH.exec(line)).filter((match) => match !== null).map((match) => match[1].trim());
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { ignore as default };
|