babel-plugin-caralho
Advanced tools
Comparing version 0.0.0 to 0.1.0
@@ -1,8 +0,6 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var words = require('curse-words-common'); | ||
exports.default = function (_ref) { | ||
module.exports = function (_ref) { | ||
var t = _ref.types; | ||
@@ -14,11 +12,16 @@ | ||
words.map(function (word) { | ||
if (path.node.value.raw.includes('!' + word)) { | ||
path.node.value.raw = path.node.value.raw.replace('!' + word, '!important'); | ||
if (path.node.value.raw.includes("!" + word)) { | ||
path.node.value.raw = path.node.value.raw.replace("!" + word, "!important"); | ||
} | ||
}); | ||
}, | ||
StringLiteral: function StringLiteral(path) { | ||
words.map(function (word) { | ||
if (path.node.value.includes("!" + word)) { | ||
path.node.value = path.node.value.replace("!" + word, "!important"); | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
}; | ||
var words = require('curse-words-common'); | ||
}; |
{ | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "Babel plugin for writing curse words instead of important because reasons", | ||
@@ -4,0 +4,0 @@ "repository": "https://github.com/SaraVieira/babel-caralho", |
@@ -1,5 +0,3 @@ | ||
Read babel plugin handbook -> https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md | ||
THIS IS NOT WORKING AND IDK WHY | ||
Try http://astexplorer.net/#/Pcw9baefXI for a visual understanding. | ||
# babel-plugin-boilerplate | ||
@@ -6,0 +4,0 @@ |
const words = require('curse-words-common'); | ||
export default function({ types: t }) { | ||
module.exports = function({ types: t }) { | ||
return { | ||
visitor: { | ||
TemplateElement(path) { | ||
TemplateElement(path) { | ||
words.map(word => { | ||
if (path.node.value.raw.includes(`!${word}`)) { | ||
path.node.value.raw = path.node.value.raw.replace( | ||
`!${word}`, | ||
'!important' | ||
); | ||
path.node.value.raw = path.node.value.raw.replace(`!${word}`, "!important"); | ||
} | ||
}); | ||
}, | ||
StringLiteral(path) { | ||
words.map(word => { | ||
if (path.node.value.includes(`!${word}`)) { | ||
path.node.value = path.node.value.replace(`!${word}`, "!important"); | ||
} | ||
}); | ||
} | ||
@@ -16,0 +20,0 @@ } |
79370
43
63