Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Used inquirer to prompt for properties when creating a new rule. #679

Merged
merged 4 commits into from
Dec 18, 2018
Merged

Used inquirer to prompt for properties when creating a new rule. #679

merged 4 commits into from
Dec 18, 2018

Conversation

reduckted
Copy link
Contributor

PR checklist

Overview of change:

As per #258, I've used Inquirer.js to prompt for the rule's metadata.

All metadata except for the options (and related properties) and commonWeaknessEnumeration can be specified. I figured it wasn't worth doing anything with CWE because of #611.

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

The existing generator didn't actually work, because it tried to add the new rule to the root tslint.json file, but that file contains comments and cannot be parsed as JSON. For now, I've removed that step, but I kinda think it's something that should still be done. I'm just not sure how to go about doing it. 😕 Any suggestions are welcome.

I've also tried to be nice and open the new rule's files after they've been created. I can detect that the generator is running in the VS Code terminal by looking at the environment variables and just launch code new_file_name.ts to open the file in the current VS Code instance. It works for me on Windows. In theory it should work on other operating systems, but I haven't confirmed that. I'm happy to remove this feature if you don't think it's worth the trouble.

Copy link
Contributor

@IllusionMH IllusionMH left a comment

Choose a reason for hiding this comment

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

Thank you for converting to prompts!

The only change that I think definitely should be - ask if rule should allow linting JS. (UPD. could be done in separate PR)

Other are suggestions and up to you.

build-tasks/templates/rule.template.js Outdated Show resolved Hide resolved
build-tasks/create-rule.js Outdated Show resolved Hide resolved
build-tasks/create-rule.js Outdated Show resolved Hide resolved
build-tasks/templates/rule.template.js Show resolved Hide resolved
Copy link

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @reduckted! I tried it out locally and it works wonderfully.

No comments from me other than what IllusionMH posted, just waiting on responses/resolutions to those.

@reduckted
Copy link
Contributor Author

Thanks for the suggestions. I've made those extra changes.

Detecting VS Code Insiders ended up being easier than I thought it would be. I've tested the generator in VS Code and Insiders, and the new files opened up in the correct instance, but it would be great if someone else could confirm it works for them just in case there's something special about my configuration that made it work.

Copy link
Contributor

@IllusionMH IllusionMH left a comment

Choose a reason for hiding this comment

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

Checked locally and it works great! 👍

Thanks for updates! No more comments from my side

@JoshuaKGoldberg JoshuaKGoldberg merged commit 59b413b into microsoft:master Dec 18, 2018
@JoshuaKGoldberg
Copy link

Thanks @reduckted! This is very snazzy.

@reduckted reduckted deleted the 258-new-rule-generator branch December 30, 2018 11:11
@IllusionMH IllusionMH added this to the 6.1.0-beta milestone Feb 19, 2019
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.

Create a rule generator by using a micro-generator f/w
3 participants