Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): createban-ts-comment rule#1361

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 6 commits intotypescript-eslint:masterfromG-Rath:add-ban-ts-nocheck-rule
Jan 21, 2020
Merged

feat(eslint-plugin): createban-ts-comment rule#1361

bradzacher merged 6 commits intotypescript-eslint:masterfromG-Rath:add-ban-ts-nocheck-rule
Jan 21, 2020

Conversation

G-Rath
Copy link
Contributor

@G-RathG-Rath commentedDec 20, 2019
edited
Loading

Pretty much a clone ofban-ts-ignore - it might be nice to merge them into some form ofban-ts-control-comments rule 🤔

On a general aside, I'm interested in hearing what you've found better overall: lots of small nice rules, or a couple of big (but ideally still relatively straightforward in layout) rules, as it's a thought I'd had a couple of times as part of maintainingeslint-plugin-jest.

I think this could be worth having in therecommended list, w/warn level.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@G-Rath!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitorsper day.

@bradzacherbradzacher changed the titlefeat: createban-ts-nocheck rulefeat(eslint-plugin): createban-ts-nocheck ruleDec 20, 2019
@bradzacherbradzacher added the enhancement: new plugin ruleNew rule request for eslint-plugin labelDec 20, 2019
@bradzacher
Copy link
Member

I'm interested in hearing what you've found better overall: lots of small nice rules, or a couple of big (but ideally still relatively straightforward in layout) rules

I don't think there's a hard-and-fast rule.
The thing I've learned from doing this is it depends on the use case.

Having one rule makes it easy to for a user to turn on everything at once, lets you deduplicate code, etc, but it comes with the drawback of only allowing a single level for the options - it's all an error, or it's all a warning.

Having two rules makes it harder for the user, as they have to review more docs, and it means you have to work harder to deduplicate code, etc, but it means that users can independently configure the level of each.

It entirely depends on the use case. If you think people will want individual levels, then two rules make sense. If you think people will not care, then one rule makes sense.

Examples:

For naming conventions, there iscamelcase,class-name-casing,generic-type-naming,member-naming, etc. All of these rules are a pain to configure separately because they all have different options, and nobody will ever want different levels for the different naming sections, so it makes complete sense to merge them all into a single naming rule (#1318).

In the case of type assertions, in2.0.0, I merged a number of rules into one rule (consistent-type-assertions). However this ran into the problem that people want to be able to both enforce that nobody uses angle bracket assertions, and nobody uses object type assertions. Because it's all one rule, someone mighteslint-disable the single rule, which then means they are free to accidentally use an angle bracket assertion.
In that case, it was a mistake - there should be two separate rules.

Inthis example - it could go either way, it could be valid that someone might want error level forban-ts-nocheck, as it has huge impact in disabling the entire file, but a warning forban-ts-ignore, as it only disables a single line.

But I highly doubt anyone would want that.
I think this would make a lot sense together as a single rule likeban-ts-directive, with options for each of them (@ts-nocheck default true,@ts-ignore default true,@ts-check default false).

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

Following on from that big spiel, I think it makes sense to have a single rule for the@ts- directives.

Could you please merge this andban-ts-ignore together, and deprecateban-ts-ignore?

I'm thinking a simple object option:

interfaceOption{'ts-ignore'?:boolean;'ts-nocheck'?:boolean;'ts-check'?:boolean;}constdefaultOptions:[Options]=[{'ts-ignore':true,'ts-nocheck':true,'ts-check':false,}];

Naming wise, up to you -ban-ts-directive,ban-ts-directive-comment,ban-ts-comment, they're all fine.
Ithink I prefer the verbose but explicitban-ts-directive-comment, but I'm not sold. IDK if people know what adirective is, so maybe justban-ts-comment is better...

@bradzacherbradzacher added the awaiting responseIssues waiting for a reply from the OP or another party labelDec 20, 2019
@G-Rath
Copy link
ContributorAuthor

G-Rath commentedDec 20, 2019
edited
Loading

I don't think there's a hard-and-fast rule.
The thing I've learned from doing this is it depends on the use case.

Thanks for taking the time write up such a detailed response - it's pretty much the same as what I've been thinking in my head, but it's useful to hear independently aligns with a repo of this scale.

Could you please merge this and ban-ts-ignore together, and deprecate ban-ts-ignore?

Sure thing - I'll do that when I get home in a few hours :) (or tomorrow)

I think I prefer the simpler "comment" over "directive", just for ease of spelling & less technical.

bradzacher reacted with thumbs up emoji

@G-Rath
Copy link
ContributorAuthor

I might have slightly forgotten about this 😬

I'll try and get it done over this weekend, so that it's ready in time for#1423

bradzacher reacted with heart emoji

@G-RathG-Rath changed the titlefeat(eslint-plugin): createban-ts-nocheck rulefeat(eslint-plugin): createban-ts-comment ruleJan 12, 2020
@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelJan 13, 2020
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

#1318 has landed, which included a fix for the recommended config generator.
So please re-run the generator and it'll create the correct config for 2.x.

With 3.0.0 we will removeban-ts-ignore and addban-ts-comment as a recommended.

One nit with naming - backticks are so much nicer.

Otherwise LGTM - thanks for doing this!

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

woops was supposed to RC sorry

@bradzacherbradzacher added the awaiting responseIssues waiting for a reply from the OP or another party labelJan 15, 2020
@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelJan 21, 2020
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

LGTM! Great work

@bradzacherbradzacher merged commit2a83d13 intotypescript-eslint:masterJan 21, 2020
mightyiam added a commit to mightyiam/eslint-config-love that referenced this pull requestFeb 4, 2020
BREAKING CHANGE: new rule @typescript-eslint/ban-ts-commenttypescript-eslint/typescript-eslint#1361BREAKING CHANGE: new rule @typescript-eslint/prefer-as-consttypescript-eslint/typescript-eslint#1431Closes#218.
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsApr 20, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@armano2armano2armano2 approved these changes

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
enhancement: new plugin ruleNew rule request for eslint-plugin
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@G-Rath@bradzacher@armano2

[8]ページ先頭

©2009-2025 Movatter.jp