mirror of
https://github.com/DavidAnson/markdownlint-cli2-action.git
synced 2024-11-21 22:01:30 +01:00
Freshen generated index.js file.
This commit is contained in:
parent
4e30c06580
commit
e94f7fb325
1 changed files with 62 additions and 52 deletions
112
dist/index.js
vendored
112
dist/index.js
vendored
|
@ -2778,8 +2778,8 @@ const braces = (input, options = {}) => {
|
||||||
let output = [];
|
let output = [];
|
||||||
|
|
||||||
if (Array.isArray(input)) {
|
if (Array.isArray(input)) {
|
||||||
for (let pattern of input) {
|
for (const pattern of input) {
|
||||||
let result = braces.create(pattern, options);
|
const result = braces.create(pattern, options);
|
||||||
if (Array.isArray(result)) {
|
if (Array.isArray(result)) {
|
||||||
output.push(...result);
|
output.push(...result);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2937,30 +2937,32 @@ const fill = __nccwpck_require__(6330);
|
||||||
const utils = __nccwpck_require__(5207);
|
const utils = __nccwpck_require__(5207);
|
||||||
|
|
||||||
const compile = (ast, options = {}) => {
|
const compile = (ast, options = {}) => {
|
||||||
let walk = (node, parent = {}) => {
|
const walk = (node, parent = {}) => {
|
||||||
let invalidBlock = utils.isInvalidBrace(parent);
|
const invalidBlock = utils.isInvalidBrace(parent);
|
||||||
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||||
let invalid = invalidBlock === true || invalidNode === true;
|
const invalid = invalidBlock === true || invalidNode === true;
|
||||||
let prefix = options.escapeInvalid === true ? '\\' : '';
|
const prefix = options.escapeInvalid === true ? '\\' : '';
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
||||||
if (node.isOpen === true) {
|
if (node.isOpen === true) {
|
||||||
return prefix + node.value;
|
return prefix + node.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.isClose === true) {
|
if (node.isClose === true) {
|
||||||
|
console.log('node.isClose', prefix, node.value);
|
||||||
return prefix + node.value;
|
return prefix + node.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.type === 'open') {
|
if (node.type === 'open') {
|
||||||
return invalid ? (prefix + node.value) : '(';
|
return invalid ? prefix + node.value : '(';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.type === 'close') {
|
if (node.type === 'close') {
|
||||||
return invalid ? (prefix + node.value) : ')';
|
return invalid ? prefix + node.value : ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.type === 'comma') {
|
if (node.type === 'comma') {
|
||||||
return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
|
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.value) {
|
if (node.value) {
|
||||||
|
@ -2968,8 +2970,8 @@ const compile = (ast, options = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.nodes && node.ranges > 0) {
|
if (node.nodes && node.ranges > 0) {
|
||||||
let args = utils.reduce(node.nodes);
|
const args = utils.reduce(node.nodes);
|
||||||
let range = fill(...args, { ...options, wrap: false, toRegex: true });
|
const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
||||||
|
|
||||||
if (range.length !== 0) {
|
if (range.length !== 0) {
|
||||||
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
||||||
|
@ -2977,10 +2979,11 @@ const compile = (ast, options = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.nodes) {
|
if (node.nodes) {
|
||||||
for (let child of node.nodes) {
|
for (const child of node.nodes) {
|
||||||
output += walk(child, node);
|
output += walk(child, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2999,7 +3002,7 @@ module.exports = compile;
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
MAX_LENGTH: 1024 * 64,
|
MAX_LENGTH: 10000,
|
||||||
|
|
||||||
// Digits
|
// Digits
|
||||||
CHAR_0: '0', /* 0 */
|
CHAR_0: '0', /* 0 */
|
||||||
|
@ -3068,7 +3071,7 @@ const stringify = __nccwpck_require__(8750);
|
||||||
const utils = __nccwpck_require__(5207);
|
const utils = __nccwpck_require__(5207);
|
||||||
|
|
||||||
const append = (queue = '', stash = '', enclose = false) => {
|
const append = (queue = '', stash = '', enclose = false) => {
|
||||||
let result = [];
|
const result = [];
|
||||||
|
|
||||||
queue = [].concat(queue);
|
queue = [].concat(queue);
|
||||||
stash = [].concat(stash);
|
stash = [].concat(stash);
|
||||||
|
@ -3078,15 +3081,15 @@ const append = (queue = '', stash = '', enclose = false) => {
|
||||||
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
|
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let item of queue) {
|
for (const item of queue) {
|
||||||
if (Array.isArray(item)) {
|
if (Array.isArray(item)) {
|
||||||
for (let value of item) {
|
for (const value of item) {
|
||||||
result.push(append(value, stash, enclose));
|
result.push(append(value, stash, enclose));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let ele of stash) {
|
for (let ele of stash) {
|
||||||
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
||||||
result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
|
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3094,9 +3097,9 @@ const append = (queue = '', stash = '', enclose = false) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const expand = (ast, options = {}) => {
|
const expand = (ast, options = {}) => {
|
||||||
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
|
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
||||||
|
|
||||||
let walk = (node, parent = {}) => {
|
const walk = (node, parent = {}) => {
|
||||||
node.queue = [];
|
node.queue = [];
|
||||||
|
|
||||||
let p = parent;
|
let p = parent;
|
||||||
|
@ -3118,7 +3121,7 @@ const expand = (ast, options = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.nodes && node.ranges > 0) {
|
if (node.nodes && node.ranges > 0) {
|
||||||
let args = utils.reduce(node.nodes);
|
const args = utils.reduce(node.nodes);
|
||||||
|
|
||||||
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
||||||
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
||||||
|
@ -3134,7 +3137,7 @@ const expand = (ast, options = {}) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let enclose = utils.encloseBrace(node);
|
const enclose = utils.encloseBrace(node);
|
||||||
let queue = node.queue;
|
let queue = node.queue;
|
||||||
let block = node;
|
let block = node;
|
||||||
|
|
||||||
|
@ -3144,7 +3147,7 @@ const expand = (ast, options = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < node.nodes.length; i++) {
|
for (let i = 0; i < node.nodes.length; i++) {
|
||||||
let child = node.nodes[i];
|
const child = node.nodes[i];
|
||||||
|
|
||||||
if (child.type === 'comma' && node.type === 'brace') {
|
if (child.type === 'comma' && node.type === 'brace') {
|
||||||
if (i === 1) queue.push('');
|
if (i === 1) queue.push('');
|
||||||
|
@ -3217,22 +3220,21 @@ const parse = (input, options = {}) => {
|
||||||
throw new TypeError('Expected a string');
|
throw new TypeError('Expected a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
let opts = options || {};
|
const opts = options || {};
|
||||||
let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||||
if (input.length > max) {
|
if (input.length > max) {
|
||||||
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ast = { type: 'root', input, nodes: [] };
|
const ast = { type: 'root', input, nodes: [] };
|
||||||
let stack = [ast];
|
const stack = [ast];
|
||||||
let block = ast;
|
let block = ast;
|
||||||
let prev = ast;
|
let prev = ast;
|
||||||
let brackets = 0;
|
let brackets = 0;
|
||||||
let length = input.length;
|
const length = input.length;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
let value;
|
let value;
|
||||||
let memo = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpers
|
* Helpers
|
||||||
|
@ -3295,7 +3297,6 @@ const parse = (input, options = {}) => {
|
||||||
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
||||||
brackets++;
|
brackets++;
|
||||||
|
|
||||||
let closed = true;
|
|
||||||
let next;
|
let next;
|
||||||
|
|
||||||
while (index < length && (next = advance())) {
|
while (index < length && (next = advance())) {
|
||||||
|
@ -3351,7 +3352,7 @@ const parse = (input, options = {}) => {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
||||||
let open = value;
|
const open = value;
|
||||||
let next;
|
let next;
|
||||||
|
|
||||||
if (options.keepQuotes !== true) {
|
if (options.keepQuotes !== true) {
|
||||||
|
@ -3383,8 +3384,8 @@ const parse = (input, options = {}) => {
|
||||||
if (value === CHAR_LEFT_CURLY_BRACE) {
|
if (value === CHAR_LEFT_CURLY_BRACE) {
|
||||||
depth++;
|
depth++;
|
||||||
|
|
||||||
let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
||||||
let brace = {
|
const brace = {
|
||||||
type: 'brace',
|
type: 'brace',
|
||||||
open: true,
|
open: true,
|
||||||
close: false,
|
close: false,
|
||||||
|
@ -3411,7 +3412,7 @@ const parse = (input, options = {}) => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = 'close';
|
const type = 'close';
|
||||||
block = stack.pop();
|
block = stack.pop();
|
||||||
block.close = true;
|
block.close = true;
|
||||||
|
|
||||||
|
@ -3429,7 +3430,7 @@ const parse = (input, options = {}) => {
|
||||||
if (value === CHAR_COMMA && depth > 0) {
|
if (value === CHAR_COMMA && depth > 0) {
|
||||||
if (block.ranges > 0) {
|
if (block.ranges > 0) {
|
||||||
block.ranges = 0;
|
block.ranges = 0;
|
||||||
let open = block.nodes.shift();
|
const open = block.nodes.shift();
|
||||||
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3443,7 +3444,7 @@ const parse = (input, options = {}) => {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
||||||
let siblings = block.nodes;
|
const siblings = block.nodes;
|
||||||
|
|
||||||
if (depth === 0 || siblings.length === 0) {
|
if (depth === 0 || siblings.length === 0) {
|
||||||
push({ type: 'text', value });
|
push({ type: 'text', value });
|
||||||
|
@ -3470,7 +3471,7 @@ const parse = (input, options = {}) => {
|
||||||
if (prev.type === 'range') {
|
if (prev.type === 'range') {
|
||||||
siblings.pop();
|
siblings.pop();
|
||||||
|
|
||||||
let before = siblings[siblings.length - 1];
|
const before = siblings[siblings.length - 1];
|
||||||
before.value += prev.value + value;
|
before.value += prev.value + value;
|
||||||
prev = before;
|
prev = before;
|
||||||
block.ranges--;
|
block.ranges--;
|
||||||
|
@ -3503,8 +3504,8 @@ const parse = (input, options = {}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// get the location of the block on parent.nodes (block's siblings)
|
// get the location of the block on parent.nodes (block's siblings)
|
||||||
let parent = stack[stack.length - 1];
|
const parent = stack[stack.length - 1];
|
||||||
let index = parent.nodes.indexOf(block);
|
const index = parent.nodes.indexOf(block);
|
||||||
// replace the (invalid) block with it's nodes
|
// replace the (invalid) block with it's nodes
|
||||||
parent.nodes.splice(index, 1, ...block.nodes);
|
parent.nodes.splice(index, 1, ...block.nodes);
|
||||||
}
|
}
|
||||||
|
@ -3528,9 +3529,9 @@ module.exports = parse;
|
||||||
const utils = __nccwpck_require__(5207);
|
const utils = __nccwpck_require__(5207);
|
||||||
|
|
||||||
module.exports = (ast, options = {}) => {
|
module.exports = (ast, options = {}) => {
|
||||||
let stringify = (node, parent = {}) => {
|
const stringify = (node, parent = {}) => {
|
||||||
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
||||||
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
||||||
if (node.value) {
|
if (node.value) {
|
||||||
|
@ -3545,7 +3546,7 @@ module.exports = (ast, options = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.nodes) {
|
if (node.nodes) {
|
||||||
for (let child of node.nodes) {
|
for (const child of node.nodes) {
|
||||||
output += stringify(child);
|
output += stringify(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3596,7 +3597,7 @@ exports.exceedsLimit = (min, max, step = 1, limit) => {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.escapeNode = (block, n = 0, type) => {
|
exports.escapeNode = (block, n = 0, type) => {
|
||||||
let node = block.nodes[n];
|
const node = block.nodes[n];
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
|
|
||||||
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
||||||
|
@ -3665,13 +3666,23 @@ exports.reduce = nodes => nodes.reduce((acc, node) => {
|
||||||
|
|
||||||
exports.flatten = (...args) => {
|
exports.flatten = (...args) => {
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
const flat = arr => {
|
const flat = arr => {
|
||||||
for (let i = 0; i < arr.length; i++) {
|
for (let i = 0; i < arr.length; i++) {
|
||||||
let ele = arr[i];
|
const ele = arr[i];
|
||||||
Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
|
|
||||||
|
if (Array.isArray(ele)) {
|
||||||
|
flat(ele);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ele !== undefined) {
|
||||||
|
result.push(ele);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
flat(args);
|
flat(args);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
@ -6497,7 +6508,7 @@ const toMaxLen = (input, maxLength) => {
|
||||||
return negative ? ('-' + input) : input;
|
return negative ? ('-' + input) : input;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toSequence = (parts, options) => {
|
const toSequence = (parts, options, maxLen) => {
|
||||||
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||||
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||||
|
|
||||||
|
@ -6507,11 +6518,11 @@ const toSequence = (parts, options) => {
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
if (parts.positives.length) {
|
if (parts.positives.length) {
|
||||||
positives = parts.positives.join('|');
|
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts.negatives.length) {
|
if (parts.negatives.length) {
|
||||||
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (positives && negatives) {
|
if (positives && negatives) {
|
||||||
|
@ -6609,7 +6620,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
||||||
|
|
||||||
if (options.toRegex === true) {
|
if (options.toRegex === true) {
|
||||||
return step > 1
|
return step > 1
|
||||||
? toSequence(parts, options)
|
? toSequence(parts, options, maxLen)
|
||||||
: toRegex(range, null, { wrap: false, ...options });
|
: toRegex(range, null, { wrap: false, ...options });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6621,7 +6632,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
|
||||||
return invalidRange(start, end, options);
|
return invalidRange(start, end, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let format = options.transform || (val => String.fromCharCode(val));
|
let format = options.transform || (val => String.fromCharCode(val));
|
||||||
let a = `${start}`.charCodeAt(0);
|
let a = `${start}`.charCodeAt(0);
|
||||||
let b = `${end}`.charCodeAt(0);
|
let b = `${end}`.charCodeAt(0);
|
||||||
|
|
Loading…
Reference in a new issue