-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move react parser in dedicated folder (#89)
- Loading branch information
Showing
42 changed files
with
841 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"name": "functions", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/packages/node-react-parser/node_modules/jest/bin/jest", | ||
"args": [ | ||
"--runInBand" | ||
], | ||
"cwd": "${workspaceFolder}/packages/node-react-parser", | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen" | ||
|
||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"eslint.workingDirectories": [ | ||
"./apps/node-cli", | ||
"./apps/node-cli", | ||
"./packages/node-react-parser" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
yarn.lock* | ||
package-lock.json | ||
Cargo.lock | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# Parcel related files | ||
dist/ | ||
.cache/ | ||
.parcel-cache/ | ||
|
||
.DS_Store | ||
|
||
playwright-report/ | ||
**/dist/ | ||
*.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
build | ||
old | ||
CHANGELOG.md | ||
public/icons/*.json | ||
.cache | ||
coverage | ||
playwright-report | ||
pnpm-lock.yaml | ||
dist | ||
templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import typescriptParser from '@typescript-eslint/parser' | ||
import js from '@eslint/js' | ||
import jest from 'eslint-plugin-jest' | ||
import tseslint from 'typescript-eslint' | ||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' | ||
|
||
// Following this article: https://www.raulmelo.me/en/blog/migration-eslint-to-flat-config | ||
|
||
export default tseslint.config( | ||
{ | ||
ignores: ['dist/**', 'node_modules/**'], | ||
}, | ||
js.configs.recommended, | ||
{ | ||
files: ['**/*.js', '**/*.ts', '**/*.tsx'], | ||
languageOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
parser: typescriptParser, | ||
globals: { | ||
document: 'readonly', | ||
}, | ||
}, | ||
rules: { | ||
'no-console': ['error', { allow: ['warn', 'error'] }], | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.{test,spec}.tsx?'], | ||
...jest.configs['flat/recommended'], | ||
}, | ||
...tseslint.configs.recommended, | ||
eslintPluginPrettierRecommended, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Config } from 'jest' | ||
|
||
const config: Config = { | ||
testMatch: ['<rootDir>/src/**/*.test.{tsx,ts}'], | ||
preset: 'ts-jest', | ||
moduleNameMapper: { | ||
'~/(.*)$': '<rootDir>/$1', | ||
}, | ||
verbose: true, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "node-react-parser", | ||
"description": "A library to parse react components", | ||
"keywords": [ | ||
"react", | ||
"parser", | ||
"react parser" | ||
], | ||
"type": "module", | ||
"main": "./src/index.ts", | ||
"version": "0.1.0", | ||
"scripts": { | ||
"cli": "tsx ./src/cli.ts", | ||
"build": "ncc build ./src/cli.ts -o dist", | ||
"test": "jest", | ||
"lint": "eslint .", | ||
"format": "prettier --check ." | ||
}, | ||
"dependencies": { | ||
"typescript": "^5.4.5" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^8.57.0", | ||
"@tsconfig/node20": "^20.1.2", | ||
"@tsconfig/strictest": "^2.0.3", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.12.12", | ||
"@typescript-eslint/parser": "^7.1.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-jest": "^27.9.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.2", | ||
"ts-node": "^10.9.2", | ||
"tsx": "^4.7.1", | ||
"typescript-eslint": "^7.1.1" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...r/src/__fixtures__/all-use-cases/arrow-function/component-with-basic-properties.spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Foo", | ||
"path": "arrow-function/component-with-basic-properties.tsx", | ||
"description": "", | ||
"properties": [ | ||
{ | ||
"name": "one", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "two", | ||
"type": "number" | ||
}, | ||
{ | ||
"name": "three", | ||
"type": "boolean" | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
...-parser/src/__fixtures__/all-use-cases/arrow-function/component-with-basic-properties.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const Foo = ({ | ||
one, | ||
two, | ||
three, | ||
}: { | ||
one: string | ||
two: number | ||
three: boolean | ||
}) => { | ||
return <div>Foo</div> | ||
} |
6 changes: 6 additions & 0 deletions
6
...rser/src/__fixtures__/all-use-cases/arrow-function/component-without-properties.spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Foo", | ||
"path": "arrow-function/component-without-properties.tsx", | ||
"description": "", | ||
"properties": [] | ||
} |
3 changes: 3 additions & 0 deletions
3
...act-parser/src/__fixtures__/all-use-cases/arrow-function/component-without-properties.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const Foo = () => { | ||
return <div>Foo</div> | ||
} |
6 changes: 6 additions & 0 deletions
6
...parser/src/__fixtures__/all-use-cases/arrow-function/default-exported-component.spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Foo", | ||
"path": "function/default-exported-component.tsx", | ||
"description": "", | ||
"properties": [] | ||
} |
5 changes: 5 additions & 0 deletions
5
...react-parser/src/__fixtures__/all-use-cases/arrow-function/default-exported-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Foo = () => { | ||
return <div>Foo</div> | ||
} | ||
|
||
export default Foo |
19 changes: 19 additions & 0 deletions
19
...-parser/src/__fixtures__/all-use-cases/function/component-with-basic-properties.spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Foo", | ||
"path": "function/component-with-basic-properties.tsx", | ||
"description": "", | ||
"properties": [ | ||
{ | ||
"name": "one", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "two", | ||
"type": "number" | ||
}, | ||
{ | ||
"name": "three", | ||
"type": "boolean" | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
...-react-parser/src/__fixtures__/all-use-cases/function/component-with-basic-properties.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function Foo({ | ||
one, | ||
two, | ||
three, | ||
}: { | ||
one: string | ||
two: number | ||
three: boolean | ||
}) { | ||
return <div>Foo</div> | ||
} |
6 changes: 6 additions & 0 deletions
6
...act-parser/src/__fixtures__/all-use-cases/function/component-without-properties.spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Foo", | ||
"path": "function/component-without-properties.tsx", | ||
"description": "", | ||
"properties": [] | ||
} |
3 changes: 3 additions & 0 deletions
3
...ode-react-parser/src/__fixtures__/all-use-cases/function/component-without-properties.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function Foo() { | ||
return <div>Foo</div> | ||
} |
6 changes: 6 additions & 0 deletions
6
...react-parser/src/__fixtures__/all-use-cases/function/default-exported-component.spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "Foo", | ||
"path": "function/default-exported-component.tsx", | ||
"description": "", | ||
"properties": [] | ||
} |
3 changes: 3 additions & 0 deletions
3
.../node-react-parser/src/__fixtures__/all-use-cases/function/default-exported-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Foo() { | ||
return <div>Foo</div> | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/node-react-parser/src/__fixtures__/all-use-cases/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"target": "ES2017", | ||
"moduleResolution": "bundler", | ||
"typeRoots": ["node_modules/@types", "src/types"], | ||
"types": ["node", "jest", "@testing-library/jest-dom"], | ||
"esModuleInterop": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": ["./*"] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/node-react-parser/src/__fixtures__/no-components/foo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo |
14 changes: 14 additions & 0 deletions
14
packages/node-react-parser/src/__fixtures__/no-components/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"target": "ES2017", | ||
"moduleResolution": "bundler", | ||
"typeRoots": ["node_modules/@types", "src/types"], | ||
"types": ["node", "jest", "@testing-library/jest-dom"], | ||
"esModuleInterop": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": ["./*"] | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/node-react-parser/src/__fixtures__/one-component-with-basic-properties/foo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function Foo({ | ||
one, | ||
two, | ||
three, | ||
}: { | ||
one: string | ||
two: number | ||
three: boolean | ||
}) { | ||
return <div>Foo</div> | ||
} |
14 changes: 14 additions & 0 deletions
14
...ages/node-react-parser/src/__fixtures__/one-component-with-basic-properties/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"target": "ES2017", | ||
"moduleResolution": "bundler", | ||
"typeRoots": ["node_modules/@types", "src/types"], | ||
"types": ["node", "jest", "@testing-library/jest-dom"], | ||
"esModuleInterop": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": ["./*"] | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/node-react-parser/src/__fixtures__/one-component/foo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function Foo() { | ||
return <div>Foo</div> | ||
} |
Oops, something went wrong.