├── .nvmrc ├── .eslintignore ├── .node-version ├── website ├── static │ ├── .nojekyll │ ├── CNAME │ └── img │ │ ├── ast.png │ │ ├── logo.png │ │ ├── favicon.ico │ │ ├── logo-md.png │ │ ├── TwitterBanner.png │ │ └── astexplorer.png ├── babel.config.js ├── docs │ ├── guides │ │ └── ci-integration.mdx │ ├── faq.mdx │ └── registry.mdx ├── .gitignore ├── README.md ├── src │ └── css │ │ └── custom.css ├── package.json └── sidebars.js ├── packages ├── cli │ ├── .npmignore │ ├── src │ │ ├── errors.ts │ │ ├── utils │ │ │ ├── package-names.ts │ │ │ ├── file-system.ts │ │ │ └── merge-configs.ts │ │ ├── validate.ts │ │ ├── resolvers │ │ │ └── app.ts │ │ ├── init.ts │ │ ├── prompt.ts │ │ └── list.ts │ ├── bin │ │ └── hypermod-cli.js │ ├── tsconfig.json │ ├── README.md │ └── package.json ├── core │ ├── .npmignore │ ├── src │ │ ├── index.ts │ │ └── types.ts │ ├── tsconfig.json │ └── package.json ├── cli-alias │ ├── .npmignore │ ├── src │ │ └── index.ts │ ├── bin │ │ └── codeshift-cli.js │ ├── README.md │ ├── tsconfig.json │ └── package.json ├── fetcher │ ├── .npmignore │ ├── README.md │ ├── tsconfig.json │ └── package.json ├── utils │ ├── .npmignore │ ├── README.md │ ├── src │ │ ├── index.ts │ │ ├── motions.ts │ │ ├── testing.ts │ │ ├── jsx.ts │ │ ├── nodes.ts │ │ ├── comments.ts │ │ └── nodes.spec.ts │ ├── tsconfig.json │ └── package.json ├── validator │ ├── .npmignore │ ├── README.md │ ├── tsconfig.json │ └── package.json ├── initializer │ ├── .npmignore │ ├── template │ │ ├── codemods │ │ │ └── codemod │ │ │ │ ├── motions │ │ │ │ └── .gitkeep │ │ │ │ ├── README.md │ │ │ │ ├── transform.spec.ts │ │ │ │ └── transform.ts │ │ ├── .gitignore │ │ ├── jest.config.js │ │ └── README.md │ ├── README.md │ ├── tsconfig.json │ └── package.json └── types │ ├── README.md │ ├── tsconfig.json │ ├── package.json │ ├── CHANGELOG.md │ └── src │ └── index.ts ├── community ├── memoize-one │ ├── src │ │ ├── 5.0.0 │ │ │ └── motions │ │ │ │ └── .gitkeep │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @emotion__monorepo │ ├── src │ │ ├── 11.0.0 │ │ │ ├── motions │ │ │ │ └── .gitkeep │ │ │ ├── transform.ts │ │ │ └── transform.spec.ts │ │ ├── styled-to-emotion-10 │ │ │ └── README.md │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__menu │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__tag │ ├── src │ │ ├── hypermod.config.js │ │ └── 11.0.0 │ │ │ ├── motions │ │ │ ├── rename-remove-button-text.ts │ │ │ ├── add-isRemovable-flag.ts │ │ │ └── replace-import-statements.ts │ │ │ ├── __tests__ │ │ │ └── transform.spec.ts │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__icon │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__popper │ ├── src │ │ ├── hypermod.config.js │ │ └── 5.0.0 │ │ │ ├── motions │ │ │ └── update-render-props.ts │ │ │ ├── constants.ts │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__popup │ ├── src │ │ ├── hypermod.config.js │ │ └── 1.0.0 │ │ │ ├── motions │ │ │ └── update-render-props.ts │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__range │ ├── src │ │ ├── hypermod.config.js │ │ └── 4.0.0 │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__calendar │ ├── src │ │ ├── hypermod.config.js │ │ └── 11.0.0 │ │ │ ├── transform.ts │ │ │ └── motions │ │ │ ├── remove-inner-props.ts │ │ │ └── flatten-certain-inner-props.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__checkbox │ ├── src │ │ ├── hypermod.config.js │ │ └── 12.0.0 │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__spinner │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__textarea │ ├── src │ │ ├── hypermod.config.js │ │ └── 4.0.0 │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__textfield │ ├── src │ │ ├── hypermod.config.js │ │ └── 5.0.0 │ │ │ ├── transform.ts │ │ │ └── motions │ │ │ └── remove-props.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__breadcrumbs │ ├── src │ │ ├── hypermod.config.js │ │ └── 11.0.0 │ │ │ ├── motions │ │ │ └── remove-has-separator.ts │ │ │ └── transform.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__section-message │ ├── src │ │ ├── hypermod.config.js │ │ └── 6.0.0 │ │ │ ├── constants.ts │ │ │ ├── transform.ts │ │ │ └── utils.ts │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__side-navigation │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__progress-indicator │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── javascript │ ├── src │ │ ├── remove-console-log │ │ │ ├── README.md │ │ │ ├── transform.ts │ │ │ └── transform.spec.ts │ │ ├── var-to-let │ │ │ ├── README.md │ │ │ ├── transform.spec.ts │ │ │ └── transform.ts │ │ ├── remove-debugger │ │ │ ├── README.md │ │ │ ├── transform.ts │ │ │ └── transform.spec.ts │ │ ├── sort-object-props │ │ │ ├── README.md │ │ │ └── transform.spec.ts │ │ ├── hypermod.config.js │ │ └── remove-unused-vars │ │ │ ├── README.md │ │ │ └── transform.ts │ └── package.json ├── @atlaskit__avatar │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__button │ ├── src │ │ └── hypermod.config.js │ ├── package.json │ └── CHANGELOG.md ├── @atlaskit__toggle │ ├── src │ │ ├── hypermod.config.js │ │ └── 12.0.0 │ │ │ ├── transform.ts │ │ │ └── motions │ │ │ ├── elevate-stateless.ts │ │ │ └── rename-togglestateless.ts │ ├── package.json │ └── CHANGELOG.md ├── hypermod │ ├── src │ │ ├── hypermod.config.js │ │ └── defineInlineTest-to-applyTransform │ │ │ └── README.md │ ├── CHANGELOG.md │ └── package.json └── react │ ├── src │ ├── add-react-import │ │ ├── README.md │ │ ├── transform.spec.ts │ │ └── transform.ts │ ├── error-boundaries │ │ ├── transform.ts │ │ └── README.md │ ├── remove-prop-types │ │ ├── README.md │ │ └── transform.spec.ts │ ├── remove-default-props │ │ ├── motions │ │ │ ├── removeDefaultPropsAssignment.ts │ │ │ ├── moveDefaultPropsToArrowFunctionExpression.ts │ │ │ └── moveDefaultPropsToFunctionDeclaration.ts │ │ ├── transform.ts │ │ └── README.md │ ├── use-string-literal-props │ │ ├── README.md │ │ ├── transform.spec.ts │ │ └── transform.ts │ ├── hypermod.config.js │ ├── rename-unsafe-lifecycles │ │ ├── README.md │ │ ├── transform.spec.ts │ │ └── transform.ts │ ├── sort-jsx-props │ │ ├── README.md │ │ ├── transform.spec.ts │ │ └── transform.ts │ └── create-element-to-jsx │ │ └── README.md │ ├── package.json │ └── CHANGELOG.md ├── .github ├── FUNDING.yml └── workflows │ ├── test-integration.yml │ ├── test.yml │ ├── hypermod.yml │ ├── validate.yml │ ├── release.yml │ └── documentation.yml.disabled ├── assets ├── favicon.ico ├── truck-solo.png ├── favicon-old.ico ├── logo-square.png ├── github-banner.png ├── social-banner.png ├── truck-solo-sm.png ├── truck-solo-jumbo.png └── social-banner-blank.png ├── .prettierrc.js ├── tsconfig.eslint.json ├── .changeset └── config.json ├── tsconfig.json ├── tsconfig.packages.json ├── scripts ├── initialize-preset.ts ├── initialize.ts ├── sync.ts └── cli-integration-test.js ├── LICENSE ├── jest.config.js └── .eslintrc.js /.nvmrc: -------------------------------------------------------------------------------- 1 | v20.17 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | .eslintrc.js -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | v16.13.2 2 | -------------------------------------------------------------------------------- /website/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /packages/core/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /packages/cli-alias/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /packages/fetcher/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /packages/utils/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /packages/validator/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /packages/initializer/.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | -------------------------------------------------------------------------------- /community/memoize-one/src/5.0.0/motions/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/types/README.md: -------------------------------------------------------------------------------- 1 | # @hypermod/types 2 | -------------------------------------------------------------------------------- /website/static/CNAME: -------------------------------------------------------------------------------- 1 | www.codeshiftcommunity.com 2 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/src/11.0.0/motions/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli-alias/src/index.ts: -------------------------------------------------------------------------------- 1 | import '@hypermod/cli'; 2 | -------------------------------------------------------------------------------- /packages/initializer/template/codemods/codemod/motions/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/initializer/template/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .parcel-cache 3 | -------------------------------------------------------------------------------- /packages/initializer/README.md: -------------------------------------------------------------------------------- 1 | # @hypermod/initializer 2 | 3 | Codegens Hypermod packages 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [danieldelcore] 4 | -------------------------------------------------------------------------------- /assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/favicon.ico -------------------------------------------------------------------------------- /assets/truck-solo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/truck-solo.png -------------------------------------------------------------------------------- /packages/core/src/index.ts: -------------------------------------------------------------------------------- 1 | export type { Flags } from './types'; 2 | export { run } from './runner'; 3 | -------------------------------------------------------------------------------- /assets/favicon-old.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/favicon-old.ico -------------------------------------------------------------------------------- /assets/logo-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/logo-square.png -------------------------------------------------------------------------------- /assets/github-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/github-banner.png -------------------------------------------------------------------------------- /assets/social-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/social-banner.png -------------------------------------------------------------------------------- /assets/truck-solo-sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/truck-solo-sm.png -------------------------------------------------------------------------------- /packages/utils/README.md: -------------------------------------------------------------------------------- 1 | # @hypermod/utils 2 | 3 | [Documentation](https://www.codeshiftcommunity.com/docs/utils) 4 | -------------------------------------------------------------------------------- /website/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /website/static/img/ast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/website/static/img/ast.png -------------------------------------------------------------------------------- /assets/truck-solo-jumbo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/truck-solo-jumbo.png -------------------------------------------------------------------------------- /packages/fetcher/README.md: -------------------------------------------------------------------------------- 1 | # @hypermod/fetcher 2 | 3 | Responsible for fetching codemod packages and associated files. 4 | -------------------------------------------------------------------------------- /packages/validator/README.md: -------------------------------------------------------------------------------- 1 | # @hypermod/validator 2 | 3 | Validates the file structure of the community directory 4 | -------------------------------------------------------------------------------- /website/static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/website/static/img/logo.png -------------------------------------------------------------------------------- /assets/social-banner-blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/assets/social-banner-blank.png -------------------------------------------------------------------------------- /website/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/website/static/img/favicon.ico -------------------------------------------------------------------------------- /website/static/img/logo-md.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/website/static/img/logo-md.png -------------------------------------------------------------------------------- /packages/cli/src/errors.ts: -------------------------------------------------------------------------------- 1 | export class InvalidUserInputError extends Error {} 2 | export class InvalidConfigError extends Error {} 3 | -------------------------------------------------------------------------------- /website/docs/guides/ci-integration.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | id: ci-integration 3 | title: Integrating with CI 4 | slug: /ci-integration 5 | --- 6 | -------------------------------------------------------------------------------- /website/static/img/TwitterBanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/website/static/img/TwitterBanner.png -------------------------------------------------------------------------------- /website/static/img/astexplorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hypermod-io/hypermod-community/HEAD/website/static/img/astexplorer.png -------------------------------------------------------------------------------- /packages/cli/bin/hypermod-cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const path = require('path'); 3 | 4 | require(path.join('..', 'dist', 'index.js')); 5 | -------------------------------------------------------------------------------- /packages/cli-alias/bin/codeshift-cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const path = require('path'); 3 | 4 | require(path.join('..', 'dist', 'index.js')); 5 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: true, 3 | trailingComma: 'all', 4 | singleQuote: true, 5 | printWidth: 80, 6 | tabWidth: 2, 7 | arrowParens: 'avoid', 8 | }; 9 | -------------------------------------------------------------------------------- /packages/cli/src/utils/package-names.ts: -------------------------------------------------------------------------------- 1 | export function getHypermodPackageName(packageName: string) { 2 | return `@hypermod/mod-${packageName.replace('@', '').replace('/', '__')}`; 3 | } 4 | -------------------------------------------------------------------------------- /community/memoize-one/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['alexreardon'], 3 | targets: ['memoize-one'], 4 | transforms: { '5.0.0': require('./5.0.0/transform') }, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/utils/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './imports'; 2 | export * from './nodes'; 3 | export * from './jsx'; 4 | export * from './motions'; 5 | export * from './comments'; 6 | export * from './testing'; 7 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": [ 4 | "packages/**/*.ts", 5 | "community/**/*.ts", 6 | "community/**/hypermod.config.js", 7 | "scripts" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /community/@atlaskit__menu/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/menu'], 4 | transforms: { 5 | '0.7.0': require('./0.7.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/tag'], 4 | transforms: { 5 | '11.0.0': require('./11.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__icon/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/icon'], 4 | transforms: { 5 | '21.2.0': require('./21.2.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__popper/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/popper'], 4 | transforms: { 5 | '5.0.0': require('./5.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__popup/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/popup'], 4 | transforms: { 5 | '1.0.0': require('./1.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__range/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/range'], 4 | transforms: { 5 | '4.0.0': require('./4.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__calendar/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/calendar'], 4 | transforms: { 5 | '11.0.0': require('./11.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__checkbox/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/checkbox'], 4 | transforms: { 5 | '12.0.0': require('./12.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__spinner/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/spinner'], 4 | transforms: { 5 | '13.0.0': require('./13.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__textarea/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/textarea'], 4 | transforms: { 5 | '4.0.0': require('./4.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__textfield/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/textfield'], 4 | transforms: { 5 | '5.0.0': require('./5.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"] 9 | } 10 | -------------------------------------------------------------------------------- /packages/utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"] 9 | } 10 | -------------------------------------------------------------------------------- /community/@atlaskit__breadcrumbs/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/breadcrumbs'], 4 | transforms: { 5 | '11.0.0': require('./11.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__section-message/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/section-message'], 4 | transforms: { 5 | '6.0.0': require('./6.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__side-navigation/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/side-navigation'], 4 | transforms: { 5 | '0.8.0': require('./0.8.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/@atlaskit__progress-indicator/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/progress-indicator'], 4 | transforms: { 5 | '9.0.0': require('./9.0.0/transform'), 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /community/javascript/src/remove-console-log/README.md: -------------------------------------------------------------------------------- 1 | # remove-console-log 2 | 3 | Removes all `console.log` statements. 4 | 5 | ```js 6 | /* INPUT */ 7 | console.log('hello world'); 8 | foo('bar'); 9 | 10 | /* OUTPUT */ 11 | foo('bar'); 12 | ``` 13 | -------------------------------------------------------------------------------- /community/@atlaskit__avatar/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/avatar'], 4 | transforms: { 5 | '18.0.0': require('./18.0.0/transform'), 6 | '19.0.0': require('./19.0.0/transform'), 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /community/@atlaskit__button/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/button'], 4 | transforms: { 5 | '15.0.0': require('./15.0.0/transform'), 6 | '15.1.1': require('./15.1.1/transform'), 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /community/@atlaskit__toggle/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: ['@atlaskit/toggle'], 4 | transforms: { 5 | '11.0.0': require('./11.0.0/transform'), 6 | '12.0.0': require('./12.0.0/transform'), 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"], 9 | "references": [{ "path": "../types" }] 10 | } 11 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@1.0.1/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "access": "public", 6 | "baseBranch": "main", 7 | "fixed": [["@hypermod/cli", "@codeshift/cli"]] 8 | } 9 | -------------------------------------------------------------------------------- /packages/fetcher/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"], 9 | "references": [{ "path": "../types" }] 10 | } 11 | -------------------------------------------------------------------------------- /packages/initializer/template/codemods/codemod/README.md: -------------------------------------------------------------------------------- 1 | # <% packageName %><% seperator %><% transform %> 2 | 3 | Codemods for <% packageName %><% seperator %><% transform %> 4 | 5 | ```js 6 | /* INPUT */ 7 | var foo = 'foo'; 8 | 9 | /* OUTPUT */ 10 | let foo = 'foo'; 11 | ``` 12 | -------------------------------------------------------------------------------- /packages/cli/src/validate.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | 3 | import { isValidConfigAtPath } from '@hypermod/validator'; 4 | 5 | export default async function validate(targetPath = '.') { 6 | await isValidConfigAtPath(targetPath); 7 | 8 | console.log(chalk.green('Valid ✅')); 9 | } 10 | -------------------------------------------------------------------------------- /packages/validator/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"], 9 | "references": [{ "path": "../fetcher" }, { "path": "../types" }] 10 | } 11 | -------------------------------------------------------------------------------- /community/hypermod/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: [], 3 | targets: [], 4 | description: 'Codemods for hypermod', 5 | transforms: {}, 6 | 7 | presets: { 8 | 'defineInlineTest-to-applyTransform': require('./defineInlineTest-to-applyTransform/transform'), 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /community/javascript/src/var-to-let/README.md: -------------------------------------------------------------------------------- 1 | # var-to-let 2 | 3 | Replace all `var` calls to use `let`. 4 | 5 | _Credit_: [https://github.com/JamieMason/codemods](https://github.com/JamieMason/codemods) 6 | 7 | ```js 8 | /* INPUT */ 9 | var foo = 'foo'; 10 | 11 | /* OUTPUT */ 12 | let foo = 'foo'; 13 | ``` 14 | -------------------------------------------------------------------------------- /packages/types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/types", 3 | "version": "0.3.0", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/types" 9 | } 10 | -------------------------------------------------------------------------------- /packages/initializer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"], 9 | "exclude": ["./template/*"], 10 | "references": [{ "path": "../types" }, { "path": "../utils" }] 11 | } 12 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /community/javascript/src/remove-debugger/README.md: -------------------------------------------------------------------------------- 1 | # remove-debugger 2 | 3 | Removes all `debugger` statements. 4 | 5 | _Credit_: [https://github.com/JamieMason/codemods](https://github.com/JamieMason/codemods) 6 | 7 | ```js 8 | /* INPUT */ 9 | console.log('hello world'); 10 | debugger; 11 | 12 | /* OUTPUT */ 13 | console.log('hello world'); 14 | ``` 15 | -------------------------------------------------------------------------------- /packages/initializer/template/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transform: { 3 | '^.+\\.ts$': 'ts-jest', 4 | }, 5 | moduleFileExtensions: ['ts', 'tsx', 'js'], 6 | testRegex: '^.+\\.spec\\.(tsx|ts|js)$', 7 | globals: { 8 | 'ts-jest': { 9 | tsconfig: 'tsconfig.json', 10 | }, 11 | }, 12 | testPathIgnorePatterns: ['/node_modules/'], 13 | }; 14 | -------------------------------------------------------------------------------- /packages/utils/src/motions.ts: -------------------------------------------------------------------------------- 1 | import core from 'jscodeshift'; 2 | 3 | interface MotionCallback { 4 | (j: core.JSCodeshift, source: core.Collection): void; 5 | } 6 | 7 | export function applyMotions( 8 | j: core.JSCodeshift, 9 | source: ReturnType, 10 | motions: MotionCallback[], 11 | ) { 12 | motions.forEach(motionTransformer => motionTransformer(j, source)); 13 | } 14 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "skipLibCheck": true, 5 | "moduleResolution": "node", 6 | "target": "es6", 7 | "module": "CommonJS", 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "lib": ["ESNext", "scripthost"] 11 | }, 12 | "include": ["packages/**/*", "community/**/*", "scripts"], 13 | "exclude": ["./plugin_packages"] 14 | } 15 | -------------------------------------------------------------------------------- /community/react/src/add-react-import/README.md: -------------------------------------------------------------------------------- 1 | # add-react-import 2 | 3 | Import React if it is missing from a file which uses JSX. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```jsx 8 | /* INPUT */ 9 | export const Component = () =>
10 | 11 | /* OUTPUT */ 12 | import React from "react"; 13 | export const Component = () =>
14 | ``` 15 | -------------------------------------------------------------------------------- /community/javascript/src/sort-object-props/README.md: -------------------------------------------------------------------------------- 1 | # sort-object-props 2 | 3 | Sort members of Object Literals alphabetically. 4 | 5 | _Credit_: [https://github.com/JamieMason/codemods](https://github.com/JamieMason/codemods) 6 | 7 | ```js 8 | /* INPUT */ 9 | const players = { messi: true, bergkamp: true, ginola: true }; 10 | 11 | /* OUTPUT */ 12 | const players = { bergkamp: true, ginola: true, messi: true }; 13 | ``` 14 | -------------------------------------------------------------------------------- /packages/cli-alias/README.md: -------------------------------------------------------------------------------- 1 | # @codeshift/cli 2 | 3 | **THIS PACKAGE IS DEPRECATED IN FAVOUR OF [@hypermod/cli](https://www.codeshiftcommunity.com/docs/cli)** 4 | 5 | No API changes were performed as part of this change, use `@hypermod/cli` as a direct replacement the package has simply been renamed. 6 | 7 | This package will continue to exist as a way for existing users to continue to receive updates **but will be removed in the future**. 8 | -------------------------------------------------------------------------------- /packages/utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/utils", 3 | "version": "0.7.1", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/utils", 9 | "engines": { 10 | "node": ">=20.17" 11 | }, 12 | "dependencies": { 13 | "jscodeshift": "^17.3.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/src/styled-to-emotion-10/README.md: -------------------------------------------------------------------------------- 1 | # styled-to-emotion 2 | 3 | Automatically migrates from styled-components to emotion v10 4 | 5 | ```jsx 6 | /* INPUT */ 7 | import styled, { css, ThemeProvider, withTheme } from 'styled-components'; 8 | 9 | /* OUTPUT */ 10 | import { css } from '@emotion/core'; 11 | import styled from '@emotion/styled'; 12 | import { ThemeProvider, withTheme } from 'emotion-theming'; 13 | ``` 14 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"], 9 | "references": [ 10 | { "path": "../types" }, 11 | { "path": "../core" }, 12 | { "path": "../fetcher" }, 13 | { "path": "../validator" }, 14 | { "path": "../initializer" }, 15 | { "path": "../fetcher" } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /packages/cli-alias/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.packages.json", 3 | "compilerOptions": { 4 | "rootDir": "src", 5 | "outDir": "dist", 6 | "baseUrl": "." 7 | }, 8 | "include": ["src"], 9 | "references": [ 10 | { "path": "../types" }, 11 | { "path": "../core" }, 12 | { "path": "../fetcher" }, 13 | { "path": "../validator" }, 14 | { "path": "../initializer" }, 15 | { "path": "../fetcher" } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /community/javascript/src/var-to-let/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('javascript#var-to-let transform', () => { 5 | it('should replace var with let', async () => { 6 | const result = await applyTransform(transformer, `var foo = 'foo'`, { 7 | parser: 'tsx', 8 | }); 9 | 10 | expect(result).toMatchInlineSnapshot(`"let foo = 'foo';"`); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /community/react/src/error-boundaries/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | return j(file.source) 9 | .find(j.Identifier) 10 | .forEach(path => { 11 | if (path.node.name === 'unstable_handleError') { 12 | j(path).replaceWith(j.identifier('componentDidCatch')); 13 | } 14 | }) 15 | .toSource(options.printOptions); 16 | } 17 | -------------------------------------------------------------------------------- /community/javascript/src/remove-debugger/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const source = j(file.source); 9 | const debuggerStatements = source.find(j.DebuggerStatement); 10 | 11 | if (debuggerStatements.length === 0) { 12 | return file.source; 13 | } 14 | 15 | debuggerStatements.remove(); 16 | 17 | return source.toSource(options.printOptions); 18 | } 19 | -------------------------------------------------------------------------------- /community/javascript/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: [], 4 | description: 'Codemods for javascript', 5 | transforms: {}, 6 | presets: { 7 | 'remove-console-log': require('./remove-console-log/transform'), 8 | 'remove-debugger': require('./remove-debugger/transform'), 9 | 'sort-object-props': require('./sort-object-props/transform'), 10 | 'var-to-let': require('./var-to-let/transform'), 11 | 'remove-unused-vars': require('./remove-unused-vars/transform'), 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /community/react/src/remove-prop-types/README.md: -------------------------------------------------------------------------------- 1 | # remove-prop-types 2 | 3 | Remove use of React PropTypes. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```jsx 8 | /* INPUT */ 9 | import React from 'react' 10 | import PropTypes from 'prop-types' 11 | 12 | export const Greet = ({ name }) => Hi {name} 13 | Greet.propTypes = { name: PropTypes.string } 14 | 15 | /* OUTPUT */ 16 | import React from 'react' 17 | 18 | export const Greet = ({ name }) => Hi {name} 19 | ``` 20 | -------------------------------------------------------------------------------- /community/javascript/src/remove-unused-vars/README.md: -------------------------------------------------------------------------------- 1 | # javascript#remove-unused-vars 2 | 3 | Codemods for javascript#remove-unused-vars 4 | 5 | Detects and removes unused variables in JavaScript code. 6 | 7 | _Credit:_ [https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-unused-variables](https://github.com/coderaiser/putout/tree/master/packages/plugin-remove-unused-variables#readme) 8 | 9 | ```js 10 | /* INPUT */ 11 | const x = 1; 12 | const y = 2; 13 | console.log(y); 14 | 15 | /* OUTPUT */ 16 | const y = 2; 17 | console.log(y); 18 | ``` 19 | -------------------------------------------------------------------------------- /packages/initializer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/initializer", 3 | "version": "0.8.1", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/initializer", 9 | "dependencies": { 10 | "@hypermod/cli": "*", 11 | "@hypermod/utils": "*", 12 | "fs-extra": "^9.1.0", 13 | "recast": "^0.20.4", 14 | "semver": "^7.3.5" 15 | }, 16 | "engines": { 17 | "node": ">=20.17" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/test-integration.yml: -------------------------------------------------------------------------------- 1 | name: CLI Integration Test 2 | 3 | on: 4 | schedule: 5 | - cron: '0 3 * * 1-5' 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | strategy: 13 | matrix: 14 | node-version: [20.17.*] 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Use Node.js ${{ matrix.node-version }} 19 | uses: actions/setup-node@v1 20 | with: 21 | node-version: ${{ matrix.node-version }} 22 | - run: node scripts/cli-integration-test.js 23 | -------------------------------------------------------------------------------- /packages/initializer/template/codemods/codemod/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('<% packageName %><% seperator %><% transform %> transform', () => { 5 | it('should transform correctly', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | import foo from '<% packageName %>'; 10 | console.log(foo); 11 | `, 12 | { parser: 'tsx' }, 13 | ); 14 | 15 | expect(result).toMatchInlineSnapshot(); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /packages/validator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/validator", 3 | "version": "0.8.0", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/validator", 9 | "dependencies": { 10 | "@hypermod/fetcher": "^0.11.0", 11 | "@hypermod/types": "^0.3.0", 12 | "semver": "^7.3.5" 13 | }, 14 | "devDependencies": { 15 | "@types/lodash": "^4.14.176" 16 | }, 17 | "engines": { 18 | "node": ">=20.17" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /community/javascript/src/var-to-let/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const source = j(file.source); 9 | 10 | source.find(j.VariableDeclaration, { kind: 'var' }).forEach(p => { 11 | const letStatement = j.variableDeclaration('let', p.value.declarations); 12 | letStatement.comments = p.value.comments; 13 | return j(p).replaceWith(letStatement); 14 | }); 15 | 16 | return source.toSource(options.printOptions); 17 | } 18 | -------------------------------------------------------------------------------- /community/react/src/add-react-import/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('react#add-react-import transform', () => { 5 | it('insert react import when JSX is used', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | `export const Component = () =>
`, 9 | { parser: 'tsx' }, 10 | ); 11 | 12 | expect(result).toMatchInlineSnapshot(` 13 | import React from "react"; export const Component = () => 14 |
15 | `); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | node-version: [20.17.*] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v1 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | - run: yarn install --frozen-lockfile 24 | - run: yarn build 25 | - run: yarn test 26 | env: 27 | CI: true 28 | -------------------------------------------------------------------------------- /community/react/src/remove-default-props/motions/removeDefaultPropsAssignment.ts: -------------------------------------------------------------------------------- 1 | import { JSCodeshift } from 'jscodeshift'; 2 | import { Collection } from 'jscodeshift/src/Collection'; 3 | 4 | export function removeDefaultPropsAssignment( 5 | j: JSCodeshift, 6 | source: Collection, 7 | ) { 8 | const removePath = (path: any) => j(path).remove(); 9 | const isAssigningDefaultProps = (e: any) => 10 | e.node.left && 11 | e.node.left.property && 12 | e.node.left.property.name === 'defaultProps'; 13 | 14 | return source 15 | .find(j.AssignmentExpression) 16 | .filter(isAssigningDefaultProps) 17 | .forEach(removePath); 18 | } 19 | -------------------------------------------------------------------------------- /website/docs/faq.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | id: faq 3 | title: FAQ 4 | slug: /faq 5 | --- 6 | 7 | ## Why jscodeshift? 8 | 9 | By default, CodeshiftCommunity uses JSCodeshift because it is the most commonly used AST transformation library in the community. Many codemods are already written with JSCodeshift, and our goal is to consolidate these codemods in one place. 10 | 11 | However, we are compatible with any JS-based AST transformation library, such as **Babel**, **PostCSS**, and **esprima**. We also provide guides for using non-JSCodeshift libraries, and we aim to support the transformation of any target file, including but not limited to JS, TS, CSS, LESS, Sass, and JSON. 12 | -------------------------------------------------------------------------------- /community/@atlaskit__section-message/src/6.0.0/constants.ts: -------------------------------------------------------------------------------- 1 | export const SECTION_MESSAGE_PACKAGE_NAME = '@atlaskit/section-message'; 2 | export const APPEARANCE_PROP_NAME = 'appearance'; 3 | export const APPEARANCE_OLD_TO_NEW_MAPPING: { 4 | [index: string]: string; 5 | } = { 6 | info: 'information', 7 | confirmation: 'success', 8 | change: 'discovery', 9 | }; 10 | export const SECTION_MESSAGE_ACTION_PACKAGE_NAME = `${SECTION_MESSAGE_PACKAGE_NAME}/section-message-action`; 11 | export const SECTION_MESSAGE_ACTION_COMPONENT_NAME = 'SectionMessageAction'; 12 | export const LINK_COMPONENT_PROP_NAME = 'linkComponent'; 13 | export const ACTIONS_PROP_NAME = 'actions'; 14 | -------------------------------------------------------------------------------- /packages/cli/src/resolvers/app.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | import { fetchHmPkg } from '../fetchers/app'; 4 | 5 | export async function resolveAppTransforms(pkg: string, dir: string) { 6 | const transformMeta = await fetchHmPkg(pkg, dir); 7 | 8 | // find entry point 9 | const entryPoint = transformMeta.transform.sources.find( 10 | source => 11 | source.name.includes('transform.ts') || 12 | source.name.includes('transform.js'), 13 | ); 14 | 15 | if (!entryPoint) { 16 | throw new Error( 17 | `Unable to locate transform entry point in package: ${pkg}`, 18 | ); 19 | } 20 | 21 | return path.join(dir, pkg, entryPoint.name); 22 | } 23 | -------------------------------------------------------------------------------- /community/react/src/error-boundaries/README.md: -------------------------------------------------------------------------------- 1 | # react#error-boundaries 2 | 3 | Renames the experimental `unstable_handleError` lifecycle hook to `componentDidCatch`. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```js 8 | /* INPUT */ 9 | import React from "react"; 10 | 11 | export class ComponentOne extends React.Component { 12 | unstable_handleError(error) {} 13 | render() { 14 | return
; 15 | } 16 | } 17 | 18 | /* OUTPUT */ 19 | import React from "react"; 20 | 21 | export class ComponentOne extends React.Component { 22 | componentDidCatch(error) {} 23 | render() { 24 | return
; 25 | } 26 | } 27 | ``` 28 | -------------------------------------------------------------------------------- /community/hypermod/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-hypermod 2 | 3 | ## 0.1.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.1.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.1.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.0.1 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | -------------------------------------------------------------------------------- /packages/cli-alias/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codeshift/cli", 3 | "version": "0.27.3", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/cli-alias", 9 | "bin": { 10 | "codeshift": "./bin/codeshift-cli.js", 11 | "codeshift-cli": "./bin/codeshift-cli.js" 12 | }, 13 | "scripts": { 14 | "start": "./bin/codeshift-cli.js", 15 | "start:dev": "ts-node src/index.ts" 16 | }, 17 | "dependencies": { 18 | "@hypermod/cli": "^0.27.3", 19 | "ts-node": "^10.9.1" 20 | }, 21 | "engines": { 22 | "node": ">=20.17" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/hypermod.yml: -------------------------------------------------------------------------------- 1 | name: Hypermod 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | deploymentId: 7 | description: "The deployment ID containing instructions to apply on a repository" 8 | deploymentKey: 9 | description: "The deployment key to authenticate the request" 10 | jobs: 11 | receive_hypermod_event: 12 | permissions: write-all 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Run Hypermod CLI 17 | uses: hypermod-io/action@v1 18 | with: 19 | deploymentId: ${{ inputs.deploymentId }} 20 | deploymentKey: ${{ inputs.deploymentKey }} 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /community/@atlaskit__toggle/src/12.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { hasImportDeclaration } from '@hypermod/utils'; 3 | 4 | import elevateStateless from './motions/elevate-stateless'; 5 | import renameToggleStateless from './motions/rename-togglestateless'; 6 | 7 | export default function transformer( 8 | fileInfo: FileInfo, 9 | { jscodeshift: j }: API, 10 | options: Options, 11 | ) { 12 | const source = j(fileInfo.source); 13 | 14 | if (!hasImportDeclaration(j, source, '@atlaskit/toggle')) { 15 | return fileInfo.source; 16 | } 17 | 18 | elevateStateless(j, source); 19 | renameToggleStateless(j, source); 20 | 21 | return source.toSource(options.printOptions); 22 | } 23 | -------------------------------------------------------------------------------- /community/react/src/use-string-literal-props/README.md: -------------------------------------------------------------------------------- 1 | # use-string-literal-props 2 | 3 | Convert JSX props which are expressions for a string literal, into just a string literal. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```jsx 8 | /* INPUT */ 9 | const SomeComponent = () => ( 10 | 15 | ); 16 | 17 | /* OUTPUT */ 18 | const SomeComponent = () => ( 19 | 24 | ); 25 | ``` 26 | -------------------------------------------------------------------------------- /tsconfig.packages.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "composite": true 5 | }, 6 | // https://github.com/microsoft/TypeScript/issues/55717#issuecomment-1715003394 7 | "files": [], 8 | "include": [], 9 | "exclude": [ 10 | "./community", 11 | "./scripts", 12 | "__tests__", 13 | "**/*.test*", 14 | "**/*.spec*" 15 | ], 16 | "references": [ 17 | { "path": "./packages/cli" }, 18 | { "path": "./packages/cli-alias" }, 19 | { "path": "./packages/core" }, 20 | { "path": "./packages/validator" }, 21 | { "path": "./packages/initializer" }, 22 | { "path": "./packages/fetcher" }, 23 | { "path": "./packages/utils" }, 24 | { "path": "./packages/types" } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /community/react/src/remove-prop-types/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('react@#remove-prop-types transform', () => { 5 | it('should remove propTypes', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | import React from 'react' 10 | import PropTypes from 'prop-types' 11 | 12 | export const Greet = ({ name }) => Hi {name} 13 | Greet.propTypes = { name: PropTypes.string } 14 | 15 | `, 16 | { parser: 'tsx' }, 17 | ); 18 | 19 | expect(result).toMatchInlineSnapshot(` 20 | import React from 'react' export const Greet = ({ name }) => 21 | Hi {name} 22 | `); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /community/react/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: [], 3 | targets: ['react', 'react-dom'], 4 | description: 'Codemods for react', 5 | transforms: {}, 6 | presets: { 7 | 'add-react-import': require('./add-react-import/transform'), 8 | 'create-element-to-jsx': require('./create-element-to-jsx/transform'), 9 | 'error-boundaries': require('./error-boundaries/transform'), 10 | 'remove-default-props': require('./remove-default-props/transform'), 11 | 'remove-prop-types': require('./remove-prop-types/transform'), 12 | 'rename-unsafe-lifecycles': require('./rename-unsafe-lifecycles/transform'), 13 | 'sort-jsx-props': require('./sort-jsx-props/transform'), 14 | 'use-string-literal-props': require('./use-string-literal-props/transform'), 15 | }, 16 | }; 17 | -------------------------------------------------------------------------------- /community/react/src/rename-unsafe-lifecycles/README.md: -------------------------------------------------------------------------------- 1 | # react#rename-unsafe-lifecycles 2 | 3 | Adds `UNSAFE_` prefix for deprecated lifecycle hooks. (For more information about this codemod, see [React RFC #6](https://github.com/reactjs/rfcs/pull/6)) 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```js 8 | /* INPUT */ 9 | class ExampleComponent extends React.Component { 10 | componentWillMount() { } 11 | componentWillUpdate(nextProps, nextState) { } 12 | componentWillReceiveProps(nextProps) { } 13 | } 14 | 15 | /* OUTPUT */ 16 | class ExampleComponent extends React.Component { 17 | UNSAFE_componentWillMount() { } 18 | UNSAFE_componentWillUpdate(nextProps, nextState) { } 19 | UNSAFE_componentWillReceiveProps(nextProps) { } 20 | } 21 | ``` 22 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/src/hypermod.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | maintainers: ['danieldelcore'], 3 | targets: [ 4 | '@emotion/babel-plugin', 5 | '@emotion/core', 6 | '@emotion/css', 7 | '@emotion/css/create-instance', 8 | '@emotion/eslint-plugin', 9 | '@emotion/jest', 10 | '@emotion/react', 11 | '@emotion/server', 12 | '@emotion/server/create-instance', 13 | 'babel-plugin-emotion', 14 | 'create-emotion-server', 15 | 'create-emotion', 16 | 'emotion-server', 17 | 'emotion-theming', 18 | 'emotion', 19 | 'eslint-plugin-emotion', 20 | 'jest-emotion', 21 | ], 22 | transforms: { 23 | '11.0.0': require('./11.0.0/transform'), 24 | }, 25 | presets: { 26 | 'styled-to-emotion-10': require('./styled-to-emotion-10/transform'), 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /community/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-react", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/react" 27 | } 28 | -------------------------------------------------------------------------------- /community/react/src/remove-default-props/transform.ts: -------------------------------------------------------------------------------- 1 | import { FileInfo, API } from 'jscodeshift'; 2 | import { applyMotions } from '@hypermod/utils'; 3 | 4 | import { moveDefaultPropsToArrowFunctionExpression } from './motions/moveDefaultPropsToArrowFunctionExpression'; 5 | import { moveDefaultPropsToFunctionDeclaration } from './motions/moveDefaultPropsToFunctionDeclaration'; 6 | import { removeDefaultPropsAssignment } from './motions/removeDefaultPropsAssignment'; 7 | 8 | export default function transformer(file: FileInfo, api: API) { 9 | const j = api.jscodeshift; 10 | const source = j(file.source); 11 | 12 | applyMotions(j, source, [ 13 | moveDefaultPropsToFunctionDeclaration, 14 | moveDefaultPropsToArrowFunctionExpression, 15 | removeDefaultPropsAssignment, 16 | ]); 17 | 18 | return source.toSource(); 19 | } 20 | -------------------------------------------------------------------------------- /community/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-javascript", 3 | "version": "0.5.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/javascript" 27 | } 28 | -------------------------------------------------------------------------------- /community/memoize-one/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-memoize-one", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/memoize-one" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__tag", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__tag" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__icon/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__icon", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__icon" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__menu/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__menu", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__menu" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__popup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__popup", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__popup" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__range/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__range", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__range" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__avatar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__avatar", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__avatar" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__button/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__button", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__button" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__popper/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__popper", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__popper" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__spinner/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__spinner", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__spinner" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__toggle/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__toggle", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__toggle" 27 | } 28 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-emotion__monorepo", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@emotion__monorepo" 27 | } 28 | -------------------------------------------------------------------------------- /community/hypermod/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-hypermod", 3 | "version": "0.1.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "parcel": "^2.8.3", 23 | "prettier": "^2.0.0", 24 | "ts-jest": "^29.2.5", 25 | "typescript": "^5.2.2" 26 | }, 27 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/hypermod" 28 | } 29 | -------------------------------------------------------------------------------- /community/@atlaskit__calendar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__calendar", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__calendar" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__checkbox/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__checkbox", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__checkbox" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__textarea/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__textarea", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__textarea" 27 | } 28 | -------------------------------------------------------------------------------- /community/react/src/remove-default-props/README.md: -------------------------------------------------------------------------------- 1 | # remove-default-props 2 | 3 | Remove use of React defaultProps. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```jsx 8 | /* INPUT */ 9 | import React from 'react'; 10 | 11 | export const Greet = ({ name }) => Hi {name}; 12 | Greet.defaultProps = { text: 'Stranger' }; 13 | 14 | /* OUTPUT */ 15 | import React from 'react'; 16 | 17 | export const Greet = ({ name, text = 'Stranger' }) => Hi {name}; 18 | ``` 19 | 20 | ```jsx 21 | /* INPUT */ 22 | import React from 'react'; 23 | 24 | export const Greet = (props) => Hi {name}; 25 | Greet.defaultProps = { text: 'Stranger' }; 26 | 27 | /* OUTPUT */ 28 | import React from 'react'; 29 | 30 | export const Greet = ({ ...props, text = 'Stranger' }) => Hi {name}; 31 | ``` -------------------------------------------------------------------------------- /community/react/src/sort-jsx-props/README.md: -------------------------------------------------------------------------------- 1 | # sort-jsx-props 2 | 3 | Sort props of JSX Components alphabetically. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```jsx 8 | /* INPUT */ 9 | 14 | 15 | /* OUTPUT */ 16 | 21 | ``` 22 | 23 | If a component uses spread props all properties before and after will be sorted, leaving the spread operation in place. 24 | 25 | ```jsx 26 | /* INPUT */ 27 | 34 | 35 | /* OUTPUT */ 36 | 43 | ``` 44 | -------------------------------------------------------------------------------- /community/@atlaskit__textfield/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__textfield", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__textfield" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__breadcrumbs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__breadcrumbs", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__breadcrumbs" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/src/11.0.0/motions/rename-remove-button-text.ts: -------------------------------------------------------------------------------- 1 | import core from 'jscodeshift'; 2 | import { 3 | getJSXAttributes, 4 | getDefaultImportSpecifierName, 5 | } from '@hypermod/utils'; 6 | 7 | export const renameRemoveButtonText = (j: core.JSCodeshift, source: any) => { 8 | const defaultSpecifier = getDefaultImportSpecifierName( 9 | j, 10 | source, 11 | '@atlaskit/tag', 12 | ); 13 | 14 | if (!defaultSpecifier) return; 15 | 16 | source 17 | .findJSXElements(defaultSpecifier) 18 | .forEach((element: core.ASTPath) => { 19 | getJSXAttributes(j, element, 'removeButtonText').forEach(attribute => { 20 | j(attribute).replaceWith( 21 | j.jsxAttribute( 22 | j.jsxIdentifier('removeButtonLabel'), 23 | attribute.node.value, 24 | ), 25 | ); 26 | }); 27 | }); 28 | }; 29 | -------------------------------------------------------------------------------- /community/@atlaskit__section-message/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__section-message", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__section-message" 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__side-navigation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__side-navigation", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__side-navigation" 27 | } 28 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. 4 | 5 | ## Installation 6 | 7 | ```console 8 | yarn install 9 | ``` 10 | 11 | ## Local Development 12 | 13 | ```console 14 | yarn start 15 | ``` 16 | 17 | This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ## Build 20 | 21 | ```console 22 | yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ## Deployment 28 | 29 | ```console 30 | GIT_USER= USE_SSH=true yarn deploy 31 | ``` 32 | 33 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 34 | -------------------------------------------------------------------------------- /community/@atlaskit__progress-indicator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/mod-atlaskit__progress-indicator", 3 | "version": "0.4.2", 4 | "license": "MIT", 5 | "source": "src/hypermod.config.js", 6 | "main": "dist/hypermod.config.js", 7 | "scripts": { 8 | "dev": "hypermod", 9 | "build": "parcel build", 10 | "test": "jest --watch", 11 | "validate": "hypermod validate ." 12 | }, 13 | "dependencies": { 14 | "@hypermod/utils": "^0.7.1", 15 | "jscodeshift": "^17.3.0" 16 | }, 17 | "devDependencies": { 18 | "@hypermod/cli": "^0.27.2", 19 | "@types/jest": "^29.0.0", 20 | "@types/node": "^16.11.0", 21 | "jest": "^29.0.0", 22 | "prettier": "^2.0.0", 23 | "ts-jest": "^29.2.5", 24 | "typescript": "^5.2.2" 25 | }, 26 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/community/@atlaskit__progress-indicator" 27 | } 28 | -------------------------------------------------------------------------------- /community/javascript/src/remove-console-log/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const source = j(file.source); 9 | const consoleLogStatements = source.find(j.ExpressionStatement, { 10 | expression: { 11 | type: 'CallExpression', 12 | callee: { 13 | type: 'MemberExpression', 14 | object: { 15 | type: 'Identifier', 16 | name: 'console', 17 | }, 18 | property: { 19 | type: 'Identifier', 20 | name: 'log', 21 | }, 22 | }, 23 | }, 24 | }); 25 | 26 | if (consoleLogStatements.length === 0) { 27 | return file.source; 28 | } 29 | 30 | consoleLogStatements.remove(); 31 | 32 | return source.toSource(options.printOptions); 33 | } 34 | -------------------------------------------------------------------------------- /packages/cli/README.md: -------------------------------------------------------------------------------- 1 | # @hypermod/cli 2 | 3 | To download and run codemods, we provide a CLI tool called @hypermod/cli. 4 | 5 | `@hypermod/cli` is responsible for running the provided transform against your entire codebase. Under the hood, it is a wrapper of jscodeshift's CLI, which provides additional functionality. 6 | 7 | - Ability to run community codemods hosted on npm 8 | - Runs versioned codemods in sequence 9 | - Always runs the latest version of a codemod 10 | - The CLI allows you to run transforms either from the the [public registry](https://www.codeshiftcommunity.com/docs/registry) or on your local machine as per the original implementation of jscodeshift 11 | 12 | _Note:_ Codemods are designed to do the heavy lifting, but they may not be perfect, so some manual work may still be required in order to successfully migrate. 13 | 14 | [Documentation](https://www.codeshiftcommunity.com/docs/cli) 15 | -------------------------------------------------------------------------------- /community/@atlaskit__range/src/4.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { 3 | getDefaultImportSpecifierName, 4 | getJSXAttributes, 5 | } from '@hypermod/utils'; 6 | 7 | export default function transformer( 8 | fileInfo: FileInfo, 9 | { jscodeshift: j }: API, 10 | options: Options, 11 | ) { 12 | const source = j(fileInfo.source); 13 | 14 | const defaultSpecifier = getDefaultImportSpecifierName( 15 | j, 16 | source, 17 | '@atlaskit/range', 18 | ); 19 | 20 | if (!defaultSpecifier) return fileInfo.source; 21 | 22 | source.findJSXElements(defaultSpecifier).forEach(element => { 23 | getJSXAttributes(j, element, 'inputRef').forEach(attribute => { 24 | j(attribute).replaceWith( 25 | j.jsxAttribute(j.jsxIdentifier('ref'), attribute.node.value), 26 | ); 27 | }); 28 | }); 29 | 30 | return source.toSource(options.printOptions); 31 | } 32 | -------------------------------------------------------------------------------- /community/react/src/rename-unsafe-lifecycles/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('react#rename-unsafe-lifecycles transform', () => { 5 | it('should transform correctly', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | class ExampleComponent extends React.Component { 10 | componentWillMount() { } 11 | componentWillUpdate(nextProps, nextState) { } 12 | componentWillReceiveProps(nextProps) { } 13 | } 14 | `, 15 | { parser: 'tsx' }, 16 | ); 17 | 18 | expect(result).toMatchInlineSnapshot(` 19 | "class ExampleComponent extends React.Component { 20 | UNSAFE_componentWillMount() { } 21 | UNSAFE_componentWillUpdate(nextProps, nextState) { } 22 | UNSAFE_componentWillReceiveProps(nextProps) { } 23 | }" 24 | `); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /community/@atlaskit__textarea/src/4.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { 3 | getDefaultImportSpecifierName, 4 | getJSXAttributes, 5 | } from '@hypermod/utils'; 6 | 7 | export default function transformer( 8 | fileInfo: FileInfo, 9 | { jscodeshift: j }: API, 10 | options: Options, 11 | ) { 12 | const source = j(fileInfo.source); 13 | 14 | const defaultSpecifier = getDefaultImportSpecifierName( 15 | j, 16 | source, 17 | '@atlaskit/textarea', 18 | ); 19 | 20 | if (!defaultSpecifier) return fileInfo.source; 21 | 22 | source.findJSXElements(defaultSpecifier).forEach(element => { 23 | getJSXAttributes(j, element, 'forwardedRef').forEach(attribute => { 24 | j(attribute).replaceWith( 25 | j.jsxAttribute(j.jsxIdentifier('ref'), attribute.node.value), 26 | ); 27 | }); 28 | }); 29 | 30 | return source.toSource(options.printOptions); 31 | } 32 | -------------------------------------------------------------------------------- /packages/utils/src/testing.ts: -------------------------------------------------------------------------------- 1 | import jscodeshift, { FileInfo } from 'jscodeshift'; 2 | 3 | type Parser = 'babel' | 'babylon' | 'flow' | 'ts' | 'tsx'; 4 | 5 | interface Options { 6 | parser?: Parser; 7 | } 8 | 9 | export async function applyTransform( 10 | transform: any, 11 | input: string | FileInfo, 12 | options: Options = { 13 | parser: 'babel', 14 | }, 15 | ) { 16 | // Handle ES6 modules using default export for the transform 17 | const transformer = transform.default ? transform.default : transform; 18 | 19 | const file = typeof input === 'string' ? { source: input } : input; 20 | 21 | const output = await transformer( 22 | file, 23 | { 24 | jscodeshift: jscodeshift.withParser(options.parser as string), 25 | // eslint-disable-next-line @typescript-eslint/no-empty-function 26 | stats: () => {}, 27 | }, 28 | options || {}, 29 | ); 30 | 31 | return (output || '').trim(); 32 | } 33 | -------------------------------------------------------------------------------- /community/@atlaskit__popper/src/5.0.0/motions/update-render-props.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTPath, JSXElement, Collection } from 'jscodeshift'; 2 | 3 | export default function updateRenderProps( 4 | j: core.JSCodeshift, 5 | source: Collection, 6 | specifier: string, 7 | oldProperty: string, 8 | newProperty: string, 9 | ) { 10 | source.findJSXElements(specifier).forEach((element: ASTPath) => { 11 | j(element) 12 | .find(j.ArrowFunctionExpression) 13 | .find(j.ObjectPattern) 14 | .find(j.ObjectProperty) 15 | .filter( 16 | // @ts-ignore 17 | (path: ASTPath) => path.value.key.name === oldProperty, 18 | ) 19 | .forEach(path => { 20 | j(path).replaceWith( 21 | j.property( 22 | 'init', 23 | j.identifier(newProperty), 24 | j.identifier(oldProperty), 25 | ), 26 | ); 27 | }); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /community/@atlaskit__popup/src/1.0.0/motions/update-render-props.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTPath, JSXElement, Collection } from 'jscodeshift'; 2 | 3 | export default function updateRenderProps( 4 | j: core.JSCodeshift, 5 | source: Collection, 6 | specifier: string, 7 | oldProperty: string, 8 | newProperty: string, 9 | ) { 10 | source.findJSXElements(specifier).forEach((element: ASTPath) => { 11 | j(element) 12 | .find(j.ArrowFunctionExpression) 13 | .find(j.ObjectPattern) 14 | .find(j.ObjectProperty) 15 | .filter( 16 | // @ts-ignore 17 | (path: ASTPath) => path.value.key.name === oldProperty, 18 | ) 19 | .forEach(path => { 20 | j(path).replaceWith( 21 | j.property( 22 | 'init', 23 | j.identifier(newProperty), 24 | j.identifier(oldProperty), 25 | ), 26 | ); 27 | }); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /community/react/src/use-string-literal-props/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('react#use-string-literal-props transform', () => { 5 | it('should remove redundant literal props', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | const SomeComponent = () => ( 10 | 15 | ); 16 | `, 17 | { parser: 'tsx' }, 18 | ); 19 | 20 | expect(result).toMatchInlineSnapshot(` 21 | "const SomeComponent = () => ( 22 | 27 | );" 28 | `); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /.github/workflows/validate.yml: -------------------------------------------------------------------------------- 1 | name: Validate 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | node-version: [20.17.*] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v1 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | - run: npm install -g yarn 24 | - run: yarn install --frozen-lockfile 25 | - run: yarn build 26 | - run: git status 27 | - name: Check for changes 28 | run: | 29 | if [ $(git status --porcelain | wc -l) -ne 0 ]; then 30 | echo "::error::Changes detected (modified or added files)" 31 | exit 1 32 | fi 33 | - run: yarn validate 34 | env: 35 | CI: true 36 | -------------------------------------------------------------------------------- /community/@atlaskit__textfield/src/5.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { applyMotions, hasImportDeclaration } from '@hypermod/utils'; 3 | 4 | import { removeThemeImports } from './motions/remove-imports'; 5 | import { removeThemeProp } from './motions/remove-props'; 6 | import { 7 | renameThemeAppearanceImport, 8 | renamethemeTokensImport, 9 | } from './motions/rename-imports'; 10 | 11 | export default function transformer( 12 | fileInfo: FileInfo, 13 | { jscodeshift: j }: API, 14 | options: Options, 15 | ) { 16 | const source = j(fileInfo.source); 17 | 18 | if (!hasImportDeclaration(j, source, '@atlaskit/textfield')) { 19 | return fileInfo.source; 20 | } 21 | 22 | applyMotions(j, source, [ 23 | removeThemeProp, 24 | removeThemeImports, 25 | renamethemeTokensImport, 26 | renameThemeAppearanceImport, 27 | ]); 28 | 29 | return source.toSource(options.printOptions); 30 | } 31 | -------------------------------------------------------------------------------- /community/@atlaskit__calendar/src/11.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { applyMotions, hasImportDeclaration } from '@hypermod/utils'; 3 | 4 | import flattenCertainInnerProps from './motions/flatten-certain-inner-props'; 5 | import removeInnerProps from './motions/remove-inner-props'; 6 | 7 | export default function transformer( 8 | fileInfo: FileInfo, 9 | { jscodeshift: j }: API, 10 | options: Options, 11 | ) { 12 | const source = j(fileInfo.source); 13 | 14 | if (!hasImportDeclaration(j, source, '@atlaskit/calendar')) { 15 | return fileInfo.source; 16 | } 17 | 18 | applyMotions(j, source, [flattenCertainInnerProps, removeInnerProps]); 19 | 20 | /** 21 | * Return your modified AST here 👇 22 | * ----- 23 | * This is where your modified AST will be transformed back into a string 24 | * and written back to the file. 25 | */ 26 | return source.toSource(options.printOptions); 27 | } 28 | -------------------------------------------------------------------------------- /packages/utils/src/jsx.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTPath } from 'jscodeshift'; 2 | 3 | export function getJSXAttributes( 4 | j: core.JSCodeshift, 5 | element: ASTPath, 6 | attributeName: string, 7 | ) { 8 | return j(element) 9 | .find(j.JSXOpeningElement) 10 | .find(j.JSXAttribute) 11 | .filter(attribute => { 12 | const matches = j(attribute) 13 | .find(j.JSXIdentifier) 14 | .filter(identifier => identifier.value.name === attributeName); 15 | return Boolean(matches.length); 16 | }); 17 | } 18 | 19 | export function hasJSXAttributes( 20 | j: core.JSCodeshift, 21 | element: ASTPath, 22 | attributeName: string, 23 | ) { 24 | return getJSXAttributes(j, element, attributeName).length > 0; 25 | } 26 | 27 | export function removeJSXAttributes( 28 | j: core.JSCodeshift, 29 | element: ASTPath, 30 | attributeName: string, 31 | ) { 32 | return getJSXAttributes(j, element, attributeName).remove(); 33 | } 34 | -------------------------------------------------------------------------------- /community/@atlaskit__section-message/src/6.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { applyMotions, hasImportDeclaration } from '@hypermod/utils'; 3 | 4 | import { SECTION_MESSAGE_PACKAGE_NAME } from './constants'; 5 | import { getDynamicImportName } from './utils'; 6 | import changeAppearanceProp from './motions/change-appearance-prop'; 7 | import mapActionsProp from './motions/map-actions-prop'; 8 | 9 | export default function transformer( 10 | fileInfo: FileInfo, 11 | { jscodeshift: j }: API, 12 | options: Options, 13 | ) { 14 | const source = j(fileInfo.source); 15 | 16 | if ( 17 | !hasImportDeclaration(j, source, SECTION_MESSAGE_PACKAGE_NAME) && 18 | !getDynamicImportName(j, source, SECTION_MESSAGE_PACKAGE_NAME) 19 | ) { 20 | return fileInfo.source; 21 | } 22 | 23 | applyMotions(j, source, [changeAppearanceProp, mapActionsProp]); 24 | 25 | return source.toSource(options.printOptions); 26 | } 27 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/src/11.0.0/motions/add-isRemovable-flag.ts: -------------------------------------------------------------------------------- 1 | import core, { JSXAttribute } from 'jscodeshift'; 2 | import { 3 | getJSXAttributes, 4 | getDefaultImportSpecifierName, 5 | } from '@hypermod/utils'; 6 | 7 | export const addIsRemovableFlag = (j: core.JSCodeshift, source: any) => { 8 | const defaultSpecifier = getDefaultImportSpecifierName( 9 | j, 10 | source, 11 | '@atlaskit/tag', 12 | ); 13 | 14 | if (!defaultSpecifier) return; 15 | 16 | source 17 | .findJSXElements(defaultSpecifier) 18 | .forEach((element: core.ASTPath) => { 19 | getJSXAttributes(j, element, 'removeButtonText').forEach(attribute => { 20 | // @ts-ignore 21 | const shouldConvert = attribute.node.value.value !== '' || false; 22 | const node = j.jsxAttribute(j.jsxIdentifier('isRemovable')); 23 | if (shouldConvert) { 24 | j(attribute).insertBefore(node); 25 | } 26 | }); 27 | }); 28 | }; 29 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/src/11.0.0/__tests__/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | 3 | import transformer from '../transform'; 4 | 5 | describe('@atlaskit/tag@11.0.0 transform', () => { 6 | it('should apply all 3 migrates', async () => { 7 | const result = await applyTransform( 8 | transformer, 9 | ` 10 | import React from "react"; 11 | import AKTag, { TagColor } from "@atlaskit/tag"; 12 | 13 | export default () => ; 14 | `, 15 | { 16 | parser: 'tsx', 17 | }, 18 | ); 19 | 20 | expect(result).toMatchInlineSnapshot(` 21 | "import React from "react"; 22 | import AKTag from "@atlaskit/tag/removable-tag"; 23 | import { TagColor } from "@atlaskit/tag"; 24 | 25 | export default () => ;" 26 | `); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/cli/src/utils/file-system.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs-extra'; 2 | import findUp from 'find-up'; 3 | 4 | import { fetchConfigs } from '@hypermod/fetcher'; 5 | import { Config } from '@hypermod/types'; 6 | 7 | export async function getPackageJson() { 8 | let rootPackageJson: any; 9 | const packageJsonPath = await findUp('package.json'); 10 | 11 | if (packageJsonPath) { 12 | const packageJsonRaw = await fs.readFile(packageJsonPath, 'utf8'); 13 | rootPackageJson = JSON.parse(packageJsonRaw); 14 | } 15 | 16 | return rootPackageJson; 17 | } 18 | 19 | export async function fetchConfigsForWorkspaces(workspaces: string[]) { 20 | return await workspaces.reduce< 21 | Promise<{ filePath: string; config: Config }[]> 22 | >(async (accum, filePath) => { 23 | const configs = await fetchConfigs(filePath); 24 | if (!configs.length) return accum; 25 | const results = await accum; 26 | return [...results, ...configs]; 27 | }, Promise.resolve([])); 28 | } 29 | -------------------------------------------------------------------------------- /packages/fetcher/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/fetcher", 3 | "version": "0.11.1", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/fetcher", 9 | "dependencies": { 10 | "@babel/core": "^7.23.0", 11 | "@babel/parser": "^7.23.0", 12 | "@babel/plugin-proposal-class-properties": "^7.13.0", 13 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8", 14 | "@babel/plugin-proposal-optional-chaining": "^7.13.12", 15 | "@babel/plugin-transform-modules-commonjs": "^7.13.8", 16 | "@babel/preset-typescript": "^7.23.0", 17 | "@babel/register": "^7.23.0", 18 | "@hypermod/types": "*", 19 | "chalk": "^4.1.0", 20 | "fs-extra": "^9.1.0", 21 | "globby": "^11.1.0", 22 | "live-plugin-manager": "^0.18.1" 23 | }, 24 | "engines": { 25 | "node": ">=20.17" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /community/@atlaskit__toggle/src/12.0.0/motions/elevate-stateless.ts: -------------------------------------------------------------------------------- 1 | import core from 'jscodeshift'; 2 | import { getImportDeclaration } from '@hypermod/utils'; 3 | 4 | const elevateStateless = (j: core.JSCodeshift, root: any) => { 5 | getImportDeclaration(j, root, '@atlaskit/toggle').forEach(path => { 6 | const defaultSpecifier = (path.value.specifiers || []).filter( 7 | specifier => specifier.type === 'ImportDefaultSpecifier', 8 | ); 9 | 10 | const otherSpecifier = (path.value.specifiers || []).filter( 11 | specifier => specifier.type === 'ImportSpecifier', 12 | ); 13 | 14 | if (defaultSpecifier.length > 0 || otherSpecifier.length > 1) return; 15 | 16 | const declaration = otherSpecifier.map(s => 17 | j.importDeclaration( 18 | [j.importDefaultSpecifier(s.local)], 19 | j.literal('@atlaskit/toggle'), 20 | ), 21 | ); 22 | 23 | j(path).replaceWith(declaration); 24 | }); 25 | }; 26 | 27 | export default elevateStateless; 28 | -------------------------------------------------------------------------------- /community/react/src/create-element-to-jsx/README.md: -------------------------------------------------------------------------------- 1 | # react#create-element-to-jsx 2 | 3 | Converts calls to `React.createElement` into JSX elements. 4 | 5 | _Credit_: [https://github.com/reactjs/react-codemod](https://github.com/reactjs/react-codemod) 6 | 7 | ```js 8 | /* INPUT */ 9 | var React = require('react/addons'); 10 | 11 | React.createElement( 12 | 'div', 13 | {}, 14 | React.createElement( 15 | 'span', 16 | {}, 17 | React.createElement( 18 | 'button', 19 | {}, 20 | React.createElement( 21 | 'a', 22 | {href: 'https://www.google.com'}, 23 | React.createElement('audio') 24 | ) 25 | ), 26 | React.createElement('br'), 27 | React.createElement('img') 28 | ) 29 | ); 30 | 31 | /* OUTPUT */ 32 | var React = require('react/addons'); 33 | 34 |
35 | 36 | 41 |
42 | 43 |
44 |
; 45 | ``` 46 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | release: 10 | name: Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout Repo 14 | uses: actions/checkout@master 15 | with: 16 | # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits 17 | fetch-depth: 0 18 | 19 | - name: Setup Node.js 20.17.* 20 | uses: actions/setup-node@master 21 | with: 22 | node-version: 20.17.* 23 | 24 | - name: Install Dependencies 25 | run: yarn 26 | 27 | - name: Create Release Pull Request or Publish to npm 28 | uses: changesets/action@v1 29 | with: 30 | # this expects you to have a script called release which does a build for your packages and calls changeset publish 31 | publish: yarn release 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 35 | -------------------------------------------------------------------------------- /website/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Any CSS included here will be global. The classic template 3 | * bundles Infima by default. Infima is a CSS framework designed to 4 | * work well for content-centric websites. 5 | */ 6 | 7 | /* You can override the default Infima variables here. */ 8 | :root { 9 | --ifm-color-primary: #000; 10 | --ifm-color-primary-dark: #000; 11 | --ifm-color-primary-darker: #000; 12 | --ifm-color-primary-darkest: #000; 13 | --ifm-color-primary-light: #000; 14 | --ifm-color-primary-lighter: #000; 15 | --ifm-color-primary-lightest: #000; 16 | } 17 | 18 | [data-theme='dark'] { 19 | --ifm-color-primary: #fff; 20 | --ifm-color-primary-dark: #fff; 21 | --ifm-color-primary-darker: #fff; 22 | --ifm-color-primary-darkest: #fff; 23 | --ifm-color-primary-light: #fff; 24 | --ifm-color-primary-lighter: #fff; 25 | --ifm-color-primary-lightest: #fff; 26 | } 27 | 28 | .docusaurus-highlight-code-line { 29 | background-color: rgb(72, 77, 91); 30 | display: block; 31 | margin: 0 calc(-1 * var(--ifm-pre-padding)); 32 | padding: 0 var(--ifm-pre-padding); 33 | } 34 | -------------------------------------------------------------------------------- /scripts/initialize-preset.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import path from 'path'; 3 | 4 | import { initDirectory, initTransform } from '@hypermod/initializer'; 5 | 6 | const communityPath = `${__dirname}/../community`; 7 | 8 | export function main(packageName: string, preset?: string) { 9 | if (!packageName) 10 | throw new Error( 11 | chalk.red( 12 | 'Package name was not provided. Example: yarn community:init foobar my-preset', 13 | ), 14 | ); 15 | if (!preset) 16 | throw new Error( 17 | chalk.red( 18 | 'Preset name was not provided. Example: Example: yarn community:init foobar my-preset', 19 | ), 20 | ); 21 | 22 | const targetPath = path.join(communityPath, packageName.replace('/', '__')); 23 | 24 | if (preset) { 25 | initDirectory(packageName, targetPath, true); 26 | initTransform(packageName, preset, 'preset', targetPath); 27 | } 28 | 29 | console.log( 30 | chalk.green( 31 | `🚚 New codemod package created at: ./community/${packageName}/${preset}`, 32 | ), 33 | ); 34 | } 35 | 36 | main(process.argv[2], process.argv[3]); 37 | -------------------------------------------------------------------------------- /scripts/initialize.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import path from 'path'; 3 | 4 | import { initDirectory, initTransform } from '@hypermod/initializer'; 5 | 6 | const communityPath = `${__dirname}/../community`; 7 | 8 | export function main(packageName: string, transform?: string) { 9 | if (!packageName) 10 | throw new Error( 11 | chalk.red( 12 | 'Package name was not provided. Example: yarn community:init foobar 12.0.0', 13 | ), 14 | ); 15 | if (!transform) 16 | throw new Error( 17 | chalk.red( 18 | 'Version was not provided. Example: Example: yarn community:init foobar 12.0.0', 19 | ), 20 | ); 21 | 22 | const targetPath = path.join(communityPath, packageName.replace('/', '__')); 23 | 24 | if (transform) { 25 | initDirectory(packageName, targetPath, true); 26 | initTransform(packageName, transform, 'version', targetPath); 27 | } 28 | 29 | console.log( 30 | chalk.green( 31 | `🚚 New codemod package created at: ./community/${packageName}/${transform}`, 32 | ), 33 | ); 34 | } 35 | 36 | main(process.argv[2], process.argv[3]); 37 | -------------------------------------------------------------------------------- /community/@atlaskit__textfield/src/5.0.0/motions/remove-props.ts: -------------------------------------------------------------------------------- 1 | import core, { Collection, Node } from 'jscodeshift'; 2 | import { 3 | insertCommentToStartOfFile, 4 | getDefaultImportSpecifierName, 5 | getJSXAttributes, 6 | } from '@hypermod/utils'; 7 | 8 | export const removeThemeProp = ( 9 | j: core.JSCodeshift, 10 | source: Collection, 11 | ) => { 12 | const defaultSpecifier = getDefaultImportSpecifierName( 13 | j, 14 | source, 15 | '@atlaskit/textfield', 16 | ); 17 | 18 | if (!defaultSpecifier) return; 19 | 20 | source.findJSXElements(defaultSpecifier).forEach(element => { 21 | getJSXAttributes(j, element, 'theme') 22 | .forEach(() => { 23 | insertCommentToStartOfFile( 24 | j, 25 | source, 26 | `This file uses the @atlaskit/textfield \`theme\` prop which 27 | has now been removed due to its poor performance characteristics. We have not replaced 28 | theme with an equivalent API due to minimal usage of the \`theme\` prop. 29 | The appearance of TextField will have likely changed.`, 30 | ); 31 | }) 32 | .remove(); 33 | }); 34 | }; 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Hypermod 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/core", 3 | "version": "0.6.2", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/core", 9 | "dependencies": { 10 | "@babel/core": "^7.23.0", 11 | "@babel/parser": "^7.23.0", 12 | "@babel/plugin-proposal-class-properties": "^7.13.0", 13 | "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8", 14 | "@babel/plugin-proposal-optional-chaining": "^7.13.12", 15 | "@babel/plugin-transform-modules-commonjs": "^7.13.8", 16 | "@babel/preset-typescript": "^7.23.0", 17 | "@babel/register": "^7.23.0", 18 | "@types/neo-async": "^2.6.0", 19 | "@types/write-file-atomic": "^4.0.0", 20 | "chalk": "^4.1.0", 21 | "graceful-fs": "^4.2.4", 22 | "jscodeshift": "^17.3.0", 23 | "neo-async": "^2.5.0", 24 | "write-file-atomic": "^2.3.0" 25 | }, 26 | "devDependencies": { 27 | "@types/jscodeshift": "^0.11.6", 28 | "temp": "^0.8.4" 29 | }, 30 | "engines": { 31 | "node": ">=20.17" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/src/11.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { hasImportDeclaration, renameImportDeclaration } from '@hypermod/utils'; 3 | 4 | const importMap = { 5 | '@emotion/core': '@emotion/react', 6 | emotion: '@emotion/css', 7 | 'emotion-theming': '@emotion/react', 8 | 'emotion-server': '@emotion/server', 9 | 'create-emotion': '@emotion/css/create-instance', 10 | 'create-emotion-server': '@emotion/server/create-instance', 11 | 'babel-plugin-emotion': '@emotion/babel-plugin', 12 | 'eslint-plugin-emotion': '@emotion/eslint-plugin', 13 | 'jest-emotion': '@emotion/jest', 14 | }; 15 | 16 | export default function transformer( 17 | file: FileInfo, 18 | { jscodeshift: j }: API, 19 | options: Options, 20 | ) { 21 | const source = j(file.source); 22 | 23 | if ( 24 | !Object.keys(importMap).some(importSource => 25 | hasImportDeclaration(j, source, importSource), 26 | ) 27 | ) { 28 | return file.source; 29 | } 30 | 31 | Object.entries(importMap).forEach(([key, value]) => 32 | renameImportDeclaration(j, source, key, value), 33 | ); 34 | 35 | return source.toSource(options.printOptions); 36 | } 37 | -------------------------------------------------------------------------------- /packages/utils/src/nodes.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTNode, ASTPath } from 'jscodeshift'; 2 | 3 | /** 4 | * The isNodeOfType function uses generics to check if a node of type ASTNode is of a specified type. 5 | * If the check passes, the type of node is narrowed to the expected type, ensuring that the returned type of the function is always correct. 6 | * 7 | * Example: 8 | * 9 | * ```ts 10 | * const isImportSpecifier = isNodeOfType(node, 'ImportSpecifier'); 11 | * ``` 12 | */ 13 | export const isNodeOfType = ( 14 | node: ASTNode, 15 | type: Expected['type'], 16 | ): node is Expected => node.type === type; 17 | 18 | /** 19 | * Determines if the current node is a decendant of a parent node of specific type 20 | * 21 | * Example: 22 | * 23 | * ```ts 24 | * const isDecendantOfImportSpecifier = isDecendantOfType(node, j.ImportSpecifier); 25 | * ``` 26 | */ 27 | export const isDecendantOfType = ( 28 | j: core.JSCodeshift, 29 | source: ASTPath, 30 | type: any, 31 | filter?: any, 32 | ): boolean => { 33 | const closestNodes = j(source).closest(type, filter); 34 | const count: number = closestNodes.length; 35 | return count > 0; 36 | }; 37 | -------------------------------------------------------------------------------- /packages/utils/src/comments.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTNode } from 'jscodeshift'; 2 | import { Collection } from 'jscodeshift/src/Collection'; 3 | 4 | function clean(value: string) { 5 | return value 6 | .replace(/[ \t]{2,}/g, ' ') 7 | .replace(/^[ \t]*/gm, '') 8 | .trim(); 9 | } 10 | 11 | export function insertCommentBefore( 12 | j: core.JSCodeshift, 13 | path: Collection, 14 | message: string, 15 | prefix = ` TODO: (@hypermod)`, 16 | ) { 17 | const content = `${prefix} ${clean(message)} `; 18 | 19 | path.forEach(path => { 20 | // @ts-ignore 21 | path.value.comments = path.value.comments || []; 22 | 23 | // @ts-ignore 24 | const exists = path.value.comments.find( 25 | // @ts-ignore 26 | comment => comment.value === content, 27 | ); 28 | 29 | // avoiding duplicates of the same comment 30 | if (exists) return; 31 | 32 | // @ts-ignore 33 | path.value.comments.push(j.commentBlock(content)); 34 | }); 35 | } 36 | 37 | export function insertCommentToStartOfFile( 38 | j: core.JSCodeshift, 39 | path: Collection, 40 | message: string, 41 | ) { 42 | insertCommentBefore(j, path.find(j.Program), message); 43 | } 44 | -------------------------------------------------------------------------------- /community/react/src/add-react-import/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const source = j(file.source); 9 | const containsJsx = source.find(j.JSXIdentifier).length > 0; 10 | 11 | const containsReactPackageImport = 12 | source 13 | .find(j.ImportDeclaration) 14 | .filter( 15 | importDeclaration => importDeclaration.node.source.value === 'react', 16 | ).length > 0; 17 | 18 | const containsReactDefaultImport = 19 | source 20 | .find(j.ImportDefaultSpecifier) 21 | .filter( 22 | importDefaultSpecifier => 23 | importDefaultSpecifier.node.local!.name === 'React', 24 | ).length > 0; 25 | 26 | if ( 27 | containsJsx && 28 | !(containsReactPackageImport && containsReactDefaultImport) 29 | ) { 30 | source 31 | .get() 32 | .node.program.body.unshift( 33 | j.importDeclaration( 34 | [j.importDefaultSpecifier(j.identifier('React'))], 35 | j.literal('react'), 36 | ), 37 | ); 38 | } 39 | 40 | return source.toSource(options.printOptions); 41 | } 42 | -------------------------------------------------------------------------------- /community/javascript/src/remove-console-log/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('javascript#remove-console-log transform', () => { 5 | it('should not modify files with no console.log statements', async () => { 6 | const result = await applyTransform(transformer, `foo();`, { 7 | parser: 'tsx', 8 | }); 9 | 10 | expect(result).toMatchInlineSnapshot(`"foo();"`); 11 | }); 12 | 13 | it('should remove top-level console.log statement', async () => { 14 | const result = await applyTransform(transformer, 'console.log("fff");', { 15 | parser: 'tsx', 16 | }); 17 | 18 | expect(result).toMatchInlineSnapshot(`""`); 19 | }); 20 | 21 | it('should console.logs in function statements', async () => { 22 | const result = await applyTransform( 23 | transformer, 24 | ` 25 | function foo () { 26 | setTimeout(() => { debugger; console.log('foo') }); 27 | } 28 | `, 29 | { parser: 'tsx' }, 30 | ); 31 | 32 | expect(result).toMatchInlineSnapshot(` 33 | "function foo () { 34 | setTimeout(() => { 35 | debugger; 36 | }); 37 | }" 38 | `); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | testEnvironment: 'node', 4 | transform: { 5 | '\\.[jt]sx?$': [ 6 | 'ts-jest', 7 | { 8 | tsconfig: 'tsconfig.json', 9 | diagnostics: { ignoreCodes: [1343] }, 10 | astTransformers: { 11 | before: [ 12 | { 13 | path: 'node_modules/ts-jest-mock-import-meta', 14 | options: { 15 | metaObjectReplacement: { url: 'https://www.url.com' }, 16 | }, 17 | }, 18 | ], 19 | }, 20 | }, 21 | ], 22 | }, 23 | moduleFileExtensions: ['ts', 'js'], 24 | testRegex: '^.+\\.(spec|test)\\.(ts|js)$', 25 | snapshotSerializers: ['jest-serializer-html-string'], 26 | watchPlugins: [ 27 | 'jest-watch-typeahead/filename', 28 | 'jest-watch-typeahead/testname', 29 | ], 30 | moduleNameMapper: { 31 | '(.+)\\.js$': '$1', 32 | '@hypermod/(.*)$': '/packages/$1/src', 33 | '@codeshift/(.*)$': '/packages/$1/src', 34 | }, 35 | testPathIgnorePatterns: [ 36 | '.tmp/', 37 | '/node_modules/', 38 | '/plugin_packages/', 39 | '/packages/initializer/template/', 40 | ], 41 | }; 42 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/src/11.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { applyMotions, hasImportDeclaration } from '@hypermod/utils'; 3 | 4 | import { addIsRemovableFlag } from './motions/add-isRemovable-flag'; 5 | import { renameRemoveButtonText } from './motions/rename-remove-button-text'; 6 | import { replaceImportStatement } from './motions/replace-import-statements'; 7 | 8 | export default function transformer( 9 | fileInfo: FileInfo, 10 | { jscodeshift: j }: API, 11 | options: Options, 12 | ) { 13 | const source = j(fileInfo.source); 14 | 15 | /** 16 | * Early exit condition 17 | * ----- 18 | * It is often good practice to exit early and return the original source file 19 | * if it does not contain code relevant to the codemod. 20 | * See this page for more information: 21 | * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output 22 | */ 23 | if (!hasImportDeclaration(j, source, '@atlaskit/tag')) { 24 | return fileInfo.source; 25 | } 26 | 27 | applyMotions(j, source, [ 28 | addIsRemovableFlag, 29 | renameRemoveButtonText, 30 | replaceImportStatement, 31 | ]); 32 | 33 | return source.toSource(options.printOptions); 34 | } 35 | -------------------------------------------------------------------------------- /community/@atlaskit__calendar/src/11.0.0/motions/remove-inner-props.ts: -------------------------------------------------------------------------------- 1 | import core, { Collection, Node } from 'jscodeshift'; 2 | import { 3 | insertCommentToStartOfFile, 4 | getDefaultImportSpecifierName, 5 | getJSXAttributes, 6 | } from '@hypermod/utils'; 7 | 8 | const removeInnerProps = (j: core.JSCodeshift, source: Collection) => { 9 | const defaultSpecifier = getDefaultImportSpecifierName( 10 | j, 11 | source, 12 | '@atlaskit/calendar', 13 | ); 14 | 15 | if (!defaultSpecifier) return; 16 | 17 | source.findJSXElements(defaultSpecifier).forEach(element => { 18 | getJSXAttributes(j, element, 'innerProps').forEach(attribute => { 19 | j(attribute).remove(); 20 | 21 | insertCommentToStartOfFile( 22 | j, 23 | source, 24 | `This file uses the @atlaskit/calendar \`innerProps\` which 25 | has now been removed due to its poor performance characteristics. Codemod 26 | has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar. 27 | Rest other properties if any inside innerProps will get auto-removed along with it, 28 | & might have to be handled manually as per need.`, 29 | ); 30 | }); 31 | }); 32 | }; 33 | 34 | export default removeInnerProps; 35 | -------------------------------------------------------------------------------- /community/javascript/src/remove-debugger/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('javascript#remove-debugger transform', () => { 5 | it('should not modify files with no debugger statements', async () => { 6 | const result = await applyTransform(transformer, `console.log('foooo');`, { 7 | parser: 'tsx', 8 | }); 9 | 10 | expect(result).toMatchInlineSnapshot(`"console.log('foooo');"`); 11 | }); 12 | 13 | it('should remove top-level debugger statement', async () => { 14 | const result = await applyTransform(transformer, 'debugger;', { 15 | parser: 'tsx', 16 | }); 17 | 18 | expect(result).toMatchInlineSnapshot(`""`); 19 | }); 20 | 21 | it('should debuggers in function statements', async () => { 22 | const result = await applyTransform( 23 | transformer, 24 | ` 25 | function foo () { 26 | debugger; 27 | setTimeout(() => { debugger; console.log('foo') });debugger; 28 | } 29 | `, 30 | { parser: 'tsx' }, 31 | ); 32 | 33 | expect(result).toMatchInlineSnapshot(` 34 | "function foo () { 35 | setTimeout(() => { 36 | console.log('foo') 37 | }); 38 | }" 39 | `); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /community/react/src/sort-jsx-props/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('react#sort-jsx-props transform', () => { 5 | it('should sort props correctly', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | 15 | `, 16 | { parser: 'tsx' }, 17 | ); 18 | 19 | expect(result).toMatchInlineSnapshot(` 20 | "" 26 | `); 27 | }); 28 | 29 | it('should leave spread props in place to avoid breaking overrides', async () => { 30 | const result = await applyTransform( 31 | transformer, 32 | ` 33 | 40 | `, 41 | { parser: 'tsx' }, 42 | ); 43 | 44 | expect(result).toMatchInlineSnapshot(` 45 | "" 52 | `); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /community/@atlaskit__popup/src/1.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { 3 | hasImportDeclaration, 4 | getDefaultImportSpecifierName, 5 | getImportSpecifierName, 6 | } from '@hypermod/utils'; 7 | 8 | import updateBoundariesProps from './motions/update-boundaries-props'; 9 | import updateOffset from './motions/update-offset'; 10 | import updateRenderProps from './motions/update-render-props'; 11 | 12 | export default function transformer( 13 | fileInfo: FileInfo, 14 | { jscodeshift: j }: API, 15 | options: Options, 16 | ) { 17 | const source = j(fileInfo.source); 18 | 19 | if (!hasImportDeclaration(j, source, '@atlaskit/popup')) { 20 | return fileInfo.source; 21 | } 22 | 23 | // Get imported name for the component 24 | let specifier = getDefaultImportSpecifierName(j, source, '@atlaskit/popup'); 25 | 26 | if (!specifier) { 27 | specifier = getImportSpecifierName(j, source, 'Popup', '@atlaskit/popup'); 28 | } 29 | 30 | if (!specifier) { 31 | return fileInfo.source; 32 | } 33 | 34 | updateBoundariesProps(j, source, specifier); 35 | updateOffset(j, source, specifier); 36 | updateRenderProps(j, source, specifier, 'scheduleUpdate', 'update'); 37 | 38 | return source.toSource(options.printOptions); 39 | } 40 | -------------------------------------------------------------------------------- /packages/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hypermod/cli", 3 | "version": "0.27.3", 4 | "source": "src/index.ts", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "license": "MIT", 8 | "repository": "https://github.com/hypermod-io/hypermod-community/tree/main/packages/cli", 9 | "bin": { 10 | "hypermod": "./bin/hypermod-cli.js", 11 | "hypermod-cli": "./bin/hypermod-cli.js", 12 | "codeshift": "./bin/hypermod-cli.js", 13 | "codeshift-cli": "./bin/hypermod-cli.js" 14 | }, 15 | "scripts": { 16 | "start": "./bin/hypermod-cli.js", 17 | "start:dev": "ts-node src/index.ts" 18 | }, 19 | "dependencies": { 20 | "@antfu/install-pkg": "^0.1.1", 21 | "@hypermod/core": "^0.6.2", 22 | "@hypermod/fetcher": "^0.11.1", 23 | "@hypermod/initializer": "^0.8.1", 24 | "@hypermod/types": "*", 25 | "@hypermod/validator": "^0.8.0", 26 | "chalk": "^4.1.0", 27 | "commander": "^8.2.0", 28 | "find-up": "5.0.0", 29 | "fs-extra": "^9.1.0", 30 | "inquirer": "^8.2.4", 31 | "jscodeshift": "^17.3.0", 32 | "live-plugin-manager": "^0.18.1", 33 | "lodash": "^4.17.21", 34 | "ora": "^5.4.1", 35 | "semver": "^7.3.5", 36 | "ts-node": "^10.9.1" 37 | }, 38 | "engines": { 39 | "node": ">=20.17" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeshift-community", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "^3.4.0", 18 | "@docusaurus/plugin-client-redirects": "^3.4.0", 19 | "@docusaurus/preset-classic": "^3.4.0", 20 | "@mdx-js/react": "^3.0.0", 21 | "clsx": "^1.1.1", 22 | "prism-react-renderer": "^2.1.0", 23 | "react": "^18.2.0", 24 | "react-dom": "^18.2.0" 25 | }, 26 | "devDependencies": { 27 | "@docusaurus/module-type-aliases": "^3.4.0", 28 | "@docusaurus/types": "^3.4.0" 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.5%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "engines": { 43 | "node": ">=18.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /community/@atlaskit__checkbox/src/12.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { applyMotions, hasImportDeclaration } from '@hypermod/utils'; 3 | 4 | import { removeThemeImports } from './motions/remove-imports'; 5 | import { 6 | removeFullWidth, 7 | removeOverrides, 8 | removeTheme, 9 | } from './motions/remove-props'; 10 | import { 11 | renameCheckboxWithoutAnalyticsImport, 12 | renameDeepTypeImport, 13 | renameTypeImport, 14 | } from './motions/rename-import'; 15 | import { renameInputRef } from './motions/rename-inputRef'; 16 | 17 | export default function transformer( 18 | fileInfo: FileInfo, 19 | { jscodeshift: j }: API, 20 | options: Options, 21 | ) { 22 | const source = j(fileInfo.source); 23 | 24 | if ( 25 | !hasImportDeclaration(j, source, '@atlaskit/checkbox') && 26 | !hasImportDeclaration(j, source, '@atlaskit/checkbox/Checkbox') && 27 | !hasImportDeclaration(j, source, '@atlaskit/checkbox/types') 28 | ) { 29 | return fileInfo.source; 30 | } 31 | 32 | applyMotions(j, source, [ 33 | removeThemeImports, 34 | renameCheckboxWithoutAnalyticsImport, 35 | renameTypeImport, 36 | renameDeepTypeImport, 37 | renameInputRef, 38 | removeFullWidth, 39 | removeOverrides, 40 | removeTheme, 41 | ]); 42 | 43 | return source.toSource(options.printOptions); 44 | } 45 | -------------------------------------------------------------------------------- /community/@atlaskit__popper/src/5.0.0/constants.ts: -------------------------------------------------------------------------------- 1 | export const messageForUsingExpression = ` 2 | Popper.js has been upgraded from 1.14.1 to 2.4.2, 3 | and as a result the offset prop has changed to be an array. e.g '0px 8px' -> [0, 8] 4 | Along with this change you cannot use vw, vh or % units or addition or multiplication 5 | Change the offset value to use pixel values 6 | Further details can be found in the popper docs https://popper.js.org/docs/v2/modifiers/offset/ 7 | `; 8 | 9 | export const messageForUsingVariable = ` 10 | Popper.js has been upgraded from 1.14.1 to 2.4.2, and as a result the offset 11 | prop has changed to be an array. e.g '0px 8px' -> [0, 8] 12 | As you are using a variable, you will have change the offset prop manually 13 | Further details can be found in the popper docs https://popper.js.org/docs/v2/modifiers/offset/ 14 | `; 15 | 16 | export const messageForModifierProps = ` 17 | Popper.js has been upgraded from 1.14.1 to 2.4.2, 18 | and as a result the modifier prop has changed significantly. The format has been 19 | changed from object of objects, to array of objects, with the key for each modifier 20 | replaced with a name key:value pair inside the modifier object, and an options:object 21 | pair for configuration and other changes unique to each modifier. 22 | Further details can be found in the popper docs: https://popper.js.org/docs/v2/modifiers/ 23 | `; 24 | -------------------------------------------------------------------------------- /packages/initializer/template/codemods/codemod/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const source = j(file.source); 9 | 10 | /** 11 | * Early exit condition 12 | * ----- 13 | * It is often good practice to exit early and return the original source file 14 | * if it does not contain code relevant to the codemod. 15 | * See this page for more information: 16 | * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output 17 | */ 18 | if (/* Some condition here */ true) { 19 | return file.source; 20 | } 21 | 22 | /** 23 | * Codemod logic goes here 👇 24 | * ----- 25 | * This is where the core logic for your codemod will go, 26 | * consider grouping specific actions into 'motions' and running them in sequence 27 | * 28 | * See this page for more information: 29 | * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/authoring#motions 30 | */ 31 | source.findVariableDeclarators('foo').renameTo('bar'); 32 | 33 | /** 34 | * Return your modified AST here 👇 35 | * ----- 36 | * This is where your modified AST will be transformed back into a string 37 | * and written back to the file. 38 | */ 39 | return source.toSource(options.printOptions); 40 | } 41 | -------------------------------------------------------------------------------- /packages/cli/src/utils/merge-configs.ts: -------------------------------------------------------------------------------- 1 | import { ConfigMeta } from '@hypermod/fetcher'; 2 | 3 | interface TransformedConfig { 4 | transforms: Record; 5 | presets: Record; 6 | } 7 | 8 | export function mergeConfigs( 9 | config1: ConfigMeta | undefined, 10 | config2: ConfigMeta | undefined, 11 | ) { 12 | const config: TransformedConfig = { transforms: {}, presets: {} }; 13 | 14 | if (config1) { 15 | config.transforms = Object.keys(config1.config.transforms || []).reduce< 16 | Record 17 | >((accum, key) => { 18 | accum[key] = `${config1.filePath}@${key}`; 19 | return accum; 20 | }, {}); 21 | config.presets = Object.keys(config1.config.presets || []).reduce< 22 | Record 23 | >((accum, key) => { 24 | accum[key] = `${config1.filePath}#${key}`; 25 | return accum; 26 | }, {}); 27 | } 28 | 29 | if (config2) { 30 | config.transforms = Object.keys(config2.config.transforms || []).reduce< 31 | Record 32 | >((accum, key) => { 33 | accum[key] = `${config2.filePath}@${key}`; 34 | return accum; 35 | }, {}); 36 | config.presets = Object.keys(config2.config.presets || []).reduce< 37 | Record 38 | >((accum, key) => { 39 | accum[key] = `${config2.filePath}#${key}`; 40 | return accum; 41 | }, {}); 42 | } 43 | 44 | return config; 45 | } 46 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/src/11.0.0/motions/replace-import-statements.ts: -------------------------------------------------------------------------------- 1 | import core from 'jscodeshift'; 2 | import { getImportDeclaration } from '@hypermod/utils'; 3 | 4 | const convertMap: Record = { 5 | Tag: '@atlaskit/tag/removable-tag', 6 | SimpleTag: '@atlaskit/tag/simple-tag', 7 | TagColor: '@atlaskit/tag', 8 | default: '@atlaskit/tag/removable-tag', 9 | '*': '@atlaskit/tag/tag', 10 | }; 11 | 12 | export const replaceImportStatement = (j: core.JSCodeshift, root: any) => { 13 | getImportDeclaration(j, root, '@atlaskit/tag').forEach(path => { 14 | const defaultSpecifier = (path.value.specifiers || []).filter( 15 | specifier => specifier.type === 'ImportDefaultSpecifier', 16 | ); 17 | 18 | const defaultDeclarations = defaultSpecifier.map(s => 19 | j.importDeclaration([s], j.literal(convertMap['default'])), 20 | ); 21 | 22 | const otherSpecifier = (path.value.specifiers || []).filter( 23 | specifier => specifier.type === 'ImportSpecifier', 24 | ); 25 | 26 | j(path).replaceWith(defaultDeclarations); 27 | 28 | const otherDeclarations = otherSpecifier.map(s => { 29 | const localName = s.local!.name; 30 | 31 | return j.importDeclaration( 32 | [s], 33 | j.literal( 34 | convertMap[localName] ? convertMap[localName] : convertMap['*'], 35 | ), 36 | ); 37 | }); 38 | 39 | j(path).insertAfter(otherDeclarations); 40 | }); 41 | }; 42 | -------------------------------------------------------------------------------- /packages/types/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/types 2 | 3 | ## 0.3.0 4 | 5 | ### Minor Changes 6 | 7 | - 68eabcf: Bump CLI to surface changes to App package downloads 8 | 9 | ## 0.2.0 10 | 11 | ### Minor Changes 12 | 13 | - 0f471c5: Adds dependencies property to the type definition + adds comments explaining all of the properties 14 | 15 | ## 0.1.2 16 | 17 | ### Patch Changes 18 | 19 | - ea20de1: Renames type `CodeshiftConfig` to `Config` (with backwards compatible alias) 20 | 21 | ## 0.1.1 22 | 23 | ### Patch Changes 24 | 25 | - 4a89dd20: Bumps typescript to 5.2.2 26 | 27 | ## 0.1.0 28 | 29 | ### Minor Changes 30 | 31 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 32 | 33 | ## 0.0.7 34 | 35 | ### Patch Changes 36 | 37 | - 8255eb2: Packages are now built with pareljs. Entrypoints have been updated to match 38 | 39 | ## 0.0.6 40 | 41 | ### Patch Changes 42 | 43 | - 2a116ba: Renames target to targets (inline with the spec) 44 | 45 | ## 0.0.5 46 | 47 | ### Patch Changes 48 | 49 | - e776f9c: Fixes colors.js vulnrability by bumping jscodeshift 50 | 51 | ## 0.0.4 52 | 53 | ### Patch Changes 54 | 55 | - caaaf9a: Locks version of colors.js to avoid vulnrability 56 | 57 | ## 0.0.3 58 | 59 | ### Patch Changes 60 | 61 | - e8cf76e: Releasing all packages to fix version mismatch 62 | 63 | ## 0.0.2 64 | 65 | ### Patch Changes 66 | 67 | - 30bf0cf: Initial release 68 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | extends: [ 5 | 'plugin:@typescript-eslint/recommended', 6 | 'plugin:prettier/recommended', 7 | 'prettier', 8 | ], 9 | plugins: ['prettier'], 10 | parserOptions: { 11 | ecmaVersion: 2018, 12 | sourceType: 'module', 13 | project: './tsconfig.eslint.json', 14 | ecmaFeatures: { 15 | jsx: true, 16 | }, 17 | }, 18 | rules: { 19 | // '@typescript-eslint/indent': 'off', // https://github.com/typescript-eslint/typescript-eslint/issues/1824 20 | '@typescript-eslint/no-namespace': 'off', 21 | '@typescript-eslint/explicit-function-return-type': 'off', 22 | '@typescript-eslint/no-explicit-any': 'off', 23 | '@typescript-eslint/explicit-member-accessibility': 'off', 24 | '@typescript-eslint/no-non-null-assertion': 'off', 25 | '@typescript-eslint/no-parameter-properties': 'off', 26 | // TODO this is dangerous to allow - should re-address 27 | '@typescript-eslint/ban-ts-comment': 'off', 28 | '@typescript-eslint/no-unused-vars': [ 29 | 'warn', 30 | { 31 | ignoreRestSiblings: true, 32 | }, 33 | ], 34 | }, 35 | overrides: [ 36 | { 37 | files: ['*/**/*.spec.ts', '*/**/__tests__/**/*'], 38 | rules: { 39 | // This deals with import jscodeshift test utils 40 | '@typescript-eslint/no-var-requires': 'off', 41 | '@typescript-eslint/no-empty-function': 'off', 42 | }, 43 | }, 44 | ], 45 | }; 46 | -------------------------------------------------------------------------------- /community/react/src/remove-default-props/motions/moveDefaultPropsToArrowFunctionExpression.ts: -------------------------------------------------------------------------------- 1 | import { Collection, JSCodeshift } from 'jscodeshift'; 2 | import { getNewParams } from './getNewParams'; 3 | 4 | export function moveDefaultPropsToArrowFunctionExpression( 5 | j: JSCodeshift, 6 | source: Collection, 7 | ) { 8 | source.find(j.VariableDeclarator).forEach(component => { 9 | const defaultProps = source.find(j.AssignmentExpression, { 10 | left: { 11 | // @ts-ignore 12 | object: { name: component.node.id?.name }, 13 | property: { name: 'defaultProps' }, 14 | }, 15 | }); 16 | 17 | const defaultValues = defaultProps.get('right').value.properties; 18 | 19 | if (defaultProps.length === 0) return; 20 | 21 | // Generate a new function parameter for each default prop 22 | const defaultParams = defaultValues.map((prop: any) => { 23 | const key = prop.key.name; 24 | const value = prop.value.value; 25 | return j.objectProperty( 26 | j.identifier(key), 27 | j.assignmentPattern(j.identifier(key), j.literal(value)), 28 | ); 29 | }); 30 | 31 | const arrowFunction = component.get('init'); 32 | 33 | const newParams = getNewParams(j, arrowFunction, defaultParams); 34 | 35 | j(component).replaceWith( 36 | j.variableDeclarator( 37 | // @ts-ignore 38 | j.identifier(component.node.id.name), 39 | j.arrowFunctionExpression(newParams!, j.blockStatement([])), 40 | ), 41 | ); 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /website/docs/registry.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | id: registry 3 | title: Registry 4 | slug: /registry 5 | description: Welcome to the codemod registry. A collection of high-quality codemods that have been contributed by the community. Browse our registry to find codemods that can help you automatically refactor your codebase, or contribute your own.' 6 | keywords: 7 | [ 8 | Hypermod, 9 | codemod registry, 10 | codeshiftcommunity, 11 | codemods, 12 | refactor, 13 | codebase, 14 | contribution, 15 | ] 16 | --- 17 | 18 | Welcome to the Hypermod Public Registry. This is a collection of high-quality codemods that have been contributed by members of the community. 19 | Browse our registry to find codemods that can help you automatically refactor your codebase, or contribute your own codemods to share with the community. 20 | 21 | Source for these packages can be found in the [/community folder](https://github.com/hypermod-io/hypermod-community/tree/main/community). 22 | 23 | ## Contribution 24 | 25 | Anyone is able to contribute packages and fixes to the registry. To contribute please see the [contribution guide](/docs/contribution). 26 | 27 | For other publishing options, including private and external codemod packages, please refer to the [Authoring guide](/docs/authoring). 28 | 29 | ## Running registry codemods 30 | 31 | Codemods from the registry can be run via the Hypermod CLI, for example: 32 | 33 | ``` 34 | $ npx @hypermod/cli --packages @atlaskit/button /project/src 35 | ``` 36 | 37 | See the [CLI reference](/docs/cli) for more information. 38 | -------------------------------------------------------------------------------- /.github/workflows/documentation.yml.disabled: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | pull_request: 5 | branches: [main] 6 | push: 7 | branches: [main] 8 | 9 | jobs: 10 | checks: 11 | if: github.event_name != 'push' 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v1 15 | - uses: actions/setup-node@v1 16 | with: 17 | node-version: '20.17.*' 18 | - name: Generate docs 19 | run: | 20 | yarn install --frozen-lockfile 21 | yarn build 22 | yarn predocs:start 23 | - name: Test Build 24 | run: | 25 | cd website 26 | yarn install --frozen-lockfile 27 | yarn build 28 | gh-release: 29 | if: github.event_name != 'pull_request' 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v1 33 | - uses: actions/setup-node@v1 34 | with: 35 | node-version: '20.17.*' 36 | - uses: webfactory/ssh-agent@v0.5.0 37 | with: 38 | ssh-private-key: ${{ secrets.GH_PAGES_DEPLOY }} 39 | - name: Generate docs 40 | run: | 41 | yarn install --frozen-lockfile 42 | yarn build 43 | yarn predocs:start 44 | - name: Release to GitHub Pages 45 | env: 46 | USE_SSH: true 47 | GIT_USER: git 48 | run: | 49 | git config --global user.email "actions@github.com" 50 | git config --global user.name "gh-actions" 51 | cd website 52 | yarn install --frozen-lockfile 53 | GIT_USER=danieldelcore yarn deploy 54 | -------------------------------------------------------------------------------- /community/hypermod/src/defineInlineTest-to-applyTransform/README.md: -------------------------------------------------------------------------------- 1 | # hypermod#defineInlineTest-to-applyTransform 2 | 3 | Codemods for hypermod#defineInlineTest-to-applyTransform 4 | 5 | This codemod transforms test cases written with `defineInlineTest` from ` jscodeshift`` to use the `applyTransform`function from`@hypermod/utils`. Below is an example of the transformation: 6 | 7 | ```js 8 | /* INPUT */ 9 | const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest; 10 | 11 | defineInlineTest( 12 | { default: transformer, parser: 'tsx' }, 13 | {}, 14 | ` 15 | import React from "react"; 16 | import Tag from "@atlaskit/tag"; 17 | export default () => ; 18 | `, 19 | ` 20 | import React from "react"; 21 | import Tag from "@atlaskit/tag"; 22 | export default () => ; 23 | `, 24 | 'should not add isRemovable flag when no removeButtonText defined', 25 | ); 26 | 27 | /* OUTPUT */ 28 | import { applyTransform } from '@hypermod/utils'; 29 | 30 | it('should not add isRemovable flag when no removeButtonText defined', async () => { 31 | const result = await applyTransform( 32 | transformer, 33 | ` 34 | import React from "react"; 35 | import Tag from "@atlaskit/tag"; 36 | export default () => ; 37 | `, 38 | { parser: 'tsx' }, 39 | ); 40 | expect(result).toMatchInlineSnapshot(` 41 | "import React from "react"; 42 | import Tag from "@atlaskit/tag"; 43 | export default () => ;" 44 | `); 45 | }); 46 | ``` 47 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/src/11.0.0/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('@emotion@11.0.0 transform', () => { 5 | it('should transform imports correctly', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | import * as core from '@emotion/core'; 10 | import * as emotion from 'emotion'; 11 | import * as emotionTheming from 'emotion-theming'; 12 | import * as emotionServer from 'emotion-server'; 13 | import * as createEmotion from 'create-emotion'; 14 | import * as createEmotionServer from 'create-emotion-server'; 15 | import * as babelPlugin from 'babel-plugin-emotion'; 16 | import * as eslintPlugin from 'eslint-plugin-emotion'; 17 | import * as jestEmotion from 'jest-emotion'; 18 | `, 19 | { parser: 'tsx' }, 20 | ); 21 | 22 | expect(result).toMatchInlineSnapshot(` 23 | "import * as core from "@emotion/react"; 24 | import * as emotion from "@emotion/css"; 25 | import * as emotionTheming from "@emotion/react"; 26 | import * as emotionServer from "@emotion/server"; 27 | import * as createEmotion from "@emotion/css/create-instance"; 28 | import * as createEmotionServer from "@emotion/server/create-instance"; 29 | import * as babelPlugin from "@emotion/babel-plugin"; 30 | import * as eslintPlugin from "@emotion/eslint-plugin"; 31 | import * as jestEmotion from "@emotion/jest";" 32 | `); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /packages/initializer/template/README.md: -------------------------------------------------------------------------------- 1 | # <% packageName %> 2 | 3 | This project was bootstrapped with [Hypermod 🚚](https://www.codeshiftcommunity.com/). Please see the [external packages guide](https://www.codeshiftcommunity.com/docs/external-packages) for more information on how to work with this repo. 4 | 5 | ![Hypermod logo](https://www.codeshiftcommunity.com/img/logo.svg) 6 | 7 | ## Scripts 8 | 9 | ### `npm run dev` 10 | 11 | Runs the Hypermod CLI useful for testing transform files as if they have been published 12 | 13 | **example:** `npm run dev -t codemods/10.0.0/transform.ts` 14 | 15 | Alternatively, you can run `npm run dev` to see an interactive list of codemods to choose from. 16 | 17 | See the [cli reference](https://www.codeshiftcommunity.com/docs/cli) for more information. 18 | 19 | ### `npm run test` 20 | 21 | Launches the test runner in interactive watch mode. 22 | 23 | See the [testing guide](https://www.codeshiftcommunity.com/docs/testing) for more information. 24 | 25 | ### `npm run validate` 26 | 27 | Checks the validity of your `hypermod.config.js` file. 28 | 29 | See the [configuration options](https://www.codeshiftcommunity.com/docs/configuration) for more information. 30 | 31 | ### `npm run build` 32 | 33 | Builds the app for production to the `dist` folder. 34 | 35 | ## Publishing 36 | 37 | This package can be published to npm via the normal commands `npm version` and `npm publish` 38 | 39 | ## Build tooling 40 | 41 | Feel free to replace the preinstalled build tooling & dependencies to suit your needs. The only requirement is that there is a valid `hypermod.config.js` in your project root, `/src` or `/codemods` directories. 42 | -------------------------------------------------------------------------------- /community/@atlaskit__breadcrumbs/src/11.0.0/motions/remove-has-separator.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTPath, Collection, Node } from 'jscodeshift'; 2 | import { 3 | insertCommentToStartOfFile, 4 | getJSXAttributes, 5 | getImportSpecifierName, 6 | } from '@hypermod/utils'; 7 | 8 | const createRemoveFuncFor = 9 | ( 10 | importSource: string, 11 | importName: string, 12 | prop: string, 13 | predicate: (j: core.JSCodeshift, element: ASTPath) => boolean = () => 14 | true, 15 | comment?: string, 16 | ) => 17 | (j: core.JSCodeshift, source: Collection) => { 18 | const specifier = getImportSpecifierName( 19 | j, 20 | source, 21 | importName, 22 | importSource, 23 | ); 24 | 25 | if (!specifier) return; 26 | 27 | source.findJSXElements(specifier).forEach(element => { 28 | if (predicate(j, element) && comment) { 29 | insertCommentToStartOfFile(j, source, comment); 30 | } else { 31 | getJSXAttributes(j, element, prop).forEach(attribute => { 32 | j(attribute).remove(); 33 | }); 34 | } 35 | }); 36 | }; 37 | 38 | const removeHasSeparator = createRemoveFuncFor( 39 | '@atlaskit/breadcrumbs', 40 | 'BreadcrumbsItem', 41 | 'hasSeparator', 42 | (j, element) => j(element).find(j.JSXSpreadAttribute).length > 0, 43 | `This file uses the @atlaskit/breadcrumbs \`hasSeparator\` prop which 44 | has now been removed due to its poor performance characteristics. From version 11.0.0, we changed to 45 | \`css\` pseudo element for the separator and consumer should not use hasSeparator directly anymore.`, 46 | ); 47 | 48 | export default removeHasSeparator; 49 | -------------------------------------------------------------------------------- /scripts/sync.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs-extra'; 2 | import junk from 'junk'; 3 | import path from 'path'; 4 | import axios from 'axios'; 5 | 6 | import { fetchConfig } from '@hypermod/fetcher'; 7 | 8 | const COMMUNITY_PATH = path.join(__dirname, '..', 'community'); 9 | const CODESHIFT_WORKER_URL = 'http://codeshift.delcore.workers.dev/packages'; 10 | 11 | interface DocsData { 12 | pkgName: string; 13 | targets: string; 14 | } 15 | 16 | async function main() { 17 | console.log('🚚 Syncing community packages with the hypermod worker'); 18 | 19 | const communityCodemods = fs.readdirSync(COMMUNITY_PATH); 20 | const data: DocsData[] = []; 21 | const directories = communityCodemods.filter(dir => junk.not(dir)); 22 | 23 | for (const dir of directories) { 24 | const { config } = await fetchConfig(path.join(COMMUNITY_PATH, dir)); 25 | 26 | if (!config) { 27 | throw new Error(`Unable to locate config for path: ${dir}`); 28 | } 29 | 30 | const pkgName = `@hypermod/mod-${dir.replace('@', '').replace('/', '__')}`; 31 | const rawPkgName = dir.replace('__', '/'); 32 | data.push({ 33 | pkgName, 34 | targets: rawPkgName + (config.targets ? `, ${config.targets}` : ''), 35 | }); 36 | } 37 | 38 | const response = await axios.post( 39 | CODESHIFT_WORKER_URL, 40 | JSON.stringify(data), 41 | { 42 | headers: { 43 | 'Content-Type': 'application/json', 44 | 'X-Custom-PSK': process.env.WORKER_PRESHARED_KEY!, 45 | }, 46 | }, 47 | ); 48 | 49 | console.log(response.data); 50 | } 51 | 52 | main().catch(error => { 53 | console.error('Syncing error:', error.message); 54 | process.exit(1); 55 | }); 56 | -------------------------------------------------------------------------------- /packages/cli/src/init.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import chalk from 'chalk'; 3 | import { 4 | initConfig, 5 | initDirectory, 6 | initTransform, 7 | } from '@hypermod/initializer'; 8 | 9 | export default async function init( 10 | transform?: string, 11 | preset?: string, 12 | configOnly?: boolean, 13 | targetPath = '.', 14 | ) { 15 | const packageName = 16 | targetPath !== '.' ? path.basename(targetPath) : 'Hypermod'; 17 | 18 | if (configOnly) { 19 | initConfig(packageName, targetPath); 20 | } else { 21 | initDirectory(packageName, targetPath); 22 | } 23 | 24 | if (transform) initTransform(packageName, transform, 'version', targetPath); 25 | if (preset) initTransform(packageName, preset, 'preset', targetPath); 26 | 27 | if (!configOnly) { 28 | console.log( 29 | chalk.green(`🚚 New codemod package created at: ${targetPath}`), 30 | ); 31 | 32 | console.log(` 33 | Inside that directory, you can run the following commands: 34 | 35 | ${chalk.blueBright('npm run dev')} 36 | Starts the Hypermod CLI 37 | 38 | ${chalk.blueBright('npm run test')} 39 | Launches the test runner in watch mode. 40 | 41 | ${chalk.blueBright('npm run validate')} 42 | Checks the validity of your \`hypermod.config.js\` file 43 | 44 | ${chalk.blueBright('npm run build')} 45 | Builds the app for production to the \`dist\` folder. 46 | 47 | Get started by running: 48 | 49 | ${chalk.blueBright(`cd ${packageName}`)} 50 | ${chalk.blueBright(`npm install`)} 51 | ${chalk.blueBright(`npm start test`)} 52 | `); 53 | 54 | return; 55 | } 56 | 57 | console.log( 58 | chalk.green(`🚚 New hypermod.config.js created at: ${targetPath}`), 59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /community/react/src/rename-unsafe-lifecycles/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | const DEPRECATED_APIS = Object.create(null); 4 | DEPRECATED_APIS.componentWillMount = 'UNSAFE_componentWillMount'; 5 | DEPRECATED_APIS.componentWillReceiveProps = 'UNSAFE_componentWillReceiveProps'; 6 | DEPRECATED_APIS.componentWillUpdate = 'UNSAFE_componentWillUpdate'; 7 | 8 | export default function transformer( 9 | file: FileInfo, 10 | { jscodeshift: j }: API, 11 | options: Options, 12 | ) { 13 | const root = j(file.source); 14 | 15 | let hasModifications = false; 16 | 17 | const renameDeprecatedApis = (path: any) => { 18 | const name = path.node.key.name; 19 | 20 | if (DEPRECATED_APIS[name]) { 21 | path.value.key.name = DEPRECATED_APIS[name]; 22 | hasModifications = true; 23 | } 24 | }; 25 | 26 | const renameDeprecatedCallExpressions = (path: any) => { 27 | const name = path.node.property.name; 28 | 29 | if (DEPRECATED_APIS[name]) { 30 | path.node.property.name = DEPRECATED_APIS[name]; 31 | hasModifications = true; 32 | } 33 | }; 34 | 35 | // Class methods 36 | root.find(j.MethodDefinition).forEach(renameDeprecatedApis); 37 | 38 | // Class methods - typescript 39 | root.find(j.ClassMethod).forEach(renameDeprecatedApis); 40 | 41 | // Arrow functions 42 | root.find(j.ClassProperty).forEach(renameDeprecatedApis); 43 | 44 | // createReactClass and mixins 45 | root.find(j.Property).forEach(renameDeprecatedApis); 46 | 47 | // Function calls 48 | root.find(j.MemberExpression).forEach(renameDeprecatedCallExpressions); 49 | 50 | return hasModifications ? root.toSource(options.printOptions) : null; 51 | } 52 | -------------------------------------------------------------------------------- /community/@atlaskit__calendar/src/11.0.0/motions/flatten-certain-inner-props.ts: -------------------------------------------------------------------------------- 1 | import core, { Collection, Node, ObjectExpression } from 'jscodeshift'; 2 | import { 3 | getJSXAttributes, 4 | getDefaultImportSpecifierName, 5 | } from '@hypermod/utils'; 6 | 7 | const flattenCertainChildProps = ( 8 | j: core.JSCodeshift, 9 | source: Collection, 10 | ) => { 11 | const defaultSpecifier = getDefaultImportSpecifierName( 12 | j, 13 | source, 14 | '@atlaskit/calendar', 15 | ); 16 | 17 | if (!defaultSpecifier) return; 18 | 19 | source.findJSXElements(defaultSpecifier).forEach(element => { 20 | getJSXAttributes(j, element, 'innerProps').forEach(attribute => { 21 | j(attribute) 22 | .find(j.JSXExpressionContainer) 23 | .find(j.ObjectExpression) 24 | .forEach(objectExpression => { 25 | objectExpression.node.properties.forEach(property => { 26 | ['style', 'className'].forEach(childProp => { 27 | if ( 28 | property.type === 'ObjectProperty' && 29 | property.key.type === 'Identifier' && 30 | property.key.name === childProp && 31 | element.node.openingElement.attributes 32 | ) { 33 | element.node.openingElement.attributes.push( 34 | j.jsxAttribute( 35 | j.jsxIdentifier(childProp), 36 | j.jsxExpressionContainer( 37 | property.value as ObjectExpression, 38 | ), 39 | ), 40 | ); 41 | } 42 | }); 43 | }); 44 | }); 45 | }); 46 | }); 47 | }; 48 | 49 | export default flattenCertainChildProps; 50 | -------------------------------------------------------------------------------- /community/react/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-react 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/memoize-one/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-memoize-one 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__icon/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_icon 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__menu/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_menu 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__tag/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_tag 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__avatar/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_avatar 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__button/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_button 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__popper/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_popper 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__popup/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_popup 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__range/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_range 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__toggle/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_toggle 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__calendar/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_calendar 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__checkbox/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_checkbox 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__spinner/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_spinner 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__textarea/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_textarea 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@emotion__monorepo/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-emotion\_\_monorepo 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__breadcrumbs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_breadcrumbs 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__popper/src/5.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { hasImportDeclaration, getImportSpecifierName } from '@hypermod/utils'; 3 | 4 | import updateRenderProps from './motions/update-render-props'; 5 | import updateOffset from './motions/update-offset'; 6 | import updateModifierProp from './motions/update-modifier-prop'; 7 | 8 | export default function transformer( 9 | fileInfo: FileInfo, 10 | { jscodeshift: j }: API, 11 | options: Options, 12 | ) { 13 | const source = j(fileInfo.source); 14 | 15 | /** 16 | * Early exit condition 17 | * ----- 18 | * It is often good practice to exit early and return the original source file 19 | * if it does not contain code relevant to the codemod. 20 | * See this page for more information: 21 | * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output 22 | */ 23 | if (!hasImportDeclaration(j, source, '@atlaskit/popper')) { 24 | return fileInfo.source; 25 | } 26 | 27 | const specifier = getImportSpecifierName( 28 | j, 29 | source, 30 | 'Popper', 31 | '@atlaskit/popper', 32 | ); 33 | 34 | if (!specifier) return fileInfo.source; 35 | 36 | updateRenderProps( 37 | j, 38 | source, 39 | specifier, 40 | 'outOfBoundaries', 41 | 'isReferenceHidden', 42 | ); 43 | updateRenderProps(j, source, specifier, 'scheduleUpdate', 'update'); 44 | updateOffset(j, source, specifier); 45 | updateModifierProp(j, source, specifier); 46 | 47 | /** 48 | * Return your modified AST here 👇 49 | * ----- 50 | * This is where your modified AST will be transformed back into a string 51 | * and written back to the file. 52 | */ 53 | return source.toSource(options.printOptions); 54 | } 55 | -------------------------------------------------------------------------------- /community/@atlaskit__section-message/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_section-message 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__side-navigation/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_side-navigation 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__progress-indicator/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_progress-indicator 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.3 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.2 37 | 38 | ### Patch Changes 39 | 40 | - 4a89dd20: Bumps typescript to 5.2.2 41 | - Updated dependencies [4a89dd20] 42 | - @hypermod/utils@0.4.1 43 | 44 | ## 0.3.1 45 | 46 | ### Patch Changes 47 | 48 | - Updated dependencies [be24d0c5] 49 | - @hypermod/utils@0.4.0 50 | 51 | ## 0.3.0 52 | 53 | ### Minor Changes 54 | 55 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 56 | 57 | ### Patch Changes 58 | 59 | - Updated dependencies [aa62194] 60 | - @hypermod/utils@0.3.0 61 | 62 | ## 0.2.0 63 | 64 | ### Minor Changes 65 | 66 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 67 | 68 | ## 0.1.0 69 | 70 | ### Minor Changes 71 | 72 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 73 | 74 | ### Patch Changes 75 | 76 | - Updated dependencies [26254c4] 77 | - Updated dependencies [8255eb2] 78 | - @codeshift/utils@0.2.3 79 | -------------------------------------------------------------------------------- /community/@atlaskit__breadcrumbs/src/11.0.0/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { hasImportDeclaration, applyMotions } from '@hypermod/utils'; 3 | 4 | import elevateStatelessToDefault from './motions/elevate-stateless-to-default'; 5 | import removeHasSeparator from './motions/remove-has-separator'; 6 | import renameBreadcrumbs from './motions/rename-breadcrumbs'; 7 | 8 | export default function transformer( 9 | fileInfo: FileInfo, 10 | { jscodeshift: j }: API, 11 | options: Options, 12 | ) { 13 | const source = j(fileInfo.source); 14 | 15 | /** 16 | * Early exit condition 17 | * ----- 18 | * It is often good practice to exit early and return the original source file 19 | * if it does not contain code relevant to the codemod. 20 | * See this page for more information: 21 | * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output 22 | */ 23 | if (!hasImportDeclaration(j, source, '@atlaskit/breadcrumbs')) { 24 | return fileInfo.source; 25 | } 26 | 27 | /** 28 | * Codemod logic goes here 👇 29 | * ----- 30 | * This is where the core logic for your codemod will go, 31 | * consider grouping specific actions into 'motions' and running them in sequence 32 | * 33 | * See this page for more information: 34 | * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/authoring#motions 35 | */ 36 | applyMotions(j, source, [ 37 | removeHasSeparator, 38 | elevateStatelessToDefault, 39 | renameBreadcrumbs, 40 | ]); 41 | 42 | /** 43 | * Return your modified AST here 👇 44 | * ----- 45 | * This is where your modified AST will be transformed back into a string 46 | * and written back to the file. 47 | */ 48 | return source.toSource(options.printOptions); 49 | } 50 | -------------------------------------------------------------------------------- /packages/types/src/index.ts: -------------------------------------------------------------------------------- 1 | export interface Config { 2 | /** 3 | * Targets represent the packages that the hypermod package is providing transforms to. 4 | * This is useful for filtering and grouping codemods based on the target package. 5 | * 6 | * For example, a hypermod package that is targetting react and react-dom would have 7 | * the following targets: ['react', 'react-dom']. 8 | */ 9 | targets?: string[]; 10 | 11 | /** 12 | * Github usernames of the maintainers 13 | */ 14 | maintainers?: string[]; 15 | 16 | /** 17 | * Description of the hypermod package, please explain the intetion of the package. 18 | */ 19 | description?: string; 20 | 21 | /** 22 | * Transforms are the main building blocks of a codemod. When a hypermod package 23 | * is targetting a specific package / focus area, transforms represent the 24 | * migrations between versions of the target package. 25 | * 26 | * Example react v16 -> v17, or react-dom v16 -> v17 27 | */ 28 | transforms?: Record; 29 | 30 | /** 31 | * Presets represent transforms that have no association with a specific 32 | * version of a package / focus area. These should be generic and reusable. 33 | * 34 | * Example: Format imports, remove console logs, etc. 35 | */ 36 | presets?: Record; 37 | 38 | /** 39 | * A list of dependencies to be installed before running the transform. 40 | * These are useful when co-locating codemods with an existing package 41 | * and want to whitelist devDependencies to be installed. 42 | * 43 | * Note: the versions installed are based on the package.json 44 | * 45 | * Example: dependencies: ['@hypermod/utils', 'postcss', 'postcss-less'] 46 | */ 47 | dependencies?: string[]; 48 | } 49 | 50 | export type CodeshiftConfig = Config; 51 | -------------------------------------------------------------------------------- /community/react/src/use-string-literal-props/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const withoutStringLiterals = j(file.source) 9 | .find(j.JSXAttribute) 10 | .filter( 11 | path => 12 | path.value && 13 | path.value.value && 14 | // @ts-expect-error 15 | path.value.value.expression && 16 | path.value.value.type === 'JSXExpressionContainer' && 17 | path.value.value.expression.type === 'StringLiteral', 18 | ) 19 | .forEach(path => { 20 | // @ts-expect-error 21 | path.value.value = j.stringLiteral(path.value.value.expression.value); 22 | }) 23 | .toSource(options.printOptions); 24 | 25 | const withoutTemplateLiterals = j(withoutStringLiterals) 26 | .find(j.JSXAttribute) 27 | .filter((path: any) => { 28 | return ( 29 | path.value && 30 | path.value.value && 31 | path.value.value.expression && 32 | path.value.value.type === 'JSXExpressionContainer' && 33 | path.value.value.expression && 34 | path.value.value.expression.type === 'TemplateLiteral' && 35 | path.value.value.expression.expressions && 36 | path.value.value.expression.expressions.length === 0 && 37 | path.value.value.expression.quasis && 38 | path.value.value.expression.quasis[0] && 39 | path.value.value.expression.quasis[0].value 40 | ); 41 | }) 42 | .forEach(path => { 43 | path.value.value = j.stringLiteral( 44 | // @ts-expect-error 45 | path.value.value.expression.quasis[0].value.raw, 46 | ); 47 | }) 48 | .toSource(options.printOptions); 49 | 50 | return withoutTemplateLiterals; 51 | } 52 | -------------------------------------------------------------------------------- /packages/utils/src/nodes.spec.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo } from 'jscodeshift'; 2 | import { applyTransform, isDecendantOfType } from '@hypermod/utils'; 3 | 4 | describe('nodes', () => { 5 | describe('isDecendantOfType', () => { 6 | it('detects decendant callExpression', async () => { 7 | let result = 0; 8 | const transform = (file: FileInfo, api: API) => { 9 | const j = api.jscodeshift; 10 | 11 | result = j(file.source) 12 | .find(j.Literal) 13 | .filter(literal => 14 | isDecendantOfType(j, literal, j.CallExpression), 15 | ).length; 16 | }; 17 | 18 | await applyTransform(transform, 'console.log("bar");'); 19 | 20 | expect(result).toEqual(1); 21 | }); 22 | 23 | it('correctly reports missing decendant', async () => { 24 | let result = 0; 25 | const transform = (file: FileInfo, api: API) => { 26 | const j = api.jscodeshift; 27 | 28 | result = j(file.source) 29 | .find(j.Literal) 30 | .filter(literal => 31 | isDecendantOfType(j, literal, j.CallExpression), 32 | ).length; 33 | }; 34 | 35 | await applyTransform(transform, 'const foo = "bar";'); 36 | 37 | expect(result).toEqual(0); 38 | }); 39 | 40 | it('correctly reports deeply nested decendant', async () => { 41 | let result = 0; 42 | const transform = (file: FileInfo, api: API) => { 43 | const j = api.jscodeshift; 44 | 45 | result = j(file.source) 46 | .find(j.Literal) 47 | .filter(literal => 48 | isDecendantOfType(j, literal, j.CallExpression), 49 | ).length; 50 | }; 51 | 52 | await applyTransform(transform, 'console.log(console.log("bar"));'); 53 | 54 | expect(result).toEqual(1); 55 | }); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /community/react/src/sort-jsx-props/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | 3 | export default function transformer( 4 | file: FileInfo, 5 | { jscodeshift: j }: API, 6 | options: Options, 7 | ) { 8 | const isSpreadElement = (prop: any) => 9 | prop && prop.type === 'JSXSpreadAttribute'; 10 | const isValue = (prop: any) => prop && prop.type !== 'JSXSpreadAttribute'; 11 | const getPropName = (jsxAttribute: any) => 12 | jsxAttribute.name ? jsxAttribute.name.name : '...spread'; 13 | const sortByPropName = (a: string, b: string) => { 14 | if (a < b) return -1; 15 | if (a > b) return 1; 16 | return 0; 17 | }; 18 | 19 | const sortProps = (props: any) => { 20 | props.sort((a: any, b: any) => 21 | sortByPropName(getPropName(a), getPropName(b)), 22 | ); 23 | }; 24 | 25 | return j(file.source) 26 | .find(j.JSXOpeningElement) 27 | .forEach(path => { 28 | const chunks: any[] = []; 29 | const nextAttributes: any[] = []; 30 | const jSXOpeningElement = path.value; 31 | 32 | jSXOpeningElement.attributes!.forEach((prop, i, props) => { 33 | if (isValue(prop)) { 34 | const prev = props[i - 1]; 35 | const next = props[i + 1]; 36 | const isChunkStart = !isValue(prev); 37 | const isChunkEnd = !isValue(next); 38 | 39 | isChunkStart && chunks.push([]); 40 | const [chunk] = chunks.slice(-1); 41 | chunk.push(prop); 42 | 43 | if (isChunkEnd) { 44 | sortProps(chunk); 45 | nextAttributes.push(...chunk); 46 | } 47 | } else if (isSpreadElement(prop)) { 48 | nextAttributes.push(prop); 49 | } 50 | }); 51 | 52 | jSXOpeningElement.attributes = nextAttributes; 53 | }) 54 | .toSource(options.printOptions); 55 | } 56 | -------------------------------------------------------------------------------- /community/@atlaskit__textfield/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @hypermod/mod-atlaskit\_\_textfield 2 | 3 | ## 0.4.2 4 | 5 | ### Patch Changes 6 | 7 | - 1cfe66f: Bump jscodeshift to fix JSX redundant brackets error 8 | - Updated dependencies [1cfe66f] 9 | - @hypermod/utils@0.7.1 10 | 11 | ## 0.4.1 12 | 13 | ### Patch Changes 14 | 15 | - Updated dependencies [68eabcf] 16 | - @hypermod/utils@0.7.0 17 | 18 | ## 0.4.0 19 | 20 | ### Minor Changes 21 | 22 | - 6baffa1: Bumps jscodeshift, which may have unintended side-effects 23 | 24 | ### Patch Changes 25 | 26 | - Updated dependencies [6baffa1] 27 | - @hypermod/utils@0.6.0 28 | 29 | ## 0.3.4 30 | 31 | ### Patch Changes 32 | 33 | - Updated dependencies [c17dd18] 34 | - @hypermod/utils@0.5.0 35 | 36 | ## 0.3.3 37 | 38 | ### Patch Changes 39 | 40 | - 6e3ab50: Removes unused variables 41 | 42 | ## 0.3.2 43 | 44 | ### Patch Changes 45 | 46 | - 4a89dd20: Bumps typescript to 5.2.2 47 | - Updated dependencies [4a89dd20] 48 | - @hypermod/utils@0.4.1 49 | 50 | ## 0.3.1 51 | 52 | ### Patch Changes 53 | 54 | - Updated dependencies [be24d0c5] 55 | - @hypermod/utils@0.4.0 56 | 57 | ## 0.3.0 58 | 59 | ### Minor Changes 60 | 61 | - aa62194: This package has moved scopes from `@codeshift` to `@hypermod`. All internal `@codeshift` dependencies and references have been updated as a result. 62 | 63 | ### Patch Changes 64 | 65 | - Updated dependencies [aa62194] 66 | - @hypermod/utils@0.3.0 67 | 68 | ## 0.2.0 69 | 70 | ### Minor Changes 71 | 72 | - a9defa8: require.resolve is no longer supported and have been replaced by require statements 73 | 74 | ## 0.1.0 75 | 76 | ### Minor Changes 77 | 78 | - 8255eb2: Community codeshift packages are now built via parcel and managed via changesets 79 | 80 | ### Patch Changes 81 | 82 | - Updated dependencies [26254c4] 83 | - Updated dependencies [8255eb2] 84 | - @codeshift/utils@0.2.3 85 | -------------------------------------------------------------------------------- /packages/cli/src/prompt.ts: -------------------------------------------------------------------------------- 1 | import inquirer from 'inquirer'; 2 | 3 | import { Config } from '@hypermod/types'; 4 | 5 | export const getConfigPrompt = (config: Config) => { 6 | const transforms = Object.keys(config.transforms || {}); 7 | const presets = Object.keys(config.presets || {}); 8 | 9 | const choices = [ 10 | transforms.length ? new inquirer.Separator('Transforms') : undefined, 11 | ...transforms, 12 | presets.length ? new inquirer.Separator('Presets') : undefined, 13 | ...presets, 14 | ].filter(item => item !== undefined); 15 | 16 | return { 17 | type: 'list', 18 | name: 'codemod', 19 | message: 'Which codemod would you like to run?', 20 | choices, 21 | }; 22 | }; 23 | 24 | export const getMultiConfigPrompt = ( 25 | configs: { filePath: string; config: Config }[], 26 | ) => { 27 | const choices = configs.reduce((accum, { filePath, config }) => { 28 | function mapToConfig(codemods: Record = {}) { 29 | return Object.keys(codemods).map(codemodKey => ({ 30 | name: codemodKey, 31 | value: { 32 | filePath, 33 | selection: codemodKey, 34 | }, 35 | short: `${codemodKey} from ${filePath}`, 36 | })); 37 | } 38 | 39 | const transforms = mapToConfig(config.transforms); 40 | const presets = mapToConfig(config.presets); 41 | 42 | return [ 43 | ...accum, 44 | new inquirer.Separator(filePath), 45 | transforms.length ? new inquirer.Separator('Transforms') : undefined, 46 | ...transforms, 47 | presets.length ? new inquirer.Separator('Presets') : undefined, 48 | ...presets, 49 | ].filter(item => item !== undefined); 50 | }, []); 51 | 52 | return { 53 | type: 'list', 54 | name: 'codemod', 55 | message: 'Which codemod would you like to run?', 56 | choices, 57 | }; 58 | }; 59 | -------------------------------------------------------------------------------- /packages/cli/src/list.ts: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | import { PluginManager } from 'live-plugin-manager'; 3 | 4 | import { fetchNpmPkg } from './fetchers/npm'; 5 | import { getHypermodPackageName } from './utils/package-names'; 6 | 7 | export default async function list(packages: string[]) { 8 | const packageManager = new PluginManager() as any; 9 | const configs = []; 10 | 11 | for (const packageName of packages) { 12 | try { 13 | const { community, remote } = await fetchNpmPkg( 14 | packageName, 15 | packageManager, 16 | ); 17 | community && 18 | configs.push({ 19 | packageName: getHypermodPackageName(packageName), 20 | config: community.config, 21 | }); 22 | remote && configs.push({ packageName, config: remote.config }); 23 | } catch (error) { 24 | console.warn( 25 | chalk.red( 26 | `Unable to find Hypermod package: ${chalk.bold(packageName)}.`, 27 | ), 28 | ); 29 | 30 | continue; 31 | } 32 | } 33 | 34 | configs.forEach(({ packageName, config }) => { 35 | console.log(chalk.bold(packageName)); 36 | 37 | if (config.transforms) { 38 | console.log(`├─ transforms`); 39 | Object.keys(config.transforms).forEach((transform, index, array) => { 40 | if (index + 1 === array.length) { 41 | console.log(`| └─ ${transform}`); 42 | return; 43 | } 44 | console.log(`| ├─ ${transform}`); 45 | }); 46 | } 47 | 48 | if (config.presets) { 49 | console.log(`└─ presets`); 50 | Object.keys(config.presets).forEach((transform, index, array) => { 51 | if (index + 1 === array.length) { 52 | console.log(` └─ ${transform}`); 53 | return; 54 | } 55 | console.log(`| ├─ ${transform}`); 56 | }); 57 | } 58 | }); 59 | } 60 | -------------------------------------------------------------------------------- /scripts/cli-integration-test.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { writeFileSync, readFileSync } = require('fs'); 3 | const { execSync } = require('child_process'); 4 | 5 | function main() { 6 | { 7 | const targetFilePath = path.join(__dirname, 'remove-debugger-test1.ts'); 8 | writeFileSync(targetFilePath, `function hello() { debugger; }`); 9 | 10 | execSync( 11 | `npx --yes @hypermod/cli@latest --packages javascript#remove-debugger --verbose="0" ${targetFilePath}`, 12 | { stdio: 'inherit' }, 13 | ); 14 | 15 | const targetFileOutput = readFileSync(targetFilePath, 'utf-8'); 16 | const expectedFileOutput = `function hello() {}`; 17 | 18 | if (targetFileOutput !== expectedFileOutput) { 19 | throw new Error( 20 | `Expected ${targetFileOutput} to equal ${expectedFileOutput}`, 21 | ); 22 | } 23 | 24 | console.log('RESULT -------------'); 25 | console.log('Correctly removed debugger statement'); 26 | } 27 | 28 | { 29 | const targetFilePath = path.join(__dirname, 'remove-unused-vars-test2.ts'); 30 | writeFileSync( 31 | targetFilePath, 32 | `export function hello() { var a = 1; debugger; }`, 33 | ); 34 | 35 | execSync( 36 | `npx --yes @hypermod/cli@latest --packages javascript#remove-unused-vars --experimental-loader --verbose="0" ${targetFilePath}`, 37 | { stdio: 'inherit' }, 38 | ); 39 | 40 | const targetFileOutput = readFileSync(targetFilePath, 'utf-8'); 41 | const expectedFileOutput = `export function hello() { 42 | debugger; 43 | }`; 44 | 45 | if (targetFileOutput !== expectedFileOutput) { 46 | throw new Error( 47 | `Expected ${targetFileOutput} to equal ${expectedFileOutput}`, 48 | ); 49 | } 50 | 51 | console.log('RESULT -------------'); 52 | console.log('Correctly removed unused var statement'); 53 | } 54 | } 55 | 56 | main(); 57 | -------------------------------------------------------------------------------- /website/sidebars.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | docs: [ 3 | { 4 | label: 'Getting Started', 5 | type: 'category', 6 | collapsed: false, 7 | items: [ 8 | 'introduction', 9 | 'guiding-principles', 10 | 'faq', 11 | 'ecosystem', 12 | 'glossary', 13 | ], 14 | }, 15 | { 16 | label: 'Docs', 17 | type: 'category', 18 | collapsed: false, 19 | items: [ 20 | 'authoring', 21 | 'consuming', 22 | 'configuration', 23 | 'testing', 24 | 'motions', 25 | 'contribution', 26 | 'external-packages', 27 | ], 28 | }, 29 | { 30 | label: 'Guides', 31 | type: 'category', 32 | collapsed: false, 33 | items: [ 34 | 'guides/your-first-codemod', 35 | 'guides/understanding-asts', 36 | 'guides/when-not-to-codemod', 37 | 'guides/prompting-for-human-input', 38 | 'guides/css-codemods', 39 | 'guides/monorepos', 40 | ], 41 | }, 42 | { 43 | label: 'Recipes', 44 | type: 'category', 45 | collapsed: false, 46 | items: [ 47 | 'recipes/import-manipulation', 48 | 'recipes/react', 49 | 'recipes/typescript', 50 | ], 51 | }, 52 | ], 53 | api: [ 54 | { 55 | label: 'Packages', 56 | type: 'category', 57 | collapsible: false, 58 | collapsed: false, 59 | items: ['api/cli', 'api/utils'], 60 | }, 61 | ], 62 | registry: [ 63 | { 64 | label: 'Registry', 65 | type: 'category', 66 | collapsible: false, 67 | collapsed: false, 68 | link: { 69 | type: 'doc', 70 | id: 'registry', 71 | }, 72 | items: [ 73 | { 74 | dirName: 'registry-generated', 75 | type: 'autogenerated', 76 | }, 77 | ], 78 | }, 79 | ], 80 | }; 81 | -------------------------------------------------------------------------------- /packages/core/src/types.ts: -------------------------------------------------------------------------------- 1 | import { FileInfo, API, Options } from 'jscodeshift'; 2 | 3 | type Actions = 'status' | 'update' | 'free' | 'report'; 4 | export type Statuses = 'error' | 'ok' | 'nochange' | 'skip'; 5 | 6 | export interface Message { 7 | action: Actions; 8 | status: Statuses; 9 | file: string; 10 | msg: string; 11 | name: string; 12 | quantity: number; 13 | } 14 | 15 | export type Transform = ( 16 | fileInfo: FileInfo, 17 | { jscodeshift }: API, 18 | options: Options, 19 | ) => string; 20 | 21 | export interface Flags { 22 | /** 23 | * The transform to run 24 | */ 25 | transform?: string; 26 | /** 27 | * Comma separated list of packages to run transforms for, @scope/package[@version]. If version is supplied, will only run transforms above that version 28 | */ 29 | packages?: string; 30 | /** 31 | * If the package flag is provided, runs all transforms from the provided version to the latest 32 | */ 33 | sequence?: boolean; 34 | /** 35 | * Parser to use for parsing the source files 36 | */ 37 | parser?: 'babel' | 'babylon' | 'flow' | 'ts' | 'tsx'; 38 | /** 39 | * Transform files with these file extensions (comma separated list) 40 | */ 41 | extensions?: string; 42 | /** 43 | * Ignore files that match a provided glob expression 44 | */ 45 | ignorePattern?: string; 46 | 47 | /** Auxiliary jscodeshift params */ 48 | cpus?: number; 49 | dry?: boolean; 50 | runInBand?: boolean; 51 | 52 | /** Package registry url that will be used to fetch the packages from. */ 53 | registry?: string; 54 | /** Authentication token that will be used to fetch packages from the registry. */ 55 | registryToken?: string; 56 | babel: boolean; 57 | failOnError: boolean; 58 | ignoreConfig: string[]; 59 | parserConfig: string; 60 | print: boolean; 61 | silent: boolean; 62 | stdin: boolean; 63 | verbose?: 0 | 1 | 2; 64 | experimentalLoader: boolean; 65 | } 66 | -------------------------------------------------------------------------------- /community/react/src/remove-default-props/motions/moveDefaultPropsToFunctionDeclaration.ts: -------------------------------------------------------------------------------- 1 | import { JSCodeshift, Collection } from 'jscodeshift'; 2 | import { getNewParams } from './getNewParams'; 3 | 4 | export function moveDefaultPropsToFunctionDeclaration( 5 | j: JSCodeshift, 6 | source: Collection, 7 | ) { 8 | source 9 | .find(j.FunctionDeclaration) 10 | .forEach(component => { 11 | const defaultProps = source.find(j.AssignmentExpression, { 12 | left: { 13 | object: { name: component.node.id?.name }, 14 | property: { name: 'defaultProps' }, 15 | }, 16 | }); 17 | 18 | if (defaultProps.length === 0) return; 19 | 20 | // Extract the default props object 21 | const defaultValues = defaultProps.get('right').value.properties; 22 | 23 | // Generate a new function parameter for each default prop 24 | const defaultParams = defaultValues.map((prop: any) => { 25 | const key = prop.key.name; 26 | const value = prop.value.value; 27 | // return j.objectPattern(`${key}=${JSON.stringify(value)}`); 28 | return j.objectProperty( 29 | j.identifier(key), 30 | j.assignmentPattern(j.identifier(key), j.literal(value)), 31 | ); 32 | }); 33 | // Find the defaultProps assignment expression 34 | const newParams = getNewParams(j, component, defaultParams); 35 | // Replace the original function declaration with a new one 36 | j(component).replaceWith(nodePath => 37 | j.functionDeclaration( 38 | nodePath.node.id, 39 | newParams!, 40 | nodePath.node.body, 41 | nodePath.node.generator, 42 | nodePath.node.async, 43 | ), 44 | ); 45 | }) 46 | .find(j.AssignmentExpression, { 47 | left: { 48 | object: { type: 'Identifier' }, 49 | property: { name: 'defaultProps' }, 50 | }, 51 | }) 52 | .toSource(); 53 | } 54 | -------------------------------------------------------------------------------- /community/@atlaskit__toggle/src/12.0.0/motions/rename-togglestateless.ts: -------------------------------------------------------------------------------- 1 | import core, { ASTPath, Collection, Identifier } from 'jscodeshift'; 2 | import { 3 | getImportDeclaration, 4 | getDefaultImportSpecifierName, 5 | } from '@hypermod/utils'; 6 | 7 | function getSafeImportName( 8 | j: core.JSCodeshift, 9 | base: Collection, 10 | currentDefaultSpecifierName: string, 11 | desiredName: string, 12 | fallbackName: string, 13 | ) { 14 | if (currentDefaultSpecifierName === desiredName) { 15 | return desiredName; 16 | } 17 | 18 | const isUsed = 19 | base 20 | .find(j.Identifier) 21 | .filter( 22 | (identifer: ASTPath) => 23 | identifer.value.name === desiredName, 24 | ).length > 0; 25 | 26 | return isUsed ? fallbackName : desiredName; 27 | } 28 | 29 | const renameToggleStateless = (j: core.JSCodeshift, source: any) => { 30 | const component = '@atlaskit/toggle'; 31 | const from = 'ToggleStateless'; 32 | const to = 'Toggle'; 33 | const fallback = 'DSToggle'; 34 | 35 | const defaultSpecifier = getDefaultImportSpecifierName(j, source, component); 36 | 37 | const toName = fallback 38 | ? getSafeImportName(j, source, defaultSpecifier!, to, fallback) 39 | : to; 40 | 41 | getImportDeclaration(j, source, component).forEach(path => { 42 | j(path).replaceWith( 43 | j.importDeclaration( 44 | [j.importDefaultSpecifier(j.identifier(toName))], 45 | j.literal(component), 46 | ), 47 | ); 48 | }); 49 | 50 | source 51 | .find(j.JSXElement) 52 | .find(j.JSXOpeningElement) 53 | .forEach( 54 | (path: ASTPath) => 55 | !!j(path.node) 56 | .find(j.JSXIdentifier) 57 | .filter(identifier => identifier.value.name === from) 58 | .forEach(element => { 59 | j(element).replaceWith(j.jsxIdentifier(toName)); 60 | }), 61 | ); 62 | }; 63 | 64 | export default renameToggleStateless; 65 | -------------------------------------------------------------------------------- /community/javascript/src/sort-object-props/transform.spec.ts: -------------------------------------------------------------------------------- 1 | import { applyTransform } from '@hypermod/utils'; 2 | import * as transformer from './transform'; 3 | 4 | describe('javascript#sort-object-props transform', () => { 5 | it('should sort object props', async () => { 6 | const result = await applyTransform( 7 | transformer, 8 | ` 9 | const foo = { 10 | frog: 'frog', 11 | potato: 'potato', 12 | cat: 'cat', 13 | apple: 'apple', 14 | zebra: 'zebra', 15 | dog: 'dog', 16 | } 17 | `, 18 | { parser: 'tsx' }, 19 | ); 20 | 21 | expect(result).toMatchInlineSnapshot(` 22 | "const foo = { 23 | apple: 'apple', 24 | cat: 'cat', 25 | dog: 'dog', 26 | frog: 'frog', 27 | potato: 'potato', 28 | zebra: 'zebra', 29 | }" 30 | `); 31 | }); 32 | 33 | it('should not error on with empty objects', async () => { 34 | const result = await applyTransform(transformer, `const foo = {};`, { 35 | parser: 'tsx', 36 | }); 37 | 38 | expect(result).toMatchInlineSnapshot(`"const foo = {};"`); 39 | }); 40 | 41 | it('should handle nested objects', async () => { 42 | const result = await applyTransform( 43 | transformer, 44 | ` 45 | const foo = { 46 | frog: 'frog', 47 | potato: 'potato', 48 | cat: 'cat', 49 | apple: 'apple', 50 | dogs: { 51 | wolf: 'wolf', 52 | staffy: 'staffy', 53 | puppy: 'puppy', 54 | poodle: 'poodle', 55 | }, 56 | zebra: 'zebra', 57 | } 58 | `, 59 | { 60 | parser: 'tsx', 61 | }, 62 | ); 63 | 64 | expect(result).toMatchInlineSnapshot(` 65 | "const foo = { 66 | apple: 'apple', 67 | cat: 'cat', 68 | dogs: { 69 | poodle: 'poodle', 70 | puppy: 'puppy', 71 | staffy: 'staffy', 72 | wolf: 'wolf', 73 | }, 74 | frog: 'frog', 75 | potato: 'potato', 76 | zebra: 'zebra', 77 | }" 78 | `); 79 | }); 80 | }); 81 | -------------------------------------------------------------------------------- /community/javascript/src/remove-unused-vars/transform.ts: -------------------------------------------------------------------------------- 1 | import { API, FileInfo, Options } from 'jscodeshift'; 2 | import { isDecendantOfType } from '@hypermod/utils'; 3 | 4 | export default function transformer( 5 | file: FileInfo, 6 | { jscodeshift: j }: API, 7 | options: Options, 8 | ) { 9 | const source = j(file.source); 10 | 11 | source 12 | .find(j.VariableDeclaration) 13 | .filter( 14 | variableDeclaration => 15 | variableDeclaration.parent.value.type !== 'ExportNamedDeclaration', 16 | ) 17 | .forEach(path => { 18 | const declaration = path.value.declarations[0]; 19 | if (!declaration) return; 20 | 21 | // @ts-ignore 22 | const variableName = declaration.id.name; 23 | 24 | // Check if the variable is used elsewhere in the code 25 | const isUsed = 26 | source 27 | .find(j.Identifier, { name: variableName }) 28 | .filter( 29 | identifier => 30 | !isDecendantOfType(j, identifier, j.VariableDeclaration), 31 | ) 32 | .size() >= 1; 33 | 34 | if (!isUsed) { 35 | j(path).remove(); 36 | } 37 | }); 38 | 39 | source 40 | .find(j.FunctionDeclaration) 41 | .filter( 42 | functionDeclaration => 43 | functionDeclaration.parent.value.type !== 'ExportNamedDeclaration', 44 | ) 45 | .forEach(path => { 46 | const functionName = path.value.id?.name; 47 | 48 | // Check if the variable is used elsewhere in the code 49 | const isUsed = 50 | source 51 | .find(j.Identifier, { name: functionName }) 52 | .filter( 53 | identifier => 54 | !isDecendantOfType(j, identifier, j.FunctionDeclaration, { 55 | id: { name: functionName }, 56 | }), 57 | ) 58 | .size() >= 1; 59 | 60 | if (!isUsed) { 61 | j(path).remove(); 62 | } 63 | }); 64 | 65 | return source.toSource(options.printOptions); 66 | } 67 | -------------------------------------------------------------------------------- /community/@atlaskit__section-message/src/6.0.0/utils.ts: -------------------------------------------------------------------------------- 1 | import core, { Collection, CallExpression } from 'jscodeshift'; 2 | 3 | function isCallExpressionCalleeImportType(callee: CallExpression['callee']) { 4 | return callee && callee.type === 'Import'; 5 | } 6 | function isCallExpressionArgumentStringLiteralType( 7 | callExpressionArguments: CallExpression['arguments'], 8 | ) { 9 | return ( 10 | callExpressionArguments && 11 | callExpressionArguments.length && 12 | callExpressionArguments[0].type === 'StringLiteral' 13 | ); 14 | } 15 | function isCallExpressionArgumentValueMatches( 16 | callExpressionArgument: CallExpression['arguments'][0], 17 | j: core.JSCodeshift, 18 | value: string, 19 | ) { 20 | return j(callExpressionArgument).some(path => path.node.value === value); 21 | } 22 | 23 | export function getDynamicImportName( 24 | j: core.JSCodeshift, 25 | source: Collection, 26 | importPath: string, 27 | ) { 28 | const dynamicImports = source 29 | .find(j.VariableDeclarator) 30 | .filter(variableDeclaratorPath => { 31 | return ( 32 | j(variableDeclaratorPath) 33 | .find(j.CallExpression) 34 | .filter(callExpressionPath => { 35 | const { callee, arguments: callExpressionArguments } = 36 | callExpressionPath.node; 37 | 38 | return !!( 39 | isCallExpressionCalleeImportType(callee) && 40 | isCallExpressionArgumentStringLiteralType( 41 | callExpressionArguments, 42 | ) && 43 | isCallExpressionArgumentValueMatches( 44 | callExpressionArguments[0], 45 | j, 46 | importPath, 47 | ) 48 | ); 49 | }).length > 0 50 | ); 51 | }); 52 | 53 | if (!dynamicImports.length) { 54 | return null; 55 | } 56 | 57 | const { id } = dynamicImports.nodes()[0]; 58 | 59 | if (id.type !== 'Identifier') { 60 | return null; 61 | } 62 | 63 | return id.name; 64 | } 65 | --------------------------------------------------------------------------------