Variable 'greenButtonSubscriber' should be initialized on declaration
4import { GreenButtonSubscriber } from '../index.js';
5import { appId, authorizationId, configEnbridge as config, customerAccountId, customerId, meterId, readingId } from './config.js';
6describe('node-green-button-subscriber', () => {
7 let greenButtonSubscriber; 8 before(() => {
9 greenButtonSubscriber = new GreenButtonSubscriber(config);
10 });
Variable 'json' should be initialized on declaration
82 if (endpointResponse === undefined) {
83 return undefined;
84 }
85 let json; 86 if ((endpointResponse.data ?? '') !== '') {
87 json = await atomToGreenButtonJson(endpointResponse.data);
88 }
Description
In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, foo
is initialized during declaration, while bar
is initialized later.
var foo = 1;
var bar;
if (foo) {
bar = 1;
} else {
bar = 2;
}
Bad Practice
function foo() {
var bar;
let baz;
}
Recommended
function foo() {
var bar = 1;
let baz = 2;
const qux = 3;
}