eslint-plugin-react-naming-convention 2.7.4-beta.4 → 2.7.4-beta.6

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 (3) hide show
  1. package/README.md +9 -0
  2. package/dist/index.js +31 -31
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -38,6 +38,15 @@ export default defineConfig(
38
38
  );
39
39
  ```
40
40
 
41
+ > [!NOTE]
42
+ > Naming convention rules enforce consistent naming patterns for `React` entities.
43
+
44
+ - [`component-name`](./naming-convention-component-name) - Enforces naming conventions for components (⚙️ Configurable)
45
+ - [`context-name`](./naming-convention-context-name) - Enforces context names ending with `Context` suffix
46
+ - [`filename`](./naming-convention-filename) - Enforces consistent file naming (⚙️ Configurable)
47
+ - [`filename-extension`](./naming-convention-filename-extension) - Enforces `JSX` file extensions (⚙️ Configurable)
48
+ - [`use-state`](./naming-convention-use-state) - Enforces symmetric naming of `useState` pairs (e.g., `[value, setValue]`)
49
+
41
50
  ## Rules
42
51
 
43
52
  <https://eslint-react.xyz/docs/rules/overview#naming-convention-rules>
package/dist/index.js CHANGED
@@ -14,9 +14,9 @@ import * as AST from "@eslint-react/ast";
14
14
  var __defProp = Object.defineProperty;
15
15
  var __exportAll = (all, symbols) => {
16
16
  let target = {};
17
- for (var name$2 in all) {
18
- __defProp(target, name$2, {
19
- get: all[name$2],
17
+ for (var name in all) {
18
+ __defProp(target, name, {
19
+ get: all[name],
20
20
  enumerable: true
21
21
  });
22
22
  }
@@ -42,7 +42,7 @@ const rules = {
42
42
  //#endregion
43
43
  //#region package.json
44
44
  var name = "eslint-plugin-react-naming-convention";
45
- var version = "2.7.4-beta.4";
45
+ var version = "2.7.4-beta.6";
46
46
 
47
47
  //#endregion
48
48
  //#region src/utils/create-rule.ts
@@ -98,24 +98,24 @@ function create$5(context) {
98
98
  const fCollector = useComponentCollector(context);
99
99
  const cCollector = useComponentCollectorLegacy(context);
100
100
  return defineRuleListener(fCollector.visitor, cCollector.visitor, { "Program:exit"(program) {
101
- for (const { id, name: name$2, node: component } of fCollector.ctx.getAllComponents(program)) {
102
- if (isValidName(name$2, options)) continue;
101
+ for (const { id, name, node: component } of fCollector.ctx.getAllComponents(program)) {
102
+ if (isValidName(name, options)) continue;
103
103
  context.report({
104
104
  messageId: "invalidComponentName",
105
105
  node: id ?? component,
106
106
  data: {
107
- name: name$2,
107
+ name,
108
108
  rule
109
109
  }
110
110
  });
111
111
  }
112
- for (const { id, name: name$2, node } of cCollector.ctx.getAllComponents(program)) {
113
- if (isValidName(name$2, options)) continue;
112
+ for (const { id, name, node } of cCollector.ctx.getAllComponents(program)) {
113
+ if (isValidName(name, options)) continue;
114
114
  context.report({
115
115
  messageId: "invalidComponentName",
116
116
  node: id ?? node,
117
117
  data: {
118
- name: name$2,
118
+ name,
119
119
  rule
120
120
  }
121
121
  });
@@ -134,10 +134,10 @@ function normalizeOptions(options) {
134
134
  }
135
135
  };
136
136
  }
137
- function isValidName(name$2, options) {
138
- if (name$2 == null) return true;
139
- if (options.excepts.some((regex) => regex.test(name$2))) return true;
140
- const normalized = name$2.split(".").at(-1) ?? name$2;
137
+ function isValidName(name, options) {
138
+ if (name == null) return true;
139
+ if (options.excepts.some((regex) => regex.test(name))) return true;
140
+ const normalized = name.split(".").at(-1) ?? name;
141
141
  switch (options.rule) {
142
142
  case "CONSTANT_CASE": return RE_CONSTANT_CASE.test(normalized);
143
143
  case "PascalCase":
@@ -162,19 +162,19 @@ var context_name_default = createRule({
162
162
  });
163
163
  function create$4(context) {
164
164
  if (!context.sourceCode.text.includes("createContext")) return {};
165
- const { version: version$1 } = getSettingsFromContext(context);
166
- if (compare(version$1, "19.0.0", "<")) return {};
165
+ const { version } = getSettingsFromContext(context);
166
+ if (compare(version, "19.0.0", "<")) return {};
167
167
  return { CallExpression(node) {
168
168
  if (!isCreateContextCall(context, node)) return;
169
- const [id, name$2] = match(findEnclosingAssignmentTarget(node)).with({
169
+ const [id, name] = match(findEnclosingAssignmentTarget(node)).with({
170
170
  type: AST_NODE_TYPES.Identifier,
171
171
  name: P.string
172
- }, (id$1) => [id$1, id$1.name]).with({
172
+ }, (id) => [id, id.name]).with({
173
173
  type: AST_NODE_TYPES.MemberExpression,
174
174
  property: { name: P.string }
175
- }, (id$1) => [id$1, id$1.property.name]).otherwise(() => [null, null]);
175
+ }, (id) => [id, id.property.name]).otherwise(() => [null, null]);
176
176
  if (id == null) return;
177
- if (isComponentName(name$2) && name$2.endsWith("Context")) return;
177
+ if (isComponentName(name) && name.endsWith("Context")) return;
178
178
  context.report({
179
179
  messageId: "invalidContextName",
180
180
  node: id
@@ -249,14 +249,14 @@ function create$3(context) {
249
249
  const options = context.options[0] ?? defaultOptions$2[0];
250
250
  const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
251
251
  const excepts = typeof options === "string" ? [] : (options.excepts ?? []).map((s) => toRegExp(s));
252
- function validate(name$2, casing = rule, ignores = excepts) {
253
- if (ignores.some((pattern) => pattern.test(name$2))) return true;
254
- const filteredName = name$2.match(/[\w.-]/gu)?.join("") ?? "";
252
+ function validate(name, casing = rule, ignores = excepts) {
253
+ if (ignores.some((pattern) => pattern.test(name))) return true;
254
+ const filteredName = name.match(/[\w.-]/gu)?.join("") ?? "";
255
255
  if (filteredName.length === 0) return true;
256
256
  return match(casing).with("PascalCase", () => RE_PASCAL_CASE.test(filteredName)).with("camelCase", () => RE_CAMEL_CASE.test(filteredName)).with("kebab-case", () => RE_KEBAB_CASE.test(filteredName)).with("snake_case", () => RE_SNAKE_CASE.test(filteredName)).exhaustive();
257
257
  }
258
- function getSuggestion(name$2, casing = rule) {
259
- return match(casing).with("PascalCase", () => pascalCase(name$2)).with("camelCase", () => camelCase(name$2)).with("kebab-case", () => kebabCase(name$2)).with("snake_case", () => snakeCase(name$2)).exhaustive();
258
+ function getSuggestion(name, casing = rule) {
259
+ return match(casing).with("PascalCase", () => pascalCase(name)).with("camelCase", () => camelCase(name)).with("kebab-case", () => kebabCase(name)).with("snake_case", () => snakeCase(name)).exhaustive();
260
260
  }
261
261
  return { Program(node) {
262
262
  const [basename = "", ...rest] = path.basename(context.filename).split(".");
@@ -378,15 +378,15 @@ function create$1(context) {
378
378
  return { CallExpression(node) {
379
379
  if (!isUseRefCall(node)) return;
380
380
  if (AST.getUnderlyingExpression(node.parent).type === AST_NODE_TYPES.MemberExpression) return;
381
- const [id, name$2] = match(findEnclosingAssignmentTarget(node)).with({
381
+ const [id, name] = match(findEnclosingAssignmentTarget(node)).with({
382
382
  type: AST_NODE_TYPES.Identifier,
383
383
  name: P.string
384
- }, (id$1) => [id$1, id$1.name]).with({
384
+ }, (id) => [id, id.name]).with({
385
385
  type: AST_NODE_TYPES.MemberExpression,
386
386
  property: { name: P.string }
387
- }, (id$1) => [id$1, id$1.property.name]).otherwise(() => [null, null]);
387
+ }, (id) => [id, id.property.name]).otherwise(() => [null, null]);
388
388
  if (id == null) return;
389
- if (name$2.endsWith("Ref") || name$2 === "ref") return;
389
+ if (name.endsWith("Ref") || name === "ref") return;
390
390
  context.report({
391
391
  messageId: "invalidRefName",
392
392
  node: id
@@ -460,7 +460,7 @@ function create(context) {
460
460
  return;
461
461
  }
462
462
  if (setter == null || !enforceSetterName) return;
463
- const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id$1) => id$1.name).otherwise(() => null);
463
+ const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id) => id.name).otherwise(() => null);
464
464
  if (setterName == null || !setterName.startsWith("set")) {
465
465
  context.report({
466
466
  messageId: "invalidSetterName",
@@ -468,7 +468,7 @@ function create(context) {
468
468
  });
469
469
  return;
470
470
  }
471
- const valueName = match(value).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name$2 }) => snakeCase(name$2)).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties }) => {
471
+ const valueName = match(value).with({ type: AST_NODE_TYPES.Identifier }, ({ name }) => snakeCase(name)).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties }) => {
472
472
  return properties.reduce((acc, prop) => {
473
473
  if (prop.type === AST_NODE_TYPES.Property && prop.key.type === AST_NODE_TYPES.Identifier) return [...acc, prop.key.name];
474
474
  return acc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-naming-convention",
3
- "version": "2.7.4-beta.4",
3
+ "version": "2.7.4-beta.6",
4
4
  "description": "ESLint React's ESLint plugin for naming convention related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -45,16 +45,16 @@
45
45
  "compare-versions": "^6.1.1",
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "2.7.4-beta.4",
49
- "@eslint-react/eff": "2.7.4-beta.4",
50
- "@eslint-react/core": "2.7.4-beta.4",
51
- "@eslint-react/shared": "2.7.4-beta.4",
52
- "@eslint-react/var": "2.7.4-beta.4"
48
+ "@eslint-react/ast": "2.7.4-beta.6",
49
+ "@eslint-react/core": "2.7.4-beta.6",
50
+ "@eslint-react/eff": "2.7.4-beta.6",
51
+ "@eslint-react/shared": "2.7.4-beta.6",
52
+ "@eslint-react/var": "2.7.4-beta.6"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.9",
56
56
  "@types/react-dom": "^19.2.3",
57
- "tsdown": "^0.20.0-beta.4",
57
+ "tsdown": "^0.20.1",
58
58
  "@local/configs": "0.0.0"
59
59
  },
60
60
  "peerDependencies": {