Comparing version 1.3.0 to 1.3.1
@@ -5,5 +5,5 @@ // https://eslint.org/docs/user-guide/configuring | ||
root: true, | ||
parser: 'babel-eslint', | ||
parser: "babel-eslint", | ||
parserOptions: { | ||
sourceType: 'module' | ||
sourceType: "module", | ||
}, | ||
@@ -14,14 +14,12 @@ env: { | ||
// https://github.com/standard/standard/blob/master/docs/RULES-en.md | ||
extends: 'standard', | ||
extends: "standard", | ||
// required to lint *.vue files | ||
plugins: [ | ||
'html' | ||
], | ||
plugins: ["html"], | ||
// add your custom rules here | ||
rules: { | ||
// allow async-await | ||
'generator-star-spacing': 'off', | ||
"generator-star-spacing": "off", | ||
// allow debugger during development | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' | ||
} | ||
} | ||
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", | ||
}, | ||
}; |
12
index.js
@@ -9,5 +9,5 @@ /** | ||
'use strict'; | ||
"use strict"; | ||
const swearList = require('./swearList'); | ||
const swearList = require("./swearList"); | ||
@@ -26,3 +26,3 @@ module.exports = { | ||
filterSync: (words) => { | ||
var lines = swearListSync() | ||
var lines = swearListSync(); | ||
var finalString = words; | ||
@@ -47,3 +47,3 @@ for (var i = 0; i < lines.length; i++) { | ||
return hasSwearWords(words, lines); | ||
} | ||
}, | ||
}; | ||
@@ -65,4 +65,4 @@ | ||
for (let i = 0; i < lines.length; i++) { | ||
let badWord = new RegExp(lines[i], 'gi'); | ||
finalString = finalString.replace(badWord, '*'.repeat(lines[i].length)); | ||
let badWord = new RegExp(lines[i], "gi"); | ||
finalString = finalString.replace(badWord, "*".repeat(lines[i].length)); | ||
} | ||
@@ -69,0 +69,0 @@ |
{ | ||
"name": "no-swears", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Filter swearwords out of your strings automagically", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,5 +0,4 @@ | ||
no-swears | ||
=== | ||
# no-swears | ||
Automagically filter out swear words in strings | ||
Automagically filter out swear words in strings | ||
@@ -9,3 +8,3 @@ [![npm version](https://badge.fury.io/js/no-swears.svg)](https://badge.fury.io/js/no-swears) | ||
Very simple package for censoring swear words from JavaScript strings, | ||
replacing offending words with "\*\*\*\*". | ||
replacing offending words with "\*\*\*\*". | ||
@@ -19,5 +18,5 @@ ## Usage | ||
```javascript | ||
'use strict' | ||
"use strict"; | ||
const noswears = require('no-swears') | ||
const noswears = require("no-swears"); | ||
``` | ||
@@ -27,11 +26,11 @@ | ||
This is the most basic filtering function, and requires the offending | ||
This is the most basic filtering function, and requires the offending | ||
string and a callback, returning the cleaned up string to the program. | ||
```javascript | ||
let badString = "this is a bitching string" | ||
let badString = "this is a bitching string"; | ||
noswears.filterSwearWords(badString, goodString => { | ||
console.log(goodString) // "this is a ****ing string" | ||
}) | ||
noswears.filterSwearWords(badString, (goodString) => { | ||
console.log(goodString); // "this is a ****ing string" | ||
}); | ||
``` | ||
@@ -45,7 +44,7 @@ | ||
```javascript | ||
let badString = "this is a bitching string" | ||
let badString = "this is a bitching string"; | ||
noswears.hasSwears(badString, swearBool => { | ||
console.log(swearBool) // true | ||
}) | ||
noswears.hasSwears(badString, (swearBool) => { | ||
console.log(swearBool); // true | ||
}); | ||
``` | ||
@@ -58,7 +57,7 @@ | ||
```javascript | ||
let badString = "this is a bitching string" | ||
let badString = "this is a bitching string"; | ||
if (noswears.hasSwearsSync(badString)) { | ||
console.log("Has swears!") // "Has swears"! | ||
console.log("Has swears!"); // "Has swears"! | ||
} | ||
``` | ||
``` |
@@ -1,8 +0,8 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const swearWordResource = path.join(__dirname, 'swearwords.txt'); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const swearWordResource = path.join(__dirname, "swearwords.txt"); | ||
module.exports = { | ||
getList: (callback) => { | ||
fs.readFile(swearWordResource, 'utf8', (err, wordList) => { | ||
fs.readFile(swearWordResource, "utf8", (err, wordList) => { | ||
if (err) { | ||
@@ -16,10 +16,10 @@ throw err; | ||
getListSync: () => { | ||
let wordList = fs.readFileSync(swearWordResource, 'utf8'); | ||
let wordList = fs.readFileSync(swearWordResource, "utf8"); | ||
return formatSwearWordList(wordList); | ||
} | ||
}, | ||
}; | ||
let formatSwearWordList = (list) => { | ||
return list.replace(new RegExp('\r', 'g'), '').split('\n'); | ||
return list.replace(new RegExp("\r", "g"), "").split("\n"); | ||
}; |
36
test.js
@@ -1,27 +0,23 @@ | ||
'use strict'; | ||
"use strict"; | ||
const noswears = require('./index'); | ||
const noswears = require("./index"); | ||
const expected = "**** brain**** is a weird *****"; | ||
noswears.filterSwearWords(badString, goodString => { | ||
let expected = '**** brain**** is a weird *****'; | ||
noswears.filterSwearWords(badString, (goodString) => { | ||
let expected = "**** brain**** is a weird *****"; | ||
console.log( | ||
`Testing filterSwearWords | ||
Want string "${expected}", got "${goodString}"` | ||
Want string "${expected}", got "${goodString}"`, | ||
); | ||
if (goodString === expected) { | ||
console.log('✔ Success!'); | ||
console.log("✔ Success!"); | ||
} else { | ||
console.log('✖ Failed!'); | ||
console.log("✖ Failed!"); | ||
} | ||
}); | ||
var filterSyncResult = noswears.filterSync(badString) | ||
console.log( | ||
'Testing filter\nWant string "' + expected + '", got', | ||
expected | ||
); | ||
var filterSyncResult = noswears.filterSync(badString); | ||
console.log('Testing filter\nWant string "' + expected + '", got', expected); | ||
if (filterSyncResult === expected) { | ||
@@ -33,12 +29,12 @@ console.log("✔ Success!\n"); | ||
noswears.hasSwears(badString, swearBool => { | ||
noswears.hasSwears(badString, (swearBool) => { | ||
console.log( | ||
`Testing hasSwears | ||
Want true, got ${swearBool}` | ||
Want true, got ${swearBool}`, | ||
); | ||
if (swearBool === true) { | ||
console.log('✔ Success!'); | ||
console.log("✔ Success!"); | ||
} else { | ||
console.log('✖ Failed!'); | ||
console.log("✖ Failed!"); | ||
} | ||
@@ -51,9 +47,9 @@ }); | ||
`Testing hasSwearsSync | ||
Want true, got ${hasSwearsSyncResult}` | ||
Want true, got ${hasSwearsSyncResult}`, | ||
); | ||
if (hasSwearsSyncResult) { | ||
console.log('✔ Success!'); | ||
console.log("✔ Success!"); | ||
} else { | ||
console.log('✖ Failed!'); | ||
console.log("✖ Failed!"); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
7378
9
142