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

Feature Request: use node module resolution semantics for rulesDirectory #2163

Closed
donaldpipowitch opened this issue Feb 1, 2017 · 5 comments · Fixed by singapore/lint-condo#282

Comments

@donaldpipowitch
Copy link
Contributor

extends uses node module resolution semantics to find files and you can specify relative paths to files, too. I'd need the same behaviour for rulesDirectory. E.g. I want to use tslint-react/rules which is sometimes in ./node_modules/tslint-react/rules and sometimes in ../node_modules/tslint-react/rules in my case. (I build a generic build tool configuration similar to create-react-app, so I don't always have full control about the projects where my configuration is used..)

@donaldpipowitch
Copy link
Contributor Author

With this pull request we can now write something like:

{
  "rulesDirectory": [
    "tslint-eslint-rules/dist/rules"
  ]
}

Instead of

{
  "rulesDirectory": [
    "./node_modules/tslint-eslint-rules/dist/rules"
  ]
}

or

{
  "rulesDirectory": [
    "../node_modules/tslint-eslint-rules/dist/rules"
  ]
}

This is very useful for tools which offer a tslint.json and are installed as a dependency of other projects (like this one), because you never really know where your exact dependency will be installed (because sometimes you install your package normally, sometimes it is symlinked, and so on).

@adidahiya
Copy link
Contributor

@donaldpipowitch makes sense, that is a good motivation for making this change

donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 1, 2017
make changes based on review
donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 1, 2017
make changes based on review
donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 1, 2017
# This is the 1st commit message:

fixes palantir#2163

make changes based on review

# This is the commit message palantir#2:

Fix variableNameRule compiler error
donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 1, 2017
donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 1, 2017
donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 10, 2017
donaldpipowitch pushed a commit to donaldpipowitch/tslint that referenced this issue Apr 10, 2017
@adidahiya adidahiya added this to the TSLint v5.2 milestone Apr 11, 2017
@adidahiya
Copy link
Contributor

Your PR #2358 seems fine as an enhancement, but I just realized that custom rule packages really ought to configure rulesDirectory themselves so that users don't have to worry about specifying the directory -- instead, you just can just rely on "extends" composition semantics. tslint-react.json does this.

@donaldpipowitch
Copy link
Contributor Author

You're right. This would work, too. But then I maybe need to overwrite the default settings.

@donaldpipowitch
Copy link
Contributor Author

donaldpipowitch commented Apr 25, 2017

From buzinas/tslint-eslint-rules#214 (comment) I think the difference is this:

  • extends: Allows me to use custom rules from other packages. I get all rules with default configs and can opt-out from rules. If new rules are added in a new version I get them automatically.
  • rulesDirectory : Allows me to use custom rules from other packages. I opt-in to use certain rules with my specific configs. If new rules are added in a new version I don't get them automatically.

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.

2 participants