UNPKG

ffbt

Version:

Build a Typescript app without pain

70 lines (69 loc) 2.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const base_command_1 = require("../base-command"); const command_1 = require("@oclif/command"); const runner_1 = require("../../services/tslint/runner"); const config_1 = require("../../services/tslint/config"); const config_2 = require("../../services/stylelint/config"); const runner_2 = require("../../services/stylelint/runner"); var ArgumentsKeys; (function (ArgumentsKeys) { ArgumentsKeys["sourcesDirectory"] = "sources_directory"; ArgumentsKeys["linterType"] = "linter_type"; })(ArgumentsKeys || (ArgumentsKeys = {})); var LinterType; (function (LinterType) { LinterType["ts"] = "ts"; LinterType["style"] = "style"; })(LinterType || (LinterType = {})); class LintCommand extends base_command_1.BaseCommand { run() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { linter_type } = this.getArguments(); this.getRunner(linter_type).run(); }); } getRunner(type) { const { sources_directory } = this.getArguments(); const flags = this.getFlags(); if (type === LinterType.ts) { const tsLintRunnerConfig = config_1.createTsLintConfig(Object.assign(Object.assign({}, flags), { path: sources_directory })); if (flags.verbose) { console.log("TsLint Parameters", tsLintRunnerConfig, "\n"); } return new runner_1.TsLintRunner(tsLintRunnerConfig); } if (type === LinterType.style) { const styleLintRunnerConfig = config_2.createStyleLintConfig(Object.assign(Object.assign({}, flags), { path: sources_directory })); if (flags.verbose) { console.log("StyleLint Parameters", styleLintRunnerConfig, "\n"); } return new runner_2.StyleLintRunner(styleLintRunnerConfig, flags.force); } throw new Error(`Lint runner for '${type}' is not implemented yet`); } } exports.default = LintCommand; LintCommand.description = "lint source code"; LintCommand.args = [ { name: ArgumentsKeys.linterType, description: "type of the linter", options: [LinterType.ts, LinterType.style], required: true, }, { name: ArgumentsKeys.sourcesDirectory, description: "directory with sources of the application", required: true, } ]; LintCommand.flags = Object.assign(Object.assign({}, base_command_1.BaseCommand.flags), { fix: command_1.flags.boolean({ default: false, description: "fixes linting errors" }), force: command_1.flags.boolean({ char: "f", default: false, description: "return status code 0 even if there are lint errors" }) });