eslint-plugin-react-x 1.36.1 → 1.36.2-beta.0

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.js CHANGED
@@ -136,7 +136,7 @@ var settings3 = {
136
136
 
137
137
  // package.json
138
138
  var name4 = "eslint-plugin-react-x";
139
- var version = "1.36.1";
139
+ var version = "1.36.2-beta.0";
140
140
  var createRule = shared.createRuleForPlugin("x");
141
141
 
142
142
  // src/rules/avoid-shorthand-boolean.ts
@@ -498,10 +498,7 @@ function create4(context) {
498
498
  if (!("value" in prop)) {
499
499
  continue;
500
500
  }
501
- const descriptors = getReportDescriptors(prop.value);
502
- for (const descriptor of descriptors) {
503
- context.report(descriptor);
504
- }
501
+ getReportDescriptors(prop.value).map(shared.report(context));
505
502
  }
506
503
  },
507
504
  "CallExpression:exit"() {
@@ -517,10 +514,7 @@ function create4(context) {
517
514
  if (node.value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
518
515
  return;
519
516
  }
520
- const descriptors = getReportDescriptors(node.value.expression);
521
- for (const descriptor of descriptors) {
522
- context.report(descriptor);
523
- }
517
+ getReportDescriptors(node.value.expression).map(shared.report(context));
524
518
  }
525
519
  };
526
520
  }
@@ -1646,11 +1640,7 @@ function create24(context) {
1646
1640
  return getReportDescriptor(initExpression);
1647
1641
  }).otherwise(() => eff._);
1648
1642
  }
1649
- const visitorFunction = (node) => {
1650
- const descriptor = getReportDescriptor(node);
1651
- if (descriptor == null) return;
1652
- context.report(descriptor);
1653
- };
1643
+ const visitorFunction = eff.flow(getReportDescriptor, shared.report(context));
1654
1644
  return {
1655
1645
  "JSXExpressionContainer > ConditionalExpression": visitorFunction,
1656
1646
  "JSXExpressionContainer > LogicalExpression": visitorFunction
@@ -1836,13 +1826,9 @@ function create27(context) {
1836
1826
  function checkBlockStatement(node) {
1837
1827
  const descriptors = [];
1838
1828
  for (const statement of AST11__namespace.getNestedReturnStatements(node)) {
1839
- if (statement.argument == null) {
1840
- continue;
1841
- }
1829
+ if (statement.argument == null) continue;
1842
1830
  const descriptor = checkIteratorElement(statement.argument);
1843
- if (descriptor != null) {
1844
- descriptors.push(descriptor);
1845
- }
1831
+ if (descriptor != null) descriptors.push(descriptor);
1846
1832
  }
1847
1833
  return descriptors;
1848
1834
  }
@@ -1858,7 +1844,7 @@ function create27(context) {
1858
1844
  const initialScope = context.sourceCode.getScope(node);
1859
1845
  for (const element of elements) {
1860
1846
  if (!JSX8__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
1861
- context.report({
1847
+ shared.report(context)({
1862
1848
  messageId: "missingKey",
1863
1849
  node: element
1864
1850
  });
@@ -1870,24 +1856,21 @@ function create27(context) {
1870
1856
  if (state.isWithinChildrenToArray) {
1871
1857
  return;
1872
1858
  }
1873
- const isMapCallLike = AST11__namespace.isMapCallLoose(node);
1874
- if (!isMapCallLike && !isArrayFromCall(node)) {
1859
+ const isMapCall = AST11__namespace.isMapCallLoose(node);
1860
+ if (!isMapCall && !isArrayFromCall(node)) {
1875
1861
  return;
1876
1862
  }
1877
- const fn = node.arguments[isMapCallLike ? 0 : 1];
1878
- if (fn?.type !== types.AST_NODE_TYPES.ArrowFunctionExpression && fn?.type !== types.AST_NODE_TYPES.FunctionExpression) {
1863
+ const fn = node.arguments[isMapCall ? 0 : 1];
1864
+ if (!AST11__namespace.isFunction(fn)) {
1879
1865
  return;
1880
1866
  }
1881
1867
  if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
1882
- for (const descriptor2 of checkBlockStatement(fn.body)) {
1883
- context.report(descriptor2);
1868
+ for (const descriptor of checkBlockStatement(fn.body)) {
1869
+ shared.report(context)(descriptor);
1884
1870
  }
1885
1871
  return;
1886
1872
  }
1887
- const descriptor = checkExpression(fn.body);
1888
- if (descriptor != null) {
1889
- context.report(descriptor);
1890
- }
1873
+ shared.report(context)(checkExpression(fn.body));
1891
1874
  },
1892
1875
  "CallExpression:exit"(node) {
1893
1876
  if (!core.isChildrenToArrayCall(context, node)) {
@@ -1900,7 +1883,7 @@ function create27(context) {
1900
1883
  return;
1901
1884
  }
1902
1885
  if (node.parent.type === types.AST_NODE_TYPES.ArrayExpression) {
1903
- context.report({
1886
+ shared.report(context)({
1904
1887
  messageId: "unexpectedFragmentSyntax",
1905
1888
  node
1906
1889
  });
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
1
+ import { createRuleForPlugin, report, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
2
2
  import * as JSX8 from '@eslint-react/jsx';
3
3
  import * as AST11 from '@eslint-react/ast';
4
4
  import { isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isComponentNameLoose, isCreateRefCall, isAssignmentToThisState, isForwardRefCall, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, getInstanceId, isInstanceIdEqual, DISPLAY_NAME_ASSIGNMENT_SELECTOR, isCreateContextCall, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideRenderMethod, isCreateElementCall, isReactHookCall, isReactHookCallWithNameAlias, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
5
- import { _, getOrUpdate, constTrue, constFalse, identity } from '@eslint-react/eff';
5
+ import { _, flow, getOrUpdate, constTrue, constFalse, identity } from '@eslint-react/eff';
6
6
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
7
7
  import { isMatching, match, P } from 'ts-pattern';
8
8
  import { compare } from 'compare-versions';
@@ -109,7 +109,7 @@ var settings3 = {
109
109
 
110
110
  // package.json
111
111
  var name4 = "eslint-plugin-react-x";
112
- var version = "1.36.1";
112
+ var version = "1.36.2-beta.0";
113
113
  var createRule = createRuleForPlugin("x");
114
114
 
115
115
  // src/rules/avoid-shorthand-boolean.ts
@@ -471,10 +471,7 @@ function create4(context) {
471
471
  if (!("value" in prop)) {
472
472
  continue;
473
473
  }
474
- const descriptors = getReportDescriptors(prop.value);
475
- for (const descriptor of descriptors) {
476
- context.report(descriptor);
477
- }
474
+ getReportDescriptors(prop.value).map(report(context));
478
475
  }
479
476
  },
480
477
  "CallExpression:exit"() {
@@ -490,10 +487,7 @@ function create4(context) {
490
487
  if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
491
488
  return;
492
489
  }
493
- const descriptors = getReportDescriptors(node.value.expression);
494
- for (const descriptor of descriptors) {
495
- context.report(descriptor);
496
- }
490
+ getReportDescriptors(node.value.expression).map(report(context));
497
491
  }
498
492
  };
499
493
  }
@@ -1619,11 +1613,7 @@ function create24(context) {
1619
1613
  return getReportDescriptor(initExpression);
1620
1614
  }).otherwise(() => _);
1621
1615
  }
1622
- const visitorFunction = (node) => {
1623
- const descriptor = getReportDescriptor(node);
1624
- if (descriptor == null) return;
1625
- context.report(descriptor);
1626
- };
1616
+ const visitorFunction = flow(getReportDescriptor, report(context));
1627
1617
  return {
1628
1618
  "JSXExpressionContainer > ConditionalExpression": visitorFunction,
1629
1619
  "JSXExpressionContainer > LogicalExpression": visitorFunction
@@ -1809,13 +1799,9 @@ function create27(context) {
1809
1799
  function checkBlockStatement(node) {
1810
1800
  const descriptors = [];
1811
1801
  for (const statement of AST11.getNestedReturnStatements(node)) {
1812
- if (statement.argument == null) {
1813
- continue;
1814
- }
1802
+ if (statement.argument == null) continue;
1815
1803
  const descriptor = checkIteratorElement(statement.argument);
1816
- if (descriptor != null) {
1817
- descriptors.push(descriptor);
1818
- }
1804
+ if (descriptor != null) descriptors.push(descriptor);
1819
1805
  }
1820
1806
  return descriptors;
1821
1807
  }
@@ -1831,7 +1817,7 @@ function create27(context) {
1831
1817
  const initialScope = context.sourceCode.getScope(node);
1832
1818
  for (const element of elements) {
1833
1819
  if (!JSX8.hasAttribute("key", element.openingElement.attributes, initialScope)) {
1834
- context.report({
1820
+ report(context)({
1835
1821
  messageId: "missingKey",
1836
1822
  node: element
1837
1823
  });
@@ -1843,24 +1829,21 @@ function create27(context) {
1843
1829
  if (state.isWithinChildrenToArray) {
1844
1830
  return;
1845
1831
  }
1846
- const isMapCallLike = AST11.isMapCallLoose(node);
1847
- if (!isMapCallLike && !isArrayFromCall(node)) {
1832
+ const isMapCall = AST11.isMapCallLoose(node);
1833
+ if (!isMapCall && !isArrayFromCall(node)) {
1848
1834
  return;
1849
1835
  }
1850
- const fn = node.arguments[isMapCallLike ? 0 : 1];
1851
- if (fn?.type !== AST_NODE_TYPES.ArrowFunctionExpression && fn?.type !== AST_NODE_TYPES.FunctionExpression) {
1836
+ const fn = node.arguments[isMapCall ? 0 : 1];
1837
+ if (!AST11.isFunction(fn)) {
1852
1838
  return;
1853
1839
  }
1854
1840
  if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
1855
- for (const descriptor2 of checkBlockStatement(fn.body)) {
1856
- context.report(descriptor2);
1841
+ for (const descriptor of checkBlockStatement(fn.body)) {
1842
+ report(context)(descriptor);
1857
1843
  }
1858
1844
  return;
1859
1845
  }
1860
- const descriptor = checkExpression(fn.body);
1861
- if (descriptor != null) {
1862
- context.report(descriptor);
1863
- }
1846
+ report(context)(checkExpression(fn.body));
1864
1847
  },
1865
1848
  "CallExpression:exit"(node) {
1866
1849
  if (!isChildrenToArrayCall(context, node)) {
@@ -1873,7 +1856,7 @@ function create27(context) {
1873
1856
  return;
1874
1857
  }
1875
1858
  if (node.parent.type === AST_NODE_TYPES.ArrayExpression) {
1876
- context.report({
1859
+ report(context)({
1877
1860
  messageId: "unexpectedFragmentSyntax",
1878
1861
  node
1879
1862
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.36.1",
3
+ "version": "1.36.2-beta.0",
4
4
  "description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -49,12 +49,12 @@
49
49
  "compare-versions": "^6.1.1",
50
50
  "string-ts": "^2.2.1",
51
51
  "ts-pattern": "^5.6.2",
52
- "@eslint-react/ast": "1.36.1",
53
- "@eslint-react/core": "1.36.1",
54
- "@eslint-react/eff": "1.36.1",
55
- "@eslint-react/jsx": "1.36.1",
56
- "@eslint-react/shared": "1.36.1",
57
- "@eslint-react/var": "1.36.1"
52
+ "@eslint-react/ast": "1.36.2-beta.0",
53
+ "@eslint-react/shared": "1.36.2-beta.0",
54
+ "@eslint-react/var": "1.36.2-beta.0",
55
+ "@eslint-react/core": "1.36.2-beta.0",
56
+ "@eslint-react/eff": "1.36.2-beta.0",
57
+ "@eslint-react/jsx": "1.36.2-beta.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/react": "^19.0.11",