Skip to content

Commit 2b43a4e

Browse files
authored
Merge pull request #36 from zanerock/work-liquid-labs/regex-repo/35
Test use of RE strings for partial string matches and update docs
2 parents a45298f + 9dc2a2e commit 2b43a4e

22 files changed

+4531
-1922
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,31 @@ npm i @liquid-labs/regex-repo
1212
## Usage
1313

1414
```javascript
15-
import { emailRE } from '@liquid-labs/regex-repo'
16-
// import * as regex from '@liquid-labs/regex-repo'
15+
import { emailRE } from '@liquid-labs/regex-repo' // ES6
16+
// const { emailRE } = require('@liquid-labs/regex-repo') // cjs
1717

1818
const verified = emailRE.test(userInput)
1919
```
2020

2121
## Regex reference
2222

23-
Each regular expression listed below is paired with an exported embeddable string named `xxxString`. E.g., `rgbRE` is paired with `rgbREString`. While the RE is pinned to the beginning and end of the value; i.e, the RE begins with '^' and ends with '$', the string does not. It is up to the user to identify token seperators when using the RE strings. E.g., if using `rgbREString` in a larger RE, one might do something like:
23+
Each regular expression listed below is paired with an embeddable string named `xxxString`. E.g., `rgbRE` is paired with `rgbREString`. Each RE will only match strings that are the given type and nothing else. I.e., the RE begins with '^' and ends with '$'. The `xxxREString` can be used for partial matches, `matchAll`s, and used as part of larger expressions. E.g., to find all unique CSS RGB colors used in a style sheet, you might do something like:
2424

2525
```javascript
2626
import { rgbREString } from '@liquid-labs/regex-repo'
2727

2828
const allColors = cssContent
29-
.matchAll(new RegExp(`[ :](${rgbREString})`)).map((match) => match[1])
29+
.matchAll(new RegExp(`[ :](${rgbREString})[; }]`, 'g'))
30+
.map((match) => match[1]) // extract the capture group
3031
.filter((v, i, arr) => i === arr.indexOf(v)) // filter non-unique items
3132
.sort()
3233
```
34+
35+
### AWS
36+
37+
- __awsS3BucketNameRE__: Matches valid S3 bucket name. Note `awsS3BucketNameREString` cannot be used for partial matches.
38+
- __awsS3TABucketNameRE__: Matches S3 Transfer Acceleration compatible S3 bucket name. Note `awsS3TABucketNameREString` cannot be used for partial matches.
39+
3340
### CSS numbers
3441

3542
- __zeroTo100FloatPercentRE__: Matches a 0 to 100% float as used in CSS color specifications.

make/10-resources.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# https://npmjs.com/package/@liquid-labs/catalyst-builder-node for further details
33

44
CATALYST_BABEL:=npx babel
5-
CATALYST_BABEL_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-babel-and-rollup -- pwd)/dist/babel/babel.config.cjs
5+
CATALYST_BABEL_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-babel-and-rollup -- pwd)/dist/babel/babel.config.cjs
66

77
CATALYST_ROLLUP:=npx rollup
8-
CATALYST_ROLLUP_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-babel-and-rollup -- pwd)/dist/rollup/rollup.config.mjs
8+
CATALYST_ROLLUP_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-babel-and-rollup -- pwd)/dist/rollup/rollup.config.mjs
99

1010
CATALYST_JEST:=npx jest
11-
CATALYST_JEST_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-jest -- pwd)/dist/jest.config.js
11+
CATALYST_JEST_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-jest -- pwd)/dist/jest.config.js
1212

1313
CATALYST_ESLINT:=npx eslint
14-
CATALYST_ESLINT_CONFIG:=$(shell npm explore @liquid-labs/catalyst-resource-eslint -- pwd)/dist/eslint.config.js
14+
CATALYST_ESLINT_CONFIG:=$(shell npm explore @liquid-labs/sdlc-resource-eslint -- pwd)/dist/eslint.config.cjs

make/55-lint.mk

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,21 @@ CATALYST_LINT_PASS_MARKER:=$(QA)/.lint.passed
1010
LINT_TARGETS+=$(CATALYST_LINT_REPORT) $(CATALYST_LINT_PASS_MARKER)
1111
PRECIOUS_TARGETS+=$(CATALYST_LINT_REPORT)
1212

13-
LINT_IGNORE_PATTERNS:=--ignore-pattern '$(DIST)/**/*'\
14-
--ignore-pattern '$(TEST_STAGING)/**/*'
15-
1613
$(CATALYST_LINT_REPORT) $(CATALYST_LINT_PASS_MARKER): $(CATALYST_ALL_JS_FILES_SRC)
1714
mkdir -p $(dir $@)
1815
echo -n 'Test git rev: ' > $(CATALYST_LINT_REPORT)
1916
git rev-parse HEAD >> $(CATALYST_LINT_REPORT)
2017
( set -e; set -o pipefail; \
21-
$(CATALYST_ESLINT) \
18+
ESLINT_USE_FLAT_CONFIG=true $(CATALYST_ESLINT) \
2219
--config $(CATALYST_ESLINT_CONFIG) \
23-
--ext .cjs,.js,.mjs,.cjs,.xjs \
24-
$(LINT_IGNORE_PATTERNS) \
2520
. \
2621
| tee -a $(CATALYST_LINT_REPORT); \
2722
touch $(CATALYST_LINT_PASS_MARKER) )
2823

2924
lint-fix:
3025
@( set -e; set -o pipefail; \
31-
$(CATALYST_ESLINT) \
26+
ESLINT_USE_FLAT_CONFIG=true $(CATALYST_ESLINT) \
3227
--config $(CATALYST_ESLINT_CONFIG) \
33-
--ext .js,.mjs,.cjs,.xjs \
34-
$(LINT_IGNORE_PATTERNS) \
3528
--fix . )
3629

3730
#####

0 commit comments

Comments
 (0)