Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Migrate to eslint 9 #7961

Merged
merged 13 commits into from
Sep 12, 2024
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default tseslint.config(
},
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'off', // TODO error
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/explicit-function-return-type': 'off', // TODO error
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': ['error', {args: 'none'}],
Expand Down
12 changes: 6 additions & 6 deletions scripts/modernExtendRefactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ project.getSourceFiles().forEach((sourceFile) => {
const evalOpts = Object.entries(eval(`(${opts})`));
for (const [key, value] of evalOpts) {
if (key === 'colorTempRange') {
// @ts-expect-error
// @ts-expect-error ignore
newOpts.colorTemp = {...newOpts.colorTemp, range: value};
Koenkk marked this conversation as resolved.
Show resolved Hide resolved
} else if (key === 'disableColorTempStartup') {
// @ts-expect-error
// @ts-expect-error ignore
newOpts.colorTemp = {...newOpts.colorTemp, startup: !value};
} else if (key === 'disablePowerOnBehavior') {
newOpts.powerOnBehavior = !value;
Expand All @@ -72,10 +72,10 @@ project.getSourceFiles().forEach((sourceFile) => {
} else if (key === 'disableHueEffects') {
newOpts.hueEffect = !value;
} else if (key === 'supportsHueAndSaturation' || key === 'preferHueAndSaturation') {
// @ts-expect-error
// @ts-expect-error ignore
newOpts.color = {...newOpts.color, modes: evalOpts.preferHueAndSaturation ? ['hs', 'xy'] : ['xy', 'hs']};
} else if (key === 'extraEffects') {
// @ts-expect-error
// @ts-expect-error ignore
newOpts.gradient = {...newOpts.gradient, extraEffects: value};
} else if (key === 'noConfigure') {
// ignore
Expand All @@ -89,10 +89,10 @@ project.getSourceFiles().forEach((sourceFile) => {
// if (key === 'turnsOffAtBrightness1') {
// newOpts.turnsOffAtBrightness1 = value;
// } else if (key === 'applyRedFix') {
// // @ts-expect-error
// // @ts-expect-error ignore
// newOpts.color = {...newOpts.color, applyRedFix: value};
// } else if (key === 'supportsEnhancedHue') {
// // @ts-expect-error
// // @ts-expect-error ignore
// newOpts.color = {...newOpts.color, enhancedHue: value};
// } else if (key === 'multiEndpoint' || key === 'disableDefaultResponse') {
// // ignore
Expand Down
2 changes: 1 addition & 1 deletion src/converters/fromZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,7 @@ const converters1 = {
convert: (model, msg, publish, options, meta) => {
const dp = msg.data[10];
const defaults = {motor_direction: 'FORWARD', motor_speed: 40};
// @ts-expect-error
// @ts-expect-error ignore
if ((msg.data[0] === 0x7a) & (msg.data[1] === 0xd1)) {
Koenkk marked this conversation as resolved.
Show resolved Hide resolved
const reportType = msg.data[12];
switch (dp) {
Expand Down
44 changes: 22 additions & 22 deletions src/converters/toZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const converters1 = {
} else {
zclData.hue = utils.mapNumberRange(hsvCorrected.hue, 0, 360, 0, 254);
}
// @ts-expect-error
// @ts-expect-error ignore
zclData.direction = value.direction || 0;
}

Expand All @@ -115,7 +115,7 @@ const converters1 = {

if (hsv.value !== null) {
// fallthrough to genLevelCtrl
// @ts-expect-error
// @ts-expect-error ignore
value.brightness = utils.mapNumberRange(hsvCorrected.value, 0, 100, 0, 254);
}

Expand All @@ -140,7 +140,7 @@ const converters1 = {
await entity.command(
'genLevelCtrl',
'moveToLevelWithOnOff',
// @ts-expect-error
// @ts-expect-error ignore
{level: Number(value.brightness), transtime: utils.getTransition(entity, key, meta).time},
utils.getOptions(meta.mapped, entity),
);
Expand Down Expand Up @@ -385,7 +385,7 @@ const converters2 = {
}
},
convertGet: async (entity, key, meta) => {
// @ts-expect-error
// @ts-expect-error ignore
const user = meta && meta.message && meta.message.pin_code ? meta.message.pin_code.user : undefined;
if (user === undefined) {
const max = utils.getMetaValue<number>(entity, meta.mapped, 'pinCodeCount');
Expand Down Expand Up @@ -437,7 +437,7 @@ const converters2 = {
);
},
convertGet: async (entity, key, meta) => {
// @ts-expect-error
// @ts-expect-error ignore
const user = meta && meta.message && meta.message.user_status ? meta.message.user_status.user : undefined;
const pinCodeCount = utils.getMetaValue<number>(entity, meta.mapped, 'pinCodeCount');
if (user === undefined) {
Expand Down Expand Up @@ -500,17 +500,17 @@ const converters2 = {
const strobeLevel = {low: 0, medium: 1, high: 2, very_high: 3};

const values = {
// @ts-expect-error
// @ts-expect-error ignore
mode: value.mode || 'emergency',
// @ts-expect-error
// @ts-expect-error ignore
level: value.level || 'medium',
// @ts-expect-error
// @ts-expect-error ignore
strobe: value.hasOwnProperty('strobe') ? value.strobe : true,
// @ts-expect-error
// @ts-expect-error ignore
duration: value.hasOwnProperty('duration') ? value.duration : 10,
// @ts-expect-error
// @ts-expect-error ignore
strobeDutyCycle: value.hasOwnProperty('strobe_duty_cycle') ? value.strobe_duty_cycle * 10 : 0,
// @ts-expect-error
// @ts-expect-error ignore
strobeLevel: value.hasOwnProperty('strobe_level') ? utils.getFromLookup(value.strobe_level, strobeLevel) : 1,
};

Expand Down Expand Up @@ -825,7 +825,7 @@ const converters2 = {
'lamp_burn_hours_trip_point',
]) {
try {
// @ts-expect-error
// @ts-expect-error ignore
result = {...result, ...(await entity.read('lightingBallastCfg', [utils.toCamelCase(attrName)]))};
} catch {
// continue regardless of error
Expand Down Expand Up @@ -1116,7 +1116,7 @@ const converters2 = {
try {
const attributeRead = await entity.read('genLevelCtrl', ['onLevel']);
if (attributeRead !== undefined) {
// @ts-expect-error
// @ts-expect-error ignore
onLevel = attributeRead['onLevel'];
}
} catch {
Expand Down Expand Up @@ -2784,9 +2784,9 @@ const converters2 = {

const zclData = {
brightness: globalStore.getValue(entity, 'brightness') || 100,
// @ts-expect-error
// @ts-expect-error ignore
hue: utils.mapNumberRange(meta.state.color.h, 0, 360, 0, 254) || 100,
// @ts-expect-error
// @ts-expect-error ignore
saturation: utils.mapNumberRange(meta.state.color.s, 0, 100, 0, 254) || 100,
transtime: 0,
};
Expand Down Expand Up @@ -3368,7 +3368,7 @@ const converters2 = {
let value = utils.getFromLookup(rawValue, lookup, Number(rawValue));

if (key == 'sensors_type') {
// @ts-expect-error
// @ts-expect-error ignore
value = utils.getFromLookup(rawValue, sensorsTypeLookup, Number(rawValue));
}

Expand Down Expand Up @@ -3437,7 +3437,7 @@ const converters2 = {
const modeOpenLookup = {never: '0', once: '1', always: '2', drop: '3'};
let value = utils.getFromLookup(rawValue, lookup, Number(rawValue));
if (key == 'mode') {
// @ts-expect-error
// @ts-expect-error ignore
value = utils.getFromLookup(rawValue, modeOpenLookup, Number(rawValue));
}
const payloads: KeyValueAny = {
Expand Down Expand Up @@ -3506,7 +3506,7 @@ const converters2 = {
const options = {
// Don't send a manufacturerCode (otherwise set in herdsman):
// https://github.com/Koenkk/zigbee-herdsman-converters/pull/2827
// @ts-expect-error
// @ts-expect-error ignore
manufacturerCode: null,
...utils.getOptions(meta.mapped, entity),
};
Expand Down Expand Up @@ -3563,11 +3563,11 @@ const converters2 = {
utils.saveSceneState(member, sceneid, groupid, meta.membersState[member.getDevice().ieeeAddr], scenename);
}
}
// @ts-expect-error
// @ts-expect-error ignore
} else if (response.status === 0) {
utils.saveSceneState(entity, sceneid, groupid, meta.state, scenename);
} else {
// @ts-expect-error
// @ts-expect-error ignore
throw new Error(`Scene add not successful ('${Zcl.Status[response.status]}')`);
}
logger.info('Successfully stored scene', NS);
Expand Down Expand Up @@ -3798,11 +3798,11 @@ const converters2 = {
utils.deleteSceneState(member, sceneid, groupid);
}
}
// @ts-expect-error
// @ts-expect-error ignore
} else if (response.status === 0) {
utils.deleteSceneState(entity, sceneid, groupid);
} else {
// @ts-expect-error
// @ts-expect-error ignore
throw new Error(`Scene remove not successful ('${Zcl.Status[response.status]}')`);
}
logger.info('Successfully removed scene', NS);
Expand Down
2 changes: 1 addition & 1 deletion src/devices/datek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const definitions: DefinitionWithExtend[] = [
attribute: {ID: 0x4000, type: 0x10},
},
];
// @ts-expect-error
// @ts-expect-error ignore
await endpoint.configureReporting('ssIasZone', payload, options);
await endpoint.read('ssIasZone', ['iasCieAddr', 'zoneState', 'zoneId']);
await endpoint.read('msOccupancySensing', ['pirOToUDelay']);
Expand Down
34 changes: 17 additions & 17 deletions src/devices/inovelli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const attributesToExposeList = (ATTRIBUTES: {[s: string]: Attribute}, exposesLis
.binary(
key,
ATTRIBUTES[key].readOnly ? ea.STATE_GET : ea.ALL,
// @ts-expect-error
// @ts-expect-error ignore
ATTRIBUTES[key].values.Enabled,
ATTRIBUTES[key].values.Disabled,
)
Expand Down Expand Up @@ -1256,7 +1256,7 @@ const tzLocal = {
[ATTRIBUTES[key].ID]: {
value:
ATTRIBUTES[key].displayType === 'enum'
? // @ts-expect-error
? // @ts-expect-error ignore
ATTRIBUTES[key].values[value]
: value,
type: ATTRIBUTES[key].dataType,
Expand Down Expand Up @@ -1311,13 +1311,13 @@ const tzLocal = {
'manuSpecificInovelli',
'ledEffect',
{
// @ts-expect-error
// @ts-expect-error ignore
effect: ledEffects[values.effect],
// @ts-expect-error
// @ts-expect-error ignore
color: Math.min(Math.max(0, values.color), 255),
// @ts-expect-error
// @ts-expect-error ignore
level: Math.min(Math.max(0, values.level), 100),
// @ts-expect-error
// @ts-expect-error ignore
duration: Math.min(Math.max(0, values.duration), 255),
},
{disableResponse: true, disableDefaultResponse: true},
Expand All @@ -1332,15 +1332,15 @@ const tzLocal = {
'manuSpecificInovelli',
'individualLedEffect',
{
// @ts-expect-error
// @ts-expect-error ignore
led: Math.min(Math.max(0, parseInt(values.led)), 7),
// @ts-expect-error
// @ts-expect-error ignore
effect: individualLedEffects[values.effect],
// @ts-expect-error
// @ts-expect-error ignore
color: Math.min(Math.max(0, values.color), 255),
// @ts-expect-error
// @ts-expect-error ignore
level: Math.min(Math.max(0, values.level), 100),
// @ts-expect-error
// @ts-expect-error ignore
duration: Math.min(Math.max(0, values.duration), 255),
},
{disableResponse: true, disableDefaultResponse: true},
Expand All @@ -1359,7 +1359,7 @@ const tzLocal = {
const transition = utils.getTransition(entity, 'brightness', meta);
const turnsOffAtBrightness1 = utils.getMetaValue(entity, meta.mapped, 'turnsOffAtBrightness1', 'allEqual', false);
let state = message.hasOwnProperty('state')
? // @ts-expect-error
? // @ts-expect-error ignore
message.state.toLowerCase()
: undefined;
let brightness = undefined;
Expand Down Expand Up @@ -1403,7 +1403,7 @@ const tzLocal = {
const payload = {level, transtime: transition.time};
await entity.command('genLevelCtrl', 'moveToLevelWithOnOff', payload, utils.getOptions(meta.mapped, entity));
const result = {state: {state: state.toUpperCase()}};
// @ts-expect-error
// @ts-expect-error ignore
if (state === 'on') result.state.brightness = level;
return result;
} else {
Expand All @@ -1415,10 +1415,10 @@ const tzLocal = {
}

const result = await inovelliOnOffConvertSet(entity, 'state', state, meta);
// @ts-expect-error
// @ts-expect-error ignore
result.readAfterWriteTime = 0;
if (result.state && result.state.state === 'ON' && meta.state.brightness === 0) {
// @ts-expect-error
// @ts-expect-error ignore
result.state.brightness = 1;
}

Expand Down Expand Up @@ -1450,7 +1450,7 @@ const tzLocal = {
},
readAfterWriteTime:
transition.time === 0
? // @ts-expect-error
? // @ts-expect-error ignore
defaultTransitionTime.rampRateOnToOffRemote * 100
: transition.time * 100, // need on speed
};
Expand Down Expand Up @@ -1693,7 +1693,7 @@ const tzLocal = {
* fallback to if a transition is not specified by passing 0xffff
*/
const inovelliOnOffConvertSet = async (entity: Zh.Endpoint | Zh.Group, key: string, value: unknown, meta: Tz.Meta) => {
// @ts-expect-error
// @ts-expect-error ignore
const state = meta.message.hasOwnProperty('state') ? meta.message.state.toLowerCase() : null;
utils.validateValue(state, ['toggle', 'off', 'on']);

Expand Down
2 changes: 1 addition & 1 deletion src/devices/kmpcil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const kmpcilConverters = {
if (msg.data.hasOwnProperty('batteryVoltage')) {
payload.voltage = msg.data['batteryVoltage'] * 100;
if (model.meta && model.meta.battery && model.meta.battery.voltageToPercentage) {
// @ts-expect-error
// @ts-expect-error ignore
payload.battery = utils.batteryVoltageToPercentage(payload.voltage, model.meta.battery.voltageToPercentage);
}
}
Expand Down
Loading
Loading