You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A JavaScript profanity filter (with TypeScript support)
8
8
9
-
## Getting Started
9
+
## Getting Started 🚀
10
10
11
-
Install package
11
+
Install the package
12
12
13
13
```Shell
14
14
npm i @2toad/profanity
15
15
```
16
16
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`)
18
18
19
-
## Usage
19
+
## Usage 📚
20
20
21
21
```JavaScript
22
22
import { profanity } from'@2toad/profanity';
@@ -37,7 +37,7 @@ profanity.censor('I like big butts (aka arses) and I cannot lie', CensorType.Fir
37
37
// I like big *utts (aka *rses) and I cannot lie
38
38
```
39
39
40
-
## Options
40
+
## Options ⚙️
41
41
Create an instance of the Profanity class to change the default options:
42
42
43
43
```JavaScript
@@ -51,9 +51,9 @@ options.grawlixChar = '$';
51
51
constprofanity=newProfanity(options);
52
52
```
53
53
54
-
### wholeWord
54
+
### wholeWord 🔤
55
55
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:
57
57
```JavaScript
58
58
profanity.exists('Arsenic is poisonous but not profane');
59
59
// false
@@ -65,7 +65,7 @@ profanity.exists('Arsenic is poisonous but not profane');
65
65
// true (matched on arse)
66
66
```
67
67
68
-
### grawlix
68
+
### grawlix 💥
69
69
70
70
By default this is set to `@#$%&!`:
71
71
```JavaScript
@@ -79,7 +79,7 @@ profanity.censor('I like big butts and I cannot lie');
79
79
// I like big **** and I cannot lie
80
80
```
81
81
82
-
### grawlixChar
82
+
### grawlixChar 💲
83
83
84
84
When specifying a `CensorType` other than `CensorType.Word`, this is the character used by the `censor` function.
85
85
@@ -96,7 +96,7 @@ profanity.censor('I like big butts and I cannot lie', CensorType.AllVowels);
96
96
```
97
97
98
98
99
-
## Customize the word list
99
+
## Customize the word list 📝
100
100
101
101
Add words:
102
102
```JavaScript
@@ -108,10 +108,10 @@ Remove words:
108
108
profanity.removeWords(['butt', 'arse']);
109
109
```
110
110
111
-
## Whitelist
111
+
## Whitelist ✅
112
112
The whitelist allows you to specify words that are always ignored by the profanity filter.
113
113
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).
115
115
116
116
Add words to the whitelist:
117
117
```JavaScript
@@ -123,6 +123,6 @@ Remove words from the whitelist:
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.
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
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
14
14
1. Make sure you run the following scripts in local, and that all of them pass, before submitting a PR:
15
15
1.`npm run lint`
16
16
2.`npm run prettier`
17
-
3.`npm test`
18
-
4.`npm run build`
17
+
3.`npm run build`
18
+
4.`npm test`
19
19
2. Make sure your PR is targeting the correct branch (see Step 2.ii)
20
20
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.
>When file changes are detected, the app will automatically rebuild/restart
39
+
>When file changes are detected, the app will automatically rebuild/restart
41
40
42
-
#### Linting
41
+
#### Linting 🧹
43
42
44
43
- Check lint rules: `npm run lint`
45
44
- Fix lint errors: `npm run lint:fix`
46
45
- Check formatting rules: `npm run prettier`
47
46
- Fix formatting errors: `npm run prettier:fix`
48
47
49
-
## Appendix
48
+
## Appendix 📚
50
49
51
-
### Dev Tools
50
+
### Dev Tools 🛠️
52
51
53
52
The following section includes optional dev tools that enhance the Profanity development experience, but are not necessary.
54
53
@@ -68,7 +67,38 @@ The Profanity project includes an .nvmrc file, so you can run `nvm use` to switc
68
67
69
68
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
70
69
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