-
Notifications
You must be signed in to change notification settings - Fork 101
[Experimental Feature] Opt in flag convert disable comments #246
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
[Experimental Feature] Opt in flag convert disable comments #246
Conversation
@JoshuaKGoldberg After digging into TSLint source code and using some of their functions (copy-paste at most) and slighty changing the regex pattern as requested (couldn't use the tslint one, doesn't get the comments as I expected), now I do have better data, specially the rules array: |
Convert the input TSLint rule into equivalent ESLint
This is still a work in progress, need to check the start and end position of rule comments to avoid overwriting the wrong lines.
👋 @KingDarBoja this feature is still very exciting but I'm also not clear on what, if anything, I can do to help? |
@JoshuaKGoldberg Hi mate, Sorry for the delay, I forgot about this one and got busy with work and other stuff. I will see how to solve what's missing, in this case (from the gitter):
In other words, while trying to replace the old rules text with the new ones, I ended up overriding code instead of placing them in their line without spamming the next ones. |
Oh gotcha! Could you provide a code snippet / repro case that shows off the issue? I can take a look. |
Let me rebuild the sample repo as I moved all my stuff to a new pc and forgot to copy that one 🙈 |
@JoshuaKGoldberg Use this sample repo to test the branch.
You will notice how the ruels mapping is able to catch the rules but I am unable to write properly the |
Some thoughts after peeking through the code...
|
It is better to use source file as you get the whole TypeScript AST Tree. In this case, we are using the AST to find any node kind matching the |
I should be able to get to this within 2-3 days. 😄 |
Status update: it's working locally on sample files as of 35adb28. A couple caveats:
|
Notes on the CLI flag: |
FYI @KingDarBoja I think this is roughly ready. I'll let it sit for a few days in case there's something you or I notice as needing change. This'll be mentioned in the changelog, of course, but your starting code was very helpful in getting this working. Seriously, it was great; most of the code now still uses its core logic. Thanks so much! 💪 |
@JoshuaKGoldberg Glad to see it working properly after all this time, I have to admit, you nailed it as there were several things that I didn't know how to handle at the time being. I will take a look at it right now and test with the sample repo and of course, review it if I find something missing. Awesome work! 🚀 |
@JoshuaKGoldberg Outstanding job, this work as expected, now what's left is resolving the merge conflicts 👍 |
PR Checklist
tslint:disable
comments toeslint-disable
#136status: accepting prs
Overview
It is a work-in-progress (WIP) so any help would be welcome!So far, I managed to pull the proper regex pattern to match anytslint
comment and split it into capture groups. Each one has enough information to be used on theconvertComments
logic inside thefor-loop
(Please check the file).Updated 4/25 by @JoshuaKGoldberg:
Fleshed out the excellent initial scaffolding from @KingDarBoja and added unit tests. Summarizing the major changes in this PR:
--comments
flag marked as(experimental)
to take in globs of source files that should have their comments replaced--typescript
tslint.json
->.eslintrc.js
logic, so that rule arguments are accounted for