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

fix(eslint-plugin): [ban-types] add option extendDefaults#1379

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 4 commits intotypescript-eslint:masterfromthreehams:master
Feb 28, 2020

Conversation

threehams
Copy link
Contributor

@threehamsthreehams commentedDec 24, 2019
edited
Loading

Special-caseban-types rule to replace default options instead of merging ifextendDefaults is set tofalse.

Fixes#686.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@threehams!

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.

@armano2armano2 added breaking changeThis change will require a new major version to be released default rule optionsDiscussions about default rule options package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin labelsDec 24, 2019
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.

Thanks - this LGTM as it currently stands.

RC for this question - one thing I might ask is a new option.

typeOptions=[{types?:Types;extendDefaults?:boolean;},]

Which would do the following: If false or omitted, it would work as you have just implemented - all or nothing. If true, it would doObject.assign(defaultOpts, userOpts.types) (i.e. extends and overrides the defaults with the user options).

This would save people copy-pasting the defaults all of the time, which would make it easier for them to include any future changes to defaults we do.

WDYT?

glen-84 reacted with thumbs up emoji
@threehams
Copy link
ContributorAuthor

We might just be dancing around the issue of theObject message and fixer here. The primitive constructor type messages and fixers are a good default any project.Object, though, doesn't really have one universal way to fix it. Usage of it could be from someone really looking for behavior likeobject, or could be from someone not wanting to figure out the real structure of an object and just throwing in something that's effectivelyany. I've seen both usages in a Flow project.

Theofficial recommendation is to useobject which I'd agree with, but is probably the wrong fix in most cases.Record is a pretty unsound "just trust me" type even without theany mixed in, so we're just auto-fixing "any" to "almost any" there.

If the message were more generic and it didn't auto-fix, then this seems like a good use for thesuggestions API, though it would require ESLint 6.7.

@glen-84
Copy link
Contributor

This is related to#848, where the fixer forObject is removed (butRecord<string, unknown> is still "suggested").

@threehams
Copy link
ContributorAuthor

In that case, I'll add extendDefaults here since it'll be taken care of in that PR.

This change could take a little longer, it's not as clear how to do it without adding more one-off code in here. Maybe necessary though.

@bradzacherbradzacher added the awaiting responseIssues waiting for a reply from the OP or another party labelDec 28, 2019
@bradzacher
Copy link
Member

bradzacher commentedDec 28, 2019
edited
Loading

I think this is definitely a one-off use case. This rule is an edge case. I'm happy with the one-off code living in this rule.

Thinking about it, if you addextendDefaults with a default value oftrue, then this is no longer a breaking change - as it wouldn't meaningfully change it from the way it works currently.

@HolgerJeromin
Copy link

Thinking about it, if you add extendDefaults with a default value of true, then this is no longer a breaking change - as it wouldn't meaningfully change it from the way it works currently.

I think this would be the best option.
Friendly ping to@threehams :)

@threehams
Copy link
ContributorAuthor

Updated code, tests, docs. Edited description as this is no longer a breaking change.

HolgerJeromin reacted with heart emoji

@bradzacherbradzacher removed awaiting responseIssues waiting for a reply from the OP or another party breaking changeThis change will require a new major version to be released labelsFeb 23, 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 - thanks for seeing this through.

@bradzacherbradzacher changed the titlefix(eslint-plugin): replace default options on ban-typesfix(eslint-plugin): [ban-types] add option extendDefaultsFeb 28, 2020
@bradzacherbradzacher added the bugSomething isn't working labelFeb 28, 2020
@codecov
Copy link

codecovbot commentedFeb 28, 2020

Codecov Report

Merging#1379 intomaster willincrease coverage by0.00%.
The diff coverage isn/a.

@@           Coverage Diff           @@##           master    #1379   +/-   ##=======================================  Coverage   95.53%   95.53%           =======================================  Files         142      142             Lines        6625     6630    +5       Branches     1897     1900    +3     =======================================+ Hits         6329     6334    +5  Misses        106      106             Partials      190      190

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
bugSomething isn't workingdefault rule optionsDiscussions about default rule optionspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[ban-types] Default options are never removed
5 participants
@threehams@glen-84@bradzacher@HolgerJeromin@armano2

[8]ページ先頭

©2009-2025 Movatter.jp