Skip to content

Commit fe34a96

Browse files
Merge branch 'release/1.2.0' into main
2 parents 798931e + 2385478 commit fe34a96

20 files changed

+199
-115
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["@babel/env", "@babel/preset-typescript"]
2+
"presets": ["@babel/env", "@babel/preset-typescript"],
3+
"ignore": ["**/*.spec.js", "**/*.spec.ts"]
34
}

.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]
1317
indent_style = space
1418
indent_size = 2

.eslintrc.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
34
"extends": [
45
"airbnb-base",
56
"plugin:jest/recommended",
6-
"plugin:@typescript-eslint/eslint-recommended",
77
"plugin:@typescript-eslint/recommended",
88
"prettier",
99
"prettier/@typescript-eslint"
@@ -12,6 +12,7 @@
1212
"ecmaVersion": 2018
1313
},
1414
"rules": {
15+
"@typescript-eslint/no-shadow": "error",
1516
"import/extensions": [
1617
"error",
1718
{
@@ -24,7 +25,8 @@
2425
"devDependencies": ["**/*.spec.{js,ts}"]
2526
}
2627
],
27-
"import/prefer-default-export": "off"
28+
"import/prefer-default-export": "off",
29+
"no-shadow": "off"
2830
},
2931
"settings": {
3032
"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+
# 13:44 on Saturdays
10+
- cron: '44 13 * * 6'
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={ts-jest,typescript} 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![npm package](https://badge.fury.io/js/strings-to-regex.svg)](https://badge.fury.io/js/strings-to-regex)
44
![node version](https://img.shields.io/node/v/strings-to-regex.svg)
55
![npm type definitions](https://img.shields.io/npm/types/strings-to-regex)
6-
[![Build Status](https://travis-ci.org/wimpyprogrammer/strings-to-regex.svg?branch=master)](https://travis-ci.org/wimpyprogrammer/strings-to-regex)
7-
[![codecov](https://codecov.io/gh/wimpyprogrammer/strings-to-regex/branch/master/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/strings-to-regex)
6+
![Tests status](https://github.com/wimpyprogrammer/strings-to-regex/workflows/Tests/badge.svg)
7+
[![codecov](https://codecov.io/gh/wimpyprogrammer/strings-to-regex/branch/main/graph/badge.svg)](https://codecov.io/gh/wimpyprogrammer/strings-to-regex)
88
[![Known Vulnerabilities](https://snyk.io/test/github/wimpyprogrammer/strings-to-regex/badge.svg)](https://snyk.io/test/github/wimpyprogrammer/strings-to-regex)
99

1010
Generate a compact Regular Expression that matches a finite set.

demo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/>
4343
<link rel="stylesheet" href="styles.css" />
4444

45-
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=Array.from,Map,Set&flags=gated"></script>
45+
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=Array.from,Event,Map,Set,URL&flags=gated"></script>
4646
</head>
4747

4848
<body>
@@ -169,7 +169,7 @@
169169
<footer>
170170
<p class="float-left">
171171
&copy;
172-
<a href="http://www.wimpyprogrammer.com/">WimpyProgrammer.com</a> 2018
172+
<a href="http://www.wimpyprogrammer.com/">WimpyProgrammer.com</a> 2019
173173
</p>
174174
<p class="float-right">
175175
<a href="https://github.com/wimpyprogrammer/strings-to-regex"

demo/src/demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { condense, condenseIgnoreCase } from '../../src/index';
1+
import { condense, condenseIgnoreCase } from '../../src';
22
import { autoExpandTextarea } from './utils/auto-expand-field';
33
import { parseString, WhitespaceHandling } from './utils/wordList';
44

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["field"] }] */
22

3-
/* eslint-disable @typescript-eslint/no-explicit-any */
3+
type anyFn = (...args: unknown[]) => void;
4+
45
/**
56
* @see https://gist.github.com/fr-ser/ded7690b245223094cd876069456ed6c
67
*/
7-
function debounce<F extends Function>(func: F, wait: number): F {
8+
function debounce<F extends anyFn>(func: F, wait: number): F {
89
let timeoutID: number;
910

10-
return (function debounced(this: any, ...args: any[]) {
11+
return (function debounced(this: unknown, ...args: unknown[]) {
1112
clearTimeout(timeoutID);
1213

1314
timeoutID = window.setTimeout(() => func.apply(this, args), wait);
14-
} as any) as F;
15+
} as unknown) as F;
1516
}
16-
/* eslint-enable @typescript-eslint/no-explicit-any */
1717

1818
/**
1919
* Grow or shrink a <textarea> field's height to fit its contents.

demo/src/utils/wordList.spec.ts

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,48 @@
11
import { parseString, WhitespaceHandling } from './wordList';
22

3-
interface TestCase {
4-
delimiter: string;
5-
inputString: string;
6-
}
7-
83
const { Preserve, TrimLeadingAndTrailing } = WhitespaceHandling;
94

105
describe('parseString', () => {
11-
it('returns an empty array when input string is empty', () => {
12-
function testInput(input: string): void {
13-
const wordList = parseString(input, ',', Preserve);
6+
it.each(['', null, undefined])(
7+
'returns an empty array when input string is %p',
8+
input => {
9+
const wordList = parseString(input as string, ',', Preserve);
1410
expect(wordList).toEqual([]);
1511
}
12+
);
1613

17-
['', null, undefined].forEach(val => testInput(val as string));
18-
});
19-
20-
it('returns entire input string in array when delimiter is empty', () => {
21-
function testDelimiter(delimiter: string): void {
14+
it.each(['', null, undefined])(
15+
'returns entire input string in array when delimiter is %p',
16+
testDelimiter => {
17+
const delimiter = testDelimiter as string;
2218
const wordList = parseString(' some input string ', delimiter, Preserve);
2319
expect(wordList).toEqual([' some input string ']);
2420
}
21+
);
2522

26-
['', null, undefined].forEach(val => testDelimiter(val as string));
27-
});
28-
29-
it('returns entire input string in array when delimiter is not present in input string', () => {
30-
function testDelimiter(delimiter: string): void {
23+
it.each([',', '\n', '\t'])(
24+
'returns entire input string in array when delimiter %p is not present in input string',
25+
delimiter => {
3126
const wordList = parseString(' some input string ', delimiter, Preserve);
3227
expect(wordList).toEqual([' some input string ']);
3328
}
34-
35-
[',', '\n', '\t'].forEach(testDelimiter);
36-
});
37-
38-
it('splits input string by delimiter', () => {
39-
const expectedResult = ['foo', 'Bar', ' b@z '];
40-
const testCases: TestCase[] = [
41-
{ delimiter: ',', inputString: 'foo,Bar, b@z ' },
42-
{ delimiter: '\t', inputString: 'foo Bar b@z ' },
43-
{ delimiter: 'aaa', inputString: 'fooaaaBaraaa b@z ' },
44-
];
45-
46-
function testSplit({ delimiter, inputString }: TestCase): void {
47-
const wordList = parseString(inputString, delimiter, Preserve);
48-
expect(wordList).toEqual(expectedResult);
49-
}
50-
51-
testCases.forEach(testSplit);
29+
);
30+
31+
it.each([
32+
['foo,Bar, b@z ', ','],
33+
['foo Bar b@z ', '\t'],
34+
['fooaaaBaraaa b@z ', 'aaa'],
35+
])('splits input string %p by delimiter %p', (inputString, delimiter) => {
36+
const wordList = parseString(inputString, delimiter, Preserve);
37+
expect(wordList).toEqual(['foo', 'Bar', ' b@z ']);
5238
});
5339

54-
it('splits input string by whitespace delimiter', () => {
55-
const expectedResult = ['foo', 'Bar', 'b@z', ''];
56-
const testCases: TestCase[] = [
57-
{ delimiter: ' ', inputString: 'foo Bar b@z ' },
58-
{ delimiter: ' ', inputString: 'foo Bar b@z ' },
59-
];
60-
61-
function testSplit({ delimiter, inputString }: TestCase): void {
62-
const wordList = parseString(inputString, delimiter, Preserve);
63-
expect(wordList).toEqual(expectedResult);
64-
}
65-
66-
testCases.forEach(testSplit);
40+
it.each([
41+
['foo Bar b@z ', ' '],
42+
['foo Bar b@z ', ' '],
43+
])('splits input string %p by delimiter %p', (inputString, delimiter) => {
44+
const wordList = parseString(inputString, delimiter, Preserve);
45+
expect(wordList).toEqual(['foo', 'Bar', 'b@z', '']);
6746
});
6847

6948
it('splits multiline input string by newline delimiter', () => {

demo/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ select:invalid {
4747
transition: border-color 0.6s ease-out;
4848
}
4949

50+
footer:after {
51+
content: '';
52+
clear: both;
53+
display: table;
54+
}
55+
5056
@media (min-width: 576px) {
5157
label + select {
5258
margin-left: 0.5em;

demo/webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
loader: 'ts-loader',
1515
options: {
1616
compilerOptions: {
17-
checkJs: false, // workaround for TypeStrong/ts-loader#702
1817
noEmit: false,
1918
},
2019
configFile: resolve(__dirname, './tsconfig.json'),

0 commit comments

Comments
 (0)