@elizaos/config 1.6.5-alpha.8 → 1.6.5-beta.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/dist/eslint/eslint.config.base.d.ts +203 -0
- package/dist/eslint/eslint.config.frontend.d.ts +250 -0
- package/dist/eslint/eslint.config.plugin.d.ts +250 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +328626 -0
- package/dist/prettier/prettier.config.d.ts +41 -0
- package/package.json +4 -4
- package/src/eslint/eslint.config.base.js +144 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let printWidth: number;
|
|
3
|
+
let tabWidth: number;
|
|
4
|
+
let useTabs: boolean;
|
|
5
|
+
let semi: boolean;
|
|
6
|
+
let singleQuote: boolean;
|
|
7
|
+
let quoteProps: string;
|
|
8
|
+
let jsxSingleQuote: boolean;
|
|
9
|
+
let trailingComma: string;
|
|
10
|
+
let bracketSpacing: boolean;
|
|
11
|
+
let bracketSameLine: boolean;
|
|
12
|
+
let arrowParens: string;
|
|
13
|
+
let proseWrap: string;
|
|
14
|
+
let htmlWhitespaceSensitivity: string;
|
|
15
|
+
let vueIndentScriptAndStyle: boolean;
|
|
16
|
+
let endOfLine: string;
|
|
17
|
+
let embeddedLanguageFormatting: string;
|
|
18
|
+
let overrides: ({
|
|
19
|
+
files: string;
|
|
20
|
+
options: {
|
|
21
|
+
printWidth: number;
|
|
22
|
+
proseWrap?: undefined;
|
|
23
|
+
tabWidth?: undefined;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
files: string;
|
|
27
|
+
options: {
|
|
28
|
+
printWidth: number;
|
|
29
|
+
proseWrap: string;
|
|
30
|
+
tabWidth?: undefined;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
files: string;
|
|
34
|
+
options: {
|
|
35
|
+
tabWidth: number;
|
|
36
|
+
printWidth?: undefined;
|
|
37
|
+
proseWrap?: undefined;
|
|
38
|
+
};
|
|
39
|
+
})[];
|
|
40
|
+
}
|
|
41
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/config",
|
|
3
3
|
"description": "Shared configuration for ElizaOS projects and plugins",
|
|
4
|
-
"version": "1.6.5-
|
|
4
|
+
"version": "1.6.5-beta.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"src"
|
|
39
39
|
],
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"prettier": "^3.
|
|
42
|
-
"typescript": "^5.
|
|
41
|
+
"prettier": "^3.7.4",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "bun run build.ts",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e4a21fa4039c24f7cd4d2a214ac74270496dddad"
|
|
55
55
|
}
|
|
@@ -2,6 +2,145 @@ import js from '@eslint/js';
|
|
|
2
2
|
import typescript from '@typescript-eslint/eslint-plugin';
|
|
3
3
|
import typescriptParser from '@typescript-eslint/parser';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Custom ESLint rule: structured-logging
|
|
7
|
+
*
|
|
8
|
+
* Enforces structured logging format: logger.level({ src: '<source>', ...context }, 'message')
|
|
9
|
+
*
|
|
10
|
+
* @see LOGGING_SPEC.md for full specification
|
|
11
|
+
*/
|
|
12
|
+
const LOGGER_METHODS = ['debug', 'info', 'warn', 'error', 'trace', 'fatal'];
|
|
13
|
+
|
|
14
|
+
const structuredLoggingRule = {
|
|
15
|
+
meta: {
|
|
16
|
+
type: 'problem',
|
|
17
|
+
docs: {
|
|
18
|
+
description: 'Enforce structured logging format with src property',
|
|
19
|
+
category: 'Best Practices',
|
|
20
|
+
recommended: true,
|
|
21
|
+
},
|
|
22
|
+
fixable: null,
|
|
23
|
+
schema: [],
|
|
24
|
+
messages: {
|
|
25
|
+
missingObjectArg:
|
|
26
|
+
'Logger calls must have an object as first argument: logger.{{method}}({ src: "...", ...context }, "message")',
|
|
27
|
+
missingSrcProperty:
|
|
28
|
+
'Logger calls must include "src" property: logger.{{method}}({ src: "...", ...context }, "message")',
|
|
29
|
+
srcMustBeString: 'The "src" property must be a string literal',
|
|
30
|
+
missingMessageArg:
|
|
31
|
+
'Logger calls must have a string message as second argument: logger.{{method}}({ src: "...", ...context }, "message")',
|
|
32
|
+
messageMustBeString: 'Second argument to logger must be a string message',
|
|
33
|
+
invalidSrcFormat:
|
|
34
|
+
'Invalid src format "{{src}}". Use: "component" (core), "plugin:name:type:component" (plugins), or "http" (server)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
create(context) {
|
|
38
|
+
// Very permissive: just check src is not empty and has reasonable format
|
|
39
|
+
// Format examples: "http", "cli", "plugin:bootstrap:action:reply", "core:runtime", etc.
|
|
40
|
+
const srcRegex = /^[a-z][a-z0-9_:-]*$/i;
|
|
41
|
+
|
|
42
|
+
function isLoggerCall(node) {
|
|
43
|
+
return (
|
|
44
|
+
node.type === 'CallExpression' &&
|
|
45
|
+
node.callee.type === 'MemberExpression' &&
|
|
46
|
+
node.callee.object.type === 'Identifier' &&
|
|
47
|
+
node.callee.object.name === 'logger' &&
|
|
48
|
+
node.callee.property.type === 'Identifier' &&
|
|
49
|
+
LOGGER_METHODS.includes(node.callee.property.name)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function validateSrcFormat(srcValue) {
|
|
54
|
+
return srcRegex.test(srcValue);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
CallExpression(node) {
|
|
59
|
+
if (!isLoggerCall(node)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const methodName = node.callee.property.name;
|
|
64
|
+
const args = node.arguments;
|
|
65
|
+
|
|
66
|
+
if (args.length === 0) {
|
|
67
|
+
context.report({ node, messageId: 'missingObjectArg', data: { method: methodName } });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const firstArg = args[0];
|
|
72
|
+
|
|
73
|
+
// First argument must be an object literal
|
|
74
|
+
if (firstArg.type !== 'ObjectExpression') {
|
|
75
|
+
if (
|
|
76
|
+
firstArg.type === 'Literal' ||
|
|
77
|
+
firstArg.type === 'TemplateLiteral' ||
|
|
78
|
+
firstArg.type === 'BinaryExpression'
|
|
79
|
+
) {
|
|
80
|
+
context.report({ node, messageId: 'missingObjectArg', data: { method: methodName } });
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Check for src property
|
|
86
|
+
const srcProperty = firstArg.properties.find(
|
|
87
|
+
(prop) =>
|
|
88
|
+
prop.type === 'Property' &&
|
|
89
|
+
!prop.computed &&
|
|
90
|
+
((prop.key.type === 'Identifier' && prop.key.name === 'src') ||
|
|
91
|
+
(prop.key.type === 'Literal' && prop.key.value === 'src'))
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (!srcProperty) {
|
|
95
|
+
context.report({
|
|
96
|
+
node: firstArg,
|
|
97
|
+
messageId: 'missingSrcProperty',
|
|
98
|
+
data: { method: methodName },
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src must be a string literal
|
|
104
|
+
if (srcProperty.value.type !== 'Literal' || typeof srcProperty.value.value !== 'string') {
|
|
105
|
+
context.report({ node: srcProperty.value, messageId: 'srcMustBeString' });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Validate src format
|
|
110
|
+
const srcValue = srcProperty.value.value;
|
|
111
|
+
if (!validateSrcFormat(srcValue)) {
|
|
112
|
+
context.report({
|
|
113
|
+
node: srcProperty.value,
|
|
114
|
+
messageId: 'invalidSrcFormat',
|
|
115
|
+
data: { src: srcValue },
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Check second argument (message)
|
|
120
|
+
if (args.length < 2) {
|
|
121
|
+
context.report({ node, messageId: 'missingMessageArg', data: { method: methodName } });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const secondArg = args[1];
|
|
126
|
+
if (secondArg.type === 'ObjectExpression' || secondArg.type === 'ArrayExpression') {
|
|
127
|
+
context.report({ node: secondArg, messageId: 'messageMustBeString' });
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* ElizaOS custom ESLint plugin
|
|
136
|
+
*/
|
|
137
|
+
const elizaPlugin = {
|
|
138
|
+
meta: { name: '@elizaos/eslint-plugin', version: '1.0.0' },
|
|
139
|
+
rules: {
|
|
140
|
+
'structured-logging': structuredLoggingRule,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
5
144
|
/**
|
|
6
145
|
* Base ESLint configuration for ElizaOS packages
|
|
7
146
|
* Provides consistent code quality across all packages
|
|
@@ -58,8 +197,12 @@ export const baseConfig = [
|
|
|
58
197
|
},
|
|
59
198
|
plugins: {
|
|
60
199
|
'@typescript-eslint': typescript,
|
|
200
|
+
'@elizaos': elizaPlugin,
|
|
61
201
|
},
|
|
62
202
|
rules: {
|
|
203
|
+
// ElizaOS custom rules - structured logging
|
|
204
|
+
'@elizaos/structured-logging': 'warn',
|
|
205
|
+
|
|
63
206
|
// TypeScript specific rules - balanced for maintainability
|
|
64
207
|
'@typescript-eslint/no-unused-vars': [
|
|
65
208
|
'warn',
|
|
@@ -163,6 +306,7 @@ export const testOverrides = {
|
|
|
163
306
|
},
|
|
164
307
|
},
|
|
165
308
|
rules: {
|
|
309
|
+
'@elizaos/structured-logging': 'off', // Tests can use any log format
|
|
166
310
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
167
311
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
168
312
|
'@typescript-eslint/no-non-null-assertion': 'off',
|