Coder Social home page Coder Social logo

codemod-missing-await-act's Introduction

I maintain stuff

codemod-missing-await-act's People

Contributors

eps1lon avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

codemod-missing-await-act's Issues

missed patterns

checkboxes.slice(0, 2).forEach((switchEl) => toggleSwitch(switchEl))
									         ^^^^^^^^^^^^ became async

Curried calls:

const renderMock = (Component) => (props) => render(<Component {...props} />)
// missing `await`
const view = renderMock(() => null)({})

Common manual fixes

Adding an Awaited when using ReturnType<typeof someNewlyAsyncTestingLibraryMethod>

 import { render } from '@testing-library/react';

-let screen: ReturnType<typeof render>;
+let screen: Awaited<ReturnType<typeof render>>;

default import name should be ignored

With a file like

import render from '../render'

render()

and an import config like

import render2 from '../render'

the transform isn't applied but should.

Output new rules to run codemod again

When an exported method changed to async we need to propagate that.

We'll stick to ESM for now for simplicity. However, the module specifier will be unknown so that requires user input.

Once #6 is done we can directly output the recommended config and prompt the user for the source specifier.

Add config for what contains an `act` call

Codebases will have their own wrappers around React Testing Libraries. Once the codemod is applied these wrappers will now also be async which needs to be propagated.

Ideally we could just propagate this through files but that needs a full resolver implementation and building up a fully dependency tree (in memory). It seems better to use an iterative approach to propagating these changes:

rules = ReactTestingLibraryAPIS
while (rules are not empty) 
  apply codemod with rules
  rules = public APIs that just now became `async`

This issue will just add the config option.

Link to LOC when warning about newly async export

e.g.

/Users/sebastian.silbermann/klapp/clients/packages/features/products-and-search/redux-fetch-module/testUtils/index.tsx: Export 'renderWithStore' is now async. Make sure to update the rules of this codemod and run it again.

should link to line and column directly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.