@markuplint/shared 5.0.0-dev.5 → 5.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/lib/errors/config-error.d.ts +16 -0
- package/lib/errors/config-error.js +20 -0
- package/lib/errors/guards.d.ts +12 -0
- package/lib/errors/guards.js +20 -0
- package/lib/errors/index.d.ts +6 -0
- package/lib/errors/index.js +5 -0
- package/lib/errors/parser-error.d.ts +55 -0
- package/lib/errors/parser-error.js +59 -0
- package/lib/errors/selector-error.d.ts +13 -0
- package/lib/errors/selector-error.js +16 -0
- package/lib/errors/unexpected-call-error.d.ts +6 -0
- package/lib/errors/unexpected-call-error.js +6 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-rc.1](https://github.com/markuplint/markuplint/compare/v5.0.0-rc.0...v5.0.0-rc.1) (2026-03-27)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- address QA review findings for error consolidation ([ac994ee](https://github.com/markuplint/markuplint/commit/ac994ee4b4150dbcb18b30d412853df086627f87))
|
|
11
|
+
|
|
12
|
+
# [5.0.0-rc.0](https://github.com/markuplint/markuplint/compare/v5.0.0-alpha.3...v5.0.0-rc.0) (2026-03-12)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @markuplint/shared
|
|
15
|
+
|
|
6
16
|
# [5.0.0-alpha.3](https://github.com/markuplint/markuplint/compare/v5.0.0-alpha.2...v5.0.0-alpha.3) (2026-02-26)
|
|
7
17
|
|
|
8
18
|
### Features
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a configuration file cannot be loaded
|
|
3
|
+
* (Tier 2 — Per-File Recoverable). The affected file is skipped
|
|
4
|
+
* while other files continue to be processed.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConfigLoadError extends Error {
|
|
7
|
+
filePath: string;
|
|
8
|
+
name: string;
|
|
9
|
+
referrer: string;
|
|
10
|
+
/**
|
|
11
|
+
* @param message - Description of the load failure
|
|
12
|
+
* @param filePath - Absolute path to the config file that failed to load
|
|
13
|
+
* @param referrer - Path of the file that referenced this config
|
|
14
|
+
*/
|
|
15
|
+
constructor(message: string, filePath: string, referrer: string);
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a configuration file cannot be loaded
|
|
3
|
+
* (Tier 2 — Per-File Recoverable). The affected file is skipped
|
|
4
|
+
* while other files continue to be processed.
|
|
5
|
+
*/
|
|
6
|
+
export class ConfigLoadError extends Error {
|
|
7
|
+
filePath;
|
|
8
|
+
name = 'ConfigLoadError';
|
|
9
|
+
referrer;
|
|
10
|
+
/**
|
|
11
|
+
* @param message - Description of the load failure
|
|
12
|
+
* @param filePath - Absolute path to the config file that failed to load
|
|
13
|
+
* @param referrer - Path of the file that referenced this config
|
|
14
|
+
*/
|
|
15
|
+
constructor(message, filePath, referrer) {
|
|
16
|
+
super(message + ` in ${referrer}`);
|
|
17
|
+
this.filePath = filePath;
|
|
18
|
+
this.referrer = referrer;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the error is a Tier 1 (Fatal) error that must
|
|
3
|
+
* never be caught or converted. These indicate implementation bugs
|
|
4
|
+
* or broken invariants.
|
|
5
|
+
*
|
|
6
|
+
* See docs/architectures/ERROR-HANDLING.md — Tier 1 for the full list.
|
|
7
|
+
*
|
|
8
|
+
* @param error - The caught value to classify
|
|
9
|
+
* @returns `true` for fatal errors (`TypeError`, `ReferenceError`, `RangeError`,
|
|
10
|
+
* `SyntaxError`, `UnexpectedCallError`, or non-`Error` throws); `false` otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function isFatalError(error: unknown): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UnexpectedCallError } from './unexpected-call-error.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the error is a Tier 1 (Fatal) error that must
|
|
4
|
+
* never be caught or converted. These indicate implementation bugs
|
|
5
|
+
* or broken invariants.
|
|
6
|
+
*
|
|
7
|
+
* See docs/architectures/ERROR-HANDLING.md — Tier 1 for the full list.
|
|
8
|
+
*
|
|
9
|
+
* @param error - The caught value to classify
|
|
10
|
+
* @returns `true` for fatal errors (`TypeError`, `ReferenceError`, `RangeError`,
|
|
11
|
+
* `SyntaxError`, `UnexpectedCallError`, or non-`Error` throws); `false` otherwise
|
|
12
|
+
*/
|
|
13
|
+
export function isFatalError(error) {
|
|
14
|
+
return (error instanceof TypeError ||
|
|
15
|
+
error instanceof ReferenceError ||
|
|
16
|
+
error instanceof RangeError ||
|
|
17
|
+
error instanceof SyntaxError ||
|
|
18
|
+
error instanceof UnexpectedCallError ||
|
|
19
|
+
!(error instanceof Error));
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ConfigLoadError } from './config-error.js';
|
|
2
|
+
export { isFatalError } from './guards.js';
|
|
3
|
+
export { ConfigParserError, ParserError, TargetParserError } from './parser-error.js';
|
|
4
|
+
export type { ParserErrorInfo } from './parser-error.js';
|
|
5
|
+
export { InvalidSelectorError } from './selector-error.js';
|
|
6
|
+
export { UnexpectedCallError } from './unexpected-call-error.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ConfigLoadError } from './config-error.js';
|
|
2
|
+
export { isFatalError } from './guards.js';
|
|
3
|
+
export { ConfigParserError, ParserError, TargetParserError } from './parser-error.js';
|
|
4
|
+
export { InvalidSelectorError } from './selector-error.js';
|
|
5
|
+
export { UnexpectedCallError } from './unexpected-call-error.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Positional and contextual information associated with a parser error,
|
|
3
|
+
* used to construct meaningful error messages with source locations.
|
|
4
|
+
*/
|
|
5
|
+
export type ParserErrorInfo = {
|
|
6
|
+
readonly line?: number;
|
|
7
|
+
readonly col?: number;
|
|
8
|
+
readonly raw?: string;
|
|
9
|
+
readonly stack?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* An error that occurs during parsing, carrying the source line, column,
|
|
13
|
+
* and raw text where the error was encountered.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ParserError extends Error {
|
|
16
|
+
readonly col: number;
|
|
17
|
+
readonly line: number;
|
|
18
|
+
name: string;
|
|
19
|
+
readonly raw: string;
|
|
20
|
+
/**
|
|
21
|
+
* @param message - Human-readable description of the parse error
|
|
22
|
+
* @param info - Source location and context where the error occurred
|
|
23
|
+
*/
|
|
24
|
+
constructor(message: string, info: ParserErrorInfo);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A parser error specific to a particular HTML element, including
|
|
28
|
+
* the node name of the element that caused the error in the message.
|
|
29
|
+
*/
|
|
30
|
+
export declare class TargetParserError extends ParserError {
|
|
31
|
+
name: string;
|
|
32
|
+
readonly nodeName: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* @param message - Human-readable description of the parse error
|
|
35
|
+
* @param info - Source location, context, and the element's node name
|
|
36
|
+
*/
|
|
37
|
+
constructor(message: string, info: ParserErrorInfo & {
|
|
38
|
+
readonly nodeName?: string | null;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A parser error that occurs while reading a configuration file,
|
|
43
|
+
* including the file path in the error message for easier debugging.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ConfigParserError extends ParserError {
|
|
46
|
+
readonly filePath: string;
|
|
47
|
+
name: string;
|
|
48
|
+
/**
|
|
49
|
+
* @param message - Human-readable description of the parse error
|
|
50
|
+
* @param info - Source location, context, and path to the config file
|
|
51
|
+
*/
|
|
52
|
+
constructor(message: string, info: ParserErrorInfo & {
|
|
53
|
+
readonly filePath: string;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error that occurs during parsing, carrying the source line, column,
|
|
3
|
+
* and raw text where the error was encountered.
|
|
4
|
+
*/
|
|
5
|
+
export class ParserError extends Error {
|
|
6
|
+
col;
|
|
7
|
+
line;
|
|
8
|
+
name = 'ParserError';
|
|
9
|
+
raw;
|
|
10
|
+
/**
|
|
11
|
+
* @param message - Human-readable description of the parse error
|
|
12
|
+
* @param info - Source location and context where the error occurred
|
|
13
|
+
*/
|
|
14
|
+
constructor(message, info) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.line = info.line ?? 1;
|
|
17
|
+
this.col = info.col ?? 0;
|
|
18
|
+
this.raw = info.raw ?? '';
|
|
19
|
+
this.stack = info.stack ?? this.stack;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A parser error specific to a particular HTML element, including
|
|
24
|
+
* the node name of the element that caused the error in the message.
|
|
25
|
+
*/
|
|
26
|
+
export class TargetParserError extends ParserError {
|
|
27
|
+
name = 'TargetParserError';
|
|
28
|
+
nodeName;
|
|
29
|
+
/**
|
|
30
|
+
* @param message - Human-readable description of the parse error
|
|
31
|
+
* @param info - Source location, context, and the element's node name
|
|
32
|
+
*/
|
|
33
|
+
constructor(message, info) {
|
|
34
|
+
const errMsg = info.nodeName
|
|
35
|
+
? `The ${info.nodeName} is invalid element (${info.line}:${info.col}): ${message}`
|
|
36
|
+
: message;
|
|
37
|
+
super(errMsg, info);
|
|
38
|
+
this.nodeName = info.nodeName ?? null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A parser error that occurs while reading a configuration file,
|
|
43
|
+
* including the file path in the error message for easier debugging.
|
|
44
|
+
*/
|
|
45
|
+
export class ConfigParserError extends ParserError {
|
|
46
|
+
filePath;
|
|
47
|
+
name = 'ConfigParserError';
|
|
48
|
+
/**
|
|
49
|
+
* @param message - Human-readable description of the parse error
|
|
50
|
+
* @param info - Source location, context, and path to the config file
|
|
51
|
+
*/
|
|
52
|
+
constructor(message, info) {
|
|
53
|
+
const pos = info.line != null && info.col != null ? `(${info.line}:${info.col})` : '';
|
|
54
|
+
const file = ` in ${info.filePath}${pos}`;
|
|
55
|
+
const errMsg = `${message}${file}`;
|
|
56
|
+
super(errMsg, info);
|
|
57
|
+
this.filePath = info.filePath;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a CSS selector string cannot be parsed.
|
|
3
|
+
*/
|
|
4
|
+
export declare class InvalidSelectorError extends Error {
|
|
5
|
+
name: string;
|
|
6
|
+
/** The invalid selector string that caused this error */
|
|
7
|
+
selector: string;
|
|
8
|
+
/**
|
|
9
|
+
* @param selector - The invalid selector string
|
|
10
|
+
* @param message - An optional custom error message
|
|
11
|
+
*/
|
|
12
|
+
constructor(selector: string, message?: string);
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a CSS selector string cannot be parsed.
|
|
3
|
+
*/
|
|
4
|
+
export class InvalidSelectorError extends Error {
|
|
5
|
+
name = 'InvalidSelectorError';
|
|
6
|
+
/** The invalid selector string that caused this error */
|
|
7
|
+
selector;
|
|
8
|
+
/**
|
|
9
|
+
* @param selector - The invalid selector string
|
|
10
|
+
* @param message - An optional custom error message
|
|
11
|
+
*/
|
|
12
|
+
constructor(selector, message) {
|
|
13
|
+
super(message ?? `Invalid selector: "${selector}"`);
|
|
14
|
+
this.selector = selector;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/shared",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-rc.1",
|
|
4
4
|
"description": "Shared functions for Markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"html-entities": "2.6.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "0d6b4324d9a7d6b9e1ba57d4a57e45d36975cba9"
|
|
33
33
|
}
|