lint: remove confusing *sync wrapper names
This commit is contained in:
parent
b3dc864f0d
commit
4159004dd4
|
@ -84,8 +84,8 @@ const bundle = {
|
||||||
'node_modules/noicejs/out/main-bundle.js': [
|
'node_modules/noicejs/out/main-bundle.js': [
|
||||||
'BaseError',
|
'BaseError',
|
||||||
'ConsoleLogger',
|
'ConsoleLogger',
|
||||||
'logWithLevel',
|
|
||||||
'NullLogger',
|
'NullLogger',
|
||||||
|
'logWithLevel',
|
||||||
],
|
],
|
||||||
'node_modules/js-yaml/index.js': [
|
'node_modules/js-yaml/index.js': [
|
||||||
'DEFAULT_SAFE_SCHEMA',
|
'DEFAULT_SAFE_SCHEMA',
|
||||||
|
|
|
@ -5,7 +5,7 @@ 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 { readFileSync } from '../source';
|
import { readFile } from '../source';
|
||||||
import { CONFIG_ENV, CONFIG_SCHEMA } from './schema';
|
import { CONFIG_ENV, CONFIG_SCHEMA } from './schema';
|
||||||
import { includeSchema } from './type/Include';
|
import { includeSchema } from './type/Include';
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ export async function readConfig(path: string): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
// need to await this read to catch the error, need to catch the error to check the code
|
// need to await this read to catch the error, need to catch the error to check the code
|
||||||
// tslint:disable-next-line:prefer-immediate-return
|
// tslint:disable-next-line:prefer-immediate-return
|
||||||
const data = await readFileSync(path, {
|
const data = await readFile(path, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -67,7 +67,7 @@ export class SchemaRule implements RuleData, Visitor<RuleResult> {
|
||||||
|
|
||||||
if (filter(node)) {
|
if (filter(node)) {
|
||||||
ctx.logger.debug({ item: node }, 'checking item');
|
ctx.logger.debug({ item: node }, 'checking item');
|
||||||
if (!check(node) && !isNil(check.errors) && check.errors.length > 0) {
|
if (!check(node) && hasItems(check.errors)) {
|
||||||
ctx.error(...Array.from(check.errors).map(friendlyError));
|
ctx.error(...Array.from(check.errors).map(friendlyError));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Dictionary, intersection, isNil } from 'lodash';
|
||||||
import { LogLevel } from 'noicejs';
|
import { LogLevel } from 'noicejs';
|
||||||
|
|
||||||
import { YamlParser } from '../parser/YamlParser';
|
import { YamlParser } from '../parser/YamlParser';
|
||||||
import { readFileSync } from '../source';
|
import { readFile } from '../source';
|
||||||
import { ensureArray } from '../utils';
|
import { ensureArray } from '../utils';
|
||||||
import { VisitorContext } from '../visitor/VisitorContext';
|
import { VisitorContext } from '../visitor/VisitorContext';
|
||||||
import { SchemaRule } from './SchemaRule';
|
import { SchemaRule } from './SchemaRule';
|
||||||
|
@ -52,7 +52,7 @@ export async function loadRules(paths: Array<string>, ctx: VisitorContext): Prom
|
||||||
const rules = [];
|
const rules = [];
|
||||||
|
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
const contents = await readFileSync(path, {
|
const contents = await readFile(path, {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { readFile, writeFile } from 'fs';
|
import { readFile as readBack, writeFile as writeBack } from 'fs';
|
||||||
import { isNil } from 'lodash';
|
import { isNil } from 'lodash';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
export const FILE_ENCODING = 'utf-8';
|
export const FILE_ENCODING = 'utf-8';
|
||||||
export const readFileSync = promisify(readFile);
|
export const readFile = promisify(readBack);
|
||||||
export const writeFileSync = promisify(writeFile);
|
export const writeFile = promisify(writeBack);
|
||||||
|
|
||||||
export async function loadSource(path: string): Promise<string> {
|
export async function loadSource(path: string): Promise<string> {
|
||||||
if (path === '-') {
|
if (path === '-') {
|
||||||
return readFileSync(0, {
|
return readFile(0, {
|
||||||
encoding: FILE_ENCODING,
|
encoding: FILE_ENCODING,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return readFileSync(path, {
|
return readFile(path, {
|
||||||
encoding: FILE_ENCODING,
|
encoding: FILE_ENCODING,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export async function writeSource(path: string, data: string): Promise<void> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return writeFileSync(path, data, {
|
return writeFile(path, data, {
|
||||||
encoding: FILE_ENCODING,
|
encoding: FILE_ENCODING,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue