Skip to content

Commit

Permalink
Disallow use of 'var'.
Browse files Browse the repository at this point in the history
This also fixes some usages of 'var' that didn't get caught by the
previous CLs.

Change-Id: I4ce53d62d24e53e121d7eced70590836c1d26523
  • Loading branch information
TheModMaker committed Feb 20, 2018
1 parent 41ac7d2 commit d47ab5c
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 25 deletions.
27 changes: 18 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ module.exports = {

// Things we should probably fix, but in stages in multiple commits: {{{

// In many cases, we should change scoped var to let.
"block-scoped-var": "off",
"no-inner-declarations": "off",
"no-redeclare": "off",
"no-shadow": "off",

// These could catch real bugs
"consistent-return": "off",
"default-case": "off",
Expand All @@ -53,6 +47,7 @@ module.exports = {
"complexity": "off",
"dot-location": "off",
"no-negated-condition": "off",
"no-shadow": "off",
// }}}

// Temporary Google style overrides while we get in compliance with the latest style guide {{{
Expand All @@ -65,7 +60,6 @@ module.exports = {
"new-cap": "off",
"no-multi-spaces": "off",
"no-multiple-empty-lines": "off",
"no-var": "off",
"object-curly-spacing": "off",
"one-var": "off",
"padded-blocks": "off",
Expand All @@ -75,7 +69,7 @@ module.exports = {
// }}}

// "Possible error" rules in "eslint:recommended" that need options: {{{
"no-empty": ["error", {"allowEmptyCatch": true}],
"no-empty": ["error", {"allowEmptyCatch": true}],
// }}}

// "Possible error" rules we should be able to pass, but are not part of "eslint:recommended": {{{
Expand Down Expand Up @@ -142,5 +136,20 @@ module.exports = {
// Style rules that don't seem to be in the Google style config: {{{
"array-bracket-newline": ["error", "consistent"],
// }}}
}
},
"overrides": [
{
"files": [
// Closure requires using var in externs.
"externs/**/*.js",
"test/test/externs/*.js",
// Use var in load.js so it works in old browsers. We'll use
// compiled mode for the main library and the demo.
"demo/load.js",
],
"rules": {
"no-var": "off",
},
},
],
};
2 changes: 1 addition & 1 deletion demo/asset_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};
var shakaDemo = shakaDemo || {}; // eslint-disable-line no-var


/** @private {!Array.<HTMLOptGroupElement>} */
Expand Down
2 changes: 1 addition & 1 deletion demo/configuration_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};
var shakaDemo = shakaDemo || {}; // eslint-disable-line no-var


/** @private */
Expand Down
2 changes: 1 addition & 1 deletion demo/info_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};
var shakaDemo = shakaDemo || {}; // eslint-disable-line no-var


/** @private */
Expand Down
4 changes: 2 additions & 2 deletions demo/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

// The application must define its list of compiled and uncompiled sources
// before including this loader. The URLs should be relative to the page.
for (var i = 0; i < scripts.length; ++i) {
loadRelativeScript(scripts[i]);
for (var j = 0; j < scripts.length; ++j) {
loadRelativeScript(scripts[j]);
}
})(); // anonymous namespace
2 changes: 1 addition & 1 deletion demo/log_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};
var shakaDemo = shakaDemo || {}; // eslint-disable-line no-var


/** @private {!Object.<string, Function>} */
Expand Down
2 changes: 1 addition & 1 deletion demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};
var shakaDemo = shakaDemo || {}; // eslint-disable-line no-var


/** @private {shaka.cast.CastProxy} */
Expand Down
2 changes: 1 addition & 1 deletion demo/offline_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};
var shakaDemo = shakaDemo || {}; // eslint-disable-line no-var


/** @private {?HTMLOptGroupElement} */
Expand Down
6 changes: 3 additions & 3 deletions test/net/http_plugin_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ function httpPluginTests(usingFetch) {
});

it('fails if non-2xx status', function(done) {
var uri = 'https://foo.bar/404';
const uri = 'https://foo.bar/404';
testFails(uri, done, undefined, shaka.util.Error.Code.BAD_HTTP_STATUS,
[uri, 404, 'ABC', { 'foo': 'BAR' }, requestType]);
PromiseMock.flush();
});

it('fails on timeout', function(done) {
var uri = 'https://foo.bar/timeout';
const uri = 'https://foo.bar/timeout';
testFails(uri, done, shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Code.TIMEOUT, [uri, requestType]);

Expand All @@ -220,7 +220,7 @@ function httpPluginTests(usingFetch) {
});

it('fails on error', function(done) {
var uri = 'https://foo.bar/error';
const uri = 'https://foo.bar/error';
testFails(uri, done, shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Code.HTTP_ERROR,
[uri, jasmine.any(Object), requestType]);
Expand Down
10 changes: 5 additions & 5 deletions test/test/util/manifest_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ shaka.test.ManifestGenerator.prototype.bandwidth = function(bandwidth) {
* @return {!shaka.test.ManifestGenerator}
*/
shaka.test.ManifestGenerator.prototype.disallowByApplication = function() {
var variant = this.currentVariant_();
let variant = this.currentVariant_();
variant.allowedByApplication = false;
return this;
};
Expand All @@ -207,7 +207,7 @@ shaka.test.ManifestGenerator.prototype.disallowByApplication = function() {
* @return {!shaka.test.ManifestGenerator}
*/
shaka.test.ManifestGenerator.prototype.disallowByKeySystem = function() {
var variant = this.currentVariant_();
let variant = this.currentVariant_();
variant.allowedByKeySystem = false;
return this;
};
Expand Down Expand Up @@ -562,7 +562,7 @@ shaka.test.ManifestGenerator.prototype.textStream = function(uri) {
* @return {!shaka.test.ManifestGenerator}
*/
shaka.test.ManifestGenerator.prototype.anyInitSegment = function() {
var stream = this.currentStream_();
let stream = this.currentStream_();
stream.initSegmentReference =
/** @type {shaka.media.InitSegmentReference} */ (
jasmine.any(this.shaka_.media.InitSegmentReference));
Expand All @@ -576,7 +576,7 @@ shaka.test.ManifestGenerator.prototype.anyInitSegment = function() {
* @return {!shaka.test.ManifestGenerator}
*/
shaka.test.ManifestGenerator.prototype.nullInitSegment = function() {
var stream = this.currentStream_();
let stream = this.currentStream_();
stream.initSegmentReference = null;
return this;
};
Expand Down Expand Up @@ -635,7 +635,7 @@ shaka.test.ManifestGenerator.prototype.mime = function(mime, opt_codecs) {
* @return {!shaka.test.ManifestGenerator}
*/
shaka.test.ManifestGenerator.prototype.frameRate = function(frameRate) {
var stream = this.currentStream_();
let stream = this.currentStream_();
stream.frameRate = frameRate;
return this;
};
Expand Down

0 comments on commit d47ab5c

Please sign in to comment.