praxis-kit 1.1.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/LICENSE +21 -0
- package/dist/chunk-KDUNVQK2.js +2059 -0
- package/dist/codemod/index.d.ts +21 -0
- package/dist/codemod/index.js +241955 -0
- package/dist/eslint/index.d.ts +84 -0
- package/dist/eslint/index.js +1068 -0
- package/dist/lit/index.d.ts +304 -0
- package/dist/lit/index.js +1887 -0
- package/dist/merge-refs-CfBqh1UO.d.ts +374 -0
- package/dist/preact/index.d.ts +292 -0
- package/dist/preact/index.js +2062 -0
- package/dist/react/index.d.ts +27 -0
- package/dist/react/index.js +197 -0
- package/dist/react/legacy.d.ts +21 -0
- package/dist/react/legacy.js +209 -0
- package/dist/solid/index.d.ts +287 -0
- package/dist/solid/index.js +1837 -0
- package/dist/svelte/index.d.ts +343 -0
- package/dist/svelte/index.js +1723 -0
- package/dist/tailwind/index.d.ts +138 -0
- package/dist/tailwind/index.js +508 -0
- package/dist/ts-plugin/index.cjs +191 -0
- package/dist/ts-plugin/index.d.cts +10 -0
- package/dist/vite-plugin/index.d.ts +395 -0
- package/dist/vite-plugin/index.js +1329 -0
- package/dist/vue/index.d.ts +309 -0
- package/dist/vue/index.js +1922 -0
- package/dist/web/index.d.ts +302 -0
- package/dist/web/index.js +1858 -0
- package/package.json +176 -0
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/deepMerge.js
|
|
28
|
+
var require_deepMerge = __commonJS({
|
|
29
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/deepMerge.js"(exports) {
|
|
30
|
+
"use strict";
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.isObjectNotArray = isObjectNotArray;
|
|
33
|
+
exports.deepMerge = deepMerge;
|
|
34
|
+
function isObjectNotArray(obj) {
|
|
35
|
+
return typeof obj === "object" && obj != null && !Array.isArray(obj);
|
|
36
|
+
}
|
|
37
|
+
function deepMerge(first = {}, second = {}) {
|
|
38
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(first), ...Object.keys(second)]);
|
|
39
|
+
return Object.fromEntries([...keys].map((key) => {
|
|
40
|
+
const firstHasKey = key in first;
|
|
41
|
+
const secondHasKey = key in second;
|
|
42
|
+
const firstValue = first[key];
|
|
43
|
+
const secondValue = second[key];
|
|
44
|
+
let value;
|
|
45
|
+
if (firstHasKey && secondHasKey) {
|
|
46
|
+
if (isObjectNotArray(firstValue) && isObjectNotArray(secondValue)) {
|
|
47
|
+
value = deepMerge(firstValue, secondValue);
|
|
48
|
+
} else {
|
|
49
|
+
value = secondValue;
|
|
50
|
+
}
|
|
51
|
+
} else if (firstHasKey) {
|
|
52
|
+
value = firstValue;
|
|
53
|
+
} else {
|
|
54
|
+
value = secondValue;
|
|
55
|
+
}
|
|
56
|
+
return [key, value];
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/applyDefault.js
|
|
63
|
+
var require_applyDefault = __commonJS({
|
|
64
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/applyDefault.js"(exports) {
|
|
65
|
+
"use strict";
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.applyDefault = applyDefault;
|
|
68
|
+
var deepMerge_1 = require_deepMerge();
|
|
69
|
+
function applyDefault(defaultOptions, userOptions) {
|
|
70
|
+
const options = structuredClone(defaultOptions);
|
|
71
|
+
if (userOptions == null) {
|
|
72
|
+
return options;
|
|
73
|
+
}
|
|
74
|
+
options.forEach((opt, i) => {
|
|
75
|
+
if (userOptions[i] !== void 0) {
|
|
76
|
+
const userOpt = userOptions[i];
|
|
77
|
+
if ((0, deepMerge_1.isObjectNotArray)(userOpt) && (0, deepMerge_1.isObjectNotArray)(opt)) {
|
|
78
|
+
options[i] = (0, deepMerge_1.deepMerge)(opt, userOpt);
|
|
79
|
+
} else {
|
|
80
|
+
options[i] = userOpt;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return options;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/parserSeemsToBeTSESLint.js
|
|
90
|
+
var require_parserSeemsToBeTSESLint = __commonJS({
|
|
91
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/parserSeemsToBeTSESLint.js"(exports) {
|
|
92
|
+
"use strict";
|
|
93
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
94
|
+
exports.parserSeemsToBeTSESLint = parserSeemsToBeTSESLint;
|
|
95
|
+
function parserSeemsToBeTSESLint(parser) {
|
|
96
|
+
return !!parser && /(?:typescript-eslint|\.\.)[\w/\\]*parser/.test(parser);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js
|
|
102
|
+
var require_getParserServices = __commonJS({
|
|
103
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js"(exports) {
|
|
104
|
+
"use strict";
|
|
105
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106
|
+
exports.getParserServices = getParserServices;
|
|
107
|
+
var parserSeemsToBeTSESLint_1 = require_parserSeemsToBeTSESLint();
|
|
108
|
+
var ERROR_MESSAGE_REQUIRES_PARSER_SERVICES = "You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.";
|
|
109
|
+
var ERROR_MESSAGE_UNKNOWN_PARSER = 'Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.';
|
|
110
|
+
function getParserServices(context, allowWithoutFullTypeInformation = false) {
|
|
111
|
+
const parser = (
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- For compatibility with ESLint 8
|
|
113
|
+
context.parserPath || context.languageOptions.parser?.meta?.name
|
|
114
|
+
);
|
|
115
|
+
if (context.sourceCode.parserServices?.esTreeNodeToTSNodeMap == null || context.sourceCode.parserServices.tsNodeToESTreeNodeMap == null) {
|
|
116
|
+
throwError(parser);
|
|
117
|
+
}
|
|
118
|
+
if (context.sourceCode.parserServices.program == null && !allowWithoutFullTypeInformation) {
|
|
119
|
+
throwError(parser);
|
|
120
|
+
}
|
|
121
|
+
return context.sourceCode.parserServices;
|
|
122
|
+
}
|
|
123
|
+
function throwError(parser) {
|
|
124
|
+
const messages = [
|
|
125
|
+
ERROR_MESSAGE_REQUIRES_PARSER_SERVICES,
|
|
126
|
+
`Parser: ${parser || "(unknown)"}`,
|
|
127
|
+
!(0, parserSeemsToBeTSESLint_1.parserSeemsToBeTSESLint)(parser) && ERROR_MESSAGE_UNKNOWN_PARSER
|
|
128
|
+
].filter(Boolean);
|
|
129
|
+
throw new Error(messages.join("\n"));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/InferTypesFromRule.js
|
|
135
|
+
var require_InferTypesFromRule = __commonJS({
|
|
136
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/InferTypesFromRule.js"(exports) {
|
|
137
|
+
"use strict";
|
|
138
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/nullThrows.js
|
|
143
|
+
var require_nullThrows = __commonJS({
|
|
144
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/nullThrows.js"(exports) {
|
|
145
|
+
"use strict";
|
|
146
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
147
|
+
exports.NullThrowsReasons = void 0;
|
|
148
|
+
exports.nullThrows = nullThrows;
|
|
149
|
+
exports.NullThrowsReasons = {
|
|
150
|
+
MissingParent: "Expected node to have a parent.",
|
|
151
|
+
MissingToken: (token, thing) => `Expected to find a ${token} for the ${thing}.`
|
|
152
|
+
};
|
|
153
|
+
function nullThrows(value, message) {
|
|
154
|
+
if (value == null) {
|
|
155
|
+
throw new Error(`Non-null Assertion Failed: ${message}`);
|
|
156
|
+
}
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js
|
|
163
|
+
var require_RuleCreator = __commonJS({
|
|
164
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js"(exports) {
|
|
165
|
+
"use strict";
|
|
166
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
167
|
+
exports.RuleCreator = RuleCreator8;
|
|
168
|
+
var applyDefault_1 = require_applyDefault();
|
|
169
|
+
function RuleCreator8(urlCreator) {
|
|
170
|
+
return function createNamedRule({ meta, name, ...rule }) {
|
|
171
|
+
const ruleWithDocs = createRule8({
|
|
172
|
+
meta: {
|
|
173
|
+
...meta,
|
|
174
|
+
docs: {
|
|
175
|
+
...meta.docs,
|
|
176
|
+
url: urlCreator(name)
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
name,
|
|
180
|
+
...rule
|
|
181
|
+
});
|
|
182
|
+
return ruleWithDocs;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function createRule8({
|
|
186
|
+
create,
|
|
187
|
+
// Keep accepting deprecated defaultOptions for backward compatibility.
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
189
|
+
defaultOptions,
|
|
190
|
+
meta,
|
|
191
|
+
name
|
|
192
|
+
}) {
|
|
193
|
+
const resolvedDefaultOptions = meta.defaultOptions ?? defaultOptions ?? [];
|
|
194
|
+
return {
|
|
195
|
+
create(context) {
|
|
196
|
+
const optionsWithDefault = (0, applyDefault_1.applyDefault)(resolvedDefaultOptions, context.options);
|
|
197
|
+
return create(context, optionsWithDefault);
|
|
198
|
+
},
|
|
199
|
+
defaultOptions,
|
|
200
|
+
meta,
|
|
201
|
+
name
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
RuleCreator8.withoutDocs = function withoutDocs(args) {
|
|
205
|
+
return createRule8(args);
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// ../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js
|
|
211
|
+
var require_eslint_utils = __commonJS({
|
|
212
|
+
"../../node_modules/.pnpm/@typescript-eslint+utils@8.60.0_eslint@10.4.1_jiti@2.7.0__typescript@6.0.3/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js"(exports) {
|
|
213
|
+
"use strict";
|
|
214
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
215
|
+
if (k2 === void 0) k2 = k;
|
|
216
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
217
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
218
|
+
desc = { enumerable: true, get: function() {
|
|
219
|
+
return m[k];
|
|
220
|
+
} };
|
|
221
|
+
}
|
|
222
|
+
Object.defineProperty(o, k2, desc);
|
|
223
|
+
}) : (function(o, m, k, k2) {
|
|
224
|
+
if (k2 === void 0) k2 = k;
|
|
225
|
+
o[k2] = m[k];
|
|
226
|
+
}));
|
|
227
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
228
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
229
|
+
};
|
|
230
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
231
|
+
__exportStar(require_applyDefault(), exports);
|
|
232
|
+
__exportStar(require_deepMerge(), exports);
|
|
233
|
+
__exportStar(require_getParserServices(), exports);
|
|
234
|
+
__exportStar(require_InferTypesFromRule(), exports);
|
|
235
|
+
__exportStar(require_nullThrows(), exports);
|
|
236
|
+
__exportStar(require_RuleCreator(), exports);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// ../eslint-plugin/src/rules/no-dead-compound.ts
|
|
241
|
+
var import_eslint_utils = __toESM(require_eslint_utils(), 1);
|
|
242
|
+
|
|
243
|
+
// ../eslint-plugin/src/utils/ast.ts
|
|
244
|
+
function getObjectProperty(obj, key) {
|
|
245
|
+
return obj.properties.find((prop) => {
|
|
246
|
+
if (prop.type !== "Property" || prop.kind !== "init" || prop.computed) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
const { key: propKey } = prop;
|
|
250
|
+
return propKey.type === "Identifier" && propKey.name === key || propKey.type === "Literal" && propKey.value === key;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function asObjectExpression(node) {
|
|
254
|
+
return node?.type === "ObjectExpression" ? node : void 0;
|
|
255
|
+
}
|
|
256
|
+
function asArrayExpression(node) {
|
|
257
|
+
return node?.type === "ArrayExpression" ? node : void 0;
|
|
258
|
+
}
|
|
259
|
+
function asNumericLiteral(node) {
|
|
260
|
+
if (node?.type === "Literal") {
|
|
261
|
+
const { value } = node;
|
|
262
|
+
if (typeof value === "number") {
|
|
263
|
+
return value;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (node?.type === "UnaryExpression") {
|
|
267
|
+
const { operator, argument } = node;
|
|
268
|
+
if ((operator === "-" || operator === "+") && argument.type === "Literal" && typeof argument.value === "number") {
|
|
269
|
+
return operator === "-" ? -argument.value : argument.value;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return void 0;
|
|
273
|
+
}
|
|
274
|
+
function isFactoryCall(node, calleeNames) {
|
|
275
|
+
const { callee } = node;
|
|
276
|
+
if (callee.type === "Identifier") {
|
|
277
|
+
return calleeNames.has(callee.name);
|
|
278
|
+
}
|
|
279
|
+
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
280
|
+
const { property } = callee;
|
|
281
|
+
return property.type === "Identifier" && calleeNames.has(property.name);
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
function getFirstObjectArg(node) {
|
|
286
|
+
const [first] = node.arguments;
|
|
287
|
+
return first?.type === "ObjectExpression" ? first : void 0;
|
|
288
|
+
}
|
|
289
|
+
function asStringLiteral(node) {
|
|
290
|
+
if (node?.type === "Literal" && typeof node.value === "string") return node.value;
|
|
291
|
+
return void 0;
|
|
292
|
+
}
|
|
293
|
+
function getPropertyKey(prop) {
|
|
294
|
+
const { key } = prop;
|
|
295
|
+
if (prop.computed) return void 0;
|
|
296
|
+
if (key.type === "Identifier") return key.name;
|
|
297
|
+
if (key.type === "Literal" && typeof key.value === "string") return key.value;
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
function extractVariantMap(variantsNode) {
|
|
301
|
+
const variantsObj = asObjectExpression(variantsNode);
|
|
302
|
+
if (!variantsObj) return void 0;
|
|
303
|
+
const map = /* @__PURE__ */ new Map();
|
|
304
|
+
for (const prop of variantsObj.properties) {
|
|
305
|
+
if (prop.type !== "Property") continue;
|
|
306
|
+
const key = getPropertyKey(prop);
|
|
307
|
+
if (!key) continue;
|
|
308
|
+
const valuesObj = asObjectExpression(prop.value);
|
|
309
|
+
if (!valuesObj) continue;
|
|
310
|
+
const values = /* @__PURE__ */ new Set();
|
|
311
|
+
for (const vProp of valuesObj.properties) {
|
|
312
|
+
if (vProp.type !== "Property") continue;
|
|
313
|
+
const vKey = getPropertyKey(vProp);
|
|
314
|
+
if (vKey !== void 0) values.add(vKey);
|
|
315
|
+
}
|
|
316
|
+
map.set(key, values);
|
|
317
|
+
}
|
|
318
|
+
return map;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// ../eslint-plugin/src/rules/no-dead-compound.ts
|
|
322
|
+
var createRule = (0, import_eslint_utils.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
323
|
+
var noDeadCompound = createRule({
|
|
324
|
+
name: "no-dead-compound",
|
|
325
|
+
meta: {
|
|
326
|
+
type: "problem",
|
|
327
|
+
docs: {
|
|
328
|
+
description: "Disallow compound variant conditions that reference unknown variant keys or values \u2014 compounds that can never fire."
|
|
329
|
+
},
|
|
330
|
+
messages: {
|
|
331
|
+
unknownVariantKey: '"{{ key }}" is not a variant defined in styling.variants. This compound condition can never match.',
|
|
332
|
+
unknownVariantValue: '"{{ value }}" is not a valid value for variant "{{ key }}". Expected one of: {{ allowed }}. This compound condition can never match.',
|
|
333
|
+
nonLiteralValue: 'Compound value for "{{ key }}" is not a string literal and cannot be statically validated.'
|
|
334
|
+
},
|
|
335
|
+
schema: [
|
|
336
|
+
{
|
|
337
|
+
type: "object",
|
|
338
|
+
properties: {
|
|
339
|
+
calleeNames: { type: "array", items: { type: "string" } },
|
|
340
|
+
reportNonLiteral: { type: "boolean" }
|
|
341
|
+
},
|
|
342
|
+
additionalProperties: false
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
defaultOptions: [{}],
|
|
347
|
+
create(context) {
|
|
348
|
+
const calleeNames = new Set(context.options[0]?.calleeNames ?? ["createContractComponent"]);
|
|
349
|
+
const reportNonLiteral = context.options[0]?.reportNonLiteral ?? false;
|
|
350
|
+
return {
|
|
351
|
+
CallExpression(node) {
|
|
352
|
+
if (!isFactoryCall(node, calleeNames)) return;
|
|
353
|
+
const arg = getFirstObjectArg(node);
|
|
354
|
+
if (!arg) return;
|
|
355
|
+
const stylingProp = getObjectProperty(arg, "styling");
|
|
356
|
+
if (!stylingProp) return;
|
|
357
|
+
const styling = asObjectExpression(stylingProp.value);
|
|
358
|
+
if (!styling) return;
|
|
359
|
+
const variantsProp = getObjectProperty(styling, "variants");
|
|
360
|
+
if (!variantsProp) return;
|
|
361
|
+
const variantMap = extractVariantMap(variantsProp.value);
|
|
362
|
+
if (!variantMap || variantMap.size === 0) return;
|
|
363
|
+
const compoundsProp = getObjectProperty(styling, "compounds");
|
|
364
|
+
if (!compoundsProp) return;
|
|
365
|
+
const compounds = asArrayExpression(compoundsProp.value);
|
|
366
|
+
if (!compounds) return;
|
|
367
|
+
for (const element of compounds.elements) {
|
|
368
|
+
if (!element || element.type !== "ObjectExpression") continue;
|
|
369
|
+
for (const prop of element.properties) {
|
|
370
|
+
if (prop.type !== "Property") continue;
|
|
371
|
+
const key = getPropertyKey(prop);
|
|
372
|
+
if (!key || key === "class" || key === "className") continue;
|
|
373
|
+
if (!variantMap.has(key)) {
|
|
374
|
+
context.report({
|
|
375
|
+
node: prop,
|
|
376
|
+
messageId: "unknownVariantKey",
|
|
377
|
+
data: { key }
|
|
378
|
+
});
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
const value = asStringLiteral(prop.value);
|
|
382
|
+
if (value === void 0) {
|
|
383
|
+
if (reportNonLiteral) {
|
|
384
|
+
context.report({ node: prop, messageId: "nonLiteralValue", data: { key } });
|
|
385
|
+
}
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
const allowed = variantMap.get(key);
|
|
389
|
+
if (!allowed.has(value)) {
|
|
390
|
+
context.report({
|
|
391
|
+
node: prop,
|
|
392
|
+
messageId: "unknownVariantValue",
|
|
393
|
+
data: { key, value, allowed: [...allowed].map((v) => `"${v}"`).join(", ") }
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// ../eslint-plugin/src/rules/no-enforcement-without-strict.ts
|
|
404
|
+
var import_eslint_utils2 = __toESM(require_eslint_utils(), 1);
|
|
405
|
+
var createRule2 = (0, import_eslint_utils2.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
406
|
+
var noEnforcementWithoutStrict = createRule2({
|
|
407
|
+
name: "no-enforcement-without-strict",
|
|
408
|
+
meta: {
|
|
409
|
+
type: "problem",
|
|
410
|
+
docs: {
|
|
411
|
+
description: "Require enforcement.strict when enforcement.children or enforcement.aria is defined."
|
|
412
|
+
},
|
|
413
|
+
messages: {
|
|
414
|
+
missingStrict: "enforcement.{{ field }} is defined but enforcement.strict is not explicitly set. Adapter defaults vary \u2014 declare strict explicitly so the behavior is clear at the call site."
|
|
415
|
+
},
|
|
416
|
+
schema: [
|
|
417
|
+
{
|
|
418
|
+
type: "object",
|
|
419
|
+
properties: {
|
|
420
|
+
calleeNames: { type: "array", items: { type: "string" } }
|
|
421
|
+
},
|
|
422
|
+
additionalProperties: false
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
},
|
|
426
|
+
defaultOptions: [{}],
|
|
427
|
+
create(context) {
|
|
428
|
+
const calleeNames = new Set(context.options[0]?.calleeNames ?? ["createContractComponent"]);
|
|
429
|
+
return {
|
|
430
|
+
CallExpression(node) {
|
|
431
|
+
if (!isFactoryCall(node, calleeNames)) return;
|
|
432
|
+
const arg = getFirstObjectArg(node);
|
|
433
|
+
if (!arg) return;
|
|
434
|
+
const enfProp = getObjectProperty(arg, "enforcement");
|
|
435
|
+
if (!enfProp) return;
|
|
436
|
+
const enf = asObjectExpression(enfProp.value);
|
|
437
|
+
if (!enf) return;
|
|
438
|
+
const hasStrict = getObjectProperty(enf, "strict") !== void 0;
|
|
439
|
+
for (const field of ["children", "aria"]) {
|
|
440
|
+
const fieldProp = getObjectProperty(enf, field);
|
|
441
|
+
if (!fieldProp) continue;
|
|
442
|
+
if (field === "children") {
|
|
443
|
+
const arr = asArrayExpression(fieldProp.value);
|
|
444
|
+
if (!arr || arr.elements.length === 0) continue;
|
|
445
|
+
}
|
|
446
|
+
if (!hasStrict) {
|
|
447
|
+
context.report({ node, messageId: "missingStrict", data: { field } });
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// ../eslint-plugin/src/rules/no-invalid-default.ts
|
|
457
|
+
var import_eslint_utils3 = __toESM(require_eslint_utils(), 1);
|
|
458
|
+
var createRule3 = (0, import_eslint_utils3.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
459
|
+
var noInvalidDefault = createRule3({
|
|
460
|
+
name: "no-invalid-default",
|
|
461
|
+
meta: {
|
|
462
|
+
type: "problem",
|
|
463
|
+
docs: {
|
|
464
|
+
description: "Disallow styling.defaults entries whose keys or values do not exist in styling.variants."
|
|
465
|
+
},
|
|
466
|
+
messages: {
|
|
467
|
+
unknownDefaultKey: '"{{ key }}" is not a variant defined in styling.variants. This default will have no effect.',
|
|
468
|
+
unknownDefaultValue: '"{{ value }}" is not a valid value for variant "{{ key }}". Expected one of: {{ allowed }}. This default will have no effect.',
|
|
469
|
+
nonLiteralValue: 'Default value for "{{ key }}" is not a string literal and cannot be statically validated.'
|
|
470
|
+
},
|
|
471
|
+
schema: [
|
|
472
|
+
{
|
|
473
|
+
type: "object",
|
|
474
|
+
properties: {
|
|
475
|
+
calleeNames: { type: "array", items: { type: "string" } },
|
|
476
|
+
reportNonLiteral: { type: "boolean" }
|
|
477
|
+
},
|
|
478
|
+
additionalProperties: false
|
|
479
|
+
}
|
|
480
|
+
]
|
|
481
|
+
},
|
|
482
|
+
defaultOptions: [{}],
|
|
483
|
+
create(context) {
|
|
484
|
+
const calleeNames = new Set(context.options[0]?.calleeNames ?? ["createContractComponent"]);
|
|
485
|
+
const reportNonLiteral = context.options[0]?.reportNonLiteral ?? false;
|
|
486
|
+
return {
|
|
487
|
+
CallExpression(node) {
|
|
488
|
+
if (!isFactoryCall(node, calleeNames)) return;
|
|
489
|
+
const arg = getFirstObjectArg(node);
|
|
490
|
+
if (!arg) return;
|
|
491
|
+
const stylingProp = getObjectProperty(arg, "styling");
|
|
492
|
+
if (!stylingProp) return;
|
|
493
|
+
const styling = asObjectExpression(stylingProp.value);
|
|
494
|
+
if (!styling) return;
|
|
495
|
+
const variantsProp = getObjectProperty(styling, "variants");
|
|
496
|
+
if (!variantsProp) return;
|
|
497
|
+
const variantMap = extractVariantMap(variantsProp.value);
|
|
498
|
+
if (!variantMap || variantMap.size === 0) return;
|
|
499
|
+
const defaultsProp = getObjectProperty(styling, "defaults");
|
|
500
|
+
if (!defaultsProp) return;
|
|
501
|
+
const defaults = asObjectExpression(defaultsProp.value);
|
|
502
|
+
if (!defaults) return;
|
|
503
|
+
for (const prop of defaults.properties) {
|
|
504
|
+
if (prop.type !== "Property") continue;
|
|
505
|
+
const key = getPropertyKey(prop);
|
|
506
|
+
if (!key) continue;
|
|
507
|
+
if (!variantMap.has(key)) {
|
|
508
|
+
context.report({ node: prop, messageId: "unknownDefaultKey", data: { key } });
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const value = asStringLiteral(prop.value);
|
|
512
|
+
if (value === void 0) {
|
|
513
|
+
if (reportNonLiteral) {
|
|
514
|
+
context.report({ node: prop, messageId: "nonLiteralValue", data: { key } });
|
|
515
|
+
}
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
const allowed = variantMap.get(key);
|
|
519
|
+
if (!allowed.has(value)) {
|
|
520
|
+
context.report({
|
|
521
|
+
node: prop,
|
|
522
|
+
messageId: "unknownDefaultValue",
|
|
523
|
+
data: { key, value, allowed: [...allowed].map((v) => `"${v}"`).join(", ") }
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
// ../eslint-plugin/src/rules/no-invalid-html-nesting.ts
|
|
533
|
+
var import_eslint_utils4 = __toESM(require_eslint_utils(), 1);
|
|
534
|
+
|
|
535
|
+
// ../eslint-plugin/src/utils/html-nesting.ts
|
|
536
|
+
var TAG_CATEGORIES = {
|
|
537
|
+
// Phrasing + flow
|
|
538
|
+
abbr: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
539
|
+
audio: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
540
|
+
b: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
541
|
+
bdi: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
542
|
+
bdo: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
543
|
+
br: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
544
|
+
button: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
545
|
+
canvas: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
546
|
+
cite: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
547
|
+
code: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
548
|
+
data: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
549
|
+
dfn: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
550
|
+
em: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
551
|
+
embed: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded", "interactive"]),
|
|
552
|
+
i: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
553
|
+
iframe: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded", "interactive"]),
|
|
554
|
+
img: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
555
|
+
input: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
556
|
+
kbd: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
557
|
+
label: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
558
|
+
mark: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
559
|
+
math: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
560
|
+
meta: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
561
|
+
noscript: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
562
|
+
object: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
563
|
+
output: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
564
|
+
picture: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
565
|
+
q: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
566
|
+
ruby: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
567
|
+
s: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
568
|
+
samp: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
569
|
+
script: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
570
|
+
select: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
571
|
+
small: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
572
|
+
span: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
573
|
+
strong: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
574
|
+
sub: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
575
|
+
sup: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
576
|
+
svg: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
577
|
+
template: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
578
|
+
textarea: /* @__PURE__ */ new Set(["flow", "phrasing", "interactive"]),
|
|
579
|
+
time: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
580
|
+
u: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
581
|
+
var: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
582
|
+
video: /* @__PURE__ */ new Set(["flow", "phrasing", "embedded"]),
|
|
583
|
+
wbr: /* @__PURE__ */ new Set(["flow", "phrasing"]),
|
|
584
|
+
// Flow only (block-level)
|
|
585
|
+
address: /* @__PURE__ */ new Set(["flow"]),
|
|
586
|
+
article: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
587
|
+
aside: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
588
|
+
blockquote: /* @__PURE__ */ new Set(["flow"]),
|
|
589
|
+
details: /* @__PURE__ */ new Set(["flow", "interactive"]),
|
|
590
|
+
dialog: /* @__PURE__ */ new Set(["flow"]),
|
|
591
|
+
div: /* @__PURE__ */ new Set(["flow"]),
|
|
592
|
+
dl: /* @__PURE__ */ new Set(["flow"]),
|
|
593
|
+
fieldset: /* @__PURE__ */ new Set(["flow"]),
|
|
594
|
+
figure: /* @__PURE__ */ new Set(["flow"]),
|
|
595
|
+
footer: /* @__PURE__ */ new Set(["flow"]),
|
|
596
|
+
form: /* @__PURE__ */ new Set(["flow"]),
|
|
597
|
+
header: /* @__PURE__ */ new Set(["flow"]),
|
|
598
|
+
hr: /* @__PURE__ */ new Set(["flow"]),
|
|
599
|
+
li: /* @__PURE__ */ new Set(["flow"]),
|
|
600
|
+
link: /* @__PURE__ */ new Set(["metadata", "flow", "phrasing"]),
|
|
601
|
+
main: /* @__PURE__ */ new Set(["flow"]),
|
|
602
|
+
menu: /* @__PURE__ */ new Set(["flow"]),
|
|
603
|
+
nav: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
604
|
+
ol: /* @__PURE__ */ new Set(["flow"]),
|
|
605
|
+
p: /* @__PURE__ */ new Set(["flow"]),
|
|
606
|
+
pre: /* @__PURE__ */ new Set(["flow"]),
|
|
607
|
+
section: /* @__PURE__ */ new Set(["flow", "sectioning"]),
|
|
608
|
+
style: /* @__PURE__ */ new Set(["metadata", "flow"]),
|
|
609
|
+
summary: /* @__PURE__ */ new Set(["flow"]),
|
|
610
|
+
table: /* @__PURE__ */ new Set(["flow"]),
|
|
611
|
+
ul: /* @__PURE__ */ new Set(["flow"]),
|
|
612
|
+
// Heading
|
|
613
|
+
h1: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
614
|
+
h2: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
615
|
+
h3: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
616
|
+
h4: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
617
|
+
h5: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
618
|
+
h6: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
619
|
+
hgroup: /* @__PURE__ */ new Set(["flow", "heading"]),
|
|
620
|
+
// Metadata only
|
|
621
|
+
base: /* @__PURE__ */ new Set(["metadata"]),
|
|
622
|
+
title: /* @__PURE__ */ new Set(["metadata"])
|
|
623
|
+
};
|
|
624
|
+
var HTML_CONTENT_MODELS = {
|
|
625
|
+
// Specific-tag constraints (structural elements whose content is enumerated, not categorical)
|
|
626
|
+
colgroup: { kind: "specific", allowed: /* @__PURE__ */ new Set(["col", "template"]) },
|
|
627
|
+
dl: { kind: "specific", allowed: /* @__PURE__ */ new Set(["dt", "dd", "div", "script", "template"]) },
|
|
628
|
+
menu: { kind: "specific", allowed: /* @__PURE__ */ new Set(["li", "script", "template"]) },
|
|
629
|
+
ol: { kind: "specific", allowed: /* @__PURE__ */ new Set(["li", "script", "template"]) },
|
|
630
|
+
optgroup: { kind: "specific", allowed: /* @__PURE__ */ new Set(["option", "script", "template"]) },
|
|
631
|
+
picture: { kind: "specific", allowed: /* @__PURE__ */ new Set(["source", "img", "script", "template"]) },
|
|
632
|
+
select: {
|
|
633
|
+
kind: "specific",
|
|
634
|
+
allowed: /* @__PURE__ */ new Set(["option", "optgroup", "hr", "script", "template"])
|
|
635
|
+
},
|
|
636
|
+
table: {
|
|
637
|
+
kind: "specific",
|
|
638
|
+
allowed: /* @__PURE__ */ new Set([
|
|
639
|
+
"caption",
|
|
640
|
+
"colgroup",
|
|
641
|
+
"thead",
|
|
642
|
+
"tbody",
|
|
643
|
+
"tfoot",
|
|
644
|
+
"tr",
|
|
645
|
+
"script",
|
|
646
|
+
"template"
|
|
647
|
+
])
|
|
648
|
+
},
|
|
649
|
+
tbody: { kind: "specific", allowed: /* @__PURE__ */ new Set(["tr", "script", "template"]) },
|
|
650
|
+
tfoot: { kind: "specific", allowed: /* @__PURE__ */ new Set(["tr", "script", "template"]) },
|
|
651
|
+
thead: { kind: "specific", allowed: /* @__PURE__ */ new Set(["tr", "script", "template"]) },
|
|
652
|
+
tr: { kind: "specific", allowed: /* @__PURE__ */ new Set(["td", "th", "script", "template"]) },
|
|
653
|
+
ul: { kind: "specific", allowed: /* @__PURE__ */ new Set(["li", "script", "template"]) },
|
|
654
|
+
// Phrasing-content parents (any element whose content model is phrasing content)
|
|
655
|
+
abbr: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
656
|
+
b: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
657
|
+
bdi: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
658
|
+
bdo: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
659
|
+
cite: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
660
|
+
code: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
661
|
+
data: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
662
|
+
dfn: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
663
|
+
dt: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
664
|
+
em: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
665
|
+
h1: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
666
|
+
h2: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
667
|
+
h3: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
668
|
+
h4: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
669
|
+
h5: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
670
|
+
h6: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
671
|
+
i: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
672
|
+
kbd: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
673
|
+
label: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
674
|
+
mark: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
675
|
+
output: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
676
|
+
p: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
677
|
+
q: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
678
|
+
ruby: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
679
|
+
s: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
680
|
+
samp: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
681
|
+
small: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
682
|
+
span: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
683
|
+
strong: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
684
|
+
sub: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
685
|
+
sup: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
686
|
+
time: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
687
|
+
u: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
688
|
+
var: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing"]) },
|
|
689
|
+
// Phrasing or heading (spec allows either as first child)
|
|
690
|
+
legend: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing", "heading"]) },
|
|
691
|
+
summary: { kind: "category", allowed: /* @__PURE__ */ new Set(["phrasing", "heading"]) }
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
// ../eslint-plugin/src/rules/no-invalid-html-nesting.ts
|
|
695
|
+
var createRule4 = (0, import_eslint_utils4.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
696
|
+
var ALLOWED_TEXT = Object.fromEntries(
|
|
697
|
+
Object.entries(HTML_CONTENT_MODELS).map(([tag, model]) => [
|
|
698
|
+
tag,
|
|
699
|
+
model.kind === "specific" ? [...model.allowed].join(", ") : [...model.allowed].map((c) => `${c} content`).join(", ")
|
|
700
|
+
])
|
|
701
|
+
);
|
|
702
|
+
function getIntrinsicTag(name) {
|
|
703
|
+
if (name.type !== "JSXIdentifier") return void 0;
|
|
704
|
+
return /^[a-z]/.test(name.name) ? name.name : void 0;
|
|
705
|
+
}
|
|
706
|
+
function isAllowed(childTag, model) {
|
|
707
|
+
if (model.kind === "specific") return model.allowed.has(childTag);
|
|
708
|
+
const cats = TAG_CATEGORIES[childTag];
|
|
709
|
+
if (!cats) return true;
|
|
710
|
+
return [...model.allowed].some((c) => cats.has(c));
|
|
711
|
+
}
|
|
712
|
+
var noInvalidHtmlNesting = createRule4({
|
|
713
|
+
name: "no-invalid-html-nesting",
|
|
714
|
+
meta: {
|
|
715
|
+
type: "problem",
|
|
716
|
+
docs: {
|
|
717
|
+
description: "Disallow HTML children that violate the HTML5 content model for their parent element."
|
|
718
|
+
},
|
|
719
|
+
messages: {
|
|
720
|
+
invalidChild: "<{{ child }}> is not a valid direct child of <{{ parent }}>. Allowed: {{ allowed }}."
|
|
721
|
+
},
|
|
722
|
+
schema: []
|
|
723
|
+
},
|
|
724
|
+
defaultOptions: [],
|
|
725
|
+
create(context) {
|
|
726
|
+
return {
|
|
727
|
+
JSXElement(node) {
|
|
728
|
+
const parentTag = getIntrinsicTag(node.openingElement.name);
|
|
729
|
+
if (!parentTag) return;
|
|
730
|
+
const model = HTML_CONTENT_MODELS[parentTag];
|
|
731
|
+
if (!model) return;
|
|
732
|
+
for (const child of node.children) {
|
|
733
|
+
if (child.type !== "JSXElement") continue;
|
|
734
|
+
const childTag = getIntrinsicTag(child.openingElement.name);
|
|
735
|
+
if (childTag === void 0) continue;
|
|
736
|
+
if (isAllowed(childTag, model)) continue;
|
|
737
|
+
context.report({
|
|
738
|
+
node: child,
|
|
739
|
+
messageId: "invalidChild",
|
|
740
|
+
data: {
|
|
741
|
+
child: childTag,
|
|
742
|
+
parent: parentTag,
|
|
743
|
+
allowed: ALLOWED_TEXT[parentTag] ?? ""
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
// ../eslint-plugin/src/rules/no-redundant-role.ts
|
|
753
|
+
var import_eslint_utils5 = __toESM(require_eslint_utils(), 1);
|
|
754
|
+
|
|
755
|
+
// ../eslint-plugin/src/utils/implicit-roles.ts
|
|
756
|
+
var IMPLICIT_ROLES = {
|
|
757
|
+
article: "article",
|
|
758
|
+
aside: "complementary",
|
|
759
|
+
button: "button",
|
|
760
|
+
datalist: "listbox",
|
|
761
|
+
details: "group",
|
|
762
|
+
dialog: "dialog",
|
|
763
|
+
figure: "figure",
|
|
764
|
+
form: "form",
|
|
765
|
+
h1: "heading",
|
|
766
|
+
h2: "heading",
|
|
767
|
+
h3: "heading",
|
|
768
|
+
h4: "heading",
|
|
769
|
+
h5: "heading",
|
|
770
|
+
h6: "heading",
|
|
771
|
+
hr: "separator",
|
|
772
|
+
img: "img",
|
|
773
|
+
li: "listitem",
|
|
774
|
+
main: "main",
|
|
775
|
+
math: "math",
|
|
776
|
+
menu: "list",
|
|
777
|
+
meter: "meter",
|
|
778
|
+
nav: "navigation",
|
|
779
|
+
ol: "list",
|
|
780
|
+
option: "option",
|
|
781
|
+
output: "status",
|
|
782
|
+
progress: "progressbar",
|
|
783
|
+
search: "search",
|
|
784
|
+
section: "region",
|
|
785
|
+
select: "listbox",
|
|
786
|
+
summary: "button",
|
|
787
|
+
table: "table",
|
|
788
|
+
tbody: "rowgroup",
|
|
789
|
+
td: "cell",
|
|
790
|
+
textarea: "textbox",
|
|
791
|
+
tfoot: "rowgroup",
|
|
792
|
+
th: "columnheader",
|
|
793
|
+
thead: "rowgroup",
|
|
794
|
+
tr: "row",
|
|
795
|
+
ul: "list"
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// ../eslint-plugin/src/rules/no-redundant-role.ts
|
|
799
|
+
var createRule5 = (0, import_eslint_utils5.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
800
|
+
function getJsxTagName(node) {
|
|
801
|
+
const name = node.name;
|
|
802
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
803
|
+
return void 0;
|
|
804
|
+
}
|
|
805
|
+
function getJsxStringAttribute(node, attrName) {
|
|
806
|
+
for (const attr of node.attributes) {
|
|
807
|
+
if (attr.type !== "JSXAttribute") continue;
|
|
808
|
+
const key = attr.name;
|
|
809
|
+
if (key.type !== "JSXIdentifier" || key.name !== attrName) continue;
|
|
810
|
+
const val = attr.value;
|
|
811
|
+
if (val === null) continue;
|
|
812
|
+
if (val.type === "Literal" && typeof val.value === "string") {
|
|
813
|
+
return { node: attr, value: val.value };
|
|
814
|
+
}
|
|
815
|
+
if (val.type === "JSXExpressionContainer" && val.expression.type === "Literal" && typeof val.expression.value === "string") {
|
|
816
|
+
return { node: attr, value: val.expression.value };
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return void 0;
|
|
820
|
+
}
|
|
821
|
+
var noRedundantRole = createRule5({
|
|
822
|
+
name: "no-redundant-role",
|
|
823
|
+
meta: {
|
|
824
|
+
type: "suggestion",
|
|
825
|
+
docs: {
|
|
826
|
+
description: "Disallow role attributes that duplicate the implicit ARIA role of the HTML element."
|
|
827
|
+
},
|
|
828
|
+
fixable: "code",
|
|
829
|
+
messages: {
|
|
830
|
+
redundantRole: 'role="{{ role }}" is redundant on <{{ tag }}>: the element already carries this implicit ARIA role. Remove the attribute.'
|
|
831
|
+
},
|
|
832
|
+
schema: []
|
|
833
|
+
},
|
|
834
|
+
defaultOptions: [],
|
|
835
|
+
create(context) {
|
|
836
|
+
return {
|
|
837
|
+
JSXOpeningElement(node) {
|
|
838
|
+
const tag = getJsxTagName(node);
|
|
839
|
+
if (!tag) return;
|
|
840
|
+
const implicitRole = IMPLICIT_ROLES[tag];
|
|
841
|
+
if (!implicitRole) return;
|
|
842
|
+
const roleAttr = getJsxStringAttribute(node, "role");
|
|
843
|
+
if (!roleAttr) return;
|
|
844
|
+
if (roleAttr.value === implicitRole) {
|
|
845
|
+
context.report({
|
|
846
|
+
node: roleAttr.node,
|
|
847
|
+
messageId: "redundantRole",
|
|
848
|
+
data: { role: roleAttr.value, tag },
|
|
849
|
+
fix(fixer) {
|
|
850
|
+
return fixer.remove(roleAttr.node);
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
// ../eslint-plugin/src/rules/valid-cardinality.ts
|
|
860
|
+
var import_eslint_utils6 = __toESM(require_eslint_utils(), 1);
|
|
861
|
+
var createRule6 = (0, import_eslint_utils6.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
862
|
+
var validCardinality = createRule6({
|
|
863
|
+
name: "valid-cardinality",
|
|
864
|
+
meta: {
|
|
865
|
+
type: "problem",
|
|
866
|
+
docs: {
|
|
867
|
+
description: "Enforce valid min/max values in enforcement.children cardinality rules."
|
|
868
|
+
},
|
|
869
|
+
messages: {
|
|
870
|
+
negativeMin: "cardinality.min must be >= 0 (got {{ value }}).",
|
|
871
|
+
negativeMax: "cardinality.max must be >= 0 (got {{ value }}).",
|
|
872
|
+
maxLessThanMin: "cardinality.max ({{ max }}) must be >= cardinality.min ({{ min }}). This rule can never be satisfied.",
|
|
873
|
+
zeroMax: "cardinality.max of 0 means no children of this type are allowed. Use 0 intentionally or remove the rule."
|
|
874
|
+
},
|
|
875
|
+
schema: [
|
|
876
|
+
{
|
|
877
|
+
type: "object",
|
|
878
|
+
properties: {
|
|
879
|
+
calleeNames: { type: "array", items: { type: "string" } }
|
|
880
|
+
},
|
|
881
|
+
additionalProperties: false
|
|
882
|
+
}
|
|
883
|
+
]
|
|
884
|
+
},
|
|
885
|
+
defaultOptions: [{}],
|
|
886
|
+
create(context) {
|
|
887
|
+
const calleeNames = new Set(context.options[0]?.calleeNames ?? ["createContractComponent"]);
|
|
888
|
+
return {
|
|
889
|
+
CallExpression(node) {
|
|
890
|
+
if (!isFactoryCall(node, calleeNames)) return;
|
|
891
|
+
const arg = getFirstObjectArg(node);
|
|
892
|
+
if (!arg) return;
|
|
893
|
+
const enfProp = getObjectProperty(arg, "enforcement");
|
|
894
|
+
if (!enfProp) return;
|
|
895
|
+
const enf = asObjectExpression(enfProp.value);
|
|
896
|
+
if (!enf) return;
|
|
897
|
+
const childrenProp = getObjectProperty(enf, "children");
|
|
898
|
+
if (!childrenProp) return;
|
|
899
|
+
const arr = asArrayExpression(childrenProp.value);
|
|
900
|
+
if (!arr) return;
|
|
901
|
+
for (const element of arr.elements) {
|
|
902
|
+
if (!element || element.type !== "ObjectExpression") continue;
|
|
903
|
+
const cardProp = getObjectProperty(element, "cardinality");
|
|
904
|
+
if (!cardProp) continue;
|
|
905
|
+
const card = asObjectExpression(cardProp.value);
|
|
906
|
+
if (!card) continue;
|
|
907
|
+
const minProp = getObjectProperty(card, "min");
|
|
908
|
+
const maxProp = getObjectProperty(card, "max");
|
|
909
|
+
const min = minProp ? asNumericLiteral(minProp.value) : void 0;
|
|
910
|
+
const max = maxProp ? asNumericLiteral(maxProp.value) : void 0;
|
|
911
|
+
if (min !== void 0 && min < 0) {
|
|
912
|
+
context.report({
|
|
913
|
+
node: minProp,
|
|
914
|
+
messageId: "negativeMin",
|
|
915
|
+
data: { value: String(min) }
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (max !== void 0 && max < 0) {
|
|
919
|
+
context.report({
|
|
920
|
+
node: maxProp,
|
|
921
|
+
messageId: "negativeMax",
|
|
922
|
+
data: { value: String(max) }
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
if (max !== void 0 && max === 0) {
|
|
926
|
+
context.report({ node: maxProp, messageId: "zeroMax" });
|
|
927
|
+
}
|
|
928
|
+
if (min !== void 0 && max !== void 0 && min >= 0 && max > 0 && max < min) {
|
|
929
|
+
context.report({
|
|
930
|
+
node: cardProp,
|
|
931
|
+
messageId: "maxLessThanMin",
|
|
932
|
+
data: { min: String(min), max: String(max) }
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
// ../eslint-plugin/src/rules/valid-children-config.ts
|
|
942
|
+
var import_eslint_utils7 = __toESM(require_eslint_utils(), 1);
|
|
943
|
+
var createRule7 = (0, import_eslint_utils7.RuleCreator)((name) => `https://praxis-kit.dev/eslint-rules/${name}`);
|
|
944
|
+
var validChildrenConfig = createRule7({
|
|
945
|
+
name: "valid-children-config",
|
|
946
|
+
meta: {
|
|
947
|
+
type: "problem",
|
|
948
|
+
docs: {
|
|
949
|
+
description: "Enforce cross-rule consistency of enforcement.children \u2014 detect positional conflicts and cardinality impossibilities."
|
|
950
|
+
},
|
|
951
|
+
messages: {
|
|
952
|
+
multipleFirst: 'Multiple enforcement.children rules require position: "first". Only one child can occupy the first position.',
|
|
953
|
+
multipleLast: 'Multiple enforcement.children rules require position: "last". Only one child can occupy the last position.',
|
|
954
|
+
minSumExceedsCapacity: 'A rule with position: "only" requires min >= 1, but {{ count }} other rule(s) also require min >= 1. These constraints cannot be satisfied simultaneously.'
|
|
955
|
+
},
|
|
956
|
+
schema: [
|
|
957
|
+
{
|
|
958
|
+
type: "object",
|
|
959
|
+
properties: {
|
|
960
|
+
calleeNames: { type: "array", items: { type: "string" } }
|
|
961
|
+
},
|
|
962
|
+
additionalProperties: false
|
|
963
|
+
}
|
|
964
|
+
]
|
|
965
|
+
},
|
|
966
|
+
defaultOptions: [{}],
|
|
967
|
+
create(context) {
|
|
968
|
+
const calleeNames = new Set(context.options[0]?.calleeNames ?? ["createContractComponent"]);
|
|
969
|
+
return {
|
|
970
|
+
CallExpression(node) {
|
|
971
|
+
if (!isFactoryCall(node, calleeNames)) return;
|
|
972
|
+
const arg = getFirstObjectArg(node);
|
|
973
|
+
if (!arg) return;
|
|
974
|
+
const enfProp = getObjectProperty(arg, "enforcement");
|
|
975
|
+
if (!enfProp) return;
|
|
976
|
+
const enf = asObjectExpression(enfProp.value);
|
|
977
|
+
if (!enf) return;
|
|
978
|
+
const childrenProp = getObjectProperty(enf, "children");
|
|
979
|
+
if (!childrenProp) return;
|
|
980
|
+
const arr = asArrayExpression(childrenProp.value);
|
|
981
|
+
if (!arr) return;
|
|
982
|
+
const firstPositionProps = [];
|
|
983
|
+
const lastPositionProps = [];
|
|
984
|
+
let onlyWithMinProp = null;
|
|
985
|
+
let rulesWithMinCount = 0;
|
|
986
|
+
for (const element of arr.elements) {
|
|
987
|
+
if (!element || element.type !== "ObjectExpression") continue;
|
|
988
|
+
const positionProp = getObjectProperty(element, "position");
|
|
989
|
+
const position = positionProp ? asStringLiteral(positionProp.value) : void 0;
|
|
990
|
+
const cardProp = getObjectProperty(element, "cardinality");
|
|
991
|
+
const card = cardProp ? asObjectExpression(cardProp.value) : void 0;
|
|
992
|
+
const minProp = card ? getObjectProperty(card, "min") : void 0;
|
|
993
|
+
const min = minProp ? asNumericLiteral(minProp.value) ?? 0 : 0;
|
|
994
|
+
if (position === "first" && positionProp) {
|
|
995
|
+
firstPositionProps.push(positionProp);
|
|
996
|
+
}
|
|
997
|
+
if (position === "last" && positionProp) {
|
|
998
|
+
lastPositionProps.push(positionProp);
|
|
999
|
+
}
|
|
1000
|
+
if (min >= 1) {
|
|
1001
|
+
rulesWithMinCount++;
|
|
1002
|
+
if (position === "only" && positionProp && !onlyWithMinProp) {
|
|
1003
|
+
onlyWithMinProp = positionProp;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
for (const prop of firstPositionProps.slice(1)) {
|
|
1008
|
+
context.report({ node: prop, messageId: "multipleFirst" });
|
|
1009
|
+
}
|
|
1010
|
+
for (const prop of lastPositionProps.slice(1)) {
|
|
1011
|
+
context.report({ node: prop, messageId: "multipleLast" });
|
|
1012
|
+
}
|
|
1013
|
+
if (onlyWithMinProp && rulesWithMinCount > 1) {
|
|
1014
|
+
context.report({
|
|
1015
|
+
node: onlyWithMinProp,
|
|
1016
|
+
messageId: "minSumExceedsCapacity",
|
|
1017
|
+
data: { count: String(rulesWithMinCount - 1) }
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
// ../eslint-plugin/src/index.ts
|
|
1026
|
+
var plugin = {
|
|
1027
|
+
meta: {
|
|
1028
|
+
name: "@praxis-kit/eslint-plugin",
|
|
1029
|
+
version: "1.0.0"
|
|
1030
|
+
},
|
|
1031
|
+
rules: {
|
|
1032
|
+
"no-dead-compound": noDeadCompound,
|
|
1033
|
+
"no-enforcement-without-strict": noEnforcementWithoutStrict,
|
|
1034
|
+
"no-invalid-default": noInvalidDefault,
|
|
1035
|
+
"no-invalid-html-nesting": noInvalidHtmlNesting,
|
|
1036
|
+
"no-redundant-role": noRedundantRole,
|
|
1037
|
+
"valid-cardinality": validCardinality,
|
|
1038
|
+
"valid-children-config": validChildrenConfig
|
|
1039
|
+
},
|
|
1040
|
+
configs: {}
|
|
1041
|
+
};
|
|
1042
|
+
var recommended = {
|
|
1043
|
+
name: "@praxis-kit/recommended",
|
|
1044
|
+
plugins: { "@praxis-kit": plugin },
|
|
1045
|
+
rules: {
|
|
1046
|
+
"@praxis-kit/no-dead-compound": "error",
|
|
1047
|
+
"@praxis-kit/no-enforcement-without-strict": "error",
|
|
1048
|
+
"@praxis-kit/no-invalid-default": "error",
|
|
1049
|
+
"@praxis-kit/no-invalid-html-nesting": "error",
|
|
1050
|
+
"@praxis-kit/no-redundant-role": "warn",
|
|
1051
|
+
"@praxis-kit/valid-cardinality": "error",
|
|
1052
|
+
"@praxis-kit/valid-children-config": "error"
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
plugin.configs["recommended"] = recommended;
|
|
1056
|
+
var src_default = plugin;
|
|
1057
|
+
export {
|
|
1058
|
+
src_default as default,
|
|
1059
|
+
noDeadCompound,
|
|
1060
|
+
noEnforcementWithoutStrict,
|
|
1061
|
+
noInvalidDefault,
|
|
1062
|
+
noInvalidHtmlNesting,
|
|
1063
|
+
noRedundantRole,
|
|
1064
|
+
plugin,
|
|
1065
|
+
recommended,
|
|
1066
|
+
validCardinality,
|
|
1067
|
+
validChildrenConfig
|
|
1068
|
+
};
|