@lark-apaas/fullstack-presets 1.1.5-alpha.0 → 1.1.5-alpha.2

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,8 +1,8 @@
1
1
  /**
2
- * ESLint rule to require AppContainer component in entry files.
2
+ * ESLint 规则:要求入口文件中必须包含 AppContainer 组件
3
3
  *
4
- * This rule ensures that client/src/index.tsx and client/src/app.tsx
5
- * files contain the AppContainer component to ensure platform features work correctly.
4
+ * 此规则确保 client/src/index.tsx client/src/app.tsx 文件中
5
+ * 包含 AppContainer 组件,以保证平台功能正常运行。
6
6
  */
7
7
  import type { Rule } from 'eslint';
8
8
  declare const rule: Rule.RuleModule;
@@ -34,16 +34,16 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const path = __importStar(require("path"));
37
- const DEFAULT_MESSAGE = '缺少平台组件AppContainer,请确认App外层包裹了AppContainer组件以确保平台功能正常运行';
38
- // Files that must contain AppContainer
37
+ const DEFAULT_MESSAGE = 'Missing platform component AppContainer. Please ensure that App is wrapped with AppContainer to enable platform features.';
38
+ // 必须包含 AppContainer 的文件列表
39
39
  const REQUIRED_FILES = ['index.tsx', 'app.tsx'];
40
- // Directory pattern to match
40
+ // 匹配 client/src/ 目录的正则表达式
41
41
  const CLIENT_SRC_PATTERN = /[/\\]client[/\\]src[/\\]$/;
42
42
  const rule = {
43
43
  meta: {
44
44
  type: 'problem',
45
45
  docs: {
46
- description: 'Require AppContainer component in entry files',
46
+ description: '要求入口文件中必须包含 AppContainer 组件',
47
47
  category: 'Possible Errors',
48
48
  recommended: true,
49
49
  },
@@ -53,7 +53,7 @@ const rule = {
53
53
  properties: {
54
54
  message: {
55
55
  type: 'string',
56
- description: 'Custom error message',
56
+ description: '自定义错误信息',
57
57
  },
58
58
  },
59
59
  additionalProperties: false,
@@ -67,48 +67,38 @@ const rule = {
67
67
  const options = context.options[0];
68
68
  const customMessage = options?.message;
69
69
  const filename = context.filename || context.getFilename();
70
- // Check if this file should be validated
70
+ // 获取文件名和目录名
71
71
  const basename = path.basename(filename);
72
72
  const dirname = path.dirname(filename);
73
- // Only check files in client/src/ directory that match our required files
73
+ // 判断是否为需要检查的文件:必须在 client/src/ 目录下且文件名匹配
74
74
  const isRequiredFile = REQUIRED_FILES.includes(basename.toLowerCase()) &&
75
75
  CLIENT_SRC_PATTERN.test(dirname + path.sep);
76
+ // 如果不是需要检查的文件,直接跳过
76
77
  if (!isRequiredFile) {
77
78
  return {};
78
79
  }
79
- let hasAppContainer = false;
80
+ // 标记是否在 JSX 中实际使用了 AppContainer
81
+ let hasAppContainerUsage = false;
80
82
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
83
  let programNode = null;
82
84
  return {
83
- // Track if AppContainer is imported
84
- ImportDeclaration(node) {
85
- // Check for default or named import of AppContainer
86
- for (const specifier of node.specifiers) {
87
- if (specifier.type === 'ImportSpecifier' ||
88
- specifier.type === 'ImportDefaultSpecifier') {
89
- if (specifier.local.name === 'AppContainer') {
90
- hasAppContainer = true;
91
- break;
92
- }
93
- }
94
- }
95
- },
96
- // Check for JSX usage of <AppContainer>
85
+ // 检查 JSX 中是否使用了 <AppContainer> 组件
86
+ // 注意:仅导入不使用不算通过,必须在 JSX 中实际使用
97
87
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
88
  JSXOpeningElement(node) {
99
89
  const elementName = node.name;
100
90
  if (elementName?.type === 'JSXIdentifier' &&
101
91
  elementName?.name === 'AppContainer') {
102
- hasAppContainer = true;
92
+ hasAppContainerUsage = true;
103
93
  }
104
94
  },
105
- // Store the program node for reporting at the end
95
+ // 保存 Program 节点,用于在文件末尾报错时定位
106
96
  Program(node) {
107
97
  programNode = node;
108
98
  },
109
- // Check at the end of file if AppContainer was found
99
+ // 文件解析完成后,检查是否在 JSX 中使用了 AppContainer
110
100
  'Program:exit'() {
111
- if (!hasAppContainer && programNode) {
101
+ if (!hasAppContainerUsage && programNode) {
112
102
  context.report({
113
103
  node: programNode,
114
104
  ...(customMessage
@@ -13,7 +13,7 @@ declare const _default: {
13
13
  plugins: {
14
14
  'react-hooks': any;
15
15
  import: any;
16
- 'fullstack-presets': {
16
+ '@lark-apaas': {
17
17
  rules: {
18
18
  'no-nested-styled-jsx': import("eslint").Rule.RuleModule;
19
19
  'require-app-container': import("eslint").Rule.RuleModule;
@@ -23,7 +23,7 @@ exports.default = {
23
23
  plugins: {
24
24
  'react-hooks': reactHooks,
25
25
  import: importPlugin,
26
- 'fullstack-presets': {
26
+ '@lark-apaas': {
27
27
  rules: custom_eslint_rules_1.customRules,
28
28
  },
29
29
  },
@@ -41,7 +41,7 @@ exports.default = {
41
41
  // React Hooks 推荐规则
42
42
  ...reactHooks.configs.recommended.rules,
43
43
  // 平台规则:确保入口文件包含 AppContainer 组件
44
- 'fullstack-presets/require-app-container': 'error',
44
+ '@lark-apaas/require-app-container': 'error',
45
45
  // TypeScript 规则
46
46
  '@typescript-eslint/no-unused-vars': 'off', // 未使用变量检查关闭
47
47
  '@typescript-eslint/no-explicit-any': 'off', // 允许使用 any 类型
@@ -16,7 +16,7 @@ export declare const eslintPresets: {
16
16
  plugins: {
17
17
  'react-hooks': any;
18
18
  import: any;
19
- 'fullstack-presets': {
19
+ '@lark-apaas': {
20
20
  rules: {
21
21
  'no-nested-styled-jsx': import("eslint").Rule.RuleModule;
22
22
  'require-app-container': import("eslint").Rule.RuleModule;
@@ -15,14 +15,14 @@ declare const _default: ({
15
15
  globals: any;
16
16
  };
17
17
  plugins: {
18
- '@lark-apaas'?: {
18
+ 'react-hooks': any;
19
+ import: any;
20
+ '@lark-apaas': {
19
21
  rules: {
20
22
  'no-nested-styled-jsx': import("eslint").Rule.RuleModule;
21
23
  'require-app-container': import("eslint").Rule.RuleModule;
22
24
  };
23
- } | undefined;
24
- 'react-hooks': any;
25
- import: any;
25
+ };
26
26
  };
27
27
  settings: {
28
28
  'import/resolver': {
@@ -94,9 +94,6 @@ const strictSyntaxRules = [
94
94
  message: 'Classname "text-accent" would cause visibility issues. Consider using proper semantic color tokens from `client/src/tailwind-theme.css`',
95
95
  },
96
96
  ];
97
- const looseSpecificPlugins = {
98
- '@lark-apaas': { rules: custom_eslint_rules_1.customRules }
99
- };
100
97
  const looseSpecificRules = {
101
98
  '@lark-apaas/no-nested-styled-jsx': 'error'
102
99
  };
@@ -128,7 +125,7 @@ const baseConfig = {
128
125
  plugins: {
129
126
  'react-hooks': reactHooks,
130
127
  import: importPlugin,
131
- ...(isLooseMode ? looseSpecificPlugins : {}),
128
+ '@lark-apaas': { rules: custom_eslint_rules_1.customRules },
132
129
  },
133
130
  settings: {
134
131
  'import/resolver': {
@@ -143,6 +140,8 @@ const baseConfig = {
143
140
  rules: {
144
141
  // React Hooks 推荐规则
145
142
  ...reactHooks.configs.recommended.rules,
143
+ // 平台规则:确保入口文件包含 AppContainer 组件
144
+ '@lark-apaas/require-app-container': 'error',
146
145
  // TypeScript 规则
147
146
  '@typescript-eslint/no-unused-vars': 'off', // 未使用变量检查关闭
148
147
  '@typescript-eslint/no-explicit-any': 'off', // 允许使用 any 类型
@@ -14,14 +14,14 @@ export declare const eslintPresets: {
14
14
  globals: any;
15
15
  };
16
16
  plugins: {
17
- '@lark-apaas'?: {
17
+ 'react-hooks': any;
18
+ import: any;
19
+ '@lark-apaas': {
18
20
  rules: {
19
21
  'no-nested-styled-jsx': import("eslint").Rule.RuleModule;
20
22
  'require-app-container': import("eslint").Rule.RuleModule;
21
23
  };
22
- } | undefined;
23
- 'react-hooks': any;
24
- import: any;
24
+ };
25
25
  };
26
26
  settings: {
27
27
  'import/resolver': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-presets",
3
- "version": "1.1.5-alpha.0",
3
+ "version": "1.1.5-alpha.2",
4
4
  "files": [
5
5
  "lib"
6
6
  ],