Skip to content

Commit 3e36c2b

Browse files
authored
Merge branch '2Toad:master' into patch-1
2 parents 3b1f9f2 + 8e6b4ae commit 3e36c2b

14 files changed

Lines changed: 2808 additions & 4323 deletions

File tree

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"extends": ["airbnb-base", "airbnb-typescript/base", "plugin:security/recommended", "plugin:prettier/recommended"],
77
"plugins": ["security", "prettier"],
88
"parserOptions": {
9-
"ecmaVersion": 2018,
9+
"ecmaVersion": 2019,
1010
"project": "./tsconfig.json"
1111
},
1212
"rules": {

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/cdp.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This Continuous Deployment (CDP) workflow publishes a package to NPM when a release is created
2+
3+
name: CDP
4+
5+
on:
6+
release:
7+
types: [created]
8+
9+
jobs:
10+
continuous-deployment:
11+
name: Continuous Deployment
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
17+
- name: Get Node Version
18+
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
19+
20+
- name: Set up Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ env.NODE_VERSION }}
24+
registry-url: https://registry.npmjs.org/
25+
26+
- name: Install Dependencies
27+
run: npm ci
28+
29+
- name: Publish Package
30+
run: npm publish
31+
env:
32+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This Continuous Integration (CI) pipeline lints, builds, and tests the code when a Pull Request is
2+
# created or a commit is pushed to a Prod branch
3+
4+
name: CI
5+
on:
6+
push:
7+
branches: [ "master", "1.x.x" ]
8+
pull_request:
9+
branches: [ "master", "1.x.x" ]
10+
11+
jobs:
12+
continuous-integration:
13+
name: Continuous Integration
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Get Node Version
21+
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
22+
23+
- name: Set up Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ env.NODE_VERSION }}
27+
28+
- name: Install Dependencies
29+
run: npm ci
30+
31+
- name: Lint
32+
run: npm run lint
33+
34+
- name: Build
35+
run: npm run build
36+
37+
- name: Unit Tests
38+
run: npm test

.github/workflows/nodejs.yml

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

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
npx lint-staged

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tests/
66
.eslintcache
77
.eslintignore
88
.eslintrc.json
9+
.gitattributes
910
.gitignore
1011
.nvmrc
1112
.prettierignore

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.17.0
1+
20.17.0

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# Profanity
1+
# Profanity 🧼
22

3-
[![GitHub version](https://badge.fury.io/gh/2Toad%2FProfanity.svg)](https://github.com/2Toad/Profanity/releases)
3+
![GitHub Release](https://img.shields.io/github/v/release/2Toad/Profanity)
44
[![Downloads](https://img.shields.io/npm/dm/@2toad/profanity.svg)](https://www.npmjs.com/package/@2toad/profanity)
5-
[![Build status](https://github.com/2toad/profanity/actions/workflows/nodejs.yml/badge.svg)](https://github.com/2Toad/Profanity/actions/workflows/nodejs.yml)
5+
[![Build status](https://github.com/2toad/profanity/actions/workflows/ci.yml/badge.svg)](https://github.com/2Toad/Profanity/actions/workflows/nodejs.yml)
66

77
A JavaScript profanity filter (with TypeScript support)
88

9-
## Getting Started
9+
## Getting Started 🚀
1010

11-
Install package
11+
Install the package
1212

1313
```Shell
1414
npm i @2toad/profanity
1515
```
1616

17-
>if you're using Node 11.x or older you'll need to install [Profanity 1.x](https://github.com/2Toad/Profanity/releases) (e.g., `npm i @2toad/profanity@1.4.0`)
17+
>If you're using Node 11.x or older, you'll need to install [Profanity 1.x](https://github.com/2Toad/Profanity/releases) (e.g., `npm i @2toad/profanity@1.4.0`)
1818
19-
## Usage
19+
## Usage 📚
2020

2121
```JavaScript
2222
import { profanity } from '@2toad/profanity';
@@ -37,7 +37,7 @@ profanity.censor('I like big butts (aka arses) and I cannot lie', CensorType.Fir
3737
// I like big *utts (aka *rses) and I cannot lie
3838
```
3939

40-
## Options
40+
## Options ⚙️
4141
Create an instance of the Profanity class to change the default options:
4242

4343
```JavaScript
@@ -51,9 +51,9 @@ options.grawlixChar = '$';
5151
const profanity = new Profanity(options);
5252
```
5353

54-
### wholeWord
54+
### wholeWord 🔤
5555

56-
By default this is set to `true`, so profanity only matches on whole words:
56+
By default, this is set to `true` so profanity only matches on whole words:
5757
```JavaScript
5858
profanity.exists('Arsenic is poisonous but not profane');
5959
// false
@@ -65,7 +65,7 @@ profanity.exists('Arsenic is poisonous but not profane');
6565
// true (matched on arse)
6666
```
6767

68-
### grawlix
68+
### grawlix 💥
6969

7070
By default this is set to `@#$%&!`:
7171
```JavaScript
@@ -79,7 +79,7 @@ profanity.censor('I like big butts and I cannot lie');
7979
// I like big **** and I cannot lie
8080
```
8181

82-
### grawlixChar
82+
### grawlixChar 💲
8383

8484
When specifying a `CensorType` other than `CensorType.Word`, this is the character used by the `censor` function.
8585

@@ -96,7 +96,7 @@ profanity.censor('I like big butts and I cannot lie', CensorType.AllVowels);
9696
```
9797

9898

99-
## Customize the word list
99+
## Customize the word list 📝
100100

101101
Add words:
102102
```JavaScript
@@ -108,10 +108,10 @@ Remove words:
108108
profanity.removeWords(['butt', 'arse']);
109109
```
110110

111-
## Whitelist
111+
## Whitelist
112112
The whitelist allows you to specify words that are always ignored by the profanity filter.
113113

114-
>This can be useful if you want to turn partial word matching on (`wholeWord = false`), so combined words are caught (e.g., arselicker), while specific words you add to the whitelist are ignored (e.g., arsenic).
114+
>This can be useful if you want to enable partial word matching (`wholeWord = false`), so combined words are caught (e.g., arselicker), while specific words you add to the whitelist are ignored (e.g., arsenic).
115115
116116
Add words to the whitelist:
117117
```JavaScript
@@ -123,6 +123,6 @@ Remove words from the whitelist:
123123
profanity.whitelist.removeWords(['arsenic', 'buttress']);
124124
```
125125

126-
## Contributing
126+
## Contributing 🤝
127127

128-
So you want to contribute to the Profanikty project? Fantastic! Please read the [Contribute](https://github.com/2Toad/Profanity/blob/master/contribute.md) doc to get started.
128+
So you want to contribute to the Profanity project? Fantastic! Please read the [Contribute](./contribute.md) doc to get started.

contribute.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Contribute to the Profanity project
1+
# Contribute to the Profanity project 🤝
22

33
Thank you for wanting to contribute to the Profanity project. With your contributions we can ensure Profanity remains a leading solution for filtering profanity within JavaScript projects
44

5-
## Steps for success
5+
## Steps for success
66

77
1. [Issues](https://github.com/2Toad/Profanity/issues):
88
1. Always work off of an Issue. Please do not submit a Pull Request that is not associated with an Issue (create the Issue if necessary).
@@ -14,41 +14,40 @@ Thank you for wanting to contribute to the Profanity project. With your contribu
1414
1. Make sure you run the following scripts in local, and that all of them pass, before submitting a PR:
1515
1. `npm run lint`
1616
2. `npm run prettier`
17-
3. `npm test`
18-
4. `npm run build`
17+
3. `npm run build`
18+
4. `npm test`
1919
2. Make sure your PR is targeting the correct branch (see Step 2.ii)
2020
3. At the top of your PR description write: "Fixes #_n_". Where _n_ is the number of the Issue your PR is fixing (e.g., `Fixes #33`). This will tell GitHub to associate your PR with the Issue.
2121

22+
## Development 💻
2223

23-
## Development
24+
### Prerequisites 📝
2425

25-
### Prerequisites
26-
27-
- `master` branch: [Node 12+](https://nodejs.org)
26+
- `master` branch: [Node 20+](https://nodejs.org)
2827
- `1.x.x` branch: [Node 10.23.0](https://nodejs.org)
2928

30-
### Source Code
29+
### Source Code 🔠
3130

3231
1. Clone the repo
3332
2. Change directories: `cd Profanity`
3433
3. Install dependencies: `npm i`
3534

36-
### Development
35+
### Workflow 🔁
3736

3837
Start app in watch mode: `npm run local`
3938

40-
>When file changes are detected, the app will automatically rebuild/restart
39+
> When file changes are detected, the app will automatically rebuild/restart
4140
42-
#### Linting
41+
#### Linting 🧹
4342

4443
- Check lint rules: `npm run lint`
4544
- Fix lint errors: `npm run lint:fix`
4645
- Check formatting rules: `npm run prettier`
4746
- Fix formatting errors: `npm run prettier:fix`
4847

49-
## Appendix
48+
## Appendix 📚
5049

51-
### Dev Tools
50+
### Dev Tools 🛠️
5251

5352
The following section includes optional dev tools that enhance the Profanity development experience, but are not necessary.
5453

@@ -68,7 +67,38 @@ The Profanity project includes an .nvmrc file, so you can run `nvm use` to switc
6867

6968
The Profanity project includes Husky for running Git Hooks. Running `git commit` will trigger `lint-staged` which will lint all files currently staged in Git. If linting fails, the commit will be cancelled
7069

71-
##### Setup
72-
73-
1. Install husky: `npx husky install`
74-
2. Give Husky permission: `sudo chmod -R +x .husky`
70+
### Dependencies 📦
71+
72+
- `chai`: we must use v4.x because v5.x is pure ESM, and we require CommonJS modules
73+
74+
### Deployments 🚀
75+
76+
Deployments to Prod consist of building and publishing the Profanity lib to NPM, and are automated through our Continous Deployment workflow.
77+
78+
#### 1. Change Version
79+
1. Checkout `master`
80+
2. Increment version (semantic) in package.json (e.g., 1.1.0)
81+
3. Rebuild package-lock (to pick up new version ): `npm i --package-lock-only`
82+
4. Push changes:
83+
```
84+
git add .
85+
git commmit -m "Bump version to 1.1.0"
86+
git push
87+
```
88+
89+
#### 2. Verify Checks
90+
1. Navigate to the [CI](https://github.com/2Toad/Profanity/actions/workflows/ci.yml) workflow
91+
2. Ensure the run for the above "Bump version" commit succeeds
92+
93+
#### 3. Publish GitHub Release
94+
1. Navigate to [Profanity's releases](https://github.com/2Toad/Profanity/releases)
95+
2. Click "Draft a new release"
96+
- **Choose a tag**: enter version (e.g., `v1.1.0`) and click "Create new tag"
97+
- **Target**: `master`
98+
- **Previous tag**: `auto`
99+
- **Release title**: (e.g., `1.1.0`)
100+
- **Description**: click the "Genereate release notes"
101+
- [x] **Set as the latest release**
102+
3. Click "Publish release"
103+
104+
> This will trigger the [CDP](https://github.com/2Toad/Profanity/actions/workflows/cdp.yml) workflow, which will build and deploy the package to NPM: https://www.npmjs.com/package/@2toad/profanity

0 commit comments

Comments
 (0)