eslint-plugin-react-x 3.0.0-beta.67 → 3.0.0-beta.68

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 +21 -24
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -147,7 +147,7 @@ const rules$7 = {
147
147
  //#endregion
148
148
  //#region package.json
149
149
  var name$6 = "eslint-plugin-react-x";
150
- var version = "3.0.0-beta.67";
150
+ var version = "3.0.0-beta.68";
151
151
 
152
152
  //#endregion
153
153
  //#region src/utils/create-rule.ts
@@ -7185,34 +7185,31 @@ var unstable_rules_of_props_default = createRule({
7185
7185
  create,
7186
7186
  defaultOptions: []
7187
7187
  });
7188
+ function toControlledName(uncontrolledName) {
7189
+ const [, head, tail] = /^default([A-Z])(.*)$/.exec(uncontrolledName) ?? [];
7190
+ if (head == null || tail == null) return null;
7191
+ return head.toLowerCase() + tail;
7192
+ }
7188
7193
  function create(context) {
7189
- /**
7190
- * Pairs of [controlled prop, uncontrolled prop] that must not appear together
7191
- * on the same JSX element.
7192
- *
7193
- * - `value` → controlled; `defaultValue` → uncontrolled
7194
- * - `checked` → controlled; `defaultChecked` → uncontrolled
7195
- */
7196
- const pairs = [["value", "defaultValue"], ["checked", "defaultChecked"]];
7197
7194
  return defineRuleListener({ JSXOpeningElement(node) {
7198
- const map = /* @__PURE__ */ new Map();
7199
- for (const attr of node.attributes) {
7200
- if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
7201
- const { name } = attr.name;
7202
- if (typeof name !== "string") continue;
7203
- map.set(name, attr);
7195
+ const attributes = /* @__PURE__ */ new Map();
7196
+ for (const attribute of node.attributes) {
7197
+ if (attribute.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
7198
+ const { name: identifier } = attribute.name;
7199
+ if (typeof identifier !== "string") continue;
7200
+ attributes.set(identifier, attribute);
7204
7201
  }
7205
- for (const [controlled, uncontrolled] of pairs) {
7206
- if (!map.has(controlled) || !map.has(uncontrolled)) continue;
7207
- const attr = map.get(uncontrolled);
7208
- if (attr == null) continue;
7202
+ for (const [propName, attrNode] of attributes) {
7203
+ const controlledProp = toControlledName(propName);
7204
+ if (controlledProp == null) continue;
7205
+ if (!attributes.has(controlledProp)) continue;
7209
7206
  context.report({
7210
- data: {
7211
- controlled,
7212
- uncontrolled
7213
- },
7207
+ node: attrNode,
7214
7208
  messageId: "noControlledAndUncontrolledTogether",
7215
- node: attr
7209
+ data: {
7210
+ controlled: controlledProp,
7211
+ uncontrolled: propName
7212
+ }
7216
7213
  });
7217
7214
  }
7218
7215
  } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-beta.67",
3
+ "version": "3.0.0-beta.68",
4
4
  "description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -45,11 +45,11 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.4.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "3.0.0-beta.67",
49
- "@eslint-react/core": "3.0.0-beta.67",
50
- "@eslint-react/eff": "3.0.0-beta.67",
51
- "@eslint-react/shared": "3.0.0-beta.67",
52
- "@eslint-react/var": "3.0.0-beta.67"
48
+ "@eslint-react/ast": "3.0.0-beta.68",
49
+ "@eslint-react/core": "3.0.0-beta.68",
50
+ "@eslint-react/shared": "3.0.0-beta.68",
51
+ "@eslint-react/eff": "3.0.0-beta.68",
52
+ "@eslint-react/var": "3.0.0-beta.68"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",