- Linting (ESLint): Simplify regexes

- npm: Update scripts to reflect removal of `all_tests.html`;
  remove `browser-test` script
- npm: Update devDeps
This commit is contained in:
Brett Zamir
2019-11-30 11:41:01 +08:00
parent 3200e0ab8e
commit a59170fbe1
24 changed files with 213 additions and 293 deletions

12
dist/canvg.js vendored
View File

@@ -386,7 +386,7 @@ var canvg = (function (exports) {
});
}
}, {
re: /^(\w{1})(\w{1})(\w{1})$/,
re: /^(\w)(\w)(\w)$/,
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'],
process: function process(_) {
@@ -1030,7 +1030,7 @@ var canvg = (function (exports) {
svg.compressSpaces = function (s) {
return s.replace(/[\s\r\t\n]+/gm, ' ');
return s.replace(/\s+/gm, ' ');
}; // ajax
// Todo: Replace with `fetch` and polyfill
@@ -1211,7 +1211,7 @@ var canvg = (function (exports) {
}, {
key: "getUnits",
value: function getUnits() {
return String(this.value).replace(/[0-9.-]/g, '');
return String(this.value).replace(/[\d.-]/g, '');
} // get the length as pixels
}, {
@@ -2528,8 +2528,8 @@ var canvg = (function (exports) {
.replace(/,/gm, ' ') // get rid of all commas
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([MmZzLlHhVvCcSsQqTtAa])(\S)/gm, '$1 $2') // separate commands from points
.replace(/(\S)([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
@@ -4002,7 +4002,7 @@ var canvg = (function (exports) {
}); // remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^\s*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);

View File

@@ -386,7 +386,7 @@ var svgEditorExtension_server_moinsave = (function () {
});
}
}, {
re: /^(\w{1})(\w{1})(\w{1})$/,
re: /^(\w)(\w)(\w)$/,
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'],
process: function process(_) {
@@ -1030,7 +1030,7 @@ var svgEditorExtension_server_moinsave = (function () {
svg.compressSpaces = function (s) {
return s.replace(/[\s\r\t\n]+/gm, ' ');
return s.replace(/\s+/gm, ' ');
}; // ajax
// Todo: Replace with `fetch` and polyfill
@@ -1211,7 +1211,7 @@ var svgEditorExtension_server_moinsave = (function () {
}, {
key: "getUnits",
value: function getUnits() {
return String(this.value).replace(/[0-9.-]/g, '');
return String(this.value).replace(/[\d.-]/g, '');
} // get the length as pixels
}, {
@@ -2528,8 +2528,8 @@ var svgEditorExtension_server_moinsave = (function () {
.replace(/,/gm, ' ') // get rid of all commas
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([MmZzLlHhVvCcSsQqTtAa])(\S)/gm, '$1 $2') // separate commands from points
.replace(/(\S)([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
@@ -4002,7 +4002,7 @@ var svgEditorExtension_server_moinsave = (function () {
}); // remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^\s*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);

View File

@@ -386,7 +386,7 @@ var svgEditorExtension_server_opensave = (function () {
});
}
}, {
re: /^(\w{1})(\w{1})(\w{1})$/,
re: /^(\w)(\w)(\w)$/,
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'],
process: function process(_) {
@@ -1030,7 +1030,7 @@ var svgEditorExtension_server_opensave = (function () {
svg.compressSpaces = function (s) {
return s.replace(/[\s\r\t\n]+/gm, ' ');
return s.replace(/\s+/gm, ' ');
}; // ajax
// Todo: Replace with `fetch` and polyfill
@@ -1211,7 +1211,7 @@ var svgEditorExtension_server_opensave = (function () {
}, {
key: "getUnits",
value: function getUnits() {
return String(this.value).replace(/[0-9.-]/g, '');
return String(this.value).replace(/[\d.-]/g, '');
} // get the length as pixels
}, {
@@ -2528,8 +2528,8 @@ var svgEditorExtension_server_opensave = (function () {
.replace(/,/gm, ' ') // get rid of all commas
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from commands
.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm, '$1 $2') // separate commands from points
.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/([MmZzLlHhVvCcSsQqTtAa])(\S)/gm, '$1 $2') // separate commands from points
.replace(/(\S)([MmZzLlHhVvCcSsQqTtAa])/gm, '$1 $2') // separate commands from points
.replace(/(\d)([+-])/gm, '$1 $2') // separate digits when no comma
.replace(/(\.\d*)(\.)/gm, '$1 $2') // separate digits when no comma
.replace(/([Aa](\s+\d+)(\s+\d+)(\s+\d+))\s+([01])\s*([01])/gm, '$1 $5 $6 '); // shorthand elliptical arc path syntax
@@ -4002,7 +4002,7 @@ var svgEditorExtension_server_opensave = (function () {
}); // remove comments
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
css = css.replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^\s*\/\/.*)/gm, ''); // eslint-disable-line unicorn/no-unsafe-regex
// replace whitespace
css = svg.compressSpaces(css);

16
dist/index-es.js vendored
View File

@@ -7934,7 +7934,7 @@ var init$2 = function init(editorContext) {
*/
var dropXMLInteralSubset = function dropXMLInteralSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?\]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
};
/**
* Converts characters in a string to XML-friendly entities.
@@ -8014,7 +8014,7 @@ function decode64(input) {
} // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
input = input.replace(/[^A-Za-z\d+/=]/g, '');
var output = '';
var i = 0;
@@ -17101,8 +17101,8 @@ function SvgCanvas(container, config) {
var pt = screenToPt(mouseX, mouseY);
var index = getIndexFromPoint(pt.x, pt.y);
var str = curtext.textContent;
var first = str.substr(0, index).replace(/[a-z0-9]+$/i, '').length;
var m = str.substr(index).match(/^[a-z0-9]+/i);
var first = str.substr(0, index).replace(/[a-z\d]+$/i, '').length;
var m = str.substr(index).match(/^[a-z\d]+/i);
var last = (m ? m[0].length : 0) + index;
setSelection(first, last); // Set tripleclick
@@ -25470,19 +25470,19 @@ var jPicker = function jPicker($) {
break;
case hex.get(0):
hex.val(hex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
hex.val(hex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
bindedHex && bindedHex.val(hex.val());
color.val('hex', hex.val() !== '' ? hex.val() : null, e.target);
break;
case bindedHex && bindedHex.get(0):
bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
bindedHex.val(bindedHex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
hex.val(bindedHex.val());
color.val('hex', bindedHex.val() !== '' ? bindedHex.val() : null, e.target);
break;
case ahex && ahex.get(0):
ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 2));
ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2));
color.val('a', !isNullish$1(ahex.val()) ? parseInt(ahex.val(), 16) : null, e.target);
break;
}
@@ -26121,7 +26121,7 @@ var jPicker = function jPicker($) {
*/
validateHex: function validateHex(hex) {
// if (typeof hex === 'object') return '';
hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
hex = hex.toLowerCase().replace(/[^a-f\d]/g, '');
if (hex.length > 8) hex = hex.substring(0, 8);
return hex;
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

16
dist/index-umd.js vendored
View File

@@ -7940,7 +7940,7 @@
*/
var dropXMLInteralSubset = function dropXMLInteralSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?\]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
};
/**
* Converts characters in a string to XML-friendly entities.
@@ -8020,7 +8020,7 @@
} // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
input = input.replace(/[^A-Za-z\d+/=]/g, '');
var output = '';
var i = 0;
@@ -17107,8 +17107,8 @@
var pt = screenToPt(mouseX, mouseY);
var index = getIndexFromPoint(pt.x, pt.y);
var str = curtext.textContent;
var first = str.substr(0, index).replace(/[a-z0-9]+$/i, '').length;
var m = str.substr(index).match(/^[a-z0-9]+/i);
var first = str.substr(0, index).replace(/[a-z\d]+$/i, '').length;
var m = str.substr(index).match(/^[a-z\d]+/i);
var last = (m ? m[0].length : 0) + index;
setSelection(first, last); // Set tripleclick
@@ -25476,19 +25476,19 @@
break;
case hex.get(0):
hex.val(hex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
hex.val(hex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
bindedHex && bindedHex.val(hex.val());
color.val('hex', hex.val() !== '' ? hex.val() : null, e.target);
break;
case bindedHex && bindedHex.get(0):
bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
bindedHex.val(bindedHex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 6));
hex.val(bindedHex.val());
color.val('hex', bindedHex.val() !== '' ? bindedHex.val() : null, e.target);
break;
case ahex && ahex.get(0):
ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 2));
ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2));
color.val('a', !isNullish$1(ahex.val()) ? parseInt(ahex.val(), 16) : null, e.target);
break;
}
@@ -26127,7 +26127,7 @@
*/
validateHex: function validateHex(hex) {
// if (typeof hex === 'object') return '';
hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
hex = hex.toLowerCase().replace(/[^a-f\d]/g, '');
if (hex.length > 8) hex = hex.substring(0, 8);
return hex;
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -265,7 +265,7 @@
});
}
}, {
re: /^(\w{1})(\w{1})(\w{1})$/,
re: /^(\w)(\w)(\w)$/,
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'],
process: function process(_) {

View File

@@ -8006,7 +8006,7 @@ var SvgCanvas = (function () {
*/
var dropXMLInteralSubset = function dropXMLInteralSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?\]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
};
/**
* Converts characters in a string to XML-friendly entities.
@@ -8086,7 +8086,7 @@ var SvgCanvas = (function () {
} // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
input = input.replace(/[^A-Za-z\d+/=]/g, '');
var output = '';
var i = 0;
@@ -16879,8 +16879,8 @@ var SvgCanvas = (function () {
var pt = screenToPt(mouseX, mouseY);
var index = getIndexFromPoint(pt.x, pt.y);
var str = curtext.textContent;
var first = str.substr(0, index).replace(/[a-z0-9]+$/i, '').length;
var m = str.substr(index).match(/^[a-z0-9]+/i);
var first = str.substr(0, index).replace(/[a-z\d]+$/i, '').length;
var m = str.substr(index).match(/^[a-z\d]+/i);
var last = (m ? m[0].length : 0) + index;
setSelection(first, last); // Set tripleclick

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long