eslint-plugin-react-x 5.30.0-beta.8 → 5.30.0-beta.9

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 +39 -47
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { DEFAULT_ESLINT_REACT_SETTINGS, getSettingsFromContext, toRegExp } from
2
2
  import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
3
3
  import { Analyze, Check, Collect, Compare, Extract, Traverse } from "@eslint-react/ast";
4
4
  import * as core from "@eslint-react/core";
5
- import { complete, getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
5
+ import { getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
6
6
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
7
7
  import { P, isMatching, match } from "ts-pattern";
8
8
  import { isAssignmentTargetEqual, isInitializedFromReact, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin, resolveOriginChain } from "@eslint-react/var";
@@ -130,7 +130,7 @@ const rules$6 = {
130
130
  };
131
131
  // package.json
132
132
  var name$6 = "eslint-plugin-react-x";
133
- var version = "5.30.0-beta.8";
133
+ var version = "5.30.0-beta.9";
134
134
  // src/utils/create-rule.ts
135
135
  function getDocsUrl(ruleName) {
136
136
  return `https://eslint-react.xyz/docs/rules/${ruleName}`;
@@ -3285,31 +3285,28 @@ function getHumanReadableKind(node) {
3285
3285
  }
3286
3286
  return toLowerCase(delimiterCase(node.type, " "));
3287
3287
  }
3288
- // src/rules/no-unstable-default-props/no-unstable-default-props.ts
3289
- const RULE_NAME$12 = "no-unstable-default-props";
3290
- const defaultOptions$1 = [{ safeDefaultProps: [] }];
3291
- const schema$1 = [{
3292
- type: "object",
3293
- additionalProperties: false,
3294
- properties: { safeDefaultProps: {
3295
- type: "array",
3296
- description: "Property names or patterns that are safe to use as default props.",
3297
- items: { type: "string" }
3298
- } }
3299
- }];
3300
3288
  var no_unstable_default_props_default = createRule({
3301
3289
  meta: {
3302
3290
  type: "problem",
3303
- defaultOptions: [...defaultOptions$1],
3291
+ defaultOptions: [{}],
3304
3292
  docs: { description: "Prevents using referential-type values as default props in object destructuring." },
3305
3293
  messages: { default: "A/an '{{kind}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{kind}}'." },
3306
- schema: schema$1
3294
+ schema: [{
3295
+ type: "object",
3296
+ additionalProperties: false,
3297
+ properties: { safeDefaultProps: {
3298
+ type: "array",
3299
+ description: "Property names or patterns that are safe to use as default props.",
3300
+ items: { type: "string" }
3301
+ } }
3302
+ }]
3307
3303
  },
3308
- name: RULE_NAME$12,
3304
+ name: "no-unstable-default-props",
3309
3305
  create: create$12
3310
3306
  });
3311
3307
  function create$12(context) {
3312
- const { safeDefaultProps } = complete(context.options[0], defaultOptions$1[0]);
3308
+ const options = { ...context.options[0] ?? {} };
3309
+ const safeDefaultProps = options.safeDefaultProps ??= [];
3313
3310
  const { compilationMode } = getSettingsFromContext(context);
3314
3311
  if (compilationMode === "infer" || compilationMode === "all") return {};
3315
3312
  if (compilationMode === "annotation" && context.sourceCode.ast.body.some((stmt) => Check.isDirective(stmt, "use memo"))) return {};
@@ -8393,48 +8390,43 @@ const LAZY_INIT_ALLOW_LIST = [
8393
8390
  "String",
8394
8391
  "Number"
8395
8392
  ];
8396
- // src/rules/use-state/use-state.ts
8397
- const RULE_NAME = "use-state";
8398
- const defaultOptions = [{
8399
- enforceAssignment: true,
8400
- enforceLazyInitialization: true,
8401
- enforceSetterName: true
8402
- }];
8403
- const schema = [{
8404
- type: "object",
8405
- additionalProperties: false,
8406
- properties: {
8407
- enforceAssignment: {
8408
- type: "boolean",
8409
- description: "Require the useState result to be assigned to a destructured value/setter pair."
8410
- },
8411
- enforceLazyInitialization: {
8412
- type: "boolean",
8413
- description: "Require expensive initializers to be wrapped in a lazy initializer function."
8414
- },
8415
- enforceSetterName: {
8416
- type: "boolean",
8417
- description: "Require the setter name to match the state value name."
8418
- }
8419
- }
8420
- }];
8421
8393
  var use_state_default = createRule({
8422
8394
  meta: {
8423
8395
  type: "suggestion",
8424
- defaultOptions: [...defaultOptions],
8396
+ defaultOptions: [{}],
8425
8397
  docs: { description: "Enforces correct usage of 'useState', including destructuring, symmetric naming of the value and setter, and wrapping expensive initializers in a lazy initializer function." },
8426
8398
  messages: {
8427
8399
  "invalid-initialization": "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'.",
8428
8400
  "invalid-assignment": "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
8429
8401
  "invalid-setter-name": "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'."
8430
8402
  },
8431
- schema
8403
+ schema: [{
8404
+ type: "object",
8405
+ additionalProperties: false,
8406
+ properties: {
8407
+ enforceAssignment: {
8408
+ type: "boolean",
8409
+ description: "Require the useState result to be assigned to a destructured value/setter pair."
8410
+ },
8411
+ enforceLazyInitialization: {
8412
+ type: "boolean",
8413
+ description: "Require expensive initializers to be wrapped in a lazy initializer function."
8414
+ },
8415
+ enforceSetterName: {
8416
+ type: "boolean",
8417
+ description: "Require the setter name to match the state value name."
8418
+ }
8419
+ }
8420
+ }]
8432
8421
  },
8433
- name: RULE_NAME,
8422
+ name: "use-state",
8434
8423
  create
8435
8424
  });
8436
8425
  function create(context) {
8437
- const { enforceAssignment, enforceLazyInitialization, enforceSetterName } = complete(context.options[0], defaultOptions[0]);
8426
+ const options = { ...context.options[0] ?? {} };
8427
+ const enforceAssignment = options.enforceAssignment ??= true;
8428
+ const enforceLazyInitialization = options.enforceLazyInitialization ??= true;
8429
+ const enforceSetterName = options.enforceSetterName ??= true;
8438
8430
  const { additionalStateHooks } = getSettingsFromContext(context);
8439
8431
  return { CallExpression(node) {
8440
8432
  if (!core.isUseStateLikeCall(node, additionalStateHooks)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.30.0-beta.8",
3
+ "version": "5.30.0-beta.9",
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",
@@ -36,12 +36,12 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@eslint-react/ast": "5.30.0-beta.8",
40
- "@eslint-react/core": "5.30.0-beta.8",
41
- "@eslint-react/eslint": "5.30.0-beta.8",
42
- "@eslint-react/jsx": "5.30.0-beta.8",
43
- "@eslint-react/shared": "5.30.0-beta.8",
44
- "@eslint-react/var": "5.30.0-beta.8",
39
+ "@eslint-react/ast": "5.30.0-beta.9",
40
+ "@eslint-react/core": "5.30.0-beta.9",
41
+ "@eslint-react/eslint": "5.30.0-beta.9",
42
+ "@eslint-react/jsx": "5.30.0-beta.9",
43
+ "@eslint-react/shared": "5.30.0-beta.9",
44
+ "@eslint-react/var": "5.30.0-beta.9",
45
45
  "@typescript-eslint/scope-manager": "^8.72.1",
46
46
  "@typescript-eslint/types": "^8.72.1",
47
47
  "@typescript-eslint/utils": "^8.72.1",