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

chore: enabled stylistic-type-checked internally#7138

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

Conversation

@JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Addsstylistic-type-checked to the list ofextends configs and removes manual enables of rules contained in it. Most of the changes seem to be fromno-confusing-void-expression, followed byconsistent-indexed-object-style.

A couple rules received special treatment:

  • Doesn't enableprefer-nullish-coalescing yet, as there were a lot of complaints from it and I'll look into it separately
  • no-empty-function seemed to be popular for tests, so I moved it to the tests overrides

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@JoshuaKGoldberg!

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.

@netlify
Copy link

netlifybot commentedJun 25, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitbc9238e
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/649f6417cba55300077aa9bf
😎 Deploy Previewhttps://deploy-preview-7138--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloud
Copy link

nx-cloudbot commentedJun 25, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitbc9238e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 31 targets

Sent with 💌 fromNxCloud.

.join('\n')
:formatted;

returncontext.report({
Copy link
Member

Choose a reason for hiding this comment

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

which rule suggested this?
TBH I prefer thereturn report style here as it's easier to see that the report is terminal.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

no-confusing-void-expression. I'm feeling more and more 👎 on including that one instylistic-type-checked.

functionisPascalCase(name:string):boolean{
return(
name.length===0||
(name[0]===name[0].toUpperCase()&&!name.includes('_'))
Copy link
Member

Choose a reason for hiding this comment

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

I actually think that the previous form is clearer for this specifica case.
It's also substantially faster (not that it matters at the this speed... but it is twice as fast - ~1.2B ops/s vs ~2.4B ops/s).

I wonder if we should add an option to skip this case from the rule?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Agreed. The main 👎 on this change in my head was that the rule is suggestinglonger code...#7140

Comment on lines 666 to 668
ConditionalExpression:(node):void=>{
checkNode(node.test);
},
Copy link
Member

Choose a reason for hiding this comment

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

TBH I personally don't think that multilining arrows is necessarily clearer.
Is there a reason the stylistic set is pushing for this style?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn’t thishttps://typescript-eslint.io/rules/no-confusing-void-expression ? You probably already know but posting for other readers :D

JoshuaKGoldberg reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yup it is! +1 to the visibility@rubiesonthesky 😄.

I wonder if it should be moved to thestrict-type-checked config instead...#7130 (comment)

functiontraverse(node:ts.Node):T|undefined{
switch(node.kind){
casets.SyntaxKind.ReturnStatement:
returnvisitor(<ts.ReturnStatement>node);
Copy link
Member

Choose a reason for hiding this comment

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

JoshuaKGoldberg reacted with laugh emoji
Comment on lines 72 to 74
constdefs=(schema.$defs??schema.definitions)as
|Record<string,JSONSchema4>
|undefined;
Copy link
Member

Choose a reason for hiding this comment

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

IIRC I did this intentionally because both of the keys were not techincallyundefined - is that not the case any more?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yup!no-unnecessary-type-assertion is complaining on them. Bothschema.$defs andschema.definitions areRecord<string, JSONSchema4> | undefined.

Comment on lines 15 to 20
exportinterfaceDependencyConstraint{
/**
* Passing a string for the value is shorthand for a '>=' constraint
*/
readonly[packageName:string]:VersionConstraint;
}
Copy link
Member

Choose a reason for hiding this comment

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

Making this a record is actually less clear due to the lost comment

JoshuaKGoldberg reacted with thumbs up emoji
block:TBlock,
isMethodDefinition:boolean,
){
constupperScopeAsScopeBase=upperScopeasScope;
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised TS allowed this - the reason this cast was there was becauseupperScope is typed asTUpper - and there was a lot of weird behaviour that stemmed from it being a generic instead of the concrete type.

I think there was also some weirdness due to the cyclic nature of the files? I don't fully remmeber though

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

🤷


it('deeplyCopy should convert node correctly',()=>{
constast=convertCode('type foo = ?foo<T> | ?(() => void)?');
/* eslint-disable @typescript-eslint/dot-notation */
Copy link
Member

Choose a reason for hiding this comment

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

why is this disabled?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

deeplyCopy is a private member.['deeplyCopy'] bypasses that.

Comment on lines 189 to 195
expect(()=>{
parseFile('foo',PROJECT_DIR);
}).not.toThrow();
// bar should throw because it doesn't exist yet
expect(()=>parseFile(bazSlashBar,PROJECT_DIR)).toThrow();
expect(()=>{
parseFile(bazSlashBar,PROJECT_DIR);
}).toThrow();
Copy link
Member

Choose a reason for hiding this comment

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

this is the sort of reason I think that the concise arrow function style is better - satisfying this lint rule just added some 160 lines to this file and (IMO) made the codeharder to read

Comment on lines 133 to 138
exportinterfaceGlobalsConfig{
[name:string]:GlobalVariableOption;
}
exportinterfaceEnvironmentConfig{
[name:string]:boolean;
}
Copy link
Member

Choose a reason for hiding this comment

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

I believe that these should stay as interfaces to allow for global augmentation from consumers.

Comment on lines 387 to 389
exportinterfaceVisitorKeys{
[nodeType:string]:string[];
}
Copy link
Member

Choose a reason for hiding this comment

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

I do like theRecord style more in general, but you can lose some nice implicit documentation sometimes (eg the variable name here).

I'm so torn about using a disable comment for this though because it's so minor.

Copy link
Contributor

Choose a reason for hiding this comment

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

It could use comment to say same if this style is kept :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yeah this is an interesting discussion. I'll undo the changes fromconsistent-indexed-object-style and file them as a todo to look at later, similar toprefer-nullish-coalescing.

typeofevaluated.value==='string'&&
// checks if the string is a character long
evaluated.value[0]===evaluated.value
evaluated.value.length===1

This comment was marked as off-topic.

Copy link
MemberAuthor

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

(accidentally started a review, but getting pulled out for something - will continue commenting soon)

.join('\n')
:formatted;

returncontext.report({
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

no-confusing-void-expression. I'm feeling more and more 👎 on including that one instylistic-type-checked.

functionisPascalCase(name:string):boolean{
return(
name.length===0||
(name[0]===name[0].toUpperCase()&&!name.includes('_'))
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Agreed. The main 👎 on this change in my head was that the rule is suggestinglonger code...#7140

Comment on lines 666 to 668
ConditionalExpression:(node):void=>{
checkNode(node.test);
},
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yup it is! +1 to the visibility@rubiesonthesky 😄.

I wonder if it should be moved to thestrict-type-checked config instead...#7130 (comment)

@codecov
Copy link

codecovbot commentedJun 26, 2023
edited
Loading

Codecov Report

Merging#7138 (bc9238e) intov6 (3cdf5c9) willnot change coverage.
The diff coverage is100.00%.

Additional details and impacted files
@@           Coverage Diff           @@##               v6    #7138   +/-   ##=======================================  Coverage   87.43%   87.43%           =======================================  Files         372      372             Lines       12849    12849             Branches     3813     3813           =======================================  Hits        11235    11235             Misses       1237     1237             Partials      377      377
FlagCoverage Δ
unittest87.43% <100.00%> (ø)

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
packages/eslint-plugin/src/rules/comma-dangle.ts93.33% <ø> (ø)
...-estree/src/create-program/createDefaultProgram.ts76.19% <ø> (ø)
.../src/create-program/getWatchProgramsForProjects.ts84.83% <ø> (ø)
...pt-estree/src/parseSettings/createParseSettings.ts81.63% <ø> (ø)
...plugin/src/rules/no-duplicate-type-constituents.ts100.00% <100.00%> (ø)
...s/eslint-plugin/src/rules/no-restricted-imports.ts96.29% <100.00%> (ø)
...lugin/src/rules/padding-line-between-statements.ts93.83% <100.00%> (ø)
...nt-plugin/src/rules/switch-exhaustiveness-check.ts97.87% <100.00%> (ø)
packages/eslint-plugin/src/util/astUtils.ts88.88% <100.00%> (ø)
packages/scope-manager/src/scope/ScopeBase.ts91.71% <100.00%> (ø)
... and1 more

@JoshuaKGoldbergJoshuaKGoldberg marked this pull request as ready for reviewJune 26, 2023 23:18
JoshuaKGoldbergand others added3 commitsJune 30, 2023 16:22
Co-authored-by: rubiesonthesky <2591240+rubiesonthesky@users.noreply.github.com>
@JoshuaKGoldbergJoshuaKGoldberg merged commit42fe29f intotypescript-eslint:v6Jun 30, 2023
@JoshuaKGoldbergJoshuaKGoldberg deleted the v6-stylistic-type-checked branchJune 30, 2023 23:53
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 8, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@bradzacherbradzacherAwaiting requested review from bradzacher

1 more reviewer

@rubiesontheskyrubiesontheskyrubiesonthesky left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@JoshuaKGoldberg@rubiesonthesky@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp