From ac50fab08cb25a92ef07ac79b617b7290ef9df94 Mon Sep 17 00:00:00 2001 From: Himani1519 Date: Wed, 8 Nov 2023 16:16:54 +0530 Subject: [PATCH] fix linting issues and added yml Signed-off-by: Himani1519 --- .eslintrc.js | 42 +++++++++++++++++++++++++++++++++ .github/workflows/test-lint.yml | 26 ++++++++++++++++++++ bin/init/plugins-init.js | 6 ++--- lib/upgradeInstance.js | 21 +++++++++++------ lib/zluxArgs.js | 11 ++++----- lib/zluxServer.js | 2 -- package.json | 3 ++- 7 files changed, 92 insertions(+), 19 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .github/workflows/test-lint.yml diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..067bfa03 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,42 @@ +/* + 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 + }, + ignorePatterns: ['.github/**/*.yml', '**/.build', '**/build', '**/dist', '**/node_modules', '**/release'], + 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: { + 'import/no-unresolved': 'off', + '@typescript-eslint/no-var-requires': 'off', + 'header/header': [ + 2, + 'block', + [ + '\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, + ], + }, + } \ No newline at end of file diff --git a/.github/workflows/test-lint.yml b/.github/workflows/test-lint.yml new file mode 100644 index 00000000..f54b8ee7 --- /dev/null +++ b/.github/workflows/test-lint.yml @@ -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 \ No newline at end of file diff --git a/bin/init/plugins-init.js b/bin/init/plugins-init.js index d99e7de6..0ee9c035 100644 --- a/bin/init/plugins-init.js +++ b/bin/init/plugins-init.js @@ -2,14 +2,14 @@ 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 * as os from 'os'; -import * as zos from 'zos'; +// import * as zos from 'zos'; import * as std from 'std'; import * as xplatform from 'xplatform'; import * as fs from '../../../../../../bin/libs/fs'; diff --git a/lib/upgradeInstance.js b/lib/upgradeInstance.js index 1a2ada58..59fe5c15 100644 --- a/lib/upgradeInstance.js +++ b/lib/upgradeInstance.js @@ -1,12 +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. + 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 fs = require('fs'); const path = require('path'); const semver = require('semver'); @@ -142,10 +143,13 @@ const versions = [ const pluginPath = path.join(toLocation, 'plugins', file); const pluginJson = JSON.parse(fs.readFileSync(pluginPath, 'utf8')); let index, componentIndex, componentsIndex, relativeIndex; + // eslint-disable-next-line @typescript-eslint/no-unused-vars index = componentsIndex = pluginJson.pluginLocation.indexOf('components/app-server'); if (index == -1) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars index = relativeIndex = pluginJson.pluginLocation.startsWith('../../') ? 6 : -1; if (index == -1 && isContainer) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars index = componentIndex = pluginJson.pluginLocation.startsWith('/component/share/') ? 17 : -1; } } @@ -177,6 +181,7 @@ const versions = [ }, { v: '1.21.0', + // eslint-disable-next-line @typescript-eslint/no-unused-vars upgrade: function(toLocation, serverConfig, envConfig, instanceItems) { if (serverConfig.agent && !serverConfig.agent.mediationLayer) { serverConfig.agent.mediationLayer = { @@ -235,8 +240,10 @@ module.exports.doUpgrade = function doUpgrade(fromVersion, toLocation, serverCon console.log('app-server config upgraded to version='+upgradedTo); } if (configNeedsUpdate) { + // eslint-disable-next-line no-unsafe-finally return {upgradedTo, serverConfig}; } else { + // eslint-disable-next-line no-unsafe-finally return {upgradedTo}; } } diff --git a/lib/zluxArgs.js b/lib/zluxArgs.js index 5aca76c4..f89ea610 100644 --- a/lib/zluxArgs.js +++ b/lib/zluxArgs.js @@ -1,5 +1,3 @@ - - /* This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies @@ -11,12 +9,12 @@ */ 'use strict'; -const ProxyServer = require('zlux-server-framework'); +// const ProxyServer = require('zlux-server-framework'); const argParser = require('zlux-server-framework/utils/argumentParser'); -const jsonUtils = require('zlux-server-framework/lib/jsonUtils'); +// const jsonUtils = require('zlux-server-framework/lib/jsonUtils'); const mergeUtils = require('zlux-server-framework/utils/mergeUtils'); const yamlConfig = require('zlux-server-framework/utils/yamlConfig'); -const mkdirp = require('mkdirp'); +// const mkdirp = require('mkdirp'); const cluster = require('cluster'); const MVD_ARGS = [ @@ -54,7 +52,8 @@ function getSafeToPrintEnvironment(env) { //Env overrides config JSON, -D args override env if(process.env.overrideFileConfig !== "false"){ if (cluster.isMaster) { - const safeEnvironment = getSafeToPrintEnvironment(process.env); + // const safeEnvironment = + getSafeToPrintEnvironment(process.env); console.log('\nZWED5014I - Processing CLI arguments:\n'+commandArgs); } const envConfig = argParser.environmentVarsToObject("ZWED_"); diff --git a/lib/zluxServer.js b/lib/zluxServer.js index 5c898813..83355e40 100644 --- a/lib/zluxServer.js +++ b/lib/zluxServer.js @@ -1,5 +1,3 @@ - - /* This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies diff --git a/package.json b/package.json index ba40c9e2..70459329 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ }, "scripts": { "build": "exit 0", - "test": "echo \"Warning: no test specified\" && exit 0" + "test": "echo \"Warning: no test specified\" && exit 0", + "lint": "eslint ." }, "dependencies": { "zlux-server-framework": "file:../zlux-server-framework",