Skip to content

Commit 94b699a

Browse files
Merge branch 'release/2.0.2' into main
2 parents 13d3c94 + 97ddc54 commit 94b699a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+319
-434
lines changed

src/.babelrc renamed to .babelrc

File renamed without changes.

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ end_of_line = lf
99
insert_final_newline = true
1010
indent_style = tab
1111

12+
[*.yml]
13+
indent_style = space
14+
indent_size = 2
15+
1216
[{package.json,package-lock.json}]
1317
indent_style = space
1418
indent_size = 2

.eslintrc.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"plugin:jest/recommended",
66
"plugin:@typescript-eslint/eslint-recommended",
77
"plugin:@typescript-eslint/recommended",
8-
"prettier",
9-
"prettier/@typescript-eslint"
8+
"prettier"
109
],
1110
"parserOptions": {
12-
"ecmaVersion": 2018
11+
"ecmaVersion": 2018,
12+
"project": ["./**/tsconfig.json", "./**/tsconfig.test.json"]
1313
},
1414
"rules": {
1515
"import/extensions": [
@@ -22,7 +22,7 @@
2222
"import/no-extraneous-dependencies": [
2323
"error",
2424
{
25-
"devDependencies": ["**/*.spec.{js,ts}", "**/jest.config.js"]
25+
"devDependencies": ["**/*.spec.{js,ts}", "**/*.config.js"]
2626
}
2727
],
2828
"import/no-unresolved": [
@@ -49,7 +49,8 @@
4949
"LabeledStatement",
5050
"WithStatement"
5151
],
52-
"@typescript-eslint/explicit-function-return-type": "off"
52+
"@typescript-eslint/explicit-function-return-type": "off",
53+
"@typescript-eslint/explicit-module-boundary-types": "off"
5354
},
5455
"settings": {
5556
"import/parsers": {

.github/workflows/security-scan.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Security Scan
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
schedule:
9+
# 10:17 on Fridays
10+
- cron: '17 10 * * 5'
11+
workflow_dispatch:
12+
13+
jobs:
14+
analyze:
15+
name: Analyze
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
language: ['javascript']
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v1
29+
with:
30+
languages: ${{ matrix.language }}
31+
32+
- name: Autobuild
33+
uses: github/codeql-action/autobuild@v1
34+
35+
- name: Perform CodeQL Analysis
36+
uses: github/codeql-action/analyze@v1

.github/workflows/tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
schedule:
9+
# 00:00 on Saturdays
10+
- cron: '0 0 * * SAT'
11+
workflow_dispatch:
12+
13+
jobs:
14+
test:
15+
name: Test
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
node-version: [10.x, 14.x]
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
with:
27+
fetch-depth: '2'
28+
29+
- name: Test on Node ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- run: npm install
35+
- run: npm run lint
36+
- run: npm run build
37+
- run: npm run test
38+
- run: npx testpack-cli --keep={@babel/*,ts-jest,typescript} .babelrc tsconfig*.json src/e2e.spec.ts
39+
40+
- name: Upload test coverage report to Codecov
41+
uses: codecov/codecov-action@v1
42+
with:
43+
fail_ci_if_error: true
44+
45+
- name: Run Snyk to check for vulnerabilities
46+
uses: snyk/actions/node@master
47+
env:
48+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

.publishrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"uncommittedChanges": true,
55
"untrackedFiles": true,
66
"sensitiveData": true,
7-
"branch": "master",
7+
"branch": "main",
88
"gitTag": true
99
},
1010
"confirm": true,

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![npm package](https://badge.fury.io/js/regex-to-strings.svg)](https://badge.fury.io/js/regex-to-strings)
44
![node version](https://img.shields.io/node/v/regex-to-strings.svg)
55
![npm type definitions](https://img.shields.io/npm/types/regex-to-strings)
6-
[![Build Status](https://travis-ci.org/wimpyprogrammer/regex-to-strings.svg?branch=master)](https://travis-ci.org/wimpyprogrammer/regex-to-strings)
7-
[![codecov](https://codecov.io/gh/wimpyprogrammer/regex-to-strings/branch/master/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/regex-to-strings)
6+
![Tests](https://github.com/wimpyprogrammer/regex-to-strings/workflows/Tests/badge.svg)
7+
[![codecov](https://codecov.io/gh/wimpyprogrammer/regex-to-strings/branch/main/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/regex-to-strings)
88
[![Known Vulnerabilities](https://snyk.io/test/github/wimpyprogrammer/regex-to-strings/badge.svg)](https://snyk.io/test/github/wimpyprogrammer/regex-to-strings)
99

1010
Generate strings that match a Regular Expression pattern. Efficiently generate all possible matches, or only the quantity you need.
@@ -108,7 +108,7 @@ console.log(strings); // ['6', '5', '0', '2', '7', '9', '4', '3', '1', '8']
108108

109109
`regex-to-strings` uses [`regexp-tree`](https://www.npmjs.com/package/regexp-tree) to parse your Regular Expression, and so the Regular Expression syntax you can use is largely determined by that library. If your pattern is not recognized by `regex-to-strings`, [try parsing it with `regexp-tree`](https://astexplorer.net/#/gist/4ea2b52f0e546af6fb14f9b2f5671c1c/39b55944da3e5782396ffa1fea3ba68d126cd394) to see if the syntax is supported.
110110

111-
`regex-to-strings` also includes [extensive positive **and** negative tests](https://github.com/wimpyprogrammer/regex-to-strings/blob/master/src/pattern.spec.ts) that track which Regular Expression features are supported.
111+
`regex-to-strings` also includes [extensive positive **and** negative tests](https://github.com/wimpyprogrammer/regex-to-strings/blob/main/src/pattern.spec.ts) that track which Regular Expression features are supported.
112112

113113
### Regular Expressions with unbounded repetition
114114

demo/src/components/demo-form.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export default class DemoForm {
2727
protected $errorContainer: HTMLDivElement;
2828
protected $errorMessage: HTMLPreElement;
2929

30+
// eslint-disable-next-line @typescript-eslint/no-empty-function
3031
public onSubmit: () => void = () => {};
32+
// eslint-disable-next-line @typescript-eslint/no-empty-function
3133
public onCancel: () => void = () => {};
3234

3335
private onInputKeydown(event: KeyboardEvent): boolean {

demo/src/components/demo-output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export default class DemoOutput {
3232

3333
if (isBlockOutput) {
3434
this.$expansions.innerHTML = expansions
35-
.map(string => `<div class="alert alert-light">${escape(string)}</div>`)
35+
.map((value) => `<div class="alert alert-light">${escape(value)}</div>`)
3636
.join('\n');
3737
} else {
3838
this.$expansions.innerHTML = expansions
39-
.map(string => `<span>${escape(string)}</span>`)
39+
.map((value) => `<span>${escape(value)}</span>`)
4040
.join(delimiter);
4141
}
4242

demo/src/demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
isCountResult,
1212
isExpandResult,
1313
} from './worker/messages';
14-
// @ts-ignore Ignore lack of default export. This is handled by worker-loader.
14+
// @ts-expect-error Ignore lack of default export. This is handled by worker-loader.
1515
import DemoWorker from './worker';
1616

1717
import './demo.scss';
@@ -97,7 +97,7 @@ $form.onCancel = () => {
9797
hideWaitingState();
9898
};
9999

100-
UrlStorage.onChange(newData => {
100+
UrlStorage.onChange((newData) => {
101101
$form.populate(newData);
102102
if (!$form.validate()) return;
103103

demo/src/utils/auto-expand-field.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["field"] }] */
22
import './auto-expand-field.scss';
33

4+
type anyFn = (...args: unknown[]) => void;
5+
46
/* eslint-disable @typescript-eslint/no-explicit-any */
57
/**
68
* @see https://gist.github.com/fr-ser/ded7690b245223094cd876069456ed6c
79
*/
8-
function debounce<F extends Function>(func: F, wait: number): F {
10+
function debounce<F extends anyFn>(func: F, wait: number): F {
911
let timeoutID: number;
1012

1113
return (function debounced(this: any, ...args: any[]) {
1214
clearTimeout(timeoutID);
13-
const context = this;
14-
15-
timeoutID = window.setTimeout(() => func.apply(context, args), wait);
15+
timeoutID = window.setTimeout(() => func.apply(this, args), wait);
1616
} as any) as F;
1717
}
1818
/* eslint-enable @typescript-eslint/no-explicit-any */

demo/src/utils/dom.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export function getElement<T extends Element>(selector: string) {
2-
return document.querySelector(selector) as T;
1+
export function getElement<T extends Element>(selector: string): T {
2+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3+
return document.querySelector(selector)!;
34
}

demo/src/utils/url-storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function write(data: FormInput) {
5656
* @param fn The function to run and receive the new data
5757
*/
5858
export function onChange(fn: (newData: StoredInput) => void) {
59-
return history.listen(location => {
59+
return history.listen((location) => {
6060
const newData = parse(location);
6161
fn(newData);
6262
});

demo/src/worker/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
isExpandRequest,
1010
OptimizeResult,
1111
} from './messages';
12-
import { expand, toRegExp } from '../../../src/index';
12+
import { expand, toRegExp } from '../../../src';
1313

1414
function assertNeverRequest(x: never): never {
1515
throw new TypeError(`Unexpected message: ${x}`);

demo/src/worker/messages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* eslint-disable no-empty-function, no-useless-constructor, @typescript-eslint/no-parameter-properties */
2-
import { expand } from '../../../src/index';
1+
/* eslint-disable max-classes-per-file, no-useless-constructor */
2+
import { expand } from '../../../src';
33

44
interface WorkerMessage {
55
readonly kind: string;

demo/src/worker/polyfills.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const featuresToPolyfill = [
1313
'es.symbol.iterator',
1414
].join(',');
1515

16-
// @ts-ignore worker-specific function that is unrecognized
16+
// @ts-expect-error worker-specific function that is unrecognized
1717
importScripts(
1818
`https://polyfill.app/api/polyfill?features=${featuresToPolyfill}&context=worker`
1919
);

demo/tsconfig.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"es5",
66
"es2015.core",
77
"es2015.iterable",
8-
"es2016.array.include",
9-
"es2017.string"
8+
"es2016.array.include"
109
]
1110
},
12-
"extends": "../tsconfig.release.json",
13-
"include": ["../src", "./src"]
11+
"extends": "../tsconfig.json",
12+
"include": ["src"],
13+
"references": [{ "path": "../src" }]
1414
}

demo/webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// eslint-disable-next-line @typescript-eslint/no-var-requires
1+
/// <reference types="node" />;
2+
/* eslint-disable @typescript-eslint/no-var-requires */
23
const { resolve } = require('path');
4+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
35

46
module.exports = {
57
entry: './demo/src/demo.ts',
@@ -9,6 +11,7 @@ module.exports = {
911
lodash: '_',
1012
RegexColorizer: 'RegexColorizer',
1113
},
14+
plugins: [new CleanWebpackPlugin()],
1215
module: {
1316
rules: [
1417
{
@@ -29,6 +32,7 @@ module.exports = {
2932
options: {
3033
compilerOptions: { noEmit: false },
3134
configFile: resolve(__dirname, './tsconfig.json'),
35+
projectReferences: true,
3236
},
3337
},
3438
],

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
],
77
globals: {
88
'ts-jest': {
9-
tsConfig: 'tsconfig.test.json',
9+
tsconfig: 'src/tsconfig.test.json',
1010
},
1111
},
1212
preset: 'ts-jest',

0 commit comments

Comments
 (0)