From e2b8ff7175c8b5bddaf197f75ae84be446ee563f Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Sun, 21 Apr 2019 19:12:11 +0300 Subject: [PATCH] refactor: drop `I` prefix for interfaces --- src/benchmark/index.ts | 8 ++++---- src/benchmark/reporter.spec.ts | 4 ++-- src/benchmark/reporter.ts | 4 ++-- src/benchmark/runner.spec.ts | 18 ++++++++-------- src/benchmark/runner.ts | 32 ++++++++++++++--------------- src/benchmark/utils.ts | 4 ++-- src/index.spec.ts | 6 +++--- src/index.ts | 2 +- src/managers/tasks.spec.ts | 22 ++++++++++---------- src/managers/tasks.ts | 10 ++++----- src/providers/reader-async.spec.ts | 4 ++-- src/providers/reader-async.ts | 8 ++++---- src/providers/reader-stream.spec.ts | 6 +++--- src/providers/reader-stream.ts | 8 ++++---- src/providers/reader-sync.spec.ts | 4 ++-- src/providers/reader-sync.ts | 8 ++++---- src/providers/reader.spec.ts | 8 ++++---- src/providers/reader.ts | 8 ++++---- src/tests/index.ts | 10 ++++----- src/tests/smoke/smoke.ts | 14 ++++++------- src/types/entries.ts | 5 ++--- tslint.json | 5 +---- 22 files changed, 97 insertions(+), 101 deletions(-) diff --git a/src/benchmark/index.ts b/src/benchmark/index.ts index 4576dc65..14cab2b0 100644 --- a/src/benchmark/index.ts +++ b/src/benchmark/index.ts @@ -3,14 +3,14 @@ import rimraf = require('rimraf'); import * as fixtures from './fixtures'; import * as logger from './logger'; -import Runner, { IRunnerOptions } from './runner'; +import Runner, { RunnerOptions } from './runner'; import * as utils from './utils'; -interface IArgv extends IRunnerOptions { +interface Arguments extends RunnerOptions { basedir: string; } -const defaultArgv: IArgv = { +const defaultArgv: Arguments = { basedir: '.benchmark', type: 'async', depth: utils.getEnvAsInteger('BENCHMARK_DEPTH') || 1, @@ -19,7 +19,7 @@ const defaultArgv: IArgv = { retries: utils.getEnvAsInteger('BENCHMARK_RETRIES') || 5 }; -const argv = minimist(process.argv.slice(2), { +const argv = minimist(process.argv.slice(2), { default: defaultArgv }); diff --git a/src/benchmark/reporter.spec.ts b/src/benchmark/reporter.spec.ts index f0febc3d..bf1ee51c 100644 --- a/src/benchmark/reporter.spec.ts +++ b/src/benchmark/reporter.spec.ts @@ -1,10 +1,10 @@ import * as assert from 'assert'; import Reporter from './reporter'; -import { ISuitePackResult } from './runner'; +import { SuitePackResult } from './runner'; describe('Benchmark → Reporter', () => { - const results: ISuitePackResult = { + const results: SuitePackResult = { name: 'name', errors: 0, retries: 1, diff --git a/src/benchmark/reporter.ts b/src/benchmark/reporter.ts index a11d40fe..19e7cf2f 100644 --- a/src/benchmark/reporter.ts +++ b/src/benchmark/reporter.ts @@ -1,7 +1,7 @@ -import { ISuitePackResult } from './runner'; +import { SuitePackResult } from './runner'; export default class Reporter { - constructor(private readonly results: ISuitePackResult) { } + constructor(private readonly results: SuitePackResult) { } public toString(): string { return this.header + '\n' + this.measures + ' | ' + this.meta; diff --git a/src/benchmark/runner.spec.ts b/src/benchmark/runner.spec.ts index fe15071e..23f182c3 100644 --- a/src/benchmark/runner.spec.ts +++ b/src/benchmark/runner.spec.ts @@ -1,6 +1,6 @@ import * as assert from 'assert'; -import Runner, { IRunnerOptions, ISuiteMeasures, ISuitePackResult } from './runner'; +import Runner, { RunnerOptions, SuiteMeasures, SuitePackResult } from './runner'; class RunnerFakeProcess extends Runner { public execNodeProcess(): string { @@ -15,9 +15,9 @@ class RunnerFakeProcessError extends Runner { } class RunnerFakeReport extends RunnerFakeProcess { - public results: ISuitePackResult[] = []; + public results: SuitePackResult[] = []; - public report(results: ISuitePackResult): void { + public report(results: SuitePackResult): void { this.results.push(results); } @@ -27,7 +27,7 @@ class RunnerFakeReport extends RunnerFakeProcess { } describe('Benchmark → Runner', () => { - const runnerOptions: IRunnerOptions = { + const runnerOptions: RunnerOptions = { type: 'async', depth: 1, launches: 3, @@ -37,9 +37,9 @@ describe('Benchmark → Runner', () => { describe('.suite', () => { it('should returns measures', () => { - const runner = new RunnerFakeProcess('basedir', {} as IRunnerOptions); + const runner = new RunnerFakeProcess('basedir', {} as RunnerOptions); - const expected: ISuiteMeasures = { + const expected: SuiteMeasures = { matches: 1, time: 1, memory: 1 @@ -51,7 +51,7 @@ describe('Benchmark → Runner', () => { }); it('should throw error', () => { - const runner = new RunnerFakeProcessError('basedir', {} as IRunnerOptions); + const runner = new RunnerFakeProcessError('basedir', {} as RunnerOptions); assert.throws(() => runner.suite('suitePath'), /Ops! Broken suite run\./); }); @@ -61,7 +61,7 @@ describe('Benchmark → Runner', () => { it('should returns pack measures', () => { const runner = new RunnerFakeProcess('basedir', runnerOptions); - const expected: ISuitePackResult = { + const expected: SuitePackResult = { name: 'suitePath', errors: 0, retries: 1, @@ -80,7 +80,7 @@ describe('Benchmark → Runner', () => { it('should returns pack measures with errors', () => { const runner = new RunnerFakeProcessError('basedir', runnerOptions); - const expected: ISuitePackResult = { + const expected: SuitePackResult = { name: 'suitePath', errors: 3, retries: 1, diff --git a/src/benchmark/runner.ts b/src/benchmark/runner.ts index ce09da50..a2202894 100644 --- a/src/benchmark/runner.ts +++ b/src/benchmark/runner.ts @@ -6,7 +6,7 @@ import execa = require('execa'); import Reporter from './reporter'; import * as utils from './utils'; -export interface IRunnerOptions { +export interface RunnerOptions { /** * The directory from which you want to take suites. */ @@ -29,34 +29,34 @@ export interface IRunnerOptions { retries: number; } -export interface ISuiteMeasures { +export interface SuiteMeasures { matches: number; time: number; memory: number; } -export interface IMeasure { +export interface Measure { units: string; raw: number[]; average: number; stdev: number; } -export interface ISuitePackMeasures extends Record { - time: IMeasure; - memory: IMeasure; +export interface SuitePackMeasures extends Record { + time: Measure; + memory: Measure; } -export interface ISuitePackResult { +export interface SuitePackResult { name: string; errors: number; entries: number; retries: number; - measures: ISuitePackMeasures; + measures: SuitePackMeasures; } export default class Runner { - constructor(private readonly basedir: string, private readonly options: IRunnerOptions) { } + constructor(private readonly basedir: string, private readonly options: RunnerOptions) { } /** * Runs child process. @@ -68,7 +68,7 @@ export default class Runner { /** * Runs a single suite in the child process and returns the measurements of his work. */ - public suite(suitePath: string): ISuiteMeasures { + public suite(suitePath: string): SuiteMeasures { const env: Record = { NODE_ENV: 'production', BENCHMARK_CWD: this.basedir @@ -77,7 +77,7 @@ export default class Runner { const stdout = this.execNodeProcess([suitePath], { env, extendEnv: true }); try { - return JSON.parse(stdout) as ISuiteMeasures; + return JSON.parse(stdout) as SuiteMeasures; } catch { throw new TypeError('Ops! Broken suite run.'); } @@ -86,8 +86,8 @@ export default class Runner { /** * Runs a pack of suites. */ - public suitePack(suitePath: string, retries: number): ISuitePackResult { - const results: ISuitePackResult = { + public suitePack(suitePath: string, retries: number): SuitePackResult { + const results: SuitePackResult = { name: path.basename(suitePath), errors: 0, entries: 0, @@ -119,7 +119,7 @@ export default class Runner { return results; } - public report(result: ISuitePackResult): void { + public report(result: SuitePackResult): void { const reporter = new Reporter(result); const report = reporter.toString(); @@ -148,7 +148,7 @@ export default class Runner { return fs.readdirSync(suitesPath).filter((suite) => suite.endsWith('.js')); } - private getMeasures(raw: number[], units: string): IMeasure { + private getMeasures(raw: number[], units: string): Measure { return { units, raw, @@ -157,7 +157,7 @@ export default class Runner { }; } - private getSuitePackMeasures(): ISuitePackMeasures { + private getSuitePackMeasures(): SuitePackMeasures { return { time: this.getMeasures([], 'ms'), memory: this.getMeasures([], 'MB') diff --git a/src/benchmark/utils.ts b/src/benchmark/utils.ts index f1f271ac..0aec4ab8 100644 --- a/src/benchmark/utils.ts +++ b/src/benchmark/utils.ts @@ -1,6 +1,6 @@ import stdev = require('compute-stdev'); -import { ISuiteMeasures } from './runner'; +import { SuiteMeasures } from './runner'; export function convertHrtimeToMilliseconds(hrtime: [number, number]): number { const nanoseconds = (hrtime[0] * 1e9) + hrtime[1]; @@ -27,7 +27,7 @@ export function getMemory(): number { } export function getMeasures(matches: number, time: number, memory: number): string { - return JSON.stringify({ matches, time, memory } as ISuiteMeasures); + return JSON.stringify({ matches, time, memory } as SuiteMeasures); } export function getAverageValue(raw: number[]): number { diff --git a/src/index.spec.ts b/src/index.spec.ts index cdafac50..6bd5324d 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,7 +1,7 @@ import * as assert from 'assert'; import * as pkg from './index'; -import { ITask } from './managers/tasks'; +import { Task } from './managers/tasks'; import { EntryItem } from './types/entries'; describe('Package', () => { @@ -155,7 +155,7 @@ describe('Package', () => { }); it('should return tasks', () => { - const expected: ITask[] = [{ + const expected: Task[] = [{ base: '.', dynamic: true, patterns: ['*'], @@ -169,7 +169,7 @@ describe('Package', () => { }); it('should return tasks with negative patterns', () => { - const expected: ITask[] = [{ + const expected: Task[] = [{ base: '.', dynamic: true, patterns: ['*', '!*.txt', '!*.md'], diff --git a/src/index.ts b/src/index.ts index b359b67e..ead4e2e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ import { Pattern } from './types/patterns'; import * as arrayUtils from './utils/array'; import * as streamUtils from './utils/stream'; -type Task = taskManager.ITask; +type Task = taskManager.Task; /** * Synchronous API. diff --git a/src/managers/tasks.spec.ts b/src/managers/tasks.spec.ts index 49f6bb73..15811f4b 100644 --- a/src/managers/tasks.spec.ts +++ b/src/managers/tasks.spec.ts @@ -3,14 +3,14 @@ import * as assert from 'assert'; import Settings from '../settings'; import { PatternsGroup } from '../types/patterns'; import * as manager from './tasks'; -import { ITask } from './tasks'; +import { Task } from './tasks'; describe('Managers → Task', () => { describe('.generate', () => { it('should return task with windows-like patterns', () => { const settings = new Settings(); - const expected: ITask[] = [{ + const expected: Task[] = [{ base: 'a', dynamic: true, patterns: ['a/*'], @@ -26,7 +26,7 @@ describe('Managers → Task', () => { it('should return task with negative patterns from «ignore» option', () => { const settings = new Settings({ ignore: ['*.txt'] }); - const expected: ITask[] = [{ + const expected: Task[] = [{ base: 'a', dynamic: true, patterns: ['a/*', '!*.md', '!*.txt'], @@ -42,7 +42,7 @@ describe('Managers → Task', () => { it('should return static and dynamic tasks', () => { const settings = new Settings({ ignore: ['*.txt'] }); - const expected: ITask[] = [ + const expected: Task[] = [ { base: 'a', dynamic: false, @@ -67,7 +67,7 @@ describe('Managers → Task', () => { describe('.convertPatternsToTasks', () => { it('should return global task when positive patterns have a global pattern', () => { - const expected: ITask[] = [{ + const expected: Task[] = [{ base: '.', dynamic: true, patterns: ['*', '!*.md'], @@ -81,7 +81,7 @@ describe('Managers → Task', () => { }); it('should return global task with negative patterns from «ignore» patterns', () => { - const expected: ITask[] = [{ + const expected: Task[] = [{ base: '.', dynamic: true, patterns: ['*', '!*.md'], @@ -95,7 +95,7 @@ describe('Managers → Task', () => { }); it('should return two tasks', () => { - const expected: ITask[] = [ + const expected: Task[] = [ { base: 'a', dynamic: true, @@ -169,7 +169,7 @@ describe('Managers → Task', () => { describe('.convertPatternGroupToTask', () => { it('should return created dynamic task', () => { - const expected: ITask = { + const expected: Task = { base: '.', dynamic: true, patterns: ['*', '!*.md'], @@ -183,7 +183,7 @@ describe('Managers → Task', () => { }); it('should return created static task', () => { - const expected: ITask = { + const expected: Task = { base: '.', dynamic: false, patterns: ['file', '!file.md'], @@ -199,7 +199,7 @@ describe('Managers → Task', () => { describe('.convertPatternGroupsToTasks', () => { it('should return one task without negative patterns', () => { - const expected: ITask[] = [{ + const expected: Task[] = [{ base: 'a', dynamic: true, patterns: ['a/*'], @@ -213,7 +213,7 @@ describe('Managers → Task', () => { }); it('should return two tasks with negative patterns', () => { - const expected: ITask[] = [ + const expected: Task[] = [ { base: 'a', dynamic: true, diff --git a/src/managers/tasks.ts b/src/managers/tasks.ts index 378ed6e4..e17f7d72 100644 --- a/src/managers/tasks.ts +++ b/src/managers/tasks.ts @@ -2,7 +2,7 @@ import Settings from '../settings'; import { Pattern, PatternsGroup } from '../types/patterns'; import * as patternUtils from '../utils/pattern'; -export interface ITask { +export interface Task { base: string; dynamic: boolean; patterns: Pattern[]; @@ -13,7 +13,7 @@ export interface ITask { /** * Generate tasks based on parent directory of each pattern. */ -export function generate(patterns: Pattern[], settings: Settings): ITask[] { +export function generate(patterns: Pattern[], settings: Settings): Task[] { const unixPatterns = patterns.map(patternUtils.unixifyPattern); const unixIgnore = settings.ignore.map(patternUtils.unixifyPattern); @@ -32,7 +32,7 @@ export function generate(patterns: Pattern[], settings: Settings): ITask[] { /** * Convert patterns to tasks based on parent directory of each pattern. */ -export function convertPatternsToTasks(positive: Pattern[], negative: Pattern[], dynamic: boolean): ITask[] { +export function convertPatternsToTasks(positive: Pattern[], negative: Pattern[], dynamic: boolean): Task[] { const positivePatternsGroup = groupPatternsByBaseDirectory(positive); // When we have a global group – there is no reason to divide the patterns into independent tasks. @@ -83,7 +83,7 @@ export function groupPatternsByBaseDirectory(patterns: Pattern[]): PatternsGroup /** * Convert group of patterns to tasks. */ -export function convertPatternGroupsToTasks(positive: PatternsGroup, negative: Pattern[], dynamic: boolean): ITask[] { +export function convertPatternGroupsToTasks(positive: PatternsGroup, negative: Pattern[], dynamic: boolean): Task[] { return Object.keys(positive).map((base) => { return convertPatternGroupToTask(base, positive[base], negative, dynamic); }); @@ -92,7 +92,7 @@ export function convertPatternGroupsToTasks(positive: PatternsGroup, negative: P /** * Create a task for positive and negative patterns. */ -export function convertPatternGroupToTask(base: string, positive: Pattern[], negative: Pattern[], dynamic: boolean): ITask { +export function convertPatternGroupToTask(base: string, positive: Pattern[], negative: Pattern[], dynamic: boolean): Task { return { base, dynamic, diff --git a/src/providers/reader-async.spec.ts b/src/providers/reader-async.spec.ts index 1662d360..51f4550b 100644 --- a/src/providers/reader-async.spec.ts +++ b/src/providers/reader-async.spec.ts @@ -2,7 +2,7 @@ import * as assert from 'assert'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import Settings from '../settings'; import * as tests from '../tests/index'; import { Entry, EntryItem } from '../types/entries'; @@ -34,7 +34,7 @@ class ReaderAsyncFakeThrowErrno extends ReaderAsyncFake { } } -function getTask(dynamic: boolean = true): ITask { +function getTask(dynamic: boolean = true): Task { return { dynamic, base: 'fixtures', diff --git a/src/providers/reader-async.ts b/src/providers/reader-async.ts index b291ded5..b5ecafd8 100644 --- a/src/providers/reader-async.ts +++ b/src/providers/reader-async.ts @@ -1,7 +1,7 @@ import * as readdir from '@mrmlnc/readdir-enhanced'; import FileSystemStream from '../adapters/fs-stream'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import { Entry, EntryItem } from '../types/entries'; import Reader from './reader'; @@ -16,7 +16,7 @@ export default class ReaderAsync extends Reader> { /** * Use async API to read entries for Task. */ - public read(task: ITask): Promise { + public read(task: Task): Promise { const root = this.getRootDirectory(task); const options = this.getReaderOptions(task); @@ -38,7 +38,7 @@ export default class ReaderAsync extends Reader> { /** * Returns founded paths. */ - public api(root: string, task: ITask, options: readdir.Options): NodeJS.ReadableStream { + public api(root: string, task: Task, options: readdir.Options): NodeJS.ReadableStream { if (task.dynamic) { return this.dynamicApi(root, options); } @@ -56,7 +56,7 @@ export default class ReaderAsync extends Reader> { /** * Api for static tasks. */ - public staticApi(task: ITask, options: readdir.Options): NodeJS.ReadableStream { + public staticApi(task: Task, options: readdir.Options): NodeJS.ReadableStream { return this.fsAdapter.read(task.patterns, options.filter as readdir.FilterFunction); } } diff --git a/src/providers/reader-stream.spec.ts b/src/providers/reader-stream.spec.ts index e1fc6974..1af6dd60 100644 --- a/src/providers/reader-stream.spec.ts +++ b/src/providers/reader-stream.spec.ts @@ -2,7 +2,7 @@ import * as assert from 'assert'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import Settings from '../settings'; import * as tests from '../tests/index'; import { Entry, EntryItem } from '../types/entries'; @@ -37,7 +37,7 @@ class ReaderStreamFakeThrowErrno extends ReaderStreamFake { /** * Wrapper for easily testing Stream API. */ -const getEntries = (settings: Settings, task: ITask, api: typeof ReaderStreamFake): Promise => { +const getEntries = (settings: Settings, task: Task, api: typeof ReaderStreamFake): Promise => { return new Promise((resolve, reject) => { const entries: EntryItem[] = []; @@ -51,7 +51,7 @@ const getEntries = (settings: Settings, task: ITask, api: typeof ReaderStreamFak }); }; -function getTask(dynamic: boolean = true): ITask { +function getTask(dynamic: boolean = true): Task { return { dynamic, base: 'fixtures', diff --git a/src/providers/reader-stream.ts b/src/providers/reader-stream.ts index d2ef9f4a..a9a016f5 100644 --- a/src/providers/reader-stream.ts +++ b/src/providers/reader-stream.ts @@ -3,7 +3,7 @@ import * as stream from 'stream'; import * as readdir from '@mrmlnc/readdir-enhanced'; import FileSystemStream from '../adapters/fs-stream'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import { Entry } from '../types/entries'; import Reader from './reader'; @@ -28,7 +28,7 @@ export default class ReaderStream extends Reader { /** * Use stream API to read entries for Task. */ - public read(task: ITask): NodeJS.ReadableStream { + public read(task: Task): NodeJS.ReadableStream { const root = this.getRootDirectory(task); const options = this.getReaderOptions(task); const transform = new TransformStream(this); @@ -43,7 +43,7 @@ export default class ReaderStream extends Reader { /** * Returns founded paths. */ - public api(root: string, task: ITask, options: readdir.Options): NodeJS.ReadableStream { + public api(root: string, task: Task, options: readdir.Options): NodeJS.ReadableStream { if (task.dynamic) { return this.dynamicApi(root, options); } @@ -61,7 +61,7 @@ export default class ReaderStream extends Reader { /** * Api for static tasks. */ - public staticApi(task: ITask, options: readdir.Options): NodeJS.ReadableStream { + public staticApi(task: Task, options: readdir.Options): NodeJS.ReadableStream { return this.fsAdapter.read(task.patterns, options.filter as readdir.FilterFunction); } } diff --git a/src/providers/reader-sync.spec.ts b/src/providers/reader-sync.spec.ts index 6160b6c7..caacc398 100644 --- a/src/providers/reader-sync.spec.ts +++ b/src/providers/reader-sync.spec.ts @@ -1,6 +1,6 @@ import * as assert from 'assert'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import Settings, { TransformFunction } from '../settings'; import * as tests from '../tests/index'; import { Entry } from '../types/entries'; @@ -28,7 +28,7 @@ class ReaderSyncFakeThrowErrno extends ReaderSyncFake { } } -function getTask(dynamic: boolean = true): ITask { +function getTask(dynamic: boolean = true): Task { return { dynamic, base: 'fixtures', diff --git a/src/providers/reader-sync.ts b/src/providers/reader-sync.ts index 9ebd8dfd..5589637a 100644 --- a/src/providers/reader-sync.ts +++ b/src/providers/reader-sync.ts @@ -1,7 +1,7 @@ import * as readdir from '@mrmlnc/readdir-enhanced'; import FileSystemSync from '../adapters/fs-sync'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import { Entry, EntryItem } from '../types/entries'; import Reader from './reader'; @@ -16,7 +16,7 @@ export default class ReaderSync extends Reader { /** * Use sync API to read entries for Task. */ - public read(task: ITask): EntryItem[] { + public read(task: Task): EntryItem[] { const root = this.getRootDirectory(task); const options = this.getReaderOptions(task); @@ -36,7 +36,7 @@ export default class ReaderSync extends Reader { /** * Returns founded paths. */ - public api(root: string, task: ITask, options: readdir.Options): Entry[] { + public api(root: string, task: Task, options: readdir.Options): Entry[] { if (task.dynamic) { return this.dynamicApi(root, options); } @@ -54,7 +54,7 @@ export default class ReaderSync extends Reader { /** * Api for static tasks. */ - public staticApi(task: ITask, options: readdir.Options): Entry[] { + public staticApi(task: Task, options: readdir.Options): Entry[] { return this.fsAdapter.read(task.patterns, options.filter as readdir.FilterFunction); } } diff --git a/src/providers/reader.spec.ts b/src/providers/reader.spec.ts index 39b2d234..d3aec4f3 100644 --- a/src/providers/reader.spec.ts +++ b/src/providers/reader.spec.ts @@ -1,14 +1,14 @@ import * as assert from 'assert'; import * as path from 'path'; -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import Settings, { Options } from '../settings'; import * as tests from '../tests'; import * as pathUtil from '../utils/path'; import Reader from './reader'; export class TestReader extends Reader> { - public read(_task: ITask): Array<{}> { + public read(_task: Task): Array<{}> { return []; } } @@ -34,7 +34,7 @@ describe('Providers → Reader', () => { const expected = process.cwd(); - const actual = reader.getRootDirectory({ base: '.' } as ITask); + const actual = reader.getRootDirectory({ base: '.' } as Task); assert.strictEqual(actual, expected); }); @@ -44,7 +44,7 @@ describe('Providers → Reader', () => { const expected = path.join(process.cwd(), 'fixtures'); - const actual = reader.getRootDirectory({ base: 'fixtures' } as ITask); + const actual = reader.getRootDirectory({ base: 'fixtures' } as Task); assert.strictEqual(actual, expected); }); diff --git a/src/providers/reader.ts b/src/providers/reader.ts index fa770d4f..12275045 100644 --- a/src/providers/reader.ts +++ b/src/providers/reader.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import { Options as IReaddirOptions } from '@mrmlnc/readdir-enhanced'; import micromatch = require('micromatch'); -import { ITask } from '../managers/tasks'; +import { Task } from '../managers/tasks'; import Settings from '../settings'; import { Entry, EntryItem } from '../types/entries'; import * as pathUtil from '../utils/path'; @@ -26,19 +26,19 @@ export default abstract class Reader { /** * The main logic of reading the directories that must be implemented by each providers. */ - public abstract read(_task: ITask): T; + public abstract read(_task: Task): T; /** * Returns root path to scanner. */ - public getRootDirectory(task: ITask): string { + public getRootDirectory(task: Task): string { return path.resolve(this.settings.cwd, task.base); } /** * Returns options for reader. */ - public getReaderOptions(task: ITask): IReaddirOptions { + public getReaderOptions(task: Task): IReaddirOptions { return { basePath: task.base === '.' ? '' : task.base, filter: this.entryFilter.getFilter(task.positive, task.negative), diff --git a/src/tests/index.ts b/src/tests/index.ts index 96dd8ddf..786be20c 100644 --- a/src/tests/index.ts +++ b/src/tests/index.ts @@ -26,7 +26,7 @@ export class EnoentErrnoException extends Error { } } -interface IFakeFsStatOptions { +interface FakeFsStatOptions { isFile: boolean; isDirectory: boolean; isSymbolicLink: boolean; @@ -37,7 +37,7 @@ class FakeEntry extends fs.Stats { public path: string = this._options.path || 'fixtures/entry'; public depth: number = this.path.split('/').length - 2; - constructor(private readonly _options: Partial = {}) { + constructor(private readonly _options: Partial = {}) { super(); } @@ -54,11 +54,11 @@ class FakeEntry extends fs.Stats { } } -export function getEntry(options: Partial = {}): Entry { +export function getEntry(options: Partial = {}): Entry { return new FakeEntry(options); } -export function getFileEntry(options: Partial = {}): Entry { +export function getFileEntry(options: Partial = {}): Entry { return new FakeEntry({ isFile: true, path: 'fixtures/file.txt', @@ -66,7 +66,7 @@ export function getFileEntry(options: Partial = {}): Entry { }); } -export function getDirectoryEntry(options: Partial = {}): Entry { +export function getDirectoryEntry(options: Partial = {}): Entry { return new FakeEntry({ isDirectory: true, path: 'fixtures/directory', diff --git a/src/tests/smoke/smoke.ts b/src/tests/smoke/smoke.ts index 1d8d7b45..0a30fd75 100644 --- a/src/tests/smoke/smoke.ts +++ b/src/tests/smoke/smoke.ts @@ -7,7 +7,7 @@ import * as fg from '../../index'; import { Options } from '../../settings'; import { Pattern } from '../../types/patterns'; -export interface ISmokeTest { +export interface SmokeTest { pattern: Pattern; ignore?: Pattern; cwd?: string; @@ -35,7 +35,7 @@ type DebugCompareTestMarker = '+' | '-'; /** * Runs the passed test suite. */ -export function suite(name: string, tests: Array): void { +export function suite(name: string, tests: Array): void { const testCases = getTestCases(tests); describe(name, () => { @@ -51,14 +51,14 @@ export function suite(name: string, tests: Array): vo /** * Return flatten list of test cases. */ -function getTestCases(tests: Array): ISmokeTest[] { - return ([] as ISmokeTest[]).concat(...tests); +function getTestCases(tests: Array): SmokeTest[] { + return ([] as SmokeTest[]).concat(...tests); } /** * Return title for one of test cases. */ -function getTestCaseTitle(test: ISmokeTest): string { +function getTestCaseTitle(test: SmokeTest): string { let title = `pattern: '${test.pattern}'`; if (test.ignore) { @@ -77,14 +77,14 @@ function getTestCaseTitle(test: ISmokeTest): string { /** * Return test case definition for run. */ -function getTestCaseMochaDefinition(test: ISmokeTest): MochaDefinition { +function getTestCaseMochaDefinition(test: SmokeTest): MochaDefinition { return test.debug ? it.only : it; } /** * Runs one of the passed test cases. */ -function testCaseRunner(test: ISmokeTest): void { +function testCaseRunner(test: SmokeTest): void { const expected = getNodeGlobEntries(test.pattern, test.ignore, test.cwd, test.globOptions); const actual = getFastGlobEntries(test.pattern, test.ignore, test.cwd, test.fgOptions); diff --git a/src/types/entries.ts b/src/types/entries.ts index 3cf453f2..d25af544 100644 --- a/src/types/entries.ts +++ b/src/types/entries.ts @@ -1,10 +1,9 @@ import * as fs from 'fs'; // Must be synchronized with readdir-enhanced -export interface IEntry extends fs.Stats { +export interface Entry extends fs.Stats { path: string; depth: number; } -export type EntryItem = string | IEntry; -export type Entry = IEntry; +export type EntryItem = string | Entry; diff --git a/tslint.json b/tslint.json index cc2fdafc..a07a9e65 100644 --- a/tslint.json +++ b/tslint.json @@ -1,8 +1,5 @@ { "extends": [ "tslint-config-mrmlnc" - ], - "rules": { - "interface-name": false - } + ] }