Giter Site home page Giter Site logo

codemod-com / codemod-registry Goto Github PK

View Code? Open in Web Editor NEW
34.0 1.0 1.0 2.23 MB

A registry of community-led codemods & code automation recipes for popular refactors, migrations, and dependency upgrades.

Home Page: https://www.codemod.com/automations/

License: Apache License 2.0

TypeScript 88.73% JavaScript 11.27% Shell 0.01%
codemod jscodeshift upgrade piranha ts-morph code-generation migration refactoring contributors-welcome good-first-issue

codemod-registry's Introduction

Codemod Registry Header

⚠️ This repository is deprecated and no longer maintained.

Please Note: This repository was migrated to a monorepo called codemod.

Codemod Registry

All Contributors

Codemod Registry is an open-source, single-stop repository for codemods and code automation recipes. Codemod Registry brings an ever-growing variety of helpful codemods all in one place.

Codemods available in Codemod Registry are automatically integrated into the Codemod platform and all developers who have the Codemod CLI or IDE extension can then discover, share, and run those codemods with a single click.

Currently, the Codemod platform supports jscodeshift, ts-morph, and Uber's Piranha codemod engines. If you would like to see a specific codemod engine supported, please leave us a feature request.

If there is a codemod you would like to see available in Codemod Registry, please consider opening a PR to add the codemod. Learn more about contributing here.

Why use Codemod Registry

Adding or using codemods in Codemod Registry allows for:

🔗 Automatic integration with the Codemod CLI and VS Code extension.

:octocat: Ensuring codemods are reviewed and improved by a community of codemod experts.

🌍 Making codemods more accessible to many developers around the world.

Supported frameworks & libraries

Running codemods in the registry

All codemods in the registry are automatically distributed to the Codemod CLI and IDE extension.

To run any codemod in the registry, you can:

Contributing

Codemod Registry is an open-source, community-first, and community-powered project made for developers, by developers.

If you would like to contribute to the Codemod Registry, please follow our contribution guide. Please note that once you create a pull request, you will be asked to sign our Contributor License Agreement.

If you are a codemod builder and/or interested in codemods, please join our community!

If you are not a codemod developer, but you would like to have the community contribute on developing a codemod you’re interested in, then feel free to request a codemod here.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Max Leiter
Max Leiter

💻
Greg Pabian
Greg Pabian

💻 🐛 📖
DmytroHryshyn
DmytroHryshyn

💻 🐛
Alex Bit
Alex Bit

💻 📖
Benny Joo
Benny Joo

💻 🐛 📖
Mohab Sameh
Mohab Sameh

💻 📖
Serhii Melnyk
Serhii Melnyk

🤔
kevtran2
kevtran2

📖 💻
George W Langham
George W Langham

🐛
Aniello Falcone
Aniello Falcone

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

codemod-registry's People

Contributors

alexbit-codemod avatar allcontributors[bot] avatar dependabot[bot] avatar dmytrohryshyn avatar gregintuitaio avatar grzpab avatar hbjorbj avatar kevtran2 avatar maxleiter avatar mohab-sameh avatar r4zendev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

hbjorbj

codemod-registry's Issues

[Codemod:HandleAsyncFunctionDeclarationsToArrowFunctions] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleAsyncFunctionDeclarationsToArrowFunctions</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>async function postHandler(req: NextApiRequest) {

const { userId, isAdmin, prisma } = req;
const { neverExpires, userId: bodyUserId, ...input } = apiKeyCreateBodySchema.parse(req.body);
const [hashedKey, apiKey] = generateUniqueAPIKey();
const args: Prisma.ApiKeyCreateArgs = {
data: {
id: v4(),
userId,
...input,
// And here we pass a null to expiresAt if never expires is true. otherwise just pass expiresAt from input
expiresAt: neverExpires ? null : input.expiresAt,
hashedKey,
},
};

if (!isAdmin && bodyUserId) throw new HttpError({ statusCode: 403, message: ADMIN required for userId });

if (isAdmin && bodyUserId) {
const where: Prisma.UserWhereInput = { id: bodyUserId };
await prisma.user.findFirstOrThrow({ where });
args.data.userId = bodyUserId;
}

const result = await prisma.apiKey.create(args);
return {
api_key: {
...apiKeyPublicSchema.parse(result),
key: ${process.env.API_KEY_PREFIX ?? "cal_"}${apiKey},
},
message: "API key created successfully. Save the key value as it won't be displayed again.",
};
}

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


const postHandler = async (req: NextApiRequest) => {
const { userId, isAdmin, prisma } = req;
const { neverExpires, userId: bodyUserId, ...input } = apiKeyCreateBodySchema.parse(req.body);
const [hashedKey, apiKey] = generateUniqueAPIKey();
const args: Prisma.ApiKeyCreateArgs = {
data: {
id: v4(),
userId,
...input,
// And here we pass a null to expiresAt if never expires is true. otherwise just pass expiresAt from input
expiresAt: neverExpires ? null : input.expiresAt,
hashedKey,
},
};

if (!isAdmin && bodyUserId) throw new HttpError({ statusCode: 403, message: ADMIN required for userId });

if (isAdmin && bodyUserId) {
const where: Prisma.UserWhereInput = { id: bodyUserId };
await prisma.user.findFirstOrThrow({ where });
args.data.userId = bodyUserId;
}

const result = await prisma.apiKey.create(args);
return {
api_key: {
...apiKeyPublicSchema.parse(result),
key: ${process.env.API_KEY_PREFIX ?? "cal_"}${apiKey},
},
message: "API key created successfully. Save the key value as it won't be displayed again.",
};
};


Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.

[Codemod][next/13/replace-next-router] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

2. Expected code after transformation (Desired output of codemod)

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


Additional context

[Codemod][next/13/move-css-in-js-styles] Invalid codemod output

Codemod: next/13/move-css-in-js-styles

1. Code before transformation (Input for codemod)

2. Expected code after transformation (Desired output of codemod)

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.



hahaha test

code code

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


type OfProps = BaseProps & {
of: Component;
};

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSInte


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

function renderEmail(
  template: K,
  props: React.ComponentProps<(typeof templates)[K]>
) {
  const Component = templates[template];
  return (
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-expect-error
    ReactDOMServer.renderToStaticMarkup(Component(props))
      // Remove `` injected scripts
      .replace(/

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


type OfProps = BaseProps & {
of: Component;
};

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	
	<pre><code>type OfProps = BaseProps & {  of: "." | "^" | Component;};</code></pre>

	<p><strong>2. Expected code after transformation (Desired output of codemod)</strong></p>
	<pre><code>// paste code here</code></pre>
	<p><strong>3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: Component;
};

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


asdfklansdfklansdklf

asdflkansdfklansdkl

asdkflnasdklfnaskldfn

asdkflansdkflansd
```klasndfklasndfkl

[Codemod:next/13/replace-next-router] Jest test mocking next/router


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

import { useRouter } from 'next/router';

jest.mock('next/router', () => ({
  useRouter: jest.fn(() => router),
}));

2. Expected code after transformation (Desired output of codemod)

import { useRouter } from 'next/navigation';

jest.mock('next/navigation', () => ({
  useRouter: jest.fn(() => router),
}));

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

import { useRouter } from 'next/navigation';

jest.mock('next/router', () => ({
  useRouter: jest.fn(() => router),
}));

Additional context

nce] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[ImmutableJS] v3 to v4 - deprecate "Record"

  • Link to relevant docs, if available

  • [high level applicability]

    • Old code patterns to transform exist in the following versions of the package:
      • Versions: v.x-v.y
    • Relevant files
      • $.js|ts|tsx|jsx
  • Transformation logic/steps (ordered list of "atomic" changes, this makes codemod creation easier):

  1. DETECT X
  2. [file] CREATE F
  3. CREATE Y
  4. DELETE Z
  • Old code sample(s):

  • New code sample(s):

  • A test file/repo (that contains both code patterns that need to be transformed and those that should not be touched.)

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


type OfProps = BaseProps & {
of: Component;
};

Additional context

[Codemod:HandleAsyncFunctionDeclarationsToArrowFunctions] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleAsyncFunctionDeclarationsToArrowFunctions

1. Code before transformation (Input for codemod)

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

Additional context

You can provide any relevant context here.


test [faulty output]

⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Faulty codemod

Mention the codemod you ran which resulted in incorrect output. [e.g. next/13/app-router-recipe]

Code before transformation

//insert your code before transformation here

Expected code after transformation

//insert the expected **correct** output here

Actual code after transformation

//insert the actual **faulty** output here

Estimated severity

A general estimation of the severity of this issue. This can be estimated based on the number of files affected and the difficulty of manually fixing the faulty output while reviewing Intuita's dry run results.

Environment:

  • Intuita CLI version: [e.g. v0.0.21]
  • OS: [e.g. MacOS 13.0.1]
  • Node.js version: [e.g. v16.16.0]

Additional context

Add any other context about the problem here. This might include the target project, explanation of faulty output related to business logic, relevant links, etc.

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


type OfProps = BaseProps & {
of: Component;
};

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


type OfProps = BaseProps & {
of: Component;
};

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.

asdfasdf

const x = 123;
const y = (tes: boolean) => {
    haha;;;
}

[Codemod:next/13/replace-next-router] Invalid codemod output: old router.query API is used


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

import { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import { useTeam } from '#/swr/use-team';
import { useUser } from '#/swr/use-user';

export default function useIsValidScope(): boolean | null {
  const router = useRouter();
  const { user } = useUser();
  const { teams } = useTeam();
  const [isValidScope, setIsValidScope] = useState<null | boolean>(null);
  const { query } = router;

  useEffect(() => {
    if (teams && isValidScope === null) {
      if (router.isReady && user?.username) {
        if (
          user.username === query.teamSlug ||
          teams.some((team) => team.slug === query.teamSlug) ||
          typeof query.teamSlug === 'undefined'
        ) {
          setIsValidScope(true);
        } else {
          setIsValidScope(false);
        }
      }
    }
  }, [query, teams, isValidScope, user, router]);

  return isValidScope;
}

2. Expected code after transformation (Desired output of codemod)

import { useSearchParams } from "next/navigation";
import { useState, useEffect } from 'react';
import { useTeam } from '#/swr/use-team';
import { useUser } from '#/swr/use-user';

export default function useIsValidScope(): boolean | null {
    const searchParams = useSearchParams();
    const { user } = useUser();
    const { teams } = useTeam();
    const [isValidScope, setIsValidScope] = useState<null | boolean>(null);
    useEffect(() => {
        if (teams && isValidScope === null) {
            if (searchParams !== null && user?.username) {
                if (user.username === searchParams?.get('teamSlug') ||
                    teams.some((team) => team.slug === searchParams?.get('teamSlug')) ||
                    typeof searchParams?.get('teamSlug') === 'undefined') {
                    setIsValidScope(true);
                } else {
                    setIsValidScope(false);
                }
            }
        }
    }, [searchParams, teams, isValidScope, user]);
    return isValidScope;
}

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

import { useSearchParams } from "next/navigation";
import { useRouter } from "next/navigation";
import { useState, useEffect } from 'react';
import { useTeam } from '#/swr/use-team';
import { useUser } from '#/swr/use-user';
export default function useIsValidScope(): boolean | null {
    const searchParams = useSearchParams();
    const router = useRouter();
    const { user } = useUser();
    const { teams } = useTeam();
    const [isValidScope, setIsValidScope] = useState<null | boolean>(null);
    const { query } = router;
    useEffect(() => {
        if (teams && isValidScope === null) {
            if (searchParams !== null && user?.username) {
                if (user.username === query.teamSlug ||
                    teams.some((team) => team.slug === query.teamSlug) ||
                    typeof query.teamSlug === 'undefined') {
                    setIsValidScope(true);
                }
                else {
                    setIsValidScope(false);
                }
            }
        }
    }, [query, teams, isValidScope, user, router]);
    return isValidScope;
}

Additional context

The router.query should be removed from this code.

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[codemod request] ember.js upgrade codemods v3 to v5

Ember Codemod

ember-3x-codemods A collection of codemods for adressing deprecations introduced in Ember 3.x General ember 3.x (varies)

  • app-controller-router-props
  • array-wrapper
  • cp-property-map
  • cp-property
  • cp-volatile
  • deprecate-merge
  • deprecate-router-events
  • ember-jquery-legacy
  • fpe-computed
  • fpe-observes
  • fpe-on
  • jquery-apis
  • jquery-event
  • new-array-wrapper → covered by array-wrapper codemod
  • notify-property-change
  • object-new-constructor
  • ember-tracked-properties-codemod Transforms your app code to use @Tracked properties General ember 3.13+
  • es5-getter-ember-codemod Transforms gets to native property access General ember 3.1+
  • ember-angle-brackets-codemod Transforms your templates to use angle bracket syntax Templates ember?
  • ember-component-template-colocation-migrator Migrates classical components to colocated components Components ember?
  • ember-native-class-codemod Transforms your app code to use the native classes and decorators General ember?
  • ember-mocha-codemods Transforms your Mocha test modules to use the setup* helper family Testing ember 2.4+, ember-mocha?
  • (BENNY WIP) ember-qunit-codemod Transforms your QUnit test modules to use the setup* helper family Testing ember 2.4+, ember-qunit?
  • ember-test-helpers-codemod Transforms your test code to use @ember/test-helpers Testing ember 2.4+
  • ember-computed-getter-codemod Transforms computed properties to use split get and set functions General ember?
  • ember-modules-codemod Transforms your code to use the module API General ember?
  • ember-memory-leaks-codemod Identifies and fixes common memory leaks in Ember apps General
  • ember-cli-htmlbars-inline-precompile-codemod Transforms imports to avoid using htmlbars-inline-precompile General
  • tagless-ember-components-codemod Transforms your components to use tagName: '' Components
  • ember-no-implicit-this-codemod Transforms your templates to use explicit this Templates
  • ember-test-onerror-codemod Transforms your test code to avoid using Ember.onerror Testing

Add a clear description of what should the codemod do.

Applicability Criteria

  • Framework/library: Ember
  • Version: v3 -> v5]

Estimated time saving

Add an expected time saving this codemod can provide. 5 minutes per occurrence

Additional context

Add any other context about the problem here. This might include extra considerations, edge cases, relevant business logic, existing migration guides, relevant links, etc.
https://github.com/ember-codemods

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


reduce style/formatting changes


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

function NewTeamForm({
  createTeamCollapsed,
  flowType,
  formLoading,
  required = true,
  skip,
  isATrial,
  disabled,
  paymentMethodId,
  nameRef,
}) {
 ...
}

2. Expected code after transformation (Desired output of codemod)

Unchanged. Same as old.

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

function NewTeamForm({ 
  createTeamCollapsed, 
  flowType, 
  formLoading, 
  required = true, 
  skip, 
  isATrial, 
  disabled, 
  paymentMethodId, 
  nameRef, 
}) {
  ...
}

Additional context

[Codemod:next/13/replace-next-router] useParams and useSearchParam can be null


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

const parsedParam = getQueryParam(router.query[key]);

2. Expected code after transformation (Desired output of codemod)

const getParam = useCallback((p: string) => params.[p] ?? searchParams?.get(p), [params, searchParams]);
const parsedParam = getQueryParam(getParam(key));

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

const getParam = useCallback((p: string) => params[p] ?? searchParams.get(p), [params, searchParams]);
const parsedParam = getQueryParam(getParam(key));

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


asdfklansdfklansdklf

asdflkansdfklansdkl

asdkflnasdklfnaskldfn

[Codemod:next/13/replace-next-router] Invalid codemod output: old router.query API is used


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

function CloneFlowPreview({
  frameworks,
  hasAccess,
}: {
  frameworks?: Framework[];
  hasAccess: boolean;
}): JSX.Element {
  const { query } = useRouter();

  const framework = useMemo(
    () => frameworks?.find((f) => f.slug === query.template),
    [frameworks, query.template],
  );

  const demo =
    typeof query['demo-title'] === 'string' &&
    typeof query['demo-description'] === 'string' &&
    typeof query['demo-image'] === 'string' &&
    typeof query['demo-url'] === 'string'
      ? {
          title: query['demo-title'],
          description: query['demo-description'],
          image: query['demo-image'],
          url: query['demo-url'],
        }
      : framework
      ? {
          title: framework.name,
          description: framework.description,
          url: framework.demo,
          framework,
        }
      : null;

2. Expected code after transformation (Desired output of codemod)

function CloneFlowPreview({
  frameworks,
  hasAccess,
}: {
  frameworks?: Framework[];
  hasAccess: boolean;
}): JSX.Element {
    const searchParams = useSearchParams();
    const framework = useMemo(() => frameworks?.find((f) => f.slug === searchParams?.get('template')), [frameworks, searchParams?.get('template')]);
    const demo = 
    typeof searchParams.get('demo-title') === 'string' &&
        typeof searchParams.get('demo-description')=== 'string' &&
        typeof searchParams.get('demo-image') === 'string' &&
        typeof searchParams.get('demo-url') === 'string'
        ? {
            title: query['demo-title'],
            description: query['demo-description'],
            image: query['demo-image'],
            url: query['demo-url'],
        }
        : framework
            ? {
                title: framework.name,
                description: framework.description,
                url: framework.demo,
                framework,
            }
            : null;

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

function CloneFlowPreview({ frameworks, hasAccess, }: {
    frameworks?: Framework[];
    hasAccess: boolean;
}): JSX.Element {
    const searchParams = useSearchParams();
    const framework = useMemo(() => frameworks?.find((f) => f.slug === searchParams?.get('template')), [frameworks, searchParams?.get('template')]);
    const demo = 
    /* eslint-disable-next-line no-nested-ternary -- TODO: Fix ESLint Error (#13355) */
    typeof query['demo-title'] === 'string' &&
        typeof query['demo-description'] === 'string' &&
        typeof query['demo-image'] === 'string' &&
        typeof query['demo-url'] === 'string'
        ? {
            title: query['demo-title'],
            description: query['demo-description'],
            image: query['demo-image'],
            url: query['demo-url'],
        }
        : framework
            ? {
                title: framework.name,
                description: framework.description,
                url: framework.demo,
                framework,
            }
            : null;

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Codemod:HandleAsyncFunctionToArrowConversion] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleAsyncFunctionToArrowConversion

1. Code before transformation (Input for codemod)

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

const postHandler = async (req: NextApiRequest) => {
  const { userId, isAdmin, prisma } = req;
  const { userId: bodyUserId, ...body } = schemaSelectedCalendarBodyParams.parse(req.body);
  const args: Prisma.SelectedCalendarCreateArgs = { data: { ...body, userId } };

if (!isAdmin && bodyUserId) throw new HttpError({ statusCode: 403, message: ADMIN required for userId });

if (isAdmin && bodyUserId) {
const where: Prisma.UserWhereInput = { id: bodyUserId };
await prisma.user.findFirstOrThrow({ where });
args.data.userId = bodyUserId;
}

const data = await prisma.selectedCalendar.create(args);

return {
selected_calendar: schemaSelectedCalendarPublic.parse(data),
message: "Selected Calendar created successfully",
};
};

Additional context

You can provide any relevant context here.


[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️

Codemod: HandleTSIntersectionTypeToComponentReference

  1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
of: "." | "^" | Component;
};

  1. Expected code after transformation (Desired output of codemod)

// paste code here

  1. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
of: Component;
};

Additional context

You can provide any relevant context here.

adsfalksdfadsfasdf

asdfklasndflkasd

[Codemod:next/13/replace-next-router] Object.fromEntries(URLSearchParams) only returns Record<string, string>


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

Object.entries(router.query).forEach(([key, value]) =>
    typeof value === 'string' ? query.set(key, value) : null,
);

2. Expected code after transformation (Desired output of codemod)

TBD

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

Object.entries(...Object.fromEntries(searchParams ?? new URLSearchParams())).forEach(
    ([key, value]) => typeof value === 'string' ? query.set(key, value) : null
);

Additional context

  1. The resulting code is a valid syntax, but wrong typing on ...Object.fromEntries()
  2. The result of Object.fromEntries(URLSearchParams) is Record<string, string>, not Record<string, string | string[]> as it is with the legacy Router.query. Thus the typeof value === 'string' would always be true.

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output

	<hr>
	<p>
	<span style="font-size: 18px; font-weight: bold; color: #FFA500;">⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️</span>
	</p>
	<hr>
	<h3>Codemod: HandleTSIntersectionTypeToComponentReference</h3>
	<p><strong>1. Code before transformation (Input for codemod)</strong></p>
	<pre><code>type OfProps = BaseProps & {

of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)


// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)


type OfProps = BaseProps & {
of: Component;
};

Additional context

[Codemod:next/13/replace-next-router] Invalid destructuring for useSearchParams


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: next/13/replace-next-router

1. Code before transformation (Input for codemod)

const { department = query.department, location = query.location } =
  router.query as IndexQuery;

2. Expected code after transformation (Desired output of codemod)

const searchParams = useSearchParams();
const { department = query.department, location = query.location } =
   Object.fromEntries(searchParams) as IndexQuery;

or collapse destructuring and use searchParams.get()

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

const { department = query.department, location = query.location } = searchParams as IndexQuery;

Additional context

[Codemod:HandleTSIntersectionTypeToComponentReference] Invalid codemod output


⚠️⚠️ Please do not include any proprietary code in the issue. ⚠️⚠️


Codemod: HandleTSIntersectionTypeToComponentReference

1. Code before transformation (Input for codemod)

type OfProps = BaseProps & {
  of: "." | "^" | Component;
};

2. Expected code after transformation (Desired output of codemod)

// paste code here

3. Faulty code obtained after running the current version of the codemod (Actual output of codemod)

type OfProps = BaseProps & {
  of: Component;
};

Additional context

You can provide any relevant context here.


[Recipe][ImmutableJS v3 to v4]

  • Link to relevant docs, if available
  • Applicability criteria (used for intelligent recommendation and better discoverability of the recipe)
    • Package versions that contain the old pattern:
  • Ordered List of Mods (codemods, filemods, CLI commands, manual steps. this is to codify the migration):
  • A test repo

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.