Skip to content

Commit

Permalink
Merge pull request #414 from mrmlnc/update_eslint_config
Browse files Browse the repository at this point in the history
Update eslint config
  • Loading branch information
mrmlnc committed Aug 3, 2023
2 parents 212f02e + f3f308d commit b775344
Show file tree
Hide file tree
Showing 79 changed files with 735 additions and 649 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"@types/picomatch": "^2.3.0",
"@types/sinon": "^10.0.15",
"bencho": "^0.1.1",
"eslint": "^6.5.1",
"eslint-config-mrmlnc": "^1.1.0",
"eslint": "^8.46.0",
"eslint-config-mrmlnc": "^4.0.1",
"execa": "^7.2.0",
"fast-glob": "^3.3.1",
"fdir": "^6.0.1",
Expand Down
27 changes: 16 additions & 11 deletions src/benchmark/suites/product/async.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as path from 'path';
import * as path from 'node:path';

import * as bencho from 'bencho';

import * as utils from '../../utils';

type GlobImplementation = 'node-glob' | 'fast-glob' | 'fdir';
type GlobImplementation = 'fast-glob' | 'fdir' | 'node-glob';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type GlobImplFunction = (...args: any[]) => Promise<unknown[]>;

Expand All @@ -15,7 +16,7 @@ class Glob {

await this._measure(() => glob.glob(this._pattern, {
cwd: this._cwd,
nodir: true
nodir: true,
}));
}

Expand All @@ -26,7 +27,7 @@ class Glob {
cwd: this._cwd,
unique: false,
followSymbolicLinks: false,
concurrency: Number.POSITIVE_INFINITY
concurrency: Number.POSITIVE_INFINITY,
}));
}

Expand All @@ -43,10 +44,10 @@ class Glob {
await this._measure(() => fdir.withPromise());
}

private async _measure(func: GlobImplFunction): Promise<void> {
private async _measure(function_: GlobImplFunction): Promise<void> {
const timeStart = utils.timeStart();

const matches = await func();
const matches = await function_();

const count = matches.length;
const memory = utils.getMemory();
Expand All @@ -69,19 +70,23 @@ class Glob {
const glob = new Glob(cwd, pattern);

switch (impl) {
case 'node-glob':
case 'node-glob': {
await glob.measureNodeGlob();
break;
}

case 'fast-glob':
case 'fast-glob': {
await glob.measureFastGlob();
break;
}

case 'fdir':
case 'fdir': {
await glob.measureFdir();
break;
}

default:
throw new TypeError(`Unknown glob implementation: ${impl}`);
default: {
throw new TypeError('Unknown glob implementation.');
}
}
})();
40 changes: 26 additions & 14 deletions src/benchmark/suites/product/stream.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as path from 'path';
import * as path from 'node:path';

import * as bencho from 'bencho';

import * as utils from '../../utils';

type GlobImplementation = 'node-glob' | 'fast-glob';
type GlobImplementation = 'fast-glob' | 'node-glob';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type GlobImplFunction = (...args: any[]) => Promise<unknown[]>;

Expand All @@ -17,13 +18,17 @@ class Glob {

const stream = glob.globStream(this._pattern, {
cwd: this._cwd,
nodir: true
nodir: true,
});

const action = new Promise<string[]>((resolve, reject) => {
stream.on('error', (error) => reject(error));
stream.on('error', (error) => {
reject(error);
});
stream.on('data', (entry: string) => entries.push(entry));
stream.on('end', () => resolve(entries));
stream.on('end', () => {
resolve(entries);
});
});

await this._measure(() => action);
Expand All @@ -38,22 +43,26 @@ class Glob {
cwd: this._cwd,
unique: false,
followSymbolicLinks: false,
concurrency: Number.POSITIVE_INFINITY
concurrency: Number.POSITIVE_INFINITY,
});

const action = new Promise<string[]>((resolve, reject) => {
stream.once('error', (error) => reject(error));
stream.once('error', (error) => {
reject(error);
});
stream.on('data', (entry: string) => entries.push(entry));
stream.once('end', () => resolve(entries));
stream.once('end', () => {
resolve(entries);
});
});

await this._measure(() => action);
}

private async _measure(func: GlobImplFunction): Promise<void> {
private async _measure(function_: GlobImplFunction): Promise<void> {
const timeStart = utils.timeStart();

const matches = await func();
const matches = await function_();

const count = matches.length;
const memory = utils.getMemory();
Expand All @@ -76,15 +85,18 @@ class Glob {
const glob = new Glob(cwd, pattern);

switch (impl) {
case 'node-glob':
case 'node-glob': {
await glob.measureNodeGlob();
break;
}

case 'fast-glob':
case 'fast-glob': {
await glob.measureFastGlob();
break;
}

default:
throw new TypeError(`Unknown glob implementation: ${impl}`);
default: {
throw new TypeError('Unknown glob implementation.');
}
}
})();
27 changes: 16 additions & 11 deletions src/benchmark/suites/product/sync.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as path from 'path';
import * as path from 'node:path';

import * as bencho from 'bencho';

import * as utils from '../../utils';

type GlobImplementation = 'node-glob' | 'fast-glob' | 'fdir';
type GlobImplementation = 'fast-glob' | 'fdir' | 'node-glob';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type GlobImplFunction = (...args: any[]) => unknown[];

Expand All @@ -15,7 +16,7 @@ class Glob {

this._measure(() => glob.globSync(this._pattern, {
cwd: this._cwd,
nodir: true
nodir: true,
}));
}

Expand All @@ -25,7 +26,7 @@ class Glob {
this._measure(() => glob.sync(this._pattern, {
cwd: this._cwd,
unique: false,
followSymbolicLinks: false
followSymbolicLinks: false,
}));
}

Expand All @@ -42,10 +43,10 @@ class Glob {
this._measure(() => fdir.sync());
}

private _measure(func: GlobImplFunction): void {
private _measure(function_: GlobImplFunction): void {
const timeStart = utils.timeStart();

const matches = func();
const matches = function_();

const count = matches.length;
const memory = utils.getMemory();
Expand All @@ -68,19 +69,23 @@ class Glob {
const glob = new Glob(cwd, pattern);

switch (impl) {
case 'node-glob':
case 'node-glob': {
await glob.measureNodeGlob();
break;
}

case 'fast-glob':
case 'fast-glob': {
await glob.measureFastGlob();
break;
}

case 'fdir':
case 'fdir': {
await glob.measureFdir();
break;
}

default:
throw new TypeError(`Unknown glob implementation: ${impl}`);
default: {
throw new TypeError('Unknown glob implementation.');
}
}
})();
28 changes: 16 additions & 12 deletions src/benchmark/suites/regression/async.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as path from 'path';
import * as path from 'node:path';

import * as bencho from 'bencho';

import * as fastGlobCurrent from '../../..';

import * as utils from '../../utils';

type GlobImplementation = 'previous' | 'current';
type GlobImplementation = 'current' | 'previous';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type GlobImplFunction = (...args: any[]) => Promise<unknown[]>;
type GlobOptions = fastGlobCurrent.Options;

class Glob {
private readonly _options: fastGlobCurrent.Options;
Expand All @@ -17,7 +18,7 @@ class Glob {
unique: false,
followSymbolicLinks: false,
concurrency: Number.POSITIVE_INFINITY,
...options
...options,
};
}

Expand All @@ -34,10 +35,10 @@ class Glob {
await this._measure(() => glob(this._pattern, this._options));
}

private async _measure(func: GlobImplFunction): Promise<void> {
private async _measure(function_: GlobImplFunction): Promise<void> {
const timeStart = utils.timeStart();

const matches = await func();
const matches = await function_();

const count = matches.length;
const memory = utils.getMemory();
Expand All @@ -56,23 +57,26 @@ class Glob {
const cwd = path.join(process.cwd(), args[0]);
const pattern = args[1];
const impl = args[2] as GlobImplementation;
const options = JSON.parse(process.env.BENCHMARK_OPTIONS ?? '{}');
const options = JSON.parse(process.env.BENCHMARK_OPTIONS ?? '{}') as GlobOptions;

const glob = new Glob(pattern, {
cwd,
...options
...options,
});

switch (impl) {
case 'current':
case 'current': {
await glob.measureCurrentVersion();
break;
}

case 'previous':
case 'previous': {
await glob.measurePreviousVersion();
break;
}

default:
throw new TypeError(`Unknown glob implementation: ${impl}`);
default: {
throw new TypeError('Unknown glob implementation.');
}
}
})();
Loading

0 comments on commit b775344

Please sign in to comment.