eslint-plugin-react-x 2.0.0-next.131 → 2.0.0-next.133

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.
Files changed (2) hide show
  1. package/dist/index.js +112 -112
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -133,7 +133,7 @@ var settings3 = {
133
133
 
134
134
  // package.json
135
135
  var name4 = "eslint-plugin-react-x";
136
- var version = "2.0.0-next.131";
136
+ var version = "2.0.0-next.133";
137
137
  var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
138
138
 
139
139
  // src/rules/jsx-key-before-spread.ts
@@ -4182,24 +4182,21 @@ function create63(context) {
4182
4182
  }
4183
4183
  };
4184
4184
  }
4185
- var RULE_NAME64 = "prefer-shorthand-boolean";
4186
- var RULE_FEATURES62 = [
4187
- "FIX"
4188
- ];
4189
- var prefer_shorthand_boolean_default = createRule({
4185
+ var RULE_NAME64 = "no-comment-textnodes";
4186
+ var RULE_FEATURES62 = [];
4187
+ var no_comment_textnodes_default = createRule({
4190
4188
  meta: {
4191
4189
  type: "problem",
4192
4190
  deprecated: true,
4193
4191
  docs: {
4194
- description: "Enforces shorthand syntax for boolean attributes.",
4192
+ description: "Prevents comments from being inserted as text nodes.",
4195
4193
  [Symbol.for("rule_features")]: RULE_FEATURES62
4196
4194
  },
4197
- fixable: "code",
4198
4195
  messages: {
4199
- preferShorthandBoolean: "Use shorthand boolean attribute '{{propName}}'."
4196
+ noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
4200
4197
  },
4201
4198
  replacedBy: [
4202
- "react-x/jsx-shorthand-boolean"
4199
+ "react-x/jsx-no-comment-textnodes"
4203
4200
  ],
4204
4201
  schema: []
4205
4202
  },
@@ -4208,44 +4205,48 @@ var prefer_shorthand_boolean_default = createRule({
4208
4205
  defaultOptions: []
4209
4206
  });
4210
4207
  function create64(context) {
4211
- return {
4212
- JSXAttribute(node) {
4213
- const { value } = node;
4214
- const propName = ER27.getAttributeName(context, node);
4215
- const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
4216
- if (!hasValueTrue) {
4217
- return;
4218
- }
4219
- context.report({
4220
- messageId: "preferShorthandBoolean",
4221
- node: node.value ?? node,
4222
- data: {
4223
- propName
4224
- },
4225
- fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
4226
- });
4208
+ function hasCommentLike(node) {
4209
+ if (AST13.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
4210
+ return false;
4211
+ }
4212
+ const rawValue = context.sourceCode.getText(node);
4213
+ return /^\s*\/(?:\/|\*)/mu.test(rawValue);
4214
+ }
4215
+ const visitorFunction = (node) => {
4216
+ if (!AST13.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) {
4217
+ return;
4218
+ }
4219
+ if (!hasCommentLike(node)) {
4220
+ return;
4227
4221
  }
4222
+ if (!node.parent.type.includes("JSX")) {
4223
+ return;
4224
+ }
4225
+ context.report({
4226
+ messageId: "noCommentTextnodes",
4227
+ node
4228
+ });
4229
+ };
4230
+ return {
4231
+ JSXText: visitorFunction,
4232
+ Literal: visitorFunction
4228
4233
  };
4229
4234
  }
4230
- var RULE_NAME65 = "prefer-shorthand-fragment";
4235
+ var RULE_NAME65 = "no-complex-conditional-rendering";
4231
4236
  var RULE_FEATURES63 = [
4232
- "FIX"
4237
+ "EXP"
4233
4238
  ];
4234
- var prefer_shorthand_fragment_default = createRule({
4239
+ var no_complex_conditional_rendering_default = createRule({
4235
4240
  meta: {
4236
4241
  type: "problem",
4237
4242
  deprecated: true,
4238
4243
  docs: {
4239
- description: "Enforces shorthand syntax for fragments.",
4244
+ description: "Disallow complex conditional rendering in JSX expressions.",
4240
4245
  [Symbol.for("rule_features")]: RULE_FEATURES63
4241
4246
  },
4242
- fixable: "code",
4243
4247
  messages: {
4244
- preferShorthandFragment: "Use fragment shorthand syntax instead of 'Fragment' component."
4248
+ noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
4245
4249
  },
4246
- replacedBy: [
4247
- "react-x/jsx-shorthand-fragment"
4248
- ],
4249
4250
  schema: []
4250
4251
  },
4251
4252
  name: RULE_NAME65,
@@ -4253,28 +4254,28 @@ var prefer_shorthand_fragment_default = createRule({
4253
4254
  defaultOptions: []
4254
4255
  });
4255
4256
  function create65(context) {
4256
- return {
4257
- JSXElement(node) {
4258
- if (!ER27.isFragmentElement(context, node)) return;
4259
- const hasAttributes = node.openingElement.attributes.length > 0;
4260
- if (hasAttributes) {
4261
- return;
4262
- }
4263
- context.report({
4264
- messageId: "preferShorthandFragment",
4265
- node,
4266
- fix: (fixer) => {
4267
- const { closingElement, openingElement } = node;
4268
- if (closingElement == null) {
4269
- return [];
4270
- }
4271
- return [
4272
- fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
4273
- fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
4274
- ];
4275
- }
4276
- });
4257
+ const visitorFunction = (node) => {
4258
+ const jsxExpContainer = node.parent?.parent;
4259
+ if (!AST13.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
4260
+ return;
4261
+ }
4262
+ if (!AST13.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
4263
+ return;
4264
+ }
4265
+ if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
4266
+ return;
4277
4267
  }
4268
+ context.report({
4269
+ messageId: "noComplexConditionalRendering",
4270
+ node: jsxExpContainer
4271
+ });
4272
+ };
4273
+ return {
4274
+ "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": visitorFunction,
4275
+ "JSXExpressionContainer > ConditionalExpression > LogicalExpression": visitorFunction,
4276
+ "JSXExpressionContainer > LogicalExpression > ConditionalExpression": visitorFunction,
4277
+ "JSXExpressionContainer > LogicalExpression[operator='&&'] > LogicalExpression[operator='||']": visitorFunction,
4278
+ "JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
4278
4279
  };
4279
4280
  }
4280
4281
  var RULE_NAME66 = "prefer-react-namespace-import";
@@ -4337,21 +4338,24 @@ function create66(context) {
4337
4338
  }
4338
4339
  };
4339
4340
  }
4340
- var RULE_NAME67 = "no-comment-textnodes";
4341
- var RULE_FEATURES65 = [];
4342
- var no_comment_textnodes_default = createRule({
4341
+ var RULE_NAME67 = "prefer-shorthand-boolean";
4342
+ var RULE_FEATURES65 = [
4343
+ "FIX"
4344
+ ];
4345
+ var prefer_shorthand_boolean_default = createRule({
4343
4346
  meta: {
4344
4347
  type: "problem",
4345
4348
  deprecated: true,
4346
4349
  docs: {
4347
- description: "Prevents comments from being inserted as text nodes.",
4350
+ description: "Enforces shorthand syntax for boolean attributes.",
4348
4351
  [Symbol.for("rule_features")]: RULE_FEATURES65
4349
4352
  },
4353
+ fixable: "code",
4350
4354
  messages: {
4351
- noCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces."
4355
+ preferShorthandBoolean: "Use shorthand boolean attribute '{{propName}}'."
4352
4356
  },
4353
4357
  replacedBy: [
4354
- "react-x/jsx-no-comment-textnodes"
4358
+ "react-x/jsx-shorthand-boolean"
4355
4359
  ],
4356
4360
  schema: []
4357
4361
  },
@@ -4360,48 +4364,44 @@ var no_comment_textnodes_default = createRule({
4360
4364
  defaultOptions: []
4361
4365
  });
4362
4366
  function create67(context) {
4363
- function hasCommentLike(node) {
4364
- if (AST13.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
4365
- return false;
4366
- }
4367
- const rawValue = context.sourceCode.getText(node);
4368
- return /^\s*\/(?:\/|\*)/mu.test(rawValue);
4369
- }
4370
- const visitorFunction = (node) => {
4371
- if (!AST13.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) {
4372
- return;
4373
- }
4374
- if (!hasCommentLike(node)) {
4375
- return;
4376
- }
4377
- if (!node.parent.type.includes("JSX")) {
4378
- return;
4379
- }
4380
- context.report({
4381
- messageId: "noCommentTextnodes",
4382
- node
4383
- });
4384
- };
4385
4367
  return {
4386
- JSXText: visitorFunction,
4387
- Literal: visitorFunction
4368
+ JSXAttribute(node) {
4369
+ const { value } = node;
4370
+ const propName = ER27.getAttributeName(context, node);
4371
+ const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
4372
+ if (!hasValueTrue) {
4373
+ return;
4374
+ }
4375
+ context.report({
4376
+ messageId: "preferShorthandBoolean",
4377
+ node: node.value ?? node,
4378
+ data: {
4379
+ propName
4380
+ },
4381
+ fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
4382
+ });
4383
+ }
4388
4384
  };
4389
4385
  }
4390
- var RULE_NAME68 = "no-complex-conditional-rendering";
4386
+ var RULE_NAME68 = "prefer-shorthand-fragment";
4391
4387
  var RULE_FEATURES66 = [
4392
- "EXP"
4388
+ "FIX"
4393
4389
  ];
4394
- var no_complex_conditional_rendering_default = createRule({
4390
+ var prefer_shorthand_fragment_default = createRule({
4395
4391
  meta: {
4396
4392
  type: "problem",
4397
4393
  deprecated: true,
4398
4394
  docs: {
4399
- description: "Disallow complex conditional rendering in JSX expressions.",
4395
+ description: "Enforces shorthand syntax for fragments.",
4400
4396
  [Symbol.for("rule_features")]: RULE_FEATURES66
4401
4397
  },
4398
+ fixable: "code",
4402
4399
  messages: {
4403
- noComplexConditionalRendering: "Avoid complex conditional rendering. Extract the logic into separate elements or components."
4400
+ preferShorthandFragment: "Use fragment shorthand syntax instead of 'Fragment' component."
4404
4401
  },
4402
+ replacedBy: [
4403
+ "react-x/jsx-shorthand-fragment"
4404
+ ],
4405
4405
  schema: []
4406
4406
  },
4407
4407
  name: RULE_NAME68,
@@ -4409,28 +4409,28 @@ var no_complex_conditional_rendering_default = createRule({
4409
4409
  defaultOptions: []
4410
4410
  });
4411
4411
  function create68(context) {
4412
- const visitorFunction = (node) => {
4413
- const jsxExpContainer = node.parent?.parent;
4414
- if (!AST13.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
4415
- return;
4416
- }
4417
- if (!AST13.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
4418
- return;
4419
- }
4420
- if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
4421
- return;
4422
- }
4423
- context.report({
4424
- messageId: "noComplexConditionalRendering",
4425
- node: jsxExpContainer
4426
- });
4427
- };
4428
4412
  return {
4429
- "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": visitorFunction,
4430
- "JSXExpressionContainer > ConditionalExpression > LogicalExpression": visitorFunction,
4431
- "JSXExpressionContainer > LogicalExpression > ConditionalExpression": visitorFunction,
4432
- "JSXExpressionContainer > LogicalExpression[operator='&&'] > LogicalExpression[operator='||']": visitorFunction,
4433
- "JSXExpressionContainer > LogicalExpression[operator='||'] > LogicalExpression[operator='&&']": visitorFunction
4413
+ JSXElement(node) {
4414
+ if (!ER27.isFragmentElement(context, node)) return;
4415
+ const hasAttributes = node.openingElement.attributes.length > 0;
4416
+ if (hasAttributes) {
4417
+ return;
4418
+ }
4419
+ context.report({
4420
+ messageId: "preferShorthandFragment",
4421
+ node,
4422
+ fix: (fixer) => {
4423
+ const { closingElement, openingElement } = node;
4424
+ if (closingElement == null) {
4425
+ return [];
4426
+ }
4427
+ return [
4428
+ fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
4429
+ fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
4430
+ ];
4431
+ }
4432
+ });
4433
+ }
4434
4434
  };
4435
4435
  }
4436
4436
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.0.0-next.131",
3
+ "version": "2.0.0-next.133",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,12 +42,12 @@
42
42
  "is-immutable-type": "^5.0.1",
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-pattern": "^5.8.0",
45
- "@eslint-react/ast": "2.0.0-next.131",
46
- "@eslint-react/core": "2.0.0-next.131",
47
- "@eslint-react/shared": "2.0.0-next.131",
48
- "@eslint-react/eff": "2.0.0-next.131",
49
- "@eslint-react/kit": "2.0.0-next.131",
50
- "@eslint-react/var": "2.0.0-next.131"
45
+ "@eslint-react/ast": "2.0.0-next.133",
46
+ "@eslint-react/eff": "2.0.0-next.133",
47
+ "@eslint-react/kit": "2.0.0-next.133",
48
+ "@eslint-react/shared": "2.0.0-next.133",
49
+ "@eslint-react/var": "2.0.0-next.133",
50
+ "@eslint-react/core": "2.0.0-next.133"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.1.10",