1
0
Fork 0

lint: remove valid-mode check in main

Mode is collected from a positional by yargs, but assigned from
callbacks, so it cannot leave the enum's valid range.
This commit is contained in:
ssube 2019-11-14 06:02:55 -06:00 committed by Sean Sube
parent 761c64851c
commit 4eec0dda70
2 changed files with 3 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import { createLogger } from 'bunyan';
import { showCompletionScript } from 'yargs'; import { showCompletionScript } from 'yargs';
import { loadConfig } from './config'; import { loadConfig } from './config';
import { CONFIG_ARGS_NAME, CONFIG_ARGS_PATH, MODE, parseArgs, VALID_MODES } from './config/args'; import { CONFIG_ARGS_NAME, CONFIG_ARGS_PATH, MODE, parseArgs } from './config/args';
import { YamlParser } from './parser/YamlParser'; import { YamlParser } from './parser/YamlParser';
import { createRuleSelector, createRuleSources, loadRules, resolveRules, visitRules } from './rule'; import { createRuleSelector, createRuleSources, loadRules, resolveRules, visitRules } from './rule';
import { readSource, writeSource } from './source'; import { readSource, writeSource } from './source';
@ -26,12 +26,7 @@ export async function main(argv: Array<string>): Promise<number> {
logger.info(VERSION_INFO, 'version info'); logger.info(VERSION_INFO, 'version info');
logger.info({ args, mode }, 'main arguments'); logger.info({ args, mode }, 'main arguments');
// check mode // load rules
if (!VALID_MODES.has(mode)) {
logger.error({ mode }, 'unsupported mode');
return STATUS_ERROR;
}
const ctx = new VisitorContext({ const ctx = new VisitorContext({
logger, logger,
schemaOptions: { schemaOptions: {
@ -59,6 +54,7 @@ export async function main(argv: Array<string>): Promise<number> {
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
// load source
const parser = new YamlParser(); const parser = new YamlParser();
const source = await readSource(args.source); const source = await readSource(args.source);
const docs = parser.parse(source); const docs = parser.parse(source);

View File

@ -10,8 +10,6 @@ export enum MODE {
list = 'list', list = 'list',
} }
export const VALID_MODES = new Set([MODE.check, MODE.fix, MODE.list]);
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
export const CONFIG_ARGS_NAME = 'config-name'; export const CONFIG_ARGS_NAME = 'config-name';