Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Expose CLI functionality as a separate class #1675

Closed
JoshuaKGoldberg opened this issue Nov 3, 2016 · 3 comments
Closed

Expose CLI functionality as a separate class #1675

JoshuaKGoldberg opened this issue Nov 3, 2016 · 3 comments

Comments

@JoshuaKGoldberg
Copy link
Contributor

Context: I'm working on autotslint, a CLI tool to take in TSLint failures and, when possible, fix them in the files.

Ask: Can the existing logic in tslint-cli.ts be exposed publicly as a usable class and documented in the readme? Ideally we should be able to do something like the following:

Autotslint will need to be able to generate "waves" of TSLint failures: given the standard configurations that can be given via tslint-cli, it should generate failures for rules. It's possible to do this using the existing require("tslint") linter and some work, but would be much simpler if the existing CLI logic could be re-used.

import {LintCli} from "tslint/lib/lintCli");

const options = {
    exclude: "**/*.d.ts",
    rules: {
        "variable-name": true,
        "quotemark": [true, "double"]
    }
};

const linter = new LintCli(options);

const result = linter.processFiles(["**/*.ts"]/*, ts.createProgram(...) */);

The CLI class would just be a refactor of tslint-cli.ts, not a change in any existing behavior. That being said, it would be nice to switch the options to have shorthand as aliases so the interface could use strings like "config" instead of "c".

@adidahiya
Copy link
Contributor

Hey, I don't know if you noticed this (there are no docs...) but we have started implementing auto-fixing in tslint itself. This is on the master branch and in the 4.0.0-dev.* releases. See #1423, #1574

@JoshuaKGoldberg
Copy link
Contributor Author

D:

@JoshuaKGoldberg
Copy link
Contributor Author

Still - can this issue remain open? It could be useful to call the CLI programmatically.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants