diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index e9f693a51f..d4a9b744ca 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -1,5 +1,5 @@ { - "packages": ["./"], - "sandboxes": ["/examples/basic", "/examples/basic-typescript"], - "node": "14" + "installCommand": "install:csb", + "sandboxes": ["/examples/react/basic", "/examples/react/basic-typescript"], + "node": "16" } diff --git a/.eslintrc b/.eslintrc index dceb933028..e5470987da 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,5 @@ { + "root": true, "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint", "import"], "extends": [ @@ -12,9 +13,23 @@ "es6": true }, "parserOptions": { - "project": "./tsconfig.json", + "project": "./tsconfig.base.json", "sourceType": "module" }, + "settings": { + "import/parsers": { + "@typescript-eslint/parser": [".ts", ".tsx"] + }, + "import/resolver": { + "node": true, + "typescript": { + "project": "packages/*/tsconfig.json" + } + }, + "react": { + "version": "detect" + } + }, "rules": { "react/jsx-key": ["error", { "checkFragmentShorthand": true }], "@typescript-eslint/ban-types": "off", @@ -32,21 +47,8 @@ ], "no-shadow": "error", "import/no-cycle": "error", - "import/no-unresolved": ["error", { "ignore": ["react-query"] }], + "import/no-unresolved": ["error", { "ignore": ["^@tanstack\/"] }], "import/no-unused-modules": ["off", { "unusedExports": true }], - "import/no-restricted-paths": [ - "error", - { - "zones": [ - { "target": "src/core", "from": "src/broadcastQueryClient-experimental" }, - { "target": "src/core", "from": "src/createAsyncStoragePersister" }, - { "target": "src/core", "from": "src/createWebStoragePersister" }, - { "target": "src/core", "from": "src/devtools" }, - { "target": "src/core", "from": "src/persistQueryClient" }, - { "target": "src/core", "from": "src/reactjs" } - ] - } - ], "no-redeclare": "off" } } diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/ci-v3.yml similarity index 83% rename from .github/workflows/test-and-publish.yml rename to .github/workflows/ci-v3.yml index 5f9aac98b4..00bb69e667 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/ci-v3.yml @@ -3,14 +3,9 @@ name: react-query tests on: push: branches: - - 'master' - - 'next' - - 'alpha' - - 'beta' - '1.x' - '2.x' - pull_request: - + - '3.x' jobs: test: name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}' @@ -40,7 +35,7 @@ jobs: name: 'Publish Module to NPM' needs: test # publish only when merged in master on original repo, not on PR - if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x') + if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x' || github.ref == 'refs/heads/3.x') runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..c2f62e407b --- /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: + if: github.event_name != 'pull_request' + 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: 'npm' + - run: | + npm i + git config --global user.name 'Tanner Linsley' + git config --global user.email 'tannerlinsley@users.noreply.github.com' + npm run cipublish + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} + 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 0000000000..7c5c939ee2 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,26 @@ +name: pr +on: [pull_request] +jobs: + test: + name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}' + runs-on: ubuntu-latest + strategy: + matrix: + node: [14, 16] + react: [17, 18] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - name: Install dependencies + uses: bahmutov/npm-install@v1 + - run: npm run test:ci + env: + REACTJS_VERSION: ${{ matrix.react }} + - run: npm run test:size + if: matrix.node == '16' && matrix.react == '18' + env: + BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 diff --git a/.gitignore b/.gitignore index f821d4d40a..950bf7c71d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ node_modules # builds types build +*/build dist lib es @@ -30,7 +31,13 @@ yarn-error.log* .history size-plugin.json stats-hydration.json -stats-react.json +stats.json stats.html .vscode/settings.json -.idea/ + +*.log +.DS_Store +node_modules +.cache +dist +.idea diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..6f7f377bf5 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..e3b414c7e0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index e3373557c0..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,112 +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-query/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-query/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-query/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 `$ npm i` -- Auto-build files as you edit by running `$ npm run dev` -- 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 `$ npm i && npm run dev`. -- 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-query` 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**: - -``` -(): - - - -