Skip to content

Commit

Permalink
Use regex.test() when we want only to check for a boolean (#4507)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored and hudochenkov committed Jan 2, 2020
1 parent 8872b76 commit 31dd8d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/rules/keyframes-name-pattern/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const rule = function(pattern) {
root.walkAtRules(/keyframes/i, (keyframesNode) => {
const value = keyframesNode.params;

if (value.match(regex)) {
if (regex.test(value)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/selector-list-comma-newline-after/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const rule = function(expectation, options, context) {

// If there's a // comment, that means there has to be a newline
// ending the comment so we're fine
if (nextChars.match(/^\s+\/\//)) {
if (/^\s+\/\//.test(nextChars)) {
return;
}

// If there are spaces and then a comment begins, look for the newline
const indextoCheckAfter = nextChars.match(/^\s+\/\*/)
const indextoCheckAfter = /^\s+\/\*/.test(nextChars)
? selector.indexOf('*/', match.endIndex) + 1
: match.startIndex;

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/value-list-comma-newline-after/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ const rule = function(expectation, options, context) {

// If there's a // comment, that means there has to be a newline
// ending the comment so we're fine
if (nextChars.match(/^[ \t]*\/\//)) {
if (/^[ \t]*\/\//.test(nextChars)) {
return false;
}

// If there are spaces and then a comment begins, look for the newline
return nextChars.match(/^[ \t]*\/\*/)
return /^[ \t]*\/\*/.test(nextChars)
? declString.indexOf('*/', match.endIndex) + 1
: match.startIndex;
},
Expand Down

0 comments on commit 31dd8d4

Please sign in to comment.