Skip to content

Commit

Permalink
more repo modernizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed May 21, 2019
1 parent 5a18c9d commit df3fd05
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
1 change: 0 additions & 1 deletion bullshit.js

This file was deleted.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "bullshit.js",
"scripts": {
"build": "rollup -c",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "eslint src"
},
"repository": {
"type": "git",
Expand All @@ -20,11 +20,19 @@
"url": "https://github.com/mourner/bullshit.js/issues"
},
"homepage": "https://github.com/mourner/bullshit.js#readme",
"eslintConfig": {
"extends": "mourner"
},
"devDependencies": {
"findandreplacedomtext": "^0.4.6",
"rollup": "^1.12.3",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-terser": "^4.0.4"
},
"dependencies": {
"eslint": "^5.16.0",
"eslint-config-mourner": "^3.0.0",
"rollup-plugin-buble": "^0.19.6"
}
}
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import buble from 'rollup-plugin-buble';
import {terser} from 'rollup-plugin-terser';

export default {
Expand All @@ -9,5 +10,5 @@ export default {
file: './bullshit.js',
indent: false
},
plugins: [resolve(), commonjs(), terser()]
plugins: [resolve(), commonjs(), terser(), buble()]
};
19 changes: 8 additions & 11 deletions src/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,28 @@ import bullshitTerms from './terms';

function revealBullshit(term) {

var c = term.charAt(0),
bullshit = (c === c.toUpperCase() ? 'B' : 'b') + 'ullshit',
last = term.length - 1;
const c = term.charAt(0);
const last = term.length - 1;
let bullshit = `(${c === c.toUpperCase() ? 'B' : 'b'}ullshit`;

if (term.substr(last - 2) === 'ing') {
bullshit += 'ting';
}
if (term.charAt(last - 1) !== 's' && term.charAt(last) === 's') {
} else if (term.charAt(last - 1) !== 's' && term.charAt(last) === 's') {
bullshit += 's';
}
if (term.charAt(last - 2) !== 'e' && term.substr(last - 1) === 'ed') {
} else if (term.charAt(last - 2) !== 'e' && term.substr(last - 1) === 'ed') {
bullshit += 'ted';
}
if (term.charAt(last - 2) !== ('o' || 'e') && term.substr(last - 1) === ('or' || 'er')) {
} else if (term.charAt(last - 2) !== ('o' || 'e') && term.substr(last - 1) === ('or' || 'er')) {
bullshit += 'ter';
}

var abbr = document.createElement("abbr");
const abbr = document.createElement('abbr');
abbr.style.color = 'red';
abbr.title = term;
abbr.innerHTML = bullshit;

return abbr;
}

var bullshitRe = new RegExp('(' + bullshitTerms.join('|') + ')(?!\\w|[^<]*>)', 'gi');
const bullshitRe = new RegExp(`(${bullshitTerms.join('|')})(?!\\w|[^<]*>)`, 'gi');

findAndReplaceDOMText(bullshitRe, document.body, revealBullshit);

0 comments on commit df3fd05

Please sign in to comment.