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
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- run: npm run lint
- run: npm run build
- run: npm run test
- run: npx testpack-cli --keep={@babel/*,ts-jest,typescript} .babelrc tsconfig*.json src/e2e.spec.ts
- run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.json src/e2e.spec.ts src/tsconfig.test.json

- name: Upload test coverage report to Codecov
uses: codecov/codecov-action@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package-lock.json
*.tsbuildinfo

coverage/
demo/lib/
Expand Down
15 changes: 0 additions & 15 deletions .publishrc

This file was deleted.

13 changes: 13 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"hooks": {
"before:init": ["npm run lint", "npm test"],
"after:bump": "npm run build"
},
"git": {
"changelog": false,
"commit": false,
"requireBranch": "main",
"requireCommits": true,
"tagName": "${version}"
}
}
6 changes: 4 additions & 2 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
"es2015.core",
"es2015.iterable",
"es2016.array.include"
]
],
"noEmit": true,
"outDir": "./lib"
},
"extends": "../tsconfig.json",
"include": ["src"],
"include": ["src", "webpack.config.js"],
"references": [{ "path": "../src" }]
}
22 changes: 9 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"type": "git",
"url": "git+https://github.com/wimpyprogrammer/regex-to-strings.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"bugs": {
"url": "https://github.com/wimpyprogrammer/regex-to-strings/issues"
},
Expand All @@ -15,7 +18,9 @@
"main": "lib/index.js",
"types": "./lib/index.d.ts",
"files": [
"lib/"
"lib/**/*.js",
"lib/**/*.js.map",
"lib/**/*.d.ts"
],
"sideEffects": [
"demo/**/polyfills.ts",
Expand All @@ -26,24 +31,15 @@
},
"scripts": {
"build": "run-s build:*",
"build:src": "babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' --delete-dir-on-start",
"build:src": "tsc -b --clean && tsc -b",
"build:demo": "wp --config demo/webpack.config.js",
"build:types": "tsc --noEmit false --emitDeclarationOnly",
"format": "prettier --write '{src,demo/src}/**'",
"lint": "tsc -b && eslint . --report-unused-disable-directives",
"lint": "tsc -b ./tsconfig.lint.json && eslint . --report-unused-disable-directives",
"precommit": "pretty-quick --staged",
"prepublish": "npx publish-please guard",
"publish-please": "npx publish-please",
"publish-please-prereqs": "npm run lint && npm run test && npm run build",
"release": "npx release-it",
"test": "jest --coverage"
},
"devDependencies": {
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.10",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/preset-env": "^7.13.10",
"@babel/preset-typescript": "^7.13.0",
"@types/escape-string-regexp": "^2.0.1",
"@types/history": "^4.7.3",
"@types/jest": "^26.0.10",
"@types/jest-when": "^2.4.1",
Expand Down
28 changes: 28 additions & 0 deletions src/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { count, expand, expandAll, expandN } from '.';

describe('count end-to-end', () => {
it('includes typings', () => {
expect(() => {
// @ts-expect-error Accepts string | RegExp
count(123);
}).toThrow();
});

it('returns a count of potential strings that match pattern', () => {
const numStrings = count(/[a-z]{5}/i);

Expand All @@ -11,6 +18,13 @@ describe('count end-to-end', () => {
describe('expand end-to-end', () => {
const phoneNumberPattern = /((\(555\) ?)|(555-))?\d{3}-\d{4}/;

it('includes typings', () => {
expect(() => {
// @ts-expect-error Accepts string | RegExp
expand(123);
}).toThrow();
});

it('returns a count of potential strings that match pattern', () => {
const phoneNumberExpander = expand(phoneNumberPattern);

Expand All @@ -29,6 +43,13 @@ describe('expand end-to-end', () => {
});

describe('expandAll end-to-end', () => {
it('includes typings', () => {
expect(() => {
// @ts-expect-error Accepts string | RegExp
expandAll(123);
}).toThrow();
});

it('returns all strings that match pattern', () => {
const strings = expandAll(/\d/);

Expand All @@ -40,6 +61,13 @@ describe('expandAll end-to-end', () => {
});

describe('expandN end-to-end', () => {
it('includes typings', () => {
expect(() => {
// @ts-expect-error Accepts string | RegExp
expandN(123, 10);
}).toThrow();
});

it('returns no more than N strings that match pattern', () => {
const pattern = /\d{3,5}/;
const strings = expandN(pattern, 5);
Expand Down
4 changes: 3 additions & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"compilerOptions": {
"lib": ["es5", "es2015.core", "es2015.iterable", "es2016.array.include"]
"lib": ["es5", "es2015.core", "es2015.iterable", "es2016.array.include"],
"outDir": "../lib",
"rootDir": "./"
},
"extends": "../tsconfig.json",
"exclude": ["../**/*.spec.ts", "../**/*.config.js"],
Expand Down
4 changes: 3 additions & 1 deletion src/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"es2016.array.include",
"es2017.string"
],
"noEmit": true,
"outDir": "../lib",
"types": ["jest", "regexp-tree", "./types/regexp-tree"]
},
"extends": "../tsconfig.json",
"include": ["./**/*.spec.ts", "../**/*.config.js"],
"include": ["./**/*.spec.ts", "../jest.config.js"],
"references": [{ "path": "./" }]
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"baseUrl": ".",
"checkJs": true,
"composite": true,
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"module": "es2015",
"module": "CommonJS",
"downlevelIteration": true,
"moduleResolution": "node",
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "../lib",
"pretty": true,
"rootDir": ".",
"skipLibCheck": true,
Expand Down
7 changes: 7 additions & 0 deletions 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": "./" }]
}