From 8b2c4a38a461ff5ecc95972291bc711e2c5dec9a Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 28 Apr 2023 01:47:57 +0800 Subject: --- .../with-create-react-app/packages/ui/.eslintrc.js | 1 + .../with-create-react-app/packages/ui/package.json | 25 ++++++++++++++++++++++ .../with-create-react-app/packages/ui/src/Link.tsx | 20 +++++++++++++++++ .../packages/ui/src/index.tsx | 4 ++++ .../packages/ui/tsconfig.json | 5 +++++ 5 files changed, 55 insertions(+) create mode 100644 examples/with-create-react-app/packages/ui/.eslintrc.js create mode 100644 examples/with-create-react-app/packages/ui/package.json create mode 100644 examples/with-create-react-app/packages/ui/src/Link.tsx create mode 100644 examples/with-create-react-app/packages/ui/src/index.tsx create mode 100644 examples/with-create-react-app/packages/ui/tsconfig.json (limited to 'examples/with-create-react-app/packages/ui') diff --git a/examples/with-create-react-app/packages/ui/.eslintrc.js b/examples/with-create-react-app/packages/ui/.eslintrc.js new file mode 100644 index 0000000..3f6c1e9 --- /dev/null +++ b/examples/with-create-react-app/packages/ui/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require("../eslint-config-custom"); diff --git a/examples/with-create-react-app/packages/ui/package.json b/examples/with-create-react-app/packages/ui/package.json new file mode 100644 index 0000000..e9aedab --- /dev/null +++ b/examples/with-create-react-app/packages/ui/package.json @@ -0,0 +1,25 @@ +{ + "name": "ui", + "version": "0.0.0", + "private": true, + "license": "MIT", + "sideEffects": false, + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "scripts": { + "build": "tsup src/index.tsx --format cjs --dts --external react", + "clean": "rm -rf dist", + "dev": "tsup src/index.tsx --format cjs --watch --dts --external react", + "lint": "eslint \"src/**/*.ts*\"" + }, + "devDependencies": { + "@types/react": "^17.0.13", + "@types/react-dom": "^17.0.8", + "eslint": "^8.4.1", + "eslint-config-custom": "workspace:*", + "react": "^17.0.2", + "tsconfig": "workspace:*", + "tsup": "^5.10.1", + "typescript": "^4.5.3" + } +} diff --git a/examples/with-create-react-app/packages/ui/src/Link.tsx b/examples/with-create-react-app/packages/ui/src/Link.tsx new file mode 100644 index 0000000..416bac8 --- /dev/null +++ b/examples/with-create-react-app/packages/ui/src/Link.tsx @@ -0,0 +1,20 @@ +import * as React from "react"; + +interface LinkProps extends React.AnchorHTMLAttributes { + children: React.ReactNode; + href: string; +} + +export const Link = (props: LinkProps) => { + const { children, href, ...rest } = props; + + if (rest.target === "_blank") { + rest.rel = "noopener noreferrer"; + } + + return ( + + {children} + + ); +}; diff --git a/examples/with-create-react-app/packages/ui/src/index.tsx b/examples/with-create-react-app/packages/ui/src/index.tsx new file mode 100644 index 0000000..c7aa624 --- /dev/null +++ b/examples/with-create-react-app/packages/ui/src/index.tsx @@ -0,0 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import * as React from "react"; + +export * from "./Link"; diff --git a/examples/with-create-react-app/packages/ui/tsconfig.json b/examples/with-create-react-app/packages/ui/tsconfig.json new file mode 100644 index 0000000..ad010d9 --- /dev/null +++ b/examples/with-create-react-app/packages/ui/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "tsconfig/react-library.json", + "include": ["."], + "exclude": ["dist", "node_modules"] +} -- cgit v1.2.3-70-g09d2