From 426fe5e0ec7c9008bafefd46cde53a6eb5be61bd Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Sun, 6 Feb 2022 21:15:05 +0100 Subject: [PATCH 001/602] feat: update project structure, migrate to typescript (#224) BREAKING CHANGE --- .all-contributorsrc | 29 - .babelrc | 28 - .browserslistrc | 9 - .editorconfig | 9 - .eslintrc | 16 - .gitattributes | 2 - .github/workflows/ci.yml | 29 + .github/workflows/pr.yml | 18 + .github/workflows/test-and-publish.yml | 46 - .gitignore | 14 + .nvmrc | 1 + .prettierrc | 5 + .vscode/settings.json | 8 - CONTRIBUTING.md | 114 - LICENSE | 2 +- babel.config.js | 32 + examples/dynamic/vite.config.js | 5 +- examples/fixed/vite.config.js | 5 +- examples/infinite-scroll/vite.config.js | 5 +- examples/padding/vite.config.js | 5 +- examples/smooth-scroll/vite.config.js | 5 +- examples/sticky/vite.config.js | 5 +- examples/variable/vite.config.js | 5 +- index.js | 5 - jest.config.js | 5 - jest.config.ts | 17 + lerna.json | 6 + package.json | 130 +- .../react-virtual/__tests__/index.test.js | 137 + .../react-virtual/__tests__/jest.setup.js | 1 + packages/react-virtual/package.json | 43 + .../react-virtual/src/index.tsx | 152 +- .../src/useIsomorphicLayoutEffect.ts | 4 + .../react-virtual/src/useRect.ts | 34 +- packages/react-virtual/tsconfig.json | 11 + packages/react-virtual/yarn.lock | 25 + prettier.config.js | 12 - rollup.config.js | 75 +- rollup.config.ts | 189 + scripts/config.ts | 60 + scripts/publish.ts | 505 + scripts/tsconfig.json | 21 + scripts/types.ts | 46 + scripts/utils.ts | 6 + src/tests/index.test.js | 138 - src/useIsomorphicLayoutEffect.js | 5 - tsconfig.base.json | 19 + tsconfig.json | 6 + types/index.d.ts | 63 - types/test.ts | 0 types/tsconfig.json | 15 - types/tslint.json | 6 - yarn.lock | 10030 +++++++++------- 53 files changed, 6819 insertions(+), 5344 deletions(-) delete mode 100644 .all-contributorsrc delete mode 100644 .babelrc delete mode 100644 .browserslistrc delete mode 100644 .editorconfig delete mode 100644 .eslintrc delete mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pr.yml delete mode 100644 .github/workflows/test-and-publish.yml create mode 100644 .nvmrc create mode 100644 .prettierrc delete mode 100644 .vscode/settings.json delete mode 100644 CONTRIBUTING.md create mode 100644 babel.config.js delete mode 100644 index.js delete mode 100644 jest.config.js create mode 100644 jest.config.ts create mode 100644 lerna.json create mode 100644 packages/react-virtual/__tests__/index.test.js create mode 100644 packages/react-virtual/__tests__/jest.setup.js create mode 100644 packages/react-virtual/package.json rename src/index.js => packages/react-virtual/src/index.tsx (67%) create mode 100644 packages/react-virtual/src/useIsomorphicLayoutEffect.ts rename src/useRect.js => packages/react-virtual/src/useRect.ts (71%) create mode 100644 packages/react-virtual/tsconfig.json create mode 100644 packages/react-virtual/yarn.lock delete mode 100644 prettier.config.js create mode 100644 rollup.config.ts create mode 100644 scripts/config.ts create mode 100644 scripts/publish.ts create mode 100644 scripts/tsconfig.json create mode 100644 scripts/types.ts create mode 100644 scripts/utils.ts delete mode 100644 src/tests/index.test.js delete mode 100644 src/useIsomorphicLayoutEffect.js create mode 100644 tsconfig.base.json create mode 100644 tsconfig.json delete mode 100644 types/index.d.ts delete mode 100644 types/test.ts delete mode 100644 types/tsconfig.json delete mode 100644 types/tslint.json diff --git a/.all-contributorsrc b/.all-contributorsrc deleted file mode 100644 index ce8789914..000000000 --- a/.all-contributorsrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "projectName": "react-virtual", - "projectOwner": "tannerlinsley", - "repoType": "github", - "repoHost": "https://github.com", - "files": [ - "README.md" - ], - "imageSize": 100, - "commit": false, - "commitConvention": "none", - "contributors": [ - { - "login": "tannerlinsley", - "name": "Tanner Linsley", - "avatar_url": "https://avatars0.githubusercontent.com/u/5580297?v=4", - "profile": "https://tannerlinsley.com", - "contributions": [ - "code", - "ideas", - "example", - "maintenance", - "review" - ] - }, - ], - "contributorsPerLine": 7, - "skipCi": true -} diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 7fde532a6..000000000 --- a/.babelrc +++ /dev/null @@ -1,28 +0,0 @@ -{ - "presets": [ - [ - "@babel/env", - { - "modules": false, - "loose": true, - "exclude": ["@babel/plugin-transform-regenerator"] - } - ], - "@babel/react" - ], - "plugins": ["babel-plugin-transform-async-to-promises"], - "env": { - "test": { - "presets": [ - [ - "@babel/env", - { - "modules": "commonjs", - "loose": true, - "exclude": ["@babel/plugin-transform-regenerator"] - } - ] - ] - } - } -} diff --git a/.browserslistrc b/.browserslistrc deleted file mode 100644 index 41bcaa1d3..000000000 --- a/.browserslistrc +++ /dev/null @@ -1,9 +0,0 @@ -# Browsers we support -> 0.5% -Chrome >= 73 -ChromeAndroid >= 75 -Firefox >= 67 -Edge >= 17 -IE 11 -Safari >= 12.1 -iOS >= 11.3 \ No newline at end of file diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 9d08a1a82..000000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 3d3ed29bb..000000000 --- a/.eslintrc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": ["react-app", "prettier"], - "env": { - "es6": true - }, - "parserOptions": { - "sourceType": "module" - }, - "rules": { - "react-hooks/exhaustive-deps": [ - "warn", - { "additionalHooks": "(useIsomorphicLayoutEffect)" } - ] - } -} diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe077042..000000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..68012e4ae --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: ci +concurrency: + group: publish-${{ github.github.base_ref }} + cancel-in-progress: true +on: [push] +jobs: + test-and-publish: + name: "Test & Publish" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: "0" + - uses: actions/setup-node@v2 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + cache: "yarn" + - run: | + yarn install --frozen-lockfile + git config --global user.name 'Tanner Linsley' + git config --global user.email 'tannerlinsley@users.noreply.github.com' + yarn cipublish + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + YARN_REGISTRY: https://registry.npmjs.org/ + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 000000000..888d0d31e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,18 @@ +name: pr +on: [pull_request] +jobs: + test: + name: "Test (node ${{ matrix.node }})" + runs-on: ubuntu-latest + strategy: + matrix: + node: [12, 14, 16] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - run: | + yarn install --frozen-lockfile + yarn build + yarn test diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml deleted file mode 100644 index 23e0bc112..000000000 --- a/.github/workflows/test-and-publish.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: react-virtual tests - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - test: - name: 'node ${{ matrix.node }} ${{ matrix.os }} ' - runs-on: '${{ matrix.os }}' - strategy: - matrix: - os: [ubuntu-latest] - node: [12, 10] - steps: - - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node }} - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - run: npm i -g yarn - - run: yarn --frozen-lockfile - - run: yarn test:ci - - publish-module: - name: 'Publish Module to NPM' - needs: test - if: github.ref == 'refs/heads/master' #publish only when merged in master, not on PR - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - uses: actions/setup-node@v1 - with: - node-version: 12 - registry-url: https://registry.npmjs.org/ - - run: npm i -g yarn - - run: yarn --frozen-lockfile - - run: npx semantic-release@17 - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - GH_TOKEN: ${{secrets.GH_TOKEN}} diff --git a/.gitignore b/.gitignore index b6802db06..8ad414273 100644 --- a/.gitignore +++ b/.gitignore @@ -5,11 +5,16 @@ node_modules # builds +types build +*/build dist +lib +es artifacts .rpt2_cache coverage +*.tgz # misc .DS_Store @@ -25,4 +30,13 @@ yarn-debug.log* yarn-error.log* .history size-plugin.json +stats-hydration.json +stats-react.json stats.html +.vscode/settings.json + +*.log +.DS_Store +node_modules +.cache +dist diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..4ec320b21 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v14.17.6 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..e3b414c7e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index cb8705fef..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "workbench.colorCustomizations": { - "titleBar.activeBackground": "#885cff", // change this color! - "titleBar.inactiveBackground": "#885cff", // change this color! - "titleBar.activeForeground": "#ffffff", // change this color! - "titleBar.inactiveForeground": "#ffffff" // change this color! - } -} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 42f942c11..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,114 +0,0 @@ -# Contributing - -## Questions - -If you have questions about implementation details, help or support, then please use our dedicated community forum at [Github Discussions](https://github.com/tannerlinsley/react-virtual/discussions) **PLEASE NOTE:** If you choose to instead open an issue for your question, your issue will be immediately closed and redirected to the forum. - -## Reporting Issues - -If you have found what you think is a bug, please [file an issue](https://github.com/tannerlinsley/react-virtual/issues/new). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [Github Discussions](https://github.com/tannerlinsley/react-virtual/discussions) - -## Suggesting new features - -If you are here to suggest a feature, first create an issue if it does not already exist. From there, we will discuss use-cases for the feature and then finally discuss how it could be implemented. - -## Development - -If you have been assigned to fix an issue or develop a new feature, please follow these steps to get started: - -- Fork this repository -- Install dependencies by running `$ yarn` -- Link `react-virtual` locally by running `$ yarn link` -- Auto-build files as you edit by running `$ yarn start` -- Implement your changes and tests to files in the `src/` directory and corresponding test files -- To run examples, follow their individual directions. Usually this is just `$ yarn && yarn start`. -- To run examples using your local build, link to the local `react-virtual` by running `$ yarn link react-virtual` from the example's directory -- Document your changes in the appropriate doc page -- Git stage your required changes and commit (see below commit guidelines) -- Submit PR for review - -## Commit message conventions - -`react-virtual` is using [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). - -We have very precise rules over how our git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**. - -### Commit Message Format - -Each commit message consists of a **header**, a **body** and a **footer**. The header has a special -format that includes a **type**, a **scope** and a **subject**: - -``` -(): - - - -