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

configurationPath option for programmatic API. #1019

Closed
jkillian opened this issue Mar 7, 2016 · 2 comments · Fixed by #1035
Closed

configurationPath option for programmatic API. #1019

jkillian opened this issue Mar 7, 2016 · 2 comments · Fixed by #1035

Comments

@jkillian
Copy link
Contributor

jkillian commented Mar 7, 2016

With more features coming to tslint.json files, such as the rulesDirectory option and the extends option, it becomes harder and harder for third-party tools that wrap TSLint to properly load configurations themselves. (See #1007 for example.)

The easiest and cleanest solution (that I can think of) for this is to change the Linter options API.

Current:

export interface ILinterOptions {
    configuration: any;
    formatter: string;
    formattersDirectory: string;
    rulesDirectory: string | string[];
}

Option 1

export interface ILinterOptions {
    configuration: ITSLintConfig | string;
    formatter: string;
    formattersDirectory: string;
    rulesDirectory: string | string[];
}

Option2

export interface ILinterOptions {
    configuration?: ITSLintConfig;
    configurationPath?: string;
    formatter: string;
    formattersDirectory: string;
    rulesDirectory: string | string[];
}

If a path to a configuration is provided (instead of passing a configuration object directly), TSLint would handle all responsibilities such as resolving rules directories, resolving extends clauses, etc. If a configuration object is passed directly, the third-party tool would have to take care of these tasks.

@unional
Copy link
Contributor

unional commented Mar 7, 2016

Currently in my PR I have the config:

export interface ConfigFile { // will rename to ITSLintConfig
    extends: string | string[];
    rulesDirectory: string | string[];
    rules: any;
}

Likely it doesn't match what you have in mind based on your snippets.
What do you envision? I can adjust the PR accordingly.

@jkillian
Copy link
Contributor Author

jkillian commented Mar 7, 2016

IConfigFile sounds good to me! In fact, your definition looks correct. The duplication of fields like rulesDirectory seems strange at first, but it's just how it has to be for historical reasons. tslint.json files used to only specify what rules to use, and when using TSLint programmatically, this data was passed as the configuration member of ILinterOptions. You could also then pass things like rulesDirectory separately.

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

Successfully merging a pull request may close this issue.

3 participants