zemdomu 1.3.6 → 1.3.7

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.
@@ -1,2 +1,13 @@
1
- import { Rule } from '../linter';
1
+ import { Rule } from "../linter";
2
+ /**
3
+ * Enforce heading order with symmetric skip detection.
4
+ *
5
+ * Flags:
6
+ * - Upward skip: h2 -> h4 (new > last + 1)
7
+ * - Downward skip: h6 -> h4 (last > new + 1)
8
+ * - Reset to h1: any h1 after a non-h1 (e.g. h6 -> h1)
9
+ *
10
+ * First heading in a file never warns.
11
+ * Does not auto-reset on <section>/<article> yet; add if you want outline semantics.
12
+ */
2
13
  export default function enforceHeadingOrder(): Rule;
@@ -2,57 +2,82 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = enforceHeadingOrder;
4
4
  const utils_1 = require("./utils");
5
+ /**
6
+ * Enforce heading order with symmetric skip detection.
7
+ *
8
+ * Flags:
9
+ * - Upward skip: h2 -> h4 (new > last + 1)
10
+ * - Downward skip: h6 -> h4 (last > new + 1)
11
+ * - Reset to h1: any h1 after a non-h1 (e.g. h6 -> h1)
12
+ *
13
+ * First heading in a file never warns.
14
+ * Does not auto-reset on <section>/<article> yet; add if you want outline semantics.
15
+ */
5
16
  function enforceHeadingOrder() {
6
- let last = 0;
7
- let seen = false;
17
+ let last = 0; // 0 means “no heading seen yet”
8
18
  return {
9
- name: 'enforceHeadingOrder',
19
+ name: "enforceHeadingOrder",
10
20
  init() {
11
21
  last = 0;
12
- seen = false;
13
22
  },
14
23
  enterHtml(node) {
15
- if (node.type === 'element' && /^h[1-6]$/.test(node.tagName)) {
16
- const lvl = parseInt(node.tagName.charAt(1), 10);
17
- let message = null;
18
- if (last && lvl > last + 1) {
19
- message = `Heading level skipped: <${node.tagName}> after <h${last}>`;
20
- }
21
- else if (seen && lvl === 1 && last !== 1) {
22
- message = `Heading level skipped: <${node.tagName}> after <h${last}>`;
23
- }
24
- last = lvl;
25
- seen = true;
26
- if (message) {
27
- last = lvl;
28
- return [{ line: 0, column: 0, message, rule: 'enforceHeadingOrder' }];
29
- }
24
+ if (!(node.type === "element" && /^h[1-6]$/.test(node.tagName)))
30
25
  return [];
31
- }
32
- return [];
26
+ const lvl = parseInt(node.tagName[1], 10);
27
+ const msg = computeMessage(lvl, last, node.tagName);
28
+ last = lvl;
29
+ if (!msg)
30
+ return [];
31
+ // simpleHtmlParser nodes don’t carry source positions here; anchor at (0,0)
32
+ return [
33
+ {
34
+ line: 0,
35
+ column: 0,
36
+ message: msg,
37
+ rule: "enforceHeadingOrder",
38
+ },
39
+ ];
33
40
  },
34
41
  enterJsx(path) {
35
42
  var _a, _b, _c, _d;
36
43
  const tag = (0, utils_1.getTag)(path);
37
- if (/^h[1-6]$/.test(tag)) {
38
- const lvl = parseInt(tag.charAt(1), 10);
39
- let message = null;
40
- if (last && lvl > last + 1) {
41
- message = `Heading level skipped: <${tag}> after <h${last}>`;
42
- }
43
- else if (seen && lvl === 1 && last !== 1) {
44
- message = `Heading level skipped: <${tag}> after <h${last}>`;
45
- }
46
- last = lvl;
47
- seen = true;
48
- if (message) {
49
- const line = ((_b = (_a = path.node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 1) - 1;
50
- const column = (_d = (_c = path.node.loc) === null || _c === void 0 ? void 0 : _c.start.column) !== null && _d !== void 0 ? _d : 0;
51
- return [{ line, column, message, rule: 'enforceHeadingOrder' }];
52
- }
44
+ if (!/^h[1-6]$/.test(tag))
45
+ return [];
46
+ const lvl = parseInt(tag[1], 10);
47
+ const msg = computeMessage(lvl, last, tag);
48
+ last = lvl;
49
+ if (!msg)
53
50
  return [];
54
- }
55
- return [];
51
+ const line = ((_b = (_a = path.node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 1) - 1; // VS Code is 0-based
52
+ const column = (_d = (_c = path.node.loc) === null || _c === void 0 ? void 0 : _c.start.column) !== null && _d !== void 0 ? _d : 0;
53
+ return [
54
+ {
55
+ line,
56
+ column,
57
+ message: msg,
58
+ rule: "enforceHeadingOrder",
59
+ },
60
+ ];
56
61
  },
57
62
  };
58
63
  }
64
+ /**
65
+ * Return a human-readable message if the new level violates order, else null.
66
+ */
67
+ function computeMessage(newLvl, lastLvl, newTag) {
68
+ if (lastLvl === 0)
69
+ return null; // first heading seen
70
+ // Any h1 after a non-h1 is considered a reset-skip
71
+ if (newLvl === 1 && lastLvl !== 1) {
72
+ return `Heading level skipped: <${newTag}> after <h${lastLvl}>`;
73
+ }
74
+ // Upward skip (e.g. h2 -> h4)
75
+ if (newLvl > lastLvl + 1) {
76
+ return `Heading level skipped: <${newTag}> after <h${lastLvl}>`;
77
+ }
78
+ // Downward skip (e.g. h6 -> h4)
79
+ if (lastLvl > newLvl + 1) {
80
+ return `Heading level skipped: <${newTag}> after <h${lastLvl}>`;
81
+ }
82
+ return null;
83
+ }
@@ -2,57 +2,82 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = enforceHeadingOrder;
4
4
  const utils_1 = require("./utils");
5
+ /**
6
+ * Enforce heading order with symmetric skip detection.
7
+ *
8
+ * Flags:
9
+ * - Upward skip: h2 -> h4 (new > last + 1)
10
+ * - Downward skip: h6 -> h4 (last > new + 1)
11
+ * - Reset to h1: any h1 after a non-h1 (e.g. h6 -> h1)
12
+ *
13
+ * First heading in a file never warns.
14
+ * Does not auto-reset on <section>/<article> yet; add if you want outline semantics.
15
+ */
5
16
  function enforceHeadingOrder() {
6
- let last = 0;
7
- let seen = false;
17
+ let last = 0; // 0 means “no heading seen yet”
8
18
  return {
9
- name: 'enforceHeadingOrder',
19
+ name: "enforceHeadingOrder",
10
20
  init() {
11
21
  last = 0;
12
- seen = false;
13
22
  },
14
23
  enterHtml(node) {
15
- if (node.type === 'element' && /^h[1-6]$/.test(node.tagName)) {
16
- const lvl = parseInt(node.tagName.charAt(1), 10);
17
- let message = null;
18
- if (last && lvl > last + 1) {
19
- message = `Heading level skipped: <${node.tagName}> after <h${last}>`;
20
- }
21
- else if (seen && lvl === 1 && last !== 1) {
22
- message = `Heading level skipped: <${node.tagName}> after <h${last}>`;
23
- }
24
- last = lvl;
25
- seen = true;
26
- if (message) {
27
- last = lvl;
28
- return [{ line: 0, column: 0, message, rule: 'enforceHeadingOrder' }];
29
- }
24
+ if (!(node.type === "element" && /^h[1-6]$/.test(node.tagName)))
30
25
  return [];
31
- }
32
- return [];
26
+ const lvl = parseInt(node.tagName[1], 10);
27
+ const msg = computeMessage(lvl, last, node.tagName);
28
+ last = lvl;
29
+ if (!msg)
30
+ return [];
31
+ // simpleHtmlParser nodes don’t carry source positions here; anchor at (0,0)
32
+ return [
33
+ {
34
+ line: 0,
35
+ column: 0,
36
+ message: msg,
37
+ rule: "enforceHeadingOrder",
38
+ },
39
+ ];
33
40
  },
34
41
  enterJsx(path) {
35
42
  var _a, _b, _c, _d;
36
43
  const tag = (0, utils_1.getTag)(path);
37
- if (/^h[1-6]$/.test(tag)) {
38
- const lvl = parseInt(tag.charAt(1), 10);
39
- let message = null;
40
- if (last && lvl > last + 1) {
41
- message = `Heading level skipped: <${tag}> after <h${last}>`;
42
- }
43
- else if (seen && lvl === 1 && last !== 1) {
44
- message = `Heading level skipped: <${tag}> after <h${last}>`;
45
- }
46
- last = lvl;
47
- seen = true;
48
- if (message) {
49
- const line = ((_b = (_a = path.node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 1) - 1;
50
- const column = (_d = (_c = path.node.loc) === null || _c === void 0 ? void 0 : _c.start.column) !== null && _d !== void 0 ? _d : 0;
51
- return [{ line, column, message, rule: 'enforceHeadingOrder' }];
52
- }
44
+ if (!/^h[1-6]$/.test(tag))
45
+ return [];
46
+ const lvl = parseInt(tag[1], 10);
47
+ const msg = computeMessage(lvl, last, tag);
48
+ last = lvl;
49
+ if (!msg)
53
50
  return [];
54
- }
55
- return [];
51
+ const line = ((_b = (_a = path.node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 1) - 1; // VS Code is 0-based
52
+ const column = (_d = (_c = path.node.loc) === null || _c === void 0 ? void 0 : _c.start.column) !== null && _d !== void 0 ? _d : 0;
53
+ return [
54
+ {
55
+ line,
56
+ column,
57
+ message: msg,
58
+ rule: "enforceHeadingOrder",
59
+ },
60
+ ];
56
61
  },
57
62
  };
58
63
  }
64
+ /**
65
+ * Return a human-readable message if the new level violates order, else null.
66
+ */
67
+ function computeMessage(newLvl, lastLvl, newTag) {
68
+ if (lastLvl === 0)
69
+ return null; // first heading seen
70
+ // Any h1 after a non-h1 is considered a reset-skip
71
+ if (newLvl === 1 && lastLvl !== 1) {
72
+ return `Heading level skipped: <${newTag}> after <h${lastLvl}>`;
73
+ }
74
+ // Upward skip (e.g. h2 -> h4)
75
+ if (newLvl > lastLvl + 1) {
76
+ return `Heading level skipped: <${newTag}> after <h${lastLvl}>`;
77
+ }
78
+ // Downward skip (e.g. h6 -> h4)
79
+ if (lastLvl > newLvl + 1) {
80
+ return `Heading level skipped: <${newTag}> after <h${lastLvl}>`;
81
+ }
82
+ return null;
83
+ }
@@ -1,7 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.default = Button;
4
37
  const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const React = __importStar(require("react"));
5
39
  function Button() {
6
40
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Button" }), (0, jsx_runtime_1.jsx)("h5", { children: "Subsection" })] }));
7
41
  }
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.default = Page;
7
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const React = __importStar(require("react"));
8
42
  const Section_1 = __importDefault(require("@alias/Section"));
9
43
  function Page() {
10
44
  return ((0, jsx_runtime_1.jsxs)("main", { children: [(0, jsx_runtime_1.jsx)("h1", { children: "Hello" }), (0, jsx_runtime_1.jsx)(Section_1.default, {})] }));
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.default = Section;
7
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const React = __importStar(require("react"));
8
42
  const SubSection_1 = __importDefault(require("@alias/SubSection"));
9
43
  function Section() {
10
44
  return ((0, jsx_runtime_1.jsxs)("section", { children: [(0, jsx_runtime_1.jsx)("h2", { children: "Section Title" }), (0, jsx_runtime_1.jsx)(SubSection_1.default, {})] }));
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.default = SubSection;
7
40
  const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const React = __importStar(require("react"));
8
42
  const Button_1 = __importDefault(require("@alias/Button"));
9
43
  function SubSection() {
10
44
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { children: "SubSection" }), (0, jsx_runtime_1.jsx)(Button_1.default, {})] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zemdomu",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Semantic HTML linter for HTML, JSX, and TSX. Detects accessibility, SEO, and structure issues before deployment.",
5
5
  "main": "./out/index.js",
6
6
  "types": "./out/index.d.ts",