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

feat(configuration): set js rules to all valid active rules #3641

Conversation

mlavina
Copy link
Contributor

@mlavina mlavina commented Jan 10, 2018

jsRules can now be a boolean. If it is set to true then parseConfig file, will copy over all active rules that can be applied to js to the jsRules configuration.

PR checklist

Overview of change:

I added comments to the files changed

Is there anything you'd like reviewers to focus on?

CHANGELOG.md entry:

@palantirtech
Copy link
Member

Thanks for your interest in palantir/tslint, @mlavina! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

const ruleOptions = parseRuleOptions(config[ruleName], defaultSeverity);
if (copyRulestoJsRules && ruleOptions.ruleSeverity !== "off") {
const Rule = findRule(ruleName, rulesDirectory);
if (Rule === undefined || (Rule.metadata && Rule.metadata.typescriptOnly)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a nicer way to find if a rule is typescript only? Because for this i need to pass in rulesDirectory which makes the parent parse function a bit less clean

@mlavina mlavina force-pushed the feat/configuration/setJsRulesToAllValidActiveRules branch 3 times, most recently from 6dfc904 to b0a4364 Compare January 11, 2018 00:07
@mlavina
Copy link
Contributor Author

mlavina commented Jan 18, 2018

CLA has been signed.

@@ -29,7 +29,7 @@ A path to a directory or an array of paths to directories of [custom rules][2].
- A boolean value may be specified instead of the above object, and is equivalent to setting no options with default severity.
- Any rules specified in this block will override those configured in any base configuration being extended.
- [Check out the full rules list here][3].
* `jsRules?: any`: Same format as `rules`. These rules are applied to `.js` and `.jsx` files.
* `jsRules?: any | boolean`: Same format as `rules` or you can set to true to copy over all valid active rules from `rules`. These rules are applied to `.js` and `.jsx` files.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Same format as rules or explicit true to copy all valid active rules from rules."

function parseRules(config: RawRulesConfig | undefined): Map<string, Partial<IOptions>> {
function parseRules(config: RawRulesConfig | undefined,
copyRulestoJsRules = false,
rulesDirectory?: string | string[]): Map<string, Partial<IOptions>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move copyRulesToJsRules feature to a separate function, rather than co-opting this existing method into doing multiple things.

@mlavina mlavina force-pushed the feat/configuration/setJsRulesToAllValidActiveRules branch from b0a4364 to 45a6868 Compare May 8, 2018 19:19
@mlavina
Copy link
Contributor Author

mlavina commented May 8, 2018

@giladgray Good call on separating the function. It is done tell me what you think?

@mlavina mlavina force-pushed the feat/configuration/setJsRulesToAllValidActiveRules branch from 45a6868 to 3f6a3df Compare May 8, 2018 19:21
jsRules can now be a boolean. If it is set to true then parseConfig file, will copy over all active rules that can be applied to js to the jsRules configuration.
@mlavina mlavina force-pushed the feat/configuration/setJsRulesToAllValidActiveRules branch from 3f6a3df to 306e0c8 Compare June 13, 2018 18:42
@mlavina
Copy link
Contributor Author

mlavina commented Jun 13, 2018

i rebased to the latest branch hopefully, that solves the ci:next failing.

@astorije @giladgray Are you okay with the requested changes i made?

@mlavina
Copy link
Contributor Author

mlavina commented Jul 12, 2018

@giladgray sorry to be annoying but just checking in if you had a chance to look at the changes I made per your request. And if there is anything else i can do to get this merged in.

@wilg
Copy link

wilg commented Aug 20, 2018

I'll be "that guy" and ping this again. Looks like there's a bunch of people (myself included) looking for this feature and it seems to be ready to go. @giladgray are you the one to sign off or is there someone else that should look at this?

Copy link
Contributor

@johnwiseheart johnwiseheart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for contributing

@johnwiseheart johnwiseheart merged commit 360bdd0 into palantir:master Aug 20, 2018
@mlavina mlavina deleted the feat/configuration/setJsRulesToAllValidActiveRules branch August 21, 2018 15:38
@maxmilton
Copy link

Any plans for an actual release? I've been waiting in anticipation for this feature for a while now!

wiese added a commit to wmde/wikibase-termbox that referenced this pull request Nov 20, 2018
Let tslint check our JS (configuration) files in the project root, too.
With the release of palantir/tslint#3641 (I
subscribed) the manual [prototypical] re-specification of `jsRules` will
hopefully be obsolte soon.
@kevinmarrec
Copy link

kevinmarrec commented Dec 8, 2018

Looking forward to this next release too, but @mlavina, I might be wrong but assuming how the code is implemented, it will not take into account rules extended from extend configuration option right ?

@Hotell
Copy link

Hotell commented Dec 13, 2018

when can we except new release with this functionality ?

@mlavina
Copy link
Contributor Author

mlavina commented Dec 13, 2018

@kevinmarrec I think that depends on how extends works internally. If extends actual tracks the rules internally this should work with extends. I feel like that is something I would have tested, but to be honest it's been a while since I wrote this

thiagestrela added a commit to pedroteosousa/dena that referenced this pull request May 23, 2019
We can define jsRules as a boolean true, so all the rules defined in key "rules" that are compatible with js will be copied to here.
If you want to know more about this feature: palantir/tslint#3641.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants