Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

39 changes: 39 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

const eslint = require('@eslint/js');
const { defineConfig } = require('eslint/config');
const globals = require('globals');

module.exports = defineConfig(
{
ignores: ['build/**'],
},
eslint.configs.recommended,
{
languageOptions: {
sourceType: 'commonjs',
globals: {
...globals.node,
},
},
rules: {
curly: ['error', 'multi-line'],
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
{
files: ['test/**/*.js'],
languageOptions: {
globals: {
...globals.mocha,
},
},
},
);
22 changes: 13 additions & 9 deletions lib/BoundCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,11 @@ class BoundCluster {
* @param {number} [options.startValue=0]
* @param {number} [options.maxResults=250]
* @returns {Promise<DiscoverAttributesResponse>}
*
* TODO: paginate. startValue and maxResults are ignored, so every call answers with all
* attributes and lastResponse true, whatever the device asked for.
*/
async discoverAttributes({ startValue = 0, maxResults = 250 } = {}) {
async discoverAttributes({ startValue: _startValue = 0, maxResults: _maxResults = 250 } = {}) {
const attributes = Object.values(this.cluster.attributesById)
.filter(attr => attr.type instanceof ZCLDataType && getPropertyDescriptor(this, attr.name));

Expand Down Expand Up @@ -263,8 +266,11 @@ class BoundCluster {
* @param {number} [options.startValue=0]
* @param {number} [options.maxResults=250]
* @returns {Promise<DiscoverAttributesExtendedResponse>}
*
* TODO: paginate. startValue and maxResults are ignored, so every call answers with all
* attributes and lastResponse true, whatever the device asked for.
*/
async discoverAttributesExtended({ startValue = 0, maxResults = 250 } = {}) {
async discoverAttributesExtended({ startValue: _startValue = 0, maxResults: _maxResults = 250 } = {}) {
const attributes = Object.values(this.cluster.attributesById)
.filter(attr => attr.type instanceof ZCLDataType && getPropertyDescriptor(this, attr.name));

Expand Down Expand Up @@ -347,10 +353,8 @@ class BoundCluster {
debug(this.logId, 'received command', command.name, args);
const result = await this[command.name](args, meta, frame, rawFrame);
if (command.response && command.response.args) {
// eslint-disable-next-line new-cap
return [command.response.id, new command.response.args(result), command.response];
}
// eslint-disable-next-line consistent-return
return;
}
}
Expand All @@ -359,14 +363,14 @@ class BoundCluster {
}

// TODO: implement when needed
async writeAttributesAtomic(args) {
async writeAttributesAtomic(_args) {
throw new Error('not_implemented');
// TODO: actually make atomic, capture current state of attrs, exec and restore upon failure
// return writeAttributesAtomic(args);
}

// TODO: implement when needed
async writeAttributesNoResponse(args) {
async writeAttributesNoResponse(_args) {
throw new Error('not_implemented');
// TODO: actually disable response
// return writeAttributesAtomic(args);
Expand Down Expand Up @@ -396,7 +400,7 @@ class BoundCluster {

// TODO: implement when needed
async readReportingConfiguration({
attributes = {
attributes: _attributes = {
// direction,
// attributeId,
},
Expand All @@ -407,7 +411,7 @@ class BoundCluster {

// TODO: implement when needed
async readAttributesStructured({
attributes = [{
attributes: _attributes = [{
// attributeId,
// indexPath,
}],
Expand All @@ -418,7 +422,7 @@ class BoundCluster {

// TODO: implement when needed
async writeAttributesStructured({
attributes = [{
attributes: _attributes = [{
// attributeId,
// indexPath,
// dataTypeId,
Expand Down
6 changes: 0 additions & 6 deletions lib/Cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ class Cluster extends EventEmitter {
*/
async configureReporting(attributes = {}, opts) {
const req = [];
// eslint-disable-next-line guard-for-in,no-restricted-syntax
for (const attributeName in attributes) {
const attr = this.constructor.attributes[attributeName];
if (!attr) throw new TypeError(`${attributeName} Does not exist (${this.constructor.name})`);
Expand Down Expand Up @@ -809,10 +808,8 @@ class Cluster extends EventEmitter {
if (handler) {
const response = await handler.call(this, args, meta, frame, rawFrame);
if (command.response && command.response.args) {
// eslint-disable-next-line new-cap
return [command.response.id, new command.response.args(response), command.response];
}
// eslint-disable-next-line consistent-return
return;
}
}
Expand Down Expand Up @@ -991,7 +988,6 @@ class Cluster extends EventEmitter {
*/
static removeCluster(clusterIdOrName) {
if (this.clusters[clusterIdOrName]) {
// eslint-disable-next-line no-shadow
const Cluster = this.clusters[clusterIdOrName];
delete this.clusters[Cluster.NAME];
delete this.clusters[Cluster.ID];
Expand Down Expand Up @@ -1089,7 +1085,6 @@ class Cluster extends EventEmitter {
return r;
}, {});

// eslint-disable-next-line guard-for-in,no-restricted-syntax
for (const cmdName in commands) {
Object.defineProperty(proto, cmdName, {
value: {
Expand Down Expand Up @@ -1220,7 +1215,6 @@ class Cluster extends EventEmitter {
if (response.status !== 'SUCCESS') {
throw new Error(response.status);
}
// eslint-disable-next-line consistent-return
return;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class Endpoint extends EventEmitter {
if (!success && typeof status === 'string') {
try {
ZCLDataTypes.enum8Status.toBuffer(responseFrame.data, status, 1);
} catch (err) {
} catch {
// Ignore invalid status codes and keep the default FAILURE status.
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class Node extends EventEmitter {
*/
async handleFrame(endpointId, clusterId, frame, meta) {
if (!Buffer.isBuffer(frame)) {
// eslint-disable-next-line prefer-rest-params
debug(`${this.getLogId(endpointId, clusterId)}, invalid frame received`, arguments, frame);
return;
}
Expand Down
1 change: 0 additions & 1 deletion lib/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const debug = require('debug')('zigbee-clusters');
function getPropertyDescriptor(obj, name) {
if (!obj) return;

// eslint-disable-next-line consistent-return
return Object.getOwnPropertyDescriptor(obj, name)
|| getPropertyDescriptor(Object.getPrototypeOf(obj), name);
}
Expand Down
1 change: 0 additions & 1 deletion lib/zclFrames.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ const ZCLConfigureReportingRecords = ({ withStatus } = {}) => new ZCLDataType(
continue;
}

// eslint-disable-next-line default-case
switch (direction) {
// Only if the direction is 'reported' are the minInterval/maxInterval and minChange
// properties available
Expand Down
2 changes: 0 additions & 2 deletions lib/zclTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const ZCLDataType = DataType;
const ZCLDataTypes = DataTypes;
const ZCLStruct = Struct;

/* eslint-disable */
ZCLDataTypes.enum8Status = ZCLDataTypes.enum8({
SUCCESS : 0x00,
FAILURE : 0x01,
Expand Down Expand Up @@ -44,7 +43,6 @@ ZCLDataTypes.enum8Status = ZCLDataTypes.enum8({
CALIBRATION_ERROR : 0xc2,
UNSUPPORTED_CLUSTER : 0xc3,
});
/* eslint-enable */

module.exports = {
ZCLDataTypes,
Expand Down
Loading
Loading