diff --git a/src/config/index.ts b/src/config/index.ts index 48ab138..a33518b 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,11 +1,12 @@ import { Stream } from 'bunyan'; -import { isNil, isString } from 'lodash'; +import { isString } from 'lodash'; import { LogLevel } from 'noicejs'; import { join } from 'path'; import { NotFoundError } from '../error/NotFoundError'; import { YamlParser } from '../parser/YamlParser'; import { readFile } from '../source'; +import { doesExist } from '../utils'; import { CONFIG_ENV, CONFIG_SCHEMA } from './schema'; import { includeSchema } from './type/Include'; @@ -56,7 +57,7 @@ export async function loadConfig(name: string, ...extras: Array): Promis for (const p of paths) { const data = await readConfig(p); - if (!isNil(data)) { + if (doesExist(data)) { const parser = new YamlParser(); const [head] = parser.parse(data); return head; diff --git a/src/rule/SchemaRule.ts b/src/rule/SchemaRule.ts index 75d01b4..8ae5249 100644 --- a/src/rule/SchemaRule.ts +++ b/src/rule/SchemaRule.ts @@ -3,7 +3,7 @@ import { cloneDeep, defaultTo, isNil } from 'lodash'; import { LogLevel } from 'noicejs'; import { Rule, RuleData } from '.'; -import { hasItems } from '../utils'; +import { doesExist, hasItems } from '../utils'; import { Visitor, VisitorError, VisitorResult } from '../visitor'; import { VisitorContext } from '../visitor/VisitorContext'; @@ -29,7 +29,7 @@ export class SchemaRule implements Rule, RuleData, Visitor { // copy schema objects this.check = cloneDeep(data.check); - if (!isNil(data.filter)) { + if (doesExist(data.filter)) { this.filter = cloneDeep(data.filter); } } diff --git a/src/rule/index.ts b/src/rule/index.ts index 8c61952..51b5b13 100644 --- a/src/rule/index.ts +++ b/src/rule/index.ts @@ -1,5 +1,5 @@ import { ValidateFunction } from 'ajv'; -import { Dictionary, intersection, isNil } from 'lodash'; +import { Dictionary, intersection } from 'lodash'; import { Minimatch } from 'minimatch'; import { LogLevel } from 'noicejs'; import recursive from 'recursive-readdir'; @@ -7,7 +7,7 @@ import recursive from 'recursive-readdir'; import ruleSchemaData from '../../rules/salty-dog.yml'; import { YamlParser } from '../parser/YamlParser'; import { readFile } from '../source'; -import { ensureArray } from '../utils'; +import { doesExist, ensureArray } from '../utils'; import { VisitorResult } from '../visitor'; import { VisitorContext } from '../visitor/VisitorContext'; import { SchemaRule } from './SchemaRule'; @@ -116,7 +116,7 @@ export async function loadRuleFiles(paths: Array, ctx: VisitorContext): continue; } - if (!isNil(data.definitions)) { + if (doesExist(data.definitions)) { ctx.addSchema(data.name, data.definitions); } @@ -163,7 +163,7 @@ export async function loadRuleModules(modules: Array, ctx: VisitorContex continue; } - if (!isNil(module.definitions)) { + if (doesExist(module.definitions)) { ctx.addSchema(module.name, module.definitions); }