Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: lint Ava tests #4981

Merged
merged 6 commits into from
Aug 15, 2023
Merged

test: lint Ava tests #4981

merged 6 commits into from
Aug 15, 2023

Conversation

turadg
Copy link
Member

@turadg turadg commented Mar 31, 2022

closes: #4941

Description

Motivation in #4941.

Security Considerations

--

Documentation Considerations

--

Testing Considerations

--

@turadg
Copy link
Member Author

turadg commented Apr 1, 2022

Wrinkle with https://github.com/eslint/eslint/issues/3458 because this makes packages that import @agoric eslint config now have to also import eslint-plugin-ava.

If we're going to have an eslint config that gets imported by packages outside this repo then I suppose it should be minimal and very general. Then more specific ones that can be opted into. For example, sdk and dapp. The ava linting would only be on the 'sdk' one.

So I'll change this PR to

  • define that "sdk" config
  • use it in all the SDK packages
  • make that config lint Ava

@turadg turadg force-pushed the 4941-lint-ava-tests branch from a3835c2 to 6c2e3a4 Compare May 4, 2023 21:34
@turadg turadg force-pushed the 4941-lint-ava-tests branch from 6c2e3a4 to 2e359df Compare June 8, 2023 19:49
@turadg turadg force-pushed the 4941-lint-ava-tests branch 4 times, most recently from 07ab914 to 3914c02 Compare July 24, 2023 15:34
@turadg turadg self-assigned this Aug 14, 2023
@turadg turadg force-pushed the 4941-lint-ava-tests branch from 3914c02 to 950a973 Compare August 15, 2023 13:18
@turadg turadg requested review from FUDCo and Chris-Hibbert August 15, 2023 13:20
@turadg turadg marked this pull request as ready for review August 15, 2023 13:20
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

with caveats, as discussed.

// error: code = NotFound desc = account agoric1mhu... not found
// Sometimes I can get this test to work alone, but not
// if run with the test above.
// TODO: https://github.com/Agoric/agoric-sdk/issues/6766
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this PR

closes: #6766

?

Copy link
Member Author

Choose a reason for hiding this comment

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

sadly, no. It's still failing https://github.com/Agoric/agoric-sdk/actions/runs/5867547993/job/15908602617?pr=4981

I'll revert this change

@@ -1,4 +1,5 @@
// @ts-check
/* eslint-disable no-lone-blocks */
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this required because of the switch/case? If so, I think the rule is being too aggressive. I wouldn't want to have to add this caveat every time I use swtch/case. Doesn't our style recommend using braces with switch/case? (It should, IMHO.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Remnant of an earlier revision. I'll remove

@@ -0,0 +1,99 @@
import { Buffer } from 'buffer';
import { makeB0ID } from './util.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

remark: Good extraction!

@turadg turadg force-pushed the 4941-lint-ava-tests branch from 950a973 to 7347734 Compare August 15, 2023 19:23
@turadg turadg enabled auto-merge August 15, 2023 19:24
@turadg turadg added this pull request to the merge queue Aug 15, 2023
@FUDCo
Copy link
Contributor

FUDCo commented Aug 15, 2023

I think no-lone-blocks is a dumb rule that serves no useful purpose that I can discern. We should disable it universally.

@mhofman mhofman removed this pull request from the merge queue due to a manual request Aug 15, 2023
@mhofman mhofman added this pull request to the merge queue Aug 15, 2023
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

This all looks quite reasonable to me.

@Chris-Hibbert
Copy link
Contributor

I think no-lone-blocks is a dumb rule that serves no useful purpose that I can discern. We should disable it universally.

I don't know why it's a good rule to enforce, but I've found that my tastes don't seem to prevail unless I can show why a proposed rule would get in the way. I asked enough questions to convince myself that it doesn't prevent anything that I'm aware of doing. @FUDCo is there something that you occasionally do that this would grouse about?

@FUDCo
Copy link
Contributor

FUDCo commented Aug 15, 2023

I think the example you already cited of switch cases is compelling by itself, but also: sometimes lone blocks are useful for expository purposes to highlight functionally distinct parts of a function, much as blank lines are used. Also, I've occasionally found them useful to control what gets captured by a closure -- sometimes optimizations inside the JS engine can result in more stuff getting captured by a closure than you want or than is lexically apparent from reading the code; arguably this latter case is more about working around JS engine issues, but real nonetheless.

Merged via the queue into master with commit 479a1a0 Aug 15, 2023
@mhofman mhofman deleted the 4941-lint-ava-tests branch August 15, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint for Ava tests
4 participants