feat: adding linter for commits

This commit is contained in:
Carlos Gutierrez
2021-11-22 09:39:27 -06:00
commit 2c7c117aa1
3093 changed files with 1215197 additions and 0 deletions

158
node_modules/dargs/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,158 @@
declare namespace dargs {
interface Options {
/**
Keys or regex of keys to exclude. Takes precedence over `includes`.
*/
excludes?: ReadonlyArray<string | RegExp>;
/**
Keys or regex of keys to include.
*/
includes?: ReadonlyArray<string | RegExp>;
/**
Maps keys in `input` to an aliased name. Matching keys are converted to arguments with a single dash (`-`) in front of the aliased key and the value in a separate array item. Keys are still affected by `includes` and `excludes`.
*/
aliases?: {[key: string]: string};
/**
Setting this to `false` makes it return the key and value as separate array items instead of using a `=` separator in one item. This can be useful for tools that doesn't support `--foo=bar` style flags.
@default true
@example
```
import dargs = require('dargs');
console.log(dargs({foo: 'bar'}, {useEquals: false}));
// [
// '--foo', 'bar'
// ]
```
*/
useEquals?: boolean;
/**
Make a single character option key `{a: true}` become a short flag `-a` instead of `--a`.
@default true
@example
```
import dargs = require('dargs');
console.log(dargs({a: true}));
//=> ['-a']
console.log(dargs({a: true}, {shortFlag: false}));
//=> ['--a']
```
*/
shortFlag?: boolean;
/**
Exclude `false` values. Can be useful when dealing with strict argument parsers that throw on unknown arguments like `--no-foo`.
@default false
*/
ignoreFalse?: boolean;
/**
By default, camel-cased keys will be hyphenated. Enabling this will bypass the conversion process.
@default false
@example
```
import dargs = require('dargs');
console.log(dargs({fooBar: 'baz'}));
//=> ['--foo-bar', 'baz']
console.log(dargs({fooBar: 'baz'}, {allowCamelCase: true}));
//=> ['--fooBar', 'baz']
```
*/
allowCamelCase?: boolean;
}
}
/**
Reverse [`minimist`](https://github.com/substack/minimist). Convert an object of options into an array of command-line arguments.
@param object - Object to convert to command-line arguments.
@example
```
import dargs = require('dargs');
const input = {
_: ['some', 'option'], // Values in '_' will be appended to the end of the generated argument list
'--': ['separated', 'option'], // Values in '--' will be put at the very end of the argument list after the escape option (`--`)
foo: 'bar',
hello: true, // Results in only the key being used
cake: false, // Prepends `no-` before the key
camelCase: 5, // CamelCase is slugged to `camel-case`
multiple: ['value', 'value2'], // Converted to multiple arguments
pieKind: 'cherry',
sad: ':('
};
const excludes = ['sad', /.*Kind$/]; // Excludes and includes accept regular expressions
const includes = ['camelCase', 'multiple', 'sad', /^pie.+/];
const aliases = {file: 'f'};
console.log(dargs(input, {excludes}));
// [
// '--foo=bar',
// '--hello',
// '--no-cake',
// '--camel-case=5',
// '--multiple=value',
// '--multiple=value2',
// 'some',
// 'option',
// '--',
// 'separated',
// 'option'
// ]
console.log(dargs(input, {excludes, includes}));
// [
// '--camel-case=5',
// '--multiple=value',
// '--multiple=value2'
// ]
console.log(dargs(input, {includes}));
// [
// '--camel-case=5',
// '--multiple=value',
// '--multiple=value2',
// '--pie-kind=cherry',
// '--sad=:('
// ]
console.log(dargs({
foo: 'bar',
hello: true,
file: 'baz'
}, {aliases}));
// [
// '--foo=bar',
// '--hello',
// '-f', 'baz'
// ]
```
*/
declare function dargs(
object: {
'--'?: string[];
_?: string[];
} & {[key: string]: string | boolean | number | readonly string[]},
options?: dargs.Options
): string[];
export = dargs;

120
node_modules/dargs/index.js generated vendored Normal file
View File

@ -0,0 +1,120 @@
'use strict';
const match = (array, value) =>
array.some(x => (x instanceof RegExp ? x.test(value) : x === value));
const dargs = (object, options) => {
const arguments_ = [];
let extraArguments = [];
let separatedArguments = [];
options = {
useEquals: true,
shortFlag: true,
...options
};
const makeArguments = (key, value) => {
const prefix = options.shortFlag && key.length === 1 ? '-' : '--';
const theKey = (options.allowCamelCase ?
key :
key.replace(/[A-Z]/g, '-$&').toLowerCase());
key = prefix + theKey;
if (options.useEquals) {
arguments_.push(key + (value ? `=${value}` : ''));
} else {
arguments_.push(key);
if (value) {
arguments_.push(value);
}
}
};
const makeAliasArg = (key, value) => {
arguments_.push(`-${key}`);
if (value) {
arguments_.push(value);
}
};
for (let [key, value] of Object.entries(object)) {
let pushArguments = makeArguments;
if (Array.isArray(options.excludes) && match(options.excludes, key)) {
continue;
}
if (Array.isArray(options.includes) && !match(options.includes, key)) {
continue;
}
if (typeof options.aliases === 'object' && options.aliases[key]) {
key = options.aliases[key];
pushArguments = makeAliasArg;
}
if (key === '--') {
if (!Array.isArray(value)) {
throw new TypeError(
`Expected key \`--\` to be Array, got ${typeof value}`
);
}
separatedArguments = value;
continue;
}
if (key === '_') {
if (!Array.isArray(value)) {
throw new TypeError(
`Expected key \`_\` to be Array, got ${typeof value}`
);
}
extraArguments = value;
continue;
}
if (value === true) {
pushArguments(key, '');
}
if (value === false && !options.ignoreFalse) {
pushArguments(`no-${key}`);
}
if (typeof value === 'string') {
pushArguments(key, value);
}
if (typeof value === 'number' && !Number.isNaN(value)) {
pushArguments(key, String(value));
}
if (Array.isArray(value)) {
for (const arrayValue of value) {
pushArguments(key, arrayValue);
}
}
}
for (const argument of extraArguments) {
arguments_.push(String(argument));
}
if (separatedArguments.length > 0) {
arguments_.push('--');
}
for (const argument of separatedArguments) {
arguments_.push(String(argument));
}
return arguments_;
};
module.exports = dargs;

9
node_modules/dargs/license generated vendored Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

48
node_modules/dargs/package.json generated vendored Normal file
View File

@ -0,0 +1,48 @@
{
"name": "dargs",
"version": "7.0.0",
"description": "Reverse minimist. Convert an object of options into an array of command-line arguments.",
"license": "MIT",
"repository": "sindresorhus/dargs",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"reverse",
"minimist",
"options",
"arguments",
"args",
"flags",
"cli",
"nopt",
"commander",
"binary",
"command",
"inverse",
"opposite",
"invert",
"switch",
"construct",
"parse",
"parser",
"argv"
],
"devDependencies": {
"ava": "^2.1.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
}

179
node_modules/dargs/readme.md generated vendored Normal file
View File

@ -0,0 +1,179 @@
# dargs [![Build Status](https://travis-ci.org/sindresorhus/dargs.svg?branch=master)](https://travis-ci.org/sindresorhus/dargs)
> Reverse [`minimist`](https://github.com/substack/minimist). Convert an object of options into an array of command-line arguments.
Useful when spawning command-line tools.
## Install
```
$ npm install dargs
```
## Usage
```js
const dargs = require('dargs');
const object = {
_: ['some', 'option'], // Values in '_' will be appended to the end of the generated argument list
'--': ['separated', 'option'], // Values in '--' will be put at the very end of the argument list after the escape option (`--`)
foo: 'bar',
hello: true, // Results in only the key being used
cake: false, // Prepends `no-` before the key
camelCase: 5, // CamelCase is slugged to `camel-case`
multiple: ['value', 'value2'], // Converted to multiple arguments
pieKind: 'cherry',
sad: ':('
};
const excludes = ['sad', /.*Kind$/]; // Excludes and includes accept regular expressions
const includes = ['camelCase', 'multiple', 'sad', /^pie.*/];
const aliases = {file: 'f'};
console.log(dargs(object, {excludes}));
/*
[
'--foo=bar',
'--hello',
'--no-cake',
'--camel-case=5',
'--multiple=value',
'--multiple=value2',
'some',
'option',
'--',
'separated',
'option'
]
*/
console.log(dargs(object, {excludes, includes}));
/*
[
'--camel-case=5',
'--multiple=value',
'--multiple=value2'
]
*/
console.log(dargs(object, {includes}));
/*
[
'--camel-case=5',
'--multiple=value',
'--multiple=value2',
'--pie-kind=cherry',
'--sad=:('
]
*/
console.log(dargs({
foo: 'bar',
hello: true,
file: 'baz'
}, {aliases}));
/*
[
'--foo=bar',
'--hello',
'-f', 'baz'
]
*/
```
## API
### dargs(object, options?)
#### object
Type: `object`
Object to convert to command-line arguments.
#### options
Type: `object`
##### excludes
Type: `Array<string | RegExp>`
Keys or regex of keys to exclude. Takes precedence over `includes`.
##### includes
Type: `Array<string | RegExp>`
Keys or regex of keys to include.
##### aliases
Type: `object`
Maps keys in `object` to an aliased name. Matching keys are converted to arguments with a single dash (`-`) in front of the aliased key and the value in a separate array item. Keys are still affected by `includes` and `excludes`.
##### useEquals
Type: `boolean`<br>
Default: `true`
Setting this to `false` makes it return the key and value as separate array items instead of using a `=` separator in one item. This can be useful for tools that doesn't support `--foo=bar` style flags.
```js
const dargs = require('dargs');
console.log(dargs({foo: 'bar'}, {useEquals: false}));
/*
[
'--foo', 'bar'
]
*/
```
##### shortFlag
Type: `boolean`<br>
Default: `true`
Make a single character option key `{a: true}` become a short flag `-a` instead of `--a`.
```js
const dargs = require('dargs');
console.log(dargs({a: true}));
//=> ['-a']
console.log(dargs({a: true}, {shortFlag: false}));
//=> ['--a']
```
##### ignoreFalse
Type: `boolean`<br>
Default: `false`
Exclude `false` values. Can be useful when dealing with strict argument parsers that throw on unknown arguments like `--no-foo`.
##### allowCamelCase
Type: `boolean`<br>
Default: `false`
By default, camel-cased keys will be hyphenated. Enabling this will bypass the conversion process.
```js
const dargs = require('dargs');
console.log(dargs({fooBar: 'baz'}));
//=> ['--foo-bar', 'baz']
console.log(dargs({fooBar: 'baz'}, {allowCamelCase: true}));
//=> ['--fooBar', 'baz']
```