Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint.Configuration.parseConfigFile Does Not Resolve "extends" #79

Open
taicho opened this issue Jun 1, 2017 · 3 comments
Open

Lint.Configuration.parseConfigFile Does Not Resolve "extends" #79

taicho opened this issue Jun 1, 2017 · 3 comments

Comments

@taicho
Copy link

taicho commented Jun 1, 2017

All,

After struggling to understand to understand why tslint-loader would not honor the "extends" directive in my tslint.config it appears that I've been able to isolate the cause.

index.js

function parseConfigFile(webpackInstance, configFile, options) {
  if (!options.configuration) {
    return Lint.Linter.findConfiguration(configFile, webpackInstance.resourcePath).results;
  }

  if (semver.satisfies(Lint.Linter.VERSION, '>=5.0.0')) {      
    Lint.Configuration.parseConfigFile(options.configuration);
  }

  return options.configuration;
}

My version of tslint is 5.4.0 and I am using a tslint.json located at my root which looks like this:

{
  "extends": [
    "tslint:recommended"
  ],
  "rules": {    
  }
}

Therefore the code will use Lint.Configuration.parseConfigFile to parse the config file. The problem is that in tslint (at least in 5.4.0) parseConfigFile does not traverse and resolve any of the rules provided via the "extends" option. I was able to fix this by using Lint.Configuration.loadConfigurationFromPath; the changed code looks like this:

function parseConfigFile(webpackInstance, configFile, options) {
  if (!options.configuration) {
    return Lint.Linter.findConfiguration(configFile, webpackInstance.resourcePath).results;
  }

  if (semver.satisfies(Lint.Linter.VERSION, '>=5.0.0')) {      
    return Lint.Configuration.loadConfigurationFromPath(configFile,configFile);
  }

  return options.configuration;
}

Using the above fix everything appears to work properly. Also worth mentioning is that in the tslint codebase parseConfigFile is only use internally by loadConfigurationFromPath...

Three questions:

  1. Has nobody else run into this issue??
  2. Am I completely doing something wrong or crazy...?
  3. If not, should I do a pull request...?
@moneydance
Copy link

From what I can gather by looking through the repo, don't provide a configuration property in the options for the loader. If you're using a tslint.json I don't think you need that property as you can specify new rules in the tslint.json. If you ommit the configuration property Lint.Linter.findConfiguration will be called which in turn calls loadConfigurationFromPath.

https://github.com/palantir/tslint/blob/master/src/configuration.ts#L93

@moneydance
Copy link

I'll try it when i get home. I was having a similar issue, but was trying to call extends from webpack options configuration property. Which from the look of things is unsupported.

@RehanSaeed
Copy link

I had TS-Lint working a few weeks ago. At some point my project lost the ability to produce TS-Lint warnings, possibly due to a package upgrade. Is there a specific version of tslint that I can use to get linting working again. It looks like the PR to fix this issue has been around for some time.

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

No branches or pull requests

3 participants