Skip to content

Commit

Permalink
Bump scaffold (#46)
Browse files Browse the repository at this point in the history
* Bump scaffold

* Use JSX classic for pages

---------

Co-authored-by: @compulim <@compulim>
Co-authored-by: William Wong <compulim@hotmail.com>
  • Loading branch information
compulim-workflow-bot[bot] and compulim authored Mar 31, 2024
1 parent 15c04c3 commit 7a6906a
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 18 deletions.
1 change: 0 additions & 1 deletion .eslintrc.react.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
extends:
- plugin:react/recommended
- plugin:react/jsx-runtime
plugins:
- react
settings:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pull-request-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ on:

jobs:
call-workflow:
strategy:
matrix:
react-version: [current, 16, 17, 18]
uses: compulim/workflows/.github/workflows/pull-request-validation.yml@main
with:
package-name: use-ref-from
react-version: ${{ matrix.react-version }}
skip-integration-test: false
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [`jest@29.7.0`](https://npmjs.com/package/jest)
- [`prettier@3.2.5`](https://npmjs.com/package/prettier)
- [`typescript@5.4.3`](https://npmjs.com/package/typescript)
- Updated pull request validation to test against various React versions, in PR [#46](https://github.com/compulim/use-ref-from/pull/46)
- Moved from JSX Runtime to JSX Classic to support testing against React 16

## [0.0.3] - 2023-10-09

Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"postscaffold": "npm run postscaffold:eslint:react && npm run postscaffold --if-present --workspaces",
"postscaffold:eslint:react": "npm run bump:eslintrc",
"precommit": "npm run precommit --if-present --workspaces",
"switch:_": "npm run --if-present --workspaces switch && npm install --legacy-peer-deps --prefer-dedupe",
"switch:react:16": "SWITCH_NAME=react:16 npm run switch:_",
"switch:react:17": "SWITCH_NAME=react:17 npm run switch:_",
"switch:react:18": "SWITCH_NAME=react:18 npm run switch:_",
"test": "npm run test --if-present --workspaces"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-test/babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[
"@babel/preset-react",
{
"runtime": "automatic"
"runtime": "classic"
}
],
[
Expand Down
4 changes: 2 additions & 2 deletions packages/integration-test/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[
"@babel/preset-react",
{
"runtime": "automatic"
"runtime": "classic"
}
]
]
Expand All @@ -21,7 +21,7 @@
[
"@babel/preset-react",
{
"runtime": "automatic"
"runtime": "classic"
}
],
[
Expand Down
1 change: 1 addition & 0 deletions packages/integration-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.localPeerDependencies // {}) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | has($K) | not)) | map(.key + \"@latest\") | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.localPeerDependencies // {}) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | has($K) | not)) | map(.key + \"@latest\") | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
"precommit": "eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts ./",
"switch": "cat package.json | jq --arg SWITCH_NAME $SWITCH_NAME -r '(.[\"switch:\" + $SWITCH_NAME] // {}) as $TEMPLATE | .devDependencies += ($TEMPLATE.devDependencies // {}) | .dependencies += ($TEMPLATE.dependencies // {})' | tee ./package.json.tmp && mv ./package.json.tmp ./package.json",
"test": "jest"
},
"author": "William Wong (https://github.com/compulim)",
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This configuration file is for VSCode only.
{
"compilerOptions": {
"jsx": "react-jsx"
"jsx": "react"
}
}
3 changes: 2 additions & 1 deletion packages/pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"precommit": "npm run precommit:typescript",
"precommit:typescript": "tsc --project ./src/tsconfig.json",
"reinstall": "rm -r node_modules package-lock.json && npm install",
"start": "npm run build -- --servedir=./public"
"start": "npm run build -- --servedir=./public",
"switch": "cat package.json | jq --arg SWITCH_NAME $SWITCH_NAME -r '(.[\"switch:\" + $SWITCH_NAME] // {}) as $TEMPLATE | .devDependencies += ($TEMPLATE.devDependencies // {}) | .dependencies += ($TEMPLATE.dependencies // {})' | tee ./package.json.tmp && mv ./package.json.tmp ./package.json"
},
"author": "William Wong (https://github.com/compulim)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/pages/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment } from 'react';
import React, { Fragment } from 'react';
import { useRefFrom } from 'use-ref-from';

const App = () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/pages/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { createRoot } from 'react-dom/client';
import React from 'react';
// eslint-disable-next-line react/no-deprecated
import { render } from 'react-dom';
// import { createRoot } from 'react-dom/client';

import App from './App';

const rootElement = document.getElementById('root');

rootElement && createRoot(rootElement).render(<App />);
// rootElement && createRoot(rootElement).render(<App />);
rootElement && render(<App />, rootElement);
2 changes: 1 addition & 1 deletion packages/pages/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-jsx",
"jsx": "react",
"lib": ["DOM", "ESNext", "WebWorker"],
"moduleResolution": "Bundler",
"noEmit": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Notes: to test changes in this file, run "jest" with "--no-cache" argument.

const run = ({ filename }) => {
const escapeStringRegexp = require('escape-string-regexp');
const fs = require('fs/promises');
const { extname } = require('path');
const typeScript = require('typescript');
Expand Down Expand Up @@ -54,8 +55,17 @@ const run = ({ filename }) => {

const expectedErrorLine = file.getFullText().split('\n')[line - 1];
const expectedError = expectedErrorLine?.replace(/\s*\/\/\s+/u, '').trim();
let expectedErrors = [expectedError];

expect(message).toEqual(expect.stringContaining(expectedError));
try {
const parsed = JSON.parse(expectedError);

if (Array.isArray(expectedErrors) && expectedErrors.every(value => typeof value === 'string')) {
expectedErrors = parsed;
}
} catch {}

expect(message).toEqual(expect.stringMatching(new RegExp(expectedErrors.map(escapeStringRegexp).join('|'))));
} else {
throw new Error(typeScript.flattenDiagnosticMessageText(messageText, '\n'));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/use-ref-from/babel.commonjs.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[
"@babel/preset-react",
{
"runtime": "automatic"
"runtime": "classic"
}
],
[
Expand Down
2 changes: 1 addition & 1 deletion packages/use-ref-from/babel.esmodules.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[
"@babel/preset-react",
{
"runtime": "automatic"
"runtime": "classic"
}
],
[
Expand Down
2 changes: 1 addition & 1 deletion packages/use-ref-from/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[
"@babel/preset-react",
{
"runtime": "automatic"
"runtime": "classic"
}
],
[
Expand Down
2 changes: 2 additions & 0 deletions packages/use-ref-from/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"precommit:typescript:production": "tsc --noEmit --project ./src/tsconfig.precommit.production.json",
"precommit:typescript:test": "tsc --noEmit --project ./src/tsconfig.precommit.test.json",
"prepack": "cp ../../CHANGELOG.md . && cp ../../LICENSE . && cp ../../README.md .",
"switch": "cat package.json | jq --arg SWITCH_NAME $SWITCH_NAME -r '(.[\"switch:\" + $SWITCH_NAME] // {}) as $TEMPLATE | .devDependencies += ($TEMPLATE.devDependencies // {}) | .dependencies += ($TEMPLATE.dependencies // {})' | tee ./package.json.tmp && mv ./package.json.tmp ./package.json",
"test": "jest"
},
"repository": {
Expand Down Expand Up @@ -80,6 +81,7 @@
"@tsconfig/strictest": "^2.0.4",
"@types/jest": "^29.5.12",
"@types/react": "^18.2.70",
"escape-string-regexp": "^5.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/use-ref-from/src/tsconfig.declaration.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"jsx": "react",
"noEmit": false
},
"exclude": ["**/*.spec.*", "**/*.test.*", "__tests__/**/*"],
Expand Down
2 changes: 1 addition & 1 deletion packages/use-ref-from/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-jsx",
"jsx": "react",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-jsx",
"jsx": "react",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/use-ref-from/src/tsconfig.precommit.test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-jsx",
"jsx": "react",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
Expand Down

0 comments on commit 7a6906a

Please sign in to comment.