eslint-plugin-react-dom 2.0.0-next.5 → 2.0.0-next.51

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.d.ts CHANGED
@@ -1,6 +1,15 @@
1
+ import { CamelCase } from 'string-ts';
1
2
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
3
  import { RulePreset } from '@eslint-react/kit';
3
4
 
5
+ declare const RULE_NAME$1 = "no-missing-iframe-sandbox";
6
+ type MessageID$1 = CamelCase<typeof RULE_NAME$1> | RuleSuggestMessageID$1;
7
+ type RuleSuggestMessageID$1 = "addIframeSandbox";
8
+
9
+ declare const RULE_NAME = "no-missing-button-type";
10
+ type MessageID = CamelCase<typeof RULE_NAME> | RuleSuggestMessageID;
11
+ type RuleSuggestMessageID = "addButtonType";
12
+
4
13
  declare const _default: {
5
14
  configs: {
6
15
  recommended: {
@@ -16,8 +25,8 @@ declare const _default: {
16
25
  readonly "no-find-dom-node": _typescript_eslint_utils_ts_eslint.RuleModule<"noFindDomNode", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
17
26
  readonly "no-flush-sync": _typescript_eslint_utils_ts_eslint.RuleModule<"noFlushSync", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
18
27
  readonly "no-hydrate": _typescript_eslint_utils_ts_eslint.RuleModule<"noHydrate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
19
- readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<"noMissingButtonType", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
- readonly "no-missing-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<"noMissingIframeSandbox", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
28
+ readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
29
+ readonly "no-missing-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
21
30
  readonly "no-namespace": _typescript_eslint_utils_ts_eslint.RuleModule<"noNamespace", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
22
31
  readonly "no-render": _typescript_eslint_utils_ts_eslint.RuleModule<"noRender", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
23
32
  readonly "no-render-return-value": _typescript_eslint_utils_ts_eslint.RuleModule<"noRenderReturnValue", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
@@ -48,8 +57,8 @@ declare const _default: {
48
57
  readonly "no-find-dom-node": _typescript_eslint_utils_ts_eslint.RuleModule<"noFindDomNode", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
49
58
  readonly "no-flush-sync": _typescript_eslint_utils_ts_eslint.RuleModule<"noFlushSync", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
50
59
  readonly "no-hydrate": _typescript_eslint_utils_ts_eslint.RuleModule<"noHydrate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
51
- readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<"noMissingButtonType", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
52
- readonly "no-missing-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<"noMissingIframeSandbox", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
60
+ readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
61
+ readonly "no-missing-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
53
62
  readonly "no-namespace": _typescript_eslint_utils_ts_eslint.RuleModule<"noNamespace", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
54
63
  readonly "no-render": _typescript_eslint_utils_ts_eslint.RuleModule<"noRender", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
55
64
  readonly "no-render-return-value": _typescript_eslint_utils_ts_eslint.RuleModule<"noRenderReturnValue", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import * as AST from '@eslint-react/ast';
5
5
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
6
6
  import { compare } from 'compare-versions';
7
7
  import { RegExp, Reporter } from '@eslint-react/kit';
8
- import { _ } from '@eslint-react/eff';
8
+ import { unit } from '@eslint-react/eff';
9
9
 
10
10
  var __defProp = Object.defineProperty;
11
11
  var __export = (target, all) => {
@@ -44,7 +44,7 @@ var settings = {
44
44
 
45
45
  // package.json
46
46
  var name2 = "eslint-plugin-react-dom";
47
- var version = "2.0.0-next.5";
47
+ var version = "2.0.0-next.51";
48
48
  function createJsxElementResolver(context) {
49
49
  const { components, polymorphicPropName } = getSettingsFromContext(context);
50
50
  return {
@@ -323,7 +323,10 @@ function getFix(context, node) {
323
323
  };
324
324
  }
325
325
  var RULE_NAME6 = "no-missing-button-type";
326
- var RULE_FEATURES6 = [];
326
+ var RULE_FEATURES6 = [
327
+ "FIX"
328
+ ];
329
+ var BUTTON_TYPES = ["button", "submit", "reset"];
327
330
  var no_missing_button_type_default = createRule({
328
331
  meta: {
329
332
  type: "problem",
@@ -331,7 +334,9 @@ var no_missing_button_type_default = createRule({
331
334
  description: "Enforces explicit `type` attribute for `button` elements.",
332
335
  [Symbol.for("rule_features")]: RULE_FEATURES6
333
336
  },
337
+ hasSuggestions: true,
334
338
  messages: {
339
+ addButtonType: "Add 'type' attribute with value '{{type}}'.",
335
340
  noMissingButtonType: "Add missing 'type' attribute on 'button' component."
336
341
  },
337
342
  schema: []
@@ -360,10 +365,13 @@ function create6(context) {
360
365
  attributeNode,
361
366
  propNameOnJsx
362
367
  );
363
- if (attributeValue.kind === "some" && typeof attributeValue.value !== "string") {
368
+ if (attributeValue.kind !== "some" || typeof attributeValue.value !== "string") {
364
369
  context.report({
365
370
  messageId: "noMissingButtonType",
366
- node: attributeNode
371
+ node: attributeNode,
372
+ suggest: getSuggest((type) => (fixer) => {
373
+ return fixer.replaceText(attributeNode, `${propNameOnJsx}="${type}"`);
374
+ })
367
375
  });
368
376
  }
369
377
  return;
@@ -371,35 +379,26 @@ function create6(context) {
371
379
  if (typeof customComponentProp?.defaultValue !== "string") {
372
380
  context.report({
373
381
  messageId: "noMissingButtonType",
374
- node
382
+ node,
383
+ suggest: getSuggest((type) => (fixer) => {
384
+ return fixer.insertTextAfter(node.openingElement.name, ` type="${type}"`);
385
+ })
375
386
  });
376
387
  }
377
388
  }
378
389
  };
379
390
  }
391
+ function getSuggest(getFix4) {
392
+ return BUTTON_TYPES.map((type) => ({
393
+ messageId: "addButtonType",
394
+ data: { type },
395
+ fix: getFix4(type)
396
+ }));
397
+ }
380
398
  var RULE_NAME7 = "no-missing-iframe-sandbox";
381
- var RULE_FEATURES7 = [];
382
- var validTypes = [
383
- "",
384
- "allow-downloads",
385
- "allow-downloads-without-user-activation",
386
- "allow-forms",
387
- "allow-modals",
388
- "allow-orientation-lock",
389
- "allow-pointer-lock",
390
- "allow-popups",
391
- "allow-popups-to-escape-sandbox",
392
- "allow-presentation",
393
- "allow-same-origin",
394
- "allow-scripts",
395
- "allow-storage-access-by-user-activation",
396
- "allow-top-navigation",
397
- "allow-top-navigation-by-user-activation",
398
- "allow-top-navigation-to-custom-protocols"
399
+ var RULE_FEATURES7 = [
400
+ "FIX"
399
401
  ];
400
- function hasValidSandBox(value) {
401
- return typeof value === "string" && value.split(" ").every((value2) => validTypes.some((valid) => valid === value2));
402
- }
403
402
  var no_missing_iframe_sandbox_default = createRule({
404
403
  meta: {
405
404
  type: "problem",
@@ -407,7 +406,10 @@ var no_missing_iframe_sandbox_default = createRule({
407
406
  description: "Enforces explicit `sandbox` attribute for `iframe` elements.",
408
407
  [Symbol.for("rule_features")]: RULE_FEATURES7
409
408
  },
409
+ fixable: "code",
410
+ hasSuggestions: true,
410
411
  messages: {
412
+ addIframeSandbox: "Add 'sandbox' attribute with value '{{value}}'.",
411
413
  noMissingIframeSandbox: "Add missing 'sandbox' attribute on 'iframe' component."
412
414
  },
413
415
  schema: []
@@ -436,17 +438,36 @@ function create7(context) {
436
438
  attributeNode,
437
439
  propNameOnJsx
438
440
  );
439
- if (attributeValue.kind === "some" && hasValidSandBox(attributeValue.value)) return;
440
- context.report({
441
- messageId: "noMissingIframeSandbox",
442
- node: attributeNode
443
- });
441
+ if (attributeValue.kind !== "some" || typeof attributeValue.value !== "string") {
442
+ context.report({
443
+ messageId: "noMissingIframeSandbox",
444
+ node: attributeNode,
445
+ suggest: [
446
+ {
447
+ messageId: "addIframeSandbox",
448
+ data: { value: "" },
449
+ fix(fixer) {
450
+ return fixer.replaceText(attributeNode, `${propNameOnJsx}=""`);
451
+ }
452
+ }
453
+ ]
454
+ });
455
+ }
444
456
  return;
445
457
  }
446
- if (!hasValidSandBox(customComponentProp?.defaultValue)) {
458
+ if (typeof customComponentProp?.defaultValue !== "string") {
447
459
  context.report({
448
460
  messageId: "noMissingIframeSandbox",
449
- node
461
+ node,
462
+ suggest: [
463
+ {
464
+ messageId: "addIframeSandbox",
465
+ data: { value: "" },
466
+ fix(fixer) {
467
+ return fixer.insertTextAfter(node.openingElement.name, ` ${propNameOnJsx}=""`);
468
+ }
469
+ }
470
+ ]
450
471
  });
451
472
  }
452
473
  }
@@ -1834,7 +1855,7 @@ function create14(context) {
1834
1855
  if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
1835
1856
  return attributeValue.value;
1836
1857
  }
1837
- return _;
1858
+ return unit;
1838
1859
  };
1839
1860
  if (getAttributeStringValue("target") !== "_blank") {
1840
1861
  return;
@@ -1965,9 +1986,10 @@ var no_void_elements_with_children_default = createRule({
1965
1986
  defaultOptions: []
1966
1987
  });
1967
1988
  function create16(context) {
1989
+ const resolver = createJsxElementResolver(context);
1968
1990
  return {
1969
1991
  JSXElement(node) {
1970
- const elementName = ER.getElementType(context, node);
1992
+ const { domElementType: elementName } = resolver.resolve(node);
1971
1993
  if (elementName.length === 0 || !voidElements.has(elementName)) {
1972
1994
  return;
1973
1995
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-dom",
3
- "version": "2.0.0-next.5",
3
+ "version": "2.0.0-next.51",
4
4
  "description": "ESLint React's ESLint plugin for React DOM related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -35,27 +35,27 @@
35
35
  "./package.json"
36
36
  ],
37
37
  "dependencies": {
38
- "@typescript-eslint/scope-manager": "^8.31.0",
39
- "@typescript-eslint/types": "^8.31.0",
40
- "@typescript-eslint/utils": "^8.31.0",
38
+ "@typescript-eslint/scope-manager": "^8.34.1",
39
+ "@typescript-eslint/types": "^8.34.1",
40
+ "@typescript-eslint/utils": "^8.34.1",
41
41
  "compare-versions": "^6.1.1",
42
42
  "string-ts": "^2.2.1",
43
- "ts-pattern": "^5.7.0",
44
- "@eslint-react/ast": "2.0.0-next.5",
45
- "@eslint-react/kit": "2.0.0-next.5",
46
- "@eslint-react/shared": "2.0.0-next.5",
47
- "@eslint-react/core": "2.0.0-next.5",
48
- "@eslint-react/var": "2.0.0-next.5",
49
- "@eslint-react/eff": "2.0.0-next.5"
43
+ "ts-pattern": "^5.7.1",
44
+ "@eslint-react/ast": "2.0.0-next.51",
45
+ "@eslint-react/core": "2.0.0-next.51",
46
+ "@eslint-react/kit": "2.0.0-next.51",
47
+ "@eslint-react/shared": "2.0.0-next.51",
48
+ "@eslint-react/eff": "2.0.0-next.51",
49
+ "@eslint-react/var": "2.0.0-next.51"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/react": "^19.1.2",
53
- "@types/react-dom": "^19.1.2",
54
- "tsup": "^8.4.0",
52
+ "@types/react": "^19.1.8",
53
+ "@types/react-dom": "^19.1.6",
54
+ "tsup": "^8.5.0",
55
55
  "@local/configs": "0.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "eslint": "^9.25.0",
58
+ "eslint": "^9.29.0",
59
59
  "typescript": "^4.9.5 || ^5.4.5"
60
60
  },
61
61
  "peerDependenciesMeta": {