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

Added convertFileComments API #821

Merged
merged 3 commits into from
Nov 15, 2020
Merged

Added convertFileComments API #821

merged 3 commits into from
Nov 15, 2020

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Adds a synchronous single-file-use function to convert a file's contents as a string into its ESLint equivalent.

import { convertFileComments } from "tslint-to-eslint-config";

// "// eslint-disable-next-line"
const newContents = convertFileComments({
    fileContent: "// tslint:disable-next-line",
    filePath: "a.ts",
});


The individual per-file conversion logic within `convertComments` is available as a standalone function:

### `convertFileComments`
Copy link
Member Author

Choose a reason for hiding this comment

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

@JamesHenry this is published under v2.0.0-beta4 now, if you want to try it out. Is this the kind of API you're looking for?

I'd recommend using both ruleCommentsCache (for a small perf boost) and ruleEquivalents (for rule accuracy per arguments).

Copy link
Member

Choose a reason for hiding this comment

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

Ooh I missed this tip and just used your snippet in the description, I'll look at adding them in

@JamesHenry
Copy link
Member

Thanks so much for the super fast turnaround! On the face of it this is exactly what I need. It's getting late here but I'll definitely incorporate this into the PR this week, thanks again!

@JamesHenry
Copy link
Member

Hmm just installing beta4 and running a build/link with lerna is blowing up

image

I see the install affected TS versions in my yarn.lock file

image

I wonder if that could be related...

@JamesHenry
Copy link
Member

Confirmed also happens with beta3, but not when restoring to beta2 which is where I was before

@JoshuaKGoldberg
Copy link
Member Author

Oh you know what, I probably neglected to remove .d.ts files left over from old file names, manually published locally, and now they're checked into npm. Glorious. This is why we should have automated package publishing 😄 .

Published a beta5. If that still has the .d.ts cruft you can delete them locally (I'd also suggest changing your tsc settings to not pick up on those orphan node_modules/ files).

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

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

This seems to be working great for my use-case! Thanks again

@JoshuaKGoldberg JoshuaKGoldberg merged commit 12683a1 into main Nov 15, 2020
@JoshuaKGoldberg JoshuaKGoldberg deleted the node-api-comments branch November 15, 2020 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for reviewer Waiting for a maintainer to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Also export comment converter Node APIs
2 participants