Skip to content

Commit

Permalink
added test linter yml
Browse files Browse the repository at this point in the history
Signed-off-by: Himani1519 <[email protected]>
  • Loading branch information
Himani1519 committed Nov 5, 2023
1 parent dee0115 commit 01fc30a
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 43 deletions.
48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

module.exports = {
env: {
browser: true,
es6: true,
node: true
},
globals: {
describe: 'readonly',
it: 'readonly',
before: 'readonly',
after: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
},
ignorePatterns: ['.github/**/*.yml', '**/.build', '**/build', '**/dist', '**/node_modules', '**/release', '**/lib','**/test/yaml-loader'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript'
],
parser: '@typescript-eslint/parser',
plugins: ['header'],
rules: {
'header/header': [
2, // Error level
'block', // Location
[
'\n This program and the accompanying materials are' +
'\n made available under the terms of the Eclipse Public License v2.0 which accompanies' +
'\n this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html' +
'\n\n SPDX-License-Identifier: EPL-2.0\n\n Copyright Contributors to the Zowe Project.\n'
],
2,
],
},
}
26 changes: 26 additions & 0 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint TypeScript

on:
push:
branches:
- v2.x/staging
pull_request:
types: [opened, reopened, synchronize]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install Dependencies
run: npm ci

- name: Lint TypeScript
run: npm run lint
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "A Server for zLUX Plugins, Dataservices, and Proxying to other Servers.",
"license": "EPL-2.0",
"homepage": "zowe.org",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/zowe/zlux-server-framework.git"
Expand Down
16 changes: 8 additions & 8 deletions test/plugin-loader/depgraph.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*/
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

import { strict as assert } from 'assert';
import Depgraph from '../../lib/depgraph';
Expand Down
6 changes: 3 additions & 3 deletions test/plugin-loader/plugin-loader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

/*
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

import assert from 'assert';
import path from 'path';
import PluginLoader from '../../lib/plugin-loader';
Expand Down
6 changes: 3 additions & 3 deletions test/webserver/multibind.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
Copyright Contributors to the Zowe Project.
*/
const assert = require('assert')
const zluxUtil = require('../../lib/util.js')
const pd = "..\..\..\\zlux-app-server\\deploy\\product"
import assert from 'assert';

Check failure on line 11 in test/webserver/multibind.js

View workflow job for this annotation

GitHub Actions / lint

missing header
import zluxUtil from '../../lib/util.js';
//const pd = "../../../zlux-app-server/deploy/product";

global.COM_RS_COMMON_LOGGER.setLogLevelForComponentPattern("_zsf.network", 5);

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"exclude": ["lib/*.js"],
"compilerOptions": {
"sourceMap": true,
"module": "ES6",
"moduleResolution": "node",
"target": "es5",
"target": "ES6",
"types": [
"node",
"express"
Expand Down
9 changes: 5 additions & 4 deletions utils/argumentParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function CLIArgument(longName, shortName, type) {
return {
getMatch: getMatch
};
};
}
exports.CLIArgument = CLIArgument;

/*
Expand All @@ -96,7 +96,7 @@ function resolveJson(argumentsObj, matchObj) {
returnVal = {};
}
let currentLevel = returnVal;
let currentIndex = -1;
// let currentIndex = -1;
const partLen = matchParts.length-1;
try {
for (let i = 0; i < partLen; i++) {
Expand Down Expand Up @@ -134,6 +134,7 @@ function resolveJson(argumentsObj, matchObj) {

function ArgumentParser(validArgs, argArray) {
var validArguments = validArgs;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
var args = argArray;

var parse = function(args) {
Expand Down Expand Up @@ -284,8 +285,8 @@ function stringToValue(stringVal, csvAsArray) {
}
exports.stringToValue = stringToValue;


function testEnv() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let input0 = {ABC:"1",
ABC_123: "2",
ABC__123: "3",
Expand Down Expand Up @@ -392,7 +393,7 @@ function testEnv() {
_______aBC_______123_______: "122",
__0__abc__1__def: "123"
};

/* eslint-disable-next-line no-unused-vars */
let input = {

node_mediationLayer_server_gatewayPort:"$GATEWAY_PORT",
Expand Down
28 changes: 15 additions & 13 deletions utils/install-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
Copyright Contributors to the Zowe Project.
*/

const fs = require('graceful-fs');
const Promise = require('bluebird');
const path = require('path');
const packagingUtils = require('./packaging-utils');
const serverUtils = require('../lib/util');
const jsonUtils = require('../lib/jsonUtils');
const rmrf = require('rimraf');
import * as fs from 'graceful-fs';

Check failure on line 11 in utils/install-app.js

View workflow job for this annotation

GitHub Actions / lint

incorrect header
//const Promise = require('bluebird');
import * as path from 'path';
import { packagingUtils } from './packaging-utils';
import * as serverUtils from '../lib/util';
import * as jsonUtils from '../lib/jsonUtils';
//import * as rmrf from 'rimraf';

//assuming that this is file isnt being called from another that is already using the logger... else expect strange logs
//TO DO - Sean - bootstrap logger
Expand All @@ -28,13 +28,13 @@ try { // Attempt to get a log message for a language a user may have specified
}
logger._messages = messages;

const argParser = require('./argumentParser');
import * as argParser from './argumentParser';
//const usage = 'Usage: --inputApp | -i INPUTAPP --pluginsDir | -p PLUGINSDIR '
// + '--zluxConfig | -c ZLUXCONFIGPATH [--verbose | -v]';

//TODO if plugins get extracted read-only, then how would we go about doing upgrades? read-write for now!
const FILE_WRITE_MODE = 0o660;
const DIR_WRITE_MODE = 0o770;
//const DIR_WRITE_MODE = 0o770;

const OPTION_ARGS = [
new argParser.CLIArgument('inputApp', 'i', argParser.constants.ARG_TYPE_VALUE),
Expand Down Expand Up @@ -96,9 +96,9 @@ function isFile(path) {
return false;
}

function cleanup() {
logger.warn(`ZWED0147W`); //logger.warn(`Cleanup not yet implemented`);
}
//function cleanup() {
// logger.warn(`ZWED0147W`); //logger.warn(`Cleanup not yet implemented`);
//}

function addToServer(appDir, installDir) {
try {
Expand Down Expand Up @@ -177,6 +177,7 @@ function copyRecognizers(appDir, appId, appVers) {
configRecognizers = JSON.parse(fs.readFileSync(filepathConfig)).recognizers;
const configRecognizersKeys = Object.keys(configRecognizers);
for (const configKey of configRecognizersKeys) { // Traverse config recognizers
// eslint-disable-next-line no-undef
for (const key of recognizerKeys) { // Traverse plugin recognizers
if (configRecognizers[configKey].key && recognizers[key].key && configRecognizers[configKey].key == recognizers[key].key) { // TODO: Need to implement real keys for Recognizers
configRecognizers[configKey] = recognizers[key]; // Choose the recognizers originating from plugin
Expand Down Expand Up @@ -244,7 +245,8 @@ function copyActions(appDir, appId, appVers) {

if(calledViaCLI){
if (!isFile(userInput.inputApp)) {
const pluginDefinition = packagingUtils.validatePluginInDirectory(userInput.inputApp);
// const pluginDefinition =
packagingUtils.validatePluginInDirectory(userInput.inputApp);
addToServer(userInput.inputApp);
} else {
packagingUtils.endWithMessage(`App given was not a directory. Not yet implemented: Package extraction`);
Expand Down
2 changes: 1 addition & 1 deletion utils/mergeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
function deepAssign(target, source) {

Check failure on line 11 in utils/mergeUtils.js

View workflow job for this annotation

GitHub Actions / lint

incorrect header
var retVal = {}
if (Array.isArray(target)) {
retVal = target;
retVal = target;
} else if (typeof target === 'object' && target) {
Object.keys(target).forEach(function (key) {
retVal[key] = target[key];
Expand Down
19 changes: 10 additions & 9 deletions utils/packaging-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
This program and the accompanying materials are
made available under the terms of the Eclipse Public License v2.0 which accompanies
this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/

const path = require('path');
const Promise = require('bluebird');
const fs = require('graceful-fs');
import path from 'path';
import Promise from 'bluebird';
import fs from 'graceful-fs';
//assuming that this is file isnt being called from another that is already using the logger... else expect strange logs
const logging = require('../../zlux-shared/src/logging/logger.js');
import type { logging } from '../../zlux-shared/src/logging/logger.js';
const coreLogger = new logging.Logger();
//simple program, no need for logger names to be displayed
coreLogger.addDestination(coreLogger.makeDefaultDestination(true,false,false));

// eslint-disable-next-line @typescript-eslint/no-unused-vars
let logger;

exports.coreLogger = coreLogger;
Expand All @@ -29,7 +29,7 @@ function mkdirp(dir, options) {
if (dir == '.') {
resolve();
} else {
fs.stat(dir, (err, stats)=> {
fs.stat(dir, (err)=> {
if (!err) {
//exists
resolve();
Expand All @@ -43,6 +43,7 @@ function mkdirp(dir, options) {
resolve();
}
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
}).catch((err)=> {
reject();
});
Expand Down Expand Up @@ -75,7 +76,7 @@ function validatePluginInDirectory(inputDir) {
endWithMessage(`Couldn't read pluginDefinition.json within ${inputDir}, e=${e}`);
}
return pluginDefinition;
};
}
exports.validatePluginInDirectory = validatePluginInDirectory;

function endWithMessage(message) {
Expand Down

0 comments on commit 01fc30a

Please sign in to comment.