-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
925 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"node": "14", | ||
"buildCommand": false, | ||
"sandboxes": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ coverage | |
lib | ||
node_modules | ||
tmp* | ||
/rules |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/markuplint/** | ||
/rules/** |
This file was deleted.
Oops, something went wrong.
Submodule markuplint
deleted from
246d4b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
diff --git a/node_modules/@markuplint/file-resolver/lib/helper.d.ts b/node_modules/@markuplint/file-resolver/lib/helper.d.ts | ||
index 63cb3a6..fff40c0 100644 | ||
--- a/node_modules/@markuplint/file-resolver/lib/helper.d.ts | ||
+++ b/node_modules/@markuplint/file-resolver/lib/helper.d.ts | ||
@@ -10,4 +10,5 @@ export declare function load<T = CosmiConfig>(filePath: string, cacheClear: bool | ||
config: T; | ||
} | null>; | ||
export declare function recursiveLoad(config: Config, filePath: string, files: Set<string>, cacheClear: boolean): Promise<ConfigSet>; | ||
+export declare function margeConfig(a: Config, b: Config): Config; | ||
export {}; | ||
diff --git a/node_modules/@markuplint/file-resolver/lib/helper.js b/node_modules/@markuplint/file-resolver/lib/helper.js | ||
index 6f8e576..26c902e 100644 | ||
--- a/node_modules/@markuplint/file-resolver/lib/helper.js | ||
+++ b/node_modules/@markuplint/file-resolver/lib/helper.js | ||
@@ -99,3 +99,4 @@ exports.recursiveLoad = recursiveLoad; | ||
function margeConfig(a, b) { | ||
return Object.assign(Object.assign(Object.assign({}, a), b), { rules: Object.assign(Object.assign({}, a.rules), b.rules), nodeRules: [...(a.nodeRules || []), ...(b.nodeRules || [])], childNodeRules: [...(a.childNodeRules || []), ...(b.childNodeRules || [])] }); | ||
} | ||
+exports.margeConfig = margeConfig; | ||
diff --git a/node_modules/@markuplint/file-resolver/lib/index.d.ts b/node_modules/@markuplint/file-resolver/lib/index.d.ts | ||
index 41f4bda..ceb6256 100644 | ||
--- a/node_modules/@markuplint/file-resolver/lib/index.d.ts | ||
+++ b/node_modules/@markuplint/file-resolver/lib/index.d.ts | ||
@@ -1,7 +1,7 @@ | ||
export { getAnonymousFile } from './get-anonymous-file'; | ||
export { getFiles } from './get-files'; | ||
export { getFile } from './get-file'; | ||
-export { recursiveLoad } from './helper'; | ||
+export { recursiveLoad, margeConfig } from './helper'; | ||
export { loadConfigFile } from './load-config-file'; | ||
export { MLFile } from './ml-file'; | ||
export { searchConfigFile } from './search-config-file'; | ||
diff --git a/node_modules/@markuplint/file-resolver/lib/index.js b/node_modules/@markuplint/file-resolver/lib/index.js | ||
index ef9b20b..6eb3adf 100644 | ||
--- a/node_modules/@markuplint/file-resolver/lib/index.js | ||
+++ b/node_modules/@markuplint/file-resolver/lib/index.js | ||
@@ -9,6 +9,7 @@ var get_file_1 = require("./get-file"); | ||
Object.defineProperty(exports, "getFile", { enumerable: true, get: function () { return get_file_1.getFile; } }); | ||
var helper_1 = require("./helper"); | ||
Object.defineProperty(exports, "recursiveLoad", { enumerable: true, get: function () { return helper_1.recursiveLoad; } }); | ||
+Object.defineProperty(exports, "margeConfig", { enumerable: true, get: function () { return helper_1.margeConfig; } }); | ||
var load_config_file_1 = require("./load-config-file"); | ||
Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return load_config_file_1.loadConfigFile; } }); | ||
var ml_file_1 = require("./ml-file"); | ||
diff --git a/node_modules/@markuplint/file-resolver/lib/types.d.ts b/node_modules/@markuplint/file-resolver/lib/types.d.ts | ||
index 1203b14..215292d 100644 | ||
--- a/node_modules/@markuplint/file-resolver/lib/types.d.ts | ||
+++ b/node_modules/@markuplint/file-resolver/lib/types.d.ts | ||
@@ -1,5 +1,5 @@ | ||
-import { Config } from '@markuplint/ml-config/'; | ||
-export { Config } from '@markuplint/ml-config/'; | ||
+import { Config } from '@markuplint/ml-config'; | ||
+export { Config } from '@markuplint/ml-config'; | ||
export interface ConfigSet { | ||
config: Config; | ||
files: Set<string>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
diff --git a/node_modules/@markuplint/i18n/lib/index.d.ts b/node_modules/@markuplint/i18n/lib/index.d.ts | ||
index f0be080..c7a3c89 100644 | ||
--- a/node_modules/@markuplint/i18n/lib/index.d.ts | ||
+++ b/node_modules/@markuplint/i18n/lib/index.d.ts | ||
@@ -9,7 +9,7 @@ export interface LocalesKeywords { | ||
} | ||
export declare class I18n { | ||
private static _singleton; | ||
- static create(localeSet: LocaleSet | null): Promise<I18n>; | ||
+ static create(localeSet: LocaleSet | null): I18n; | ||
localeSet: LocaleSet | null; | ||
private constructor(); | ||
translator(): Translator; | ||
diff --git a/node_modules/@markuplint/i18n/lib/index.js b/node_modules/@markuplint/i18n/lib/index.js | ||
index 1836db6..33d11b2 100644 | ||
--- a/node_modules/@markuplint/i18n/lib/index.js | ||
+++ b/node_modules/@markuplint/i18n/lib/index.js | ||
@@ -5,7 +5,7 @@ class I18n { | ||
constructor(localeSet) { | ||
this.localeSet = localeSet; | ||
} | ||
- static async create(localeSet) { | ||
+ static create(localeSet) { | ||
if (!I18n._singleton) { | ||
I18n._singleton = new I18n(localeSet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
diff --git a/node_modules/@markuplint/ml-core/lib/ml-dom/document.js b/node_modules/@markuplint/ml-core/lib/ml-dom/document.js | ||
index 14ea219..635e699 100644 | ||
--- a/node_modules/@markuplint/ml-core/lib/ml-dom/document.js | ||
+++ b/node_modules/@markuplint/ml-core/lib/ml-dom/document.js | ||
@@ -50,22 +50,45 @@ class MLDOMDocument { | ||
} | ||
return treeRoots; | ||
} | ||
- async walk(walker) { | ||
- for (const node of this.nodeList) { | ||
- await walker(node); | ||
- } | ||
+ walk(walker) { | ||
+ /** | ||
+ * The following pattern is used to ensure that all rules run sequentially, | ||
+ * no matter it runs asynchronously or synchronously. | ||
+ */ | ||
+ let _resolve; | ||
+ let _reject; | ||
+ const promise = new Promise((resolve, reject) => { | ||
+ _resolve = resolve; | ||
+ _reject = reject; | ||
+ }); | ||
+ const loop = (index = 0) => { | ||
+ if (index >= this.nodeList.length) { | ||
+ _resolve(); | ||
+ return; | ||
+ } | ||
+ const node = this.nodeList[index]; | ||
+ const result = walker(node); | ||
+ if (result instanceof Promise) { | ||
+ result.then(() => loop(index + 1)).catch(_reject); | ||
+ } | ||
+ else { | ||
+ loop(index + 1); | ||
+ } | ||
+ }; | ||
+ loop(); | ||
+ return promise; | ||
} | ||
- async walkOn(type, walker, skipWhenRuleIsDisabled = true) { | ||
- for (const node of this.nodeList) { | ||
+ walkOn(type, walker, skipWhenRuleIsDisabled = true) { | ||
+ return this.walk(node => { | ||
if (node instanceof tokens_1.MLDOMNode) { | ||
if (skipWhenRuleIsDisabled && node.rule.disabled) { | ||
- continue; | ||
+ return; | ||
} | ||
if (node.is(type)) { | ||
- await walker(node); | ||
+ return walker(node); | ||
} | ||
} | ||
- } | ||
+ }); | ||
} | ||
setRule(rule) { | ||
this.currentRule = rule; | ||
diff --git a/node_modules/@markuplint/ml-core/lib/ml-dom/helper/walkers.d.ts b/node_modules/@markuplint/ml-core/lib/ml-dom/helper/walkers.d.ts | ||
index 1972a2a..d87476b 100644 | ||
--- a/node_modules/@markuplint/ml-core/lib/ml-dom/helper/walkers.d.ts | ||
+++ b/node_modules/@markuplint/ml-core/lib/ml-dom/helper/walkers.d.ts | ||
@@ -1,5 +1,5 @@ | ||
import { AnonymousNode } from '../types'; | ||
import { RuleConfigValue } from '@markuplint/ml-config'; | ||
-export declare type Walker<T extends RuleConfigValue, O = null, N = AnonymousNode<T, O>> = (node: N) => Promise<void>; | ||
+export declare type Walker<T extends RuleConfigValue, O = null, N = AnonymousNode<T, O>> = (node: N) => void | Promise<void>; | ||
export declare type SyncWalker<T extends RuleConfigValue, O = null, N = AnonymousNode<T, O>> = (node: N) => void; | ||
export declare function syncWalk<T extends RuleConfigValue, O = null>(nodeList: AnonymousNode<T, O>[], walker: SyncWalker<T, O>): void; | ||
diff --git a/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.d.ts b/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.d.ts | ||
index e9f8442..dd4a74b 100644 | ||
--- a/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.d.ts | ||
+++ b/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.d.ts | ||
@@ -9,6 +9,16 @@ export declare class MLRule<T extends RuleConfigValue, O = null> { | ||
readonly defaultServerity: Severity; | ||
readonly defaultValue: T; | ||
readonly defaultOptions: O; | ||
+ /** | ||
+ * The following getter is unused internally, | ||
+ * only for extending from 3rd party library | ||
+ */ | ||
+ private get v(); | ||
+ /** | ||
+ * The following getter is unused internally, | ||
+ * only for extending from 3rd party library | ||
+ */ | ||
+ private get f(); | ||
private constructor(); | ||
verify(document: Document<T, O>, i18n: I18n, rule: RuleInfo<T, O>): Promise<VerifiedResult[]>; | ||
fix(document: Document<T, O>, rule: RuleInfo<T, O>): Promise<void>; | ||
diff --git a/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.js b/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.js | ||
index 74086ec..7393b32 100644 | ||
--- a/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.js | ||
+++ b/node_modules/@markuplint/ml-core/lib/ml-rule/ml-rule.js | ||
@@ -29,6 +29,20 @@ class MLRule { | ||
static create(options) { | ||
return new MLRule(options); | ||
} | ||
+ /** | ||
+ * The following getter is unused internally, | ||
+ * only for extending from 3rd party library | ||
+ */ | ||
+ get v() { | ||
+ return __classPrivateFieldGet(this, _v); | ||
+ } | ||
+ /** | ||
+ * The following getter is unused internally, | ||
+ * only for extending from 3rd party library | ||
+ */ | ||
+ get f() { | ||
+ return __classPrivateFieldGet(this, _f); | ||
+ } | ||
async verify(document, i18n, rule) { | ||
if (!__classPrivateFieldGet(this, _v)) { | ||
return []; | ||
diff --git a/node_modules/@markuplint/ml-core/lib/ml-rule/types.d.ts b/node_modules/@markuplint/ml-core/lib/ml-rule/types.d.ts | ||
index 6202d55..1488927 100644 | ||
--- a/node_modules/@markuplint/ml-core/lib/ml-rule/types.d.ts | ||
+++ b/node_modules/@markuplint/ml-core/lib/ml-rule/types.d.ts | ||
@@ -6,6 +6,6 @@ export interface MLRuleOptions<T extends RuleConfigValue, O = null> { | ||
defaultLevel?: Severity; | ||
defaultValue: T; | ||
defaultOptions: O; | ||
- verify(document: Document<T, O>, translate: Translator, globalRule: RuleInfo<T, O>): Promise<Result[]>; | ||
- fix?(document: Document<T, O>, globalRule: RuleInfo<T, O>): Promise<void>; | ||
+ verify(document: Document<T, O>, translate: Translator, globalRule: RuleInfo<T, O>): Result[] | Promise<Result[]>; | ||
+ fix?(document: Document<T, O>, globalRule: RuleInfo<T, O>): void | Promise<void>; | ||
} |
Oops, something went wrong.