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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -11,47 +11,25 @@
"ecmaVersion": 2018,
"project": ["./**/tsconfig.json", "./**/tsconfig.test.json"]
},
"ignorePatterns": ["coverage/", "lib/"],
"rules": {
"import/extensions": [
"error",
{
"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"]
Expand Down
2 changes: 1 addition & 1 deletion .github/README.md
11 changes: 5 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,33 @@ 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
uses: actions/checkout@v5
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
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.pnp.cjs
.pnp.loader.mjs
package-lock.json
package.json

Expand Down
16 changes: 16 additions & 0 deletions demo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": ["**/*.config.js"]
}
],
"import/no-unresolved": [
"error",
{
"ignore": ["history", "lodash", "RegexColorizer"]
}
]
}
}
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 2 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions demo/src/utils/auto-expand-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type anyFn = (...args: unknown[]) => void;
function debounce<F extends anyFn>(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 */

Expand Down
2 changes: 1 addition & 1 deletion demo/src/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.lint.json → demo/tsconfig.lint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"compilerOptions": {
"noEmit": true
},
"extends": "./tsconfig.json",
"extends": "../tsconfig.json",
"references": [{ "path": "./" }]
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
}
24 changes: 24 additions & 0 deletions packages/regex-to-strings/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
6 changes: 4 additions & 2 deletions packages/regex-to-strings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@
"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"
},
"devDependencies": {
"@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"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/regex-to-strings/src/pattern.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
7 changes: 7 additions & 0 deletions packages/regex-to-strings/tsconfig.lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"noEmit": true
},
"extends": "../../tsconfig.json",
"references": [{ "path": "./" }]
}