Skip to content

Commit

Permalink
pkg: make JavaScript keyspacing consistent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jelly committed Nov 9, 2022
1 parent 35b9360 commit 58b95f1
Show file tree
Hide file tree
Showing 24 changed files with 159 additions and 160 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/base1/test-browser-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion pkg/base1/test-chan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions pkg/base1/test-framed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
})
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion pkg/lib/cockpit-components-shutdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/lib/cockpit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
102 changes: 51 additions & 51 deletions pkg/networkmanager/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
};

Expand All @@ -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")
};
}
Expand All @@ -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")
};
}
Expand Down Expand Up @@ -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: [] }
}
};

Expand All @@ -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: [] }
}
};

Expand All @@ -843,7 +843,7 @@ export function NetworkManagerModel() {
],

props: {
Unsaved: { }
Unsaved: { }
},

signals: {
Expand Down Expand Up @@ -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"
},

Expand All @@ -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"
},

Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/hosts_dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/shell/indexes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
Expand Down
24 changes: 12 additions & 12 deletions pkg/shell/machines/test-machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}'
Expand All @@ -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: {
Expand Down Expand Up @@ -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 }
});
});

Expand Down
2 changes: 1 addition & 1 deletion pkg/storaged/crypto-keyslots.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
};

Expand Down
4 changes: 2 additions & 2 deletions pkg/storaged/crypto-panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
]
};
}
Expand Down
Loading

0 comments on commit 58b95f1

Please sign in to comment.