@bleedingdev/modern-js-code-tools 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91
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/cjs/cli/i18n-check.cjs +0 -6
- package/dist/cjs/cli/workspace-source-check.cjs +0 -3
- package/dist/cjs/oxlint-plugin/ast.cjs +181 -0
- package/dist/cjs/oxlint-plugin/options.cjs +172 -0
- package/dist/cjs/oxlint-plugin/rules/no-hardcoded-jsx-text.cjs +82 -0
- package/dist/cjs/oxlint-plugin/rules/no-legacy-mf-boundary-attributes.cjs +61 -0
- package/dist/cjs/oxlint-plugin/rules/no-literal-visible-jsx-attributes.cjs +74 -0
- package/dist/cjs/oxlint-plugin/rules/no-manual-locale-copy-branching.cjs +80 -0
- package/dist/cjs/oxlint-plugin/rules/no-split-translation-keys.cjs +70 -0
- package/dist/cjs/oxlint-plugin/rules/strict-effect-api-boundaries.cjs +84 -0
- package/dist/cjs/oxlint-plugin/types.cjs +18 -0
- package/dist/cjs/oxlint-plugin.cjs +100 -382
- package/dist/esm/cli/i18n-check.js +1 -1
- package/dist/esm/cli/workspace-source-check.js +1 -1
- package/dist/esm/oxlint-plugin/ast.js +83 -0
- package/dist/esm/oxlint-plugin/options.js +89 -0
- package/dist/esm/oxlint-plugin/rules/no-hardcoded-jsx-text.js +44 -0
- package/dist/esm/oxlint-plugin/rules/no-legacy-mf-boundary-attributes.js +23 -0
- package/dist/esm/oxlint-plugin/rules/no-literal-visible-jsx-attributes.js +36 -0
- package/dist/esm/oxlint-plugin/rules/no-manual-locale-copy-branching.js +42 -0
- package/dist/esm/oxlint-plugin/rules/no-split-translation-keys.js +32 -0
- package/dist/esm/oxlint-plugin/rules/strict-effect-api-boundaries.js +46 -0
- package/dist/esm/oxlint-plugin/types.js +0 -0
- package/dist/esm/oxlint-plugin.js +15 -367
- package/dist/esm-node/cli/i18n-check.js +1 -1
- package/dist/esm-node/cli/workspace-source-check.js +1 -1
- package/dist/esm-node/oxlint-plugin/ast.js +84 -0
- package/dist/esm-node/oxlint-plugin/options.js +90 -0
- package/dist/esm-node/oxlint-plugin/rules/no-hardcoded-jsx-text.js +45 -0
- package/dist/esm-node/oxlint-plugin/rules/no-legacy-mf-boundary-attributes.js +24 -0
- package/dist/esm-node/oxlint-plugin/rules/no-literal-visible-jsx-attributes.js +37 -0
- package/dist/esm-node/oxlint-plugin/rules/no-manual-locale-copy-branching.js +43 -0
- package/dist/esm-node/oxlint-plugin/rules/no-split-translation-keys.js +33 -0
- package/dist/esm-node/oxlint-plugin/rules/strict-effect-api-boundaries.js +47 -0
- package/dist/esm-node/oxlint-plugin/types.js +1 -0
- package/dist/esm-node/oxlint-plugin.js +15 -367
- package/dist/types/cli/i18n-check.d.ts +0 -2
- package/dist/types/cli/workspace-source-check.d.ts +0 -1
- package/dist/types/oxlint-plugin/ast.d.ts +22 -0
- package/dist/types/oxlint-plugin/options.d.ts +62 -0
- package/dist/types/oxlint-plugin/rules/no-hardcoded-jsx-text.d.ts +2 -0
- package/dist/types/oxlint-plugin/rules/no-legacy-mf-boundary-attributes.d.ts +2 -0
- package/dist/types/oxlint-plugin/rules/no-literal-visible-jsx-attributes.d.ts +2 -0
- package/dist/types/oxlint-plugin/rules/no-manual-locale-copy-branching.d.ts +2 -0
- package/dist/types/oxlint-plugin/rules/no-split-translation-keys.d.ts +2 -0
- package/dist/types/oxlint-plugin/rules/strict-effect-api-boundaries.d.ts +2 -0
- package/dist/types/oxlint-plugin/types.d.ts +60 -0
- package/dist/types/oxlint-plugin.d.ts +15 -56
- package/package.json +6 -7
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./oxlint-plugin/ast.ts" (module) {
|
|
4
|
+
module.exports = require("./oxlint-plugin/ast.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./oxlint-plugin/options.ts" (module) {
|
|
7
|
+
module.exports = require("./oxlint-plugin/options.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./oxlint-plugin/rules/no-hardcoded-jsx-text.ts" (module) {
|
|
10
|
+
module.exports = require("./oxlint-plugin/rules/no-hardcoded-jsx-text.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./oxlint-plugin/rules/no-legacy-mf-boundary-attributes.ts" (module) {
|
|
13
|
+
module.exports = require("./oxlint-plugin/rules/no-legacy-mf-boundary-attributes.cjs");
|
|
14
|
+
},
|
|
15
|
+
"./oxlint-plugin/rules/no-literal-visible-jsx-attributes.ts" (module) {
|
|
16
|
+
module.exports = require("./oxlint-plugin/rules/no-literal-visible-jsx-attributes.cjs");
|
|
17
|
+
},
|
|
18
|
+
"./oxlint-plugin/rules/no-manual-locale-copy-branching.ts" (module) {
|
|
19
|
+
module.exports = require("./oxlint-plugin/rules/no-manual-locale-copy-branching.cjs");
|
|
20
|
+
},
|
|
21
|
+
"./oxlint-plugin/rules/no-split-translation-keys.ts" (module) {
|
|
22
|
+
module.exports = require("./oxlint-plugin/rules/no-split-translation-keys.cjs");
|
|
23
|
+
},
|
|
24
|
+
"./oxlint-plugin/rules/strict-effect-api-boundaries.ts" (module) {
|
|
25
|
+
module.exports = require("./oxlint-plugin/rules/strict-effect-api-boundaries.cjs");
|
|
26
|
+
},
|
|
27
|
+
"./oxlint-plugin/types.ts" (module) {
|
|
28
|
+
module.exports = require("./oxlint-plugin/types.cjs");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var __webpack_module_cache__ = {};
|
|
32
|
+
function __webpack_require__(moduleId) {
|
|
33
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
34
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
35
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
36
|
+
exports: {}
|
|
37
|
+
};
|
|
38
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
39
|
+
return module.exports;
|
|
40
|
+
}
|
|
41
|
+
(()=>{
|
|
42
|
+
__webpack_require__.n = (module)=>{
|
|
43
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
44
|
+
__webpack_require__.d(getter, {
|
|
45
|
+
a: getter
|
|
46
|
+
});
|
|
47
|
+
return getter;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
3
50
|
(()=>{
|
|
4
51
|
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
52
|
var define = (defs, kind)=>{
|
|
@@ -26,391 +73,62 @@ var __webpack_require__ = {};
|
|
|
26
73
|
};
|
|
27
74
|
})();
|
|
28
75
|
var __webpack_exports__ = {};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
additionalProperties: false
|
|
69
|
-
};
|
|
70
|
-
const DEFAULT_VISIBLE_ATTRIBUTES = [
|
|
71
|
-
'aria-label',
|
|
72
|
-
"aria-description",
|
|
73
|
-
"aria-roledescription",
|
|
74
|
-
'aria-valuetext',
|
|
75
|
-
'alt',
|
|
76
|
-
'placeholder',
|
|
77
|
-
'title'
|
|
78
|
-
];
|
|
79
|
-
const DEFAULT_ALLOWED_ELEMENTS = [
|
|
80
|
-
'code',
|
|
81
|
-
'kbd',
|
|
82
|
-
'samp'
|
|
83
|
-
];
|
|
84
|
-
const DEFAULT_TRANSLATION_FUNCTIONS = [
|
|
85
|
-
't'
|
|
86
|
-
];
|
|
87
|
-
const DEFAULT_IGNORE_COMMENT_PATTERN = 'i18n-ignore';
|
|
88
|
-
const LETTER_PATTERN = /\p{L}/u;
|
|
89
|
-
const SPLIT_TRANSLATION_KEY_PATTERN = /\.(?:prefix|suffix|before|after)$/u;
|
|
90
|
-
const API_SOURCE_FILE_PATTERN = /(?:^|\/)(?:api\/|shared\/api\.[cm]?[jt]sx?$)/u;
|
|
91
|
-
const FORBIDDEN_GENERATED_EFFECT_PATH_PATTERN = /(?:^|\/)(?:(?:apps|verticals)\/[^/]+\/(?:api\/(?:effect|lambda)|shared\/effect|src\/effect))(?:\/|$)/u;
|
|
92
|
-
const API_ENTRY_PATTERN = /(?:^|\/)(?:apps|verticals)\/[^/]+\/api\/index\.[cm]?[jt]sx?$/u;
|
|
93
|
-
const SHARED_API_CONTRACT_PATTERN = /(?:^|\/)(?:apps|verticals)\/[^/]+\/shared\/api\.[cm]?[jt]sx?$/u;
|
|
94
|
-
const isRecord = (value)=>Boolean(value) && 'object' == typeof value && !Array.isArray(value);
|
|
95
|
-
const asStringArray = (value, fallback)=>Array.isArray(value) && value.every((item)=>'string' == typeof item) ? value : fallback;
|
|
96
|
-
const getCommonRuleOption = (context, defaults)=>{
|
|
97
|
-
const options = context.options?.[0];
|
|
98
|
-
if (!isRecord(options)) return defaults;
|
|
99
|
-
return {
|
|
100
|
-
allowElements: asStringArray(options.allowElements, defaults.allowElements),
|
|
101
|
-
ignoreCommentPattern: 'string' == typeof options.ignoreCommentPattern ? options.ignoreCommentPattern : defaults.ignoreCommentPattern
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
const getAttributeRuleOption = (context, defaults)=>{
|
|
105
|
-
const options = context.options?.[0];
|
|
106
|
-
const commonOptions = getCommonRuleOption(context, defaults);
|
|
107
|
-
return {
|
|
108
|
-
...commonOptions,
|
|
109
|
-
visibleAttributes: isRecord(options) ? asStringArray(options.visibleAttributes, defaults.visibleAttributes) : defaults.visibleAttributes
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
const getSplitTranslationKeyRuleOption = (context, defaults)=>{
|
|
113
|
-
const options = context.options?.[0];
|
|
114
|
-
if (!isRecord(options)) return defaults;
|
|
115
|
-
return {
|
|
116
|
-
translationFunctions: asStringArray(options.translationFunctions, defaults.translationFunctions)
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
const normalizeVisibleText = (value)=>value.replaceAll(/\s+/gu, ' ').trim();
|
|
120
|
-
const hasLetters = (value)=>LETTER_PATTERN.test(value);
|
|
121
|
-
const getNodeName = (node)=>{
|
|
122
|
-
if (!node) return;
|
|
123
|
-
if ('string' == typeof node.name) return node.name;
|
|
124
|
-
if ('JSXIdentifier' === node.type && isRecord(node.name) && 'string' == typeof node.name.name) return node.name.name;
|
|
125
|
-
if ('JSXIdentifier' === node.type && 'string' == typeof node.name) return node.name;
|
|
126
|
-
if (('JSXMemberExpression' === node.type || 'MemberExpression' === node.type) && isRecord(node.property) && true !== node.computed) {
|
|
127
|
-
const objectName = getNodeName(node.object);
|
|
128
|
-
const propertyName = getNodeName(node.property);
|
|
129
|
-
return objectName && propertyName ? `${objectName}.${propertyName}` : propertyName;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const getJsxElementName = (node)=>{
|
|
133
|
-
if (node?.type !== 'JSXElement') return;
|
|
134
|
-
return getNodeName(node.openingElement?.name);
|
|
135
|
-
};
|
|
136
|
-
const hasAllowedElementAncestor = (node, allowedElements)=>{
|
|
137
|
-
let current = node;
|
|
138
|
-
while(current){
|
|
139
|
-
const elementName = getJsxElementName(current);
|
|
140
|
-
if (elementName && allowedElements.has(elementName)) return true;
|
|
141
|
-
current = current.parent;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
};
|
|
145
|
-
const getTemplateLiteralValue = (node)=>{
|
|
146
|
-
if ('TemplateLiteral' !== node.type || (node.expressions?.length ?? 0) > 0) return;
|
|
147
|
-
const quasi = node.quasis?.[0];
|
|
148
|
-
if (!isRecord(quasi?.value)) return;
|
|
149
|
-
const cooked = quasi.value.cooked;
|
|
150
|
-
const raw = quasi.value.raw;
|
|
151
|
-
return 'string' == typeof cooked ? cooked : 'string' == typeof raw ? raw : void 0;
|
|
152
|
-
};
|
|
153
|
-
const getStringLiteralValue = (node)=>{
|
|
154
|
-
if (!node) return;
|
|
155
|
-
if (('Literal' === node.type || 'StringLiteral' === node.type) && 'string' == typeof node.value) return node.value;
|
|
156
|
-
return getTemplateLiteralValue(node);
|
|
157
|
-
};
|
|
158
|
-
const expressionStringValue = (node)=>getStringLiteralValue(node?.type === 'JSXExpressionContainer' ? node.expression : node);
|
|
159
|
-
const getLine = (node)=>node.loc?.start?.line;
|
|
160
|
-
const hasIgnoreComment = (node, context, pattern)=>{
|
|
161
|
-
const sourceCode = context.getSourceCode?.();
|
|
162
|
-
const nodeLine = getLine(node);
|
|
163
|
-
if (!sourceCode?.getAllComments || void 0 === nodeLine) return false;
|
|
164
|
-
return sourceCode.getAllComments().some((comment)=>{
|
|
165
|
-
const commentValue = String(comment.value ?? '');
|
|
166
|
-
if (!pattern.test(commentValue)) return false;
|
|
167
|
-
const startLine = comment.loc?.start?.line;
|
|
168
|
-
const endLine = comment.loc?.end?.line ?? startLine;
|
|
169
|
-
return void 0 !== startLine && void 0 !== endLine && startLine <= nodeLine + 1 && endLine >= nodeLine - 1;
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
const getIgnorePattern = (options)=>new RegExp(options.ignoreCommentPattern, 'u');
|
|
173
|
-
const reportVisibleText = (context, node, text)=>{
|
|
174
|
-
context.report({
|
|
175
|
-
node,
|
|
176
|
-
message: `Move user-visible JSX text to locale resources: ${JSON.stringify(text)}`
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
const createNoHardcodedJsxTextRule = ()=>({
|
|
180
|
-
meta: {
|
|
181
|
-
type: 'problem',
|
|
182
|
-
docs: {
|
|
183
|
-
description: 'Disallow literal user-visible text in JSX children in UltraModern generated apps.'
|
|
184
|
-
},
|
|
185
|
-
schema: [
|
|
186
|
-
commonOptionsSchema
|
|
187
|
-
]
|
|
188
|
-
},
|
|
189
|
-
create (context) {
|
|
190
|
-
const options = getCommonRuleOption(context, {
|
|
191
|
-
allowElements: DEFAULT_ALLOWED_ELEMENTS,
|
|
192
|
-
ignoreCommentPattern: DEFAULT_IGNORE_COMMENT_PATTERN
|
|
193
|
-
});
|
|
194
|
-
const allowedElements = new Set(options.allowElements);
|
|
195
|
-
const ignorePattern = getIgnorePattern(options);
|
|
196
|
-
const shouldSkipNode = (node)=>hasAllowedElementAncestor(node, allowedElements) || hasIgnoreComment(node, context, ignorePattern);
|
|
197
|
-
return {
|
|
198
|
-
JSXText (node) {
|
|
199
|
-
const text = normalizeVisibleText(String(node.value ?? ''));
|
|
200
|
-
if (!text || !hasLetters(text) || shouldSkipNode(node)) return;
|
|
201
|
-
reportVisibleText(context, node, text);
|
|
202
|
-
},
|
|
203
|
-
JSXExpressionContainer (node) {
|
|
204
|
-
if (node.parent?.type !== 'JSXElement' && node.parent?.type !== 'JSXFragment') return;
|
|
205
|
-
const text = normalizeVisibleText(expressionStringValue(node.expression) ?? '');
|
|
206
|
-
if (!text || !hasLetters(text) || shouldSkipNode(node)) return;
|
|
207
|
-
reportVisibleText(context, node, text);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
const createNoLiteralVisibleJsxAttributesRule = ()=>({
|
|
213
|
-
meta: {
|
|
214
|
-
type: 'problem',
|
|
215
|
-
docs: {
|
|
216
|
-
description: 'Disallow literal user-visible JSX attribute text in UltraModern generated apps.'
|
|
217
|
-
},
|
|
218
|
-
schema: [
|
|
219
|
-
attributeOptionsSchema
|
|
220
|
-
]
|
|
221
|
-
},
|
|
222
|
-
create (context) {
|
|
223
|
-
const options = getAttributeRuleOption(context, {
|
|
224
|
-
allowElements: DEFAULT_ALLOWED_ELEMENTS,
|
|
225
|
-
ignoreCommentPattern: DEFAULT_IGNORE_COMMENT_PATTERN,
|
|
226
|
-
visibleAttributes: DEFAULT_VISIBLE_ATTRIBUTES
|
|
227
|
-
});
|
|
228
|
-
const visibleAttributes = new Set(options.visibleAttributes);
|
|
229
|
-
const ignorePattern = getIgnorePattern(options);
|
|
230
|
-
return {
|
|
231
|
-
JSXAttribute (node) {
|
|
232
|
-
const attributeName = getNodeName(node.name);
|
|
233
|
-
if (!attributeName || !visibleAttributes.has(attributeName)) return;
|
|
234
|
-
const text = normalizeVisibleText(expressionStringValue(node.value) ?? '');
|
|
235
|
-
if (!text || !hasLetters(text) || hasIgnoreComment(node, context, ignorePattern)) return;
|
|
236
|
-
context.report({
|
|
237
|
-
node,
|
|
238
|
-
message: `Move literal ${attributeName} copy to locale resources: ${JSON.stringify(text)}`
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
const getSourceText = (context, node)=>context.getSourceCode?.().getText?.(node) ?? context.getSourceCode?.().text ?? '';
|
|
245
|
-
const normalizeFilename = (filePath)=>(filePath ?? '').replaceAll('\\', '/');
|
|
246
|
-
const isApiSourceFile = (filePath)=>API_SOURCE_FILE_PATTERN.test(normalizeFilename(filePath));
|
|
247
|
-
const isForbiddenGeneratedEffectPath = (filePath)=>FORBIDDEN_GENERATED_EFFECT_PATH_PATTERN.test(normalizeFilename(filePath));
|
|
248
|
-
const isApiEntryFile = (filePath)=>API_ENTRY_PATTERN.test(normalizeFilename(filePath));
|
|
249
|
-
const isSharedApiContractFile = (filePath)=>SHARED_API_CONTRACT_PATTERN.test(normalizeFilename(filePath));
|
|
250
|
-
const looksLikeLocaleTest = (context, node)=>{
|
|
251
|
-
const text = getSourceText(context, node);
|
|
252
|
-
return /\b(?:language|locale|lng|currentLanguage)\b/u.test(text) && /(?:={2,3}|!==?)/u.test(text) && /['"][a-z]{2}(?:-[A-Za-z0-9]+)?['"]/u.test(text);
|
|
253
|
-
};
|
|
254
|
-
const isAllowedBranchLiteral = (text)=>new Set([
|
|
255
|
-
'page',
|
|
256
|
-
'undefined',
|
|
257
|
-
'null',
|
|
258
|
-
'true',
|
|
259
|
-
'false'
|
|
260
|
-
]).has(text);
|
|
261
|
-
const createNoManualLocaleCopyBranchingRule = ()=>({
|
|
262
|
-
meta: {
|
|
263
|
-
type: 'problem',
|
|
264
|
-
docs: {
|
|
265
|
-
description: 'Disallow manual locale conditionals that choose user-visible copy.'
|
|
266
|
-
},
|
|
267
|
-
schema: []
|
|
268
|
-
},
|
|
269
|
-
create (context) {
|
|
270
|
-
const reportBranch = (node, text)=>{
|
|
271
|
-
context.report({
|
|
272
|
-
node,
|
|
273
|
-
message: `Move locale-specific copy branch to i18n resources: ${JSON.stringify(normalizeVisibleText(text))}`
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
return {
|
|
277
|
-
ConditionalExpression (node) {
|
|
278
|
-
if (!node.test || !looksLikeLocaleTest(context, node.test)) return;
|
|
279
|
-
for (const branch of [
|
|
280
|
-
node.consequent,
|
|
281
|
-
node.alternate
|
|
282
|
-
]){
|
|
283
|
-
const text = expressionStringValue(branch);
|
|
284
|
-
if (text && hasLetters(text) && !isAllowedBranchLiteral(text.trim())) reportBranch(branch, text);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
const getCallExpressionName = (node)=>getNodeName(node);
|
|
291
|
-
const createNoSplitTranslationKeysRule = ()=>({
|
|
292
|
-
meta: {
|
|
293
|
-
type: 'problem',
|
|
294
|
-
docs: {
|
|
295
|
-
description: 'Disallow split phrase translation key suffixes such as .prefix and .suffix.'
|
|
296
|
-
},
|
|
297
|
-
schema: [
|
|
298
|
-
translationOptionsSchema
|
|
299
|
-
]
|
|
300
|
-
},
|
|
301
|
-
create (context) {
|
|
302
|
-
const options = getSplitTranslationKeyRuleOption(context, {
|
|
303
|
-
translationFunctions: DEFAULT_TRANSLATION_FUNCTIONS
|
|
304
|
-
});
|
|
305
|
-
const translationFunctions = new Set(options.translationFunctions);
|
|
306
|
-
return {
|
|
307
|
-
CallExpression (node) {
|
|
308
|
-
const calleeName = getCallExpressionName(node.callee);
|
|
309
|
-
if (!calleeName || !translationFunctions.has(calleeName)) return;
|
|
310
|
-
const key = expressionStringValue(node.arguments?.[0]);
|
|
311
|
-
if (!key || !SPLIT_TRANSLATION_KEY_PATTERN.test(key)) return;
|
|
312
|
-
context.report({
|
|
313
|
-
node,
|
|
314
|
-
message: 'Keep translator-owned phrases whole instead of using split translation keys.'
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
const createNoLegacyMfBoundaryAttributesRule = ()=>({
|
|
321
|
-
meta: {
|
|
322
|
-
type: 'problem',
|
|
323
|
-
docs: {
|
|
324
|
-
description: 'Disallow legacy Module Federation boundary attributes in generated UltraModern workspaces.'
|
|
325
|
-
},
|
|
326
|
-
schema: []
|
|
327
|
-
},
|
|
328
|
-
create (context) {
|
|
329
|
-
return {
|
|
330
|
-
JSXAttribute (node) {
|
|
331
|
-
const attributeName = getNodeName(node.name);
|
|
332
|
-
if ('data-mf-boundary' !== attributeName && 'data-mf-remote' !== attributeName && 'data-mf-expose' !== attributeName) return;
|
|
333
|
-
context.report({
|
|
334
|
-
node,
|
|
335
|
-
message: 'Use data-modern-boundary-id and data-modern-mf-expose instead of legacy data-mf-* boundary attributes.'
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
const reportProgramPattern = (context, node, source, pattern, message)=>{
|
|
342
|
-
if (pattern.test(source)) context.report({
|
|
343
|
-
node,
|
|
344
|
-
message
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
const reportMissingProgramPattern = (context, node, source, pattern, message)=>{
|
|
348
|
-
if (!pattern.test(source)) context.report({
|
|
349
|
-
node,
|
|
350
|
-
message
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
const createStrictEffectApiBoundariesRule = ()=>({
|
|
76
|
+
(()=>{
|
|
77
|
+
__webpack_require__.r(__webpack_exports__);
|
|
78
|
+
var _oxlint_plugin_rules_no_hardcoded_jsx_text_ts__rspack_import_0 = __webpack_require__("./oxlint-plugin/rules/no-hardcoded-jsx-text.ts");
|
|
79
|
+
var _oxlint_plugin_rules_no_legacy_mf_boundary_attributes_ts__rspack_import_1 = __webpack_require__("./oxlint-plugin/rules/no-legacy-mf-boundary-attributes.ts");
|
|
80
|
+
var _oxlint_plugin_rules_no_literal_visible_jsx_attributes_ts__rspack_import_2 = __webpack_require__("./oxlint-plugin/rules/no-literal-visible-jsx-attributes.ts");
|
|
81
|
+
var _oxlint_plugin_rules_no_manual_locale_copy_branching_ts__rspack_import_3 = __webpack_require__("./oxlint-plugin/rules/no-manual-locale-copy-branching.ts");
|
|
82
|
+
var _oxlint_plugin_rules_no_split_translation_keys_ts__rspack_import_4 = __webpack_require__("./oxlint-plugin/rules/no-split-translation-keys.ts");
|
|
83
|
+
var _oxlint_plugin_rules_strict_effect_api_boundaries_ts__rspack_import_5 = __webpack_require__("./oxlint-plugin/rules/strict-effect-api-boundaries.ts");
|
|
84
|
+
var _oxlint_plugin_ast_ts__rspack_import_6 = __webpack_require__("./oxlint-plugin/ast.ts");
|
|
85
|
+
var __rspack_reexport = {};
|
|
86
|
+
for(const __rspack_import_key in _oxlint_plugin_ast_ts__rspack_import_6)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_ast_ts__rspack_import_6[__rspack_import_key];
|
|
87
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
88
|
+
var _oxlint_plugin_options_ts__rspack_import_7 = __webpack_require__("./oxlint-plugin/options.ts");
|
|
89
|
+
var __rspack_reexport = {};
|
|
90
|
+
for(const __rspack_import_key in _oxlint_plugin_options_ts__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_options_ts__rspack_import_7[__rspack_import_key];
|
|
91
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
92
|
+
var __rspack_reexport = {};
|
|
93
|
+
for(const __rspack_import_key in _oxlint_plugin_rules_no_hardcoded_jsx_text_ts__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_rules_no_hardcoded_jsx_text_ts__rspack_import_0[__rspack_import_key];
|
|
94
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
95
|
+
var __rspack_reexport = {};
|
|
96
|
+
for(const __rspack_import_key in _oxlint_plugin_rules_no_legacy_mf_boundary_attributes_ts__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_rules_no_legacy_mf_boundary_attributes_ts__rspack_import_1[__rspack_import_key];
|
|
97
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
98
|
+
var __rspack_reexport = {};
|
|
99
|
+
for(const __rspack_import_key in _oxlint_plugin_rules_no_literal_visible_jsx_attributes_ts__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_rules_no_literal_visible_jsx_attributes_ts__rspack_import_2[__rspack_import_key];
|
|
100
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
101
|
+
var __rspack_reexport = {};
|
|
102
|
+
for(const __rspack_import_key in _oxlint_plugin_rules_no_manual_locale_copy_branching_ts__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_rules_no_manual_locale_copy_branching_ts__rspack_import_3[__rspack_import_key];
|
|
103
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
104
|
+
var __rspack_reexport = {};
|
|
105
|
+
for(const __rspack_import_key in _oxlint_plugin_rules_no_split_translation_keys_ts__rspack_import_4)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_rules_no_split_translation_keys_ts__rspack_import_4[__rspack_import_key];
|
|
106
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
107
|
+
var __rspack_reexport = {};
|
|
108
|
+
for(const __rspack_import_key in _oxlint_plugin_rules_strict_effect_api_boundaries_ts__rspack_import_5)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_rules_strict_effect_api_boundaries_ts__rspack_import_5[__rspack_import_key];
|
|
109
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
110
|
+
var _oxlint_plugin_types_ts__rspack_import_8 = __webpack_require__("./oxlint-plugin/types.ts");
|
|
111
|
+
var __rspack_reexport = {};
|
|
112
|
+
for(const __rspack_import_key in _oxlint_plugin_types_ts__rspack_import_8)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_oxlint_plugin_types_ts__rspack_import_8[__rspack_import_key];
|
|
113
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
114
|
+
const plugin = {
|
|
354
115
|
meta: {
|
|
355
|
-
|
|
356
|
-
docs: {
|
|
357
|
-
description: 'Disallow raw HTTP handlers and non-Effect API runtime drift in UltraModern workspaces.'
|
|
358
|
-
},
|
|
359
|
-
schema: []
|
|
116
|
+
name: 'ultramodern'
|
|
360
117
|
},
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
node,
|
|
369
|
-
message: 'Generated UltraModern workspaces use direct api/index.ts, shared/api.ts and src/api/* paths; api/effect, api/lambda, shared/effect and src/effect are forbidden.'
|
|
370
|
-
});
|
|
371
|
-
reportProgramPattern(context, node, source, /@modern-js\/plugin-bff\/hono-server/u, 'UltraModern API workspaces must not import Hono server helpers; use @modern-js/plugin-bff/effect-edge and HttpApi.');
|
|
372
|
-
reportProgramPattern(context, node, source, /\bruntimeFramework\s*(?::|=)\s*['"]hono['"]/u, 'UltraModern API apps must use bff.runtimeFramework: "effect".');
|
|
373
|
-
reportProgramPattern(context, node, source, /(?:from|import)\s*['"][^'"]*(?:api\/effect|shared\/effect)[^'"]*['"]|shared-effect-api/u, 'Import API code from direct api/index.ts, shared/api.ts or src/api/* paths, not api/effect, shared/effect or shared Effect API packages.');
|
|
374
|
-
reportProgramPattern(context, node, source, /\bstrictEffectApproach\s*(?::|=)\s*false\b/u, 'UltraModern API apps must keep strictEffectApproach enabled.');
|
|
375
|
-
if (isApiEntryFile(filename)) {
|
|
376
|
-
reportMissingProgramPattern(context, node, source, /\bdefineEffectBff\b/u, 'Generated API entries must export defineEffectBff(...).');
|
|
377
|
-
reportMissingProgramPattern(context, node, source, /\bHttpApiBuilder\b/u, 'Generated API entries must implement handlers through HttpApiBuilder.');
|
|
378
|
-
reportMissingProgramPattern(context, node, source, /\bLayer\b/u, 'Generated API entries must compose dependencies with Effect Layer.');
|
|
379
|
-
reportMissingProgramPattern(context, node, source, /from\s+['"]\.\.\/shared\/api\.ts['"]/u, 'Generated API entries must import the contract from ../shared/api.ts.');
|
|
380
|
-
}
|
|
381
|
-
if (isSharedApiContractFile(filename)) {
|
|
382
|
-
reportMissingProgramPattern(context, node, source, /\bHttpApi\.make\b/u, 'Generated shared API contracts must declare an HttpApi contract.');
|
|
383
|
-
reportMissingProgramPattern(context, node, source, /\bHttpApiGroup\.make\b/u, 'Generated shared API contracts must declare HttpApi groups.');
|
|
384
|
-
reportMissingProgramPattern(context, node, source, /\bHttpApiEndpoint\./u, 'Generated shared API contracts must declare endpoints through HttpApiEndpoint.');
|
|
385
|
-
reportMissingProgramPattern(context, node, source, /\bSchema\./u, 'Generated shared API contracts must model request, response and error shapes with Schema.');
|
|
386
|
-
}
|
|
387
|
-
if (!apiFile) return;
|
|
388
|
-
reportProgramPattern(context, node, source, /\bnew\s+Response\s*\(|\bResponse\.json\s*\(/u, 'API modules must not hand-build Response objects; model endpoints through Effect HttpApi and schemas.');
|
|
389
|
-
reportProgramPattern(context, node, source, /\b(?:request|req)\.(?:json|text|formData|arrayBuffer)\s*\(/u, 'API modules must not manually parse request bodies; use HttpApiEndpoint payload/query/params schemas.');
|
|
390
|
-
reportProgramPattern(context, node, source, /\bexport\s+const\s+handler\b|\bexport\s+default\s+async\b/u, 'API modules must not export raw request handlers; export defineEffectBff(...) from api/index.ts.');
|
|
391
|
-
reportProgramPattern(context, node, source, /\bcreateHandler\s*[:=]\s*(?!defineEffectBff\b)/u, 'API modules must not define unbranded handler factories; use defineEffectBff(...).');
|
|
392
|
-
reportProgramPattern(context, node, source, /\bSchema\.(?:UnknownFromJsonString|Unknown|Any)\b/u, 'API modules must use concrete request, response and error schemas; Schema.UnknownFromJsonString, Schema.Unknown and Schema.Any are forbidden in UltraModern API code.');
|
|
393
|
-
}
|
|
394
|
-
};
|
|
118
|
+
rules: {
|
|
119
|
+
'no-hardcoded-jsx-text': (0, _oxlint_plugin_rules_no_hardcoded_jsx_text_ts__rspack_import_0.createNoHardcodedJsxTextRule)(),
|
|
120
|
+
'no-legacy-mf-boundary-attributes': (0, _oxlint_plugin_rules_no_legacy_mf_boundary_attributes_ts__rspack_import_1.createNoLegacyMfBoundaryAttributesRule)(),
|
|
121
|
+
'no-literal-visible-jsx-attributes': (0, _oxlint_plugin_rules_no_literal_visible_jsx_attributes_ts__rspack_import_2.createNoLiteralVisibleJsxAttributesRule)(),
|
|
122
|
+
'no-manual-locale-copy-branching': (0, _oxlint_plugin_rules_no_manual_locale_copy_branching_ts__rspack_import_3.createNoManualLocaleCopyBranchingRule)(),
|
|
123
|
+
'no-split-translation-keys': (0, _oxlint_plugin_rules_no_split_translation_keys_ts__rspack_import_4.createNoSplitTranslationKeysRule)(),
|
|
124
|
+
'strict-effect-api-boundaries': (0, _oxlint_plugin_rules_strict_effect_api_boundaries_ts__rspack_import_5.createStrictEffectApiBoundariesRule)()
|
|
395
125
|
}
|
|
126
|
+
};
|
|
127
|
+
const __rspack_default_export = plugin;
|
|
128
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
129
|
+
default: __rspack_default_export
|
|
396
130
|
});
|
|
397
|
-
|
|
398
|
-
meta: {
|
|
399
|
-
name: 'ultramodern'
|
|
400
|
-
},
|
|
401
|
-
rules: {
|
|
402
|
-
'no-hardcoded-jsx-text': createNoHardcodedJsxTextRule(),
|
|
403
|
-
'no-legacy-mf-boundary-attributes': createNoLegacyMfBoundaryAttributesRule(),
|
|
404
|
-
'no-literal-visible-jsx-attributes': createNoLiteralVisibleJsxAttributesRule(),
|
|
405
|
-
'no-manual-locale-copy-branching': createNoManualLocaleCopyBranchingRule(),
|
|
406
|
-
'no-split-translation-keys': createNoSplitTranslationKeysRule(),
|
|
407
|
-
'strict-effect-api-boundaries': createStrictEffectApiBoundariesRule()
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
const __rspack_default_export = plugin;
|
|
411
|
-
__webpack_require__.d(__webpack_exports__, {}, {
|
|
412
|
-
default: __rspack_default_export
|
|
413
|
-
});
|
|
131
|
+
})();
|
|
414
132
|
exports["default"] = __webpack_exports__["default"];
|
|
415
133
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
416
134
|
"default"
|
|
@@ -23,4 +23,4 @@ const runSingleAppI18nCheck = ({ cwd = process.cwd(), targets = [
|
|
|
23
23
|
const main = ()=>{
|
|
24
24
|
process.exitCode = runSingleAppI18nCheck();
|
|
25
25
|
};
|
|
26
|
-
export {
|
|
26
|
+
export { main, runSingleAppI18nCheck };
|
|
@@ -142,4 +142,4 @@ const runWorkspaceSourceCheck = ({ cwd = process.cwd(), sourceRoots = [
|
|
|
142
142
|
const main = ()=>{
|
|
143
143
|
process.exitCode = runWorkspaceSourceCheck();
|
|
144
144
|
};
|
|
145
|
-
export {
|
|
145
|
+
export { main, runWorkspaceSourceCheck };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { API_ENTRY_PATTERN, API_SOURCE_FILE_PATTERN, FORBIDDEN_GENERATED_EFFECT_PATH_PATTERN, LETTER_PATTERN, SHARED_API_CONTRACT_PATTERN } from "./options.js";
|
|
2
|
+
const isRecord = (value)=>Boolean(value) && 'object' == typeof value && !Array.isArray(value);
|
|
3
|
+
const asStringArray = (value, fallback)=>Array.isArray(value) && value.every((item)=>'string' == typeof item) ? value : fallback;
|
|
4
|
+
const normalizeVisibleText = (value)=>value.replaceAll(/\s+/gu, ' ').trim();
|
|
5
|
+
const hasLetters = (value)=>LETTER_PATTERN.test(value);
|
|
6
|
+
const getNodeName = (node)=>{
|
|
7
|
+
if (!node) return;
|
|
8
|
+
if ('string' == typeof node.name) return node.name;
|
|
9
|
+
if ('JSXIdentifier' === node.type && isRecord(node.name) && 'string' == typeof node.name.name) return node.name.name;
|
|
10
|
+
if ('JSXIdentifier' === node.type && 'string' == typeof node.name) return node.name;
|
|
11
|
+
if (('JSXMemberExpression' === node.type || 'MemberExpression' === node.type) && isRecord(node.property) && true !== node.computed) {
|
|
12
|
+
const objectName = getNodeName(node.object);
|
|
13
|
+
const propertyName = getNodeName(node.property);
|
|
14
|
+
return objectName && propertyName ? `${objectName}.${propertyName}` : propertyName;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getJsxElementName = (node)=>{
|
|
18
|
+
if (node?.type !== 'JSXElement') return;
|
|
19
|
+
return getNodeName(node.openingElement?.name);
|
|
20
|
+
};
|
|
21
|
+
const hasAllowedElementAncestor = (node, allowedElements)=>{
|
|
22
|
+
let current = node;
|
|
23
|
+
while(current){
|
|
24
|
+
const elementName = getJsxElementName(current);
|
|
25
|
+
if (elementName && allowedElements.has(elementName)) return true;
|
|
26
|
+
current = current.parent;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
const getTemplateLiteralValue = (node)=>{
|
|
31
|
+
if ('TemplateLiteral' !== node.type || (node.expressions?.length ?? 0) > 0) return;
|
|
32
|
+
const quasi = node.quasis?.[0];
|
|
33
|
+
if (!isRecord(quasi?.value)) return;
|
|
34
|
+
const cooked = quasi.value.cooked;
|
|
35
|
+
const raw = quasi.value.raw;
|
|
36
|
+
return 'string' == typeof cooked ? cooked : 'string' == typeof raw ? raw : void 0;
|
|
37
|
+
};
|
|
38
|
+
const getStringLiteralValue = (node)=>{
|
|
39
|
+
if (!node) return;
|
|
40
|
+
if (('Literal' === node.type || 'StringLiteral' === node.type) && 'string' == typeof node.value) return node.value;
|
|
41
|
+
return getTemplateLiteralValue(node);
|
|
42
|
+
};
|
|
43
|
+
const expressionStringValue = (node)=>getStringLiteralValue(node?.type === 'JSXExpressionContainer' ? node.expression : node);
|
|
44
|
+
const getLine = (node)=>node.loc?.start?.line;
|
|
45
|
+
const hasIgnoreComment = (node, context, pattern)=>{
|
|
46
|
+
const sourceCode = context.getSourceCode?.();
|
|
47
|
+
const nodeLine = getLine(node);
|
|
48
|
+
if (!sourceCode?.getAllComments || void 0 === nodeLine) return false;
|
|
49
|
+
return sourceCode.getAllComments().some((comment)=>{
|
|
50
|
+
const commentValue = String(comment.value ?? '');
|
|
51
|
+
if (!pattern.test(commentValue)) return false;
|
|
52
|
+
const startLine = comment.loc?.start?.line;
|
|
53
|
+
const endLine = comment.loc?.end?.line ?? startLine;
|
|
54
|
+
return void 0 !== startLine && void 0 !== endLine && startLine <= nodeLine + 1 && endLine >= nodeLine - 1;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const getIgnorePattern = (options)=>new RegExp(options.ignoreCommentPattern, 'u');
|
|
58
|
+
const reportVisibleText = (context, node, text)=>{
|
|
59
|
+
context.report({
|
|
60
|
+
node,
|
|
61
|
+
message: `Move user-visible JSX text to locale resources: ${JSON.stringify(text)}`
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const getSourceText = (context, node)=>context.getSourceCode?.().getText?.(node) ?? context.getSourceCode?.().text ?? '';
|
|
65
|
+
const normalizeFilename = (filePath)=>(filePath ?? '').replaceAll('\\', '/');
|
|
66
|
+
const isApiSourceFile = (filePath)=>API_SOURCE_FILE_PATTERN.test(normalizeFilename(filePath));
|
|
67
|
+
const isForbiddenGeneratedEffectPath = (filePath)=>FORBIDDEN_GENERATED_EFFECT_PATH_PATTERN.test(normalizeFilename(filePath));
|
|
68
|
+
const isApiEntryFile = (filePath)=>API_ENTRY_PATTERN.test(normalizeFilename(filePath));
|
|
69
|
+
const isSharedApiContractFile = (filePath)=>SHARED_API_CONTRACT_PATTERN.test(normalizeFilename(filePath));
|
|
70
|
+
const getCallExpressionName = (node)=>getNodeName(node);
|
|
71
|
+
const reportProgramPattern = (context, node, source, pattern, message)=>{
|
|
72
|
+
if (pattern.test(source)) context.report({
|
|
73
|
+
node,
|
|
74
|
+
message
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const reportMissingProgramPattern = (context, node, source, pattern, message)=>{
|
|
78
|
+
if (!pattern.test(source)) context.report({
|
|
79
|
+
node,
|
|
80
|
+
message
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
export { asStringArray, expressionStringValue, getCallExpressionName, getIgnorePattern, getLine, getNodeName, getSourceText, getStringLiteralValue, hasAllowedElementAncestor, hasIgnoreComment, hasLetters, isApiEntryFile, isApiSourceFile, isForbiddenGeneratedEffectPath, isRecord, isSharedApiContractFile, normalizeFilename, normalizeVisibleText, reportMissingProgramPattern, reportProgramPattern, reportVisibleText };
|