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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ban-ts-comment] add option to allow a ts-comment if there is a description with it #2093
Comments
I don't think a full rule is necessary but instead perhaps options to I'd kinda like it on the former (just for |
I agree! I think this makes sense as an option in I think something like the following configuration makes sense: interface Options {
'ts-expect-error'?: boolean | 'allow-with-comment';
'ts-ignore'?: boolean | 'allow-with-comment';
'ts-nocheck'?: boolean | 'allow-with-comment';
'ts-check'?: boolean | 'allow-with-comment';
} Also agree that with the next major, we can consider setting the default to |
I don't agree and think it makes sense to have them separate but I can see what you're both talking about and I'm not passionate about it either way - it's the functionality that I'm really interested in, haha. I do like, I'll say (against my own point), the result that you can't get into a situation where you banned a ts-comment but also require a comment (which could happen if they were different rules). I have some experience with estree and a decent amount with the internals of eslint circa version 5, but it's been a minute. I'd be happy to contribute this update to |
This rule is one of the simplest we have in our repo, so it's definitely not a huge task to add. |
great, I'll take a look, thanks! |
PR posted #2099 |
Also, I was meaning to inquire, does anyone here have any interest in functionality that would allow the user to dictate what kind of thing happens in the description. For example, say I only want to allow
I donno, don't wanna bikeshed but if there's any interest in such a thing now'd be the time to add it. It'd be simple enough to add but I don't feel strongly that it's necessary (although perhaps there are people out there would really like to categorize their directives! I can totally see that use case!). |
It might be a bit niche? Unsure. I think that might be better suited to a local rule in your project to help enforce the coding guidelines for your project. |
cool. yeah. I wasn't sure "how far" we wanna take it. I think the added feature of setting the minimum description length is enough of a power-user feature to suffice for now. If it comes up in the future that people want to impose some kind of regulations on the classification of the errors just lemme know. And in case anyone is turning their nose at the idea of a codebase having so many ts-ignores (and ts-expect-errors) that they need to be classified consider the use-cases of migrating a large codebase from Flow (where you might have lots of loose ends to cinch up over the span of weeks or months due to differences in 3rd party typings or just differences in TypeScript vs Flow) or a large JavaScript project that you are trying to provide stopgap types for. In that case, I have seen conventions develop for the ignores such that people can search a set of ignores later to try attacking them in groups. Anyway. I'm happy to leave it open ended for now so cool. |
[Feature Request] @typescript-eslint/require-ts-comment-description
Rule Details
Examples of 馃憥 incorrect code for this rule:
Examples of 馃憤 correct code for this rule:
Options
The configuration looks like this:
Additional Info
There is a similar rule in https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html.
I thought typescript-eslint had such a rule, but apparently not. My apologies if I just missed it.
The text was updated successfully, but these errors were encountered: