diff --git a/.eslintrc.js b/.eslintrc.js index 6ecd516f47..a4d4c507bc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -84,7 +84,9 @@ module.exports = { 'no-empty': ['error', {'allowEmptyCatch': true}], 'no-misleading-character-class': 'error', 'no-template-curly-in-string': 'error', - 'require-atomic-updates': 'error', + // TODO: Try to re-enable this if possible. Right now, it produces way too + // many false-positives with eslint 7. It worked well enough in eslint 5. + // 'require-atomic-updates': 'error', // }}} // "Best practices" rules: {{{ @@ -292,5 +294,16 @@ module.exports = { 'test/**/*.js', ], }, + { + 'rules': { + // Externs naturally redeclare things eslint knows about. + 'no-redeclare': 'off', + }, + 'files': [ + 'ui/externs/*.js', + 'externs/**/*.js', + 'test/test/externs/*.js', + ], + }, ], }; diff --git a/lib/cast/cast_proxy.js b/lib/cast/cast_proxy.js index b9701b8b14..fb2eb9fda9 100644 --- a/lib/cast/cast_proxy.js +++ b/lib/cast/cast_proxy.js @@ -278,7 +278,7 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget { configurable: false, enumerable: true, get: () => this.videoProxyGet_(k), - set: (value) => this.videoProxySet_(k, value), + set: (value) => { this.videoProxySet_(k, value); }, }); } diff --git a/lib/dependencies/all.js b/lib/dependencies/all.js index c1a44f2c1e..6584e7d78a 100644 --- a/lib/dependencies/all.js +++ b/lib/dependencies/all.js @@ -38,8 +38,7 @@ shaka.dependencies = class { /** @return {?muxjs} */ static muxjs() { return /** @type {?muxjs} */ (shaka.dependencies.dependencies_.get( - shaka.dependencies.Allowed.muxjs - )); + shaka.dependencies.Allowed.muxjs)); } }; @@ -60,6 +59,4 @@ shaka.dependencies.Allowed = { // Add global muxjs object for backward compatibility shaka.dependencies.dependencies_.set( shaka.dependencies.Allowed.muxjs, - window.muxjs -); - + window.muxjs); diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index 4ceed92321..588b6e41ac 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -752,8 +752,7 @@ shaka.media.DrmEngine = class { if (info.initData && info.initData.length) { config.initDataTypes = [ ...new Set( - info.initData.map((initData) => initData.initDataType) - ), + info.initData.map((initData) => initData.initDataType)), ]; } if (info.distinctiveIdentifierRequired) { diff --git a/lib/offline/indexeddb/base_storage_cell.js b/lib/offline/indexeddb/base_storage_cell.js index 85a1b14e3e..cfa3a15cd0 100644 --- a/lib/offline/indexeddb/base_storage_cell.js +++ b/lib/offline/indexeddb/base_storage_cell.js @@ -233,8 +233,7 @@ shaka.offline.indexeddb.BaseStorageCell = class { shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.STORAGE, shaka.util.Error.Code.KEY_NOT_FOUND, - 'Could not find values for ' + missing - ); + 'Could not find values for ' + missing); } return keys.map((key) => values[key]); diff --git a/lib/offline/indexeddb/db_connection.js b/lib/offline/indexeddb/db_connection.js index 03fadefaee..908686bbcc 100644 --- a/lib/offline/indexeddb/db_connection.js +++ b/lib/offline/indexeddb/db_connection.js @@ -72,8 +72,7 @@ shaka.offline.indexeddb.DBConnection = class { // Once the operation is done (regardless of outcome) stop tracking it. operation.promise().then( () => this.stopTracking_(operation), - () => this.stopTracking_(operation) - ); + () => this.stopTracking_(operation)); return operation; } diff --git a/lib/util/multi_map.js b/lib/util/multi_map.js index 21ff3d10d5..487a522484 100644 --- a/lib/util/multi_map.js +++ b/lib/util/multi_map.js @@ -25,6 +25,7 @@ shaka.util.MultiMap = class { * @param {T} value */ push(key, value) { + // eslint-disable-next-line no-prototype-builtins if (this.map_.hasOwnProperty(key)) { this.map_[key].push(value); } else { diff --git a/package.json b/package.json index dd0ea48a1e..5ec6de64a8 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "core-js": "^3.6.5", "dialog-polyfill": "^0.5.0", "es6-promise-polyfill": "^1.2.0", - "eslint": "^5.16.0", + "eslint": "^7.18.0", "eslint-config-google": "^0.13.0", "eslint-plugin-shaka-rules": "file:./build/eslint-plugin-shaka-rules", "esprima": "^4.0.1", diff --git a/test/cast/cast_receiver_unit.js b/test/cast/cast_receiver_unit.js index 2b3e9f5065..4602d6a389 100644 --- a/test/cast/cast_receiver_unit.js +++ b/test/cast/cast_receiver_unit.js @@ -1174,15 +1174,13 @@ filterDescribe('CastReceiver', castReceiverSupport, () => { expectedMedia.metadata = metadata; } - expect(mockGenericMessageBus.messages[0]).toEqual( - { - requestId: 0, - type: 'MEDIA_STATUS', - status: [jasmine.objectContaining({ - media: expectedMedia, - })], - } - ); + expect(mockGenericMessageBus.messages[0]).toEqual({ + requestId: 0, + type: 'MEDIA_STATUS', + status: [jasmine.objectContaining({ + media: expectedMedia, + })], + }); mockGenericMessageBus.messages.shift(); } }); diff --git a/test/dash/dash_parser_content_protection_unit.js b/test/dash/dash_parser_content_protection_unit.js index bbf4a890e7..31e06fab1e 100644 --- a/test/dash/dash_parser_content_protection_unit.js +++ b/test/dash/dash_parser_content_protection_unit.js @@ -287,14 +287,13 @@ describe('DashParser ContentProtection', () => { '', ], []); + const initData = buildInitData( + ['bm8gaHVtYW4gY2FuIHJlYWQgYmFzZTY0IGRpcmVjdGx5'], // PSSHs + ['deadbeeffeedbaadf00d000008675309']); // key ID for init data const expected = buildExpectedManifest([ buildDrmInfo('com.widevine.alpha', ['deadbeeffeedbaadf00d000008675309'], // key ID - buildInitData( - ['bm8gaHVtYW4gY2FuIHJlYWQgYmFzZTY0IGRpcmVjdGx5'], // PSSHs - ['deadbeeffeedbaadf00d000008675309'] // key ID for init data - ) - ), + initData), ]); await testDashParser(source, expected); }); @@ -344,12 +343,10 @@ describe('DashParser ContentProtection', () => { const expected = buildExpectedManifest([ buildDrmInfo('com.widevine.alpha', [], // key IDs - buildInitData(['ZmFrZSBXaWRldmluZSBQU1NI']) - ), + buildInitData(['ZmFrZSBXaWRldmluZSBQU1NI'])), buildDrmInfo('com.microsoft.playready', [], // key IDs - buildInitData(['bm8gaHVtYW4gY2FuIHJlYWQgYmFzZTY0IGRpcmVjdGx5']) - ), + buildInitData(['bm8gaHVtYW4gY2FuIHJlYWQgYmFzZTY0IGRpcmVjdGx5'])), ]); await testDashParser(source, expected); }); @@ -367,8 +364,7 @@ describe('DashParser ContentProtection', () => { [], // key IDs buildInitData([ 'AAAAKXBzc2gAAAAAmgTweZhAQoarkuZb4IhflQAAAAlQbGF5cmVhZHk=', - ]) - ), + ])), ]); await testDashParser(source, expected); }); @@ -385,8 +381,7 @@ describe('DashParser ContentProtection', () => { const expected = buildExpectedManifest([ buildDrmInfo('com.microsoft.playready', [], // key IDs - buildInitData(['bm8gaHVtYW4gY2FuIHJlYWQgYmFzZTY0IGRpcmVjdGx5']) - ), + buildInitData(['bm8gaHVtYW4gY2FuIHJlYWQgYmFzZTY0IGRpcmVjdGx5'])), ]); await testDashParser(source, expected); }); @@ -433,8 +428,7 @@ describe('DashParser ContentProtection', () => { ]); const expected = buildExpectedManifest( /** @type {!Array.} */(drmInfos), - [], // key IDs - ); + []); // key IDs await testDashParser(source, expected, /* ignoreDrmInfo= */ true); }); @@ -484,12 +478,10 @@ describe('DashParser ContentProtection', () => { const expected = buildExpectedManifest([ buildDrmInfo('com.widevine.alpha', [], // key IDs - buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs']) - ), + buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs'])), buildDrmInfo('com.microsoft.playready', [], // key IDs - buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs']) - ), + buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs'])), ]); await testDashParser(source, expected); }); @@ -514,13 +506,10 @@ describe('DashParser ContentProtection', () => { buildDrmInfo('com.widevine.alpha', [], // key IDs buildInitData( - ['VGltZSBpcyBhbiBpbGx1c2lvbi4gTHVuY2h0aW1lIGRvdWJseSBzby4='], - ) - ), + ['VGltZSBpcyBhbiBpbGx1c2lvbi4gTHVuY2h0aW1lIGRvdWJseSBzby4='])), buildDrmInfo('com.microsoft.playready', [], // key IDs - buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs']), - ), + buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs'])), ]); await testDashParser(source, expected); }); @@ -708,8 +697,7 @@ describe('DashParser ContentProtection', () => { const expected = buildExpectedManifest([ buildDrmInfo('com.widevine.alpha', [], // key IDs - buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs']) - ), + buildInitData(['b25lIGhlYWRlciB0byBydWxlIHRoZW0gYWxs'])), ]); await testDashParser(source, expected); }); diff --git a/test/dash/dash_parser_manifest_unit.js b/test/dash/dash_parser_manifest_unit.js index 4e63965e08..f2495f7318 100644 --- a/test/dash/dash_parser_manifest_unit.js +++ b/test/dash/dash_parser_manifest_unit.js @@ -380,15 +380,15 @@ describe('DashParser Manifest', () => { const stream1 = manifest.variants[0].video; const stream2 = manifest.variants[1].video; - const expectedClosedCaptions1 = new Map( - [['CC1', shaka.util.LanguageUtils.normalize('eng')], - ['CC3', shaka.util.LanguageUtils.normalize('swe')]] - ); - - const expectedClosedCaptions2 = new Map( - [['svc1', shaka.util.LanguageUtils.normalize('bos')], - ['svc3', shaka.util.LanguageUtils.normalize('cze')]] - ); + const expectedClosedCaptions1 = new Map([ + ['CC1', shaka.util.LanguageUtils.normalize('eng')], + ['CC3', shaka.util.LanguageUtils.normalize('swe')], + ]); + + const expectedClosedCaptions2 = new Map([ + ['svc1', shaka.util.LanguageUtils.normalize('bos')], + ['svc3', shaka.util.LanguageUtils.normalize('cze')], + ]); expect(stream1.closedCaptions).toEqual(expectedClosedCaptions1); expect(stream2.closedCaptions).toEqual(expectedClosedCaptions2); }); @@ -414,10 +414,10 @@ describe('DashParser Manifest', () => { /** @type {shaka.extern.Manifest} */ const manifest = await parser.start('dummy://foo', playerInterface); const stream = manifest.variants[0].video; - const expectedClosedCaptions = new Map( - [['svc1', shaka.util.LanguageUtils.normalize('eng')], - ['svc3', shaka.util.LanguageUtils.normalize('swe')]] - ); + const expectedClosedCaptions = new Map([ + ['svc1', shaka.util.LanguageUtils.normalize('eng')], + ['svc3', shaka.util.LanguageUtils.normalize('swe')], + ]); expect(stream.closedCaptions).toEqual(expectedClosedCaptions); }); @@ -442,10 +442,10 @@ describe('DashParser Manifest', () => { /** @type {shaka.extern.Manifest} */ const manifest = await parser.start('dummy://foo', playerInterface); const stream = manifest.variants[0].video; - const expectedClosedCaptions = new Map( - [['svc1', shaka.util.LanguageUtils.normalize('eng')], - ['svc2', shaka.util.LanguageUtils.normalize('swe')]] - ); + const expectedClosedCaptions = new Map([ + ['svc1', shaka.util.LanguageUtils.normalize('eng')], + ['svc2', shaka.util.LanguageUtils.normalize('swe')], + ]); expect(stream.closedCaptions).toEqual(expectedClosedCaptions); }); @@ -503,19 +503,17 @@ describe('DashParser Manifest', () => { const stream1 = manifest.variants[0].video; const stream2 = manifest.variants[1].video; - const expectedClosedCaptions1 = new Map( - [['CC1', shaka.util.LanguageUtils.normalize('eng')], - ['CC3', shaka.util.LanguageUtils.normalize('swe')]] - ); - - const expectedClosedCaptions2 = new Map( - [ - ['CC1', shaka.util.LanguageUtils.normalize('eng')], - ['CC2', shaka.util.LanguageUtils.normalize('swe')], - ['CC3', shaka.util.LanguageUtils.normalize('fre')], - ['CC4', shaka.util.LanguageUtils.normalize('pol')], - ] - ); + const expectedClosedCaptions1 = new Map([ + ['CC1', shaka.util.LanguageUtils.normalize('eng')], + ['CC3', shaka.util.LanguageUtils.normalize('swe')], + ]); + + const expectedClosedCaptions2 = new Map([ + ['CC1', shaka.util.LanguageUtils.normalize('eng')], + ['CC2', shaka.util.LanguageUtils.normalize('swe')], + ['CC3', shaka.util.LanguageUtils.normalize('fre')], + ['CC4', shaka.util.LanguageUtils.normalize('pol')], + ]); expect(stream1.closedCaptions).toEqual(expectedClosedCaptions1); expect(stream2.closedCaptions).toEqual(expectedClosedCaptions2); diff --git a/test/hls/manifest_text_parser_unit.js b/test/hls/manifest_text_parser_unit.js index b49ee5dc5d..9196fa43df 100644 --- a/test/hls/manifest_text_parser_unit.js +++ b/test/hls/manifest_text_parser_unit.js @@ -323,15 +323,13 @@ describe('ManifestTextParser', () => { new shaka.hls.Tag(/* id= */ 0, 'EXT-X-MEDIA-SEQUENCE', [], '1'), ], segments: [ - new shaka.hls.Segment('https://test/test.mp4', - [ - new shaka.hls.Tag( - /* id= */ 2, - 'EXTINF', - [new shaka.hls.Attribute('pid', '180')], - '5.99467' - ), - ]), + new shaka.hls.Segment('https://test/test.mp4', [ + new shaka.hls.Tag( + /* id= */ 2, + 'EXTINF', + [new shaka.hls.Attribute('pid', '180')], + '5.99467'), + ]), ], }, diff --git a/test/text/lrc_text_parser_unit.js b/test/text/lrc_text_parser_unit.js index 70e87f207d..396e816948 100644 --- a/test/text/lrc_text_parser_unit.js +++ b/test/text/lrc_text_parser_unit.js @@ -94,8 +94,7 @@ describe('LrcTextParser', () => { const expected = cues.map((cue) => { if (cue.nestedCues) { cue.nestedCues = cue.nestedCues.map( - (nestedCue) => jasmine.objectContaining(nestedCue) - ); + (nestedCue) => jasmine.objectContaining(nestedCue)); } return jasmine.objectContaining(cue); }); diff --git a/test/text/srt_text_parser_unit.js b/test/text/srt_text_parser_unit.js index 3cd25a709d..5284d73671 100644 --- a/test/text/srt_text_parser_unit.js +++ b/test/text/srt_text_parser_unit.js @@ -81,8 +81,7 @@ describe('SrtTextParser', () => { const expected = cues.map((cue) => { if (cue.nestedCues) { cue.nestedCues = cue.nestedCues.map( - (nestedCue) => jasmine.objectContaining(nestedCue) - ); + (nestedCue) => jasmine.objectContaining(nestedCue)); } return jasmine.objectContaining(cue); }); diff --git a/test/text/vtt_text_parser_unit.js b/test/text/vtt_text_parser_unit.js index 2142238dd9..c9c73a574f 100644 --- a/test/text/vtt_text_parser_unit.js +++ b/test/text/vtt_text_parser_unit.js @@ -759,8 +759,7 @@ describe('VttTextParser', () => { const expected = cues.map((cue) => { if (cue.nestedCues) { cue.nestedCues = cue.nestedCues.map( - (nestedCue) => jasmine.objectContaining(nestedCue) - ); + (nestedCue) => jasmine.objectContaining(nestedCue)); } return jasmine.objectContaining(cue); }); diff --git a/test/ui/ui_integration.js b/test/ui/ui_integration.js index 358e1070ca..5db6ade412 100644 --- a/test/ui/ui_integration.js +++ b/test/ui/ui_integration.js @@ -317,8 +317,7 @@ describe('UI', () => { languagesToButtons = mapChoicesToButtons( /* allButtons= */ languageButtons, /* choices= */ langsFromContent, - /* modifier= */ getNativeName - ); + /* modifier= */ getNativeName); const button = languagesToButtons.get(newLanguage); const isChosen = button.querySelector('.shaka-chosen-item');