diff --git a/.gitignore b/.gitignore index c3e05d6f25..bbd8fe162e 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,6 @@ coverage venv *.orig out/ + +# typescript tsbuildinfo +*.tsbuildinfo diff --git a/CHANGELOG.md b/CHANGELOG.md index ea4b36f55f..d33ca1990a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,15 @@ should change the heading of the (upcoming) version to include a major version b - Added theme for Fluent UI v9 (React Components), fixing [#3659](https://github.com/rjsf-team/react-jsonschema-form/issues/3659) +## @rjsf/snapshot-tests + +Move theme snapshot tests into separate package + +## Dev / playground + +- update configuration to use typescript project references, start type checking the tests + + # 5.13.6 ## @rjsf/core diff --git a/nx.json b/nx.json index 4977839da8..f836e8d38c 100644 --- a/nx.json +++ b/nx.json @@ -25,7 +25,11 @@ }, "targetDefaults": { "build": { - "dependsOn": ["^build"] + "dependsOn": [{ + "//": "use only dependencies to avoid cycle @rjsf/core:build --> @rjsf/snapshot-tests:build --> @rjsf/core:build", + "projects": "dependencies", + "target": "^build" + }] } }, "affected": { diff --git a/package-lock.json b/package-lock.json index 9dec41b902..a245a7b0e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,8 @@ "packages/semantic-ui", "packages/utils", "packages/validator-ajv6", - "packages/validator-ajv8" + "packages/validator-ajv8", + "packages/snapshot-tests" ], "devDependencies": { "@babel/eslint-parser": "^7.22.15", @@ -9662,6 +9663,10 @@ "resolved": "packages/semantic-ui", "link": true }, + "node_modules/@rjsf/snapshot-tests": { + "resolved": "packages/snapshot-tests", + "link": true + }, "node_modules/@rjsf/utils": { "resolved": "packages/utils", "link": true @@ -10402,9 +10407,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.5", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.5.tgz", - "integrity": "sha512-ebylz2hnsWR9mYvmBFbXJXr+33UPc4+ZdxyDXh5w0FlPBTfCVN3wPL+kuOiQt3xvrK419v7XWeAs+AeOksafXg==", + "version": "29.5.8", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.8.tgz", + "integrity": "sha512-fXEFTxMV2Co8ZF5aYFJv+YeA08RTYJfhtN5c9JSv/mFEMe+xxjufCb+PHL+bJcMs/ebPUsBu+UNTEz+ydXrR6g==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -33535,9 +33540,11 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", "@rollup/plugin-replace": "^5.0.2", + "@types/jest": "^29.5.5", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", @@ -34193,8 +34200,10 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", @@ -34243,8 +34252,10 @@ "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", @@ -34336,9 +34347,11 @@ "@babel/preset-env": "^7.22.15", "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv6": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", @@ -34452,8 +34465,10 @@ "@babel/preset-typescript": "^7.22.15", "@fluentui/react": "^8.111.2", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", @@ -34496,28 +34511,24 @@ "@babel/preset-env": "^7.22.15", "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", - "@rjsf/core": "^5.13.2", - "@rjsf/utils": "^5.13.0", - "@rjsf/validator-ajv8": "^5.13.0", + "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", + "@rjsf/utils": "^5.13.6", + "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", - "ajv": "^8.12.0", "babel-jest": "^29.6.4", - "chai": "^3.5.0", "esbuild": "^0.18.20", "eslint": "^8.48.0", "jest": "^29.6.4", "jest-environment-jsdom": "^29.6.4", - "jsdom": "^20.0.3", - "mocha": "^10.2.0", "react": "^17.0.2", "react-dom": "^17.0.2", - "react-portal": "^4.2.2", "react-test-renderer": "^17.0.2", "rimraf": "^5.0.1", "rollup": "^3.29.0", - "sinon": "^9.2.4", "typescript": "^4.9.5" }, "engines": { @@ -34528,28 +34539,6 @@ "react": "^16.14.0 || >=17" } }, - "packages/fluentui-rc/node_modules/ajv": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", - "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "packages/fluentui-rc/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, "packages/material-ui": { "name": "@rjsf/material-ui", "version": "5.13.6", @@ -34564,8 +34553,10 @@ "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", @@ -34609,8 +34600,10 @@ "@mui/icons-material": "^5.14.8", "@mui/material": "^5.14.8", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", @@ -34717,6 +34710,7 @@ "react-transform-hmr": "^1.0.4", "rimraf": "^5.0.1", "source-map-loader": "^4.0.1", + "typescript": "^4.9.5", "vite": "^4.4.9" }, "engines": { @@ -34793,8 +34787,10 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", @@ -34823,6 +34819,32 @@ "semantic-ui-react": "^1.3.1" } }, + "packages/snapshot-tests": { + "name": "@rjsf/snapshot-tests", + "version": "5.13.6", + "license": "Apache-2.0", + "dependencies": { + "@rjsf/core": "^5.10.0", + "@rjsf/utils": "^5.10.0", + "@rjsf/validator-ajv8": "^5.10.0" + }, + "devDependencies": { + "@types/jest": "^29.5.3", + "@types/react": "^17.0.62", + "@types/react-dom": "^17.0.20", + "@types/react-test-renderer": "^17.0.2", + "react": "^17.0.2", + "react-test-renderer": "^17.0.2", + "typescript": "^4.9.5" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": "^16.14.0 || >=17", + "react-test-renderer": "^17.0.2" + } + }, "packages/utils": { "name": "@rjsf/utils", "version": "5.13.6", @@ -34841,6 +34863,7 @@ "@babel/preset-env": "^7.22.15", "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", + "@types/jest": "^29.5.5", "@types/json-schema": "^7.0.12", "@types/json-schema-merge-allof": "^0.6.1", "@types/lodash": "^4.14.198", @@ -34892,6 +34915,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/utils": "^5.13.6", + "@types/jest": "^29.5.7", "@types/json-schema": "^7.0.12", "@types/lodash": "^4.14.198", "babel-jest": "^29.6.4", @@ -34928,6 +34952,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/utils": "^5.13.6", + "@types/jest": "^29.5.7", "@types/json-schema": "^7.0.12", "@types/lodash": "^4.14.198", "babel-jest": "^29.6.4", diff --git a/package.json b/package.json index 5d59d58036..82498696b0 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "packages/semantic-ui", "packages/utils", "packages/validator-ajv6", - "packages/validator-ajv8" + "packages/validator-ajv8", + "packages/snapshot-tests" ] } diff --git a/packages/antd/package.json b/packages/antd/package.json index 6403e4c59d..41b75ab940 100644 --- a/packages/antd/package.json +++ b/packages/antd/package.json @@ -6,11 +6,11 @@ "module": "lib/index.js", "typings": "lib/index.d.ts", "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/antd.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/antd.esm.js --format=umd --file=dist/antd.umd.js --name=@rjsf/antd", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -57,9 +57,11 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", "@rollup/plugin-replace": "^5.0.2", + "@types/jest": "^29.5.5", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", diff --git a/packages/antd/src/tsconfig.json b/packages/antd/src/tsconfig.json new file mode 100644 index 0000000000..01834bf1ab --- /dev/null +++ b/packages/antd/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/antd/test/Array.test.tsx b/packages/antd/test/Array.test.tsx index e8648cfe4c..2ae40788e3 100644 --- a/packages/antd/test/Array.test.tsx +++ b/packages/antd/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests, { CHECKBOXES_CUSTOMIZE } from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests, CHECKBOXES_CUSTOMIZE } from '@rjsf/snapshot-tests'; import '../__mocks__/matchMedia.mock'; import Form from '../src'; diff --git a/packages/antd/test/Form.test.tsx b/packages/antd/test/Form.test.tsx index ca4a92cdd9..005ed52a46 100644 --- a/packages/antd/test/Form.test.tsx +++ b/packages/antd/test/Form.test.tsx @@ -1,7 +1,7 @@ import renderer from 'react-test-renderer'; import validator from '@rjsf/validator-ajv8'; import { RJSFSchema } from '@rjsf/utils'; -import formTests, { SELECT_CUSTOMIZE } from '@rjsf/core/testSnap/formTests'; +import { formTests, SELECT_CUSTOMIZE } from '@rjsf/snapshot-tests'; import '../__mocks__/matchMedia.mock'; import Form from '../src'; diff --git a/packages/antd/test/Object.test.tsx b/packages/antd/test/Object.test.tsx index fd12052c8e..fc9655bca3 100644 --- a/packages/antd/test/Object.test.tsx +++ b/packages/antd/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import '../__mocks__/matchMedia.mock'; import Form from '../src'; diff --git a/packages/antd/test/tsconfig.json b/packages/antd/test/tsconfig.json new file mode 100644 index 0000000000..5db560d2c3 --- /dev/null +++ b/packages/antd/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/antd/tsconfig.json b/packages/antd/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/antd/tsconfig.json +++ b/packages/antd/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/bootstrap-4/package.json b/packages/bootstrap-4/package.json index e0beff7e35..7c8dba5f58 100644 --- a/packages/bootstrap-4/package.json +++ b/packages/bootstrap-4/package.json @@ -15,11 +15,11 @@ "url": "" }, "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/bootstrap-4.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/bootstrap-4.esm.js --format=umd --file=dist/bootstrap-4.umd.js --name=@rjsf/bootstrap-4", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -50,8 +50,10 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", diff --git a/packages/bootstrap-4/src/tsconfig.json b/packages/bootstrap-4/src/tsconfig.json new file mode 100644 index 0000000000..01834bf1ab --- /dev/null +++ b/packages/bootstrap-4/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/bootstrap-4/test/Array.test.tsx b/packages/bootstrap-4/test/Array.test.tsx index 7709a7a692..a17060201a 100644 --- a/packages/bootstrap-4/test/Array.test.tsx +++ b/packages/bootstrap-4/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/bootstrap-4/test/Form.test.tsx b/packages/bootstrap-4/test/Form.test.tsx index 8aac502b3e..c96826c914 100644 --- a/packages/bootstrap-4/test/Form.test.tsx +++ b/packages/bootstrap-4/test/Form.test.tsx @@ -1,4 +1,4 @@ -import formTests from '@rjsf/core/testSnap/formTests'; +import { formTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/bootstrap-4/test/Object.test.tsx b/packages/bootstrap-4/test/Object.test.tsx index 3caaa69282..dabe023e32 100644 --- a/packages/bootstrap-4/test/Object.test.tsx +++ b/packages/bootstrap-4/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/bootstrap-4/test/tsconfig.json b/packages/bootstrap-4/test/tsconfig.json new file mode 100644 index 0000000000..5db560d2c3 --- /dev/null +++ b/packages/bootstrap-4/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/bootstrap-4/tsconfig.json b/packages/bootstrap-4/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/bootstrap-4/tsconfig.json +++ b/packages/bootstrap-4/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/chakra-ui/package.json b/packages/chakra-ui/package.json index 4c0e5e9f58..24139a9ac3 100644 --- a/packages/chakra-ui/package.json +++ b/packages/chakra-ui/package.json @@ -11,11 +11,11 @@ "src" ], "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/chakra-ui.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/chakra-ui.esm.js --format=umd --file=dist/chakra-ui.umd.js --name=@rjsf/chakra-ui", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -69,8 +69,10 @@ "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", diff --git a/packages/chakra-ui/src/tsconfig.json b/packages/chakra-ui/src/tsconfig.json new file mode 100644 index 0000000000..794ef76faa --- /dev/null +++ b/packages/chakra-ui/src/tsconfig.json @@ -0,0 +1,26 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx", + // There are type errors in @chakra-ui/menu type definitions because of which skipLibCheck had to be added + // @chakra-ui/menu/dist/declarations/src/use-menu.d.ts:986:61 - error TS2694: Namespace '"node_modules/csstype/index".Property' has no exported member 'ColorAdjust'. + "skipLibCheck": true + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/chakra-ui/test/Array.test.tsx b/packages/chakra-ui/test/Array.test.tsx index 7709a7a692..a17060201a 100644 --- a/packages/chakra-ui/test/Array.test.tsx +++ b/packages/chakra-ui/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/chakra-ui/test/Form.test.tsx b/packages/chakra-ui/test/Form.test.tsx index 8aac502b3e..c96826c914 100644 --- a/packages/chakra-ui/test/Form.test.tsx +++ b/packages/chakra-ui/test/Form.test.tsx @@ -1,4 +1,4 @@ -import formTests from '@rjsf/core/testSnap/formTests'; +import { formTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/chakra-ui/test/Object.test.tsx b/packages/chakra-ui/test/Object.test.tsx index 3caaa69282..dabe023e32 100644 --- a/packages/chakra-ui/test/Object.test.tsx +++ b/packages/chakra-ui/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/chakra-ui/test/tsconfig.json b/packages/chakra-ui/test/tsconfig.json new file mode 100644 index 0000000000..d825800ca7 --- /dev/null +++ b/packages/chakra-ui/test/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx", + // todo: + // ../../node_modules/@chakra-ui/menu/dist/declarations/src/use-menu.d.ts:986:61 - error TS2694: Namespace '"node_modules/csstype/index".Property' has no exported member 'ColorAdjust'. + "skipLibCheck": true + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/chakra-ui/tsconfig.json b/packages/chakra-ui/tsconfig.json index 0230c34710..82462dfbeb 100644 --- a/packages/chakra-ui/tsconfig.json +++ b/packages/chakra-ui/tsconfig.json @@ -1,13 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx", - // There are type errors in @chakra-ui/menu type definitions because of which skipLibCheck had to be added - // @chakra-ui/menu/dist/declarations/src/use-menu.d.ts:986:61 - error TS2694: Namespace '"node_modules/csstype/index".Property' has no exported member 'ColorAdjust'. - "skipLibCheck": true - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/core/package.json b/packages/core/package.json index 4634d82fab..84c230e7b1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,13 +3,13 @@ "version": "5.13.6", "description": "A simple React component capable of building HTML forms out of a JSON schema.", "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/index.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/index.esm.js --format=umd --file=dist/core.umd.js --name=JSONSchemaForm", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", - "cs-check": "prettier -l \"{src,test,testSnap}/**/*.[jt]s?(x)\"", - "cs-format": "prettier \"{src,test,testSnap}/**/*.[jt]s?(x)\" --write", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "cs-check": "prettier -l \"{src,test}/**/*.[jt]s?(x)\"", + "cs-format": "prettier \"{src,test}/**/*.[jt]s?(x)\" --write", "lint": "eslint src test", "precommit": "lint-staged", "publish-to-npm": "npm run build && npm publish", @@ -20,7 +20,7 @@ "test-coverage": "jest --coverage" }, "lint-staged": { - "{src,test,testSnap}/**/*.[jt]s?(x)": [ + "{src,test}/**/*.[jt]s?(x)": [ "eslint --fix" ] }, @@ -54,9 +54,11 @@ "@babel/preset-env": "^7.22.15", "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv6": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", diff --git a/packages/core/src/tsconfig.json b/packages/core/src/tsconfig.json new file mode 100644 index 0000000000..d2e6a35741 --- /dev/null +++ b/packages/core/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv6" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/core/test/ArraySnap.test.jsx b/packages/core/test/ArraySnap.test.jsx index 540590fe99..93046e87f1 100644 --- a/packages/core/test/ArraySnap.test.jsx +++ b/packages/core/test/ArraySnap.test.jsx @@ -1,4 +1,4 @@ import Form from '../src'; -import arrayTests from '../testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; arrayTests(Form); diff --git a/packages/core/test/FormSnap.test.jsx b/packages/core/test/FormSnap.test.jsx index 19ed866c93..65498a69b4 100644 --- a/packages/core/test/FormSnap.test.jsx +++ b/packages/core/test/FormSnap.test.jsx @@ -1,4 +1,4 @@ import Form from '../src'; -import formTests from '../testSnap/formTests'; +import { formTests } from '@rjsf/snapshot-tests'; formTests(Form); diff --git a/packages/core/test/ObjectSnap.test.jsx b/packages/core/test/ObjectSnap.test.jsx index 45f4895a62..3721817572 100644 --- a/packages/core/test/ObjectSnap.test.jsx +++ b/packages/core/test/ObjectSnap.test.jsx @@ -1,4 +1,4 @@ import Form from '../src'; -import objectTests from '../testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; objectTests(Form); diff --git a/packages/core/test/tsconfig.json b/packages/core/test/tsconfig.json new file mode 100644 index 0000000000..3655ccd74d --- /dev/null +++ b/packages/core/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + }, + ] +} diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/docs/docs/contributing.md b/packages/docs/docs/contributing.md index 4f0fc2bac8..99fcb0145c 100644 --- a/packages/docs/docs/contributing.md +++ b/packages/docs/docs/contributing.md @@ -73,9 +73,9 @@ There are functions in the `testSnap` directory: `arrayTests`, `formTests` and ` Each theme will basically run these functions by creating a `Xxx.test.tsx` file (where `Xxx` is `Array`, `Form` or `Object`) that looks like the following: ```tsx -import arrayTests from '@rjsf/core/testSnap/arrayTests'; // OR -// import arrayTests from '@rjsf/core/testSnap/formTests' -// import arrayTests from '@rjsf/core/testSnap/objectTests' +import { arrayTests } from '@rjsf/snapshot-tests'; // OR +// import { formTests } from '@rjsf/snapshot-tests'; +// import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; @@ -90,7 +90,7 @@ For example: ```tsx import { RJSFSchema, UiSchema } from '@rjsf/utils'; -import arrayTests from '@rjsf/core/testSnap/formTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluent-ui/package.json b/packages/fluent-ui/package.json index 03cbd58f65..a12f86cdc3 100644 --- a/packages/fluent-ui/package.json +++ b/packages/fluent-ui/package.json @@ -11,11 +11,11 @@ "src" ], "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/fluent-ui.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/fluent-ui.esm.js --format=umd --file=dist/fluent-ui.umd.js --name=@rjsf/fluent-ui", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -47,8 +47,10 @@ "@babel/preset-typescript": "^7.22.15", "@fluentui/react": "^8.111.2", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", diff --git a/packages/fluent-ui/src/tsconfig.json b/packages/fluent-ui/src/tsconfig.json new file mode 100644 index 0000000000..36a20a539a --- /dev/null +++ b/packages/fluent-ui/src/tsconfig.json @@ -0,0 +1,29 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx", + // There are type errors in @fluentui type definitions because of which skipLibCheck had to be added + // @fluentui/font-icons-mdl2/lib/IconNames.d.ts + // @fluentui/merge-styles/lib/mergeStyleSets.d.ts + // @fluentui/react/lib/components/SelectedItemsList/BaseSelectedItemsList.d.ts + // @fluentui/utilities/lib/styled.d.ts + "skipLibCheck": true + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/fluent-ui/test/Array.test.tsx b/packages/fluent-ui/test/Array.test.tsx index 7709a7a692..a17060201a 100644 --- a/packages/fluent-ui/test/Array.test.tsx +++ b/packages/fluent-ui/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluent-ui/test/Form.test.tsx b/packages/fluent-ui/test/Form.test.tsx index 8aac502b3e..c96826c914 100644 --- a/packages/fluent-ui/test/Form.test.tsx +++ b/packages/fluent-ui/test/Form.test.tsx @@ -1,4 +1,4 @@ -import formTests from '@rjsf/core/testSnap/formTests'; +import { formTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluent-ui/test/Object.test.tsx b/packages/fluent-ui/test/Object.test.tsx index 3caaa69282..dabe023e32 100644 --- a/packages/fluent-ui/test/Object.test.tsx +++ b/packages/fluent-ui/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluent-ui/test/tsconfig.json b/packages/fluent-ui/test/tsconfig.json new file mode 100644 index 0000000000..5db560d2c3 --- /dev/null +++ b/packages/fluent-ui/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/fluent-ui/tsconfig.json b/packages/fluent-ui/tsconfig.json index 9738c553a3..82462dfbeb 100644 --- a/packages/fluent-ui/tsconfig.json +++ b/packages/fluent-ui/tsconfig.json @@ -1,16 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx", - // There are type errors in @fluentui type definitions because of which skipLibCheck had to be added - // @fluentui/font-icons-mdl2/lib/IconNames.d.ts - // @fluentui/merge-styles/lib/mergeStyleSets.d.ts - // @fluentui/react/lib/components/SelectedItemsList/BaseSelectedItemsList.d.ts - // @fluentui/utilities/lib/styled.d.ts - "skipLibCheck": true - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/fluentui-rc/package.json b/packages/fluentui-rc/package.json index a3384d1c76..7563e48c0e 100644 --- a/packages/fluentui-rc/package.json +++ b/packages/fluentui-rc/package.json @@ -3,11 +3,11 @@ "version": "5.13.6", "description": "FluentUI React Components theme, fields and widgets for react-jsonschema-form", "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/index.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/index.esm.js --format=umd --file=dist/core.umd.js --name=JSONSchemaForm", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test,testSnap}/**/*.[jt]s?(x)\"", "cs-format": "prettier \"{src,test,testSnap}/**/*.[jt]s?(x)\" --write", "lint": "eslint src test", @@ -20,9 +20,8 @@ "test-coverage": "jest --coverage" }, "lint-staged": { - "{src,test,testSnap}/**/*.[jt]s?(x)": [ - "eslint --fix", - "prettier --write" + "{src,test}/**/*.[jt]s?(x)": [ + "eslint --fix" ] }, "main": "dist/index.js", @@ -53,28 +52,24 @@ "@babel/preset-env": "^7.22.15", "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", - "@rjsf/core": "^5.13.2", - "@rjsf/utils": "^5.13.0", - "@rjsf/validator-ajv8": "^5.13.0", + "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", + "@rjsf/utils": "^5.13.6", + "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", - "ajv": "^8.12.0", "babel-jest": "^29.6.4", - "chai": "^3.5.0", "esbuild": "^0.18.20", "eslint": "^8.48.0", "jest": "^29.6.4", "jest-environment-jsdom": "^29.6.4", - "jsdom": "^20.0.3", - "mocha": "^10.2.0", "react": "^17.0.2", "react-dom": "^17.0.2", - "react-portal": "^4.2.2", "react-test-renderer": "^17.0.2", "rimraf": "^5.0.1", "rollup": "^3.29.0", - "sinon": "^9.2.4", "typescript": "^4.9.5" }, "directories": { diff --git a/packages/fluentui-rc/test/Array.test.tsx b/packages/fluentui-rc/test/Array.test.tsx index 7709a7a692..a17060201a 100644 --- a/packages/fluentui-rc/test/Array.test.tsx +++ b/packages/fluentui-rc/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluentui-rc/test/Form.test.tsx b/packages/fluentui-rc/test/Form.test.tsx index 8aac502b3e..c96826c914 100644 --- a/packages/fluentui-rc/test/Form.test.tsx +++ b/packages/fluentui-rc/test/Form.test.tsx @@ -1,4 +1,4 @@ -import formTests from '@rjsf/core/testSnap/formTests'; +import { formTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluentui-rc/test/Object.test.tsx b/packages/fluentui-rc/test/Object.test.tsx index 3caaa69282..dabe023e32 100644 --- a/packages/fluentui-rc/test/Object.test.tsx +++ b/packages/fluentui-rc/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/fluentui-rc/tsconfig.json b/packages/fluentui-rc/tsconfig.json index a0a7c6e7bd..77e127b0ed 100644 --- a/packages/fluentui-rc/tsconfig.json +++ b/packages/fluentui-rc/tsconfig.json @@ -7,5 +7,16 @@ "baseUrl": "./", "jsx": "react-jsx", "skipLibCheck": true - } + }, + "references": [ + { + "path": "../core" + }, + { + "path": "../utils" + }, + { + "path": "../validator-ajv8" + } + ] } diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index 4c9b912c46..2ba3dfbb5d 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -11,11 +11,11 @@ "src" ], "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/material-ui.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/material-ui.esm.js --format=umd --file=dist/material-ui.umd.js --name=@rjsf/material-ui", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -48,8 +48,10 @@ "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", diff --git a/packages/material-ui/src/tsconfig.json b/packages/material-ui/src/tsconfig.json new file mode 100644 index 0000000000..01834bf1ab --- /dev/null +++ b/packages/material-ui/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/material-ui/test/Array.test.tsx b/packages/material-ui/test/Array.test.tsx index 7709a7a692..a17060201a 100644 --- a/packages/material-ui/test/Array.test.tsx +++ b/packages/material-ui/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/material-ui/test/Form.test.tsx b/packages/material-ui/test/Form.test.tsx index 6829f8aa97..bdcb9b0bdd 100644 --- a/packages/material-ui/test/Form.test.tsx +++ b/packages/material-ui/test/Form.test.tsx @@ -1,4 +1,4 @@ -import formTests, { SLIDER_CUSTOMIZE } from '@rjsf/core/testSnap/formTests'; +import { formTests, SLIDER_CUSTOMIZE } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/material-ui/test/Object.test.tsx b/packages/material-ui/test/Object.test.tsx index 3caaa69282..dabe023e32 100644 --- a/packages/material-ui/test/Object.test.tsx +++ b/packages/material-ui/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/material-ui/test/tsconfig.json b/packages/material-ui/test/tsconfig.json new file mode 100644 index 0000000000..5db560d2c3 --- /dev/null +++ b/packages/material-ui/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/material-ui/tsconfig.json b/packages/material-ui/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/material-ui/tsconfig.json +++ b/packages/material-ui/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/mui/package.json b/packages/mui/package.json index 37fa1a1cb6..e8bc300c17 100644 --- a/packages/mui/package.json +++ b/packages/mui/package.json @@ -11,11 +11,11 @@ "src" ], "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/mui.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/mui.esm.js --format=umd --file=dist/mui.umd.js --name=@rjsf/mui", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -53,8 +53,10 @@ "@mui/icons-material": "^5.14.8", "@mui/material": "^5.14.8", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", "@types/react-test-renderer": "^17.0.3", diff --git a/packages/mui/src/tsconfig.json b/packages/mui/src/tsconfig.json new file mode 100644 index 0000000000..01834bf1ab --- /dev/null +++ b/packages/mui/src/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/mui/test/Array.test.tsx b/packages/mui/test/Array.test.tsx index 7709a7a692..a17060201a 100644 --- a/packages/mui/test/Array.test.tsx +++ b/packages/mui/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/mui/test/Form.test.tsx b/packages/mui/test/Form.test.tsx index 444a933de5..fdc2b75b9e 100644 --- a/packages/mui/test/Form.test.tsx +++ b/packages/mui/test/Form.test.tsx @@ -1,4 +1,4 @@ -import formTests, { SLIDER_CUSTOMIZE, TEXTAREA_CUSTOMIZE } from '@rjsf/core/testSnap/formTests'; +import { formTests, SLIDER_CUSTOMIZE, TEXTAREA_CUSTOMIZE } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/mui/test/Object.test.tsx b/packages/mui/test/Object.test.tsx index 3caaa69282..dabe023e32 100644 --- a/packages/mui/test/Object.test.tsx +++ b/packages/mui/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/mui/test/tsconfig.json b/packages/mui/test/tsconfig.json new file mode 100644 index 0000000000..5db560d2c3 --- /dev/null +++ b/packages/mui/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/mui/tsconfig.json b/packages/mui/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/mui/tsconfig.json +++ b/packages/mui/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/playground/package.json b/packages/playground/package.json index 7bbc813eaf..b35857ce2e 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -105,6 +105,7 @@ "react-transform-hmr": "^1.0.4", "rimraf": "^5.0.1", "source-map-loader": "^4.0.1", + "typescript": "^4.9.5", "vite": "^4.4.9" }, "directories": { diff --git a/packages/playground/src/app.tsx b/packages/playground/src/app.tsx index 20cd676f3d..43ccb289d9 100644 --- a/packages/playground/src/app.tsx +++ b/packages/playground/src/app.tsx @@ -14,6 +14,7 @@ import Ajv2020 from 'ajv/dist/2020.js'; import Layout from './layout'; import Playground, { PlaygroundProps } from './components'; +// @ts-expect-error todo: error TS2345: Argument of type 'Localize' is not assignable to parameter of type 'Localizer'. const esV8Validator = customizeValidator({}, localize_es); const AJV8_2019 = customizeValidator({ AjvClass: Ajv2019 }); const AJV8_2020 = customizeValidator({ AjvClass: Ajv2020 }); diff --git a/packages/playground/src/components/Playground.tsx b/packages/playground/src/components/Playground.tsx index 2f7a8d7840..8152d003e8 100644 --- a/packages/playground/src/components/Playground.tsx +++ b/packages/playground/src/components/Playground.tsx @@ -20,7 +20,7 @@ export interface PlaygroundProps { export default function Playground({ themes, validators }: PlaygroundProps) { const [loaded, setLoaded] = useState(false); const [schema, setSchema] = useState(samples.Simple.schema as RJSFSchema); - const [uiSchema, setUiSchema] = useState(samples.Simple.uiSchema); + const [uiSchema, setUiSchema] = useState(samples.Simple.uiSchema!); const [formData, setFormData] = useState(samples.Simple.formData); const [extraErrors, setExtraErrors] = useState(); const [shareURL, setShareURL] = useState(null); diff --git a/packages/playground/src/components/Selector.tsx b/packages/playground/src/components/Selector.tsx index 91f9111da1..9e9707cc2b 100644 --- a/packages/playground/src/components/Selector.tsx +++ b/packages/playground/src/components/Selector.tsx @@ -1,14 +1,14 @@ import { useState, MouseEvent } from 'react'; -import { Sample, samples } from '../samples'; +import { samples } from '../samples'; interface SelectorProps { onSelected: (data: any) => void; } export default function Selector({ onSelected }: SelectorProps) { - const [current, setCurrent] = useState('Simple'); + const [current, setCurrent] = useState('Simple'); - function onLabelClick(label: Sample) { + function onLabelClick(label: string) { return (event: MouseEvent) => { event.preventDefault(); setCurrent(label); @@ -21,7 +21,7 @@ export default function Selector({ onSelected }: SelectorProps) { {Object.keys(samples).map((label, i) => { return (
  • - + {label}
  • diff --git a/packages/playground/tsconfig.json b/packages/playground/tsconfig.json index 3c9b7c805d..25dd7e04d0 100644 --- a/packages/playground/tsconfig.json +++ b/packages/playground/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "rootDir": "./src", + "baseUrl": "./", "target": "ESNext", "useDefineForClassFields": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], @@ -19,5 +21,17 @@ "types": ["vite/client"] }, "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] + "references": [ + { "path": "../antd" }, + { "path": "../bootstrap-4" }, + { "path": "../chakra-ui" }, + { "path": "../core" }, + { "path": "../fluent-ui" }, + { "path": "../material-ui" }, + { "path": "../mui" }, + { "path": "../semantic-ui" }, + { "path": "../utils" }, + { "path": "../validator-ajv6" }, + { "path": "../validator-ajv8" } + ] } diff --git a/packages/playground/tsconfig.node.json b/packages/playground/tsconfig.node.json deleted file mode 100644 index 9d31e2aed9..0000000000 --- a/packages/playground/tsconfig.node.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "module": "ESNext", - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/packages/semantic-ui/package.json b/packages/semantic-ui/package.json index f296b4e3cc..54157022d1 100644 --- a/packages/semantic-ui/package.json +++ b/packages/semantic-ui/package.json @@ -15,11 +15,11 @@ "node": ">=14" }, "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/semantic-ui.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/semantic-ui.esm.js --format=umd --file=dist/semantic-ui.umd.js --name=@rjsf/semantic-ui", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -46,8 +46,10 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/core": "^5.13.6", + "@rjsf/snapshot-tests": "^5.13.6", "@rjsf/utils": "^5.13.6", "@rjsf/validator-ajv8": "^5.13.6", + "@types/jest": "^29.5.7", "@types/lodash": "^4.14.198", "@types/react": "^17.0.65", "@types/react-dom": "^17.0.20", diff --git a/packages/semantic-ui/src/tsconfig.json b/packages/semantic-ui/src/tsconfig.json new file mode 100644 index 0000000000..ea4f988573 --- /dev/null +++ b/packages/semantic-ui/src/tsconfig.json @@ -0,0 +1,26 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx", + // There are type errors in semantic-ui-react type definitions because of which skipLibCheck had to be added + // semantic-ui-react/dist/commonjs/generic.d.ts(73,73): error TS2344: Type 'TProps' does not satisfy the constraint 'Record'. + "skipLibCheck": true + }, + "references": [ + { + "path": "../../core" + }, + { + "path": "../../utils" + }, + { + "path": "../../validator-ajv8" + } + ] +} diff --git a/packages/semantic-ui/test/Array.test.tsx b/packages/semantic-ui/test/Array.test.tsx index 7b658bca59..468ee40fab 100644 --- a/packages/semantic-ui/test/Array.test.tsx +++ b/packages/semantic-ui/test/Array.test.tsx @@ -1,4 +1,4 @@ -import arrayTests from '@rjsf/core/testSnap/arrayTests'; +import { arrayTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/semantic-ui/test/Form.test.tsx b/packages/semantic-ui/test/Form.test.tsx index 4750719e94..7d5de6fe89 100644 --- a/packages/semantic-ui/test/Form.test.tsx +++ b/packages/semantic-ui/test/Form.test.tsx @@ -1,7 +1,7 @@ import { RJSFSchema } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; import renderer from 'react-test-renderer'; -import formTests from '@rjsf/core/testSnap/formTests'; +import { formTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/semantic-ui/test/Object.test.tsx b/packages/semantic-ui/test/Object.test.tsx index 6a9ed1d5b0..0b8142fd2a 100644 --- a/packages/semantic-ui/test/Object.test.tsx +++ b/packages/semantic-ui/test/Object.test.tsx @@ -1,4 +1,4 @@ -import objectTests from '@rjsf/core/testSnap/objectTests'; +import { objectTests } from '@rjsf/snapshot-tests'; import Form from '../src'; diff --git a/packages/semantic-ui/test/tsconfig.json b/packages/semantic-ui/test/tsconfig.json new file mode 100644 index 0000000000..5db560d2c3 --- /dev/null +++ b/packages/semantic-ui/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + "noEmit": true, + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../snapshot-tests" + } + ] +} diff --git a/packages/semantic-ui/tsconfig.json b/packages/semantic-ui/tsconfig.json index a88ff5a3e8..82462dfbeb 100644 --- a/packages/semantic-ui/tsconfig.json +++ b/packages/semantic-ui/tsconfig.json @@ -1,13 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx", - // There are type errors in semantic-ui-react type definitions because of which skipLibCheck had to be added - // semantic-ui-react/dist/commonjs/generic.d.ts(73,73): error TS2344: Type 'TProps' does not satisfy the constraint 'Record'. - "skipLibCheck": true - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/snapshot-tests/.eslintrc b/packages/snapshot-tests/.eslintrc new file mode 100644 index 0000000000..731b36bae0 --- /dev/null +++ b/packages/snapshot-tests/.eslintrc @@ -0,0 +1,4 @@ +{ + "extends": ["../../.eslintrc"], + "plugins": ["@typescript-eslint", "jsx-a11y", "react", "import"] +} diff --git a/packages/snapshot-tests/.npmignore b/packages/snapshot-tests/.npmignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/snapshot-tests/README.md b/packages/snapshot-tests/README.md new file mode 100644 index 0000000000..7cdf42ab83 --- /dev/null +++ b/packages/snapshot-tests/README.md @@ -0,0 +1,104 @@ +[![Build Status][build-shield]][build-url] +[![npm][npm-shield]][npm-url] +[![npm downloads][npm-dl-shield]][npm-dl-url] +[![Contributors][contributors-shield]][contributors-url] +[![Apache 2.0 License][license-shield]][license-url] + +
    +

    + + Logo + + +

    @rjsf/snapshot-tests

    + +

    + A set of snapshot tests to be used for testing RJSF themes. +
    + Explore the docs » +
    +
    + View Playground + · + Report Bug + · + Request Feature +

    +

    + + + +## Table of Contents + +- [Table of Contents](#table-of-contents) +- [About The Project](#about-the-project) +- [Getting Started](#getting-started) + - [Installation](#installation) +- [Usage](#usage) +- [Roadmap](#roadmap) +- [Contributing](#contributing) +- [Contact](#contact) + + + +## About The Project + +Package with snapshot test suits for testing themes for `react-jsonschema-form`. + + + +## Getting Started + +### Installation + +```sh +npm install @rjsf/snapshot-tests +``` + +## Usage + +```tsx +import { arrayTests } from '@rjsf/snapshot-tests'; // OR +// import { formTests } from '@rjsf/snapshot-tests'; +// import { objectTests } from '@rjsf/snapshot-tests'; + +import Form from '../src'; + +arrayTests(Form); // OR +// formTests(Form); +// objectTests(Form); +``` + + +## Roadmap + +See the general [open issues](https://github.com/rjsf-team/react-jsonschema-form/issues). + + + +## Contributing + +Read our [contributors' guide](https://rjsf-team.github.io/react-jsonschema-form/docs/contributing/) to get started. + + + +## Contact + +rjsf team: [https://github.com/orgs/rjsf-team/people](https://github.com/orgs/rjsf-team/people) + +GitHub repository: [https://github.com/rjsf-team/react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form) + + + + +[build-shield]: https://github.com/rjsf-team/react-jsonschema-form/workflows/CI/badge.svg +[build-url]: https://github.com/rjsf-team/react-jsonschema-form/actions +[contributors-shield]: https://img.shields.io/github/contributors/rjsf-team/react-jsonschema-form.svg +[contributors-url]: https://github.com/rjsf-team/react-jsonschema-form/graphs/contributors +[license-shield]: https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square +[license-url]: https://choosealicense.com/licenses/apache-2.0/ +[npm-shield]: https://img.shields.io/npm/v/@rjsf/snapshot-tests/latest.svg?style=flat-square +[npm-url]: https://www.npmjs.com/package/@rjsf/snapshot-tests +[npm-dl-shield]: https://img.shields.io/npm/dm/@rjsf/snapshot-tests.svg?style=flat-square +[npm-dl-url]: https://www.npmjs.com/package/@rjsf/snapshot-tests +[product-screenshot]: https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/59a8206e148474bea854bbb004f624143fbcbac8/packages/snapshot-tests/screenshot.png diff --git a/packages/snapshot-tests/package.json b/packages/snapshot-tests/package.json new file mode 100644 index 0000000000..01a5f5602f --- /dev/null +++ b/packages/snapshot-tests/package.json @@ -0,0 +1,66 @@ +{ + "name": "@rjsf/snapshot-tests", + "version": "5.13.6", + "description": "A set of snapshot tests to be used for testing RJSF theme.", + "scripts": { + "build": "tsc -b .", + "cs-check": "prettier -l \"src/**/*.[jt]s?(x)\"", + "cs-format": "prettier \"src/**/*.[jt]s?(x)\" --write", + "lint": "eslint src", + "precommit": "lint-staged", + "publish-to-npm": "npm run build && npm publish", + "test": "echo 'OK'", + "test-coverage": "echo 'OK'" + }, + "lint-staged": { + "src/**/*.[jt]s?(x)": [ + "eslint --fix" + ] + }, + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "files": [ + "dist", + "lib" + ], + "engineStrict": false, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": "^16.14.0 || >=17", + "react-test-renderer": "^17.0.2" + }, + "dependencies": { + "@rjsf/utils": "^5.10.0", + "@rjsf/validator-ajv8": "^5.10.0", + "@rjsf/core": "^5.10.0" + }, + "devDependencies": { + "@types/jest": "^29.5.3", + "@types/react": "^17.0.62", + "@types/react-dom": "^17.0.20", + "@types/react-test-renderer": "^17.0.2", + "react": "^17.0.2", + "react-test-renderer": "^17.0.2", + "typescript": "^4.9.5" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rjsf-team/react-jsonschema-form.git" + }, + "author": "Nicolas Perriault ", + "contributors": [ + "Heath Chiavettone , customOptions: ArrayRenderCustomOptions = {}) { +export function arrayTests(Form: ComponentType, customOptions: ArrayRenderCustomOptions = {}) { describe('array fields', () => { test('array', () => { const schema: RJSFSchema = { diff --git a/packages/core/testSnap/formTests.tsx b/packages/snapshot-tests/src/formTests.tsx similarity index 98% rename from packages/core/testSnap/formTests.tsx rename to packages/snapshot-tests/src/formTests.tsx index 92d6a24eb7..4ffa74c13b 100644 --- a/packages/core/testSnap/formTests.tsx +++ b/packages/snapshot-tests/src/formTests.tsx @@ -3,7 +3,7 @@ import renderer, { TestRendererOptions } from 'react-test-renderer'; import { RJSFSchema, ErrorSchema } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; -import { FormProps } from '../src'; +import { FormProps } from '@rjsf/core'; export const SELECT_CUSTOMIZE = 'selectMulti'; export const SLIDER_CUSTOMIZE = 'slider'; @@ -15,7 +15,7 @@ export type FormRenderCustomOptions = { textarea?: TestRendererOptions; }; -export default function formTests(Form: ComponentType, customOptions: FormRenderCustomOptions = {}) { +export function formTests(Form: ComponentType, customOptions: FormRenderCustomOptions = {}) { describe('single fields', () => { describe('string field', () => { test('regular', () => { diff --git a/packages/snapshot-tests/src/index.ts b/packages/snapshot-tests/src/index.ts new file mode 100644 index 0000000000..dd85ece8e0 --- /dev/null +++ b/packages/snapshot-tests/src/index.ts @@ -0,0 +1,11 @@ +export { type ArrayRenderCustomOptions, CHECKBOXES_CUSTOMIZE, arrayTests } from './arrayTests'; + +export { + type FormRenderCustomOptions, + formTests, + SELECT_CUSTOMIZE, + SLIDER_CUSTOMIZE, + TEXTAREA_CUSTOMIZE, +} from './formTests'; + +export { objectTests } from './objectTests'; diff --git a/packages/core/testSnap/objectTests.tsx b/packages/snapshot-tests/src/objectTests.tsx similarity index 98% rename from packages/core/testSnap/objectTests.tsx rename to packages/snapshot-tests/src/objectTests.tsx index dcdfedea7c..0d1d1a577b 100644 --- a/packages/core/testSnap/objectTests.tsx +++ b/packages/snapshot-tests/src/objectTests.tsx @@ -3,7 +3,7 @@ import renderer from 'react-test-renderer'; import { RJSFSchema, UiSchema } from '@rjsf/utils'; import validator from '@rjsf/validator-ajv8'; -import { FormProps } from '../src'; +import { FormProps } from '@rjsf/core'; const titleAndDesc = { title: 'Test field', @@ -33,7 +33,7 @@ const labelsOff: UiSchema = { 'ui:globalOptions': { label: false }, }; -export default function arrayTests(Form: ComponentType) { +export function objectTests(Form: ComponentType) { describe('object fields', () => { test('object', () => { const schema: RJSFSchema = { diff --git a/packages/snapshot-tests/tsconfig.json b/packages/snapshot-tests/tsconfig.json new file mode 100644 index 0000000000..d13380177b --- /dev/null +++ b/packages/snapshot-tests/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "module": "CommonJS", + "baseUrl": "./", + "rootDir": "./src", + "outDir": "./lib", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../core/src" + }, + { + "path": "../utils" + }, + { + "path": "../validator-ajv6" + }, + { + "path": "../validator-ajv8" + } + ] +} diff --git a/packages/utils/.gitignore b/packages/utils/.gitignore new file mode 100644 index 0000000000..70bcb98f15 --- /dev/null +++ b/packages/utils/.gitignore @@ -0,0 +1 @@ +lib-test diff --git a/packages/utils/package.json b/packages/utils/package.json index be54ced67d..f8fb38432b 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -15,11 +15,11 @@ "node": ">=14" }, "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -49,6 +49,7 @@ "@babel/preset-env": "^7.22.15", "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", + "@types/jest": "^29.5.5", "@types/json-schema": "^7.0.12", "@types/json-schema-merge-allof": "^0.6.1", "@types/lodash": "^4.14.198", diff --git a/packages/utils/src/tsconfig.json b/packages/utils/src/tsconfig.json new file mode 100644 index 0000000000..7ae2e0ab42 --- /dev/null +++ b/packages/utils/src/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + } +} diff --git a/packages/utils/src/withIdRefPrefix.ts b/packages/utils/src/withIdRefPrefix.ts index e0c7b26c04..68039f5295 100644 --- a/packages/utils/src/withIdRefPrefix.ts +++ b/packages/utils/src/withIdRefPrefix.ts @@ -38,7 +38,9 @@ function withIdRefPrefixArray(node: S[] * @param schemaNode - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it * @returns - A copy of the `schemaNode` with updated `$ref`s */ -export default function withIdRefPrefix(schemaNode: S): S | S[] { +export default function withIdRefPrefix( + schemaNode: S | S[] | S[keyof S] +): S | S[] | S[keyof S] { if (Array.isArray(schemaNode)) { return withIdRefPrefixArray([...schemaNode]); } diff --git a/packages/utils/test/testUtils/testData.ts b/packages/utils/test/testUtils/testData.ts index 14b3f29030..9249a08e4f 100644 --- a/packages/utils/test/testUtils/testData.ts +++ b/packages/utils/test/testUtils/testData.ts @@ -206,7 +206,7 @@ export const oneOfSchema: RJSFSchema = deepFreeze({ export const ONE_OF_SCHEMA_OPTIONS = oneOfSchema[ONE_OF_KEY]! as RJSFSchema[]; export const FIRST_ONE_OF: RJSFSchema = ONE_OF_SCHEMA_OPTIONS[0]; export const SECOND_ONE_OF: RJSFSchema = ONE_OF_SCHEMA_OPTIONS[1]; -export const OPTIONAL_ONE_OF_SCHEMA: RJSFSchema = deepFreeze({ +export const OPTIONAL_ONE_OF_SCHEMA: RJSFSchema = deepFreeze({ oneOf: [ { type: 'object', @@ -406,7 +406,7 @@ export const TEST_ERROR_LIST_OUTPUT: RJSFValidationError[] = reduce( [] ); -export const SUPER_SCHEMA: RJSFSchema = deepFreeze({ +export const SUPER_SCHEMA: RJSFSchema = deepFreeze({ [ID_KEY]: 'super-schema', definitions: { test: { @@ -506,7 +506,7 @@ export const SUPER_SCHEMA: RJSFSchema = deepFreeze({ }, }, ], -}); +} satisfies RJSFSchema); export const PROPERTY_DEPENDENCIES: RJSFSchema = deepFreeze({ type: 'object', @@ -668,7 +668,7 @@ export const SCHEMA_WITH_SINGLE_CONDITION: RJSFSchema = deepFreeze({ }, }); -export const SCHEMA_WITH_MULTIPLE_CONDITIONS: RJSFSchema = deepFreeze({ +export const SCHEMA_WITH_MULTIPLE_CONDITIONS: RJSFSchema = deepFreeze({ type: 'object', properties: { Animal: { @@ -774,7 +774,7 @@ export const SCHEMA_WITH_MULTIPLE_CONDITIONS: RJSFSchema = deepFreeze({ required: ['Animal'], }); -export const SCHEMA_WITH_NESTED_CONDITIONS: RJSFSchema = deepFreeze({ +export const SCHEMA_WITH_NESTED_CONDITIONS: RJSFSchema = deepFreeze({ type: 'object', properties: { country: { @@ -835,7 +835,7 @@ export const SCHEMA_WITH_NESTED_CONDITIONS: RJSFSchema = deepFreeze({ }, }); -export const SCHEMA_WITH_ARRAY_CONDITION: RJSFSchema = deepFreeze({ +export const SCHEMA_WITH_ARRAY_CONDITION: RJSFSchema = deepFreeze({ type: 'object', properties: { list: { @@ -845,7 +845,7 @@ export const SCHEMA_WITH_ARRAY_CONDITION: RJSFSchema = deepFreeze({ }, }); -export const SCHEMA_WITH_ALLOF_CANNOT_MERGE: RJSFSchema = deepFreeze({ +export const SCHEMA_WITH_ALLOF_CANNOT_MERGE: RJSFSchema = deepFreeze({ type: 'object', properties: { animal: { diff --git a/packages/utils/test/toErrorList.test.ts b/packages/utils/test/toErrorList.test.ts index cc468df01d..9b21cfd058 100644 --- a/packages/utils/test/toErrorList.test.ts +++ b/packages/utils/test/toErrorList.test.ts @@ -9,6 +9,7 @@ describe('toErrorList()', () => { expect(toErrorList({})).toEqual([]); }); it('Returns an empty array when an object with a non-plain child object is provided', () => { + // @ts-expect-error testing unexpected argument handling expect(toErrorList({ nonObject: new Error('non-object') })).toEqual([]); }); it('Returns the expected list of errors when given an ErrorSchema', () => { diff --git a/packages/utils/test/tsconfig.json b/packages/utils/test/tsconfig.json new file mode 100644 index 0000000000..a437f4ecba --- /dev/null +++ b/packages/utils/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "baseUrl": "../", + // todo: noEmit: true + // maybe better to move this to some separate package + // this is needed for packages/validator-ajv8/test/utilsTests + "outDir": "../lib-test", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + } + ] +} diff --git a/packages/utils/test/withIdRef.test.ts b/packages/utils/test/withIdRef.test.ts index 17a63dbfb0..609068c4ea 100644 --- a/packages/utils/test/withIdRef.test.ts +++ b/packages/utils/test/withIdRef.test.ts @@ -34,8 +34,8 @@ describe('withIdRefPrefix()', () => { expect(withIdRefPrefix(schema)).toEqual(schema); }); - it('should handle null schema', () => { - const schema: RJSFSchema = null; - expect(withIdRefPrefix(schema)).toEqual(schema); + it('should handle null schemaNode', () => { + const schemaNode = null; + expect(withIdRefPrefix(schemaNode)).toEqual(schemaNode); }); }); diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/validator-ajv6/package.json b/packages/validator-ajv6/package.json index 3dfa5e0639..bd289fa186 100644 --- a/packages/validator-ajv6/package.json +++ b/packages/validator-ajv6/package.json @@ -15,11 +15,11 @@ "node": ">=14" }, "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/validator-ajv6.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/validator-ajv6.esm.js --format=umd --file=dist/validator-ajv6.umd.js --name=@rjsf/validator-ajv6", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -47,6 +47,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/utils": "^5.13.6", + "@types/jest": "^29.5.7", "@types/json-schema": "^7.0.12", "@types/lodash": "^4.14.198", "babel-jest": "^29.6.4", diff --git a/packages/validator-ajv6/src/tsconfig.json b/packages/validator-ajv6/src/tsconfig.json new file mode 100644 index 0000000000..2701b42ad7 --- /dev/null +++ b/packages/validator-ajv6/src/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": [ + "./" + ], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../utils" + } + ] +} diff --git a/packages/validator-ajv6/test/tsconfig.json b/packages/validator-ajv6/test/tsconfig.json new file mode 100644 index 0000000000..ff0e009d67 --- /dev/null +++ b/packages/validator-ajv6/test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./", "./**/*.json"], + "compilerOptions": { + "rootDir": "./", + "noEmit": true, + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../utils/test" + } + ] +} diff --git a/packages/validator-ajv6/tsconfig.json b/packages/validator-ajv6/tsconfig.json index 0786a3f6bf..82462dfbeb 100644 --- a/packages/validator-ajv6/tsconfig.json +++ b/packages/validator-ajv6/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/packages/validator-ajv8/package.json b/packages/validator-ajv8/package.json index ad588c5c76..43f6e1edac 100644 --- a/packages/validator-ajv8/package.json +++ b/packages/validator-ajv8/package.json @@ -15,11 +15,11 @@ "node": ">=14" }, "scripts": { - "build:ts": "rimraf lib && tsc", + "build:ts": "tsc -b", "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs && esbuild ./src/compileSchemaValidators.ts --bundle --outfile=dist/compileSchemaValidators.js --sourcemap --packages=external --format=cjs", "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/validator-ajv8.esm.js --sourcemap --packages=external --format=esm && esbuild ./src/compileSchemaValidators.ts --bundle --outfile=dist/compileSchemaValidators.esm.js --sourcemap --packages=external --format=esm", "build:umd": "rollup dist/validator-ajv8.esm.js --format=umd --file=dist/validator-ajv8.umd.js --name=@rjsf/validator-ajv8", - "build": "rimraf dist && npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", + "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd", "cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"", "cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write", "lint": "eslint src test", @@ -49,6 +49,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.22.15", "@rjsf/utils": "^5.13.6", + "@types/jest": "^29.5.7", "@types/json-schema": "^7.0.12", "@types/lodash": "^4.14.198", "babel-jest": "^29.6.4", diff --git a/packages/validator-ajv8/src/tsconfig.json b/packages/validator-ajv8/src/tsconfig.json new file mode 100644 index 0000000000..95445107e0 --- /dev/null +++ b/packages/validator-ajv8/src/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./"], + "compilerOptions": { + "rootDir": "./", + "outDir": "../lib", + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../../utils" + } + ] +} diff --git a/packages/validator-ajv8/test/compileSchemaValidatorsCode.test.ts b/packages/validator-ajv8/test/compileSchemaValidatorsCode.test.ts index 93b655f1d4..641d7d0e52 100644 --- a/packages/validator-ajv8/test/compileSchemaValidatorsCode.test.ts +++ b/packages/validator-ajv8/test/compileSchemaValidatorsCode.test.ts @@ -17,9 +17,9 @@ describe('compileSchemaValidatorsCode()', () => { describe('compiling without additional options', () => { let schemas: RJSFSchema[]; beforeAll(() => { - schemas = Object.values(schemaParser(superSchema as RJSFSchema)); + schemas = Object.values(schemaParser(superSchema as unknown as RJSFSchema)); expectedCode = readFileSync('./test/harness/superSchema.js').toString(); - generatedCode = compileSchemaValidatorsCode(superSchema as RJSFSchema); + generatedCode = compileSchemaValidatorsCode(superSchema as unknown as RJSFSchema); }); it('create AJV instance was called with the expected options', () => { const expectedCompileOpts = { code: { source: true, lines: true }, schemas }; @@ -33,9 +33,9 @@ describe('compileSchemaValidatorsCode()', () => { let schemas: RJSFSchema[]; let expectedCode: string; beforeAll(() => { - schemas = Object.values(schemaParser(superSchema as RJSFSchema)); + schemas = Object.values(schemaParser(superSchema as unknown as RJSFSchema)); expectedCode = readFileSync('./test/harness/superSchemaOptions.js').toString(); - generatedCode = compileSchemaValidatorsCode(superSchema as RJSFSchema, { + generatedCode = compileSchemaValidatorsCode(superSchema as unknown as RJSFSchema, { ...CUSTOM_OPTIONS, ajvOptionsOverrides: { ...CUSTOM_OPTIONS.ajvOptionsOverrides, code: { lines: false } }, }); diff --git a/packages/validator-ajv8/test/createPrecompiledValidator.test.ts b/packages/validator-ajv8/test/createPrecompiledValidator.test.ts index f8c9d28c18..346d74d15e 100644 --- a/packages/validator-ajv8/test/createPrecompiledValidator.test.ts +++ b/packages/validator-ajv8/test/createPrecompiledValidator.test.ts @@ -2,6 +2,8 @@ import { RJSFSchema } from '@rjsf/utils'; import AJV8PrecompiledValidator from '../src/precompiledValidator'; import { Localizer, ValidatorFunctions } from '../src'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore file might be not yet generated by test/harness/compileTestSchema.js import * as superSchemaFns from './harness/superSchema'; import superSchema from './harness/superSchema.json'; import createPrecompiledValidator from '../src/createPrecompiledValidator'; @@ -14,7 +16,7 @@ type TestType = { }; const validateFns = superSchemaFns as ValidatorFunctions; -const rootSchema = superSchema as RJSFSchema; +const rootSchema = superSchema as unknown as RJSFSchema; const mockedValidator = jest.mocked(AJV8PrecompiledValidator); describe('createPrecompiledValidator()', () => { diff --git a/packages/validator-ajv8/test/harness/compileTestSchema.js b/packages/validator-ajv8/test/harness/compileTestSchema.js index 5504056428..c404533543 100644 --- a/packages/validator-ajv8/test/harness/compileTestSchema.js +++ b/packages/validator-ajv8/test/harness/compileTestSchema.js @@ -9,6 +9,7 @@ * Then add the two updated `superSchema.js` and `superSchemaOptions.js` files to your PR */ +// @ts-ignore todo: update this to use sources directly const compileSchemaValidators = require('../../dist/compileSchemaValidators').default; const superSchema = require('./superSchema.json'); diff --git a/packages/validator-ajv8/test/precompiledValidator.test.ts b/packages/validator-ajv8/test/precompiledValidator.test.ts index cc23f54615..02662002a0 100644 --- a/packages/validator-ajv8/test/precompiledValidator.test.ts +++ b/packages/validator-ajv8/test/precompiledValidator.test.ts @@ -12,13 +12,17 @@ import { import AJV8PrecompiledValidator from '../src/precompiledValidator'; import { Localizer, ValidatorFunctions } from '../src'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore file might be not yet generated by test/harness/compileTestSchema.js import * as superSchemaFns from './harness/superSchema'; +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore file might be not yet generated by test/harness/compileTestSchema.js import * as superSchemaOptionsFns from './harness/superSchemaOptions'; import superSchema from './harness/superSchema.json'; const validateFns = superSchemaFns as ValidatorFunctions; const validateOptionsFns = superSchemaOptionsFns as ValidatorFunctions; -const rootSchema = superSchema as RJSFSchema; +const rootSchema = superSchema as unknown as RJSFSchema; describe('AJV8PrecompiledValidator', () => { let builder: ErrorSchemaBuilder; diff --git a/packages/validator-ajv8/test/tsconfig.json b/packages/validator-ajv8/test/tsconfig.json new file mode 100644 index 0000000000..4ccf928f2c --- /dev/null +++ b/packages/validator-ajv8/test/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["./", "./**/*.json"], + "compilerOptions": { + "rootDir": "./", + "noEmit": true, + "resolveJsonModule": true, + "baseUrl": "../", + "jsx": "react-jsx" + }, + "references": [ + { + "path": "../src" + }, + { + "path": "../../utils/test" + } + ] +} diff --git a/packages/validator-ajv8/tsconfig.json b/packages/validator-ajv8/tsconfig.json index 1b1d75c204..82462dfbeb 100644 --- a/packages/validator-ajv8/tsconfig.json +++ b/packages/validator-ajv8/tsconfig.json @@ -1,11 +1,12 @@ { "extends": "../../tsconfig.base.json", - "include": ["src"], - "compilerOptions": { - "rootDir": "./src", - "outDir": "./lib", - "resolveJsonModule": true, - "baseUrl": "./", - "jsx": "react-jsx" - } + "files": [], + "references": [ + { + "path": "./src" + }, + { + "path": "./test" + } + ] } diff --git a/tsconfig.base.json b/tsconfig.base.json index ebf463b2cd..49415e1249 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "composite": true, "target": "es6", "module": "esnext", "lib": ["dom", "esnext"], diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..f4ea64b91f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,47 @@ +{ + "files": [], + "references": [ + { + "path": "./packages/antd" + }, + { + "path": "./packages/bootstrap-4" + }, + { + "path": "./packages/chakra-ui" + }, + { + "path": "./packages/core" + }, + { + "path": "./packages/snapshot-tests" + }, + { + "path": "./packages/fluent-ui" + }, + { + "path": "./packages/fluentui-rc" + }, + { + "path": "./packages/material-ui" + }, + { + "path": "./packages/mui" + }, + { + "path": "./packages/playground" + }, + { + "path": "./packages/semantic-ui" + }, + { + "path": "./packages/utils" + }, + { + "path": "./packages/validator-ajv6" + }, + { + "path": "./packages/validator-ajv8" + } + ] +}