Skip to content

Commit

Permalink
fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Jul 21, 2023
1 parent a28fc78 commit 847828c
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 105 deletions.
54 changes: 27 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';


/* !
* Chai - pathval utility
Expand Down Expand Up @@ -73,19 +73,19 @@ function hasProperty(obj, name) {
*/

function parsePath(path) {
var str = path.replace(/([^\\])\[/g, '$1.[');
var parts = str.match(/(\\\.|[^.]+?)+/g);
return parts.map(function mapMatches(value) {
const str = path.replace(/([^\\])\[/g, '$1.[');
const parts = str.match(/(\\\.|[^.]+?)+/g);
return parts.map((value) => {
if (
value === 'constructor' ||
value === '__proto__' ||
value === 'prototype'
) {
return {};
}
var regexp = /^\[(\d+)\]$/;
var mArr = regexp.exec(value);
var parsed = null;
const regexp = /^\[(\d+)\]$/;
const mArr = regexp.exec(value);
let parsed = null;
if (mArr) {
parsed = { i: parseFloat(mArr[1]) };
} else {
Expand All @@ -112,12 +112,12 @@ function parsePath(path) {
*/

function internalGetPathValue(obj, parsed, pathDepth) {
var temporaryValue = obj;
var res = null;
let temporaryValue = obj;
let res = null;
pathDepth = typeof pathDepth === 'undefined' ? parsed.length : pathDepth;

for (var i = 0; i < pathDepth; i++) {
var part = parsed[i];
for (let i = 0; i < pathDepth; i++) {
const part = parsed[i];
if (temporaryValue) {
if (typeof part.p === 'undefined') {
temporaryValue = temporaryValue[part.i];
Expand Down Expand Up @@ -149,13 +149,13 @@ function internalGetPathValue(obj, parsed, pathDepth) {
*/

function internalSetPathValue(obj, val, parsed) {
var tempObj = obj;
var pathDepth = parsed.length;
var part = null;
let tempObj = obj;
const pathDepth = parsed.length;
let part = null;
// Here we iterate through every part of the path
for (var i = 0; i < pathDepth; i++) {
var propName = null;
var propVal = null;
for (let i = 0; i < pathDepth; i++) {
let propName = null;
let propVal = null;
part = parsed[i];

// If it's the last part of the path, we set the 'propName' value with the property name
Expand All @@ -169,7 +169,7 @@ function internalSetPathValue(obj, val, parsed) {
tempObj = tempObj[part.i];
} else {
// If the obj doesn't have the property we create one with that name to define it
var next = parsed[i + 1];
const next = parsed[i + 1];
// Here we set the name of the property which will be defined
propName = typeof part.p === 'undefined' ? part.i : part.p;
// Here we decide if this property will be an array or a new object
Expand Down Expand Up @@ -203,9 +203,9 @@ function internalSetPathValue(obj, val, parsed) {
*/

function getPathInfo(obj, path) {
var parsed = parsePath(path);
var last = parsed[parsed.length - 1];
var info = {
const parsed = parsePath(path);
const last = parsed[parsed.length - 1];
const info = {
parent:
parsed.length > 1 ?
internalGetPathValue(obj, parsed, parsed.length - 1) :
Expand Down Expand Up @@ -250,7 +250,7 @@ function getPathInfo(obj, path) {
*/

function getPathValue(obj, path) {
var info = getPathInfo(obj, path);
const info = getPathInfo(obj, path);
return info.value;
}

Expand Down Expand Up @@ -288,14 +288,14 @@ function getPathValue(obj, path) {
*/

function setPathValue(obj, path, val) {
var parsed = parsePath(path);
const parsed = parsePath(path);
internalSetPathValue(obj, val, parsed);
return obj;
}

module.exports = {
hasProperty: hasProperty,
getPathInfo: getPathInfo,
getPathValue: getPathValue,
setPathValue: setPathValue,
hasProperty,
getPathInfo,
getPathValue,
setPathValue,
};
19 changes: 9 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* eslint no-process-env: "off" */

'use strict';

var packageJson = require('./package.json');
var defaultTimeout = 120000;
var browserifyIstanbul = require('browserify-istanbul');
const packageJson = require('./package.json');
const defaultTimeout = 120000;
const browserifyIstanbul = require('browserify-istanbul');
module.exports = function configureKarma(config) {
var localBrowsers = [ 'PhantomJS' ];
var sauceLabsBrowsers = {
const localBrowsers = [ 'PhantomJS' ];
const sauceLabsBrowsers = {
SauceChromeLatest: {
base: 'SauceLabs',
browserName: 'Chrome',
Expand Down Expand Up @@ -68,10 +67,10 @@ module.exports = function configureKarma(config) {
});

if (process.env.SAUCE_ACCESS_KEY && process.env.SAUCE_USERNAME) {
var branch = process.env.TRAVIS_BRANCH || 'local';
var build = 'localbuild';
const branch = process.env.TRAVIS_BRANCH || 'local';
let build = 'localbuild';
if (process.env.TRAVIS_JOB_NUMBER) {
build = 'travis@' + process.env.TRAVIS_JOB_NUMBER;
build = `travis@${ process.env.TRAVIS_JOB_NUMBER }`;
}
config.reporters.push('saucelabs');
config.set({
Expand All @@ -83,7 +82,7 @@ module.exports = function configureKarma(config) {
process.env.TRAVIS_JOB_NUMBER || new Date().getTime(),
recordVideo: true,
startConnect: 'TRAVIS' in process.env === false,
tags: [ 'pathval_' + packageJson.version, process.env.SAUCE_USERNAME + '@' + branch, build ],
tags: [ `pathval_${ packageJson.version }`, `${ process.env.SAUCE_USERNAME }@${ branch }`, build ],
},
});
}
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
},
"eslintConfig": {
"extends": [
"strict/es5"
"strict/es6"
],
"parserOptions": {
"sourceType": "module"
},
"env": {
"es6": true
},
Expand Down
Loading

0 comments on commit 847828c

Please sign in to comment.