Skip to content

Commit

Permalink
Upgrading ESLint to v.4.0.0, and refactoring regEx for compliance.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Jun 12, 2017
1 parent 70dd783 commit 5621e09
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/formatting.js
Expand Up @@ -111,7 +111,7 @@ var formatAs = {

object: (query, obj, raw, options) => {
options = options && typeof options === 'object' ? options : {};
var pattern = /\$(?:({)|(\()|(<)|(\[)|(\/))\s*[a-zA-Z0-9\$_]+(\^|~|#|:raw|:alias|:name|:json|:csv|:value)?\s*(?:(?=\2)(?=\3)(?=\4)(?=\5)}|(?=\1)(?=\3)(?=\4)(?=\5)\)|(?=\1)(?=\2)(?=\4)(?=\5)>|(?=\1)(?=\2)(?=\3)(?=\5)]|(?=\1)(?=\2)(?=\3)(?=\4)\/)/g;
var pattern = /\$(?:({)|(\()|(<)|(\[)|(\/))\s*[a-zA-Z0-9$_]+(\^|~|#|:raw|:alias|:name|:json|:csv|:value)?\s*(?:(?=\2)(?=\3)(?=\4)(?=\5)}|(?=\1)(?=\3)(?=\4)(?=\5)\)|(?=\1)(?=\2)(?=\4)(?=\5)>|(?=\1)(?=\2)(?=\3)(?=\5)]|(?=\1)(?=\2)(?=\3)(?=\4)\/)/g;
return query.replace(pattern, name => {
var v = formatAs.stripName(name.replace(/^\$[{(<[/]|[\s})>\]/]/g, ''), raw);
if (v.name in obj) {
Expand All @@ -134,7 +134,7 @@ var formatAs = {

array: (query, array, raw, options) => {
options = options && typeof options === 'object' ? options : {};
return query.replace(/\$([1-9][0-9]{0,3}(?![0-9])(\^|~|#|:raw|:alias|:name|:json|:csv|:value)?)/g, name => {
return query.replace(/\$([1-9][0-9]{0,4}(?![0-9])(\^|~|#|:raw|:alias|:name|:json|:csv|:value)?)/g, name => {
var v = formatAs.stripName(name.substr(1), raw);
var idx = v.name - 1;
if (idx < array.length) {
Expand Down Expand Up @@ -663,7 +663,7 @@ var $as = {
* Replaces variables in a string according to the type of `values`:
*
* - Replaces `$1` occurrences when `values` is of type `string`, `boolean`, `number`, `Date`, `Buffer` or when it is `null`.
* - Replaces variables `$1`, `$2`, ...`$9999` when `values` is an array of parameters. When a variable is out of range,
* - Replaces variables `$1`, `$2`, ...`$99999` when `values` is an array of parameters. When a variable is out of range,
* it throws {@link external:RangeError RangeError} = `Variable $n out of range. Parameters array length: x`, unless
* option `partial` is used.
* - Replaces `$*propName*`, where `*` is any of `{}`, `()`, `[]`, `<>`, `//`, when `values` is an object that's not a
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers/column.js
Expand Up @@ -208,7 +208,7 @@ function parseCast(name) {
}

function parseColumn(name) {
var m = name.match(/\??[a-zA-Z0-9\$_]+(\^|~|#|:raw|:alias|:name|:json|:csv|:value)?/);
var m = name.match(/\??[a-zA-Z0-9$_]+(\^|~|#|:raw|:alias|:name|:json|:csv|:value)?/);
if (m && m[0] === name) {
var res = {};
if (name[0] === '?') {
Expand All @@ -233,7 +233,7 @@ function isValidMod(mod) {
}

function isValidVariable(name) {
var m = name.match(/^[0-9]+|[a-zA-Z0-9\$_]+/);
var m = name.match(/^[0-9]+|[a-zA-Z0-9$_]+/);
return !!m && m[0] === name;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/index.js
Expand Up @@ -92,7 +92,7 @@ function getSafeConnection(cn) {
return copy;
}
// or else it is a connection string;
return cn.replace(/:(?![\/])([^@]+)/, (_, m) => {
return cn.replace(/:(?![/])([^@]+)/, (_, m) => {
return ':' + new Array(m.length + 1).join('#');
});
}
Expand All @@ -119,7 +119,7 @@ function inherits(child, parent) {
function isPathAbsolute(path) {
// Based on: https://github.com/sindresorhus/path-is-absolute
if (process.platform === 'win32') {
var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
var splitDeviceRe = /^([a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?([\\/])?([\s\S]*?)$/;
var result = splitDeviceRe.exec(path);
var device = result[1] || '';
var isUnc = !!device && device.charAt(1) !== ':';
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/public.js
Expand Up @@ -31,7 +31,7 @@ var EOL = require('os').EOL;
*
*/
function camelize(text) {
text = text.replace(/[\-_\s\.]+(.)?/g, (match, chr) => {
text = text.replace(/[-_\s.]+(.)?/g, (match, chr) => {
return chr ? chr.toUpperCase() : '';
});
return text.substr(0, 1).toLowerCase() + text.substr(1);
Expand Down Expand Up @@ -60,7 +60,7 @@ function camelize(text) {
*
*/
function camelizeVar(text) {
text = text.replace(/[^a-zA-Z0-9\$_\-\s\.]/g, '').replace(/^[0-9_\-\s\.]+/, '');
text = text.replace(/[^a-zA-Z0-9$_\-\s.]/g, '').replace(/^[0-9_\-\s.]+/, '');
return camelize(text);
}

Expand Down
12 changes: 6 additions & 6 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "pg-promise",
"version": "5.9.1",
"version": "5.9.2",
"description": "Promises interface for PostgreSQL",
"main": "lib/index.js",
"typings": "typescript/pg-promise.d.ts",
Expand Down Expand Up @@ -40,21 +40,21 @@
"npm": ">=2.15"
},
"dependencies": {
"pg": "5.1",
"spex": "1.2",
"manakin": "0.4",
"pg": "^5.1.0",
"pg-minify": "0.4",
"manakin": "0.4"
"spex": "1.2"
},
"devDependencies": {
"@types/node": "7.0",
"JSONStream": "1.3",
"bluebird": "3.5",
"coveralls": "2.11",
"eslint": "^4.0.0",
"istanbul": "0.4",
"jasmine-node": "1.14",
"jsdoc": "3.4",
"pg-query-stream": "1.x",
"typescript": "2.3",
"eslint": "3.19"
"typescript": "2.3"
}
}

0 comments on commit 5621e09

Please sign in to comment.