From 7c1b556b5a1284daa062c4b7697a01cc996d7bff Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Mon, 13 Oct 2025 01:44:21 -0500 Subject: [PATCH 01/13] Upgrade package manager from Yarn Classic (1.x) to Yarn Modern This is necessary to fix the "focus" behavior of Yarn workspace. In Yarn 1.x, a focused install of a workspace will fail when other workspaces are private. --- .github/workflows/tests.yml | 3 +++ .npmrc | 1 - package.json | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 .npmrc diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e84e38c..f96d90c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,6 +32,9 @@ jobs: with: fetch-depth: '2' + - name: Enable Corepack + run: corepack enable + - name: Test on Node ${{ matrix.node-version }} uses: actions/setup-node@v4 with: diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 43c97e7..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/package.json b/package.json index e246c09..0a9f387 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "private": true, + "packageManager": "yarn@4.10.3", "workspaces": [ "packages/*", "demo" From 5825d32646b5c71b7d1489797b9a80fbd7db0f01 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Mon, 13 Oct 2025 01:47:16 -0500 Subject: [PATCH 02/13] Scope the "tests" GitHub Action workflow to only the npm package Do not install or build the demo workspace. The dependencies of that workspace do not need the same Node version support as the npm package. --- .github/workflows/tests.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f96d90c..e6fe917 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,6 +3,8 @@ name: Tests on: push: branches: [main, develop] + paths-ignore: + - 'demo/**' pull_request: branches: [main, develop] schedule: @@ -10,6 +12,10 @@ on: - cron: '0 0 * * SAT' workflow_dispatch: +defaults: + run: + working-directory: ./packages/regex-to-strings + jobs: test: name: Test @@ -40,14 +46,13 @@ jobs: with: node-version: ${{ matrix.node-version }} - - run: yarn + - run: yarn workspace focus - run: npx prettier --check . - run: yarn run build - run: yarn run lint - run: yarn run test - run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.test.json src/e2e.spec.ts - working-directory: ./packages/regex-to-strings # Workaround for #66 continue-on-error: ${{ !matrix.require-successful-testpack }} From f680bf1c16106472595b27934bc16d857b22ac73 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Mon, 13 Oct 2025 01:55:22 -0500 Subject: [PATCH 03/13] Fix typo in Yarn install command --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e6fe917..edb95e2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,7 +46,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - - run: yarn workspace focus + - run: yarn workspaces focus - run: npx prettier --check . - run: yarn run build - run: yarn run lint From 350b9a2051cac7ae2800058602cd3286c49547dd Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Mon, 13 Oct 2025 02:01:40 -0500 Subject: [PATCH 04/13] Apply latest Prettier formatting --- .github/README.md | 2 +- .github/workflows/tests.yml | 4 ++-- demo/index.html | 2 +- demo/src/utils/auto-expand-field.ts | 4 ++-- demo/src/worker/index.ts | 2 +- packages/regex-to-strings/src/pattern.spec.ts | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/README.md b/.github/README.md index 02ba92f..a7f62aa 120000 --- a/.github/README.md +++ b/.github/README.md @@ -1 +1 @@ -../packages/regex-to-strings/README.md \ No newline at end of file +../packages/regex-to-strings/README.md diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index edb95e2..ad5d893 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,8 +13,8 @@ on: workflow_dispatch: defaults: - run: - working-directory: ./packages/regex-to-strings + run: + working-directory: ./packages/regex-to-strings jobs: test: diff --git a/demo/index.html b/demo/index.html index 4ad8008..2799927 100644 --- a/demo/index.html +++ b/demo/index.html @@ -1,4 +1,4 @@ - + diff --git a/demo/src/utils/auto-expand-field.ts b/demo/src/utils/auto-expand-field.ts index 1c962db..a00e9ab 100644 --- a/demo/src/utils/auto-expand-field.ts +++ b/demo/src/utils/auto-expand-field.ts @@ -10,10 +10,10 @@ type anyFn = (...args: unknown[]) => void; function debounce(func: F, wait: number): F { let timeoutID: number; - return (function debounced(this: any, ...args: any[]) { + return function debounced(this: any, ...args: any[]) { clearTimeout(timeoutID); timeoutID = window.setTimeout(() => func.apply(this, args), wait); - } as any) as F; + } as any as F; } /* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/demo/src/worker/index.ts b/demo/src/worker/index.ts index f47028e..1e59234 100644 --- a/demo/src/worker/index.ts +++ b/demo/src/worker/index.ts @@ -31,7 +31,7 @@ function takeNIterations( } // eslint-disable-next-line no-restricted-globals -const ctx: Worker = (self as unknown) as Worker; +const ctx: Worker = self as unknown as Worker; function* processRequest( message: MessageEvent diff --git a/packages/regex-to-strings/src/pattern.spec.ts b/packages/regex-to-strings/src/pattern.spec.ts index 5b49bc5..4d53155 100644 --- a/packages/regex-to-strings/src/pattern.spec.ts +++ b/packages/regex-to-strings/src/pattern.spec.ts @@ -52,12 +52,12 @@ describe('count', () => { }); it('counts null as zero patterns', () => { - const result = count((null as unknown) as string); + const result = count(null as unknown as string); expect(result).toBe(0); }); it('counts undefined as one pattern', () => { - const result = count((undefined as unknown) as string); + const result = count(undefined as unknown as string); expect(result).toBe(1); }); @@ -122,11 +122,11 @@ describe('expand', () => { }); it('returns an empty list for null', () => { - const result = expandAll((null as unknown) as string); + const result = expandAll(null as unknown as string); expect(result).toEqual([]); // Mirror this JavaScript behavior - const nativeRegex = new RegExp((null as unknown) as string); + const nativeRegex = new RegExp(null as unknown as string); expect(nativeRegex.test('')).toBe(false); }); From e67d04e78290a5c91533f2dcf78c27c43cb43f43 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Mon, 13 Oct 2025 02:15:57 -0500 Subject: [PATCH 05/13] Run Prettier check from root so it will use its config files --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ad5d893..4e9c702 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,7 @@ jobs: - run: yarn workspaces focus - run: npx prettier --check . + working-directory: ./ - run: yarn run build - run: yarn run lint - run: yarn run test From 9fba0d41cd35613a0fe4a129fdff310370e6c0e9 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Mon, 13 Oct 2025 02:26:34 -0500 Subject: [PATCH 06/13] Exclude generated Yarn PnP files from Prettier check --- .prettierignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.prettierignore b/.prettierignore index 6c4a539..65fc0a5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,5 @@ +.pnp.cjs +.pnp.loader.mjs package-lock.json package.json From d53fd0aa526b2952eff24c287dc5688ce221e962 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Fri, 17 Oct 2025 00:16:48 -0500 Subject: [PATCH 07/13] Create per-project lint configurations This allows for linting a single focused workspace instead of all workspaces. Isolate project-specific ESLint configs in their respective config files. --- .eslintrc.json | 30 +++---------------- .github/workflows/tests.yml | 2 +- demo/.eslintrc.json | 16 ++++++++++ demo/package.json | 2 ++ tsconfig.lint.json => demo/tsconfig.lint.json | 2 +- package.json | 6 ++-- packages/regex-to-strings/.eslintrc.json | 24 +++++++++++++++ packages/regex-to-strings/package.json | 5 ++-- packages/regex-to-strings/tsconfig.lint.json | 7 +++++ 9 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 demo/.eslintrc.json rename tsconfig.lint.json => demo/tsconfig.lint.json (71%) create mode 100644 packages/regex-to-strings/.eslintrc.json create mode 100644 packages/regex-to-strings/tsconfig.lint.json diff --git a/.eslintrc.json b/.eslintrc.json index 9167687..9eaa05e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,8 @@ { + "root": true, "parser": "@typescript-eslint/parser", "extends": [ "airbnb-base", - "plugin:jest/recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "prettier" @@ -11,6 +11,7 @@ "ecmaVersion": 2018, "project": ["./**/tsconfig.json", "./**/tsconfig.test.json"] }, + "ignorePatterns": ["coverage/", "lib/"], "rules": { "import/extensions": [ "error", @@ -18,40 +19,17 @@ "ts": "never" } ], - "import/no-cycle": "off", - "import/no-extraneous-dependencies": [ - "error", - { - "devDependencies": ["**/*.spec.{js,ts}", "**/*.config.js"] - } - ], - "import/no-unresolved": [ - "error", - { - "ignore": [ - "history", - "lodash", - // Workaround for alexgorbatchev/eslint-import-resolver-typescript#17 - "regexp-tree/ast", - "RegexColorizer" - ] - } - ], "import/prefer-default-export": "off", - "no-else-return": "off", "no-plusplus": "off", - // This rule excludes too many escape sequences we need, like \p - "no-useless-escape": "off", // Allow ForOfStatement, preserve the rest of Airbnb's restrictions "no-restricted-syntax": [ "error", "ForInStatement", "LabeledStatement", "WithStatement" - ], - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "off" + ] }, + "reportUnusedDisableDirectives": true, "settings": { "import/parsers": { "@typescript-eslint/parser": [".ts"] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e9c702..b0c83d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,7 +50,7 @@ jobs: - run: npx prettier --check . working-directory: ./ - run: yarn run build - - run: yarn run lint + - run: yarn run -T lint - run: yarn run test - run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.test.json src/e2e.spec.ts diff --git a/demo/.eslintrc.json b/demo/.eslintrc.json new file mode 100644 index 0000000..b772426 --- /dev/null +++ b/demo/.eslintrc.json @@ -0,0 +1,16 @@ +{ + "rules": { + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": ["**/*.config.js"] + } + ], + "import/no-unresolved": [ + "error", + { + "ignore": ["history", "lodash", "RegexColorizer"] + } + ] + } +} diff --git a/demo/package.json b/demo/package.json index d309a9f..44872a7 100644 --- a/demo/package.json +++ b/demo/package.json @@ -4,10 +4,12 @@ "private": true, "scripts": { "build": "wp --config webpack.config.js", + "lint": "tsc -b ./tsconfig.lint.json && eslint .", "test": "exit 0" }, "devDependencies": { "@types/lodash": "^4.14.140", + "@types/node": "^24.8.1", "clean-webpack-plugin": "^4.0.0", "css-loader": "^7.1.1", "node-sass": "^9.0.0", diff --git a/tsconfig.lint.json b/demo/tsconfig.lint.json similarity index 71% rename from tsconfig.lint.json rename to demo/tsconfig.lint.json index 67c49bd..707e186 100644 --- a/tsconfig.lint.json +++ b/demo/tsconfig.lint.json @@ -2,6 +2,6 @@ "compilerOptions": { "noEmit": true }, - "extends": "./tsconfig.json", + "extends": "../tsconfig.json", "references": [{ "path": "./" }] } diff --git a/package.json b/package.json index 0a9f387..16724fe 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "build": "yarn workspaces run build", "format": "prettier --write .", - "lint": "tsc -b ./tsconfig.lint.json && eslint . --report-unused-disable-directives", + "lint": "yarn workspaces foreach --all run lint", "test": "yarn workspaces run test" }, "devDependencies": { @@ -19,7 +19,7 @@ "eslint-config-prettier": "^10.0.1", "eslint-import-resolver-typescript": "^4.3.1", "eslint-plugin-import": "^2.25.3", - "eslint-plugin-jest": "^27.0.4", - "prettier": "2.2.1" + "prettier": "2.2.1", + "typescript": "^4.2.3" } } diff --git a/packages/regex-to-strings/.eslintrc.json b/packages/regex-to-strings/.eslintrc.json new file mode 100644 index 0000000..bcbda6e --- /dev/null +++ b/packages/regex-to-strings/.eslintrc.json @@ -0,0 +1,24 @@ +{ + "extends": ["plugin:jest/recommended"], + "rules": { + "import/no-cycle": "off", + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": ["**/*.spec.{js,ts}", "**/*.config.js"] + } + ], + "import/no-unresolved": [ + "error", + { + "ignore": [ + // Workaround for alexgorbatchev/eslint-import-resolver-typescript#17 + "regexp-tree/ast" + ] + } + ], + "no-else-return": "off", + // This rule excludes too many escape sequences we need, like \p + "no-useless-escape": "off" + } +} diff --git a/packages/regex-to-strings/package.json b/packages/regex-to-strings/package.json index 7705a25..ae4dc2f 100644 --- a/packages/regex-to-strings/package.json +++ b/packages/regex-to-strings/package.json @@ -29,6 +29,7 @@ "scripts": { "build": "tsc -b --clean && tsc -b", "changelog": "npx auto-changelog", + "lint": "tsc -b ./tsconfig.lint.json && eslint .", "release": "npx release-it --no-increment", "test": "jest --coverage" }, @@ -37,11 +38,11 @@ "@types/jest-when": "^3.5.0", "jest": "^29.7.0", "jest-when": "^3.2.1", - "ts-jest": "^29.2.5", - "typescript": "^4.2.3" + "ts-jest": "^29.2.5" }, "dependencies": { "escape-string-regexp": "^4.0.0", + "eslint-plugin-jest": "^27.0.4", "pandemonium": "^2.0.0", "regexp-tree": "^0.1.23" }, diff --git a/packages/regex-to-strings/tsconfig.lint.json b/packages/regex-to-strings/tsconfig.lint.json new file mode 100644 index 0000000..2a71cf4 --- /dev/null +++ b/packages/regex-to-strings/tsconfig.lint.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "noEmit": true + }, + "extends": "../../tsconfig.json", + "references": [{ "path": "./" }] +} From 0dd32d59bc083f04fa6a9829d87391bc95f7dfba Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Fri, 17 Oct 2025 00:18:19 -0500 Subject: [PATCH 08/13] Update Yarn scripts to work on Yarn Modern Convert "format" into a global script that can be run from any project. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 16724fe..46c015d 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "demo" ], "scripts": { - "build": "yarn workspaces run build", - "format": "prettier --write .", + "build": "yarn workspaces foreach --all run build", + ":format": "prettier --write .", "lint": "yarn workspaces foreach --all run lint", - "test": "yarn workspaces run test" + "test": "yarn workspaces foreach --all run test" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.6.0", From 7c06fcd951a2fd43a4b54ff109afd0cc2a06fa03 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Fri, 17 Oct 2025 00:38:28 -0500 Subject: [PATCH 09/13] Update test workflow to run "build" script from root --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b0c83d3..1fe0256 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,7 +49,7 @@ jobs: - run: yarn workspaces focus - run: npx prettier --check . working-directory: ./ - - run: yarn run build + - run: yarn run -T build - run: yarn run -T lint - run: yarn run test From 10f2c6b6f83a41f68e778154b62eb2551754e99a Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Fri, 17 Oct 2025 00:46:14 -0500 Subject: [PATCH 10/13] Revert tests workflow to run scripts from root "yarn workspaces focus" may be unnecessary after upgrading to Yarn Modern. --- .github/workflows/tests.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1fe0256..9d05370 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,8 +3,6 @@ name: Tests on: push: branches: [main, develop] - paths-ignore: - - 'demo/**' pull_request: branches: [main, develop] schedule: @@ -12,10 +10,6 @@ on: - cron: '0 0 * * SAT' workflow_dispatch: -defaults: - run: - working-directory: ./packages/regex-to-strings - jobs: test: name: Test @@ -46,14 +40,15 @@ jobs: with: node-version: ${{ matrix.node-version }} - - run: yarn workspaces focus + - run: yarn - run: npx prettier --check . working-directory: ./ - - run: yarn run -T build - - run: yarn run -T lint + - run: yarn run build + - run: yarn run lint - run: yarn run test - run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.test.json src/e2e.spec.ts + working-directory: ./packages/regex-to-strings # Workaround for #66 continue-on-error: ${{ !matrix.require-successful-testpack }} From bf89b30951bc2195f3fea80a0a0eaf32f420d4cc Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Fri, 17 Oct 2025 00:48:36 -0500 Subject: [PATCH 11/13] Require testpack to succeed for all Node versions The workaround for #66 seems to be no longer necessary. --- .github/workflows/tests.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9d05370..a44dedd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,12 +19,9 @@ jobs: fail-fast: false matrix: node-version: [18.x] - require-successful-testpack: [true] include: - node-version: 20.x - require-successful-testpack: false - node-version: lts/* - require-successful-testpack: false steps: - name: Checkout repository @@ -49,8 +46,6 @@ jobs: - run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.test.json src/e2e.spec.ts working-directory: ./packages/regex-to-strings - # Workaround for #66 - continue-on-error: ${{ !matrix.require-successful-testpack }} - name: Upload test coverage report to Codecov uses: codecov/codecov-action@v5.4.0 From 1da5a18297f58cdee3fa304789e5ad9308fb651d Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Fri, 17 Oct 2025 01:00:12 -0500 Subject: [PATCH 12/13] Update tests workflow to allow Yarn install to create lockfile Fix error in GitHub Actions: The lockfile would have been created by this install, which is explicitly forbidden. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a44dedd..4fcfbfb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,7 +37,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - - run: yarn + - run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install - run: npx prettier --check . working-directory: ./ - run: yarn run build From a81d43b39d8370ef36b5854c393c347c28d30548 Mon Sep 17 00:00:00 2001 From: Drew Scheller Date: Sat, 18 Oct 2025 20:30:14 -0500 Subject: [PATCH 13/13] Add jest-util as an explicit dev dependency ts=jest has a peer dependency on jest-util, which is a dependency of jest. But evidently Yarn Modern requires a more explicit dependency on jest-util. --- packages/regex-to-strings/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/regex-to-strings/package.json b/packages/regex-to-strings/package.json index ae4dc2f..76cd967 100644 --- a/packages/regex-to-strings/package.json +++ b/packages/regex-to-strings/package.json @@ -37,6 +37,7 @@ "@types/jest": "^29.0.0", "@types/jest-when": "^3.5.0", "jest": "^29.7.0", + "jest-util": "^30.2.0", "jest-when": "^3.2.1", "ts-jest": "^29.2.5" },