Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions .eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ runs:
shell: bash
run: pnpm i -g [email protected]

- name: Use Node.js 18
- name: Use Node.js lts
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm
registry-url: 'https://registry.npmjs.org'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
e2e:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.34.3-focal
image: mcr.microsoft.com/playwright:v1.55.0-noble
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged && pnpm types:check
1 change: 0 additions & 1 deletion e2e/test/concurrent-transition.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('concurrent rendering transitions', () => {
Expand Down
1 change: 0 additions & 1 deletion e2e/test/initial-render.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('rendering', () => {
Expand Down
1 change: 0 additions & 1 deletion e2e/test/mutate-server-action.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test('mutate-server-action', async ({ page }) => {
Expand Down
1 change: 0 additions & 1 deletion e2e/test/stream-ssr.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('Stream SSR', () => {
Expand Down
1 change: 0 additions & 1 deletion e2e/test/suspense-fallback.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('suspense fallback', () => {
Expand Down
1 change: 0 additions & 1 deletion e2e/test/suspense-undefined-key.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('suspense with undefined key', () => {
Expand Down
119 changes: 119 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { defineConfig, globalIgnores } from "eslint/config";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import reactHooks from "eslint-plugin-react-hooks";
import { fixupPluginRules } from "@eslint/compat";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default defineConfig([
globalIgnores([
'**/dist/',
'**/node_modules',
'**/scripts',
'**/examples',
'**/.next',
'**/next.config.js',
'eslint.config.mjs',
'playwright.config.js',
'jest.config.js',
'jest.config.build.js'
]),
{
extends: compat.extends(
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:jest-dom/recommended',
'plugin:testing-library/react',
'plugin:react/jsx-runtime'
),

plugins: {
'@typescript-eslint': typescriptEslint,
'react-hooks': fixupPluginRules(reactHooks)
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest
},

parser: tsParser,
ecmaVersion: 8,
sourceType: 'module',

parserOptions: {
ecmaFeatures: {
impliedStrict: true,
experimentalObjectRestSpread: true
},

allowImportExportEverywhere: true,
project: ['**/tsconfig.json']
}
},

settings: {
react: {
version: 'detect'
}
},

rules: {
'func-names': [2, 'as-needed'],
'no-shadow': 0,
'@typescript-eslint/no-shadow': 2,
'@typescript-eslint/explicit-function-return-type': 0,

'@typescript-eslint/no-unused-vars': [
0,
{
argsIgnorePattern: '^_'
}
],

'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,

'@typescript-eslint/consistent-type-imports': [
2,
{
prefer: 'type-imports'
}
],

'@typescript-eslint/ban-types': 0,
'react-hooks/rules-of-hooks': 2,
'react-hooks/exhaustive-deps': 1,
'react/prop-types': 0,
'testing-library/no-unnecessary-act': 0
}
},
{
files: ['e2e/**/*.ts'],

rules: {
'testing-library/prefer-screen-queries': 'off'
}
}
])
7 changes: 5 additions & 2 deletions jest.config.build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const config = require("./jest.config");
module.exports = {
import config from './jest.config.js'

const useBuildConfig = {
...config,
// override to use build files
moduleNameMapper: {}
}

export default useBuildConfig
14 changes: 8 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
const config = {
testEnvironment: 'jsdom',
testRegex: '/test/.*\\.test\\.tsx?$',
testPathIgnorePatterns: ['/node_modules/', '/e2e/'],
Expand All @@ -10,17 +10,19 @@ module.exports = {
'^swr/immutable$': '<rootDir>/src/immutable/index.ts',
'^swr/subscription$': '<rootDir>/src/subscription/index.ts',
'^swr/mutation$': '<rootDir>/src/mutation/index.ts',
'^swr/_internal$': '<rootDir>/src/_internal/index.ts',
'^swr/_internal$': '<rootDir>/src/_internal/index.ts'
},
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest']
'^.+\\.(t|j)sx?$': '@swc/jest'
},
coveragePathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/node_modules/',
'/dist/',
'/test/',
'<rootDir>/src/_internal/utils/env.ts',
'<rootDir>/src/_internal/utils/env.ts'
],
coverageReporters: ['text', 'html'],
reporters: [['github-actions', { silent: false }], 'summary']
}

export default config
73 changes: 39 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cache",
"fetch"
],
"packageManager": "pnpm@8.4.0",
"packageManager": "pnpm@10.17.0",
"main": "./dist/index/index.js",
"module": "./dist/index/index.mjs",
"types": "./dist/index/index.d.ts",
Expand Down Expand Up @@ -93,7 +93,7 @@
"homepage": "https://swr.vercel.app",
"license": "MIT",
"scripts": {
"prepare": "husky install",
"prepare": "husky",
"csb:install": "corepack enable && corepack pnpm i",
"csb:build": "pnpm build",
"clean": "rimraf ./dist && rimraf playwright-report test-result",
Expand Down Expand Up @@ -121,40 +121,45 @@
]
},
"devDependencies": {
"@edge-runtime/jest-environment": "^3.0.4",
"@arethetypeswrong/cli": "^0.15.3",
"@playwright/test": "1.34.3",
"@swc/core": "^1.3.62",
"@swc/jest": "0.2.26",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.2.1",
"@arethetypeswrong/cli": "^0.18.2",
"@edge-runtime/jest-environment": "^4.0.0",
"@eslint/compat": "^1.3.2",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.36.0",
"@playwright/test": "1.55.0",
"@swc/core": "^1.13.5",
"@swc/jest": "0.2.39",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
"@type-challenges/utils": "0.1.1",
"@types/jest": "^29.5.2",
"@types/node": "^20.2.5",
"@types/react": "^18.2.8",
"@types/use-sync-external-store": "^0.0.3",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"bunchee": "^6.3.2",
"eslint": "8.42.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-jest-dom": "5.1.0",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-testing-library": "5.11.0",
"husky": "8.0.3",
"jest": "29.7.0",
"@types/jest": "^30.0.0",
"@types/node": "^22.18.6",
"@types/react": "^18.3.24",
"@types/use-sync-external-store": "^1.5.0",
"@typescript-eslint/eslint-plugin": "8.44.0",
"@typescript-eslint/parser": "8.44.0",
"bunchee": "^6.6.0",
"eslint": "9.36.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-jest-dom": "5.5.0",
"eslint-plugin-react": "7.37.5",
"eslint-plugin-react-hooks": "5.2.0",
"eslint-plugin-testing-library": "7.8.0",
"globals": "^16.4.0",
"husky": "9.1.7",
"jest": "30.1.3",
"jest-environment-jsdom": "29.7.0",
"lint-staged": "13.2.2",
"next": "15.4.4",
"prettier": "2.8.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.9",
"rimraf": "5.0.1",
"semver": "^7.5.1",
"lint-staged": "16.1.6",
"next": "15.5.3",
"prettier": "3.6.2",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"react-error-boundary": "^5.0.0",
"rimraf": "6.0.1",
"semver": "^7.7.2",
"swr": "workspace:*",
"typescript": "5.1.3"
"typescript": "5.9.2"
},
"peerDependencies": {
"react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
Expand All @@ -169,6 +174,6 @@
},
"dependencies": {
"dequal": "^2.0.3",
"use-sync-external-store": "^1.4.0"
"use-sync-external-store": "^1.5.0"
}
}
Loading
Loading