ts-morph-react 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -7
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ A powerful collection of **AST transformers for ts-morph** to automate React cod
|
|
|
11
11
|
- 🔄 **Enforce Direct Exports** - Convert separate export statements to direct exports on function declarations
|
|
12
12
|
- 🎯 **Function Components** - Automatically convert function declarations to arrow function components with proper typing
|
|
13
13
|
- 📦 **Named Imports** - Transform default imports to named imports for consistency
|
|
14
|
-
- 🎨 **Code Formatting** - Format code and organize imports according to your style guide
|
|
14
|
+
- 🎨 **Code Formatting** - Format code and organize imports according to your style guide (using ESLint, Prettier or Typescript Language Featues)
|
|
15
15
|
- ⚡ **Composable** - Mix and match transformers to create your refactoring pipeline
|
|
16
16
|
- 🛡️ **Type-Safe** - Built with TypeScript for a fully typed experience
|
|
17
17
|
- 🎭 **AST-Powered** - Leverage ts-morph for precise, reliable code transformations
|
|
@@ -42,7 +42,10 @@ await transform(sourceFile, {
|
|
|
42
42
|
enforceDirectExports: true,
|
|
43
43
|
enforceFunctionComponent: true,
|
|
44
44
|
enforceNamedImports: true,
|
|
45
|
-
enforceFormat: true
|
|
45
|
+
enforceFormat: true,
|
|
46
|
+
enforcePrettier: true,
|
|
47
|
+
enforceEslint: true,
|
|
48
|
+
enforceLineSeparation: true
|
|
46
49
|
})
|
|
47
50
|
|
|
48
51
|
// Save changes
|
|
@@ -111,9 +114,9 @@ export const Button: FunctionComponent<ButtonProps> = ({ label }) => {
|
|
|
111
114
|
}
|
|
112
115
|
```
|
|
113
116
|
|
|
114
|
-
### enforceFormat
|
|
117
|
+
### enforceEslint / enforcePrettier / enforceFormat
|
|
115
118
|
|
|
116
|
-
Formats code and organizes imports according to your style guide. Respects all standard TypeScript formatting options.
|
|
119
|
+
Formats code and organizes imports according to your style guide. Respects all standard TypeScript formatting options, eslint rules and prettier options.
|
|
117
120
|
|
|
118
121
|
**Usage:**
|
|
119
122
|
```tsx
|
|
@@ -121,10 +124,20 @@ import { transform } from 'ts-morph-react'
|
|
|
121
124
|
|
|
122
125
|
await transform(sourceFile, {
|
|
123
126
|
enforceFormat: true,
|
|
127
|
+
enforcePrettier: true,
|
|
128
|
+
enforceEslint: true,
|
|
129
|
+
enforceLineSeparation: true,
|
|
124
130
|
format: {
|
|
125
131
|
indentSize: 2,
|
|
126
132
|
convertTabsToSpaces: true,
|
|
127
133
|
semicolons: ts.SemicolonPreference.Remove
|
|
134
|
+
},
|
|
135
|
+
eslint: {
|
|
136
|
+
'@stylistic/quotes': ['error', 'single']
|
|
137
|
+
},
|
|
138
|
+
prettier: {
|
|
139
|
+
semi: false,
|
|
140
|
+
singleQuote: true
|
|
128
141
|
}
|
|
129
142
|
})
|
|
130
143
|
```
|
|
@@ -133,10 +146,12 @@ await transform(sourceFile, {
|
|
|
133
146
|
```tsx
|
|
134
147
|
import * as React from 'react';
|
|
135
148
|
|
|
136
|
-
import { Text } from '@/components/Text'
|
|
149
|
+
import { Text } from '@/components/Text';
|
|
137
150
|
|
|
138
|
-
export const Button: React.FunctionComponent<ButtonProps> = ({
|
|
139
|
-
|
|
151
|
+
export const Button: React.FunctionComponent<ButtonProps> = ({
|
|
152
|
+
label
|
|
153
|
+
}) => {
|
|
154
|
+
return <button><Text>{label}</Text></button>;
|
|
140
155
|
};
|
|
141
156
|
```
|
|
142
157
|
|
|
@@ -162,6 +177,9 @@ interface TransformerConfig {
|
|
|
162
177
|
enforceFunctionComponent: boolean
|
|
163
178
|
enforceNamedImports: boolean
|
|
164
179
|
enforceFormat: boolean
|
|
180
|
+
enforceLineSeparation: boolean
|
|
181
|
+
enforceEslint: boolean
|
|
182
|
+
enforcePrettier: boolean
|
|
165
183
|
format: {
|
|
166
184
|
baseIndentSize: number
|
|
167
185
|
convertTabsToSpaces: boolean
|
|
@@ -191,6 +209,19 @@ interface TransformerConfig {
|
|
|
191
209
|
semicolons: SemicolonPreference
|
|
192
210
|
tabSize: number
|
|
193
211
|
trimTrailingWhitespace: boolean
|
|
212
|
+
},
|
|
213
|
+
eslint: {
|
|
214
|
+
'@stylistic/*': ['error'],
|
|
215
|
+
'@typescript-eslint/*': ['error']
|
|
216
|
+
},
|
|
217
|
+
prettier: {
|
|
218
|
+
semi: false,
|
|
219
|
+
singleQuote: true,
|
|
220
|
+
jsxSingleQuote: true,
|
|
221
|
+
arrowParens: 'always',
|
|
222
|
+
bracketSameLine: true,
|
|
223
|
+
objectWrap: 'collapse',
|
|
224
|
+
printWidth: 120
|
|
194
225
|
}
|
|
195
226
|
}
|
|
196
227
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface TransformerConfig {
|
|
|
8
8
|
enforceFunctionComponent: boolean;
|
|
9
9
|
enforceNamedImports: boolean;
|
|
10
10
|
enforceFormat: boolean;
|
|
11
|
+
enforceLineSeparation: boolean;
|
|
11
12
|
enforceEslint: boolean;
|
|
12
13
|
enforcePrettier: boolean;
|
|
13
14
|
format: FormatCodeSettings;
|
|
@@ -35,6 +36,8 @@ declare const enforceFormat: Transformer;
|
|
|
35
36
|
|
|
36
37
|
declare const enforceFunctionComponent: Transformer;
|
|
37
38
|
|
|
39
|
+
declare const enforceLineSeparation: Transformer;
|
|
40
|
+
|
|
38
41
|
declare const enforceNamedImports: Transformer;
|
|
39
42
|
|
|
40
43
|
declare const enforcePrettier: Transformer;
|
|
@@ -60,4 +63,4 @@ interface SeparationEntry {
|
|
|
60
63
|
}
|
|
61
64
|
declare function enforeLineSeparation(sourceFile: SourceFile, predicate: (cur: Node<ts.Node>, prev: Node<ts.Node>, triviaWidth: number) => SeparationIntent): void;
|
|
62
65
|
|
|
63
|
-
export { type MatchFn, REACT_APIS, REACT_HOOKS, REACT_TYPES, type SeparationEntry, SeparationIntent, type TransformFn, type Transformer, type TransformerConfig, type TransformerParams, enforceDirectExports, enforceEslint, enforceFormat, enforceFunctionComponent, enforceNamedImports, enforcePrettier, enforeLineSeparation, isForwardRefComponent, isFunctionComponent, isReactComponent, mergeConfig, transform, transformers };
|
|
66
|
+
export { type MatchFn, REACT_APIS, REACT_HOOKS, REACT_TYPES, type SeparationEntry, SeparationIntent, type TransformFn, type Transformer, type TransformerConfig, type TransformerParams, enforceDirectExports, enforceEslint, enforceFormat, enforceFunctionComponent, enforceLineSeparation, enforceNamedImports, enforcePrettier, enforeLineSeparation, isForwardRefComponent, isFunctionComponent, isReactComponent, mergeConfig, transform, transformers };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {SyntaxKind,Node,
|
|
2
|
-
|
|
3
|
-
}`:c.startsWith("{")?l=x:l=`{
|
|
4
|
-
return ${x}
|
|
5
|
-
}`;let u=`${a?"export ":""}function ${o}(${p}) ${l}`;n.replaceWithText(u),s&&e.getExportDeclarations().forEach(f=>{let E=f.getNamedExports().filter(S=>S.getName()===o);E.length>0&&(E.forEach(S=>{S.remove();}),f.getNamedExports().length===0&&f.remove());});});}};var A={match:({config:e})=>e.enforceEslint,transform:async({sourceFile:e,config:t})=>{let r=e.getFilePath(),o=dirname(r),n=new ESLint({fix:true,cwd:o,overrideConfigFile:true,overrideConfig:[{basePath:".",languageOptions:{parser:J.parser,ecmaVersion:2020,sourceType:"module",parserOptions:{ecmaFeatures:{jsx:true}}},files:["**/*.{ts,tsx,js,jsx}"],plugins:{"@stylistic":j},rules:t.eslint}]}),[i]=await n.lintText(e.getFullText(),{filePath:r});i?.output&&e.replaceWithText(i.output);}};var O=(o=>(o[o.IGNORE=0]="IGNORE",o[o.COMBINE=1]="COMBINE",o[o.SEPARATE=2]="SEPARATE",o))(O||{});function w(e,t){let r=[],o=e.getChildSyntaxListOrThrow();for(let n=o.getChildCount()-1;n>0;n-=1){let i=o.getChildAtIndex(n-1),s=o.getChildAtIndex(n),a=t(s,i,s.getLeadingTriviaWidth());r.push({range:[i.getEnd(),s.getStart()],intent:a});}r.forEach(({range:n,intent:i})=>{i===1?e.replaceText(n,`
|
|
6
|
-
`):i===2&&e.replaceText(n,`
|
|
1
|
+
import {SyntaxKind,Node,StructureKind,VariableDeclarationKind,ImportDeclaration,ts}from'ts-morph';import k from'@stylistic/eslint-plugin';import {ESLint}from'eslint';import {dirname}from'path';import C from'typescript-eslint';import {format}from'prettier';var f=["ComponentProps","ComponentPropsWithRef","ComponentPropsWithoutRef","FC","FunctionComponent","ReactNode","ReactElement","JSX","RefObject","MutableRefObject","CSSProperties","HTMLAttributes","SVGAttributes","DOMAttributes","PropsWithChildren","PropsWithRef"],y=["useState","useEffect","useCallback","useMemo","useRef","useContext","useReducer","useImperativeHandle","useLayoutEffect","useDebugValue","useTransition","useDeferredValue","useId","useSyncExternalStore"],E=["forwardRef","memo","lazy","createContext","createElement","cloneElement","isValidElement","Children","Fragment","StrictMode","Suspense"];function G(e){try{let t=e.getInitializer?.();if(!t)return !1;let n=t.getDescendantsOfKind?.(SyntaxKind.JsxElement)||[],r=t.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement)||[];if(n.length>0||r.length>0)return !0;if(Node.isArrowFunction(t)){let o=t.getBody?.();if(o){let i=o.getDescendantsOfKind?.(SyntaxKind.JsxElement)||[],s=o.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement)||[];return i.length>0||s.length>0}}return !1}catch{return false}}function Y(e){try{let t=e.getInitializer?.();if(!t)return !1;let n=t.getText?.();return !!(n?.includes("forwardRef(")||n?.includes("React.forwardRef("))}catch{return false}}function l(e){try{let t=e.getDescendantsOfKind?.(SyntaxKind.JsxElement)||[],n=e.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement)||[];return t.length>0||n.length>0}catch{return false}}var S={match:({config:e})=>e.enforceDirectExports,transform:async({sourceFile:e})=>{e.getFunctions().forEach(t=>{if(!l(t)||t.isExported()&&t.hasExportKeyword())return;let n=t.getName(),r=false;e.getExportDeclarations().forEach(o=>{o.getNamedExports().some(s=>s.getName()===n)&&(r=true);}),r&&(t.setIsExported(true),e.getExportDeclarations().forEach(o=>{let s=o.getNamedExports().filter(a=>a.getName()===n);s.length>0&&(s.forEach(a=>{a.remove();}),o.getNamedExports().length===0&&o.remove());}));});}};var h={match:({config:e})=>e.enforceEslint,transform:async({sourceFile:e,config:t})=>{let n=e.getFilePath(),r=dirname(n),o=new ESLint({fix:true,cwd:r,overrideConfigFile:true,overrideConfig:[{basePath:".",languageOptions:{parser:C.parser,ecmaVersion:2020,sourceType:"module",parserOptions:{ecmaFeatures:{jsx:true}}},files:["**/*.{ts,tsx,js,jsx}"],plugins:{"@stylistic":k,"@typescript-eslint":C.plugin},rules:t.eslint}]}),[i]=await o.lintText(e.getFullText(),{filePath:n});i?.output&&e.replaceWithText(i.output);}};var b={match:({config:e})=>e.enforceFormat,transform:async({sourceFile:e,config:t})=>{e.formatText(t.format),e.organizeImports(t.format,{organizeImportsTypeOrder:"first"});}};var N={match:({config:e})=>e.enforceFunctionComponent,transform:async({sourceFile:e,config:{enforceDirectExports:t}})=>{e.getFunctions().some(r=>{if(!l(r))return false;let o=r.getName();if(!o)return false;let i=r.isExported(),s=false;e.getExportDeclarations().forEach(c=>{c.getNamedExports().some(x=>x.getName()===o)&&(s=true);});let a=t&&(i||s),u=r.getParameters()[0],T=(u.getTypeNode()??u.getType()).getText();u.removeType();let v=T==="any"?"React.FunctionComponent":`React.FunctionComponent<${T}>`,L=r.getChildIndex();return e.insertVariableStatement(L,{declarations:[{name:o,type:v,initializer:c=>{c.write("(").write(r.getParameters().map(K=>K.getText()).join(", ")).write(")");let g=r.getReturnTypeNode()?.getText();g&&c.write(`: ${g}`),c.write(" => ");let x=r.getBody()?.getText()??"{}";c.block(()=>{c.write(x.replace(/^{|}$/g,"").trim());});}}],declarationKind:VariableDeclarationKind.Const,kind:StructureKind.VariableStatement,isExported:a}),r.remove(),true})&&(e.getImportDeclarations().find(o=>o.getModuleSpecifier().getLiteralValue()==="react")||e.addImportDeclaration({moduleSpecifier:"react",namespaceImport:"React"}));}};var I=(r=>(r[r.IGNORE=0]="IGNORE",r[r.COMBINE=1]="COMBINE",r[r.SEPARATE=2]="SEPARATE",r))(I||{});function P(e,t){let n=[],r=e.getChildSyntaxListOrThrow();for(let o=r.getChildCount()-1;o>0;o-=1){let i=r.getChildAtIndex(o-1),s=r.getChildAtIndex(o),a=t(s,i,s.getLeadingTriviaWidth());n.push({range:[i.getEnd(),s.getStart()],intent:a});}n.forEach(({range:o,intent:i})=>{i===1?e.replaceText(o,`
|
|
2
|
+
`):i===2&&e.replaceText(o,`
|
|
7
3
|
|
|
8
|
-
`);});}var
|
|
4
|
+
`);});}var w={match:({config:e})=>e.enforceLineSeparation,transform:async({sourceFile:e})=>{P(e,(t,n)=>n instanceof ImportDeclaration&&t instanceof ImportDeclaration?1:2);}};var D={match:({config:e})=>e.enforceNamedImports,transform:async({sourceFile:e})=>{let t=e.getImportDeclarations().find(o=>o.getModuleSpecifier().getLiteralValue()==="react"),n=new Set,r=new Set;if(e.forEachDescendant(o=>{if(o.getKind()===SyntaxKind.TypeReference){let i=o.asKind(SyntaxKind.TypeReference);if(!i)return;let s=i.getTypeName();if(Node.isQualifiedName(s)){let a=s.getLeft().getText(),p=s.getRight().getText();a==="React"&&f.includes(p)&&(s.replaceWithText(p),n.add(p));}}if(o.getKind()===SyntaxKind.PropertyAccessExpression){let i=o.asKind(SyntaxKind.PropertyAccessExpression);if(!i)return;let s=i.getExpression(),a=i.getName();s.getText()==="React"&&(y.includes(a)||E.includes(a)||f.includes(a))&&(i.replaceWithText(a),f.includes(a)?n.add(a):(y.includes(a)||E.includes(a))&&r.add(a));}}),t&&(n.size>0||r.size>0)){t.removeNamespaceImport();let o=Array.from(n).sort();for(let s of o)t.addNamedImport({name:s,isTypeOnly:true});let i=Array.from(r).sort();for(let s of i)t.addNamedImport(s);}}};var A={match:({config:e})=>e.enforcePrettier,transform:async({sourceFile:e,config:t})=>{let n=await format(e.getText(),{parser:"babel-ts",...t.prettier,embeddedLanguageFormatting:"auto",quoteProps:"consistent",trailingComma:"none",singleQuote:true,jsxSingleQuote:true});e.replaceWithText(n);}};function F({eslint:e,format:t,prettier:n,...r}={}){return {enforceDirectExports:false,enforceFunctionComponent:false,enforceNamedImports:false,enforceFormat:false,enforceLineSeparation:false,enforceEslint:false,enforcePrettier:false,eslint:{"@stylistic/space-in-parens":["error"],"@stylistic/comma-spacing":["error"],"@stylistic/no-multi-spaces":["error"],"@stylistic/no-trailing-spaces":["error"],"@stylistic/no-whitespace-before-property":["error"],"@stylistic/array-bracket-newline":["error","consistent"],"@stylistic/array-bracket-spacing":["error"],"@stylistic/arrow-spacing":["error"],"@stylistic/arrow-parens":["error","always"],"@stylistic/block-spacing":["error","always"],"@stylistic/brace-style":["error","1tbs",{allowSingleLine:true}],"@stylistic/comma-dangle":["error","never"],"@stylistic/key-spacing":["error"],"@stylistic/keyword-spacing":["error"],"@stylistic/member-delimiter-style":["error",{multiline:{delimiter:"none"}}],"@stylistic/no-extra-semi":["error"],"@stylistic/indent":["error",2],"@stylistic/no-multiple-empty-lines":["error",{max:1,maxEOF:0,maxBOF:0}],"@stylistic/object-curly-spacing":["error","always"],"@stylistic/quotes":["error","single"],"@stylistic/semi":["error","never"],"@stylistic/space-before-blocks":["error","always"],"@stylistic/space-before-function-paren":["error",{anonymous:"always",named:"never",asyncArrow:"always"}],"@typescript-eslint/adjacent-overload-signatures":"error","@typescript-eslint/no-extra-non-null-assertion":"error","@typescript-eslint/no-misused-new":"error","@typescript-eslint/no-non-null-asserted-optional-chain":"error","@typescript-eslint/no-shadow":"error","@typescript-eslint/prefer-for-of":"error",...e},format:{indentSize:2,convertTabsToSpaces:true,ensureNewLineAtEndOfFile:true,indentStyle:ts.IndentStyle.Block,semicolons:ts.SemicolonPreference.Remove,trimTrailingWhitespace:true,...t},prettier:{semi:false,singleQuote:true,jsxSingleQuote:true,arrowParens:"always",bracketSameLine:true,objectWrap:"collapse",printWidth:120,...n},...r}}var _=[S,N,D,w,b,A,h];async function Ae(e,t={}){let n={config:F(t),sourceFile:e};for(let r of _)r.match(n)&&await r.transform(n);}export{E as REACT_APIS,y as REACT_HOOKS,f as REACT_TYPES,I as SeparationIntent,S as enforceDirectExports,h as enforceEslint,b as enforceFormat,N as enforceFunctionComponent,w as enforceLineSeparation,D as enforceNamedImports,A as enforcePrettier,P as enforeLineSeparation,Y as isForwardRefComponent,l as isFunctionComponent,G as isReactComponent,F as mergeConfig,Ae as transform,_ as transformers};//# sourceMappingURL=index.js.map
|
|
9
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/react.ts","../src/transformers/enforceDirectExports.ts","../src/transformers/enforceEslint.ts","../src/utils/trivia.ts","../src/transformers/enforceFormat.ts","../src/transformers/enforceFunctionComponent.ts","../src/transformers/enforceNamedImports.ts","../src/transformers/enforcePrettier.ts","../src/utils/config.ts","../src/utils/transform.ts"],"names":["REACT_TYPES","REACT_HOOKS","REACT_APIS","isReactComponent","varDecl","initializer","descendants","SyntaxKind","selfClosing","Node","body","bodyDescendants","bodySelfClosing","isForwardRefComponent","text","isFunctionComponent","func","enforceDirectExports","config","sourceFile","funcName","isExportedViaSeparateStatement","exportDecl","exp","matchingExports","namedExport","varName","varStatement","isExportedViaKeyword","isExported","paramsText","p","bodyText","functionBody","trimmedBody","funcText","enforceEslint","filePath","cwd","dirname","eslint","ESLint","tseslint","stylistic","result","SeparationIntent","enforeLineSeparation","predicate","instructions","syntaxList","index","prev","cur","intent","range","enforceFormat","ImportDeclaration","enforceFunctionComponent","param","typeText","typeAnnotation","writer","returnType","VariableDeclarationKind","StructureKind","enforceNamedImports","reactImport","importDeclaration","typeImportsNeeded","valueImportsNeeded","node","typeRef","typeName","left","right","propAccess","expr","name","typeImportsArray","valueImportsArray","valueName","enforcePrettier","formattedText","format","mergeConfig","prettier","ts","transformers","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7CO,IAAMqE,EAAe,CAC1BtE,CAAAA,CACAwC,EACAQ,CAAAA,CACAV,CAAAA,CACAnB,CAAAA,CACA6C,CACF,EAEA,eAAsBO,EAAAA,CACpBrE,EACAD,CAAAA,CAAyC,GAC1B,CACf,IAAMuE,CAAAA,CAA4B,CAAE,OAAQL,CAAAA,CAAYlE,CAAM,EAAG,UAAA,CAAAC,CAAW,EAC5E,IAAA,IAAWuE,CAAAA,IAAeH,CAAAA,CACpBG,CAAAA,CAAY,MAAMD,CAAM,CAAA,EAC1B,MAAMC,CAAAA,CAAY,SAAA,CAAUD,CAAM,EAGxC","file":"index.js","sourcesContent":["import { FunctionDeclaration, Node, SyntaxKind, VariableDeclaration } from 'ts-morph'\n\nexport const REACT_TYPES = [\n 'ComponentProps',\n 'ComponentPropsWithRef',\n 'ComponentPropsWithoutRef',\n 'FC',\n 'FunctionComponent',\n 'ReactNode',\n 'ReactElement',\n 'JSX',\n 'RefObject',\n 'MutableRefObject',\n 'CSSProperties',\n 'HTMLAttributes',\n 'SVGAttributes',\n 'DOMAttributes',\n 'PropsWithChildren',\n 'PropsWithRef'\n]\n\nexport const REACT_HOOKS = [\n 'useState',\n 'useEffect',\n 'useCallback',\n 'useMemo',\n 'useRef',\n 'useContext',\n 'useReducer',\n 'useImperativeHandle',\n 'useLayoutEffect',\n 'useDebugValue',\n 'useTransition',\n 'useDeferredValue',\n 'useId',\n 'useSyncExternalStore'\n]\n\nexport const REACT_APIS = [\n 'forwardRef',\n 'memo',\n 'lazy',\n 'createContext',\n 'createElement',\n 'cloneElement',\n 'isValidElement',\n 'Children',\n 'Fragment',\n 'StrictMode',\n 'Suspense'\n]\n\nexport function isReactComponent(varDecl: VariableDeclaration): boolean {\n try {\n const initializer = varDecl.getInitializer?.()\n if (!initializer) return false\n\n // Check if the initializer contains JSX\n const descendants = initializer.getDescendantsOfKind?.(SyntaxKind.JsxElement) || []\n const selfClosing = initializer.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement) || []\n\n if (descendants.length > 0 || selfClosing.length > 0) { return true }\n\n // Check if it's assigned to an arrow function that returns JSX\n if (Node.isArrowFunction(initializer)) {\n const body = initializer.getBody?.()\n if (body) {\n const bodyDescendants = body.getDescendantsOfKind?.(SyntaxKind.JsxElement) || []\n const bodySelfClosing = body.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement) || []\n return bodyDescendants.length > 0 || bodySelfClosing.length > 0\n }\n }\n\n return false\n } catch {\n return false\n }\n}\n\nexport function isForwardRefComponent(varDecl: VariableDeclaration): boolean {\n try {\n const initializer = varDecl.getInitializer?.()\n if (!initializer) return false\n\n const text = initializer.getText?.()\n return text?.includes('forwardRef(') || text?.includes('React.forwardRef(') ? true : false\n } catch {\n return false\n }\n}\n\nexport function isFunctionComponent(func: FunctionDeclaration): boolean {\n try {\n const descendants = func.getDescendantsOfKind?.(SyntaxKind.JsxElement) || []\n const selfClosing = func.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement) || []\n if (descendants.length > 0 || selfClosing.length > 0) { return true }\n return false\n } catch {\n return false\n }\n}\n","import { Node } from 'ts-morph'\nimport { isForwardRefComponent, isFunctionComponent, isReactComponent } from '../utils/react'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceDirectExports: Transformer = {\n match: ({ config }) => config.enforceDirectExports,\n transform: async ({ sourceFile }) => {\n // Transform function declarations: add direct export if it's a component\n sourceFile.getFunctions().forEach((func) => {\n // Skip if not a component\n if (!isFunctionComponent(func)) { return }\n\n // Skip if already exported directly\n if (func.isExported() && func.hasExportKeyword()) { return }\n\n const funcName = func.getName()\n\n // Check if it's exported via separate export statement\n let isExportedViaSeparateStatement = false\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n if (namedExports.some((exp) => exp.getName() === funcName)) {\n isExportedViaSeparateStatement = true\n }\n })\n\n // Only convert if it's a component that should be exported\n if (isExportedViaSeparateStatement) {\n // Add direct export modifier\n func.setIsExported(true)\n\n // Remove from separate export statements\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n const matchingExports = namedExports.filter((namedExport) => namedExport.getName() === funcName)\n if (matchingExports.length > 0) {\n matchingExports.forEach((namedExport) => { namedExport.remove() })\n if (exportDecl.getNamedExports().length === 0) { exportDecl.remove() }\n }\n })\n }\n })\n\n // Transform const arrow functions to function declarations (if they're components and not forwardRef)\n sourceFile.getVariableDeclarations().forEach((varDecl) => {\n // Skip if not a component\n if (!isReactComponent(varDecl)) return\n\n // Skip forwardRef and memo patterns\n if (isForwardRefComponent(varDecl)) return\n\n const initializer = varDecl.getInitializer()\n if (!initializer || !Node.isArrowFunction(initializer)) return\n\n const varName = varDecl.getName()\n const varStatement = varDecl.getVariableStatement()\n if (!varStatement) return\n\n const isExportedViaKeyword = varStatement.hasExportKeyword()\n\n // Check if it's exported via separate export statement\n let isExportedViaSeparateStatement = false\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n if (namedExports.some((exp) => exp.getName() === varName)) {\n isExportedViaSeparateStatement = true\n }\n })\n\n const isExported = isExportedViaKeyword || isExportedViaSeparateStatement\n\n // Get the parameters\n const params = initializer.getParameters()\n const paramsText = params.map((p) => p.getText()).join(', ')\n\n // Get the body\n const body = initializer.getBody()\n if (!body) return\n\n const bodyText = body.getText()\n\n // Build the function body\n let functionBody: string\n const trimmedBody = bodyText.trim()\n\n if (trimmedBody.startsWith('(') && trimmedBody.endsWith(')')) {\n // Parenthesized expression like: (\n // <button />\n // )\n const innerBody = trimmedBody.slice(1, -1).trim()\n functionBody = `{\\n return ${innerBody}\\n }`\n } else if (trimmedBody.startsWith('{')) {\n // Already a block statement\n functionBody = bodyText\n } else {\n // Simple JSX expression like: <button />\n functionBody = `{\\n return ${bodyText}\\n }`\n }\n\n const funcText = `${isExported ? 'export ' : ''}function ${varName}(${paramsText}) ${functionBody}`\n\n // Replace the variable statement with function declaration\n varStatement.replaceWithText(funcText)\n\n // Remove from separate export statements if it was exported that way\n if (isExportedViaSeparateStatement) {\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n const matchingExports = namedExports.filter((namedExport) => namedExport.getName() === varName)\n\n if (matchingExports.length > 0) {\n matchingExports.forEach((namedExport) => {\n namedExport.remove()\n })\n\n // Remove the entire export declaration if no exports remain\n if (exportDecl.getNamedExports().length === 0) {\n exportDecl.remove()\n }\n }\n })\n }\n })\n }\n}\n","import stylistic from '@stylistic/eslint-plugin'\nimport { ESLint } from 'eslint'\nimport { dirname } from 'path'\nimport tseslint from 'typescript-eslint'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceEslint: Transformer = {\n match: ({ config }) => config.enforceEslint,\n transform: async ({ sourceFile, config }) => {\n const filePath = sourceFile.getFilePath()\n const cwd = dirname(filePath)\n const eslint = new ESLint({\n fix: true,\n cwd,\n overrideConfigFile: true,\n overrideConfig: [{\n basePath: '.',\n languageOptions: {\n parser: tseslint.parser,\n ecmaVersion: 2020,\n sourceType: 'module',\n parserOptions: { ecmaFeatures: { jsx: true } }\n },\n files: ['**/*.{ts,tsx,js,jsx}'],\n plugins: { '@stylistic': stylistic },\n rules: config.eslint\n }]\n })\n\n const [result] = await eslint.lintText(sourceFile.getFullText(), { filePath })\n if (result?.output) { sourceFile.replaceWithText(result.output) }\n }\n}\n","import { Node, SourceFile, ts } from 'ts-morph'\n\nexport enum SeparationIntent { IGNORE, COMBINE, SEPARATE }\n\nexport interface SeparationEntry {\n range: [number, number]\n intent: SeparationIntent\n}\n\nexport function enforeLineSeparation(sourceFile: SourceFile, predicate: (cur: Node<ts.Node>, prev: Node<ts.Node>, triviaWidth: number) => SeparationIntent) {\n const instructions: SeparationEntry[] = []\n const syntaxList = sourceFile.getChildSyntaxListOrThrow()\n for (let index = syntaxList.getChildCount() - 1; index > 0; index -= 1) {\n const prev = syntaxList.getChildAtIndex(index - 1)\n const cur = syntaxList.getChildAtIndex(index)\n const intent = predicate(cur, prev, cur.getLeadingTriviaWidth())\n instructions.push({ range: [prev.getEnd(), cur.getStart()], intent })\n }\n instructions.forEach(({ range, intent }) => {\n if (intent === SeparationIntent.COMBINE) {\n sourceFile.replaceText(range, '\\n')\n } else if (intent === SeparationIntent.SEPARATE) {\n sourceFile.replaceText(range, '\\n\\n')\n }\n })\n}\n","import { ImportDeclaration } from 'ts-morph'\nimport { Transformer } from '../utils/transformer'\nimport { enforeLineSeparation, SeparationIntent } from '../utils/trivia'\n\nexport const enforceFormat: Transformer = {\n match: ({ config }) => config.enforceFormat,\n transform: async ({ sourceFile, config }) => {\n enforeLineSeparation(sourceFile, (cur, prev) => (prev instanceof ImportDeclaration && cur instanceof ImportDeclaration)\n ? SeparationIntent.COMBINE\n : SeparationIntent.SEPARATE\n )\n sourceFile.organizeImports()\n sourceFile.formatText(config.format)\n }\n}\n","import { StructureKind, VariableDeclarationKind } from 'ts-morph'\nimport { isFunctionComponent } from '../utils/react'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceFunctionComponent: Transformer = {\n match: ({ config }) => config.enforceFunctionComponent,\n transform: async ({ sourceFile, config: { enforceDirectExports } }) => {\n sourceFile.getFunctions().forEach((func) => {\n if (!isFunctionComponent(func)) { return }\n\n const funcName = func.getName()\n if (!funcName) { return }\n\n const isExportedViaKeyword = func.isExported()\n let isExportedViaSeparateStatement = false\n\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n if (namedExports.some((exp) => exp.getName() === funcName)) {\n isExportedViaSeparateStatement = true\n }\n })\n\n const isExported = enforceDirectExports && (isExportedViaKeyword || isExportedViaSeparateStatement)\n\n // Get the parameters with their type annotations\n const params = func.getParameters()\n const param = params[0]\n const type = param.getTypeNode() ?? param.getType()\n const typeText = type.getText()\n param.removeType()\n const typeAnnotation = typeText === 'any' ? 'React.FunctionComponent' : `React.FunctionComponent<${typeText}>`\n\n const index = func.getChildIndex()\n sourceFile.insertVariableStatement(index, {\n declarations: [{\n name: funcName,\n type: typeAnnotation,\n initializer: (writer) => {\n writer.write('(').write(func.getParameters().map((p) => p.getText()).join(', ')).write(')')\n const returnType = func.getReturnTypeNode()?.getText()\n if (returnType) { writer.write(`: ${returnType}`) }\n writer.write(' => ')\n const bodyText = func.getBody()?.getText() ?? '{}'\n writer.block(() => { writer.write(bodyText.replace(/^{|}$/g, '').trim()) })\n }\n }],\n declarationKind: VariableDeclarationKind.Const,\n kind: StructureKind.VariableStatement,\n isExported\n })\n func.remove()\n })\n }\n}\n","import { Node, SyntaxKind } from 'ts-morph'\nimport { REACT_APIS, REACT_HOOKS, REACT_TYPES } from '../utils/react'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceNamedImports: Transformer = {\n match: ({ config }) => config.enforceNamedImports,\n transform: async ({ sourceFile }) => {\n // Find React import declaration\n const reactImport = sourceFile.getImportDeclarations().find((importDeclaration) => {\n return importDeclaration.getModuleSpecifier().getLiteralValue() === 'react'\n })\n\n // If no React import exists, no transformation needed\n if (!reactImport) { return }\n\n // Check if it's already using named imports only (early exit if enforceNamedImports is disabled)\n const namespaceImport = reactImport.getNamespaceImport()\n if (!namespaceImport) { return }\n\n // Initialize tracking sets\n const typeImportsNeeded = new Set<string>()\n const valueImportsNeeded = new Set<string>()\n\n // ============================================================\n // Phase 2 & 3: Transform Type References and Hook Calls\n // (Single-pass traversal for efficiency)\n // ============================================================\n\n sourceFile.forEachDescendant((node) => {\n // Handle TypeReference nodes (Phase 2)\n if (node.getKind() === SyntaxKind.TypeReference) {\n const typeRef = node.asKind(SyntaxKind.TypeReference)\n if (!typeRef) return\n\n const typeName = typeRef.getTypeName()\n\n // Check if it's a qualified name like React.ComponentProps or React.HTMLAttributes\n if (Node.isQualifiedName(typeName)) {\n const left = typeName.getLeft().getText()\n const right = typeName.getRight().getText()\n\n if (left === 'React') {\n // Check if it's a known React type\n if (REACT_TYPES.includes(right)) {\n typeName.replaceWithText(right)\n typeImportsNeeded.add(right)\n }\n }\n }\n }\n\n // Handle PropertyAccessExpression nodes (Phase 3)\n // This handles both React.Component and React.SomethingRef patterns\n if (node.getKind() === SyntaxKind.PropertyAccessExpression) {\n const propAccess = node.asKind(SyntaxKind.PropertyAccessExpression)\n if (!propAccess) return\n\n const expr = propAccess.getExpression()\n const name = propAccess.getName()\n\n if (expr.getText() === 'React') {\n // Check if it's a known hook or API\n if (REACT_HOOKS.includes(name) || REACT_APIS.includes(name) || REACT_TYPES.includes(name)) {\n propAccess.replaceWithText(name)\n\n // Determine if it's a type or value import\n if (REACT_TYPES.includes(name)) {\n typeImportsNeeded.add(name)\n } else if (REACT_HOOKS.includes(name) || REACT_APIS.includes(name)) {\n valueImportsNeeded.add(name)\n }\n }\n }\n }\n })\n\n // ============================================================\n // Phase 4: Import Management\n // ============================================================\n\n // Only add named imports and remove namespace if we have imports to add\n if (typeImportsNeeded.size > 0 || valueImportsNeeded.size > 0) {\n // Remove namespace import FIRST (before adding named imports)\n reactImport.removeNamespaceImport()\n\n // Add type imports (with 'type' keyword for type-only imports)\n const typeImportsArray = Array.from(typeImportsNeeded).sort()\n for (const typeName of typeImportsArray) {\n reactImport.addNamedImport({\n name: typeName,\n isTypeOnly: true\n })\n }\n\n // Add value imports\n const valueImportsArray = Array.from(valueImportsNeeded).sort()\n for (const valueName of valueImportsArray) {\n reactImport.addNamedImport(valueName)\n }\n }\n }\n}\n","import { format } from 'prettier'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforcePrettier: Transformer = {\n match: ({ config }) => config.enforcePrettier,\n transform: async ({ sourceFile, config }) => {\n const formattedText = await format(sourceFile.getText(), { parser: 'typescript', ...config.prettier })\n sourceFile.replaceWithText(formattedText)\n\n }\n}\n","import { RulesConfig } from '@eslint/core'\nimport { Options as PrettierOptions } from 'prettier'\nimport { FormatCodeSettings, ts } from 'ts-morph'\nimport { PartialDeep } from 'type-fest'\n\nexport interface TransformerConfig {\n enforceDirectExports: boolean\n enforceFunctionComponent: boolean\n enforceNamedImports: boolean\n enforceFormat: boolean\n enforceEslint: boolean\n enforcePrettier: boolean\n format: FormatCodeSettings\n prettier: PrettierOptions\n eslint: Partial<RulesConfig>\n}\n\nexport function mergeConfig({ eslint, format, prettier, ...config }: PartialDeep<TransformerConfig> = {}): TransformerConfig {\n return {\n enforceDirectExports: false,\n enforceFunctionComponent: false,\n enforceNamedImports: false,\n enforceFormat: false,\n enforceEslint: false,\n enforcePrettier: false,\n eslint: {\n '@stylistic/indent': ['error', 2],\n '@stylistic/quotes': ['error', 'single'],\n '@stylistic/semi': ['error', 'never'],\n '@stylistic/no-trailing-spaces': 'error',\n '@stylistic/no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0, 'maxBOF': 0 }],\n '@stylistic/function-paren-newline': ['error', 'never'],\n '@stylistic/object-curly-newline': ['error', 'never'],\n ...eslint\n },\n format: {\n indentSize: 2,\n convertTabsToSpaces: true,\n ensureNewLineAtEndOfFile: true,\n indentStyle: ts.IndentStyle.Block,\n semicolons: ts.SemicolonPreference.Remove,\n trimTrailingWhitespace: true,\n ...format\n },\n prettier: {\n semi: false,\n singleQuote: true,\n jsxSingleQuote: true,\n arrowParens: 'always',\n bracketSameLine: true,\n objectWrap: 'collapse',\n printWidth: 120,\n ...prettier\n },\n ...config\n }\n}\n","import { SourceFile } from 'ts-morph'\nimport { PartialDeep } from 'type-fest'\nimport { enforceDirectExports } from '../transformers/enforceDirectExports'\nimport { enforceEslint } from '../transformers/enforceEslint'\nimport { enforceFormat } from '../transformers/enforceFormat'\nimport { enforceFunctionComponent } from '../transformers/enforceFunctionComponent'\nimport { enforceNamedImports } from '../transformers/enforceNamedImports'\nimport { enforcePrettier } from '../transformers/enforcePrettier'\nimport { mergeConfig, TransformerConfig } from './config'\nimport { TransformerParams } from './transformer'\n\nexport const transformers = [\n enforceDirectExports,\n enforceFunctionComponent,\n enforceNamedImports,\n enforceFormat,\n enforceEslint,\n enforcePrettier\n]\n\nexport async function transform(\n sourceFile: SourceFile,\n config: PartialDeep<TransformerConfig> = {}\n): Promise<void> {\n const params: TransformerParams = { config: mergeConfig(config), sourceFile }\n for (const transformer of transformers) {\n if (transformer.match(params)) {\n await transformer.transform(params)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/react.ts","../src/transformers/enforceDirectExports.ts","../src/transformers/enforceEslint.ts","../src/transformers/enforceFormat.ts","../src/transformers/enforceFunctionComponent.ts","../src/utils/trivia.ts","../src/transformers/enforceLineSeparation.ts","../src/transformers/enforceNamedImports.ts","../src/transformers/enforcePrettier.ts","../src/utils/config.ts","../src/utils/transform.ts"],"names":["REACT_TYPES","REACT_HOOKS","REACT_APIS","isReactComponent","varDecl","initializer","descendants","SyntaxKind","selfClosing","Node","body","bodyDescendants","bodySelfClosing","isForwardRefComponent","text","isFunctionComponent","func","enforceDirectExports","config","sourceFile","funcName","isExportedViaSeparateStatement","exportDecl","exp","matchingExports","namedExport","enforceEslint","filePath","cwd","dirname","eslint","ESLint","tseslint","stylistic","result","enforceFormat","enforceFunctionComponent","isExportedViaKeyword","isExported","param","typeText","typeAnnotation","index","writer","p","returnType","bodyText","VariableDeclarationKind","StructureKind","importDeclaration","SeparationIntent","enforeLineSeparation","predicate","instructions","syntaxList","prev","cur","intent","range","enforceLineSeparation","ImportDeclaration","enforceNamedImports","reactImport","typeImportsNeeded","valueImportsNeeded","node","typeRef","typeName","left","right","propAccess","expr","name","typeImportsArray","valueImportsArray","valueName","enforcePrettier","formattedText","format","mergeConfig","prettier","ts","transformers","transform","params","transformer"],"mappings":"gQAEO,IAAMA,CAAAA,CAAc,CACzB,gBAAA,CACA,uBAAA,CACA,2BACA,IAAA,CACA,mBAAA,CACA,YACA,cAAA,CACA,KAAA,CACA,YACA,kBAAA,CACA,eAAA,CACA,gBAAA,CACA,eAAA,CACA,eAAA,CACA,mBAAA,CACA,cACF,CAAA,CAEaC,CAAAA,CAAc,CACzB,UAAA,CACA,WAAA,CACA,cACA,SAAA,CACA,QAAA,CACA,aACA,YAAA,CACA,qB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,CAAA,CACZ,oBAAqB,IAAA,CACrB,wBAAA,CAA0B,IAAA,CAC1B,WAAA,CAAamD,GAAG,WAAA,CAAY,KAAA,CAC5B,UAAA,CAAYA,EAAAA,CAAG,mBAAA,CAAoB,MAAA,CACnC,sBAAA,CAAwB,IAAA,CACxB,GAAGH,CACL,CAAA,CACA,QAAA,CAAU,CACR,IAAA,CAAM,KAAA,CACN,WAAA,CAAa,IAAA,CACb,eAAgB,IAAA,CAChB,WAAA,CAAa,QAAA,CACb,eAAA,CAAiB,IAAA,CACjB,UAAA,CAAY,UAAA,CACZ,UAAA,CAAY,IACZ,GAAGE,CACL,CAAA,CACA,GAAG9D,CACL,CACF,CCpEO,IAAMgE,EAAe,CAC1BjE,CAAAA,CACAmB,CAAAA,CACAyB,CAAAA,CACAF,CAAAA,CACAxB,CAAAA,CACAyC,CAAAA,CACAlD,CACF,EAEA,eAAsByD,EAAAA,CACpBhE,CAAAA,CACAD,CAAAA,CAAyC,EAAC,CAC3B,CACf,IAAMkE,EAA4B,CAAE,MAAA,CAAQL,CAAAA,CAAY7D,CAAM,CAAA,CAAG,UAAA,CAAAC,CAAW,CAAA,CAC5E,QAAWkE,CAAAA,IAAeH,CAAAA,CACpBG,CAAAA,CAAY,KAAA,CAAMD,CAAM,CAAA,EAC1B,MAAMC,CAAAA,CAAY,SAAA,CAAUD,CAAM,EAGxC","file":"index.js","sourcesContent":["import { FunctionDeclaration, Node, SyntaxKind, VariableDeclaration } from 'ts-morph'\n\nexport const REACT_TYPES = [\n 'ComponentProps',\n 'ComponentPropsWithRef',\n 'ComponentPropsWithoutRef',\n 'FC',\n 'FunctionComponent',\n 'ReactNode',\n 'ReactElement',\n 'JSX',\n 'RefObject',\n 'MutableRefObject',\n 'CSSProperties',\n 'HTMLAttributes',\n 'SVGAttributes',\n 'DOMAttributes',\n 'PropsWithChildren',\n 'PropsWithRef'\n]\n\nexport const REACT_HOOKS = [\n 'useState',\n 'useEffect',\n 'useCallback',\n 'useMemo',\n 'useRef',\n 'useContext',\n 'useReducer',\n 'useImperativeHandle',\n 'useLayoutEffect',\n 'useDebugValue',\n 'useTransition',\n 'useDeferredValue',\n 'useId',\n 'useSyncExternalStore'\n]\n\nexport const REACT_APIS = [\n 'forwardRef',\n 'memo',\n 'lazy',\n 'createContext',\n 'createElement',\n 'cloneElement',\n 'isValidElement',\n 'Children',\n 'Fragment',\n 'StrictMode',\n 'Suspense'\n]\n\nexport function isReactComponent(varDecl: VariableDeclaration): boolean {\n try {\n const initializer = varDecl.getInitializer?.()\n if (!initializer) return false\n\n // Check if the initializer contains JSX\n const descendants = initializer.getDescendantsOfKind?.(SyntaxKind.JsxElement) || []\n const selfClosing = initializer.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement) || []\n\n if (descendants.length > 0 || selfClosing.length > 0) { return true }\n\n // Check if it's assigned to an arrow function that returns JSX\n if (Node.isArrowFunction(initializer)) {\n const body = initializer.getBody?.()\n if (body) {\n const bodyDescendants = body.getDescendantsOfKind?.(SyntaxKind.JsxElement) || []\n const bodySelfClosing = body.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement) || []\n return bodyDescendants.length > 0 || bodySelfClosing.length > 0\n }\n }\n\n return false\n } catch {\n return false\n }\n}\n\nexport function isForwardRefComponent(varDecl: VariableDeclaration): boolean {\n try {\n const initializer = varDecl.getInitializer?.()\n if (!initializer) return false\n\n const text = initializer.getText?.()\n return text?.includes('forwardRef(') || text?.includes('React.forwardRef(') ? true : false\n } catch {\n return false\n }\n}\n\nexport function isFunctionComponent(func: FunctionDeclaration): boolean {\n try {\n const descendants = func.getDescendantsOfKind?.(SyntaxKind.JsxElement) || []\n const selfClosing = func.getDescendantsOfKind?.(SyntaxKind.JsxSelfClosingElement) || []\n if (descendants.length > 0 || selfClosing.length > 0) { return true }\n return false\n } catch {\n return false\n }\n}\n","import { isFunctionComponent } from '../utils/react'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceDirectExports: Transformer = {\n match: ({ config }) => config.enforceDirectExports,\n transform: async ({ sourceFile }) => {\n // Transform function declarations: add direct export if it's a component\n sourceFile.getFunctions().forEach((func) => {\n // Skip if not a component\n if (!isFunctionComponent(func)) { return }\n\n // Skip if already exported directly\n if (func.isExported() && func.hasExportKeyword()) { return }\n\n const funcName = func.getName()\n\n // Check if it's exported via separate export statement\n let isExportedViaSeparateStatement = false\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n if (namedExports.some((exp) => exp.getName() === funcName)) {\n isExportedViaSeparateStatement = true\n }\n })\n\n // Only convert if it's a component that should be exported\n if (isExportedViaSeparateStatement) {\n // Add direct export modifier\n func.setIsExported(true)\n\n // Remove from separate export statements\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n const matchingExports = namedExports.filter((namedExport) => namedExport.getName() === funcName)\n if (matchingExports.length > 0) {\n matchingExports.forEach((namedExport) => { namedExport.remove() })\n if (exportDecl.getNamedExports().length === 0) { exportDecl.remove() }\n }\n })\n }\n })\n }\n}\n","import stylistic from '@stylistic/eslint-plugin'\nimport { ESLint } from 'eslint'\nimport { dirname } from 'path'\nimport tseslint from 'typescript-eslint'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceEslint: Transformer = {\n match: ({ config }) => config.enforceEslint,\n transform: async ({ sourceFile, config }) => {\n const filePath = sourceFile.getFilePath()\n const cwd = dirname(filePath)\n const eslint = new ESLint({\n fix: true,\n cwd,\n overrideConfigFile: true,\n overrideConfig: [{\n basePath: '.',\n languageOptions: {\n parser: tseslint.parser,\n ecmaVersion: 2020,\n sourceType: 'module',\n parserOptions: { ecmaFeatures: { jsx: true } }\n },\n files: ['**/*.{ts,tsx,js,jsx}'],\n plugins: {\n '@stylistic': stylistic,\n '@typescript-eslint': tseslint.plugin\n },\n rules: config.eslint\n }]\n })\n\n const [result] = await eslint.lintText(sourceFile.getFullText(), { filePath })\n if (result?.output) { sourceFile.replaceWithText(result.output) }\n }\n}\n","import { Transformer } from '../utils/transformer'\n\nexport const enforceFormat: Transformer = {\n match: ({ config }) => config.enforceFormat,\n transform: async ({ sourceFile, config }) => {\n sourceFile.formatText(config.format)\n sourceFile.organizeImports(config.format, { organizeImportsTypeOrder: 'first' })\n }\n}\n","import { StructureKind, VariableDeclarationKind } from 'ts-morph'\nimport { isFunctionComponent } from '../utils/react'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceFunctionComponent: Transformer = {\n match: ({ config }) => config.enforceFunctionComponent,\n transform: async ({ sourceFile, config: { enforceDirectExports } }) => {\n const requireImportCheck = sourceFile.getFunctions().some((func) => {\n if (!isFunctionComponent(func)) { return false }\n\n const funcName = func.getName()\n if (!funcName) { return false }\n\n const isExportedViaKeyword = func.isExported()\n let isExportedViaSeparateStatement = false\n\n sourceFile.getExportDeclarations().forEach((exportDecl) => {\n const namedExports = exportDecl.getNamedExports()\n if (namedExports.some((exp) => exp.getName() === funcName)) {\n isExportedViaSeparateStatement = true\n }\n })\n\n const isExported = enforceDirectExports && (isExportedViaKeyword || isExportedViaSeparateStatement)\n\n // Get the parameters with their type annotations\n const params = func.getParameters()\n const param = params[0]\n const type = param.getTypeNode() ?? param.getType()\n const typeText = type.getText()\n param.removeType()\n const typeAnnotation = typeText === 'any' ? 'React.FunctionComponent' : `React.FunctionComponent<${typeText}>`\n\n const index = func.getChildIndex()\n sourceFile.insertVariableStatement(index, {\n declarations: [{\n name: funcName,\n type: typeAnnotation,\n initializer: (writer) => {\n writer.write('(').write(func.getParameters().map((p) => p.getText()).join(', ')).write(')')\n const returnType = func.getReturnTypeNode()?.getText()\n if (returnType) { writer.write(`: ${returnType}`) }\n writer.write(' => ')\n const bodyText = func.getBody()?.getText() ?? '{}'\n writer.block(() => { writer.write(bodyText.replace(/^{|}$/g, '').trim()) })\n }\n }],\n declarationKind: VariableDeclarationKind.Const,\n kind: StructureKind.VariableStatement,\n isExported\n })\n func.remove()\n return true\n })\n\n if (requireImportCheck) {\n const reactImport = sourceFile.getImportDeclarations().find((importDeclaration) => {\n return importDeclaration.getModuleSpecifier().getLiteralValue() === 'react'\n })\n if (!reactImport) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'react',\n namespaceImport: 'React'\n })\n }\n }\n }\n}\n","import { Node, SourceFile, ts } from 'ts-morph'\n\nexport enum SeparationIntent { IGNORE, COMBINE, SEPARATE }\n\nexport interface SeparationEntry {\n range: [number, number]\n intent: SeparationIntent\n}\n\nexport function enforeLineSeparation(sourceFile: SourceFile, predicate: (cur: Node<ts.Node>, prev: Node<ts.Node>, triviaWidth: number) => SeparationIntent) {\n const instructions: SeparationEntry[] = []\n const syntaxList = sourceFile.getChildSyntaxListOrThrow()\n for (let index = syntaxList.getChildCount() - 1; index > 0; index -= 1) {\n const prev = syntaxList.getChildAtIndex(index - 1)\n const cur = syntaxList.getChildAtIndex(index)\n const intent = predicate(cur, prev, cur.getLeadingTriviaWidth())\n instructions.push({ range: [prev.getEnd(), cur.getStart()], intent })\n }\n instructions.forEach(({ range, intent }) => {\n if (intent === SeparationIntent.COMBINE) {\n sourceFile.replaceText(range, '\\n')\n } else if (intent === SeparationIntent.SEPARATE) {\n sourceFile.replaceText(range, '\\n\\n')\n }\n })\n}\n","import { ImportDeclaration } from 'ts-morph'\nimport { Transformer } from '../utils/transformer'\nimport { enforeLineSeparation, SeparationIntent } from '../utils/trivia'\n\nexport const enforceLineSeparation: Transformer = {\n match: ({ config }) => config.enforceLineSeparation,\n transform: async ({ sourceFile }) => {\n enforeLineSeparation(sourceFile, (cur, prev) => (prev instanceof ImportDeclaration && cur instanceof ImportDeclaration)\n ? SeparationIntent.COMBINE\n : SeparationIntent.SEPARATE\n )\n }\n}\n","import { Node, SyntaxKind } from 'ts-morph'\nimport { REACT_APIS, REACT_HOOKS, REACT_TYPES } from '../utils/react'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforceNamedImports: Transformer = {\n match: ({ config }) => config.enforceNamedImports,\n transform: async ({ sourceFile }) => {\n // Find React import declaration\n const reactImport = sourceFile.getImportDeclarations().find((importDeclaration) => {\n return importDeclaration.getModuleSpecifier().getLiteralValue() === 'react'\n })\n\n // Initialize tracking sets\n const typeImportsNeeded = new Set<string>()\n const valueImportsNeeded = new Set<string>()\n\n // ============================================================\n // Phase 2 & 3: Transform Type References and Hook Calls\n // (Single-pass traversal for efficiency)\n // ============================================================\n\n sourceFile.forEachDescendant((node) => {\n // Handle TypeReference nodes (Phase 2)\n if (node.getKind() === SyntaxKind.TypeReference) {\n const typeRef = node.asKind(SyntaxKind.TypeReference)\n if (!typeRef) return\n\n const typeName = typeRef.getTypeName()\n\n // Check if it's a qualified name like React.ComponentProps or React.HTMLAttributes\n if (Node.isQualifiedName(typeName)) {\n const left = typeName.getLeft().getText()\n const right = typeName.getRight().getText()\n\n if (left === 'React') {\n // Check if it's a known React type\n if (REACT_TYPES.includes(right)) {\n typeName.replaceWithText(right)\n typeImportsNeeded.add(right)\n }\n }\n }\n }\n\n // Handle PropertyAccessExpression nodes (Phase 3)\n // This handles both React.Component and React.SomethingRef patterns\n if (node.getKind() === SyntaxKind.PropertyAccessExpression) {\n const propAccess = node.asKind(SyntaxKind.PropertyAccessExpression)\n if (!propAccess) return\n\n const expr = propAccess.getExpression()\n const name = propAccess.getName()\n\n if (expr.getText() === 'React') {\n // Check if it's a known hook or API\n if (REACT_HOOKS.includes(name) || REACT_APIS.includes(name) || REACT_TYPES.includes(name)) {\n propAccess.replaceWithText(name)\n\n // Determine if it's a type or value import\n if (REACT_TYPES.includes(name)) {\n typeImportsNeeded.add(name)\n } else if (REACT_HOOKS.includes(name) || REACT_APIS.includes(name)) {\n valueImportsNeeded.add(name)\n }\n }\n }\n }\n })\n\n // ============================================================\n // Phase 4: Import Management\n // ============================================================\n\n // Only add named imports and remove namespace if we have imports to add\n if (reactImport && (typeImportsNeeded.size > 0 || valueImportsNeeded.size > 0)) {\n // Remove namespace import FIRST (before adding named imports)\n reactImport.removeNamespaceImport()\n\n // Add type imports (with 'type' keyword for type-only imports)\n const typeImportsArray = Array.from(typeImportsNeeded).sort()\n for (const typeName of typeImportsArray) {\n reactImport.addNamedImport({ name: typeName, isTypeOnly: true })\n }\n\n // Add value imports\n const valueImportsArray = Array.from(valueImportsNeeded).sort()\n for (const valueName of valueImportsArray) {\n reactImport.addNamedImport(valueName)\n }\n }\n }\n}\n","import { format } from 'prettier'\nimport { Transformer } from '../utils/transformer'\n\nexport const enforcePrettier: Transformer = {\n match: ({ config }) => config.enforcePrettier,\n transform: async ({ sourceFile, config }) => {\n const formattedText = await format(sourceFile.getText(), {\n parser: 'babel-ts',\n ...config.prettier,\n embeddedLanguageFormatting: 'auto',\n quoteProps: 'consistent',\n trailingComma: 'none',\n singleQuote: true,\n jsxSingleQuote: true\n })\n sourceFile.replaceWithText(formattedText)\n }\n}\n","import { RulesConfig } from '@eslint/core'\nimport { Options as PrettierOptions } from 'prettier'\nimport { FormatCodeSettings, ts } from 'ts-morph'\nimport { PartialDeep } from 'type-fest'\n\nexport interface TransformerConfig {\n enforceDirectExports: boolean\n enforceFunctionComponent: boolean\n enforceNamedImports: boolean\n enforceFormat: boolean\n enforceLineSeparation: boolean\n enforceEslint: boolean\n enforcePrettier: boolean\n format: FormatCodeSettings\n prettier: PrettierOptions\n eslint: Partial<RulesConfig>\n}\n\nexport function mergeConfig({ eslint, format, prettier, ...config }: PartialDeep<TransformerConfig> = {}): TransformerConfig {\n return {\n enforceDirectExports: false,\n enforceFunctionComponent: false,\n enforceNamedImports: false,\n enforceFormat: false,\n enforceLineSeparation: false,\n enforceEslint: false,\n enforcePrettier: false,\n eslint: {\n '@stylistic/space-in-parens': ['error'],\n '@stylistic/comma-spacing': ['error'],\n '@stylistic/no-multi-spaces': ['error'],\n '@stylistic/no-trailing-spaces': ['error'],\n '@stylistic/no-whitespace-before-property': ['error'],\n '@stylistic/array-bracket-newline': ['error', 'consistent'],\n '@stylistic/array-bracket-spacing': ['error'],\n '@stylistic/arrow-spacing': ['error'],\n '@stylistic/arrow-parens': ['error', 'always'],\n '@stylistic/block-spacing': ['error', 'always'],\n '@stylistic/brace-style': ['error', '1tbs', { 'allowSingleLine': true }],\n '@stylistic/comma-dangle': ['error', 'never'],\n '@stylistic/key-spacing': ['error'],\n '@stylistic/keyword-spacing': ['error'],\n '@stylistic/member-delimiter-style': ['error', { 'multiline': { 'delimiter': 'none' } }],\n '@stylistic/no-extra-semi': ['error'],\n '@stylistic/indent': ['error', 2],\n '@stylistic/no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0, 'maxBOF': 0 }],\n '@stylistic/object-curly-spacing': ['error', 'always'],\n '@stylistic/quotes': ['error', 'single'],\n '@stylistic/semi': ['error', 'never'],\n '@stylistic/space-before-blocks': ['error', 'always'],\n '@stylistic/space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never', 'asyncArrow': 'always' }],\n '@typescript-eslint/adjacent-overload-signatures': 'error',\n '@typescript-eslint/no-extra-non-null-assertion': 'error',\n '@typescript-eslint/no-misused-new': 'error',\n '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/prefer-for-of': 'error',\n ...eslint\n },\n format: {\n indentSize: 2,\n convertTabsToSpaces: true,\n ensureNewLineAtEndOfFile: true,\n indentStyle: ts.IndentStyle.Block,\n semicolons: ts.SemicolonPreference.Remove,\n trimTrailingWhitespace: true,\n ...format\n },\n prettier: {\n semi: false,\n singleQuote: true,\n jsxSingleQuote: true,\n arrowParens: 'always',\n bracketSameLine: true,\n objectWrap: 'collapse',\n printWidth: 120,\n ...prettier\n },\n ...config\n }\n}\n","import { SourceFile } from 'ts-morph'\nimport { PartialDeep } from 'type-fest'\nimport { enforceDirectExports } from '../transformers/enforceDirectExports'\nimport { enforceEslint } from '../transformers/enforceEslint'\nimport { enforceFormat } from '../transformers/enforceFormat'\nimport { enforceFunctionComponent } from '../transformers/enforceFunctionComponent'\nimport { enforceLineSeparation } from '../transformers/enforceLineSeparation'\nimport { enforceNamedImports } from '../transformers/enforceNamedImports'\nimport { enforcePrettier } from '../transformers/enforcePrettier'\nimport { mergeConfig, TransformerConfig } from './config'\nimport { TransformerParams } from './transformer'\n\nexport const transformers = [\n enforceDirectExports,\n enforceFunctionComponent,\n enforceNamedImports,\n enforceLineSeparation,\n enforceFormat,\n enforcePrettier,\n enforceEslint\n]\n\nexport async function transform(\n sourceFile: SourceFile,\n config: PartialDeep<TransformerConfig> = {}\n): Promise<void> {\n const params: TransformerParams = { config: mergeConfig(config), sourceFile }\n for (const transformer of transformers) {\n if (transformer.match(params)) {\n await transformer.transform(params)\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-morph-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A collection of transformers for ts-morph to refactor react code",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@base-ui/react": "^1.0.0",
|
|
43
43
|
"@types/node": "^25.0.3",
|
|
44
|
+
"class-variance-authority": "^0.7.1",
|
|
44
45
|
"cli-highlight": "^2.1.11",
|
|
45
46
|
"react": "^19.2.3",
|
|
46
47
|
"rimraf": "^6.0.1",
|