Skip to content

Commit

Permalink
chore(package.json): upgrade @codemirror/lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bhsd-harry committed Jun 9, 2024
1 parent ca9a8f0 commit e747821
Show file tree
Hide file tree
Showing 23 changed files with 333 additions and 240 deletions.
4 changes: 2 additions & 2 deletions addon/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ TableToken.prototype.insertTableCell =
const {x, y} = coords;
rawCoords = this.toRawCoords(coords);
if (!rawCoords?.start) {
throw new RangeError(`The specified coordinates are not the starting point of a cell: (${x}, ${y})`);
throw new RangeError(`The specified coordinates are not the starting point of any cell: (${x}, ${y})`);
}
} else {
rawCoords = coords;
Expand Down Expand Up @@ -261,7 +261,7 @@ TableToken.prototype.insertTableCol =
rowLength = layout.map(({length}) => length),
minCol = Math.min(...rowLength);
if (x > minCol) {
throw new RangeError(`Row ${rowLength.indexOf(minCol)} has only ${minCol} columns!`);
throw new RangeError(`Row ${rowLength.indexOf(minCol)} has only ${minCol} column(s)!`);
}
const token = createTd(inner, subtype, attr, this.getAttribute('include'), this.getAttribute('config'));
for (let i = 0; i < layout.length; i++) {
Expand Down
6 changes: 4 additions & 2 deletions addon/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ Token.prototype.findEnclosingHtml =
const {html} = this.getAttribute('config'),
normalTags = new Set(html[0]),
voidTags = new Set(html[2]);
if (tag !== undefined && !html.slice(0, 2).some(tags => tags.includes(tag))) {
throw new RangeError(`Invalid or void tag name: ${tag}`);
if (html[2].includes(tag!)) {
throw new RangeError(`Void tag: ${tag}`);
} else if (tag !== undefined && !html.slice(0, 2).some(tags => tags.includes(tag))) {
throw new RangeError(`Invalid tag name: ${tag}`);
}
const {parentNode} = this;
if (!parentNode) {
Expand Down
10 changes: 5 additions & 5 deletions addon/transclude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TranscludeToken.prototype.setValue =
/** @implements */
function(key, value): void {
if (!this.isTemplate()) {
throw new Error('setValue method is only for templates!');
throw new Error('TranscludeToken.setValue method is only for templates!');
}
const arg = this.getArg(key);
if (arg) {
Expand All @@ -49,7 +49,7 @@ TranscludeToken.prototype.replaceTemplate =
/** @implements */
function(title): void {
if (this.type === 'magic-word') {
throw new Error('replaceTemplate method is only for templates!');
throw new Error('TranscludeToken.replaceTemplate method is only for templates!');
}
const {childNodes} = Parser.parse(title, this.getAttribute('include'), 2, this.getAttribute('config'));
(this.firstChild as AtomToken).replaceChildren(...childNodes);
Expand All @@ -59,7 +59,7 @@ TranscludeToken.prototype.replaceModule =
/** @implements */
function(title): void {
if (this.type !== 'magic-word' || this.name !== 'invoke') {
throw new Error('replaceModule method is only for modules!');
throw new Error('TranscludeToken.replaceModule method is only for modules!');
}
const config = this.getAttribute('config');
if (this.length === 1) {
Expand All @@ -76,9 +76,9 @@ TranscludeToken.prototype.replaceFunction =
/** @implements */
function(func): void {
if (this.type !== 'magic-word' || this.name !== 'invoke') {
throw new Error('replaceModule method is only for modules!');
throw new Error('TranscludeToken.replaceModule method is only for modules!');
} else if (this.length < 2) {
throw new Error('No module name specified yet!');
throw new Error('No module name specified!');
}
const config = this.getAttribute('config');
if (this.length === 2) {
Expand Down
4 changes: 2 additions & 2 deletions lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export abstract class AstElement extends AstNode {

/* NOT FOR BROWSER */

throw new RangeError(`The ${i}th child node is ${oldText.constructor.name}!`);
throw new RangeError(`The child node at position ${i} is ${oldText.constructor.name}!`);
}

/** @private */
Expand Down Expand Up @@ -570,7 +570,7 @@ export abstract class AstElement extends AstNode {
try {
return new RegExp(mt[2], mt[3]).test(String(this.getAttribute(mt[1].trim())));
} catch {
throw new SyntaxError(`Wrong regex: /${mt[2]}/${mt[3]}`);
throw new SyntaxError(`Invalid regular expression: /${mt[2]}/${mt[3]}`);
}
}
default:
Expand Down
6 changes: 3 additions & 3 deletions lib/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export abstract class AstNode implements AstNodeBase {
#insertAdjacent(nodes: readonly (AstNodes | string)[], offset: number): void {
const {parentNode} = this;
if (!parentNode) {
throw new Error('The node has no parent!');
throw new Error('There is no parent node!');
}
const i = parentNode.childNodes.indexOf(this as AstNode as AstNodes) + offset;
for (let j = 0; j < nodes.length; j++) {
Expand Down Expand Up @@ -430,7 +430,7 @@ export abstract class AstNode implements AstNodeBase {
verifyChild(i: number, addition = 0): void {
const {childNodes: {length}} = this;
if (i < -length || i >= length + addition) {
throw new RangeError(`The ${i}th child does not exist!`);
throw new RangeError(`The child node at position ${i} does not exist!`);
}
}

Expand Down Expand Up @@ -531,7 +531,7 @@ export abstract class AstNode implements AstNodeBase {
} else if (other.contains(this)) {
return 1;
} else if (this.getRootNode() !== other.getRootNode()) {
throw new RangeError('Nodes are not in the same tree!');
throw new RangeError('Nodes to be compared are not in the same document!');
}
const aAncestors = [...this.getAncestors().reverse(), this as AstNode as AstNodes],
bAncestors = [...other.getAncestors().reverse(), other],
Expand Down
4 changes: 2 additions & 2 deletions lib/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class AstText extends AstNode {
lint(start = this.getAbsoluteIndex(), errorRegex?: RegExp): LintError[] {
const {data, parentNode, nextSibling, previousSibling} = this;
if (!parentNode) {
throw new Error('Cannot lint an isolated text node!');
throw new Error('An isolated text node cannot be linted!');
}
const {type, name, parentNode: grandparent} = parentNode;
let isHtmlAttrVal = false;
Expand Down Expand Up @@ -382,7 +382,7 @@ export class AstText extends AstNode {
}
const {parentNode, data} = this;
if (!parentNode) {
throw new Error('The text node to be split has no parent!');
throw new Error('The text node to be split has no parent node!');
}
const newText = new AstText(data.slice(offset));
setChildNodes(parentNode, parentNode.childNodes.indexOf(this) + 1, 0, [newText]);
Expand Down
Loading

0 comments on commit e747821

Please sign in to comment.