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/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 5c497fe..6f68b72 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
@@ -32,21 +29,23 @@ jobs:
with:
fetch-depth: '2'
+ - name: Enable Corepack
+ run: corepack enable
+
- name: Test on Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
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
- 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 }}
- name: Upload test coverage report to Codecov
uses: codecov/codecov-action@v5.5.0
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/.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
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/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/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/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/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 e246c09..46c015d 100644
--- a/package.json
+++ b/package.json
@@ -1,14 +1,15 @@
{
"private": true,
+ "packageManager": "yarn@4.10.3",
"workspaces": [
"packages/*",
"demo"
],
"scripts": {
- "build": "yarn workspaces run build",
- "format": "prettier --write .",
- "lint": "tsc -b ./tsconfig.lint.json && eslint . --report-unused-disable-directives",
- "test": "yarn workspaces run test"
+ "build": "yarn workspaces foreach --all run build",
+ ":format": "prettier --write .",
+ "lint": "yarn workspaces foreach --all run lint",
+ "test": "yarn workspaces foreach --all run test"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.6.0",
@@ -18,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 a4c9396..50552a5 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"
},
@@ -36,12 +37,13 @@
"@types/jest": "^30.0.0",
"@types/jest-when": "^3.5.0",
"jest": "^30.0.0",
+ "jest-util": "^30.2.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/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);
});
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": "./" }]
+}