Skip to content

Commit

Permalink
Changing console.assert to node assert (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielboliveira authored and michalsnik committed Jun 20, 2017
1 parent 547e824 commit b71c7a3
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
const HTML_ELEMENT_NAMES = new Set(require('./html-elements.json'))
const SVG_ELEMENT_NAMES = new Set(require('./svg-elements.json'))
const VOID_ELEMENT_NAMES = new Set(require('./void-elements.json'))
const assert = require('assert')

// ------------------------------------------------------------------------------
// Exports
Expand Down Expand Up @@ -63,7 +64,7 @@ module.exports = {
* @returns {boolean} `true` if the node is the root element.
*/
isRootElement (node) {
console.assert(node && node.type === 'VElement')
assert(node && node.type === 'VElement')

return (
node.parent.type === 'Program' ||
Expand All @@ -77,7 +78,7 @@ module.exports = {
* @returns {ASTNode|null} The previous sibling element.
*/
prevSibling (node) {
console.assert(node && node.type === 'VElement')
assert(node && node.type === 'VElement')
let prevElement = null

for (const siblingNode of (node.parent && node.parent.children) || []) {
Expand All @@ -100,7 +101,7 @@ module.exports = {
* @returns {boolean} `true` if the start tag has the directive.
*/
hasAttribute (node, name, value) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.some(a =>
!a.directive &&
a.key.name === name &&
Expand All @@ -119,7 +120,7 @@ module.exports = {
* @returns {boolean} `true` if the start tag has the directive.
*/
hasDirective (node, name, argument) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.some(a =>
a.directive &&
a.key.name === name &&
Expand All @@ -133,7 +134,7 @@ module.exports = {
* @returns {boolean} `true` if the attribute has their value.
*/
hasAttributeValue (node) {
console.assert(node && node.type === 'VAttribute')
assert(node && node.type === 'VAttribute')
return (
node.value != null &&
(node.value.expression != null || node.value.syntaxError != null)
Expand All @@ -148,7 +149,7 @@ module.exports = {
* @returns {ASTNode} The found attribute.
*/
getAttribute (node, name, value) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.find(a =>
!a.directive &&
a.key.name === name &&
Expand All @@ -167,7 +168,7 @@ module.exports = {
* @returns {ASTNode} The found directive.
*/
getDirective (node, name, argument) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')
return node.attributes.find(a =>
a.directive &&
a.key.name === name &&
Expand All @@ -181,7 +182,7 @@ module.exports = {
* @returns {boolean} `true` if the previous sibling element has `if` or `else-if` directive.
*/
prevElementHasIf (node) {
console.assert(node && node.type === 'VElement')
assert(node && node.type === 'VElement')

const prev = this.prevSibling(node)
return (
Expand All @@ -199,7 +200,7 @@ module.exports = {
* @returns {boolean} `true` if the node is a custom component.
*/
isCustomComponent (node) {
console.assert(node && node.type === 'VStartTag')
assert(node && node.type === 'VStartTag')

const name = node.id.name
return (
Expand All @@ -215,7 +216,7 @@ module.exports = {
* @returns {boolean} `true` if the name is a HTML element name.
*/
isHtmlElementName (name) {
console.assert(typeof name === 'string')
assert(typeof name === 'string')

return HTML_ELEMENT_NAMES.has(name.toLowerCase())
},
Expand All @@ -226,7 +227,7 @@ module.exports = {
* @returns {boolean} `true` if the name is a SVG element name.
*/
isSvgElementName (name) {
console.assert(typeof name === 'string')
assert(typeof name === 'string')

return SVG_ELEMENT_NAMES.has(name.toLowerCase())
},
Expand All @@ -237,7 +238,7 @@ module.exports = {
* @returns {boolean} `true` if the name is a void element name.
*/
isVoidElementName (name) {
console.assert(typeof name === 'string')
assert(typeof name === 'string')

return VOID_ELEMENT_NAMES.has(name.toLowerCase())
}
Expand Down

0 comments on commit b71c7a3

Please sign in to comment.