1
0
Fork 0

lint: replace negated nil checks with positive assertion

This commit is contained in:
ssube 2019-11-17 16:22:24 -06:00 committed by Sean Sube
parent 8c1c45dfeb
commit 197b6119a8
3 changed files with 9 additions and 8 deletions

View File

@ -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<string>): 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;

View File

@ -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);
}
}

View File

@ -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<string>, 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<string>, ctx: VisitorContex
continue;
}
if (!isNil(module.definitions)) {
if (doesExist(module.definitions)) {
ctx.addSchema(module.name, module.definitions);
}