format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

View File

@ -5,7 +5,7 @@ const scan = require('./scan');
const parse = require('./parse');
const utils = require('./utils');
const constants = require('./constants');
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
const isObject = (val) => val && typeof val === 'object' && !Array.isArray(val);
/**
* Creates a matcher function from one or more glob patterns. The
@ -31,8 +31,8 @@ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
const picomatch = (glob, options, returnState = false) => {
if (Array.isArray(glob)) {
const fns = glob.map(input => picomatch(input, options, returnState));
const arrayMatcher = str => {
const fns = glob.map((input) => picomatch(input, options, returnState));
const arrayMatcher = (str) => {
for (const isMatch of fns) {
const state = isMatch(str);
if (state) return state;
@ -50,8 +50,9 @@ const picomatch = (glob, options, returnState = false) => {
const opts = options || {};
const posix = utils.isWindows(options);
const regex = isState
? picomatch.compileRe(glob, options)
const regex =
isState ?
picomatch.compileRe(glob, options)
: picomatch.makeRe(glob, options, false, true);
const state = regex.state;
@ -59,12 +60,20 @@ const picomatch = (glob, options, returnState = false) => {
let isIgnored = () => false;
if (opts.ignore) {
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
const ignoreOpts = {
...options,
ignore: null,
onMatch: null,
onResult: null,
};
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
}
const matcher = (input, returnObject = false) => {
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
const { isMatch, match, output } = picomatch.test(input, regex, options, {
glob,
posix,
});
const result = { glob, state, regex, posix, input, output, match, isMatch };
if (typeof opts.onResult === 'function') {
@ -126,7 +135,7 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
const opts = options || {};
const format = opts.format || (posix ? utils.toPosixSlashes : null);
let match = input === glob;
let output = (match && format) ? format(input) : input;
let output = match && format ? format(input) : input;
if (match === false) {
output = format ? format(input) : input;
@ -158,7 +167,12 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
* @api public
*/
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
picomatch.matchBase = (
input,
glob,
options,
posix = utils.isWindows(options)
) => {
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
return regex.test(path.basename(input));
};
@ -180,7 +194,8 @@ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) =
* @api public
*/
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
picomatch.isMatch = (str, patterns, options) =>
picomatch(patterns, options)(str);
/**
* Parse a glob pattern to create the source string for a regular
@ -197,7 +212,8 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str
*/
picomatch.parse = (pattern, options) => {
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
if (Array.isArray(pattern))
return pattern.map((p) => picomatch.parse(p, options));
return parse(pattern, { ...options, fastpaths: false });
};
@ -242,7 +258,12 @@ picomatch.scan = (input, options) => scan(input, options);
* @api public
*/
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
picomatch.compileRe = (
state,
options,
returnOutput = false,
returnState = false
) => {
if (returnOutput === true) {
return state.output;
}
@ -283,7 +304,12 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false
* @api public
*/
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
picomatch.makeRe = (
input,
options = {},
returnOutput = false,
returnState = false
) => {
if (!input || typeof input !== 'string') {
throw new TypeError('Expected a non-empty string');
}