Skip to content

Commit

Permalink
style: set prettier trailingComma to all
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticrake committed Nov 8, 2023
1 parent ee2fdfe commit 0b7aec5
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "all"
}
18 changes: 9 additions & 9 deletions examples/multi-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,71 +11,71 @@ devices.push(
address: '10.0.0.200',
model: 'hs100',
data: { alias: 'Mock HS100', mac: '50:c7:bf:8f:58:18', deviceId: 'A100' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.201',
model: 'hs105',
data: { alias: 'Mock HS105', mac: '50:c7:bf:d8:bf:d4', deviceId: 'A105' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.202',
model: 'hs110',
data: { alias: 'Mock HS110', mac: '50:c7:bf:0d:91:8c', deviceId: 'A110' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.203',
model: 'hs200',
data: { alias: 'Mock HS200', mac: '50:c7:bf:46:b4:24', deviceId: 'A200' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.204',
model: 'hs220',
data: { alias: 'Mock HS220', mac: '50:c7:bf:47:b5:25', deviceId: 'A220' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.205',
model: 'hs300',
data: { alias: 'Mock HS300', mac: '50:c7:bf:48:b6:26', deviceId: 'A300' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.206',
model: 'lb100',
data: { alias: 'Mock LB100', mac: '50:c7:bf:49:ca:42', deviceId: 'BB100' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.207',
model: 'lb120',
data: { alias: 'Mock LB120', mac: '50:c7:bf:90:9b:da', deviceId: 'BB120' },
})
}),
);
devices.push(
new Device({
port: 9999,
address: '10.0.0.208',
model: 'lb130',
data: { alias: 'Mock LB130', mac: '50:c7:bf:b1:04:d3', deviceId: 'BB130' },
})
}),
);

devices.forEach((d) => {
Expand Down
8 changes: 4 additions & 4 deletions src/device-networking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class DeviceNetworking extends EventEmitter {
this.model,
this.responseDelay,
rinfo.port,
rinfo.address
rinfo.address,
);
logUdp(responseForLog);
this.emit('response', {
Expand All @@ -112,7 +112,7 @@ export default class DeviceNetworking extends EventEmitter {
0,
response.length,
rinfo.port,
rinfo.address
rinfo.address,
);
});
}
Expand All @@ -123,7 +123,7 @@ export default class DeviceNetworking extends EventEmitter {
'[%s] TCP DATA',
this.model,
socket.remoteAddress,
socket.remotePort
socket.remotePort,
);
const decryptedMsg = decryptWithHeader(msg).toString('utf8');
logTcp(decryptedMsg);
Expand Down Expand Up @@ -157,7 +157,7 @@ export default class DeviceNetworking extends EventEmitter {
'[%s] TCP responding, delay:%s,',
this.model,
this.responseDelay,
socket.address()
socket.address(),
);
logTcp(responseForLog);
this.emit('response', {
Expand Down
8 changes: 4 additions & 4 deletions src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ class Device implements DeviceType {
customizerFn?: (
moduleName: string,
methodName: string,
methodResponse: MethodResponse
) => MethodResponse
methodResponse: MethodResponse,
) => MethodResponse,
) {
this.#deviceInfo.reset();

let responseUnencrypted: Buffer | string = processCommands(
msg,
this.api,
this.#deviceInfo.constructor.errors,
customizerFn
customizerFn,
);

let response = encryptFn(responseUnencrypted);
Expand Down Expand Up @@ -209,7 +209,7 @@ class Device implements DeviceType {
});
}
return methodResponse;
}
},
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/devices/hs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Hs extends Base {
this.data.system.sysinfo.longitude = longitude;
this.data.system.sysinfo.latitude_i = latitude_i;
this.data.system.sysinfo.longitude_i = longitude_i;
}
},
),
set_led_off: errCode(({ off }) => {
this.data.system.sysinfo.led_off = off;
Expand Down Expand Up @@ -150,7 +150,7 @@ class Hs extends Base {
this.scheduleContext.daystat.day_list,
() => {
return utils.randomInt(0, 1440);
}
},
);
return { day_list };
}),
Expand All @@ -161,7 +161,7 @@ class Hs extends Base {
this.scheduleContext.daystat.day_list,
() => {
return utils.randomInt(0, 1440);
}
},
);
return { month_list };
}),
Expand Down Expand Up @@ -283,7 +283,7 @@ class Hs extends Base {
month,
key,
this.emeterContext.daystat.day_list,
defaultValue
defaultValue,
);
return { day_list };
}),
Expand All @@ -305,7 +305,7 @@ class Hs extends Base {
year,
key,
this.emeterContext.daystat.day_list,
defaultValue
defaultValue,
);
return { month_list };
}),
Expand Down
4 changes: 2 additions & 2 deletions src/devices/hs300.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class Hs300 extends Hs {

get children() {
return Object.keys(this.data.children).map(
(childId) => this.data.children[childId]
(childId) => this.data.children[childId],
);
}

get sysinfoChildren() {
return Object.keys(this.data.children).map(
(childId) => this.data.children[childId].sysinfo
(childId) => this.data.children[childId].sysinfo,
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/devices/kl.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Kl extends Base {
// eslint-disable-next-line no-unused-vars
({ year, month, mday, hour, min, sec }) => {
// TODO
}
},
);

this.api.netif = this.hs.api.netif;
Expand Down Expand Up @@ -118,12 +118,12 @@ class Kl extends Base {

this.data.system.sysinfo.light_state = pick(
this.data['smartlife.iot.lightStrip'].light_state,
['on_off', 'mode', 'hue', 'saturation', 'color_temp', 'brightness']
['on_off', 'mode', 'hue', 'saturation', 'color_temp', 'brightness'],
);

this.data.system.sysinfo.light_state.dft_on_state = pick(
this.data['smartlife.iot.lightStrip'].dft_on_state,
['mode', 'hue', 'saturation', 'color_temp', 'brightness']
['mode', 'hue', 'saturation', 'color_temp', 'brightness'],
);

return this.data.system.sysinfo;
Expand Down
2 changes: 1 addition & 1 deletion src/devices/lb.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Lb extends Base {
// eslint-disable-next-line no-unused-vars
({ year, month, mday, hour, min, sec }) => {
// TODO
}
},
);

this.api.netif = this.hs.api.netif;
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function processCommands(json, api, errors, customizerFn) {
method.results = customizerFn(
module.name,
method.name,
api[module.name][method.name](method.args)
api[module.name][method.name](method.args),
);
} else {
method.results = errors.METHOD_NOT_SUPPORT;
Expand Down Expand Up @@ -200,7 +200,7 @@ function getDayList(
month,
key,
dayListData = [],
defaultValue = undefined
defaultValue = undefined,
) {
const dayList = [];
if (year != null && month != null) {
Expand All @@ -212,7 +212,7 @@ function getDayList(
getDaysInMonth(year, month).forEach((day) => {
if (day > lastDay) return; // Don't return data for future dates
let entry = dayListData.find(
(dl) => dl.year === year && dl.month === month && dl.day === day
(dl) => dl.year === year && dl.month === month && dl.day === day,
);
if (entry == null) {
const def =
Expand All @@ -237,7 +237,7 @@ function getMonthList(year, key, dayListData = [], defaultValue = undefined) {
month,
key,
dayListData,
defaultValue
defaultValue,
).reduce((acc, val) => acc + val[key], 0);
monthList.push({ year, month, [key]: monthSum });
}
Expand Down
Loading

0 comments on commit 0b7aec5

Please sign in to comment.