@salesforce-ux/eslint-plugin-slds 0.0.8 → 0.0.10

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/build/index.js CHANGED
@@ -12,13 +12,13 @@ function getDefaultExportFromCjs (x) {
12
12
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13
13
  }
14
14
 
15
- var lib = {exports: {}};
15
+ var lib$1 = {exports: {}};
16
16
 
17
- var parser$1 = {};
17
+ var parser$2 = {};
18
18
 
19
19
  var dist = {};
20
20
 
21
- var parser = {};
21
+ var parser$1 = {};
22
22
 
23
23
  var parse = {};
24
24
 
@@ -2827,13 +2827,13 @@ function requireParse () {
2827
2827
  return parse;
2828
2828
  }
2829
2829
 
2830
- var hasRequiredParser$1;
2830
+ var hasRequiredParser$2;
2831
2831
 
2832
- function requireParser$1 () {
2833
- if (hasRequiredParser$1) return parser;
2834
- hasRequiredParser$1 = 1;
2832
+ function requireParser$2 () {
2833
+ if (hasRequiredParser$2) return parser$1;
2834
+ hasRequiredParser$2 = 1;
2835
2835
  (function (exports) {
2836
- var __createBinding = (parser && parser.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2836
+ var __createBinding = (parser$1 && parser$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2837
2837
  if (k2 === undefined) k2 = k;
2838
2838
  var desc = Object.getOwnPropertyDescriptor(m, k);
2839
2839
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
@@ -2844,13 +2844,13 @@ function requireParser$1 () {
2844
2844
  if (k2 === undefined) k2 = k;
2845
2845
  o[k2] = m[k];
2846
2846
  }));
2847
- var __exportStar = (parser && parser.__exportStar) || function(m, exports) {
2847
+ var __exportStar = (parser$1 && parser$1.__exportStar) || function(m, exports) {
2848
2848
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2849
2849
  };
2850
2850
  Object.defineProperty(exports, "__esModule", { value: true });
2851
2851
  __exportStar(requireParse(), exports);
2852
- } (parser));
2853
- return parser;
2852
+ } (parser$1));
2853
+ return parser$1;
2854
2854
  }
2855
2855
 
2856
2856
  var node$1 = {};
@@ -2886,7 +2886,7 @@ function requireDist () {
2886
2886
  };
2887
2887
  Object.defineProperty(exports, "__esModule", { value: true });
2888
2888
  exports.TokenTypes = exports.NodeTypes = exports.parse = void 0;
2889
- var parser_1 = requireParser$1();
2889
+ var parser_1 = requireParser$2();
2890
2890
  Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_1.parse; } });
2891
2891
  var constants_1 = requireConstants();
2892
2892
  Object.defineProperty(exports, "NodeTypes", { enumerable: true, get: function () { return constants_1.NodeTypes; } });
@@ -3024,25 +3024,307 @@ function requireTraverse () {
3024
3024
  }
3025
3025
 
3026
3026
  /**
3027
- * @typedef {import("./types").ProgramNode} ProgramNode
3027
+ * @typedef {import("./types").TemplateSyntax} TemplateSyntax
3028
+ * @typedef {import("./types").Range} Range
3029
+ * @typedef {import("./types").OpenSyntax} OpenSyntax
3030
+ * @typedef {import("./types").CloseSyntax} CloseSyntax
3031
+ * @typedef {import("./types").TemplateSyntaxParserResult} TemplateSyntaxParserResult
3032
+ *
3033
+ */
3034
+
3035
+ var parser;
3036
+ var hasRequiredParser$1;
3037
+
3038
+ function requireParser$1 () {
3039
+ if (hasRequiredParser$1) return parser;
3040
+ hasRequiredParser$1 = 1;
3041
+ parser = class Parser {
3042
+ /**
3043
+ * @param {string} code
3044
+ * @param {[string, string][]} syntaxPairs
3045
+ * @param {Range[]} skipRanges
3046
+ */
3047
+ constructor(code, syntaxPairs, skipRanges) {
3048
+ /**
3049
+ * @type {string}
3050
+ */
3051
+ this.code = code;
3052
+ /**
3053
+ * @type {[string, string][]}
3054
+ */
3055
+ this.syntaxPairs = syntaxPairs || [];
3056
+ /**
3057
+ * @type {Range[]}
3058
+ */
3059
+ this.skipRanges = skipRanges;
3060
+ /**
3061
+ * @type {OpenSyntax[]}
3062
+ */
3063
+ this.syntaxStack = [];
3064
+ /**
3065
+ * @type {TemplateSyntax[]}
3066
+ */
3067
+ this.result = [];
3068
+ }
3069
+
3070
+ /**
3071
+ * @private
3072
+ * @param {number} index
3073
+ * @returns {Range | undefined}
3074
+ */
3075
+ findSkipRange(index) {
3076
+ return this.skipRanges.find(
3077
+ (range) => range[0] <= index && index < range[1]
3078
+ );
3079
+ }
3080
+
3081
+ /**
3082
+ * @param {string} syntax
3083
+ * @param {number} position
3084
+ * @returns {number}
3085
+ */
3086
+ indexOf(syntax, position) {
3087
+ const index = this.code.indexOf(syntax, position);
3088
+ if (index < 0) return index;
3089
+ const skipRange = this.findSkipRange(index);
3090
+ if (skipRange) {
3091
+ return this.indexOf(syntax, skipRange[1]);
3092
+ }
3093
+ return index;
3094
+ }
3095
+
3096
+ /**
3097
+ * @param {number} position
3098
+ * @returns {OpenSyntax | null}
3099
+ */
3100
+ findOpenSyntax(position) {
3101
+ /**
3102
+ * @type {string | null}
3103
+ */
3104
+ let value = null;
3105
+ let rangeStart = Infinity;
3106
+ for (let i = 0; i < this.syntaxPairs.length; i++) {
3107
+ const [open] = this.syntaxPairs[i];
3108
+ const openIndex = this.indexOf(open, position);
3109
+ if (openIndex >= 0 && openIndex < rangeStart) {
3110
+ value = open;
3111
+ rangeStart = openIndex;
3112
+ }
3113
+ }
3114
+ if (!value) return null;
3115
+ return {
3116
+ type: "open",
3117
+ value,
3118
+ range: [rangeStart, rangeStart + value.length],
3119
+ };
3120
+ }
3121
+
3122
+ /**
3123
+ * @param {number} position
3124
+ * @returns {CloseSyntax | null}
3125
+ */
3126
+ findCloseSyntax(position) {
3127
+ /**
3128
+ * @type {string | null}
3129
+ */
3130
+ let value = null;
3131
+ let rangeStart = Infinity;
3132
+ for (let i = 0; i < this.syntaxPairs.length; i++) {
3133
+ const [, close] = this.syntaxPairs[i];
3134
+ const closeIndex = this.indexOf(close, position);
3135
+ if (closeIndex >= 0 && closeIndex < rangeStart) {
3136
+ value = close;
3137
+ rangeStart = closeIndex;
3138
+ }
3139
+ }
3140
+ if (!value) return null;
3141
+ return {
3142
+ type: "close",
3143
+ value,
3144
+ range: [rangeStart, rangeStart + value.length],
3145
+ };
3146
+ }
3147
+
3148
+ /**
3149
+ * @returns {OpenSyntax[]}
3150
+ */
3151
+ findAllOpenSyntax() {
3152
+ /**
3153
+ * @type {OpenSyntax[]}
3154
+ */
3155
+ const result = [];
3156
+ let position = 0;
3157
+
3158
+ while (position < this.code.length) {
3159
+ const openSyntax = this.findOpenSyntax(position);
3160
+ if (!openSyntax) {
3161
+ break;
3162
+ }
3163
+ result.push(openSyntax);
3164
+ position = openSyntax.range[1];
3165
+ }
3166
+
3167
+ return result;
3168
+ }
3169
+
3170
+ /**
3171
+ * @returns {CloseSyntax[]}
3172
+ */
3173
+ findAllCloseSyntax() {
3174
+ /**
3175
+ * @type {CloseSyntax[]}
3176
+ */
3177
+ const result = [];
3178
+ let position = 0;
3179
+
3180
+ while (position < this.code.length) {
3181
+ const closeSyntax = this.findCloseSyntax(position);
3182
+ if (!closeSyntax) {
3183
+ break;
3184
+ }
3185
+ result.push(closeSyntax);
3186
+ position = closeSyntax.range[1];
3187
+ }
3188
+
3189
+ return result;
3190
+ }
3191
+
3192
+ /**
3193
+ * @returns {(CloseSyntax | OpenSyntax)[]}
3194
+ */
3195
+ findAllSyntax() {
3196
+ return this.findAllOpenSyntax()
3197
+ .concat(this.findAllCloseSyntax())
3198
+ .sort((a, b) => a.range[0] - b.range[0]);
3199
+ }
3200
+
3201
+ /**
3202
+ * @param {OpenSyntax} open
3203
+ * @returns {string}
3204
+ */
3205
+ getPossibleCloseValueOf(open) {
3206
+ return this.syntaxPairs.find((syntax) => syntax[0] === open.value)[1];
3207
+ }
3208
+
3209
+ /**
3210
+ * @param {CloseSyntax | OpenSyntax} syntax
3211
+ */
3212
+ eatSyntax(syntax) {
3213
+ if (syntax.type === "open") {
3214
+ const top = this.syntaxStack.pop();
3215
+ if (!top) {
3216
+ this.syntaxStack.push(syntax);
3217
+ } else {
3218
+ throw new Error(
3219
+ `Expecting "${this.getPossibleCloseValueOf(top)}", but found "${
3220
+ syntax.value
3221
+ }" at (${syntax.range[0]}, ${syntax.range[1]}).`
3222
+ );
3223
+ }
3224
+ } else if (syntax.type === "close") {
3225
+ const top = this.syntaxStack.pop();
3226
+ if (!top) {
3227
+ return;
3228
+ } else if (this.getPossibleCloseValueOf(top) === syntax.value) {
3229
+ this.result.push({
3230
+ open: top.value,
3231
+ close: syntax.value,
3232
+ range: [top.range[0], syntax.range[1]],
3233
+ });
3234
+ }
3235
+ }
3236
+ }
3237
+
3238
+ /**
3239
+ * @returns {TemplateSyntaxParserResult}
3240
+ */
3241
+ parse() {
3242
+ for (const syntax of this.findAllSyntax()) {
3243
+ this.eatSyntax(syntax);
3244
+ }
3245
+ return {
3246
+ syntax: this.result,
3247
+ };
3248
+ }
3249
+ };
3250
+ return parser;
3251
+ }
3252
+
3253
+ /**
3254
+ * @typedef {import("./types").TemplateSyntaxParserConfig} TemplateSyntaxParserConfig
3255
+ */
3256
+
3257
+ var templateSyntaxParser;
3258
+ var hasRequiredTemplateSyntaxParser;
3259
+
3260
+ function requireTemplateSyntaxParser () {
3261
+ if (hasRequiredTemplateSyntaxParser) return templateSyntaxParser;
3262
+ hasRequiredTemplateSyntaxParser = 1;
3263
+ const Parser = requireParser$1();
3264
+
3265
+ /**
3266
+ * @param {string} code
3267
+ * @param {TemplateSyntaxParserConfig} config
3268
+ */
3269
+ function parse(code, config) {
3270
+ const syntaxPairs = Object.entries(config.syntax) || [];
3271
+ syntaxPairs.sort((syntaxA, syntaxB) => syntaxB[0].length - syntaxA[0].length);
3272
+ const parser = new Parser(code, syntaxPairs, config.skipRanges || []);
3273
+ return parser.parse();
3274
+ }
3275
+
3276
+ templateSyntaxParser = {
3277
+ parse,
3278
+ };
3279
+ return templateSyntaxParser;
3280
+ }
3281
+
3282
+ var lib;
3283
+ var hasRequiredLib$1;
3284
+
3285
+ function requireLib$1 () {
3286
+ if (hasRequiredLib$1) return lib;
3287
+ hasRequiredLib$1 = 1;
3288
+ const { parse } = requireTemplateSyntaxParser();
3289
+ lib = {
3290
+ parse,
3291
+ };
3292
+ return lib;
3293
+ }
3294
+
3295
+ /**
3296
+ * @typedef {import("./types").ParserOptions} ParserOptions
3028
3297
  */
3029
3298
 
3030
3299
  var hasRequiredParser;
3031
3300
 
3032
3301
  function requireParser () {
3033
- if (hasRequiredParser) return parser$1;
3302
+ if (hasRequiredParser) return parser$2;
3034
3303
  hasRequiredParser = 1;
3035
3304
  const { parse } = requireDist();
3036
3305
  const { visitorKeys } = requireVisitorKeys();
3037
3306
  const { traverse } = requireTraverse();
3038
3307
  const { NODE_TYPES } = requireNodeTypes();
3308
+ const templateSyntaxParser = requireLib$1();
3039
3309
 
3040
3310
  /**
3041
3311
  * @param {string} code
3042
- * @returns {ProgramNode}
3312
+ * @param {ParserOptions | undefined} parserOptions
3313
+ * @returns {any}
3043
3314
  */
3044
- parser$1.parseForESLint = function parseForESLint(code) {
3045
- const { ast, tokens } = parse(code);
3315
+ parser$2.parseForESLint = function parseForESLint(code, parserOptions) {
3316
+ const options =
3317
+ (parserOptions &&
3318
+ parserOptions.templateEngineSyntax && {
3319
+ templateRanges: templateSyntaxParser
3320
+ .parse(code, {
3321
+ syntax: parserOptions.templateEngineSyntax,
3322
+ })
3323
+ .syntax.map((s) => s.range),
3324
+ }) ||
3325
+ undefined;
3326
+
3327
+ const { ast, tokens } = parse(code, options);
3046
3328
 
3047
3329
  const programNode = {
3048
3330
  type: "Program",
@@ -3075,11 +3357,11 @@ function requireParser () {
3075
3357
  scopeManager: null,
3076
3358
  };
3077
3359
  };
3078
- return parser$1;
3360
+ return parser$2;
3079
3361
  }
3080
3362
 
3081
3363
  var name = "@html-eslint/parser";
3082
- var version = "0.33.0";
3364
+ var version = "0.34.0";
3083
3365
  var description = "Parser for @html-eslint/eslint-plugin";
3084
3366
  var author = "yeonjuan";
3085
3367
  var homepage = "https://github.com/yeonjuan/html-eslint#readme";
@@ -3114,12 +3396,13 @@ var bugs = {
3114
3396
  url: "https://github.com/yeonjuan/html-eslint/issues"
3115
3397
  };
3116
3398
  var dependencies = {
3399
+ "@html-eslint/template-syntax-parser": "^0.34.0",
3117
3400
  "es-html-parser": "^1.0.0-alpha.4"
3118
3401
  };
3119
3402
  var devDependencies = {
3120
3403
  typescript: "^5.7.2"
3121
3404
  };
3122
- var gitHead = "4a0ee932a671f8c54bf1a86849fe886e9628b777";
3405
+ var gitHead = "f0401cc30d1510d6f5c7511280c0a6b9779fea0c";
3123
3406
  var require$$0 = {
3124
3407
  name: name,
3125
3408
  version: version,
@@ -3152,24 +3435,52 @@ function requireMeta () {
3152
3435
  return meta;
3153
3436
  }
3154
3437
 
3438
+ var templateEngineSyntaxPreset;
3439
+ var hasRequiredTemplateEngineSyntaxPreset;
3440
+
3441
+ function requireTemplateEngineSyntaxPreset () {
3442
+ if (hasRequiredTemplateEngineSyntaxPreset) return templateEngineSyntaxPreset;
3443
+ hasRequiredTemplateEngineSyntaxPreset = 1;
3444
+ const HANDLEBAR = {
3445
+ "{{": "}}",
3446
+ };
3447
+ const TWIG = {
3448
+ "{{": "}}",
3449
+ "{%": "%}",
3450
+ "{#": "#}",
3451
+ };
3452
+ const ERB = {
3453
+ "<%": "%>",
3454
+ };
3455
+
3456
+ templateEngineSyntaxPreset = {
3457
+ HANDLEBAR,
3458
+ TWIG,
3459
+ ERB,
3460
+ };
3461
+ return templateEngineSyntaxPreset;
3462
+ }
3463
+
3155
3464
  var hasRequiredLib;
3156
3465
 
3157
3466
  function requireLib () {
3158
- if (hasRequiredLib) return lib.exports;
3467
+ if (hasRequiredLib) return lib$1.exports;
3159
3468
  hasRequiredLib = 1;
3160
3469
  const { parseForESLint } = requireParser();
3161
3470
  const meta = requireMeta();
3162
3471
  const { NODE_TYPES } = requireNodeTypes();
3472
+ const TEMPLATE_ENGINE_SYNTAX = requireTemplateEngineSyntaxPreset();
3163
3473
 
3164
- lib.exports.parseForESLint = parseForESLint;
3165
- lib.exports.NODE_TYPES = NODE_TYPES;
3474
+ lib$1.exports.parseForESLint = parseForESLint;
3475
+ lib$1.exports.NODE_TYPES = NODE_TYPES;
3166
3476
 
3167
- lib.exports = {
3477
+ lib$1.exports = {
3478
+ TEMPLATE_ENGINE_SYNTAX,
3168
3479
  parseForESLint,
3169
3480
  NODE_TYPES,
3170
3481
  meta,
3171
3482
  };
3172
- return lib.exports;
3483
+ return lib$1.exports;
3173
3484
  }
3174
3485
 
3175
3486
  var node;
@@ -3634,11 +3945,19 @@ function requireModalCloseButtonIssue () {
3634
3945
 
3635
3946
  const tagName = node.name;
3636
3947
 
3637
- // ✅ Scenario 1: Remove 'slds-button_icon-inverse' from <button>
3948
+ // ✅ Scenario 1: Remove 'slds-button_icon-inverse' from <button>
3949
+ // (optional) when the parent of the button has class name `slds-modal`
3950
+ // and also button should have class `slds-modal__close`
3638
3951
  if (tagName === "button") {
3639
3952
  const classAttr = findAttr(node, "class");
3640
3953
  if (classAttr && classAttr.value) {
3641
3954
  const classList = classAttr.value.value.split(/\s+/);
3955
+
3956
+ // ✅ Ensure button has "slds-modal__close" before proceeding
3957
+ if (!classList.includes("slds-modal__close")) {
3958
+ return; // Stop execution if the class is missing
3959
+ }
3960
+
3642
3961
  if (classList.includes("slds-button_icon-inverse")) {
3643
3962
  context.report({
3644
3963
  node,
@@ -3657,98 +3976,116 @@ function requireModalCloseButtonIssue () {
3657
3976
  }
3658
3977
  }
3659
3978
 
3660
- // ✅ Scenario 2: Fix <lightning-button-icon>
3979
+ // ✅ Scenario 2: Fix <lightning-button-icon> and this should have class `slds-modal__close`
3661
3980
  if (tagName === "lightning-button-icon" || tagName === "lightning:buttonIcon") {
3662
3981
  const variantAttr = findAttr(node, "variant");
3663
3982
  const sizeAttr = findAttr(node, "size");
3664
3983
  const classAttr = findAttr(node, "class");
3665
3984
 
3666
- // Fix variant="bare-inverse" to "bare"
3667
- if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
3668
- context.report({
3669
- node: variantAttr,
3670
- messageId: "changeVariant",
3671
- fix(fixer) {
3672
- return fixer.replaceText(variantAttr.value, `bare`);
3673
- },
3674
- });
3675
- }
3676
-
3677
- // Ensure size="large" exists
3678
- if (!sizeAttr) {
3679
- context.report({
3680
- node,
3681
- messageId: "ensureSizeAttribute",
3682
- fix(fixer) {
3683
- //return fixer.insertTextAfter(node, ' size="large"');
3684
- return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"')
3685
- },
3686
- });
3687
- }
3688
-
3689
- // Ensure 'slds-button' and 'slds-button_icon' are in the class attribute
3690
3985
  if (classAttr && classAttr.value) {
3691
3986
  const classList = classAttr.value.value.split(/\s+/);
3692
- if (!classList.includes("slds-button") || !classList.includes("slds-button_icon")) {
3987
+
3988
+ // ✅ Ensure button has "slds-modal__close" before proceeding
3989
+ if (!classList.includes("slds-modal__close")) {
3990
+ return; // Stop execution if the class is missing
3991
+ }
3992
+
3993
+ // Fix variant="bare-inverse" to "bare"
3994
+ if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
3693
3995
  context.report({
3694
- node: classAttr,
3695
- messageId: "ensureButtonClasses",
3996
+ node: variantAttr,
3997
+ messageId: "changeVariant",
3696
3998
  fix(fixer) {
3697
- const newClassList = [
3698
- "slds-button",
3699
- "slds-button_icon",
3700
- ...classList.filter(
3701
- (cls) => cls !== "slds-button_icon-inverse"
3702
- ),
3703
- ].join(" ");
3704
- return fixer.replaceText(classAttr.value, `"${newClassList}"`);
3999
+ return fixer.replaceText(variantAttr.value, `bare`);
3705
4000
  },
3706
4001
  });
3707
4002
  }
4003
+
4004
+ // Ensure size="large" exists
4005
+ if (!sizeAttr) {
4006
+ context.report({
4007
+ node,
4008
+ messageId: "ensureSizeAttribute",
4009
+ fix(fixer) {
4010
+ //return fixer.insertTextAfter(node, ' size="large"');
4011
+ return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"')
4012
+ },
4013
+ });
4014
+ }
4015
+
4016
+ // Ensure 'slds-button' and 'slds-button_icon' are in the class attribute
4017
+ if (classAttr && classAttr.value) {
4018
+ const classList = classAttr.value.value.split(/\s+/);
4019
+ if (!classList.includes("slds-button") || !classList.includes("slds-button_icon")) {
4020
+ context.report({
4021
+ node: classAttr,
4022
+ messageId: "ensureButtonClasses",
4023
+ fix(fixer) {
4024
+ const newClassList = [
4025
+ "slds-button",
4026
+ "slds-button_icon",
4027
+ ...classList.filter(
4028
+ (cls) => cls !== "slds-button_icon-inverse"
4029
+ ),
4030
+ ].join(" ");
4031
+ return fixer.replaceText(classAttr.value, `"${newClassList}"`);
4032
+ },
4033
+ });
4034
+ }
4035
+ }
3708
4036
  }
4037
+
3709
4038
  }
3710
4039
 
3711
- // ✅ Scenario 3: Fix <lightning-icon> inside <button>
4040
+ // ✅ Scenario 3: Fix <lightning-icon> inside <button> & the class name of the parent name as button and it should have `slds-modal__close`
3712
4041
  if ((tagName === "lightning-icon" || tagName === "lightning:icon") && node.parent?.name === "button") {
3713
- const variantAttr = findAttr(node, "variant");
3714
- const sizeAttr = findAttr(node, "size");
4042
+ const parentClassAttr = findAttr(node.parent, "class");
4043
+ if (parentClassAttr && parentClassAttr.value) {
4044
+ const parentClassList = parentClassAttr.value.value.split(/\s+/);
3715
4045
 
3716
- // Fix variant="bare-inverse" to "bare"
3717
- if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
3718
- context.report({
3719
- node: variantAttr,
3720
- messageId: "changeVariant",
3721
- fix(fixer) {
3722
- return fixer.replaceText(variantAttr.value, `"bare"`);
3723
- },
3724
- });
3725
- }
4046
+ // Ensure the parent <button> has "slds-modal__close" before proceeding
4047
+ if (!parentClassList.includes("slds-modal__close")) {
4048
+ return; // Stop execution if the class is missing
4049
+ }
4050
+ const variantAttr = findAttr(node, "variant");
4051
+ const sizeAttr = findAttr(node, "size");
3726
4052
 
3727
- // Remove variant attribute completely
3728
- if (variantAttr) {
3729
- context.report({
3730
- node: variantAttr,
3731
- messageId: "removeVariant",
3732
- fix(fixer) {
3733
- return fixer.remove(variantAttr);
3734
- },
3735
- });
3736
- }
4053
+ // Fix variant="bare-inverse" to "bare"
4054
+ if (variantAttr && variantAttr.value && variantAttr.value.value === "bare-inverse") {
4055
+ context.report({
4056
+ node: variantAttr,
4057
+ messageId: "changeVariant",
4058
+ fix(fixer) {
4059
+ return fixer.replaceText(variantAttr.value, `"bare"`);
4060
+ },
4061
+ });
4062
+ }
3737
4063
 
3738
- //Ensure size="large" is set
3739
- if (!sizeAttr) {
3740
- context.report({
3741
- node,
3742
- messageId: "ensureSizeAttribute",
3743
- fix(fixer) {
3744
- //return fixer.insertTextAfter(node, ' size="large"');
3745
- return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], ' size="large"')
3746
- },
3747
- });
4064
+ // Remove variant attribute completely
4065
+ if (variantAttr) {
4066
+ context.report({
4067
+ node: variantAttr,
4068
+ messageId: "removeVariant",
4069
+ fix(fixer) {
4070
+ return fixer.remove(variantAttr);
4071
+ },
4072
+ });
4073
+ }
4074
+
4075
+ //Ensure size="large" is set
4076
+ if (!sizeAttr) {
4077
+ context.report({
4078
+ node,
4079
+ messageId: "ensureSizeAttribute",
4080
+ fix(fixer) {
4081
+ //return fixer.insertTextAfter(node, ' size="large"');
4082
+ return fixer.insertTextAfterRange([variantAttr.range[1], variantAttr.range[1]], 'size="large"')
4083
+ },
4084
+ });
4085
+ }
3748
4086
  }
3749
4087
  }
3750
4088
  }
3751
-
3752
4089
  return {
3753
4090
  Tag: check,
3754
4091
  };