diff --git a/.browserslistrc b/.browserslistrc index 41bcaa1d38..01b924286a 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,9 +1,7 @@ # 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 +Firefox >= 78 +Edge >= 79 +Safari >= 12.0 +iOS >= 12.0 +opera >= 53 diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index e9f693a51f..483392af19 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -1,5 +1,6 @@ { - "packages": ["./"], - "sandboxes": ["/examples/basic", "/examples/basic-typescript"], - "node": "14" + "installCommand": "install:csb", + "sandboxes": ["/examples/react/basic", "/examples/react/basic-typescript"], + "packages": ["packages/**"], + "node": "16" } diff --git a/.eslintrc b/.eslintrc index 832b08a87c..e5470987da 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,5 @@ { + "root": true, "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint", "import"], "extends": [ @@ -12,8 +13,23 @@ "es6": true }, "parserOptions": { + "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", @@ -22,6 +38,7 @@ "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/no-unnecessary-condition": "error", "@typescript-eslint/no-inferrable-types": [ "error", { @@ -30,7 +47,7 @@ ], "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 }], "no-redeclare": "off" } diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/ci-v3.yml similarity index 74% rename from .github/workflows/test-and-publish.yml rename to .github/workflows/ci-v3.yml index bfb40333b2..7e79b080e2 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/ci-v3.yml @@ -3,20 +3,17 @@ name: react-query tests on: push: branches: - - 'main' - - 'next' - - 'beta' - '1.x' - '2.x' - pull_request: - + - '3.x' jobs: test: - name: 'Node ${{ matrix.node }}' + name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}' runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [14, 16] + react: [17, 18] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -25,8 +22,10 @@ jobs: - name: Install dependencies uses: bahmutov/npm-install@v1 - run: yarn test:ci + env: + REACTJS_VERSION: ${{ matrix.react }} - run: yarn test:size - if: matrix.node == '16' + if: matrix.node == '16' && matrix.react == '18' env: BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} - name: Upload coverage to Codecov @@ -35,8 +34,8 @@ jobs: publish-module: name: 'Publish Module to NPM' needs: test - # publish only when merged in main on original repo, not on PR - if: github.repository == 'TanStack/query' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x') + # publish only when merged in master on original repo, not on PR + if: github.repository == 'TanStack/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..2937d9c0a4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: ci +concurrency: + group: publish-${{ github.github.base_ref }} + cancel-in-progress: true +on: [push] +jobs: + test-and-publish: + if: github.repository == 'TanStack/query' && 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.14.2 + registry-url: https://registry.npmjs.org/ + cache: 'npm' + - run: | + npm i + npm run test:ci + 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..820947817f --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,28 @@ +name: pr +on: [pull_request] +jobs: + test: + name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}' + runs-on: ubuntu-latest + strategy: + matrix: + node: [16.14.2] + 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 + with: + install-command: npm install + - run: npm run test:ci + env: + REACTJS_VERSION: ${{ matrix.react }} + - run: npm run test:size + if: 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/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 7639205ec9..0000000000 --- a/.gitpod.yml +++ /dev/null @@ -1,18 +0,0 @@ -tasks: - - name: Auto Build - init: | - yarn install - gp sync-done boot - command: yarn run start - - - name: Docs - before: cd docs/ - init: | - gp sync-await boot - yarn install - command: yarn dev - openMode: split-right - -ports: - - port: 3000 - onOpen: open-preview diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..6276cf12fb --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16.14.2 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/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 420d141d57..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "workbench.colorCustomizations": { - "titleBar.activeBackground": "#00da63", // change this color! - "titleBar.inactiveBackground": "#00da63", // 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 d406a0ee7b..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,125 +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 `$ yarn` -- Link `react-query` 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-query` by running `$ yarn link react-query` 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 - -## Online one-click setup - -You can use Gitpod (An Online Open Source VS Code like IDE which is free for Open Source) for developing online. With a single click it will start a workspace and automatically: - -- clone the `react-query` repo. -- install all the dependencies in `/` and `/docs`. -- run `yarn start` in the root(`/`) to Auto-build files. -- run `yarn dev` in `/docs`. - -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/tannerlinsley/react-query) - -## 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**: - -``` -(): - - - -