lint: replace negated nil checks with positive assertion
This commit is contained in:
parent
8c1c45dfeb
commit
197b6119a8
|
@ -1,11 +1,12 @@
|
||||||
import { Stream } from 'bunyan';
|
import { Stream } from 'bunyan';
|
||||||
import { isNil, isString } from 'lodash';
|
import { isString } from 'lodash';
|
||||||
import { LogLevel } from 'noicejs';
|
import { LogLevel } from 'noicejs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { NotFoundError } from '../error/NotFoundError';
|
import { NotFoundError } from '../error/NotFoundError';
|
||||||
import { YamlParser } from '../parser/YamlParser';
|
import { YamlParser } from '../parser/YamlParser';
|
||||||
import { readFile } from '../source';
|
import { readFile } from '../source';
|
||||||
|
import { doesExist } from '../utils';
|
||||||
import { CONFIG_ENV, CONFIG_SCHEMA } from './schema';
|
import { CONFIG_ENV, CONFIG_SCHEMA } from './schema';
|
||||||
import { includeSchema } from './type/Include';
|
import { includeSchema } from './type/Include';
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ export async function loadConfig(name: string, ...extras: Array<string>): Promis
|
||||||
|
|
||||||
for (const p of paths) {
|
for (const p of paths) {
|
||||||
const data = await readConfig(p);
|
const data = await readConfig(p);
|
||||||
if (!isNil(data)) {
|
if (doesExist(data)) {
|
||||||
const parser = new YamlParser();
|
const parser = new YamlParser();
|
||||||
const [head] = parser.parse(data);
|
const [head] = parser.parse(data);
|
||||||
return head;
|
return head;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { cloneDeep, defaultTo, isNil } from 'lodash';
|
||||||
import { LogLevel } from 'noicejs';
|
import { LogLevel } from 'noicejs';
|
||||||
|
|
||||||
import { Rule, RuleData } from '.';
|
import { Rule, RuleData } from '.';
|
||||||
import { hasItems } from '../utils';
|
import { doesExist, hasItems } from '../utils';
|
||||||
import { Visitor, VisitorError, VisitorResult } from '../visitor';
|
import { Visitor, VisitorError, VisitorResult } from '../visitor';
|
||||||
import { VisitorContext } from '../visitor/VisitorContext';
|
import { VisitorContext } from '../visitor/VisitorContext';
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ export class SchemaRule implements Rule, RuleData, Visitor {
|
||||||
|
|
||||||
// copy schema objects
|
// copy schema objects
|
||||||
this.check = cloneDeep(data.check);
|
this.check = cloneDeep(data.check);
|
||||||
if (!isNil(data.filter)) {
|
if (doesExist(data.filter)) {
|
||||||
this.filter = cloneDeep(data.filter);
|
this.filter = cloneDeep(data.filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { ValidateFunction } from 'ajv';
|
import { ValidateFunction } from 'ajv';
|
||||||
import { Dictionary, intersection, isNil } from 'lodash';
|
import { Dictionary, intersection } from 'lodash';
|
||||||
import { Minimatch } from 'minimatch';
|
import { Minimatch } from 'minimatch';
|
||||||
import { LogLevel } from 'noicejs';
|
import { LogLevel } from 'noicejs';
|
||||||
import recursive from 'recursive-readdir';
|
import recursive from 'recursive-readdir';
|
||||||
|
@ -7,7 +7,7 @@ import recursive from 'recursive-readdir';
|
||||||
import ruleSchemaData from '../../rules/salty-dog.yml';
|
import ruleSchemaData from '../../rules/salty-dog.yml';
|
||||||
import { YamlParser } from '../parser/YamlParser';
|
import { YamlParser } from '../parser/YamlParser';
|
||||||
import { readFile } from '../source';
|
import { readFile } from '../source';
|
||||||
import { ensureArray } from '../utils';
|
import { doesExist, ensureArray } from '../utils';
|
||||||
import { VisitorResult } from '../visitor';
|
import { VisitorResult } from '../visitor';
|
||||||
import { VisitorContext } from '../visitor/VisitorContext';
|
import { VisitorContext } from '../visitor/VisitorContext';
|
||||||
import { SchemaRule } from './SchemaRule';
|
import { SchemaRule } from './SchemaRule';
|
||||||
|
@ -116,7 +116,7 @@ export async function loadRuleFiles(paths: Array<string>, ctx: VisitorContext):
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNil(data.definitions)) {
|
if (doesExist(data.definitions)) {
|
||||||
ctx.addSchema(data.name, data.definitions);
|
ctx.addSchema(data.name, data.definitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ export async function loadRuleModules(modules: Array<string>, ctx: VisitorContex
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isNil(module.definitions)) {
|
if (doesExist(module.definitions)) {
|
||||||
ctx.addSchema(module.name, module.definitions);
|
ctx.addSchema(module.name, module.definitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue