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(eslint-plugin-internal): [plugin-test-formatting] support random object literal tests#5895

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 intomainfromcheck-variables-formatting-plugin-test
Nov 2, 2022

Conversation

bradzacher
Copy link
Member

Overview

I was looking at some of our tests and noticed they weren't formatted correctly.
Investigating it was because they were declared as variables instead of as part of a test run.

This PR just adds support to the rule for random object literals by doing some fuzzy checks using types.

@bradzacherbradzacher added the repo maintenancethings to do with maintenance of the repo, and not with code/docs labelOct 27, 2022
@nx-cloud
Copy link

nx-cloudbot commentedOct 27, 2022
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitffff806. 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 46 targets

Sent with 💌 fromNxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@bradzacher!

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 commentedOct 27, 2022
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitffff806
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6361f87aea4ead0009b97836
😎 Deploy Previewhttps://deploy-preview-5895--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 settings.

@codecov
Copy link

codecovbot commentedOct 27, 2022
edited
Loading

Codecov Report

Merging#5895 (ffff806) intomain (2089e5a) willdecrease coverage by0.02%.
The diff coverage is85.36%.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #5895      +/-   ##==========================================- Coverage   91.32%   91.29%   -0.03%==========================================  Files         365      365                Lines       12212    12251      +39       Branches     3564     3577      +13     ==========================================+ Hits        11152    11185      +33- Misses        752      758       +6  Partials      308      308
FlagCoverage Δ
unittest91.29% <85.36%> (-0.03%)⬇️

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

Impacted FilesCoverage Δ
...lugin-internal/src/rules/plugin-test-formatting.ts80.92% <85.36%> (+1.07%)⬆️

@bradzacherbradzacherforce-pushed thecheck-variables-formatting-plugin-test branch from74828bc to9d928caCompareOctober 27, 2022 07:10
JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesOct 27, 2022
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Super, thanks! ✨

import { RuleTester } from '../RuleTester';

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
});

const grouped:TSESLint.RunTests<MessageIds, Options> = {
const grouped: RunTests<MessageIds, Options> = {

Choose a reason for hiding this comment

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

Why don't we just pass this directly toruleTester.run? There's only one variable here.

import { RuleTester } from '../../RuleTester';

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
});

const sortedCiWithoutGrouping:TSESLint.RunTests<MessageIds, Options> = {
const sortedCiWithoutGrouping: RunTests<MessageIds, Options> = {

Choose a reason for hiding this comment

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

Similar suggestion: I like the idea behind describing the variables, but it just seems like extra cruft to me. How about passing them directly toruleTester.run?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm personally not too miffed either way.

I think the separate variables is nice as a way to document and group the tests.
it's much clearer than the alternative:

ruleTester.run('member-ordering',rule,{valid:[//// Sorted case insensitive without grouping//'test1',// ...//// Sorted case insensitive with grouping//'testn+1',// ...],});

I find it really easy to lose the comments in the array when it gets really big.

But the indirection is a bit of a pain overall.

I think either way has trade-offs, so IDK which one we want as the standard in the repo.

Choose a reason for hiding this comment

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

My mild preference would be for less code, but it's not a hill I'm going to die on 😄

testProp.computed ||
testProp.key.type !== AST_NODE_TYPES.Identifier ||
testProp.key.name !== 'errors' ||
testProp.value.type !== AST_NODE_TYPES.ArrayExpression

Choose a reason for hiding this comment

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

Nit: this isalmost the same as the previous.type === AST_NODE_TYPES.SpreadElement || ... check, but for the'errors' case. I wonder if there's a good way to dedup? 🤷 definitely not a blocker IMO.

@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelOct 27, 2022
@bradzacherbradzacher merged commitf11183c intomainNov 2, 2022
@bradzacherbradzacher deleted the check-variables-formatting-plugin-test branchNovember 2, 2022 05:12
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsNov 17, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg left review comments

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we mergerepo maintenancethings to do with maintenance of the repo, and not with code/docs
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@bradzacher@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp