Bug 1432062 - Require dangling commas via eslint for the migration component. r=MattN

This commit is contained in:
Sam R-T, Joseph F, Robin H 2018-01-22 15:22:35 -08:00
parent e8281edb09
commit b6f7cc8e46
15 changed files with 71 additions and 71 deletions

View File

@ -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],

View File

@ -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);
};

View File

@ -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);
});
}
},
};
}

View File

@ -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

View File

@ -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) {

View File

@ -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,
});

View File

@ -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";

View File

@ -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 = {

View File

@ -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;
});

View File

@ -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]);

View File

@ -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";

View File

@ -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);

View File

@ -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();

View File

@ -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()],

View File

@ -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,
}
},
});
});