@vue-jsx-vapor/eslint 3.2.11 → 3.2.13
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/index.cjs +150 -162
- package/dist/index.d.cts +8 -2674
- package/dist/index.d.ts +8 -2674
- package/dist/index.js +137 -147
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import prettier from "@prettier/sync";
|
|
2
|
-
|
|
3
2
|
//#region src/rules/define-style/index.ts
|
|
4
3
|
const rule$1 = {
|
|
5
4
|
defaultOptions: [{ tabWidth: 2 }],
|
|
@@ -29,7 +28,7 @@ const rule$1 = {
|
|
|
29
28
|
if (arg?.type === "TemplateLiteral") {
|
|
30
29
|
let index = 0;
|
|
31
30
|
const cssRaw = context.sourceCode.text.slice(arg.range[0] + 1, arg.range[1] - 1);
|
|
32
|
-
let formattedCss
|
|
31
|
+
let formattedCss;
|
|
33
32
|
try {
|
|
34
33
|
formattedCss = prettier.format(arg.quasis.map((i) => i.value.raw + (arg.expressions[index] ? `-MACROS_START-${context.sourceCode.text.slice(...arg.expressions[index++].range)}-MACROS_END-` : "")).join(""), {
|
|
35
34
|
parser,
|
|
@@ -61,8 +60,6 @@ const rule$1 = {
|
|
|
61
60
|
} };
|
|
62
61
|
}
|
|
63
62
|
};
|
|
64
|
-
var define_style_default = rule$1;
|
|
65
|
-
|
|
66
63
|
//#endregion
|
|
67
64
|
//#region src/rules/jsx-sort-props/index.ts
|
|
68
65
|
const COMPAT_TAG_REGEX = /^[a-z]/;
|
|
@@ -346,159 +343,154 @@ function reportNodeAttribute(nodeAttribute, errorType, node, context, reservedLi
|
|
|
346
343
|
fix: generateFixerFunction(node, context, reservedList)
|
|
347
344
|
});
|
|
348
345
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
type: "
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
"
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
type: "
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}]
|
|
385
|
-
},
|
|
386
|
-
create(context) {
|
|
387
|
-
const configuration = context.options[0] || {};
|
|
388
|
-
const ignoreCase = configuration.ignoreCase || false;
|
|
389
|
-
const callbacksLast = configuration.callbacksLast || false;
|
|
390
|
-
const shorthandFirst = configuration.shorthandFirst || false;
|
|
391
|
-
const shorthandLast = configuration.shorthandLast || false;
|
|
392
|
-
const multiline = configuration.multiline || "ignore";
|
|
393
|
-
const noSortAlphabetically = configuration.noSortAlphabetically || false;
|
|
394
|
-
const reservedFirst = configuration.reservedFirst || false;
|
|
395
|
-
const reservedFirstError = validateReservedFirstConfig(context, reservedFirst);
|
|
396
|
-
const reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST;
|
|
397
|
-
const reservedLastList = configuration.reservedLast || [];
|
|
398
|
-
const locale = configuration.locale || "auto";
|
|
399
|
-
return {
|
|
400
|
-
Program() {
|
|
401
|
-
attributeMap = /* @__PURE__ */ new WeakMap();
|
|
402
|
-
},
|
|
403
|
-
JSXOpeningElement(node) {
|
|
404
|
-
const nodeReservedList = reservedFirst && !isDOMComponent(node) ? reservedList.filter((prop) => prop !== "dangerouslySetInnerHTML") : reservedList;
|
|
405
|
-
node.attributes.reduce((memo, decl, idx, attrs) => {
|
|
406
|
-
if (decl.type === "JSXSpreadAttribute") return attrs[idx + 1];
|
|
407
|
-
let previousPropName = getPropName(memo);
|
|
408
|
-
let currentPropName = getPropName(decl);
|
|
409
|
-
const previousReservedNamespace = previousPropName.split(":")[0];
|
|
410
|
-
const currentReservedNamespace = currentPropName.split(":")[0];
|
|
411
|
-
const previousValue = memo.value;
|
|
412
|
-
const currentValue = decl.value;
|
|
413
|
-
const previousIsCallback = isCallbackPropName(previousPropName);
|
|
414
|
-
const currentIsCallback = isCallbackPropName(currentPropName);
|
|
415
|
-
if (ignoreCase) {
|
|
416
|
-
previousPropName = previousPropName.toLowerCase();
|
|
417
|
-
currentPropName = currentPropName.toLowerCase();
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/rules/index.ts
|
|
348
|
+
const ruleOptions = {
|
|
349
|
+
"jsx-sort-props": {
|
|
350
|
+
defaultOptions: [{
|
|
351
|
+
multiline: "ignore",
|
|
352
|
+
locale: "auto"
|
|
353
|
+
}],
|
|
354
|
+
meta: {
|
|
355
|
+
type: "layout",
|
|
356
|
+
docs: { description: "Enforce props alphabetical sorting" },
|
|
357
|
+
fixable: "code",
|
|
358
|
+
messages,
|
|
359
|
+
schema: [{
|
|
360
|
+
type: "object",
|
|
361
|
+
properties: {
|
|
362
|
+
callbacksLast: { type: "boolean" },
|
|
363
|
+
shorthandFirst: { type: "boolean" },
|
|
364
|
+
shorthandLast: { type: "boolean" },
|
|
365
|
+
multiline: {
|
|
366
|
+
type: "string",
|
|
367
|
+
enum: [
|
|
368
|
+
"ignore",
|
|
369
|
+
"first",
|
|
370
|
+
"last"
|
|
371
|
+
],
|
|
372
|
+
default: "ignore"
|
|
373
|
+
},
|
|
374
|
+
ignoreCase: { type: "boolean" },
|
|
375
|
+
noSortAlphabetically: { type: "boolean" },
|
|
376
|
+
reservedFirst: { type: ["array", "boolean"] },
|
|
377
|
+
reservedLast: { type: "array" },
|
|
378
|
+
locale: {
|
|
379
|
+
type: "string",
|
|
380
|
+
default: "auto"
|
|
418
381
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
382
|
+
},
|
|
383
|
+
additionalProperties: false
|
|
384
|
+
}]
|
|
385
|
+
},
|
|
386
|
+
create(context) {
|
|
387
|
+
const configuration = context.options[0] || {};
|
|
388
|
+
const ignoreCase = configuration.ignoreCase || false;
|
|
389
|
+
const callbacksLast = configuration.callbacksLast || false;
|
|
390
|
+
const shorthandFirst = configuration.shorthandFirst || false;
|
|
391
|
+
const shorthandLast = configuration.shorthandLast || false;
|
|
392
|
+
const multiline = configuration.multiline || "ignore";
|
|
393
|
+
const noSortAlphabetically = configuration.noSortAlphabetically || false;
|
|
394
|
+
const reservedFirst = configuration.reservedFirst || false;
|
|
395
|
+
const reservedFirstError = validateReservedFirstConfig(context, reservedFirst);
|
|
396
|
+
const reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST;
|
|
397
|
+
const reservedLastList = configuration.reservedLast || [];
|
|
398
|
+
const locale = configuration.locale || "auto";
|
|
399
|
+
return {
|
|
400
|
+
Program() {
|
|
401
|
+
attributeMap = /* @__PURE__ */ new WeakMap();
|
|
402
|
+
},
|
|
403
|
+
JSXOpeningElement(node) {
|
|
404
|
+
const nodeReservedList = reservedFirst && !isDOMComponent(node) ? reservedList.filter((prop) => prop !== "dangerouslySetInnerHTML") : reservedList;
|
|
405
|
+
node.attributes.reduce((memo, decl, idx, attrs) => {
|
|
406
|
+
if (decl.type === "JSXSpreadAttribute") return attrs[idx + 1];
|
|
407
|
+
let previousPropName = getPropName(memo);
|
|
408
|
+
let currentPropName = getPropName(decl);
|
|
409
|
+
const previousReservedNamespace = previousPropName.split(":")[0];
|
|
410
|
+
const currentReservedNamespace = currentPropName.split(":")[0];
|
|
411
|
+
const previousValue = memo.value;
|
|
412
|
+
const currentValue = decl.value;
|
|
413
|
+
const previousIsCallback = isCallbackPropName(previousPropName);
|
|
414
|
+
const currentIsCallback = isCallbackPropName(currentPropName);
|
|
415
|
+
if (ignoreCase) {
|
|
416
|
+
previousPropName = previousPropName.toLowerCase();
|
|
417
|
+
currentPropName = currentPropName.toLowerCase();
|
|
423
418
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
419
|
+
if (reservedFirst) {
|
|
420
|
+
if (reservedFirstError) {
|
|
421
|
+
reservedFirstError(decl);
|
|
422
|
+
return memo;
|
|
423
|
+
}
|
|
424
|
+
const previousReservedIndex = getReservedPropIndex(previousPropName, nodeReservedList);
|
|
425
|
+
const currentReservedIndex = getReservedPropIndex(currentPropName, nodeReservedList);
|
|
426
|
+
if (previousReservedIndex > -1 && currentReservedIndex === -1) return decl;
|
|
427
|
+
if (reservedFirst !== true && previousReservedIndex > currentReservedIndex || previousReservedIndex === -1 && currentReservedIndex > -1) {
|
|
428
|
+
reportNodeAttribute(decl, "listReservedPropsFirst", node, context, nodeReservedList);
|
|
429
|
+
return memo;
|
|
430
|
+
}
|
|
431
|
+
if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
|
|
430
432
|
}
|
|
431
|
-
if (
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return
|
|
433
|
+
if (reservedLastList.length > 0) {
|
|
434
|
+
const previousReservedIndex = getReservedPropIndex(previousPropName, reservedLastList);
|
|
435
|
+
const currentReservedIndex = getReservedPropIndex(currentPropName, reservedLastList);
|
|
436
|
+
if (previousReservedIndex === -1 && currentReservedIndex > -1) return decl;
|
|
437
|
+
if (previousReservedIndex < currentReservedIndex || previousReservedIndex > -1 && currentReservedIndex === -1) {
|
|
438
|
+
reportNodeAttribute(decl, "listReservedPropsLast", node, context, nodeReservedList);
|
|
439
|
+
return memo;
|
|
440
|
+
}
|
|
441
|
+
if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
|
|
440
442
|
}
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
return memo;
|
|
443
|
+
if (callbacksLast) {
|
|
444
|
+
if (!previousIsCallback && currentIsCallback) return decl;
|
|
445
|
+
if (previousIsCallback && !currentIsCallback) {
|
|
446
|
+
reportNodeAttribute(memo, "listCallbacksLast", node, context, nodeReservedList);
|
|
447
|
+
return memo;
|
|
448
|
+
}
|
|
448
449
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
450
|
+
if (shorthandFirst) {
|
|
451
|
+
if (currentValue && !previousValue) return decl;
|
|
452
|
+
if (!currentValue && previousValue) {
|
|
453
|
+
reportNodeAttribute(decl, "listShorthandFirst", node, context, nodeReservedList);
|
|
454
|
+
return memo;
|
|
455
|
+
}
|
|
455
456
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
457
|
+
if (shorthandLast) {
|
|
458
|
+
if (!currentValue && previousValue) return decl;
|
|
459
|
+
if (currentValue && !previousValue) {
|
|
460
|
+
reportNodeAttribute(memo, "listShorthandLast", node, context, nodeReservedList);
|
|
461
|
+
return memo;
|
|
462
|
+
}
|
|
462
463
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
464
|
+
const previousIsMultiline = isMultilineProp(memo);
|
|
465
|
+
const currentIsMultiline = isMultilineProp(decl);
|
|
466
|
+
if (multiline === "first") {
|
|
467
|
+
if (previousIsMultiline && !currentIsMultiline) return decl;
|
|
468
|
+
if (!previousIsMultiline && currentIsMultiline) {
|
|
469
|
+
reportNodeAttribute(decl, "listMultilineFirst", node, context, nodeReservedList);
|
|
470
|
+
return memo;
|
|
471
|
+
}
|
|
472
|
+
} else if (multiline === "last") {
|
|
473
|
+
if (!previousIsMultiline && currentIsMultiline) return decl;
|
|
474
|
+
if (previousIsMultiline && !currentIsMultiline) {
|
|
475
|
+
reportNodeAttribute(memo, "listMultilineLast", node, context, nodeReservedList);
|
|
476
|
+
return memo;
|
|
477
|
+
}
|
|
471
478
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (previousIsMultiline && !currentIsMultiline) {
|
|
475
|
-
reportNodeAttribute(memo, "listMultilineLast", node, context, nodeReservedList);
|
|
479
|
+
if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(currentPropName, locale === "auto" ? void 0 : locale) > 0 : previousPropName > currentPropName)) {
|
|
480
|
+
reportNodeAttribute(decl, "sortPropsByAlpha", node, context, nodeReservedList);
|
|
476
481
|
return memo;
|
|
477
482
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
var jsx_sort_props_default = rule;
|
|
490
|
-
|
|
491
|
-
//#endregion
|
|
492
|
-
//#region src/rules/index.ts
|
|
493
|
-
const ruleOptions = {
|
|
494
|
-
"jsx-sort-props": jsx_sort_props_default,
|
|
495
|
-
"define-style": define_style_default
|
|
483
|
+
return decl;
|
|
484
|
+
}, node.attributes[0]);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
"define-style": rule$1
|
|
496
490
|
};
|
|
497
|
-
var rules_default = ruleOptions;
|
|
498
|
-
|
|
499
491
|
//#endregion
|
|
500
492
|
//#region src/index.ts
|
|
501
|
-
const plugins = { "vue-jsx-vapor": { rules:
|
|
493
|
+
const plugins = { "vue-jsx-vapor": { rules: ruleOptions } };
|
|
502
494
|
const config = ({ rules = {}, ...options } = {}) => ({
|
|
503
495
|
name: "vue-jsx-vapor",
|
|
504
496
|
plugins,
|
|
@@ -528,7 +520,5 @@ const config = ({ rules = {}, ...options } = {}) => ({
|
|
|
528
520
|
},
|
|
529
521
|
...options
|
|
530
522
|
});
|
|
531
|
-
var src_default = config;
|
|
532
|
-
|
|
533
523
|
//#endregion
|
|
534
|
-
export {
|
|
524
|
+
export { config as default, plugins, ruleOptions as rules };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-jsx-vapor/eslint",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.13",
|
|
5
5
|
"description": "Vue JSX Vapor ESLint Plugin",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/vuejs/vue-jsx-vapor#readme",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"jsx-vapor-dev": "./src/index.ts",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.cjs"
|
|
27
27
|
},
|
|
28
28
|
"./*": "./*"
|
|
29
29
|
},
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@prettier/sync": "^0.6.1",
|
|
38
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/utils": "^8.59.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"eslint-vitest-rule-tester": "^3.0
|
|
41
|
+
"eslint-vitest-rule-tester": "^3.1.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsdown",
|