pkg: make JavaScript keyspacing consistent

cockpit-ostree enables this by default and we have to disable it now.
Having consistent key spacing for all our JavaScript objects seems like
something we want everywhere as eslint --fix can automatically.
This commit is contained in:
Jelle van der Waa 2022-11-04 11:30:32 +01:00 committed by Jelle van der Waa
parent 35b9360191
commit 58b95f1a8c
24 changed files with 159 additions and 160 deletions

View File

@ -41,7 +41,6 @@
"curly": "off",
"no-template-curly-in-string": "off",
"jsx-quotes": "off",
"key-spacing": "off",
"no-console": "off",
"quotes": "off",
"react/jsx-curly-spacing": "off",

View File

@ -5,7 +5,7 @@ function test_storage (assert, storage, cockpitStorage) {
assert.expect(29);
storage.clear();
window.mock = {
pathname : "/cockpit+test/test"
pathname: "/cockpit+test/test"
};
assert.equal(cockpitStorage.prefixedKey("key1"), "cockpit+test:key1", "prefixed key has application");

View File

@ -467,7 +467,7 @@ QUnit.test("close peer", function (assert) {
const cmd = {
command: "close",
channel: channel.id,
problem : "marmalade",
problem: "marmalade",
extra: 5
};
mock_peer.send("", JSON.stringify(cmd));

View File

@ -51,7 +51,7 @@ function child_frame() {
let spawn_done = false;
let binary_done = false;
const promise = cockpit.spawn(["/bin/sh", "-c", "echo hi"], { host : "localhost" })
const promise = cockpit.spawn(["/bin/sh", "-c", "echo hi"], { host: "localhost" })
.then(resp => {
assert.equal(resp, "hi\n", "framed channel got output");
})
@ -67,7 +67,7 @@ function child_frame() {
const channel = cockpit.channel({
payload: "echo",
binary: true,
host : "localhost"
host: "localhost"
});
channel.addEventListener("message", function(ev, payload) {
assert.equal(typeof payload[0], "number", "binary channel got a byte array");

View File

@ -79,7 +79,7 @@ export class ShutdownModal extends React.Component {
}
updateDate(value, dateObject) {
this.setState({ date : value, dateObject }, this.calculate);
this.setState({ date: value, dateObject }, this.calculate);
}
updateTime(value, hour, minute) {

View File

@ -948,7 +948,7 @@ function Channel(options) {
if (!options)
options = { };
else if (typeof options == "string")
options = { problem : options };
options = { problem: options };
options.command = "close";
options.channel = id;

View File

@ -483,28 +483,28 @@ export function NetworkManagerModel() {
function get_ip(first, addr_from_nm, route_from_nm, ip_to_text) {
return {
method: get(first, "method", "auto"),
ignore_auto_dns: get(first, "ignore-auto-dns", false),
method: get(first, "method", "auto"),
ignore_auto_dns: get(first, "ignore-auto-dns", false),
ignore_auto_routes: get(first, "ignore-auto-routes", false),
addresses: get(first, "addresses", []).map(addr_from_nm),
dns: get(first, "dns", []).map(ip_to_text),
dns_search: get(first, "dns-search", []),
routes: get(first, "routes", []).map(route_from_nm)
addresses: get(first, "addresses", []).map(addr_from_nm),
dns: get(first, "dns", []).map(ip_to_text),
dns_search: get(first, "dns-search", []),
routes: get(first, "routes", []).map(route_from_nm)
};
}
const result = {
connection: {
type: get("connection", "type"),
uuid: get("connection", "uuid"),
type: get("connection", "type"),
uuid: get("connection", "uuid"),
interface_name: get("connection", "interface-name"),
timestamp: get("connection", "timestamp", 0),
id: get("connection", "id", _("Unknown")),
autoconnect: get("connection", "autoconnect", true),
timestamp: get("connection", "timestamp", 0),
id: get("connection", "id", _("Unknown")),
autoconnect: get("connection", "autoconnect", true),
autoconnect_members:
get("connection", "autoconnect-slaves", -1),
member_type: get("connection", "slave-type"),
group: get("connection", "master")
member_type: get("connection", "slave-type"),
group: get("connection", "master")
}
};
@ -525,7 +525,7 @@ export function NetworkManagerModel() {
https://www.kernel.org/doc/Documentation/networking/bonding.txt
*/
result.bond = {
options: { ...get("bond", "options", { }) },
options: { ...get("bond", "options", { }) },
interface_name: get("bond", "interface-name")
};
}
@ -540,39 +540,39 @@ export function NetworkManagerModel() {
if (settings.team) {
result.team = {
config: JSON_parse_carefully(get("team", "config", "{}")),
config: JSON_parse_carefully(get("team", "config", "{}")),
interface_name: get("team", "interface-name")
};
}
if (settings["team-port"] || result.connection.member_type == "team") {
result.team_port = { config: JSON_parse_carefully(get("team-port", "config", "{}")), };
result.team_port = { config: JSON_parse_carefully(get("team-port", "config", "{}")), };
}
if (settings.bridge) {
result.bridge = {
interface_name: get("bridge", "interface-name"),
stp: get("bridge", "stp", true),
priority: get("bridge", "priority", 32768),
forward_delay: get("bridge", "forward-delay", 15),
hello_time: get("bridge", "hello-time", 2),
max_age: get("bridge", "max-age", 20),
ageing_time: get("bridge", "ageing-time", 300)
stp: get("bridge", "stp", true),
priority: get("bridge", "priority", 32768),
forward_delay: get("bridge", "forward-delay", 15),
hello_time: get("bridge", "hello-time", 2),
max_age: get("bridge", "max-age", 20),
ageing_time: get("bridge", "ageing-time", 300)
};
}
if (settings["bridge-port"] || result.connection.member_type == "bridge") {
result.bridge_port = {
priority: get("bridge-port", "priority", 32),
path_cost: get("bridge-port", "path-cost", 100),
hairpin_mode: get("bridge-port", "hairpin-mode", false)
priority: get("bridge-port", "priority", 32),
path_cost: get("bridge-port", "path-cost", 100),
hairpin_mode: get("bridge-port", "hairpin-mode", false)
};
}
if (settings.vlan) {
result.vlan = {
parent: get("vlan", "parent"),
id: get("vlan", "id"),
parent: get("vlan", "parent"),
id: get("vlan", "id"),
interface_name: get("vlan", "interface-name")
};
}
@ -823,7 +823,7 @@ export function NetworkManagerModel() {
],
props: {
Addresses: { conv: conv_Array(ip4_address_from_nm), def: [] }
Addresses: { conv: conv_Array(ip4_address_from_nm), def: [] }
}
};
@ -833,7 +833,7 @@ export function NetworkManagerModel() {
],
props: {
Addresses: { conv: conv_Array(ip6_address_from_nm), def: [] }
Addresses: { conv: conv_Array(ip6_address_from_nm), def: [] }
}
};
@ -843,7 +843,7 @@ export function NetworkManagerModel() {
],
props: {
Unsaved: { }
Unsaved: { }
},
signals: {
@ -945,9 +945,9 @@ export function NetworkManagerModel() {
],
props: {
Connection: { conv: conv_Object(type_Connection) },
Ip4Config: { conv: conv_Object(type_Ipv4Config) },
Ip6Config: { conv: conv_Object(type_Ipv6Config) }
Connection: { conv: conv_Object(type_Connection) },
Ip4Config: { conv: conv_Object(type_Ipv4Config) },
Ip6Config: { conv: conv_Object(type_Ipv6Config) }
// See below for "Group"
},
@ -972,22 +972,22 @@ export function NetworkManagerModel() {
],
props: {
DeviceType: { conv: device_type_to_symbol },
Interface: { },
StateText: { prop: "State", conv: device_state_to_text, def: _("Unknown") },
State: { },
HwAddress: { },
DeviceType: { conv: device_type_to_symbol },
Interface: { },
StateText: { prop: "State", conv: device_state_to_text, def: _("Unknown") },
State: { },
HwAddress: { },
AvailableConnections: { conv: conv_Array(conv_Object(type_Connection)), def: [] },
ActiveConnection: { conv: conv_Object(type_ActiveConnection) },
Ip4Config: { conv: conv_Object(type_Ipv4Config) },
Ip6Config: { conv: conv_Object(type_Ipv6Config) },
Udi: { trigger: refresh_udev },
IdVendor: { def: "" },
IdModel: { def: "" },
Driver: { def: "" },
Carrier: { def: true },
Speed: { },
Managed: { def: false },
ActiveConnection: { conv: conv_Object(type_ActiveConnection) },
Ip4Config: { conv: conv_Object(type_Ipv4Config) },
Ip6Config: { conv: conv_Object(type_Ipv6Config) },
Udi: { trigger: refresh_udev },
IdVendor: { def: "" },
IdModel: { def: "" },
Driver: { def: "" },
Carrier: { def: true },
Speed: { },
Managed: { def: false },
// See below for "Members"
},
@ -1102,7 +1102,7 @@ export function NetworkManagerModel() {
],
props: {
Connections: { conv: conv_Array(conv_Object(type_Connection)), def: [] }
Connections: { conv: conv_Array(conv_Object(type_Connection)), def: [] }
},
prototype: {
@ -1155,12 +1155,12 @@ export function NetworkManagerModel() {
],
props: {
Version: { },
Version: { },
Devices: {
conv: conv_Array(conv_Object(type_Device)),
def: []
},
ActiveConnections: { conv: conv_Array(conv_Object(type_ActiveConnection)), def: [] }
ActiveConnections: { conv: conv_Array(conv_Object(type_ActiveConnection)), def: [] }
},
prototype: {

View File

@ -698,7 +698,7 @@ class ChangeAuth extends React.Component {
return this.props.try2Connect(this.props.full_address, options)
.then(() => {
if (machine)
return this.props.machines_ins.change(machine.address, { user : user });
return this.props.machines_ins.change(machine.address, { user: user });
else
return Promise.resolve();
})

View File

@ -280,10 +280,10 @@ function MachinesIndex(index_options, machines, loader) {
}
const new_item = Object.assign({}, item);
new_item.keyword = { score:-1 };
new_item.keyword = { score: -1 };
if (!term)
return new_item;
const best_keyword = new_item.keywords.reduce(keyword_relevance, { score:-1 });
const best_keyword = new_item.keywords.reduce(keyword_relevance, { score: -1 });
if (best_keyword.score > -1) {
new_item.keyword = best_keyword;
return new_item;
@ -327,7 +327,7 @@ function MachinesIndex(index_options, machines, loader) {
name: _("Apps"),
items: compiled.ordered("dashboard"),
}, {
name: _("System"),
name: _("System"),
items: compiled.ordered("menu"),
}, {
name: _("Tools"),

View File

@ -85,7 +85,7 @@ QUnit.test("merge several JSON files", function (assert) {
assert,
{
"01-green.json": '{"green": {"visible": true, "address": "1.2.3.4"}}',
"02-blue.json": '{"blue": {"address": "9.8.7.6"}}',
"02-blue.json": '{"blue": {"address": "9.8.7.6"}}',
"09-webui.json": '{"green": {"visible": false}, ' +
' "blue": {"user": "joe"}, ' +
' "yellow": {"address": "fe80::1", "user": "sue"}}'
@ -111,21 +111,21 @@ QUnit.test("merge JSON files with errors", function (assert) {
machinesParseTest(
assert,
{
"01-valid.json": '{"green": {"visible": true, "address": "1.2.3.4"}}',
"02-syntax.json": '[a',
"03-toptype.json": '["green"]',
"04-toptype.json": '{"green": ["visible"]}',
"05-valid.json": '{"blue": {"address": "fe80::1"}}',
"01-valid.json": '{"green": {"visible": true, "address": "1.2.3.4"}}',
"02-syntax.json": '[a',
"03-toptype.json": '["green"]',
"04-toptype.json": '{"green": ["visible"]}',
"05-valid.json": '{"blue": {"address": "fe80::1"}}',
// goodprop should still be considered
"06-proptype.json": '{"green": {"visible": [], "address": {"bar": null}, "goodprop": "yeah"}}',
"07-valid.json": '{"green": {"user": "joe"}}',
"08-empty.json": ''
"07-valid.json": '{"green": {"user": "joe"}}',
"08-empty.json": ''
},
{
green: {
address: { t: "s", v: "1.2.3.4" },
visible: { t: "b", v: true },
user: { t: "s", v: "joe" },
address: { t: "s", v: "1.2.3.4" },
visible: { t: "b", v: true },
user: { t: "s", v: "joe" },
goodprop: { t: "s", v: "yeah" },
},
blue: {
@ -177,7 +177,7 @@ QUnit.test("add host to existing map", function (assert) {
{ visible: cockpit.variant('b', false), address: cockpit.variant('s', "9.8.7.6") },
{
green: { address: "1.2.3.4", visible: true },
blue: { address: "9.8.7.6", visible: false }
blue: { address: "9.8.7.6", visible: false }
});
});

View File

@ -70,7 +70,7 @@ function jwk_b64_encode(bytes) {
function compute_thp(jwk) {
const REQUIRED_ATTRS = {
RSA: ['kty', 'p', 'd', 'q', 'dp', 'dq', 'qi', 'oth'],
EC: ['kty', 'crv', 'x', 'y'],
EC: ['kty', 'crv', 'x', 'y'],
oct: ['kty', 'k'],
};

View File

@ -52,8 +52,8 @@ export class LockedCryptoPanel extends React.Component {
return {
props: { path, client, key: path },
columns: [
{ title: name },
{ title: block_name(block) },
{ title: name },
{ title: block_name(block) },
]
};
}

View File

@ -1022,9 +1022,9 @@ export const SizeSlider = (tag, title, options) => {
export const BlockingMessage = (usage) => {
const usage_desc = {
pvol: _("physical volume of LVM2 volume group"),
mdraid: _("member of RAID device"),
vdo: _("backing device for VDO device"),
pvol: _("physical volume of LVM2 volume group"),
mdraid: _("member of RAID device"),
vdo: _("backing device for VDO device"),
"stratis-pool-member": _("member of Stratis pool")
};
@ -1048,7 +1048,7 @@ export const BlockingMessage = (usage) => {
columns={[
{ title: _("Device") },
{ title: _("Location") },
{ title: _("Use") }
{ title: _("Use") }
]}
rows={rows} />
</div>);
@ -1126,8 +1126,8 @@ export const TeardownMessage = (usage) => {
columns={[
{ title: _("Device") },
{ title: _("Location") },
{ title: _("Action") },
{ title: "" }
{ title: _("Action") },
{ title: "" }
]}
rows={rows} />
</div>);

View File

@ -177,7 +177,7 @@ export class FilesystemsPanel extends React.Component {
{ title: _("Source"), sortable: true },
{ title: _("Type"), sortable: true },
{ title: _("Mount"), sortable: true },
{ title: _("Size") }
{ title: _("Size") }
]}
rows={mounts.concat(flatten(pools))} />
</OptionalPanel>

View File

@ -39,50 +39,50 @@ const _ = cockpit.gettext;
*/
const descriptions = {
'ata-smart-selftest': _("SMART self-test of $target"),
'drive-eject': _("Ejecting $target"),
'encrypted-unlock': _("Unlocking $target"),
'encrypted-lock': _("Locking $target"),
'encrypted-modify': _("Modifying $target"),
'encrypted-resize': _("Resizing $target"),
'swapspace-start': _("Starting swapspace $target"),
'swapspace-stop': _("Stopping swapspace $target"),
'filesystem-mount': _("Mounting $target"),
'filesystem-unmount': _("Unmounting $target"),
'filesystem-modify': _("Modifying $target"),
'filesystem-resize': _("Resizing $target"),
'filesystem-check': _("Checking $target"),
'filesystem-repair': _("Repairing $target"),
'format-erase': _("Erasing $target"),
'format-mkfs': _("Creating filesystem on $target"),
'loop-setup': _("Setting up loop device $target"),
'partition-modify': _("Modifying $target"),
'partition-delete': _("Deleting $target"),
'partition-create': _("Creating partition $target"),
cleanup: _("Cleaning up for $target"),
'ata-secure-erase': _("Securely erasing $target"),
'ata-enhanced-secure-erase': _("Very securely erasing $target"),
'md-raid-stop': _("Stopping RAID device $target"),
'md-raid-start': _("Starting RAID device $target"),
'md-raid-fault-device': _("Marking $target as faulty"),
'md-raid-remove-device': _("Removing $target from RAID device"),
'md-raid-create': _("Creating RAID device $target"),
'mdraid-check-job': _("Checking RAID device $target"),
'mdraid-repair-job': _("Checking and repairing RAID device $target"),
'mdraid-recover-job': _("Recovering RAID device $target"),
'mdraid-sync-job': _("Synchronizing RAID device $target"),
'lvm-lvol-delete': _("Deleting $target"),
'lvm-lvol-activate': _("Activating $target"),
'lvm-lvol-deactivate': _("Deactivating $target"),
'lvm-lvol-snapshot': _("Creating snapshot of $target"),
'lvm-vg-create': _("Creating LVM2 volume group $target"),
'lvm-vg-delete': _("Deleting LVM2 volume group $target"),
'lvm-vg-add-device': _("Adding physical volume to $target"),
'lvm-vg-rem-device': _("Removing physical volume from $target"),
'lvm-vg-empty-device': _("Emptying $target"),
'lvm-vg-create-volume': _("Creating logical volume $target"),
'lvm-vg-rename': _("Renaming $target"),
'lvm-vg-resize': _("Resizing $target")
'ata-smart-selftest': _("SMART self-test of $target"),
'drive-eject': _("Ejecting $target"),
'encrypted-unlock': _("Unlocking $target"),
'encrypted-lock': _("Locking $target"),
'encrypted-modify': _("Modifying $target"),
'encrypted-resize': _("Resizing $target"),
'swapspace-start': _("Starting swapspace $target"),
'swapspace-stop': _("Stopping swapspace $target"),
'filesystem-mount': _("Mounting $target"),
'filesystem-unmount': _("Unmounting $target"),
'filesystem-modify': _("Modifying $target"),
'filesystem-resize': _("Resizing $target"),
'filesystem-check': _("Checking $target"),
'filesystem-repair': _("Repairing $target"),
'format-erase': _("Erasing $target"),
'format-mkfs': _("Creating filesystem on $target"),
'loop-setup': _("Setting up loop device $target"),
'partition-modify': _("Modifying $target"),
'partition-delete': _("Deleting $target"),
'partition-create': _("Creating partition $target"),
cleanup: _("Cleaning up for $target"),
'ata-secure-erase': _("Securely erasing $target"),
'ata-enhanced-secure-erase': _("Very securely erasing $target"),
'md-raid-stop': _("Stopping RAID device $target"),
'md-raid-start': _("Starting RAID device $target"),
'md-raid-fault-device': _("Marking $target as faulty"),
'md-raid-remove-device': _("Removing $target from RAID device"),
'md-raid-create': _("Creating RAID device $target"),
'mdraid-check-job': _("Checking RAID device $target"),
'mdraid-repair-job': _("Checking and repairing RAID device $target"),
'mdraid-recover-job': _("Recovering RAID device $target"),
'mdraid-sync-job': _("Synchronizing RAID device $target"),
'lvm-lvol-delete': _("Deleting $target"),
'lvm-lvol-activate': _("Activating $target"),
'lvm-lvol-deactivate': _("Deactivating $target"),
'lvm-lvol-snapshot': _("Creating snapshot of $target"),
'lvm-vg-create': _("Creating LVM2 volume group $target"),
'lvm-vg-delete': _("Deleting LVM2 volume group $target"),
'lvm-vg-add-device': _("Adding physical volume to $target"),
'lvm-vg-rem-device': _("Removing physical volume from $target"),
'lvm-vg-empty-device': _("Emptying $target"),
'lvm-vg-create-volume': _("Creating logical volume $target"),
'lvm-vg-rename': _("Renaming $target"),
'lvm-vg-resize': _("Resizing $target")
};
function make_description(client, job) {

View File

@ -108,11 +108,11 @@ class MDRaidSidebar extends React.Component {
function state_text(state) {
return {
faulty: _("Failed"),
in_sync: _("In sync"),
spare: active_state[1] < 0 ? _("Spare") : _("Recovering"),
faulty: _("Failed"),
in_sync: _("In sync"),
spare: active_state[1] < 0 ? _("Spare") : _("Recovering"),
write_mostly: _("Write-mostly"),
blocked: _("Blocked")
blocked: _("Blocked")
}[state] || cockpit.format(_("Unknown ($0)"), state);
}

View File

@ -101,7 +101,7 @@ export class NFSPanel extends React.Component {
columns={[
{ title: _("Server"), sortable: true },
{ title: _("Mount point"), sortable: true },
{ title: _("Size") }
{ title: _("Size") }
]}
rows={mounts} />
</OptionalPanel>

View File

@ -204,7 +204,7 @@ const StratisPoolSidebar = ({ client, pool }) => {
desc = cockpit.format(_("$0 of unknown tier"),
fmt_size(Number(blockdev.TotalPhysicalSize)));
return { client, block, detail: desc, key:blockdev.path };
return { client, block, detail: desc, key: blockdev.path };
}
const actions = (

View File

@ -143,9 +143,9 @@ export function validate_lvm2_name(name) {
export function validate_fsys_label(label, type) {
const fs_label_max = {
xfs: 12,
ext4: 16,
vfat: 11,
xfs: 12,
ext4: 16,
vfat: 11,
ntfs: 128,
};

View File

@ -210,7 +210,7 @@ const PageSystemInformationChangeHostname = () => {
const [error, set_error] = useState([]);
useInit(() => {
const client = cockpit.dbus('org.freedesktop.hostname1', { superuser : "try" });
const client = cockpit.dbus('org.freedesktop.hostname1', { superuser: "try" });
const hostname_proxy = client.proxy();
hostname_proxy.wait()

View File

@ -119,22 +119,22 @@ function validate_username(username, accounts) {
function suggest_username(realname) {
function remove_diacritics(str) {
const translate_table = {
a : '[àáâãäå]',
ae: 'æ',
c : '[čç]',
d : 'ď',
e : '[èéêë]',
i : '[íìïî]',
l : '[ĺľ]',
n : '[ňñ]',
o : '[òóôõö]',
oe: 'œ',
r : '[ŕř]',
s : 'š',
t : 'ť',
u : '[ùúůûűü]',
y : '[ýÿ]',
z : 'ž',
a: '[àáâãäå]',
ae: 'æ',
c: '[čç]',
d: 'ď',
e: '[èéêë]',
i: '[íìïî]',
l: '[ĺľ]',
n: '[ňñ]',
o: '[òóôõö]',
oe: 'œ',
r: '[ŕř]',
s: 'š',
t: 'ť',
u: '[ùúůûűü]',
y: '[ýÿ]',
z: 'ž',
};
for (const i in translate_table)
str = str.replace(new RegExp(translate_table[i], 'g'), i);

View File

@ -54,10 +54,10 @@ export function AccountRoles({ account, groups, currently_logged_in }) {
}
const role_groups = {
wheel: _("Server administrator"),
sudo: _("Server administrator"),
docker: _("Container administrator"),
weldr: _("Image builder")
wheel: _("Server administrator"),
sudo: _("Server administrator"),
docker: _("Container administrator"),
weldr: _("Image builder")
};
const roles = [];

View File

@ -119,7 +119,7 @@ export function account_expiration_dialog(account, expire_date) {
} else
prog.push("");
prog.push(account.name);
return cockpit.spawn(prog, { superuser : true, err: "message" });
return cockpit.spawn(prog, { superuser: true, err: "message" });
} else {
update();
return Promise.reject();

View File

@ -278,7 +278,7 @@ export function reset_password_dialog(account) {
style: "primary",
clicked: () => {
return cockpit.spawn(["/usr/bin/passwd", "-e", account.name],
{ superuser : true, err: "message" });
{ superuser: true, err: "message" });
}
}
]