From b6f7cc8e46ba18537f5de45bc26cd977a34e591b Mon Sep 17 00:00:00 2001 From: "Sam R-T, Joseph F, Robin H" Date: Mon, 22 Jan 2018 15:22:35 -0800 Subject: [PATCH] Bug 1432062 - Require dangling commas via eslint for the migration component. r=MattN --- browser/components/migration/.eslintrc.js | 2 +- .../migration/360seProfileMigrator.js | 18 +++++++------- .../migration/ChromeProfileMigrator.js | 12 +++++----- browser/components/migration/ESEDBReader.jsm | 6 ++--- .../migration/EdgeProfileMigrator.js | 8 +++---- .../migration/FirefoxProfileMigrator.js | 14 +++++------ .../components/migration/IEProfileMigrator.js | 12 +++++----- .../components/migration/MSMigrationUtils.jsm | 12 +++++----- .../components/migration/MigrationUtils.jsm | 10 ++++---- .../components/migration/ProfileMigrator.js | 2 +- .../migration/SafariProfileMigrator.js | 12 +++++----- .../tests/unit/test_360se_bookmarks.js | 2 +- .../migration/tests/unit/test_IE_cookies.js | 2 +- .../tests/unit/test_automigration.js | 24 +++++++++---------- .../migration/tests/unit/test_fx_telemetry.js | 6 ++--- 15 files changed, 71 insertions(+), 71 deletions(-) diff --git a/browser/components/migration/.eslintrc.js b/browser/components/migration/.eslintrc.js index da9ae4f1d855..fba586f11c01 100644 --- a/browser/components/migration/.eslintrc.js +++ b/browser/components/migration/.eslintrc.js @@ -3,7 +3,7 @@ module.exports = { "rules": { "block-scoped-var": "error", - "comma-dangle": "off", + "comma-dangle": ["error", "always-multiline"], "complexity": ["error", {"max": 21}], "indent-legacy": ["error", 2, {"SwitchCase": 1, "ArrayExpression": "first", "ObjectExpression": "first"}], "max-nested-callbacks": ["error", 3], diff --git a/browser/components/migration/360seProfileMigrator.js b/browser/components/migration/360seProfileMigrator.js index 5171a9bdb99e..a70e87f68a6e 100644 --- a/browser/components/migration/360seProfileMigrator.js +++ b/browser/components/migration/360seProfileMigrator.js @@ -116,7 +116,7 @@ Bookmarks.prototype = { let toolbarBMs = []; let connection = await Sqlite.openConnection({ - path: this._file.path + path: this._file.path, }); try { @@ -145,7 +145,7 @@ Bookmarks.prototype = { bmToInsert = { children: [], title, - type: PlacesUtils.bookmarks.TYPE_FOLDER + type: PlacesUtils.bookmarks.TYPE_FOLDER, }; folderMap.set(id, bmToInsert); } else { @@ -158,7 +158,7 @@ Bookmarks.prototype = { bmToInsert = { title, - url + url, }; } @@ -182,7 +182,7 @@ Bookmarks.prototype = { } })().then(() => aCallback(true), e => { Cu.reportError(e); aCallback(false); }); - } + }, }; function Qihoo360seProfileMigrator() { @@ -190,13 +190,13 @@ function Qihoo360seProfileMigrator() { // for v6 and above { users: ["360se6", "apps", "data", "users"], - defaultUser: "default" + defaultUser: "default", }, // for earlier versions { users: ["360se"], - defaultUser: "data" - } + defaultUser: "data", + }, ]; this._usersDir = null; this._defaultUserPath = null; @@ -287,7 +287,7 @@ Object.defineProperty(Qihoo360seProfileMigrator.prototype, "sourceProfiles", { return resources && resources.length > 0; }); return this.__sourceProfiles; - } + }, }); Qihoo360seProfileMigrator.prototype._getIdFromConfig = function(aConfig) { @@ -303,7 +303,7 @@ Qihoo360seProfileMigrator.prototype.getResources = function(aProfile) { } let resources = [ - new Bookmarks(profileFolder) + new Bookmarks(profileFolder), ]; return resources.filter(r => r.exists); }; diff --git a/browser/components/migration/ChromeProfileMigrator.js b/browser/components/migration/ChromeProfileMigrator.js index 7386bfd153ee..92bdfaeddd33 100644 --- a/browser/components/migration/ChromeProfileMigrator.js +++ b/browser/components/migration/ChromeProfileMigrator.js @@ -16,7 +16,7 @@ const S100NS_PER_MS = 10; const AUTH_TYPE = { SCHEME_HTML: 0, SCHEME_BASIC: 1, - SCHEME_DIGEST: 2 + SCHEME_DIGEST: 2, }; Cu.import("resource://gre/modules/AppConstants.jsm"); @@ -178,7 +178,7 @@ Object.defineProperty(ChromeProfileMigrator.prototype, "sourceProfiles", { return resources && resources.length > 0; }, this); return this.__sourceProfiles; - } + }, }); Object.defineProperty(ChromeProfileMigrator.prototype, "sourceHomePageURL", { @@ -200,7 +200,7 @@ Object.defineProperty(ChromeProfileMigrator.prototype, "sourceHomePageURL", { } } return ""; - } + }, }); Object.defineProperty(ChromeProfileMigrator.prototype, "sourceLocked", { @@ -257,7 +257,7 @@ function GetBookmarksResource(aProfileFolder) { } })().then(() => aCallback(true), () => aCallback(false)); - } + }, }; } @@ -320,7 +320,7 @@ function GetHistoryResource(aProfileFolder) { } else { reject(new Error("Couldn't add visits")); } - } + }, }); }); } @@ -329,7 +329,7 @@ function GetHistoryResource(aProfileFolder) { Cu.reportError(ex); aCallback(false); }); - } + }, }; } diff --git a/browser/components/migration/ESEDBReader.jsm b/browser/components/migration/ESEDBReader.jsm index 959b56228e87..0a120d65dbf8 100644 --- a/browser/components/migration/ESEDBReader.jsm +++ b/browser/components/migration/ESEDBReader.jsm @@ -33,7 +33,7 @@ const MAX_STR_LENGTH = 64 * 1024; const KERNEL = {}; KERNEL.FILETIME = new ctypes.StructType("FILETIME", [ {dwLowDateTime: ctypes.uint32_t}, - {dwHighDateTime: ctypes.uint32_t} + {dwHighDateTime: ctypes.uint32_t}, ]); KERNEL.SYSTEMTIME = new ctypes.StructType("SYSTEMTIME", [ {wYear: ctypes.uint16_t}, @@ -43,7 +43,7 @@ KERNEL.SYSTEMTIME = new ctypes.StructType("SYSTEMTIME", [ {wHour: ctypes.uint16_t}, {wMinute: ctypes.uint16_t}, {wSecond: ctypes.uint16_t}, - {wMilliseconds: ctypes.uint16_t} + {wMilliseconds: ctypes.uint16_t}, ]); // DB column types, cribbed from the ESE header @@ -97,7 +97,7 @@ ESE.JET_COLUMNDEF = new ctypes.StructType("JET_COLUMNDEF", [ {"cp": ctypes.unsigned_short }, {"wCollate": ctypes.unsigned_short }, /* Must be 0 */ {"cbMax": ctypes.unsigned_long }, - {"grbit": ESE.JET_GRBIT } + {"grbit": ESE.JET_GRBIT }, ]); // Track open databases diff --git a/browser/components/migration/EdgeProfileMigrator.js b/browser/components/migration/EdgeProfileMigrator.js index d607b5dd0d37..4c18ce778c9b 100644 --- a/browser/components/migration/EdgeProfileMigrator.js +++ b/browser/components/migration/EdgeProfileMigrator.js @@ -131,7 +131,7 @@ EdgeTypedURLMigrator.prototype = { places.push({ uri, visits: [{ transitionType: Ci.nsINavHistoryService.TRANSITION_TYPED, - visitDate}] + visitDate}], }); } @@ -145,7 +145,7 @@ EdgeTypedURLMigrator.prototype = { ignoreResults: true, handleCompletion(updatedCount) { aCallback(updatedCount > 0); - } + }, }); }, }; @@ -181,7 +181,7 @@ EdgeReadingListMigrator.prototype = { let columns = [ {name: "URL", type: "string"}, {name: "Title", type: "string"}, - {name: "AddedDate", type: "date"} + {name: "AddedDate", type: "date"}, ]; // Later versions have an IsDeleted column: @@ -284,7 +284,7 @@ EdgeBookmarksMigrator.prototype = { {name: "IsFolder", type: "boolean"}, {name: "IsDeleted", type: "boolean"}, {name: "ParentId", type: "guid"}, - {name: "ItemId", type: "guid"} + {name: "ItemId", type: "guid"}, ]; let filterFn = row => { if (row.IsDeleted) { diff --git a/browser/components/migration/FirefoxProfileMigrator.js b/browser/components/migration/FirefoxProfileMigrator.js index 5275023fc057..9ff98b49acbb 100644 --- a/browser/components/migration/FirefoxProfileMigrator.js +++ b/browser/components/migration/FirefoxProfileMigrator.js @@ -64,7 +64,7 @@ function sorter(a, b) { Object.defineProperty(FirefoxProfileMigrator.prototype, "sourceProfiles", { get() { return [...this._getAllProfiles().keys()].map(x => ({id: x, name: x})).sort(sorter); - } + }, }); FirefoxProfileMigrator.prototype._getFileObject = function(dir, fileName) { @@ -122,7 +122,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD file.copyTo(currentProfileDir, ""); } aCallback(true); - } + }, }; }; @@ -181,7 +181,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD }, function() { aCallback(false); }); - } + }, }; } } @@ -214,7 +214,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD return; } aCallback(true); - } + }, }; // Telemetry related migrations. @@ -232,7 +232,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD () => aCallback(true), () => aCallback(false) ); - } + }, }; let telemetry = { name: "telemetry", // name is used only by tests... @@ -283,7 +283,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD } aCallback(true); - } + }, }; return [places, cookies, passwords, formData, dictionary, bookmarksBackups, @@ -291,7 +291,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD }; Object.defineProperty(FirefoxProfileMigrator.prototype, "startupOnlyMigrator", { - get: () => true + get: () => true, }); diff --git a/browser/components/migration/IEProfileMigrator.js b/browser/components/migration/IEProfileMigrator.js index 8d72b6774b79..f85d9204610e 100644 --- a/browser/components/migration/IEProfileMigrator.js +++ b/browser/components/migration/IEProfileMigrator.js @@ -78,7 +78,7 @@ History.prototype = { { uri, title, visits: [{ transitionType, - visitDate: lastVisitTime }] + visitDate: lastVisitTime }], } ); } @@ -94,9 +94,9 @@ History.prototype = { ignoreResults: true, handleCompletion(updatedCount) { aCallback(updatedCount > 0); - } + }, }); - } + }, }; // IE form password migrator supporting windows from XP until 7 and IE from 7 until 11 @@ -272,7 +272,7 @@ IE7FormPasswords.prototype = { // Bytes 24-35 are not needed and not documented {"unknown4": ctypes.uint32_t}, {"unknown5": ctypes.uint32_t}, - {"unknown6": ctypes.uint32_t} + {"unknown6": ctypes.uint32_t}, ]); // the structure of a IE7 decrypted login item @@ -289,7 +289,7 @@ IE7FormPasswords.prototype = { // Bytes 20-31 are not needed and not documented {"unknown1": ctypes.uint32_t}, {"unknown2": ctypes.uint32_t}, - {"unknown3": ctypes.uint32_t} + {"unknown3": ctypes.uint32_t}, ]); let url = uri.prePath; @@ -402,7 +402,7 @@ Object.defineProperty(IEProfileMigrator.prototype, "sourceHomePageURL", { } return homepage; - } + }, }); IEProfileMigrator.prototype.classDescription = "IE Profile Migrator"; diff --git a/browser/components/migration/MSMigrationUtils.jsm b/browser/components/migration/MSMigrationUtils.jsm index df412935a024..5245f8851e6f 100644 --- a/browser/components/migration/MSMigrationUtils.jsm +++ b/browser/components/migration/MSMigrationUtils.jsm @@ -65,12 +65,12 @@ function CtypesKernelHelpers() { {wHour: wintypes.WORD}, {wMinute: wintypes.WORD}, {wSecond: wintypes.WORD}, - {wMilliseconds: wintypes.WORD} + {wMilliseconds: wintypes.WORD}, ]); this._structs.FILETIME = new ctypes.StructType("FILETIME", [ {dwLowDateTime: wintypes.DWORD}, - {dwHighDateTime: wintypes.DWORD} + {dwHighDateTime: wintypes.DWORD}, ]); try { @@ -133,7 +133,7 @@ CtypesKernelHelpers.prototype = { systemTime.wMinute, systemTime.wSecond, systemTime.wMilliseconds) / 1000); - } + }, }; function CtypesVaultHelpers() { @@ -256,7 +256,7 @@ CtypesVaultHelpers.prototype = { this._vaultcliLib.close(); } catch (ex) {} this._vaultcliLib = null; - } + }, }; /** @@ -644,7 +644,7 @@ Cookies.prototype = { expireTime, {}); } - } + }, }; function getTypedURLs(registryKeyPath) { @@ -871,7 +871,7 @@ WindowsVaultFormPasswords.prototype = { return false; } return undefined; - } + }, }; var MSMigrationUtils = { diff --git a/browser/components/migration/MigrationUtils.jsm b/browser/components/migration/MigrationUtils.jsm index 17118bf8585d..6f298a02776d 100644 --- a/browser/components/migration/MigrationUtils.jsm +++ b/browser/components/migration/MigrationUtils.jsm @@ -50,7 +50,7 @@ XPCOMUtils.defineLazyGetter(this, "gAvailableMigratorKeys", function() { if (AppConstants.platform == "win") { return [ "firefox", "edge", "ie", "chrome", "chromium", "360se", - "canary" + "canary", ]; } if (AppConstants.platform == "macosx") { @@ -445,7 +445,7 @@ this.MigratorPrototype = { } this._resourcesByProfile[profileKey] = this.getResources(aProfile); return this._resourcesByProfile[profileKey]; - } + }, }; this.MigrationUtils = Object.freeze({ @@ -532,7 +532,7 @@ this.MigrationUtils = Object.freeze({ const OVERRIDES = { "4_firefox": "4_firefox_history_and_bookmarks", - "64_firefox": "64_firefox_other" + "64_firefox": "64_firefox_other", }; aKey = OVERRIDES[aKey] || aKey; @@ -589,7 +589,7 @@ this.MigrationUtils = Object.freeze({ let source = this.getLocalizedString("sourceName" + sourceNameStr); let title = this.getLocalizedString("importedBookmarksFolder", [source]); return (await PlacesUtils.bookmarks.insert({ - type: PlacesUtils.bookmarks.TYPE_FOLDER, parentGuid, title + type: PlacesUtils.bookmarks.TYPE_FOLDER, parentGuid, title, })).guid; }, @@ -980,7 +980,7 @@ this.MigrationUtils = Object.freeze({ return insertionPromise.then(bm => { let {guid, lastModified, type} = bm; gUndoData.get("bookmarks").push({ - parentGuid, guid, lastModified, type + parentGuid, guid, lastModified, type, }); return bm; }); diff --git a/browser/components/migration/ProfileMigrator.js b/browser/components/migration/ProfileMigrator.js index f67823bae750..1000b4d08a58 100644 --- a/browser/components/migration/ProfileMigrator.js +++ b/browser/components/migration/ProfileMigrator.js @@ -15,7 +15,7 @@ ProfileMigrator.prototype = { QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIProfileMigrator]), classDescription: "Profile Migrator", contractID: "@mozilla.org/toolkit/profile-migrator;1", - classID: Components.ID("6F8BB968-C14F-4D6F-9733-6C6737B35DCE") + classID: Components.ID("6F8BB968-C14F-4D6F-9733-6C6737B35DCE"), }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ProfileMigrator]); diff --git a/browser/components/migration/SafariProfileMigrator.js b/browser/components/migration/SafariProfileMigrator.js index b50732281759..bdc3534fb55c 100644 --- a/browser/components/migration/SafariProfileMigrator.js +++ b/browser/components/migration/SafariProfileMigrator.js @@ -237,7 +237,7 @@ History.prototype = { ignoreResults: true, handleCompletion(updatedCount) { aCallback(updatedCount > 0); - } + }, }); } else { aCallback(false); @@ -247,7 +247,7 @@ History.prototype = { aCallback(false); } }); - } + }, }; /** @@ -305,7 +305,7 @@ MainPreferencesPropertyList.prototype = { this._dict = PropertyListUtils._readFromArrayBufferSync( new Uint8Array(bytes).buffer); return this._dict; - } + }, }; function SearchStrings(aMainPreferencesPropertyListInstance) { @@ -331,7 +331,7 @@ SearchStrings.prototype = { } } }, aCallback)); - } + }, }; function SafariProfileMigrator() { @@ -399,7 +399,7 @@ Object.defineProperty(SafariProfileMigrator.prototype, "mainPreferencesPropertyL return this._mainPreferencesPropertyList; } return this._mainPreferencesPropertyList; - } + }, }); Object.defineProperty(SafariProfileMigrator.prototype, "sourceHomePageURL", { @@ -410,7 +410,7 @@ Object.defineProperty(SafariProfileMigrator.prototype, "sourceHomePageURL", { return dict.get("HomePage"); } return ""; - } + }, }); SafariProfileMigrator.prototype.classDescription = "Safari Profile Migrator"; diff --git a/browser/components/migration/tests/unit/test_360se_bookmarks.js b/browser/components/migration/tests/unit/test_360se_bookmarks.js index bafc0afa76c5..cf3d260487c9 100644 --- a/browser/components/migration/tests/unit/test_360se_bookmarks.js +++ b/browser/components/migration/tests/unit/test_360se_bookmarks.js @@ -45,7 +45,7 @@ add_task(async function() { PlacesUtils.bookmarks.addObserver(bmObserver); await promiseMigration(migrator, MigrationUtils.resourceTypes.BOOKMARKS, { - id: "default" + id: "default", }); PlacesUtils.bookmarks.removeObserver(bmObserver); diff --git a/browser/components/migration/tests/unit/test_IE_cookies.js b/browser/components/migration/tests/unit/test_IE_cookies.js index 1ef482d443df..eb09173a2be5 100644 --- a/browser/components/migration/tests/unit/test_IE_cookies.js +++ b/browser/components/migration/tests/unit/test_IE_cookies.js @@ -61,7 +61,7 @@ add_task(async function() { href: `http://mycookietest.${Math.random()}.com`, name: "testcookie", value: "testvalue", - expiry: new Date(new Date().setDate(date + 2)) + expiry: new Date(new Date().setDate(date + 2)), }; let data = ctypes.char16_t.array()(256); let sizeRef = DWORD(256).address(); diff --git a/browser/components/migration/tests/unit/test_automigration.js b/browser/components/migration/tests/unit/test_automigration.js index 7fcbca02c9a9..1001d713ffc2 100644 --- a/browser/components/migration/tests/unit/test_automigration.js +++ b/browser/components/migration/tests/unit/test_automigration.js @@ -269,7 +269,7 @@ add_task(async function checkUndoRemoval() { transitionType: PlacesUtils.history.TRANSITION_LINK, visitDate: now_uSec - 100 * kUsecPerMin, }, - ] + ], }]); await frecencyUpdatePromise; @@ -335,23 +335,23 @@ add_task(async function checkUndoBookmarksState() { let url = "http://www.example.com"; let parentGuid = PlacesUtils.bookmarks.toolbarGuid; let {guid, lastModified} = await MigrationUtils.insertBookmarkWrapper({ - title, url, parentGuid + title, url, parentGuid, }); Assert.deepEqual((await MigrationUtils.stopAndRetrieveUndoData()).get("bookmarks"), [{lastModified, parentGuid, guid, type: TYPE_BOOKMARK}]); MigrationUtils.initializeUndoData(); ({guid, lastModified} = await MigrationUtils.insertBookmarkWrapper({ - title, parentGuid, type: TYPE_FOLDER + title, parentGuid, type: TYPE_FOLDER, })); let folder = {guid, lastModified, parentGuid, type: TYPE_FOLDER}; let folderGuid = folder.guid; ({guid, lastModified} = await MigrationUtils.insertBookmarkWrapper({ - title, url, parentGuid: folderGuid + title, url, parentGuid: folderGuid, })); let kid1 = {guid, lastModified, parentGuid: folderGuid, type: TYPE_BOOKMARK}; ({guid, lastModified} = await MigrationUtils.insertBookmarkWrapper({ - title, url, parentGuid: folderGuid + title, url, parentGuid: folderGuid, })); let kid2 = {guid, lastModified, parentGuid: folderGuid, type: TYPE_BOOKMARK}; @@ -375,28 +375,28 @@ add_task(async function testBookmarkRemovalByUndo() { let url = "http://www.mymagicaluniqueurl.com"; let parentGuid = PlacesUtils.bookmarks.toolbarGuid; let {guid} = await MigrationUtils.insertBookmarkWrapper({ - title: "Some folder", parentGuid, type: TYPE_FOLDER + title: "Some folder", parentGuid, type: TYPE_FOLDER, }); let folderGuid = guid; let itemsToRemove = []; ({guid} = await MigrationUtils.insertBookmarkWrapper({ - title: "Inner folder", parentGuid: folderGuid, type: TYPE_FOLDER + title: "Inner folder", parentGuid: folderGuid, type: TYPE_FOLDER, })); let innerFolderGuid = guid; itemsToRemove.push(innerFolderGuid); ({guid} = await MigrationUtils.insertBookmarkWrapper({ - title: "Inner inner folder", parentGuid: innerFolderGuid, type: TYPE_FOLDER + title: "Inner inner folder", parentGuid: innerFolderGuid, type: TYPE_FOLDER, })); itemsToRemove.push(guid); ({guid} = await MigrationUtils.insertBookmarkWrapper({ - title: "Inner nested item", url: "http://inner-nested-example.com", parentGuid: guid + title: "Inner nested item", url: "http://inner-nested-example.com", parentGuid: guid, })); itemsToRemove.push(guid); ({guid} = await MigrationUtils.insertBookmarkWrapper({ - title, url, parentGuid: folderGuid + title, url, parentGuid: folderGuid, })); itemsToRemove.push(guid); @@ -579,7 +579,7 @@ add_task(async function checkUndoVisitsState() { onManyFrecenciesChanged() { PlacesUtils.history.removeObserver(this); resolve(); - } + }, }); }); await PlacesUtils.history.insertMany([{ @@ -608,7 +608,7 @@ add_task(async function checkUndoVisitsState() { let frecencyChangesExpected = new Map([ ["http://www.example.com/", PromiseUtils.defer()], - ["http://www.example.org/", PromiseUtils.defer()] + ["http://www.example.org/", PromiseUtils.defer()], ]); let uriDeletedExpected = new Map([ ["http://www.mozilla.org/", PromiseUtils.defer()], diff --git a/browser/components/migration/tests/unit/test_fx_telemetry.js b/browser/components/migration/tests/unit/test_fx_telemetry.js index c4a76fab2b8b..6d2ad21580b8 100644 --- a/browser/components/migration/tests/unit/test_fx_telemetry.js +++ b/browser/components/migration/tests/unit/test_fx_telemetry.js @@ -219,7 +219,7 @@ add_task(async function test_datareporting_many() { "datareporting": { "state.json": shouldBeCopied, "session-state.json": shouldBeCopied, - } + }, }); }); @@ -237,7 +237,7 @@ add_task(async function test_no_session_state() { checkDirectoryContains(targetDir, { "datareporting": { "state.json": stateContent, - } + }, }); }); @@ -255,7 +255,7 @@ add_task(async function test_no_state() { checkDirectoryContains(targetDir, { "datareporting": { "session-state.json": sessionStateContent, - } + }, }); });