Merge pull request #8174 from Snuffleupagus/eslint-yoda-follow-up

Adjust the `yoda` ESLint rule to apply to inequalities as well
This commit is contained in:
Tim van der Meij 2017-03-19 23:49:47 +01:00 committed by GitHub
commit 3ff872b796
6 changed files with 31 additions and 29 deletions

View File

@ -73,7 +73,9 @@
"no-useless-call": "error", "no-useless-call": "error",
"no-useless-concat": "error", "no-useless-concat": "error",
"wrap-iife": ["error", "any"], "wrap-iife": ["error", "any"],
"yoda": ["error", "never", { "onlyEquality": true, }], "yoda": ["error", "never", {
"exceptRange": true,
}],
// Strict Mode // Strict Mode
"strict": ["error", "global"], "strict": ["error", "global"],

View File

@ -41,7 +41,7 @@ function onAnimationStart(event) {
// invocations have no effect. // invocations have no effect.
function watchObjectOrEmbed(elem) { function watchObjectOrEmbed(elem) {
var mimeType = elem.type; var mimeType = elem.type;
if (mimeType && 'application/pdf' !== mimeType.toLowerCase()) { if (mimeType && mimeType.toLowerCase() !== 'application/pdf') {
return; return;
} }
// <embed src> <object data> // <embed src> <object data>

View File

@ -1614,7 +1614,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var type = xobj.dict.get('Subtype'); var type = xobj.dict.get('Subtype');
assert(isName(type), 'XObject should have a Name subtype'); assert(isName(type), 'XObject should have a Name subtype');
if ('Form' !== type.name) { if (type.name !== 'Form') {
xobjsCache.key = name; xobjsCache.key = name;
xobjsCache.texts = null; xobjsCache.texts = null;
break; break;

View File

@ -106,7 +106,7 @@ var JpxImage = (function JpxImageClosure() {
this.parseCodestream(data, position, position + dataLength); this.parseCodestream(data, position, position + dataLength);
break; break;
case 0x6A502020: // 'jP\024\024' case 0x6A502020: // 'jP\024\024'
if (0x0d0a870a !== readUint32(data, position)) { if (readUint32(data, position) !== 0x0d0a870a) {
warn('Invalid JP2 signature'); warn('Invalid JP2 signature');
} }
break; break;

View File

@ -349,7 +349,7 @@ Shadings.Mesh = (function MeshClosure() {
var coord = reader.readCoordinate(); var coord = reader.readCoordinate();
var color = reader.readComponents(); var color = reader.readComponents();
if (verticesLeft === 0) { // ignoring flags if we started a triangle if (verticesLeft === 0) { // ignoring flags if we started a triangle
assert(0 <= f && f <= 2, 'Unknown type4 flag'); assert((0 <= f && f <= 2), 'Unknown type4 flag');
switch (f) { switch (f) {
case 0: case 0:
verticesLeft = 3; verticesLeft = 3;
@ -513,7 +513,7 @@ Shadings.Mesh = (function MeshClosure() {
var cs = new Int32Array(4); // c00, c30, c03, c33 var cs = new Int32Array(4); // c00, c30, c03, c33
while (reader.hasData) { while (reader.hasData) {
var f = reader.readFlag(); var f = reader.readFlag();
assert(0 <= f && f <= 3, 'Unknown type6 flag'); assert((0 <= f && f <= 3), 'Unknown type6 flag');
var i, ii; var i, ii;
var pi = coords.length; var pi = coords.length;
for (i = 0, ii = (f !== 0 ? 8 : 12); i < ii; i++) { for (i = 0, ii = (f !== 0 ? 8 : 12); i < ii; i++) {
@ -623,7 +623,7 @@ Shadings.Mesh = (function MeshClosure() {
var cs = new Int32Array(4); // c00, c30, c03, c33 var cs = new Int32Array(4); // c00, c30, c03, c33
while (reader.hasData) { while (reader.hasData) {
var f = reader.readFlag(); var f = reader.readFlag();
assert(0 <= f && f <= 3, 'Unknown type7 flag'); assert((0 <= f && f <= 3), 'Unknown type7 flag');
var i, ii; var i, ii;
var pi = coords.length; var pi = coords.length;
for (i = 0, ii = (f !== 0 ? 12 : 16); i < ii; i++) { for (i = 0, ii = (f !== 0 ? 12 : 16); i < ii; i++) {

View File

@ -1267,7 +1267,7 @@ PDFJS.compatibilityChecked = true;
cursor = 0; cursor = 0;
state = 'no scheme'; state = 'no scheme';
continue; continue;
} else if (EOF === c) { } else if (c === EOF) {
break loop; break loop;
} else { } else {
err('Code point not allowed in scheme: ' + c); err('Code point not allowed in scheme: ' + c);
@ -1284,7 +1284,7 @@ PDFJS.compatibilityChecked = true;
state = 'fragment'; state = 'fragment';
} else { } else {
// XXX error handling // XXX error handling
if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) { if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
this._schemeData += percentEscape(c); this._schemeData += percentEscape(c);
} }
} }
@ -1312,10 +1312,10 @@ PDFJS.compatibilityChecked = true;
case 'relative': case 'relative':
this._isRelative = true; this._isRelative = true;
if ('file' !== this._scheme) { if (this._scheme !== 'file') {
this._scheme = base._scheme; this._scheme = base._scheme;
} }
if (EOF === c) { if (c === EOF) {
this._host = base._host; this._host = base._host;
this._port = base._port; this._port = base._port;
this._path = base._path.slice(); this._path = base._path.slice();
@ -1348,10 +1348,10 @@ PDFJS.compatibilityChecked = true;
} else { } else {
var nextC = input[cursor + 1]; var nextC = input[cursor + 1];
var nextNextC = input[cursor + 2]; var nextNextC = input[cursor + 2];
if ('file' !== this._scheme || !ALPHA.test(c) || if (this._scheme !== 'file' || !ALPHA.test(c) ||
(nextC !== ':' && nextC !== '|') || (nextC !== ':' && nextC !== '|') ||
(EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && (nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' &&
'?' !== nextNextC && '#' !== nextNextC)) { nextNextC !== '?' && nextNextC !== '#')) {
this._host = base._host; this._host = base._host;
this._port = base._port; this._port = base._port;
this._username = base._username; this._username = base._username;
@ -1375,7 +1375,7 @@ PDFJS.compatibilityChecked = true;
state = 'authority ignore slashes'; state = 'authority ignore slashes';
} }
} else { } else {
if ('file' !== this._scheme) { if (this._scheme !== 'file') {
this._host = base._host; this._host = base._host;
this._port = base._port; this._port = base._port;
this._username = base._username; this._username = base._username;
@ -1398,14 +1398,14 @@ PDFJS.compatibilityChecked = true;
case 'authority second slash': case 'authority second slash':
state = 'authority ignore slashes'; state = 'authority ignore slashes';
if ('/' !== c) { if (c !== '/') {
err('Expected \'/\', got: ' + c); err('Expected \'/\', got: ' + c);
continue; continue;
} }
break; break;
case 'authority ignore slashes': case 'authority ignore slashes':
if ('/' !== c && '\\' !== c) { if (c !== '/' && c !== '\\') {
state = 'authority'; state = 'authority';
continue; continue;
} else { } else {
@ -1432,7 +1432,7 @@ PDFJS.compatibilityChecked = true;
continue; continue;
} }
var tempC = percentEscape(cp); var tempC = percentEscape(cp);
if (null !== this._password) { if (this._password !== null) {
this._password += tempC; this._password += tempC;
} else { } else {
this._username += tempC; this._username += tempC;
@ -1489,7 +1489,7 @@ PDFJS.compatibilityChecked = true;
break loop; break loop;
} }
continue; continue;
} else if ('\t' !== c && '\n' !== c && '\r' !== c) { } else if (c !== '\t' && c !== '\n' && c !== '\r') {
if (c === '[') { if (c === '[') {
seenBracket = true; seenBracket = true;
} else if (c === ']') { } else if (c === ']') {
@ -1506,7 +1506,7 @@ PDFJS.compatibilityChecked = true;
buffer += c; buffer += c;
} else if (c === EOF || c === '/' || c === '\\' || } else if (c === EOF || c === '/' || c === '\\' ||
c === '?' || c === '#' || stateOverride) { c === '?' || c === '#' || stateOverride) {
if ('' !== buffer) { if (buffer !== '') {
var temp = parseInt(buffer, 10); var temp = parseInt(buffer, 10);
if (temp !== relative[this._scheme]) { if (temp !== relative[this._scheme]) {
this._port = temp + ''; this._port = temp + '';
@ -1530,7 +1530,7 @@ PDFJS.compatibilityChecked = true;
err('\'\\\' not allowed in path.'); err('\'\\\' not allowed in path.');
} }
state = 'relative path'; state = 'relative path';
if ('/' !== c && '\\' !== c) { if (c !== '/' && c !== '\\') {
continue; continue;
} }
break; break;
@ -1547,12 +1547,12 @@ PDFJS.compatibilityChecked = true;
} }
if (buffer === '..') { if (buffer === '..') {
this._path.pop(); this._path.pop();
if ('/' !== c && '\\' !== c) { if (c !== '/' && c !== '\\') {
this._path.push(''); this._path.push('');
} }
} else if (buffer === '.' && '/' !== c && '\\' !== c) { } else if (buffer === '.' && c !== '/' && c !== '\\') {
this._path.push(''); this._path.push('');
} else if ('.' !== buffer) { } else if (buffer !== '.') {
if (this._scheme === 'file' && this._path.length === 0 && if (this._scheme === 'file' && this._path.length === 0 &&
buffer.length === 2 && ALPHA.test(buffer[0]) && buffer.length === 2 && ALPHA.test(buffer[0]) &&
buffer[1] === '|') { buffer[1] === '|') {
@ -1568,7 +1568,7 @@ PDFJS.compatibilityChecked = true;
this._fragment = '#'; this._fragment = '#';
state = 'fragment'; state = 'fragment';
} }
} else if ('\t' !== c && '\n' !== c && '\r' !== c) { } else if (c !== '\t' && c !== '\n' && c !== '\r') {
buffer += percentEscape(c); buffer += percentEscape(c);
} }
break; break;
@ -1577,13 +1577,13 @@ PDFJS.compatibilityChecked = true;
if (!stateOverride && c === '#') { if (!stateOverride && c === '#') {
this._fragment = '#'; this._fragment = '#';
state = 'fragment'; state = 'fragment';
} else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) { } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
this._query += percentEscapeQuery(c); this._query += percentEscapeQuery(c);
} }
break; break;
case 'fragment': case 'fragment':
if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) { if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
this._fragment += c; this._fragment += c;
} }
break; break;
@ -1632,9 +1632,9 @@ PDFJS.compatibilityChecked = true;
return this._url; return this._url;
} }
var authority = ''; var authority = '';
if ('' !== this._username || null !== this._password) { if (this._username !== '' || this._password !== null) {
authority = this._username + authority = this._username +
(null !== this._password ? ':' + this._password : '') + '@'; (this._password !== null ? ':' + this._password : '') + '@';
} }
return this.protocol + return this.protocol +