chore: Convert == to === and != to !== where possible. (#5599)

This commit is contained in:
Neil Fraser
2021-10-15 09:17:04 -07:00
committed by GitHub
parent 7ac1e27cd6
commit c929b3015b
183 changed files with 1409 additions and 1409 deletions

View File

@@ -30,7 +30,7 @@ goog.module('Blockly.utils.string');
* @alias Blockly.utils.string.startsWith
*/
const startsWith = function(str, prefix) {
return str.lastIndexOf(prefix, 0) == 0;
return str.lastIndexOf(prefix, 0) === 0;
};
exports.startsWith = startsWith;
@@ -63,7 +63,7 @@ exports.shortestStringLength = shortestStringLength;
const commonWordPrefix = function(array, opt_shortest) {
if (!array.length) {
return 0;
} else if (array.length == 1) {
} else if (array.length === 1) {
return array[0].length;
}
let wordPrefix = 0;
@@ -72,17 +72,17 @@ const commonWordPrefix = function(array, opt_shortest) {
for (len = 0; len < max; len++) {
const letter = array[0][len];
for (let i = 1; i < array.length; i++) {
if (letter != array[i][len]) {
if (letter !== array[i][len]) {
return wordPrefix;
}
}
if (letter == ' ') {
if (letter === ' ') {
wordPrefix = len + 1;
}
}
for (let i = 1; i < array.length; i++) {
const letter = array[i][len];
if (letter && letter != ' ') {
if (letter && letter !== ' ') {
return wordPrefix;
}
}
@@ -101,7 +101,7 @@ exports.commonWordPrefix = commonWordPrefix;
const commonWordSuffix = function(array, opt_shortest) {
if (!array.length) {
return 0;
} else if (array.length == 1) {
} else if (array.length === 1) {
return array[0].length;
}
let wordPrefix = 0;
@@ -110,17 +110,17 @@ const commonWordSuffix = function(array, opt_shortest) {
for (len = 0; len < max; len++) {
const letter = array[0].substr(-len - 1, 1);
for (let i = 1; i < array.length; i++) {
if (letter != array[i].substr(-len - 1, 1)) {
if (letter !== array[i].substr(-len - 1, 1)) {
return wordPrefix;
}
}
if (letter == ' ') {
if (letter === ' ') {
wordPrefix = len + 1;
}
}
for (let i = 1; i < array.length; i++) {
const letter = array[i].charAt(array[i].length - len - 1);
if (letter && letter != ' ') {
if (letter && letter !== ' ') {
return wordPrefix;
}
}
@@ -226,9 +226,9 @@ const wrapScore = function(words, wordBreaks, limit) {
score -= Math.pow(maxLength - lineLengths[i], 1.5);
// Optimize for structure.
// Add score to line endings after punctuation.
if ('.?!'.indexOf(linePunctuation[i]) != -1) {
if ('.?!'.indexOf(linePunctuation[i]) !== -1) {
score += limit / 3;
} else if (',;)]}'.indexOf(linePunctuation[i]) != -1) {
} else if (',;)]}'.indexOf(linePunctuation[i]) !== -1) {
score += limit / 4;
}
}
@@ -257,7 +257,7 @@ const wrapMutate = function(words, wordBreaks, limit) {
let bestBreaks;
// Try shifting every line break forward or backward.
for (let i = 0; i < wordBreaks.length - 1; i++) {
if (wordBreaks[i] == wordBreaks[i + 1]) {
if (wordBreaks[i] === wordBreaks[i + 1]) {
continue;
}
const mutatedWordBreaks = [].concat(wordBreaks);