Skip to content

Commit ccc1843

Browse files
committed
Job FIX
1 parent cc0e3a6 commit ccc1843

File tree

7 files changed

+197
-149
lines changed

7 files changed

+197
-149
lines changed

.eslintignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
docs
2+
test
3+
lib/env/tools.js
4+
gulpfile.js
5+
test.json
6+
test.js
7+
test2.js
8+
test_plants.json
9+
testSharePlant.json

eslint.config.js .eslintrc.js

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
1-
21
module.exports = {
3-
files: ["**/*.js"],
4-
/*env: {
2+
env: {
53
browser: true,
64
es2017: true,
75
node: true,
86
mocha: true,
9-
},
7+
},
108
extends: ['eslint:recommended', 'airbnb-base', 'plugin:prettier/recommended'],
119
parserOptions: {
1210
ecmaVersion: 2018,
1311
ecmaFeatures: {
1412
impliedStrict: true,
1513
},
1614
sourceType: 'module',
17-
},*/
15+
},
1816
rules: {
1917
'no-use-before-define': ['error', { functions: false }],
2018
'no-continue': 'off',
2119
'no-param-reassign': ['error', { props: false }],
2220
},
23-
ignores: ["docs",
24-
"test",
25-
"lib/env/tools.js",
26-
"gulpfile.js",
27-
"test.json",
28-
"test.js",
29-
"test2.js",
30-
"test_plants.json",
31-
"testSharePlant.json"
32-
],
33-
3421
};

.github/workflows/test-and-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ jobs:
2222
if: contains(github.event.head_commit.message, '[skip ci]') == false
2323

2424
runs-on: ubuntu-latest
25-
25+
2626
strategy:
2727
matrix:
2828
node-version: [16.x, 18.x, 20.x]
29-
29+
3030
steps:
3131
- name: Checkout source Code
3232
uses: actions/checkout@v4

lib/growatt.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const https = require('https');
2323
const debugApi = require('debug')('growatt:api');
2424
const debugVerbose = require('debug')('growatt:verbose');
2525
const Axios = require('axios');
26-
const md5 = require('md5');
26+
const MD5 = require('md5');
2727
const QUEUE = require('./queue');
2828
const GROWATTTYPE = require('./growatttype');
2929
const PARSEIN = require('./parsein');
@@ -133,7 +133,7 @@ module.exports = class growatt {
133133
login(user, password) {
134134
return new Promise((resolve, reject) => {
135135
debugApi('login:', 'user:', user, 'password:', '*no*');
136-
const params = new Url.URLSearchParams({ account: user, password: '', validateCode: '', isReadPact: 0, passwordCrc: md5(password) });
136+
const params = new Url.URLSearchParams({ account: user, password: '', validateCode: '', isReadPact: 0, passwordCrc: MD5(password) });
137137
this.connected = false;
138138
if (this.lifeSignCallback) this.lifeSignCallback();
139139
this.axios
@@ -598,7 +598,7 @@ module.exports = class growatt {
598598
});
599599
}
600600

601-
601+
// eslint-disable-next-line class-methods-use-this
602602
getInverterCommunication(type) {
603603
debugApi('getInverterCommunication:', 'type', type);
604604
const ret = {};
@@ -631,7 +631,7 @@ module.exports = class growatt {
631631
}
632632

633633
comInverter(type, paramorgi) {
634-
634+
// eslint-disable-next-line no-async-promise-executor
635635
return new Promise(async (resolve, reject) => {
636636
debugApi('comInverter:', 'type', type, 'paramorgi', paramorgi);
637637
let checkRet = null;
@@ -735,13 +735,13 @@ module.exports = class growatt {
735735
reject(e);
736736
});
737737
if (plants) {
738-
738+
// eslint-disable-next-line no-restricted-syntax
739739
for (const plant of plants) {
740740
let res = {};
741741
let curPage = 0;
742742
do {
743743
curPage += 1;
744-
744+
// eslint-disable-next-line no-await-in-loop
745745
res = await this.getDataLogger(plant.id, curPage).catch(e => {
746746
debugApi('getDataLoggers getDataLogger err:', e);
747747
reject(e);
@@ -790,7 +790,7 @@ module.exports = class growatt {
790790
});
791791
}
792792

793-
793+
/* eslint-disable-next-line class-methods-use-this */
794794
correctTime(struct) {
795795
function makeTime(time) {
796796
if (
@@ -853,7 +853,7 @@ module.exports = class growatt {
853853
}
854854

855855
getAllPlantData(opt) {
856-
856+
/* eslint-disable-next-line no-async-promise-executor */
857857
return new Promise(async (resolve, reject) => {
858858
let options = opt;
859859
debugApi('getAllPlantData', 'options:', options);
@@ -891,7 +891,7 @@ module.exports = class growatt {
891891
result[plant.id] = plant;
892892
if (options.plantData) {
893893
result[plant.id].plantData = {};
894-
894+
/* eslint-disable-next-line no-await-in-loop */
895895
const plantData = await this.getPlantData(plant.id).catch(e => {
896896
debugApi('getAllPlantData getPlantData err:', e);
897897
reject(e);
@@ -902,7 +902,7 @@ module.exports = class growatt {
902902
}
903903
if (options.weather) {
904904
result[plant.id].weather = {};
905-
905+
/* eslint-disable-next-line no-await-in-loop */
906906
const weather = await this.getWeatherByPlantId(plant.id).catch(e => {
907907
debugApi('getAllPlantData getWeatherByPlantId err:', e);
908908
reject(e);
@@ -913,7 +913,7 @@ module.exports = class growatt {
913913
}
914914
if (options.faultlog) {
915915
result[plant.id].faultlog = {};
916-
916+
/* eslint-disable-next-line no-await-in-loop */
917917
const faultlog = await this.getNewPlantFaultLog(plant.id, options.faultlogdate).catch(e => {
918918
debugApi('getAllPlantData getNewPlantFaultLog err:', e);
919919
reject(e);
@@ -939,22 +939,22 @@ module.exports = class growatt {
939939
}
940940
}
941941
}
942-
942+
/* eslint-disable-next-line no-await-in-loop */
943943
result[plant.id].devices = await this.getAllPlantDeviceData(plant.id, options).catch(e => {
944944
debugApi('getAllPlantData getAllPlantDeviceData err:', e);
945945
reject(e);
946946
});
947947

948948
if (options.deviceData) {
949-
949+
/* eslint-disable-next-line no-await-in-loop */
950950
const devices = await this.getDevicesByPlantList(plant.id, 1).catch(e => {
951951
debugApi('getAllPlantData getDevicesByPlantList err:', e);
952952
reject(e);
953953
});
954954
if (devices && devices.obj && devices.obj.datas) {
955955
if (devices.obj.pages && devices.obj.pages > 1) {
956956
for (let p = 1; p < devices.obj.pages; p += 1) {
957-
957+
/* eslint-disable-next-line no-await-in-loop */
958958
const devicesPlus = await this.getDevicesByPlantList(plant.id, p).catch(e => {
959959
debugApi('getAllPlantData getDevicesByPlantList err:', e);
960960
reject(e);
@@ -968,7 +968,7 @@ module.exports = class growatt {
968968
result[plant.id].devices = {};
969969
}
970970
if (!result[plant.id].devices[devData.sn] && devData.plantId) {
971-
971+
/* eslint-disable-next-line no-await-in-loop */
972972
result[plant.id].devices[devData.sn] = await this.getPlantDeviceData(
973973
devData.plantId,
974974
devData.deviceTypeName,
@@ -996,7 +996,7 @@ module.exports = class growatt {
996996
}
997997

998998
getAllPlantDeviceData(plantId, opt) {
999-
999+
/* eslint-disable-next-line no-async-promise-executor */
10001000
return new Promise(async (resolve, reject) => {
10011001
let options = opt;
10021002
debugApi('getAllPlantDeviceData:', 'plantId:', plantId, 'options:', options);
@@ -1025,7 +1025,7 @@ module.exports = class growatt {
10251025
if (GROWATTTYPE[growattType].atIndex) {
10261026
serialNr += `@${device.obj[growattType][a][GROWATTTYPE[growattType].atIndex]}`;
10271027
}
1028-
1028+
/* eslint-disable-next-line no-await-in-loop */
10291029
result[serialNr] = await this.getPlantDeviceData(plantId, growattType, serialNr, invId, options).catch(e => {
10301030
debugApi(`getAllPlantDeviceData getPlantDeviceData ${growattType} err:`, e);
10311031
reject(e);
@@ -1044,7 +1044,7 @@ module.exports = class growatt {
10441044
}
10451045

10461046
getPlantDeviceData(plantId, growattType, serialNr, invId, opt) {
1047-
1047+
/* eslint-disable-next-line no-async-promise-executor */
10481048
return new Promise(async (resolve, reject) => {
10491049
let options = opt;
10501050
debugApi('getPlantDeviceData:', 'plantId', plantId, 'growattType', growattType, 'serialNr', serialNr, 'invId', invId, 'options:', options);

lib/parseret.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const debugApi = require('debug')('growatt:api');
2222

2323
function fTime(val, ok) {
2424
debugApi('fTime:', 'val', val, 'ok', ok);
25-
25+
// eslint-disable-next-line no-bitwise
2626
const H = val >> 8;
27-
27+
// eslint-disable-next-line no-bitwise
2828
const M = val & 255;
2929

3030
return [`${`00${H}`.slice(-2)}:${`00${M}`.slice(-2)}`, ok && ((H >= 0 && H <= 23) || M >= 0 || M <= 59)];

0 commit comments

Comments
 (0)