Skip to content

Commit

Permalink
Merge pull request #56 from krzkaczor/kk/config-path-fix
Browse files Browse the repository at this point in the history
Make configFile relative to project root
  • Loading branch information
angelozerr authored Jan 9, 2018
2 parents 8d11a58 + 948c257 commit 6b9dbf7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Your `node_modules` folder should look like this:

**Notice** this configuration settings allow you to configure the behaviour of the tslint-language-service plugin. To configure rules and tslint options you should use the `tslint.json` file.

* `configFile` - the configuration file that tslint should use instead of the default tslint.json.
* `configFile` - the configuration file that tslint should use instead of the default tslint.json. A relative file path is resolved relative to the project root.
* `ignoreDefinitionFiles` - control if TypeScript definition files should be ignored.
* `alwaysShowRuleFailuresAsWarnings` - always show rule failures as warnings, ignoring the severity configuration in the tslint.json configuration.
* `disableNoUnusedVariableRule` - disable `no-unused-variable` rule.
Expand Down
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ function init(modules: { typescript: typeof ts_module }) {
});
}

function create(info: ts.server.PluginCreateInfo) {
function fixRelativeConfigFilePath(config: Settings, projectRoot: string): Settings {
if (!config.configFile) {
return config;
}
if (path.isAbsolute(config.configFile)) {
return config;
}
config.configFile = path.join(projectRoot, config.configFile);
return config;
}

function create(info: ts.server.PluginCreateInfo) {
info.project.projectService.logger.info("tslint-language-service loaded");
let config: Settings = info.config;
let config: Settings = fixRelativeConfigFilePath(info.config, info.project.getCurrentDirectory());
let configuration: tslint.Configuration.IConfigurationFile = null;

// Set up decorator
Expand Down

0 comments on commit 6b9dbf7

Please sign in to comment.