@vue-jsx-vapor/eslint 3.2.12 → 3.2.14

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 CHANGED
@@ -1,7 +1,4 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
5
2
  //#region \0rolldown/runtime.js
6
3
  var __create = Object.create;
7
4
  var __defProp = Object.defineProperty;
@@ -10,12 +7,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
10
7
  var __getProtoOf = Object.getPrototypeOf;
11
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
12
9
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
- key = keys[i];
15
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: ((k) => from[k]).bind(null, key),
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
19
20
  }
20
21
  return to;
21
22
  };
@@ -23,9 +24,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
24
  value: mod,
24
25
  enumerable: true
25
26
  }) : target, mod));
27
+
26
28
  //#endregion
27
29
  let _prettier_sync = require("@prettier/sync");
28
- _prettier_sync = __toESM(_prettier_sync, 1);
30
+ _prettier_sync = __toESM(_prettier_sync);
31
+
29
32
  //#region src/rules/define-style/index.ts
30
33
  const rule$1 = {
31
34
  defaultOptions: [{ tabWidth: 2 }],
@@ -87,6 +90,7 @@ const rule$1 = {
87
90
  } };
88
91
  }
89
92
  };
93
+
90
94
  //#endregion
91
95
  //#region src/rules/jsx-sort-props/index.ts
92
96
  const COMPAT_TAG_REGEX = /^[a-z]/;
@@ -370,151 +374,154 @@ function reportNodeAttribute(nodeAttribute, errorType, node, context, reservedLi
370
374
  fix: generateFixerFunction(node, context, reservedList)
371
375
  });
372
376
  }
373
- //#endregion
374
- //#region src/rules/index.ts
375
- const ruleOptions = {
376
- "jsx-sort-props": {
377
- defaultOptions: [{
378
- multiline: "ignore",
379
- locale: "auto"
380
- }],
381
- meta: {
382
- type: "layout",
383
- docs: { description: "Enforce props alphabetical sorting" },
384
- fixable: "code",
385
- messages,
386
- schema: [{
387
- type: "object",
388
- properties: {
389
- callbacksLast: { type: "boolean" },
390
- shorthandFirst: { type: "boolean" },
391
- shorthandLast: { type: "boolean" },
392
- multiline: {
393
- type: "string",
394
- enum: [
395
- "ignore",
396
- "first",
397
- "last"
398
- ],
399
- default: "ignore"
400
- },
401
- ignoreCase: { type: "boolean" },
402
- noSortAlphabetically: { type: "boolean" },
403
- reservedFirst: { type: ["array", "boolean"] },
404
- reservedLast: { type: "array" },
405
- locale: {
406
- type: "string",
407
- default: "auto"
408
- }
409
- },
410
- additionalProperties: false
411
- }]
412
- },
413
- create(context) {
414
- const configuration = context.options[0] || {};
415
- const ignoreCase = configuration.ignoreCase || false;
416
- const callbacksLast = configuration.callbacksLast || false;
417
- const shorthandFirst = configuration.shorthandFirst || false;
418
- const shorthandLast = configuration.shorthandLast || false;
419
- const multiline = configuration.multiline || "ignore";
420
- const noSortAlphabetically = configuration.noSortAlphabetically || false;
421
- const reservedFirst = configuration.reservedFirst || false;
422
- const reservedFirstError = validateReservedFirstConfig(context, reservedFirst);
423
- const reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST;
424
- const reservedLastList = configuration.reservedLast || [];
425
- const locale = configuration.locale || "auto";
426
- return {
427
- Program() {
428
- attributeMap = /* @__PURE__ */ new WeakMap();
377
+ const rule = {
378
+ defaultOptions: [{
379
+ multiline: "ignore",
380
+ locale: "auto"
381
+ }],
382
+ meta: {
383
+ type: "layout",
384
+ docs: { description: "Enforce props alphabetical sorting" },
385
+ fixable: "code",
386
+ messages,
387
+ schema: [{
388
+ type: "object",
389
+ properties: {
390
+ callbacksLast: { type: "boolean" },
391
+ shorthandFirst: { type: "boolean" },
392
+ shorthandLast: { type: "boolean" },
393
+ multiline: {
394
+ type: "string",
395
+ enum: [
396
+ "ignore",
397
+ "first",
398
+ "last"
399
+ ],
400
+ default: "ignore"
429
401
  },
430
- JSXOpeningElement(node) {
431
- const nodeReservedList = reservedFirst && !isDOMComponent(node) ? reservedList.filter((prop) => prop !== "dangerouslySetInnerHTML") : reservedList;
432
- node.attributes.reduce((memo, decl, idx, attrs) => {
433
- if (decl.type === "JSXSpreadAttribute") return attrs[idx + 1];
434
- let previousPropName = getPropName(memo);
435
- let currentPropName = getPropName(decl);
436
- const previousReservedNamespace = previousPropName.split(":")[0];
437
- const currentReservedNamespace = currentPropName.split(":")[0];
438
- const previousValue = memo.value;
439
- const currentValue = decl.value;
440
- const previousIsCallback = isCallbackPropName(previousPropName);
441
- const currentIsCallback = isCallbackPropName(currentPropName);
442
- if (ignoreCase) {
443
- previousPropName = previousPropName.toLowerCase();
444
- currentPropName = currentPropName.toLowerCase();
402
+ ignoreCase: { type: "boolean" },
403
+ noSortAlphabetically: { type: "boolean" },
404
+ reservedFirst: { type: ["array", "boolean"] },
405
+ reservedLast: { type: "array" },
406
+ locale: {
407
+ type: "string",
408
+ default: "auto"
409
+ }
410
+ },
411
+ additionalProperties: false
412
+ }]
413
+ },
414
+ create(context) {
415
+ const configuration = context.options[0] || {};
416
+ const ignoreCase = configuration.ignoreCase || false;
417
+ const callbacksLast = configuration.callbacksLast || false;
418
+ const shorthandFirst = configuration.shorthandFirst || false;
419
+ const shorthandLast = configuration.shorthandLast || false;
420
+ const multiline = configuration.multiline || "ignore";
421
+ const noSortAlphabetically = configuration.noSortAlphabetically || false;
422
+ const reservedFirst = configuration.reservedFirst || false;
423
+ const reservedFirstError = validateReservedFirstConfig(context, reservedFirst);
424
+ const reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST;
425
+ const reservedLastList = configuration.reservedLast || [];
426
+ const locale = configuration.locale || "auto";
427
+ return {
428
+ Program() {
429
+ attributeMap = /* @__PURE__ */ new WeakMap();
430
+ },
431
+ JSXOpeningElement(node) {
432
+ const nodeReservedList = reservedFirst && !isDOMComponent(node) ? reservedList.filter((prop) => prop !== "dangerouslySetInnerHTML") : reservedList;
433
+ node.attributes.reduce((memo, decl, idx, attrs) => {
434
+ if (decl.type === "JSXSpreadAttribute") return attrs[idx + 1];
435
+ let previousPropName = getPropName(memo);
436
+ let currentPropName = getPropName(decl);
437
+ const previousReservedNamespace = previousPropName.split(":")[0];
438
+ const currentReservedNamespace = currentPropName.split(":")[0];
439
+ const previousValue = memo.value;
440
+ const currentValue = decl.value;
441
+ const previousIsCallback = isCallbackPropName(previousPropName);
442
+ const currentIsCallback = isCallbackPropName(currentPropName);
443
+ if (ignoreCase) {
444
+ previousPropName = previousPropName.toLowerCase();
445
+ currentPropName = currentPropName.toLowerCase();
446
+ }
447
+ if (reservedFirst) {
448
+ if (reservedFirstError) {
449
+ reservedFirstError(decl);
450
+ return memo;
445
451
  }
446
- if (reservedFirst) {
447
- if (reservedFirstError) {
448
- reservedFirstError(decl);
449
- return memo;
450
- }
451
- const previousReservedIndex = getReservedPropIndex(previousPropName, nodeReservedList);
452
- const currentReservedIndex = getReservedPropIndex(currentPropName, nodeReservedList);
453
- if (previousReservedIndex > -1 && currentReservedIndex === -1) return decl;
454
- if (reservedFirst !== true && previousReservedIndex > currentReservedIndex || previousReservedIndex === -1 && currentReservedIndex > -1) {
455
- reportNodeAttribute(decl, "listReservedPropsFirst", node, context, nodeReservedList);
456
- return memo;
457
- }
458
- if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
452
+ const previousReservedIndex = getReservedPropIndex(previousPropName, nodeReservedList);
453
+ const currentReservedIndex = getReservedPropIndex(currentPropName, nodeReservedList);
454
+ if (previousReservedIndex > -1 && currentReservedIndex === -1) return decl;
455
+ if (reservedFirst !== true && previousReservedIndex > currentReservedIndex || previousReservedIndex === -1 && currentReservedIndex > -1) {
456
+ reportNodeAttribute(decl, "listReservedPropsFirst", node, context, nodeReservedList);
457
+ return memo;
459
458
  }
460
- if (reservedLastList.length > 0) {
461
- const previousReservedIndex = getReservedPropIndex(previousPropName, reservedLastList);
462
- const currentReservedIndex = getReservedPropIndex(currentPropName, reservedLastList);
463
- if (previousReservedIndex === -1 && currentReservedIndex > -1) return decl;
464
- if (previousReservedIndex < currentReservedIndex || previousReservedIndex > -1 && currentReservedIndex === -1) {
465
- reportNodeAttribute(decl, "listReservedPropsLast", node, context, nodeReservedList);
466
- return memo;
467
- }
468
- if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
459
+ if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
460
+ }
461
+ if (reservedLastList.length > 0) {
462
+ const previousReservedIndex = getReservedPropIndex(previousPropName, reservedLastList);
463
+ const currentReservedIndex = getReservedPropIndex(currentPropName, reservedLastList);
464
+ if (previousReservedIndex === -1 && currentReservedIndex > -1) return decl;
465
+ if (previousReservedIndex < currentReservedIndex || previousReservedIndex > -1 && currentReservedIndex === -1) {
466
+ reportNodeAttribute(decl, "listReservedPropsLast", node, context, nodeReservedList);
467
+ return memo;
469
468
  }
470
- if (callbacksLast) {
471
- if (!previousIsCallback && currentIsCallback) return decl;
472
- if (previousIsCallback && !currentIsCallback) {
473
- reportNodeAttribute(memo, "listCallbacksLast", node, context, nodeReservedList);
474
- return memo;
475
- }
469
+ if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
470
+ }
471
+ if (callbacksLast) {
472
+ if (!previousIsCallback && currentIsCallback) return decl;
473
+ if (previousIsCallback && !currentIsCallback) {
474
+ reportNodeAttribute(memo, "listCallbacksLast", node, context, nodeReservedList);
475
+ return memo;
476
476
  }
477
- if (shorthandFirst) {
478
- if (currentValue && !previousValue) return decl;
479
- if (!currentValue && previousValue) {
480
- reportNodeAttribute(decl, "listShorthandFirst", node, context, nodeReservedList);
481
- return memo;
482
- }
477
+ }
478
+ if (shorthandFirst) {
479
+ if (currentValue && !previousValue) return decl;
480
+ if (!currentValue && previousValue) {
481
+ reportNodeAttribute(decl, "listShorthandFirst", node, context, nodeReservedList);
482
+ return memo;
483
483
  }
484
- if (shorthandLast) {
485
- if (!currentValue && previousValue) return decl;
486
- if (currentValue && !previousValue) {
487
- reportNodeAttribute(memo, "listShorthandLast", node, context, nodeReservedList);
488
- return memo;
489
- }
484
+ }
485
+ if (shorthandLast) {
486
+ if (!currentValue && previousValue) return decl;
487
+ if (currentValue && !previousValue) {
488
+ reportNodeAttribute(memo, "listShorthandLast", node, context, nodeReservedList);
489
+ return memo;
490
490
  }
491
- const previousIsMultiline = isMultilineProp(memo);
492
- const currentIsMultiline = isMultilineProp(decl);
493
- if (multiline === "first") {
494
- if (previousIsMultiline && !currentIsMultiline) return decl;
495
- if (!previousIsMultiline && currentIsMultiline) {
496
- reportNodeAttribute(decl, "listMultilineFirst", node, context, nodeReservedList);
497
- return memo;
498
- }
499
- } else if (multiline === "last") {
500
- if (!previousIsMultiline && currentIsMultiline) return decl;
501
- if (previousIsMultiline && !currentIsMultiline) {
502
- reportNodeAttribute(memo, "listMultilineLast", node, context, nodeReservedList);
503
- return memo;
504
- }
491
+ }
492
+ const previousIsMultiline = isMultilineProp(memo);
493
+ const currentIsMultiline = isMultilineProp(decl);
494
+ if (multiline === "first") {
495
+ if (previousIsMultiline && !currentIsMultiline) return decl;
496
+ if (!previousIsMultiline && currentIsMultiline) {
497
+ reportNodeAttribute(decl, "listMultilineFirst", node, context, nodeReservedList);
498
+ return memo;
505
499
  }
506
- if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(currentPropName, locale === "auto" ? void 0 : locale) > 0 : previousPropName > currentPropName)) {
507
- reportNodeAttribute(decl, "sortPropsByAlpha", node, context, nodeReservedList);
500
+ } else if (multiline === "last") {
501
+ if (!previousIsMultiline && currentIsMultiline) return decl;
502
+ if (previousIsMultiline && !currentIsMultiline) {
503
+ reportNodeAttribute(memo, "listMultilineLast", node, context, nodeReservedList);
508
504
  return memo;
509
505
  }
510
- return decl;
511
- }, node.attributes[0]);
512
- }
513
- };
514
- }
515
- },
506
+ }
507
+ if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(currentPropName, locale === "auto" ? void 0 : locale) > 0 : previousPropName > currentPropName)) {
508
+ reportNodeAttribute(decl, "sortPropsByAlpha", node, context, nodeReservedList);
509
+ return memo;
510
+ }
511
+ return decl;
512
+ }, node.attributes[0]);
513
+ }
514
+ };
515
+ }
516
+ };
517
+
518
+ //#endregion
519
+ //#region src/rules/index.ts
520
+ const ruleOptions = {
521
+ "jsx-sort-props": rule,
516
522
  "define-style": rule$1
517
523
  };
524
+
518
525
  //#endregion
519
526
  //#region src/index.ts
520
527
  const plugins = { "vue-jsx-vapor": { rules: ruleOptions } };
@@ -547,7 +554,8 @@ const config = ({ rules = {}, ...options } = {}) => ({
547
554
  },
548
555
  ...options
549
556
  });
557
+
550
558
  //#endregion
551
559
  exports.default = config;
552
560
  exports.plugins = plugins;
553
- exports.rules = ruleOptions;
561
+ exports.rules = ruleOptions;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
1
+ import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
2
2
  import { ClassicConfig, Linter } from "@typescript-eslint/utils/ts-eslint";
3
3
 
4
4
  //#region src/rules/jsx-sort-props/types.d.ts
@@ -25,8 +25,8 @@ type MessageIds = 'define-style' | 'define-style-syntax-error';
25
25
  //#endregion
26
26
  //#region src/rules/index.d.ts
27
27
  declare const ruleOptions: {
28
- 'jsx-sort-props': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
29
- 'define-style': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
28
+ 'jsx-sort-props': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
29
+ 'define-style': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
30
30
  };
31
31
  interface RuleOptions {
32
32
  'vue-jsx-vapor/jsx-sort-props': JsxSortPropsRuleOptions;
@@ -38,8 +38,8 @@ type Rules = Partial<{ [K in keyof RuleOptions]: Linter.Severity | [Linter.Sever
38
38
  declare const plugins: {
39
39
  'vue-jsx-vapor': {
40
40
  rules: {
41
- 'jsx-sort-props': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
42
- 'define-style': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
41
+ 'jsx-sort-props': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
42
+ 'define-style': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
43
43
  };
44
44
  };
45
45
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
1
+ import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
2
2
  import { ClassicConfig, Linter } from "@typescript-eslint/utils/ts-eslint";
3
3
 
4
4
  //#region src/rules/jsx-sort-props/types.d.ts
@@ -25,8 +25,8 @@ type MessageIds = 'define-style' | 'define-style-syntax-error';
25
25
  //#endregion
26
26
  //#region src/rules/index.d.ts
27
27
  declare const ruleOptions: {
28
- 'jsx-sort-props': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
29
- 'define-style': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
28
+ 'jsx-sort-props': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
29
+ 'define-style': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
30
30
  };
31
31
  interface RuleOptions {
32
32
  'vue-jsx-vapor/jsx-sort-props': JsxSortPropsRuleOptions;
@@ -38,8 +38,8 @@ type Rules = Partial<{ [K in keyof RuleOptions]: Linter.Severity | [Linter.Sever
38
38
  declare const plugins: {
39
39
  'vue-jsx-vapor': {
40
40
  rules: {
41
- 'jsx-sort-props': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
42
- 'define-style': _$_typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _$_typescript_eslint_utils_ts_eslint0.RuleListener>;
41
+ 'jsx-sort-props': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds$1, JsxSortPropsRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
42
+ 'define-style': _typescript_eslint_utils_ts_eslint0.RuleModule<MessageIds, DefineStyleRuleOptions, unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
43
43
  };
44
44
  };
45
45
  };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import prettier from "@prettier/sync";
2
+
2
3
  //#region src/rules/define-style/index.ts
3
4
  const rule$1 = {
4
5
  defaultOptions: [{ tabWidth: 2 }],
@@ -60,6 +61,7 @@ const rule$1 = {
60
61
  } };
61
62
  }
62
63
  };
64
+
63
65
  //#endregion
64
66
  //#region src/rules/jsx-sort-props/index.ts
65
67
  const COMPAT_TAG_REGEX = /^[a-z]/;
@@ -343,151 +345,154 @@ function reportNodeAttribute(nodeAttribute, errorType, node, context, reservedLi
343
345
  fix: generateFixerFunction(node, context, reservedList)
344
346
  });
345
347
  }
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"
381
- }
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();
348
+ const rule = {
349
+ defaultOptions: [{
350
+ multiline: "ignore",
351
+ locale: "auto"
352
+ }],
353
+ meta: {
354
+ type: "layout",
355
+ docs: { description: "Enforce props alphabetical sorting" },
356
+ fixable: "code",
357
+ messages,
358
+ schema: [{
359
+ type: "object",
360
+ properties: {
361
+ callbacksLast: { type: "boolean" },
362
+ shorthandFirst: { type: "boolean" },
363
+ shorthandLast: { type: "boolean" },
364
+ multiline: {
365
+ type: "string",
366
+ enum: [
367
+ "ignore",
368
+ "first",
369
+ "last"
370
+ ],
371
+ default: "ignore"
402
372
  },
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();
373
+ ignoreCase: { type: "boolean" },
374
+ noSortAlphabetically: { type: "boolean" },
375
+ reservedFirst: { type: ["array", "boolean"] },
376
+ reservedLast: { type: "array" },
377
+ locale: {
378
+ type: "string",
379
+ default: "auto"
380
+ }
381
+ },
382
+ additionalProperties: false
383
+ }]
384
+ },
385
+ create(context) {
386
+ const configuration = context.options[0] || {};
387
+ const ignoreCase = configuration.ignoreCase || false;
388
+ const callbacksLast = configuration.callbacksLast || false;
389
+ const shorthandFirst = configuration.shorthandFirst || false;
390
+ const shorthandLast = configuration.shorthandLast || false;
391
+ const multiline = configuration.multiline || "ignore";
392
+ const noSortAlphabetically = configuration.noSortAlphabetically || false;
393
+ const reservedFirst = configuration.reservedFirst || false;
394
+ const reservedFirstError = validateReservedFirstConfig(context, reservedFirst);
395
+ const reservedList = Array.isArray(reservedFirst) ? reservedFirst : RESERVED_PROPS_LIST;
396
+ const reservedLastList = configuration.reservedLast || [];
397
+ const locale = configuration.locale || "auto";
398
+ return {
399
+ Program() {
400
+ attributeMap = /* @__PURE__ */ new WeakMap();
401
+ },
402
+ JSXOpeningElement(node) {
403
+ const nodeReservedList = reservedFirst && !isDOMComponent(node) ? reservedList.filter((prop) => prop !== "dangerouslySetInnerHTML") : reservedList;
404
+ node.attributes.reduce((memo, decl, idx, attrs) => {
405
+ if (decl.type === "JSXSpreadAttribute") return attrs[idx + 1];
406
+ let previousPropName = getPropName(memo);
407
+ let currentPropName = getPropName(decl);
408
+ const previousReservedNamespace = previousPropName.split(":")[0];
409
+ const currentReservedNamespace = currentPropName.split(":")[0];
410
+ const previousValue = memo.value;
411
+ const currentValue = decl.value;
412
+ const previousIsCallback = isCallbackPropName(previousPropName);
413
+ const currentIsCallback = isCallbackPropName(currentPropName);
414
+ if (ignoreCase) {
415
+ previousPropName = previousPropName.toLowerCase();
416
+ currentPropName = currentPropName.toLowerCase();
417
+ }
418
+ if (reservedFirst) {
419
+ if (reservedFirstError) {
420
+ reservedFirstError(decl);
421
+ return memo;
418
422
  }
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;
423
+ const previousReservedIndex = getReservedPropIndex(previousPropName, nodeReservedList);
424
+ const currentReservedIndex = getReservedPropIndex(currentPropName, nodeReservedList);
425
+ if (previousReservedIndex > -1 && currentReservedIndex === -1) return decl;
426
+ if (reservedFirst !== true && previousReservedIndex > currentReservedIndex || previousReservedIndex === -1 && currentReservedIndex > -1) {
427
+ reportNodeAttribute(decl, "listReservedPropsFirst", node, context, nodeReservedList);
428
+ return memo;
432
429
  }
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;
430
+ if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
431
+ }
432
+ if (reservedLastList.length > 0) {
433
+ const previousReservedIndex = getReservedPropIndex(previousPropName, reservedLastList);
434
+ const currentReservedIndex = getReservedPropIndex(currentPropName, reservedLastList);
435
+ if (previousReservedIndex === -1 && currentReservedIndex > -1) return decl;
436
+ if (previousReservedIndex < currentReservedIndex || previousReservedIndex > -1 && currentReservedIndex === -1) {
437
+ reportNodeAttribute(decl, "listReservedPropsLast", node, context, nodeReservedList);
438
+ return memo;
442
439
  }
443
- if (callbacksLast) {
444
- if (!previousIsCallback && currentIsCallback) return decl;
445
- if (previousIsCallback && !currentIsCallback) {
446
- reportNodeAttribute(memo, "listCallbacksLast", node, context, nodeReservedList);
447
- return memo;
448
- }
440
+ if (previousReservedIndex > -1 && currentReservedIndex > -1 && currentReservedIndex > previousReservedIndex && previousReservedNamespace !== currentReservedNamespace) return decl;
441
+ }
442
+ if (callbacksLast) {
443
+ if (!previousIsCallback && currentIsCallback) return decl;
444
+ if (previousIsCallback && !currentIsCallback) {
445
+ reportNodeAttribute(memo, "listCallbacksLast", node, context, nodeReservedList);
446
+ return memo;
449
447
  }
450
- if (shorthandFirst) {
451
- if (currentValue && !previousValue) return decl;
452
- if (!currentValue && previousValue) {
453
- reportNodeAttribute(decl, "listShorthandFirst", node, context, nodeReservedList);
454
- return memo;
455
- }
448
+ }
449
+ if (shorthandFirst) {
450
+ if (currentValue && !previousValue) return decl;
451
+ if (!currentValue && previousValue) {
452
+ reportNodeAttribute(decl, "listShorthandFirst", node, context, nodeReservedList);
453
+ return memo;
456
454
  }
457
- if (shorthandLast) {
458
- if (!currentValue && previousValue) return decl;
459
- if (currentValue && !previousValue) {
460
- reportNodeAttribute(memo, "listShorthandLast", node, context, nodeReservedList);
461
- return memo;
462
- }
455
+ }
456
+ if (shorthandLast) {
457
+ if (!currentValue && previousValue) return decl;
458
+ if (currentValue && !previousValue) {
459
+ reportNodeAttribute(memo, "listShorthandLast", node, context, nodeReservedList);
460
+ return memo;
463
461
  }
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
- }
462
+ }
463
+ const previousIsMultiline = isMultilineProp(memo);
464
+ const currentIsMultiline = isMultilineProp(decl);
465
+ if (multiline === "first") {
466
+ if (previousIsMultiline && !currentIsMultiline) return decl;
467
+ if (!previousIsMultiline && currentIsMultiline) {
468
+ reportNodeAttribute(decl, "listMultilineFirst", node, context, nodeReservedList);
469
+ return memo;
478
470
  }
479
- if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(currentPropName, locale === "auto" ? void 0 : locale) > 0 : previousPropName > currentPropName)) {
480
- reportNodeAttribute(decl, "sortPropsByAlpha", node, context, nodeReservedList);
471
+ } else if (multiline === "last") {
472
+ if (!previousIsMultiline && currentIsMultiline) return decl;
473
+ if (previousIsMultiline && !currentIsMultiline) {
474
+ reportNodeAttribute(memo, "listMultilineLast", node, context, nodeReservedList);
481
475
  return memo;
482
476
  }
483
- return decl;
484
- }, node.attributes[0]);
485
- }
486
- };
487
- }
488
- },
477
+ }
478
+ if (!noSortAlphabetically && (ignoreCase || locale !== "auto" ? previousPropName.localeCompare(currentPropName, locale === "auto" ? void 0 : locale) > 0 : previousPropName > currentPropName)) {
479
+ reportNodeAttribute(decl, "sortPropsByAlpha", node, context, nodeReservedList);
480
+ return memo;
481
+ }
482
+ return decl;
483
+ }, node.attributes[0]);
484
+ }
485
+ };
486
+ }
487
+ };
488
+
489
+ //#endregion
490
+ //#region src/rules/index.ts
491
+ const ruleOptions = {
492
+ "jsx-sort-props": rule,
489
493
  "define-style": rule$1
490
494
  };
495
+
491
496
  //#endregion
492
497
  //#region src/index.ts
493
498
  const plugins = { "vue-jsx-vapor": { rules: ruleOptions } };
@@ -520,5 +525,6 @@ const config = ({ rules = {}, ...options } = {}) => ({
520
525
  },
521
526
  ...options
522
527
  });
528
+
523
529
  //#endregion
524
- export { config as default, plugins, ruleOptions as rules };
530
+ 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.12",
4
+ "version": "3.2.14",
5
5
  "description": "Vue JSX Vapor ESLint Plugin",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/vuejs/vue-jsx-vapor#readme",