@lark-apaas/fullstack-presets 1.1.3 → 1.1.5-alpha.0
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/lib/custom-eslint-rules/index.d.ts +1 -0
- package/lib/custom-eslint-rules/index.js +2 -0
- package/lib/custom-eslint-rules/require-app-container.d.ts +9 -0
- package/lib/custom-eslint-rules/require-app-container.js +123 -0
- package/lib/recommend/eslint/eslint-client.d.ts +6 -0
- package/lib/recommend/eslint/eslint-client.js +6 -0
- package/lib/recommend/eslint/index.d.ts +6 -0
- package/lib/simple/recommend/eslint/eslint-client.d.ts +1 -0
- package/lib/simple/recommend/eslint/index.d.ts +1 -0
- package/package.json +2 -3
|
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.customRules = void 0;
|
|
7
7
|
const no_nested_styled_jsx_1 = __importDefault(require("./no-nested-styled-jsx"));
|
|
8
|
+
const require_app_container_1 = __importDefault(require("./require-app-container"));
|
|
8
9
|
exports.customRules = {
|
|
9
10
|
'no-nested-styled-jsx': no_nested_styled_jsx_1.default,
|
|
11
|
+
'require-app-container': require_app_container_1.default,
|
|
10
12
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint rule to require AppContainer component in entry files.
|
|
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.
|
|
6
|
+
*/
|
|
7
|
+
import type { Rule } from 'eslint';
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const path = __importStar(require("path"));
|
|
37
|
+
const DEFAULT_MESSAGE = '缺少平台组件AppContainer,请确认App外层包裹了AppContainer组件以确保平台功能正常运行';
|
|
38
|
+
// Files that must contain AppContainer
|
|
39
|
+
const REQUIRED_FILES = ['index.tsx', 'app.tsx'];
|
|
40
|
+
// Directory pattern to match
|
|
41
|
+
const CLIENT_SRC_PATTERN = /[/\\]client[/\\]src[/\\]$/;
|
|
42
|
+
const rule = {
|
|
43
|
+
meta: {
|
|
44
|
+
type: 'problem',
|
|
45
|
+
docs: {
|
|
46
|
+
description: 'Require AppContainer component in entry files',
|
|
47
|
+
category: 'Possible Errors',
|
|
48
|
+
recommended: true,
|
|
49
|
+
},
|
|
50
|
+
schema: [
|
|
51
|
+
{
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
message: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Custom error message',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
messages: {
|
|
63
|
+
missingAppContainer: DEFAULT_MESSAGE,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
create(context) {
|
|
67
|
+
const options = context.options[0];
|
|
68
|
+
const customMessage = options?.message;
|
|
69
|
+
const filename = context.filename || context.getFilename();
|
|
70
|
+
// Check if this file should be validated
|
|
71
|
+
const basename = path.basename(filename);
|
|
72
|
+
const dirname = path.dirname(filename);
|
|
73
|
+
// Only check files in client/src/ directory that match our required files
|
|
74
|
+
const isRequiredFile = REQUIRED_FILES.includes(basename.toLowerCase()) &&
|
|
75
|
+
CLIENT_SRC_PATTERN.test(dirname + path.sep);
|
|
76
|
+
if (!isRequiredFile) {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
let hasAppContainer = false;
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
let programNode = null;
|
|
82
|
+
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>
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
JSXOpeningElement(node) {
|
|
99
|
+
const elementName = node.name;
|
|
100
|
+
if (elementName?.type === 'JSXIdentifier' &&
|
|
101
|
+
elementName?.name === 'AppContainer') {
|
|
102
|
+
hasAppContainer = true;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
// Store the program node for reporting at the end
|
|
106
|
+
Program(node) {
|
|
107
|
+
programNode = node;
|
|
108
|
+
},
|
|
109
|
+
// Check at the end of file if AppContainer was found
|
|
110
|
+
'Program:exit'() {
|
|
111
|
+
if (!hasAppContainer && programNode) {
|
|
112
|
+
context.report({
|
|
113
|
+
node: programNode,
|
|
114
|
+
...(customMessage
|
|
115
|
+
? { message: customMessage }
|
|
116
|
+
: { messageId: 'missingAppContainer' }),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
exports.default = rule;
|
|
@@ -13,6 +13,12 @@ declare const _default: {
|
|
|
13
13
|
plugins: {
|
|
14
14
|
'react-hooks': any;
|
|
15
15
|
import: any;
|
|
16
|
+
'fullstack-presets': {
|
|
17
|
+
rules: {
|
|
18
|
+
'no-nested-styled-jsx': import("eslint").Rule.RuleModule;
|
|
19
|
+
'require-app-container': import("eslint").Rule.RuleModule;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
16
22
|
};
|
|
17
23
|
settings: {
|
|
18
24
|
'import/resolver': {
|
|
@@ -4,6 +4,7 @@ const globals = require('globals');
|
|
|
4
4
|
const reactHooks = require('eslint-plugin-react-hooks');
|
|
5
5
|
const tseslint = require('typescript-eslint');
|
|
6
6
|
const importPlugin = require('eslint-plugin-import');
|
|
7
|
+
const custom_eslint_rules_1 = require("../../custom-eslint-rules");
|
|
7
8
|
exports.default = {
|
|
8
9
|
name: 'fullstack-presets/client-recommend',
|
|
9
10
|
languageOptions: {
|
|
@@ -22,6 +23,9 @@ exports.default = {
|
|
|
22
23
|
plugins: {
|
|
23
24
|
'react-hooks': reactHooks,
|
|
24
25
|
import: importPlugin,
|
|
26
|
+
'fullstack-presets': {
|
|
27
|
+
rules: custom_eslint_rules_1.customRules,
|
|
28
|
+
},
|
|
25
29
|
},
|
|
26
30
|
settings: {
|
|
27
31
|
'import/resolver': {
|
|
@@ -36,6 +40,8 @@ exports.default = {
|
|
|
36
40
|
rules: {
|
|
37
41
|
// React Hooks 推荐规则
|
|
38
42
|
...reactHooks.configs.recommended.rules,
|
|
43
|
+
// 平台规则:确保入口文件包含 AppContainer 组件
|
|
44
|
+
'fullstack-presets/require-app-container': 'error',
|
|
39
45
|
// TypeScript 规则
|
|
40
46
|
'@typescript-eslint/no-unused-vars': 'off', // 未使用变量检查关闭
|
|
41
47
|
'@typescript-eslint/no-explicit-any': 'off', // 允许使用 any 类型
|
|
@@ -16,6 +16,12 @@ export declare const eslintPresets: {
|
|
|
16
16
|
plugins: {
|
|
17
17
|
'react-hooks': any;
|
|
18
18
|
import: any;
|
|
19
|
+
'fullstack-presets': {
|
|
20
|
+
rules: {
|
|
21
|
+
'no-nested-styled-jsx': import("eslint").Rule.RuleModule;
|
|
22
|
+
'require-app-container': import("eslint").Rule.RuleModule;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
19
25
|
};
|
|
20
26
|
settings: {
|
|
21
27
|
'import/resolver': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-presets",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5-alpha.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -45,6 +45,5 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"eslint": "^9.0.0",
|
|
47
47
|
"typescript-eslint": "^8.44.0"
|
|
48
|
-
}
|
|
49
|
-
"gitHead": "bc9469110ed352267d992d7406578d00bc3ffe03"
|
|
48
|
+
}
|
|
50
49
|
}
|