- Linting (ESLint): Lint per latest ash-nazg (e.g., named capture)

- Linting (ESLint): Add HTML files to linting and add devDeps for new ash-nazg
- npm: Update devDeps
This commit is contained in:
Brett Zamir
2019-07-02 12:21:21 +08:00
parent af290bd743
commit e4231aeb10
30 changed files with 313 additions and 267 deletions

View File

@@ -110,7 +110,7 @@ export const init = function (editorContext) {
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
*/
export const dropXMLInteralSubset = (str) => {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?\]>)/, '$1$2');
return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
};
/**
@@ -265,9 +265,9 @@ export const dataURLToObjectURL = function (dataurl) {
if (typeof Uint8Array === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) {
return '';
}
const arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]);
const [prefix, suffix] = dataurl.split(','),
{groups: {mime}} = prefix.match(/:(?<mime>.*?);/),
bstr = atob(suffix);
let n = bstr.length;
const u8arr = new Uint8Array(n);
while (n--) {
@@ -330,6 +330,7 @@ export const convertToXMLReferences = function (input) {
*/
export const text2xml = function (sXML) {
if (sXML.includes('<svg:svg')) {
// eslint-disable-next-line prefer-named-capture-group
sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns');
}
@@ -651,11 +652,13 @@ export const getBBox = function (elem) {
// have a featured detection for correct 'use' behavior?
// ——————————
if (!isWebkit()) {
const bb = {};
bb.width = ret.width;
bb.height = ret.height;
bb.x = ret.x + parseFloat(selected.getAttribute('x') || 0);
bb.y = ret.y + parseFloat(selected.getAttribute('y') || 0);
const {x, y, width, height} = ret;
const bb = {
width,
height,
x: x + parseFloat(selected.getAttribute('x') || 0),
y: y + parseFloat(selected.getAttribute('y') || 0)
};
ret = bb;
}
} else if (visElemsArr.includes(elname)) {
@@ -1369,7 +1372,7 @@ export const copyElem = function (el, getNextId) {
/**
* Whether a value is `null` or `undefined`.
* @param {Any} val
* @param {any} val
* @returns {boolean}
*/
export const isNullish = (val) => {