Adjust the yoda ESLint rule to apply to inequalities as well

I happened to notice that some inequalities had the wrong order, and was surprised since I thought that the `yoda` rule should have caught that.
However, reading http://eslint.org/docs/rules/yoda#options a bit more closely than previously, it's quite obvious that the `onlyEquality` option does *exactly* what its name suggests. Hence I think that it makes sense to adjust the options such that only ranges are allowed instead.
This commit is contained in:
Jonas Jenwald 2017-03-06 16:50:22 +01:00
parent f0c45f0336
commit a7c19d9cbb
6 changed files with 31 additions and 29 deletions

View file

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