├── .gitignore ├── assets ├── logo.png ├── logo-square.png ├── extension-demo.gif ├── logo.svg └── logo-square.svg ├── src ├── test │ ├── components │ │ ├── shortHand │ │ │ ├── export.js │ │ │ ├── export.ts │ │ │ ├── shortHand.jsx │ │ │ ├── shortHand.tsx │ │ │ ├── shortHandResult.jsx │ │ │ └── shortHandResult.tsx │ │ ├── onlyStatic │ │ │ ├── export.js │ │ │ ├── export.ts │ │ │ ├── onlyStatic.jsx │ │ │ ├── onlyStatic.tsx │ │ │ ├── onlyStaticResult.jsx │ │ │ └── onlyStaticResult.tsx │ │ ├── static │ │ │ ├── export.js │ │ │ ├── export.ts │ │ │ ├── static.jsx │ │ │ ├── static.tsx │ │ │ ├── staticResult.jsx │ │ │ └── staticResult.tsx │ │ ├── spread │ │ │ ├── spread.jsx │ │ │ ├── spreadResult.jsx │ │ │ ├── spread.tsx │ │ │ └── spreadResult.tsx │ │ ├── destructureRename │ │ │ ├── destructureRename.jsx │ │ │ ├── destructureRename.tsx │ │ │ ├── destructureRenameResult.jsx │ │ │ └── destructureRenameResult.tsx │ │ ├── spreadAny │ │ │ ├── spreadAny.tsx │ │ │ └── spreadAnyResult.tsx │ │ ├── wrapInFragment │ │ │ ├── wrapInFragment.jsx │ │ │ ├── wrapInFragment.tsx │ │ │ ├── wrapInFragmentResult.jsx │ │ │ └── wrapInFragmentResult.tsx │ │ ├── noProps │ │ │ ├── noProps.jsx │ │ │ ├── noProps.tsx │ │ │ ├── noPropsResult.jsx │ │ │ └── noPropsResult.tsx │ │ ├── typeTypeDeclarationEmpty │ │ │ ├── typeTypeDeclarationEmpty.tsx │ │ │ └── typeTypeDeclarationEmptyResult.tsx │ │ ├── undestructuredPropsEmpty │ │ │ ├── undestructuredPropsEmpty.jsx │ │ │ ├── undestructuredPropsEmpty.tsx │ │ │ ├── undestructuredPropsEmptyResult.jsx │ │ │ └── undestructuredPropsEmptyResult.tsx │ │ ├── arrowFunctionDeclarationEmpty │ │ │ ├── arrowFunctionDeclarationEmpty.jsx │ │ │ ├── arrowFunctionDeclarationEmpty.tsx │ │ │ ├── arrowFunctionDeclarationEmptyResult.jsx │ │ │ └── arrowFunctionDeclarationEmptyResult.tsx │ │ ├── typeInlineDeclarationEmpty │ │ │ ├── typeInlineDeclarationEmpty.tsx │ │ │ └── typeInlineDeclarationEmptyResult.tsx │ │ ├── undestructuredPropsSpreadAttribute │ │ │ ├── undestructuredPropsSpreadAttribute.jsx │ │ │ ├── undestructuredPropsSpreadAttribute.tsx │ │ │ ├── undestructuredPropsSpreadAttributeResult.jsx │ │ │ └── undestructuredPropsSpreadAttributeResult.tsx │ │ ├── destructureNested │ │ │ ├── destructureNested.jsx │ │ │ ├── destructureNested.tsx │ │ │ ├── destructureNestedResult.jsx │ │ │ └── destructureNestedResult.tsx │ │ ├── reactFCTypeEmpty │ │ │ ├── reactFCTypeEmpty.tsx │ │ │ └── reactFCTypeEmptyResult.tsx │ │ ├── fragment │ │ │ ├── fragment.jsx │ │ │ ├── fragment.tsx │ │ │ ├── fragmentResult.jsx │ │ │ └── fragmentResult.tsx │ │ ├── arrowFunctionExplicitReturn │ │ │ ├── arrowFunctionExplicitReturn.jsx │ │ │ └── arrowFunctionExplicitReturnResult.jsx │ │ ├── parameter │ │ │ ├── parameter.jsx │ │ │ ├── parameterResult.jsx │ │ │ ├── parameter.tsx │ │ │ └── parameterResult.tsx │ │ ├── reactFCType │ │ │ ├── reactFCType.jsx │ │ │ ├── reactFCType.tsx │ │ │ ├── reactFCTypeResult.jsx │ │ │ └── reactFCTypeResult.tsx │ │ ├── textChild │ │ │ ├── textChild.jsx │ │ │ ├── textChild.tsx │ │ │ ├── textChildResult.jsx │ │ │ └── textChildResult.tsx │ │ ├── undestructuredProps │ │ │ ├── undestructuredProps.jsx │ │ │ ├── undestructuredProps.tsx │ │ │ ├── undestructuredPropsResult.jsx │ │ │ └── undestructuredPropsResult.tsx │ │ ├── spreadArray │ │ │ ├── spreadArray.jsx │ │ │ ├── spreadArray.tsx │ │ │ ├── spreadArrayResult.jsx │ │ │ └── spreadArrayResult.tsx │ │ ├── typeTypeDeclaration │ │ │ ├── typeTypeDeclaration.tsx │ │ │ └── typeTypeDeclarationResult.tsx │ │ ├── typeInlineDeclaration │ │ │ ├── typeInlineDeclaration.tsx │ │ │ └── typeInlineDeclarationResult.tsx │ │ ├── typeInlineDeclarationReactFC │ │ │ ├── typeInlineDeclarationReactFC.tsx │ │ │ └── typeInlineDeclarationReactFCResult.tsx │ │ ├── arrowFunctionDeclarationSpread │ │ │ ├── arrowFunctionDeclarationSpread.jsx │ │ │ ├── arrowFunctionDeclarationSpread.tsx │ │ │ ├── arrowFunctionDeclarationSpreadResult.jsx │ │ │ └── arrowFunctionDeclarationSpreadResult.tsx │ │ ├── parameterTypeReference │ │ │ ├── parameterTypeReference.tsx │ │ │ └── parameterTypeReferenceResult.tsx │ │ ├── componentAsProps │ │ │ ├── componentAsProps.jsx │ │ │ ├── componentAsProps.tsx │ │ │ ├── componentAsPropsResult.jsx │ │ │ └── componentAsPropsResult.tsx │ │ ├── spreadNestedTypeReference │ │ │ ├── spreadNestedTypeReference.tsx │ │ │ └── spreadNestedTypeReferenceResult.tsx │ │ ├── typeTypeDeclarationExtended │ │ │ ├── typeTypeDeclarationExtended.tsx │ │ │ └── typeTypeDeclarationExtendedResult.tsx │ │ ├── typeInlineDeclarationExtended │ │ │ ├── typeInlineDeclarationExtended.tsx │ │ │ └── typeInlineDeclarationExtendedResult.tsx │ │ ├── implicit │ │ │ ├── implicit.jsx │ │ │ ├── implicit.tsx │ │ │ ├── implicitResult.jsx │ │ │ └── implicitResult.tsx │ │ ├── spreadNested │ │ │ ├── spreadNested.jsx │ │ │ ├── spreadNestedResult.jsx │ │ │ ├── spreadNested.tsx │ │ │ └── spreadNestedResult.tsx │ │ ├── componentAsFunction │ │ │ ├── componentAsFunction.jsx │ │ │ ├── componentAsFunction.tsx │ │ │ ├── componentAsFunctionResult.jsx │ │ │ └── componentAsFunctionResult.tsx │ │ ├── conditional │ │ │ ├── conditional.jsx │ │ │ ├── conditional.tsx │ │ │ ├── conditionalResult.jsx │ │ │ └── conditionalResult.tsx │ │ ├── map │ │ │ ├── map.jsx │ │ │ ├── map.tsx │ │ │ ├── mapResult.jsx │ │ │ └── mapResult.tsx │ │ ├── subSelection │ │ │ ├── subSelection.jsx │ │ │ ├── subSelection.tsx │ │ │ ├── subSelectionResult.jsx │ │ │ └── subSelectionResult.tsx │ │ ├── propertiesAndMethods │ │ │ ├── propertiesAndMethods.jsx │ │ │ ├── propertiesAndMethods.tsx │ │ │ ├── propertiesAndMethodsResult.jsx │ │ │ └── propertiesAndMethodsResult.tsx │ │ ├── longType │ │ │ ├── longType.tsx │ │ │ └── longTypeResult.tsx │ │ └── undestructuredPropsExtended │ │ │ ├── undestructuredPropsExtended.jsx │ │ │ └── undestructuredPropsExtendedResult.jsx │ ├── createTestCase.js │ ├── checks.test.ts │ ├── isJsx.test.ts │ ├── utils.test.ts │ ├── common.ts │ └── extractComponent.test.ts ├── checks.ts ├── parsers │ ├── parsingUtils.ts │ ├── fragment.ts │ ├── isJsx.ts │ ├── replacePropsWithFullPath.ts │ ├── getNodeType.ts │ └── extractProps.ts ├── typescriptProgram.ts ├── utils.ts ├── extension.ts ├── types.ts └── extractComponent.ts ├── .vscode-test.mjs ├── tsconfig.json ├── .prettierrc ├── .vscode ├── extensions.json ├── tasks.json ├── settings.json └── launch.json ├── .vscodeignore ├── .eslintrc.json ├── LICENSE ├── webpack.config.js ├── CHANGELOG.md ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules 4 | .vscode-test/ 5 | *.vsix 6 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joao-mbn/react-extract/HEAD/assets/logo.png -------------------------------------------------------------------------------- /src/test/components/shortHand/export.js: -------------------------------------------------------------------------------- 1 | export const shortHandImport = 'shortHandImport'; 2 | 3 | -------------------------------------------------------------------------------- /src/test/components/shortHand/export.ts: -------------------------------------------------------------------------------- 1 | export const shortHandImport = 'shortHandImport'; 2 | 3 | -------------------------------------------------------------------------------- /assets/logo-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joao-mbn/react-extract/HEAD/assets/logo-square.png -------------------------------------------------------------------------------- /assets/extension-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joao-mbn/react-extract/HEAD/assets/extension-demo.gif -------------------------------------------------------------------------------- /src/test/components/onlyStatic/export.js: -------------------------------------------------------------------------------- 1 | export const VALUE = 42; 2 | export const CLASS_NAME = 'class'; 3 | -------------------------------------------------------------------------------- /src/test/components/onlyStatic/export.ts: -------------------------------------------------------------------------------- 1 | export const VALUE = 42; 2 | export const CLASS_NAME = 'class'; 3 | -------------------------------------------------------------------------------- /src/test/components/static/export.js: -------------------------------------------------------------------------------- 1 | export const VALUE = 42; 2 | export const CLASS_NAME = 'class'; 3 | -------------------------------------------------------------------------------- /src/test/components/static/export.ts: -------------------------------------------------------------------------------- 1 | export const VALUE = 42; 2 | export const CLASS_NAME = 'class'; 3 | -------------------------------------------------------------------------------- /src/test/components/spread/spread.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Component({ ...props }) { 4 | return
; 5 | } 6 | -------------------------------------------------------------------------------- /src/checks.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | 3 | export function isFileTypescript(document: vscode.TextDocument) { 4 | return document.languageId === 'typescript' || document.languageId === 'typescriptreact'; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /src/test/components/destructureRename/destructureRename.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Component() { 4 | const { colour: color } = { colour: 'red' }; 5 | 6 | return
Test
; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/test/components/destructureRename/destructureRename.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Component() { 4 | const { colour: color } = { colour: 'red' }; 5 | 6 | return
Test
; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/test/components/spreadAny/spreadAny.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Component({ children, ...props }: any) { 4 | return ( 5 |
6 |
{children}
7 |
8 | ); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /.vscode-test.mjs: -------------------------------------------------------------------------------- 1 | import { defineConfig } from '@vscode/test-cli'; 2 | 3 | export default defineConfig({ 4 | files: 'out/test/**/*.test.js', 5 | mocha: { 6 | timeout: 1000000 7 | }, 8 | launchArgs: ['--disable-extensions'] 9 | }); 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react", 4 | "module": "Node16", 5 | "target": "ES2022", 6 | "lib": ["ES2022"], 7 | "sourceMap": true, 8 | "rootDir": "src", 9 | "strict": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/components/spread/spreadResult.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Component({ ...props }) { 4 | return ; 5 | } 6 | 7 | function Extracted({ ...props }) { 8 | return
; 9 | } 10 | -------------------------------------------------------------------------------- /src/test/components/wrapInFragment/wrapInFragment.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | function Component() { 4 | return ( 5 |
6 |