@markuplint/ml-core 4.0.0-alpha.3 → 4.0.0-alpha.5

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.
Files changed (44) hide show
  1. package/LICENSE +1 -1
  2. package/lib/configs.browser.js +3 -1
  3. package/lib/configs.js +4 -5
  4. package/lib/convert-ruleset.d.ts +1 -1
  5. package/lib/convert-ruleset.js +1 -1
  6. package/lib/index.d.ts +2 -2
  7. package/lib/index.js +2 -2
  8. package/lib/ml-core.d.ts +3 -3
  9. package/lib/ml-core.js +44 -20
  10. package/lib/ml-dom/helper/accname.js +3 -3
  11. package/lib/ml-dom/helper/debug.js +11 -15
  12. package/lib/ml-dom/helper/{getIndent.js → get-indent.js} +14 -4
  13. package/lib/ml-dom/helper/walkers.js +1 -1
  14. package/lib/ml-dom/manipulations/child-node-methods.js +1 -1
  15. package/lib/ml-dom/manipulations/get-children.js +1 -1
  16. package/lib/ml-dom/node/attr.js +13 -3
  17. package/lib/ml-dom/node/character-data.js +1 -1
  18. package/lib/ml-dom/node/document-fragment.js +1 -1
  19. package/lib/ml-dom/node/document.d.ts +1 -1
  20. package/lib/ml-dom/node/document.js +57 -35
  21. package/lib/ml-dom/node/dom-token-list.js +14 -4
  22. package/lib/ml-dom/node/element.d.ts +4 -0
  23. package/lib/ml-dom/node/element.js +36 -18
  24. package/lib/ml-dom/node/named-node-map.js +1 -1
  25. package/lib/ml-dom/node/node-list.js +2 -2
  26. package/lib/ml-dom/node/node-store.js +7 -3
  27. package/lib/ml-dom/node/node.js +14 -3
  28. package/lib/ml-dom/node/parent-node.js +13 -3
  29. package/lib/ml-dom/node/rule-mapper.js +17 -7
  30. package/lib/ml-dom/node/text.js +3 -3
  31. package/lib/ml-dom/node/types.d.ts +9 -2
  32. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -1
  33. package/lib/ml-dom/node/unexpected-call-error.js +1 -1
  34. package/lib/ml-dom/token/token.js +11 -1
  35. package/lib/ml-rule/ml-rule-context.js +6 -2
  36. package/lib/ml-rule/ml-rule.d.ts +1 -1
  37. package/lib/ml-rule/ml-rule.js +12 -2
  38. package/lib/ruleset/index.d.ts +1 -1
  39. package/lib/ruleset/index.js +1 -1
  40. package/lib/test/index.js +1 -1
  41. package/lib/types.d.ts +1 -1
  42. package/lib/utils/get-location-from-chars.js +3 -3
  43. package/package.json +13 -14
  44. /package/lib/ml-dom/helper/{getIndent.d.ts → get-indent.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
- export default class UnexpectedCallError extends Error {
1
+ export declare class UnexpectedCallError extends Error {
2
2
  }
@@ -1,2 +1,2 @@
1
- export default class UnexpectedCallError extends Error {
1
+ export class UnexpectedCallError extends Error {
2
2
  }
@@ -1,5 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
1
12
  var _MLToken_endCol, _MLToken_endLine, _MLToken_endOffset, _MLToken_fixed, _MLToken_raw, _MLToken_startCol, _MLToken_startLine, _MLToken_startOffset;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
13
  export class MLToken {
4
14
  constructor(astToken) {
5
15
  _MLToken_endCol.set(this, void 0);
@@ -1,5 +1,9 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
1
6
  var _MLRuleContext_reports;
2
- import { __classPrivateFieldGet } from "tslib";
3
7
  import { translator } from '@markuplint/i18n';
4
8
  export class MLRuleContext {
5
9
  constructor(
@@ -37,7 +41,7 @@ export class MLRuleContext {
37
41
  this._push(report);
38
42
  }
39
43
  _push(report) {
40
- if (!__classPrivateFieldGet(this, _MLRuleContext_reports, "f").find(r => is(r, report))) {
44
+ if (!__classPrivateFieldGet(this, _MLRuleContext_reports, "f").some(r => is(r, report))) {
41
45
  __classPrivateFieldGet(this, _MLRuleContext_reports, "f").push(report);
42
46
  }
43
47
  }
@@ -1,6 +1,6 @@
1
1
  import type { RuleSeed } from './types.js';
2
2
  import type { MLDocument } from '../ml-dom/node/document.js';
3
- import type Ruleset from '../ruleset/index.js';
3
+ import type { Ruleset } from '../ruleset/index.js';
4
4
  import type { LocaleSet } from '@markuplint/i18n';
5
5
  import type { GlobalRuleInfo, PlainData, Rule, RuleConfigValue, RuleInfo, Severity, Violation } from '@markuplint/ml-config';
6
6
  export declare class MLRule<T extends RuleConfigValue, O extends PlainData = undefined> {
@@ -1,5 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
1
12
  var _MLRule_f, _MLRule_v;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
13
  import { deleteUndefProp } from '@markuplint/ml-config';
4
14
  // @ts-ignore
5
15
  import { isPlainObject } from 'is-plain-object';
@@ -11,7 +21,7 @@ export class MLRule {
11
21
  this.name = o.name;
12
22
  this.defaultSeverity = o.defaultSeverity ?? 'error';
13
23
  // TODO: https://github.com/markuplint/markuplint/issues/808
14
- this.defaultValue = (o.defaultValue !== undefined ? o.defaultValue : true);
24
+ this.defaultValue = (o.defaultValue === undefined ? true : o.defaultValue);
15
25
  this.defaultOptions = o.defaultOptions;
16
26
  __classPrivateFieldSet(this, _MLRule_v, o.verify, "f");
17
27
  __classPrivateFieldSet(this, _MLRule_f, o.fix, "f");
@@ -1,5 +1,5 @@
1
1
  import type { ChildNodeRule, Config, NodeRule, Rules } from '@markuplint/ml-config';
2
- export default class Ruleset {
2
+ export declare class Ruleset {
3
3
  readonly childNodeRules: readonly ChildNodeRule[];
4
4
  readonly nodeRules: readonly NodeRule[];
5
5
  readonly rules: Rules;
@@ -1,4 +1,4 @@
1
- export default class Ruleset {
1
+ export class Ruleset {
2
2
  constructor(config) {
3
3
  this.rules = config.rules ?? {};
4
4
  this.nodeRules = config.nodeRules ?? [];
package/lib/test/index.js CHANGED
@@ -22,7 +22,7 @@ export function createTestElement(sourceCode, options) {
22
22
  if (el && el.is(el.ELEMENT_NODE)) {
23
23
  return el;
24
24
  }
25
- throw TypeError(`Could not parse it to be an element from: ${sourceCode}`);
25
+ throw new TypeError(`Could not parse it to be an element from: ${sourceCode}`);
26
26
  }
27
27
  /**
28
28
  * for test suite
package/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AnyMLRule } from './ml-rule/index.js';
2
- import type Ruleset from './ruleset/index.js';
2
+ import type { Ruleset } from './ruleset/index.js';
3
3
  import type { LocaleSet } from '@markuplint/i18n';
4
4
  import type { MLMarkupLanguageParser, ParserOptions } from '@markuplint/ml-ast';
5
5
  import type { Pretender } from '@markuplint/ml-config';
@@ -1,7 +1,7 @@
1
1
  export function getLocationFromChars(searches, text, currentLine, currentCol) {
2
- const lines = text.split(/\r?\n/g);
2
+ const lines = text.split(/\r?\n/);
3
3
  const foundLocations = [];
4
- lines.forEach((lineText, i) => {
4
+ for (const [i, lineText] of lines.entries()) {
5
5
  let offset = 0;
6
6
  for (const char of lineText) {
7
7
  if (searches.includes(char)) {
@@ -19,6 +19,6 @@ export function getLocationFromChars(searches, text, currentLine, currentCol) {
19
19
  }
20
20
  offset++;
21
21
  }
22
- });
22
+ }
23
23
  return foundLocations;
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "4.0.0-alpha.3",
3
+ "version": "4.0.0-alpha.5",
4
4
  "description": "The core module of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -28,20 +28,19 @@
28
28
  "./lib/configs.js": "./lib/configs.browser.js"
29
29
  },
30
30
  "dependencies": {
31
- "@markuplint/config-presets": "4.0.0-alpha.3",
32
- "@markuplint/html-parser": "4.0.0-alpha.3",
33
- "@markuplint/html-spec": "4.0.0-alpha.3",
34
- "@markuplint/i18n": "4.0.0-alpha.3",
35
- "@markuplint/ml-ast": "4.0.0-alpha.3",
36
- "@markuplint/ml-config": "4.0.0-alpha.3",
37
- "@markuplint/ml-spec": "4.0.0-alpha.3",
38
- "@markuplint/parser-utils": "4.0.0-alpha.3",
39
- "@markuplint/selector": "4.0.0-alpha.3",
40
- "@types/debug": "^4.1.9",
31
+ "@markuplint/config-presets": "4.0.0-alpha.5",
32
+ "@markuplint/html-parser": "4.0.0-alpha.5",
33
+ "@markuplint/html-spec": "4.0.0-alpha.5",
34
+ "@markuplint/i18n": "4.0.0-alpha.5",
35
+ "@markuplint/ml-ast": "4.0.0-alpha.5",
36
+ "@markuplint/ml-config": "4.0.0-alpha.5",
37
+ "@markuplint/ml-spec": "4.0.0-alpha.5",
38
+ "@markuplint/parser-utils": "4.0.0-alpha.5",
39
+ "@markuplint/selector": "4.0.0-alpha.5",
40
+ "@types/debug": "^4.1.10",
41
41
  "debug": "^4.3.4",
42
42
  "is-plain-object": "^5.0.0",
43
- "tslib": "^2.6.2",
44
- "type-fest": "^4.3.1"
43
+ "type-fest": "^4.5.0"
45
44
  },
46
- "gitHead": "380836f7adc1ff7e8eaf9d869e68d29eee8f3b7e"
45
+ "gitHead": "0c3e4690662edf1765bcc4b6411ec5507c1e2ea3"
47
46
  }