king-design-analyzer 2.1.6 → 2.1.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.
package/dist/ast/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  require('../chunk-YTEYDSDW.js');
4
- var chunkGW5YOUB7_js = require('../chunk-GW5YOUB7.js');
4
+ var chunkYWY3D4J7_js = require('../chunk-YWY3D4J7.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "analyzeCodeWithAST", {
9
9
  enumerable: true,
10
- get: function () { return chunkGW5YOUB7_js.analyzeCodeWithAST; }
10
+ get: function () { return chunkYWY3D4J7_js.analyzeCodeWithAST; }
11
11
  });
12
12
  Object.defineProperty(exports, "componentRegistry", {
13
13
  enumerable: true,
14
- get: function () { return chunkGW5YOUB7_js.componentRegistry; }
14
+ get: function () { return chunkYWY3D4J7_js.componentRegistry; }
15
15
  });
@@ -1,2 +1,2 @@
1
1
  import '../chunk-5H7N2A5X.mjs';
2
- export { analyzeCodeWithAST, componentRegistry } from '../chunk-UYVGHUC5.mjs';
2
+ export { analyzeCodeWithAST, componentRegistry } from '../chunk-HDV7ETXE.mjs';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkGW5YOUB7_js = require('./chunk-GW5YOUB7.js');
3
+ var chunkYWY3D4J7_js = require('./chunk-YWY3D4J7.js');
4
4
  var chunkD3Y6FGWA_js = require('./chunk-D3Y6FGWA.js');
5
5
  var chunkHPAUCD5I_js = require('./chunk-HPAUCD5I.js');
6
6
 
@@ -64,7 +64,7 @@ function validateCompilation(code) {
64
64
  }
65
65
  async function validateAST(code) {
66
66
  try {
67
- const violations = await chunkGW5YOUB7_js.analyzeCodeWithAST(code);
67
+ const violations = await chunkYWY3D4J7_js.analyzeCodeWithAST(code);
68
68
  if (violations.length > 0) {
69
69
  return {
70
70
  name: "AST\u89C4\u5219\u68C0\u67E5",
@@ -1,4 +1,4 @@
1
- import { analyzeCodeWithAST } from './chunk-UYVGHUC5.mjs';
1
+ import { analyzeCodeWithAST } from './chunk-HDV7ETXE.mjs';
2
2
  import { validateRuntimePrecheck } from './chunk-NZ6TLWMD.mjs';
3
3
  import { compileSFC } from './chunk-L4DS3EXI.mjs';
4
4
 
@@ -510,6 +510,15 @@ var NATIVE_HTML_ATTRIBUTES = /* @__PURE__ */ new Set([
510
510
  "aria-controls",
511
511
  "aria-haspopup"
512
512
  ]);
513
+ var STRICT_CHECK_ATTRIBUTES = /* @__PURE__ */ new Set([
514
+ "required",
515
+ "disabled",
516
+ "readonly",
517
+ "value",
518
+ "name",
519
+ "checked",
520
+ "selected"
521
+ ]);
513
522
  var VERSATILE_COMPONENTS = /* @__PURE__ */ new Set([
514
523
  "BillTypes",
515
524
  "Region",
@@ -900,6 +909,23 @@ function checkComponentSpecificRules(tagName, node, violations) {
900
909
  }
901
910
  });
902
911
  }
912
+ if (tagName === "TableColumn") {
913
+ node.children?.forEach((child) => {
914
+ if (child.type === 1 && child.tag === "template") {
915
+ const slotProp = child.props?.find((p) => p.type === 7 && p.name === "slot");
916
+ if (slotProp && slotProp.exp && slotProp.exp.content) {
917
+ const exp = slotProp.exp.content.trim();
918
+ if (exp.startsWith("{") && exp.endsWith("}")) {
919
+ violations.push({
920
+ rule: "TableColumn \u63D2\u69FD\u53C2\u6570\u5E94\u4E3A\u6570\u7EC4\u7ED3\u6784",
921
+ match: exp,
922
+ suggestion: `King Design \u8868\u683C\u63D2\u69FD\u53C2\u6570\u4E3A\u6570\u7EC4\u987A\u5E8F\u4F20\u9012\uFF0C\u8BF7\u5C06 ${exp} \u6539\u4E3A [row]`
923
+ });
924
+ }
925
+ }
926
+ }
927
+ });
928
+ }
903
929
  }
904
930
  function checkProps(tagName, node, metadata, violations) {
905
931
  let customTagName = null;
@@ -923,10 +949,12 @@ function checkProps(tagName, node, metadata, violations) {
923
949
  const isDynamicallyAllowed = dynamicAllowedProps.includes(propName);
924
950
  const isBuiltinProp = ["class", "style", "key", "ref"].includes(propName) || propName.startsWith("data-");
925
951
  const isNativeHtmlAttr = NATIVE_HTML_ATTRIBUTES.has(propName) || propName.startsWith("aria-");
926
- if (!isPropValid && !isDynamicallyAllowed && !isBuiltinProp && !isNativeHtmlAttr) {
952
+ const isStrictAttr = STRICT_CHECK_ATTRIBUTES.has(propName);
953
+ const isNativeIgnored = isNativeHtmlAttr && isStrictAttr && metadata.props;
954
+ if (!isPropValid && !isDynamicallyAllowed && !isBuiltinProp && (!isNativeHtmlAttr || isNativeIgnored)) {
927
955
  if (metadata.props && metadata.props.length > 0) {
928
956
  violations.push({
929
- rule: `\u5C5E\u6027 ${propName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
957
+ rule: `\u5C5E\u6027 ${propName} \u4E0D\u5B58\u5728\u4E8E ${tagName}${isNativeIgnored ? " (\u8BE5\u7EC4\u4EF6\u4E0D\u652F\u6301\u6B64\u539F\u751F\u5C5E\u6027)" : ""}`,
930
958
  match: propName,
931
959
  suggestion: `\u53EF\u7528\u5C5E\u6027: ${metadata.props.map((p) => p.name).join(", ")}`
932
960
  });
@@ -32,7 +32,7 @@ var path__namespace = /*#__PURE__*/_interopNamespace(path);
32
32
  var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
33
33
 
34
34
  // src/analysis/componentRegistry.ts
35
- var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-GW5YOUB7.js', document.baseURI).href)));
35
+ var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-YWY3D4J7.js', document.baseURI).href)));
36
36
  var __dirname$1 = path__namespace.dirname(__filename$1);
37
37
  function resolveComponentsPath() {
38
38
  const prodPath = path__namespace.join(__dirname$1, "../components");
@@ -122,7 +122,7 @@ var ComponentRegistry = class {
122
122
  }
123
123
  };
124
124
  var componentRegistry = new ComponentRegistry();
125
- var __filename2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-GW5YOUB7.js', document.baseURI).href)));
125
+ var __filename2 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-YWY3D4J7.js', document.baseURI).href)));
126
126
  var __dirname2 = path__namespace.dirname(__filename2);
127
127
  function resolveHooksPath() {
128
128
  const prodPath = path__namespace.join(__dirname2, "../hooks");
@@ -536,6 +536,15 @@ var NATIVE_HTML_ATTRIBUTES = /* @__PURE__ */ new Set([
536
536
  "aria-controls",
537
537
  "aria-haspopup"
538
538
  ]);
539
+ var STRICT_CHECK_ATTRIBUTES = /* @__PURE__ */ new Set([
540
+ "required",
541
+ "disabled",
542
+ "readonly",
543
+ "value",
544
+ "name",
545
+ "checked",
546
+ "selected"
547
+ ]);
539
548
  var VERSATILE_COMPONENTS = /* @__PURE__ */ new Set([
540
549
  "BillTypes",
541
550
  "Region",
@@ -926,6 +935,23 @@ function checkComponentSpecificRules(tagName, node, violations) {
926
935
  }
927
936
  });
928
937
  }
938
+ if (tagName === "TableColumn") {
939
+ node.children?.forEach((child) => {
940
+ if (child.type === 1 && child.tag === "template") {
941
+ const slotProp = child.props?.find((p) => p.type === 7 && p.name === "slot");
942
+ if (slotProp && slotProp.exp && slotProp.exp.content) {
943
+ const exp = slotProp.exp.content.trim();
944
+ if (exp.startsWith("{") && exp.endsWith("}")) {
945
+ violations.push({
946
+ rule: "TableColumn \u63D2\u69FD\u53C2\u6570\u5E94\u4E3A\u6570\u7EC4\u7ED3\u6784",
947
+ match: exp,
948
+ suggestion: `King Design \u8868\u683C\u63D2\u69FD\u53C2\u6570\u4E3A\u6570\u7EC4\u987A\u5E8F\u4F20\u9012\uFF0C\u8BF7\u5C06 ${exp} \u6539\u4E3A [row]`
949
+ });
950
+ }
951
+ }
952
+ }
953
+ });
954
+ }
929
955
  }
930
956
  function checkProps(tagName, node, metadata, violations) {
931
957
  let customTagName = null;
@@ -949,10 +975,12 @@ function checkProps(tagName, node, metadata, violations) {
949
975
  const isDynamicallyAllowed = dynamicAllowedProps.includes(propName);
950
976
  const isBuiltinProp = ["class", "style", "key", "ref"].includes(propName) || propName.startsWith("data-");
951
977
  const isNativeHtmlAttr = NATIVE_HTML_ATTRIBUTES.has(propName) || propName.startsWith("aria-");
952
- if (!isPropValid && !isDynamicallyAllowed && !isBuiltinProp && !isNativeHtmlAttr) {
978
+ const isStrictAttr = STRICT_CHECK_ATTRIBUTES.has(propName);
979
+ const isNativeIgnored = isNativeHtmlAttr && isStrictAttr && metadata.props;
980
+ if (!isPropValid && !isDynamicallyAllowed && !isBuiltinProp && (!isNativeHtmlAttr || isNativeIgnored)) {
953
981
  if (metadata.props && metadata.props.length > 0) {
954
982
  violations.push({
955
- rule: `\u5C5E\u6027 ${propName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
983
+ rule: `\u5C5E\u6027 ${propName} \u4E0D\u5B58\u5728\u4E8E ${tagName}${isNativeIgnored ? " (\u8BE5\u7EC4\u4EF6\u4E0D\u652F\u6301\u6B64\u539F\u751F\u5C5E\u6027)" : ""}`,
956
984
  match: propName,
957
985
  suggestion: `\u53EF\u7528\u5C5E\u6027: ${metadata.props.map((p) => p.name).join(", ")}`
958
986
  });
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkBVQTJJYS_js = require('../chunk-BVQTJJYS.js');
4
- require('../chunk-GW5YOUB7.js');
3
+ var chunk6QS5IGS6_js = require('../chunk-6QS5IGS6.js');
4
+ require('../chunk-YWY3D4J7.js');
5
5
  require('../chunk-D3Y6FGWA.js');
6
6
  require('../chunk-HPAUCD5I.js');
7
7
 
@@ -9,9 +9,9 @@ require('../chunk-HPAUCD5I.js');
9
9
 
10
10
  Object.defineProperty(exports, "validateCode", {
11
11
  enumerable: true,
12
- get: function () { return chunkBVQTJJYS_js.validateCode; }
12
+ get: function () { return chunk6QS5IGS6_js.validateCode; }
13
13
  });
14
14
  Object.defineProperty(exports, "validateCodeSync", {
15
15
  enumerable: true,
16
- get: function () { return chunkBVQTJJYS_js.validateCodeSync; }
16
+ get: function () { return chunk6QS5IGS6_js.validateCodeSync; }
17
17
  });
@@ -1,4 +1,4 @@
1
- export { validateCode, validateCodeSync } from '../chunk-QSJKP7AO.mjs';
2
- import '../chunk-UYVGHUC5.mjs';
1
+ export { validateCode, validateCodeSync } from '../chunk-FVSQ6BU6.mjs';
2
+ import '../chunk-HDV7ETXE.mjs';
3
3
  import '../chunk-NZ6TLWMD.mjs';
4
4
  import '../chunk-L4DS3EXI.mjs';
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  var chunkWYSRJVX4_js = require('./chunk-WYSRJVX4.js');
4
4
  require('./chunk-YTEYDSDW.js');
5
- var chunkBVQTJJYS_js = require('./chunk-BVQTJJYS.js');
6
- var chunkGW5YOUB7_js = require('./chunk-GW5YOUB7.js');
5
+ var chunk6QS5IGS6_js = require('./chunk-6QS5IGS6.js');
6
+ var chunkYWY3D4J7_js = require('./chunk-YWY3D4J7.js');
7
7
  var chunkD3Y6FGWA_js = require('./chunk-D3Y6FGWA.js');
8
8
  var chunkHPAUCD5I_js = require('./chunk-HPAUCD5I.js');
9
9
 
@@ -15,19 +15,19 @@ Object.defineProperty(exports, "validateCompilation", {
15
15
  });
16
16
  Object.defineProperty(exports, "validateCode", {
17
17
  enumerable: true,
18
- get: function () { return chunkBVQTJJYS_js.validateCode; }
18
+ get: function () { return chunk6QS5IGS6_js.validateCode; }
19
19
  });
20
20
  Object.defineProperty(exports, "validateCodeSync", {
21
21
  enumerable: true,
22
- get: function () { return chunkBVQTJJYS_js.validateCodeSync; }
22
+ get: function () { return chunk6QS5IGS6_js.validateCodeSync; }
23
23
  });
24
24
  Object.defineProperty(exports, "analyzeCodeWithAST", {
25
25
  enumerable: true,
26
- get: function () { return chunkGW5YOUB7_js.analyzeCodeWithAST; }
26
+ get: function () { return chunkYWY3D4J7_js.analyzeCodeWithAST; }
27
27
  });
28
28
  Object.defineProperty(exports, "componentRegistry", {
29
29
  enumerable: true,
30
- get: function () { return chunkGW5YOUB7_js.componentRegistry; }
30
+ get: function () { return chunkYWY3D4J7_js.componentRegistry; }
31
31
  });
32
32
  Object.defineProperty(exports, "validateRuntimePrecheck", {
33
33
  enumerable: true,
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { validateCompilation } from './chunk-DSWKLUIX.mjs';
2
2
  import './chunk-5H7N2A5X.mjs';
3
- export { validateCode, validateCodeSync } from './chunk-QSJKP7AO.mjs';
4
- export { analyzeCodeWithAST, componentRegistry } from './chunk-UYVGHUC5.mjs';
3
+ export { validateCode, validateCodeSync } from './chunk-FVSQ6BU6.mjs';
4
+ export { analyzeCodeWithAST, componentRegistry } from './chunk-HDV7ETXE.mjs';
5
5
  export { validateRuntimePrecheck } from './chunk-NZ6TLWMD.mjs';
6
6
  export { compileSFC, scopeStyles } from './chunk-L4DS3EXI.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "king-design-analyzer",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "AST-based code analyzer for King Design Vue components with on-demand modular imports",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",