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:
parent
761c64851c
commit
4eec0dda70
10
src/app.ts
10
src/app.ts
|
@ -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);
|
||||||
|
|
|
@ -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';
|
||||||
|
|
Loading…
Reference in New Issue