From 4cfa0bc689031de3a2e7983442a668b687bc1ae8 Mon Sep 17 00:00:00 2001 From: Dima Vyshniakov Date: Thu, 30 Nov 2023 18:17:52 +0100 Subject: [PATCH 1/2] update readme --- README.md | 38 +++++++++++++++++++++++++++++++++++++- tsconfig.linter.json | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 962f585..61f3e2e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ # React Library Template -With React Template Repository, you can focus on developing your React components and libraries without worrying about the configuration and setup. +With React Library Template Repository, you can focus on developing your React components and libraries without worrying about the configuration and setup. + +Read [full documentation](https://github.com/morewings/cra-template-npm-library/wiki). + +Visit [Demo Storybook](https://morewings.github.io/cra-template-npm-library). + +## Features + +- Supports **Typescript** and **Javascript**. +- Bundles `commonjs` and `es` module formats. +- [pnpm](https://pnpm.io/) for blazing fast package management. +- [Vite](https://vitejs.dev/) for speedy bundling +- [Husky](https://github.com/typicode/husky) for git hooks. +- [Eslint](https://eslint.org/) and [stylelint](https://stylelint.io/). +- [Rollup](https://rollupjs.org/guide/en/) for bundling. +- [Jest](https://jestjs.io/) and [react-testing-library](https://testing-library.com/docs/react-testing-library/intro) for testing. +- [Storybook](https://storybook.js.org/) for documentation and demo. +- And [much more](https://github.com/morewings/cra-template-npm-library/wiki). + +## Quickstart + +### Prerequisites + +1. Install **Node** >= 18.x. +2. Install **pnpm**. E.g. `corepack prepare pnpm@latest --activate`. + + +### Installation + +Manually clone repo or use `degit`. + +```shell script +npx degit https://github.com/morewings/react-library-template my-library +cd ./my-library +pnpm i +``` + diff --git a/tsconfig.linter.json b/tsconfig.linter.json index ad2eb3a..0535d8c 100644 --- a/tsconfig.linter.json +++ b/tsconfig.linter.json @@ -1,5 +1,5 @@ { "extends" : "./tsconfig.json", - "include": ["**/*.stories.tsx", "**/*.stories.ts", "vite.config.ts", "src"], + "include": ["**/*.stories.tsx", "**/*.stories.ts", "*.config.ts", "src"], "exclude": [] } From ecd99e32189641ad9de78324fad7c8a7ffe06033 Mon Sep 17 00:00:00 2001 From: Dima Vyshniakov Date: Thu, 30 Nov 2023 18:25:53 +0100 Subject: [PATCH 2/2] fix --- .eslintrc.cjs | 22 +++++----------------- package.json | 2 +- tsconfig.linter.json | 2 +- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index f7f7a9d..e836ee6 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -7,6 +7,11 @@ module.exports = { sourceType: 'module', project: './tsconfig.linter.json', }, + settings: { + react: { + version: 'detect' + }, + }, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', @@ -118,23 +123,6 @@ module.exports = { ], }, }, - /* Disable `environment` directory imports for library files */ - { - files: ['./src/lib/**/*.*'], - rules: { - 'no-restricted-imports': [ - 'error', - { - patterns: [ - { - "group": ['**/environment/**'], - "message": "Imports from environment directory are forbidden in the library files." - } - ], - }, - ] - } - } ], }; diff --git a/package.json b/package.json index 4e8798d..fbed045 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "clean:lib": "rm -rf dist", "build:lib": "vite build", "build": "run-s clean:lib build:lib", - "lint:code": "eslint . --ext ts,tsx --report-unused-disable-directives", + "lint:code": "eslint ./src/ --ext ts,tsx --report-unused-disable-directives", "fix:code": "run-s 'lint:code --fix'", "lint:types": "tsc --pretty --noEmit", "lint:style": "stylelint ./src/**/*.css", diff --git a/tsconfig.linter.json b/tsconfig.linter.json index 0535d8c..6594320 100644 --- a/tsconfig.linter.json +++ b/tsconfig.linter.json @@ -1,5 +1,5 @@ { "extends" : "./tsconfig.json", "include": ["**/*.stories.tsx", "**/*.stories.ts", "*.config.ts", "src"], - "exclude": [] + "exclude": ["./dist/**"] }