eslint-plugin-react-naming-convention 2.5.1 → 2.5.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.
Files changed (2) hide show
  1. package/dist/index.js +17 -16
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -2,11 +2,11 @@ import { RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAK
2
2
  import * as AST from "@eslint-react/ast";
3
3
  import { getInstanceId, isComponentName, isCreateContextCall, isUseRefCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy } from "@eslint-react/core";
4
4
  import { ESLintUtils } from "@typescript-eslint/utils";
5
- import { identity, isObject } from "@eslint-react/eff";
6
5
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
7
6
  import { P, match } from "ts-pattern";
8
7
  import path from "node:path";
9
8
  import { camelCase, kebabCase, pascalCase, snakeCase } from "string-ts";
9
+ import { isObject } from "@eslint-react/eff";
10
10
 
11
11
  //#region rolldown:runtime
12
12
  var __defProp = Object.defineProperty;
@@ -40,7 +40,7 @@ const rules = {
40
40
  //#endregion
41
41
  //#region package.json
42
42
  var name = "eslint-plugin-react-naming-convention";
43
- var version = "2.5.1";
43
+ var version = "2.5.2-beta.0";
44
44
 
45
45
  //#endregion
46
46
  //#region src/utils/create-rule.ts
@@ -172,16 +172,15 @@ function create$4(context) {
172
172
  if (!context.sourceCode.text.includes("createContext")) return {};
173
173
  return { CallExpression(node) {
174
174
  if (!isCreateContextCall(context, node)) return;
175
- const id = getInstanceId(node);
176
- if (id == null) return;
177
- const name$2 = match(id).with({
175
+ const [id, name$2] = match(getInstanceId(node)).with({
178
176
  type: AST_NODE_TYPES.Identifier,
179
- name: P.select()
180
- }, identity).with({
177
+ name: P.string
178
+ }, (id$1) => [id$1, id$1.name]).with({
181
179
  type: AST_NODE_TYPES.MemberExpression,
182
- property: { name: P.select(P.string) }
183
- }, identity).otherwise(() => null);
184
- if (name$2 != null && isComponentName(name$2) && name$2.endsWith("Context")) return;
180
+ property: { name: P.string }
181
+ }, (id$1) => [id$1, id$1.property.name]).otherwise(() => [null, null]);
182
+ if (id == null) return;
183
+ if (isComponentName(name$2) && name$2.endsWith("Context")) return;
185
184
  context.report({
186
185
  messageId: "invalidContextName",
187
186
  node: id
@@ -385,13 +384,15 @@ function create$1(context) {
385
384
  return { CallExpression(node) {
386
385
  if (!isUseRefCall(node)) return;
387
386
  if (AST.getUnderlyingExpression(node.parent).type === AST_NODE_TYPES.MemberExpression) return;
388
- const id = getInstanceId(node);
389
- if (id == null) return;
390
- const name$2 = match(id).with({
387
+ const [id, name$2] = match(getInstanceId(node)).with({
391
388
  type: AST_NODE_TYPES.Identifier,
392
- name: P.select()
393
- }, identity).otherwise(() => null);
394
- if (name$2 != null && name$2.endsWith("Ref")) return;
389
+ name: P.string
390
+ }, (id$1) => [id$1, id$1.name]).with({
391
+ type: AST_NODE_TYPES.MemberExpression,
392
+ property: { name: P.string }
393
+ }, (id$1) => [id$1, id$1.property.name]).otherwise(() => [null, null]);
394
+ if (id == null) return;
395
+ if (name$2.endsWith("Ref")) return;
395
396
  context.report({
396
397
  messageId: "invalidRefName",
397
398
  node: id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-naming-convention",
3
- "version": "2.5.1",
3
+ "version": "2.5.2-beta.0",
4
4
  "description": "ESLint React's ESLint plugin for naming convention related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -44,11 +44,11 @@
44
44
  "@typescript-eslint/utils": "^8.51.0",
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-pattern": "^5.9.0",
47
- "@eslint-react/ast": "2.5.1",
48
- "@eslint-react/eff": "2.5.1",
49
- "@eslint-react/shared": "2.5.1",
50
- "@eslint-react/var": "2.5.1",
51
- "@eslint-react/core": "2.5.1"
47
+ "@eslint-react/ast": "2.5.2-beta.0",
48
+ "@eslint-react/core": "2.5.2-beta.0",
49
+ "@eslint-react/eff": "2.5.2-beta.0",
50
+ "@eslint-react/shared": "2.5.2-beta.0",
51
+ "@eslint-react/var": "2.5.2-beta.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/react": "^19.2.7",