Skip to content

Commit

Permalink
Further MATScommon linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Aug 15, 2024
1 parent 8861fbf commit 23fc6a7
Show file tree
Hide file tree
Showing 110 changed files with 334 additions and 3,120 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"no-prototype-builtins": "warn",
"no-await-in-loop": "warn",
"no-dupe-else-if": "warn",
"meteor/no-session": "warn",
"meteor/no-session": "off",
"meteor/template-names": "warn",
"meteor/eventmap-params": "warn",
"meteor/no-template-lifecycle-assignments": "warn",
Expand Down
5 changes: 4 additions & 1 deletion meteor_packages/mats-common/client/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global setInfo, Session, $ */
/* eslint-disable no-undef */

setError = function (error) {
let myError = "";
let myStackTrace = "";
Expand All @@ -27,7 +30,7 @@ setError = function (error) {
$("#error").modal("show");
};

clearError = function (message) {
clearError = function () {
Session.set("errorMessage", "");
Session.set("stackTrace", "");
$("#error").modal("hide");
Expand Down
5 changes: 4 additions & 1 deletion meteor_packages/mats-common/client/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global Session, $ */
/* eslint-disable no-undef */

setInfo = function (info) {
Session.set("infoMessage", info);
$("#info").modal("show");
};

clearInfo = function (info) {
clearInfo = function () {
Session.set("infoMessage", "");
$("#info").modal("hide");
};
Expand Down
2 changes: 2 additions & 0 deletions meteor_packages/mats-common/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Created by pierce on 8/31/16.
*/

/* eslint-disable import/no-unresolved */

import "../imports/startup/client";
import "../imports/startup/both";
import "@fortawesome/fontawesome-free";
Expand Down
5 changes: 4 additions & 1 deletion meteor_packages/mats-common/client/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global Session */
/* eslint-disable no-undef */

setStatus = function (status) {
Session.set("statusMessage", status);
};

clearStatus = function (status) {
clearStatus = function () {
Session.set("statusMessage", "");
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ const status = function (res) {
}
};

// wrapper for NaN check
const isThisANaN = function (val) {
// eslint-disable-next-line no-restricted-globals
return !val || isNaN(val);
};

// private - used to see if the main page needs to update its selectors
const checkMetaDataRefresh = async function () {
// This routine compares the current last modified time of the tables (MYSQL) or documents (Couchbase)
Expand Down Expand Up @@ -3946,6 +3952,7 @@ if (Meteor.isServer) {

// eslint-disable-next-line no-undef
export default matsMethods = {
isThisANaN,
addSentAddress,
applyAuthorization,
applyDatabaseSettings,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { versionInfo } from "meteor/randyp:mats-common";

/* eslint-disable no-undef */

const assert = require("assert");

describe("getVersionsFromEnv", function () {
Expand All @@ -25,18 +27,18 @@ describe("getVersionsFromEnv", function () {
// Test
it("Correctly reads version from env", function () {
process.env.VERSION = "4.2.0";
const { version, commit, branch } = versionInfo.getVersionsFromEnv();
assert.equal(version, "4.2.0");
const versionStats = versionInfo.getVersionsFromEnv();
assert.equal(versionStats.version, "4.2.0");
});
it("Correctly reads commit from env", function () {
process.env.COMMIT = "ae214rfda";
const { version, commit, branch } = versionInfo.getVersionsFromEnv();
assert.equal(commit, "ae214rfda");
const versionStats = versionInfo.getVersionsFromEnv();
assert.equal(versionStats.commit, "ae214rfda");
});
it("Correctly reads version from env", function () {
process.env.BRANCH = "test";
const { version, commit, branch } = versionInfo.getVersionsFromEnv();
assert.equal(branch, "test");
const versionStats = versionInfo.getVersionsFromEnv();
assert.equal(versionStats.branch, "test");
});
it("Correctly handles no env", function () {
const { version, commit, branch } = versionInfo.getVersionsFromEnv();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function getVersionsFromEnv() {
};
}

// eslint-disable-next-line no-undef
export default versionInfo = {
getVersionsFromEnv,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Mongo } from "meteor/mongo";
import { Meteor } from "meteor/meteor";
import { curveParamsByApp } from "./mats-curve-params";

/* eslint-disable no-console */

const params = curveParamsByApp[Meteor.settings.public.app];
if (!params) {
console.log(
Expand All @@ -20,7 +22,7 @@ if (!params) {
}
const paramCollections = {};
let currParam;
for (let i = 0; i < params.length; i++) {
for (let i = 0; i < params.length; i += 1) {
currParam = params[i];
paramCollections[currParam] = new Mongo.Collection(currParam);
}
Expand Down Expand Up @@ -86,6 +88,7 @@ const explicitCollections = {
Scorecard,
};

// eslint-disable-next-line no-undef
export default matsCollections = {
...paramCollections,
...explicitCollections,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line no-undef, import/prefer-default-export
export const curveParamsByApp = {
"cb-metar": [
"label",
Expand Down
21 changes: 11 additions & 10 deletions meteor_packages/mats-common/imports/startup/both/mats-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,40 @@ of table names. The internal list can be appended. The getRecords returns the in
*/
class MetaDataDBRecord {
constructor(poolName, dbName, tables) {
if (!typeof poolName === "string") {
if (!(typeof poolName === "string")) {
throw new Error("MetaDataDBRecord.constructor : poolName is not a string");
}
if (!typeof dbName === "string") {
if (!(typeof dbName === "string")) {
throw new Error("MetaDataDBRecord.constructor : dbName is not a string");
}
if (!tables instanceof Array) {
if (!(tables instanceof Array)) {
throw new Error("MetaDataDBRecord.constructor : tables is not an array");
}
this._records = [];
this.records = [];
const record = { pool: poolName, name: dbName, tables };
this._records.push(record);
this.records.push(record);
}

addRecord(poolName, dbName, tables) {
if (!typeof poolName === "string") {
if (!(typeof poolName === "string")) {
throw new Error("MetaDataDBRecord.constructor : poolName is not a string");
}
if (!typeof dbName === "string") {
if (!(typeof dbName === "string")) {
throw new Error("MetaDataDBRecord.constructor : dbName is not a string");
}
if (!tables instanceof Array) {
if (!(tables instanceof Array)) {
throw new Error("MetaDataDBRecord.constructor : tables is not an array");
}
const record = { pool: poolName, name: dbName, tables };
this._records.push(record);
this.records.push(record);
}

getRecords() {
return this._records;
return this.records;
}
}

// eslint-disable-next-line no-undef
export default matsTypes = {
InputTypes,
ScorecardStatus,
Expand Down
Loading

0 comments on commit 23fc6a7

Please sign in to comment.