Skip to content

Commit b71c7a3

Browse files
gabrielboliveiramichalsnik
authored andcommitted
Changing console.assert to node assert (#40)
1 parent 547e824 commit b71c7a3

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Diff for: lib/utils/index.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
const HTML_ELEMENT_NAMES = new Set(require('./html-elements.json'))
1313
const SVG_ELEMENT_NAMES = new Set(require('./svg-elements.json'))
1414
const VOID_ELEMENT_NAMES = new Set(require('./void-elements.json'))
15+
const assert = require('assert')
1516

1617
// ------------------------------------------------------------------------------
1718
// Exports
@@ -63,7 +64,7 @@ module.exports = {
6364
* @returns {boolean} `true` if the node is the root element.
6465
*/
6566
isRootElement (node) {
66-
console.assert(node && node.type === 'VElement')
67+
assert(node && node.type === 'VElement')
6768

6869
return (
6970
node.parent.type === 'Program' ||
@@ -77,7 +78,7 @@ module.exports = {
7778
* @returns {ASTNode|null} The previous sibling element.
7879
*/
7980
prevSibling (node) {
80-
console.assert(node && node.type === 'VElement')
81+
assert(node && node.type === 'VElement')
8182
let prevElement = null
8283

8384
for (const siblingNode of (node.parent && node.parent.children) || []) {
@@ -100,7 +101,7 @@ module.exports = {
100101
* @returns {boolean} `true` if the start tag has the directive.
101102
*/
102103
hasAttribute (node, name, value) {
103-
console.assert(node && node.type === 'VStartTag')
104+
assert(node && node.type === 'VStartTag')
104105
return node.attributes.some(a =>
105106
!a.directive &&
106107
a.key.name === name &&
@@ -119,7 +120,7 @@ module.exports = {
119120
* @returns {boolean} `true` if the start tag has the directive.
120121
*/
121122
hasDirective (node, name, argument) {
122-
console.assert(node && node.type === 'VStartTag')
123+
assert(node && node.type === 'VStartTag')
123124
return node.attributes.some(a =>
124125
a.directive &&
125126
a.key.name === name &&
@@ -133,7 +134,7 @@ module.exports = {
133134
* @returns {boolean} `true` if the attribute has their value.
134135
*/
135136
hasAttributeValue (node) {
136-
console.assert(node && node.type === 'VAttribute')
137+
assert(node && node.type === 'VAttribute')
137138
return (
138139
node.value != null &&
139140
(node.value.expression != null || node.value.syntaxError != null)
@@ -148,7 +149,7 @@ module.exports = {
148149
* @returns {ASTNode} The found attribute.
149150
*/
150151
getAttribute (node, name, value) {
151-
console.assert(node && node.type === 'VStartTag')
152+
assert(node && node.type === 'VStartTag')
152153
return node.attributes.find(a =>
153154
!a.directive &&
154155
a.key.name === name &&
@@ -167,7 +168,7 @@ module.exports = {
167168
* @returns {ASTNode} The found directive.
168169
*/
169170
getDirective (node, name, argument) {
170-
console.assert(node && node.type === 'VStartTag')
171+
assert(node && node.type === 'VStartTag')
171172
return node.attributes.find(a =>
172173
a.directive &&
173174
a.key.name === name &&
@@ -181,7 +182,7 @@ module.exports = {
181182
* @returns {boolean} `true` if the previous sibling element has `if` or `else-if` directive.
182183
*/
183184
prevElementHasIf (node) {
184-
console.assert(node && node.type === 'VElement')
185+
assert(node && node.type === 'VElement')
185186

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

204205
const name = node.id.name
205206
return (
@@ -215,7 +216,7 @@ module.exports = {
215216
* @returns {boolean} `true` if the name is a HTML element name.
216217
*/
217218
isHtmlElementName (name) {
218-
console.assert(typeof name === 'string')
219+
assert(typeof name === 'string')
219220

220221
return HTML_ELEMENT_NAMES.has(name.toLowerCase())
221222
},
@@ -226,7 +227,7 @@ module.exports = {
226227
* @returns {boolean} `true` if the name is a SVG element name.
227228
*/
228229
isSvgElementName (name) {
229-
console.assert(typeof name === 'string')
230+
assert(typeof name === 'string')
230231

231232
return SVG_ELEMENT_NAMES.has(name.toLowerCase())
232233
},
@@ -237,7 +238,7 @@ module.exports = {
237238
* @returns {boolean} `true` if the name is a void element name.
238239
*/
239240
isVoidElementName (name) {
240-
console.assert(typeof name === 'string')
241+
assert(typeof name === 'string')
241242

242243
return VOID_ELEMENT_NAMES.has(name.toLowerCase())
243244
}

0 commit comments

Comments
 (0)