Skip to content

Commit

Permalink
Merge pull request #591 from snyk/fix/use-let-and-const
Browse files Browse the repository at this point in the history
fix: use let/const instead of var
  • Loading branch information
Konstantin Yegupov committed Jun 24, 2019
2 parents cf5088d + 43f416c commit 7f8a635
Show file tree
Hide file tree
Showing 37 changed files with 428 additions and 426 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
"no-undef": 2,
"no-unused-vars": 1,
"no-use-before-define": [2, "nofunc"],
"no-var": 2,
"object-curly-spacing": [2, "never"],
"prefer-arrow-callback": 2,
"prefer-const": 2,
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"keyword-spacing": [2, {"before": true, "after": true}],
Expand Down
8 changes: 4 additions & 4 deletions src/cli/commands/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var snyk = require('../../lib');
const snyk = require('../../lib');

module.exports = function config(method) {
var args = [].slice.call(arguments, 1);
var key = args[0];
const args = [].slice.call(arguments, 1);
const key = args[0];

return new Promise((resolve) => {
var res = '';
let res = '';
if (method === 'set') {
args.map((item) => {
return item.split('=');
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var abbrev = require('abbrev');
var hotload = require('../../lib/hotload')(__dirname);
const abbrev = require('abbrev');
const hotload = require('../../lib/hotload')(__dirname);
require('../../lib/spinner').isRequired = false;

// the aim of this module is to load as little as possible to keep cli boot
// time as low as possible

var commands = {
const commands = {
auth: hotload('./auth'),
config: hotload('./config'),
help: hotload('./help'),
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/modules.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var snyk = require('../../lib');
const snyk = require('../../lib');

module.exports = function (path, options) {
if (!options) {
options = {};
}
return snyk.modules(path || process.cwd()).then((modules) => {

var parent = '';
let parent = '';
if (modules.parent) {
parent = modules.parent.full;
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/policy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = displayPolicy;

var policy = require('snyk-policy');
var display = require('../../lib/display-policy');
const policy = require('snyk-policy');
const display = require('../../lib/display-policy');

function displayPolicy(path) {
return policy.load(path || process.cwd())
Expand Down
18 changes: 9 additions & 9 deletions src/cli/commands/protect/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var debug = require('debug')('snyk');
var snyk = require('../../../lib/');
var protect = require('../../../lib/protect');
var analytics = require('../../../lib/analytics');
var detect = require('../../../lib/detect');
var pm = require('../../../lib/package-managers');
const debug = require('debug')('snyk');
const snyk = require('../../../lib/');
const protect = require('../../../lib/protect');
const analytics = require('../../../lib/analytics');
const detect = require('../../../lib/detect');
const pm = require('../../../lib/package-managers');


function protectFunc(options = {}) {
Expand All @@ -20,8 +20,8 @@ function protectFunc(options = {}) {


try {
var packageManager = detect.detectPackageManager(process.cwd(), options);
var supportsProtect = pm.PROTECT_SUPPORTED_PACKAGE_MANAGERS
const packageManager = detect.detectPackageManager(process.cwd(), options);
const supportsProtect = pm.PROTECT_SUPPORTED_PACKAGE_MANAGERS
.includes(packageManager);
if (!supportsProtect) {
throw new Error(
Expand Down Expand Up @@ -62,7 +62,7 @@ function protectFunc(options = {}) {
function patch(policy, options) {
return snyk.test(process.cwd(), options).then((res) => {
if (!res.vulnerabilities) {
var e = new Error('Code is already patched');
const e = new Error('Code is already patched');
e.code = 'ALREADY_PATCHED';
throw e;
}
Expand Down

0 comments on commit 7f8a635

Please sign in to comment.