eslint-plugin-react-naming-convention 1.23.2-next.6 → 1.23.3-next.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
@@ -36,7 +36,7 @@ var path__default = /*#__PURE__*/_interopDefault(path);
36
36
 
37
37
  // package.json
38
38
  var name = "eslint-plugin-react-naming-convention";
39
- var version = "1.23.2-next.6";
39
+ var version = "1.23.3-next.0";
40
40
  var createRule = shared.createRuleForPlugin("naming-convention");
41
41
 
42
42
  // src/rules/component-name.ts
@@ -79,15 +79,21 @@ var schema = [
79
79
  ];
80
80
  function normalizeOptions(options) {
81
81
  const [opts] = options;
82
- if (eff.isNullable(opts)) return defaultOptions[0];
83
- if (eff.isString(opts)) return { ...defaultOptions[0], rule: opts };
82
+ if (eff.isNullable(opts)) {
83
+ return defaultOptions[0];
84
+ }
85
+ if (eff.isString(opts)) {
86
+ return { ...defaultOptions[0], rule: opts };
87
+ }
84
88
  return {
85
89
  ...opts,
86
90
  excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
87
91
  };
88
92
  }
89
93
  function validate(name2, options) {
90
- if (options.excepts.some((regex) => regex.test(name2))) return true;
94
+ if (options.excepts.some((regex) => regex.test(name2))) {
95
+ return true;
96
+ }
91
97
  let normalized = name2.normalize("NFKD").replace(/[\u0300-\u036F]/g, "");
92
98
  normalized = normalized.split(".").at(-1) ?? normalized;
93
99
  if (options.allowNamespace) {
@@ -97,7 +103,9 @@ function validate(name2, options) {
97
103
  normalized = normalized.replace(/^_/, "");
98
104
  }
99
105
  return tsPattern.match(options.rule).with("CONSTANT_CASE", () => shared.RE_CONSTANT_CASE.test(normalized)).with("PascalCase", () => {
100
- if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) return options.allowAllCaps;
106
+ if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
107
+ return options.allowAllCaps;
108
+ }
101
109
  return shared.RE_PASCAL_CASE.test(normalized);
102
110
  }).otherwise(eff.F.constFalse);
103
111
  }
@@ -123,8 +131,12 @@ var component_name_default = createRule({
123
131
  ...collectorLegacy.listeners,
124
132
  JSXOpeningElement(node) {
125
133
  const name2 = JSX__namespace.getElementName(node);
126
- if (/^[a-z]/u.test(name2)) return;
127
- if (validate(name2, options)) return;
134
+ if (/^[a-z]/u.test(name2)) {
135
+ return;
136
+ }
137
+ if (validate(name2, options)) {
138
+ return;
139
+ }
128
140
  context.report({
129
141
  messageId: "componentName",
130
142
  node,
@@ -138,9 +150,13 @@ var component_name_default = createRule({
138
150
  const classComponents = collectorLegacy.ctx.getAllComponents(node);
139
151
  for (const { node: component } of functionComponents.values()) {
140
152
  const mbId = AST__namespace.getFunctionIdentifier(component);
141
- if (eff.O.isNone(mbId)) continue;
153
+ if (eff.O.isNone(mbId)) {
154
+ continue;
155
+ }
142
156
  const id = mbId.value;
143
- if (validate(id.name, options)) continue;
157
+ if (validate(id.name, options)) {
158
+ continue;
159
+ }
144
160
  context.report({
145
161
  messageId: "componentName",
146
162
  node: id,
@@ -242,7 +258,9 @@ var filename_default = createRule({
242
258
  context.report({ messageId: "filenameEmpty", node });
243
259
  return;
244
260
  }
245
- if (validate2(basename)) return;
261
+ if (validate2(basename)) {
262
+ return;
263
+ }
246
264
  context.report({
247
265
  messageId: "filenameCaseMismatchSuggestion",
248
266
  node,
@@ -332,7 +350,9 @@ var filename_extension_default = createRule({
332
350
  }
333
351
  const hasCode = node.body.length > 0;
334
352
  const ignoreFilesWithoutCode = eff.isObject(options) && options.ignoreFilesWithoutCode;
335
- if (!hasCode && ignoreFilesWithoutCode) return;
353
+ if (!hasCode && ignoreFilesWithoutCode) {
354
+ return;
355
+ }
336
356
  if (!hasJSXNode && isJSXExt && allow === "as-needed") {
337
357
  context.report({
338
358
  messageId: "filenameExtensionUnexpected",
@@ -373,10 +393,16 @@ var use_state_default = createRule({
373
393
  "Program:exit"(node) {
374
394
  const components = ctx.getAllComponents(node);
375
395
  for (const { hookCalls } of components.values()) {
376
- if (hookCalls.length === 0) continue;
396
+ if (hookCalls.length === 0) {
397
+ continue;
398
+ }
377
399
  for (const hookCall of hookCalls) {
378
- if (!core.isUseStateCall(hookCall, context) && !alias.some(core.isReactHookCallWithNameLoose(hookCall))) continue;
379
- if (hookCall.parent.type !== types.AST_NODE_TYPES.VariableDeclarator) continue;
400
+ if (!core.isUseStateCall(hookCall, context) && !alias.some(core.isReactHookCallWithNameLoose(hookCall))) {
401
+ continue;
402
+ }
403
+ if (hookCall.parent.type !== types.AST_NODE_TYPES.VariableDeclarator) {
404
+ continue;
405
+ }
380
406
  const { id } = hookCall.parent;
381
407
  const descriptor = eff.O.some({ messageId: "useState", node: id });
382
408
  eff.F.pipe(
@@ -390,7 +416,9 @@ var use_state_default = createRule({
390
416
  }
391
417
  const [stateName, setStateName] = [state.name, setState.name];
392
418
  const expectedSetterName = `set${stringTs.capitalize(stateName)}`;
393
- if (setStateName === expectedSetterName) return eff.O.none();
419
+ if (setStateName === expectedSetterName) {
420
+ return eff.O.none();
421
+ }
394
422
  return descriptor;
395
423
  }).otherwise(eff.O.none),
396
424
  eff.O.map(context.report)
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';
10
10
 
11
11
  // package.json
12
12
  var name = "eslint-plugin-react-naming-convention";
13
- var version = "1.23.2-next.6";
13
+ var version = "1.23.3-next.0";
14
14
  var createRule = createRuleForPlugin("naming-convention");
15
15
 
16
16
  // src/rules/component-name.ts
@@ -53,15 +53,21 @@ var schema = [
53
53
  ];
54
54
  function normalizeOptions(options) {
55
55
  const [opts] = options;
56
- if (isNullable(opts)) return defaultOptions[0];
57
- if (isString(opts)) return { ...defaultOptions[0], rule: opts };
56
+ if (isNullable(opts)) {
57
+ return defaultOptions[0];
58
+ }
59
+ if (isString(opts)) {
60
+ return { ...defaultOptions[0], rule: opts };
61
+ }
58
62
  return {
59
63
  ...opts,
60
64
  excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
61
65
  };
62
66
  }
63
67
  function validate(name2, options) {
64
- if (options.excepts.some((regex) => regex.test(name2))) return true;
68
+ if (options.excepts.some((regex) => regex.test(name2))) {
69
+ return true;
70
+ }
65
71
  let normalized = name2.normalize("NFKD").replace(/[\u0300-\u036F]/g, "");
66
72
  normalized = normalized.split(".").at(-1) ?? normalized;
67
73
  if (options.allowNamespace) {
@@ -71,7 +77,9 @@ function validate(name2, options) {
71
77
  normalized = normalized.replace(/^_/, "");
72
78
  }
73
79
  return match(options.rule).with("CONSTANT_CASE", () => RE_CONSTANT_CASE.test(normalized)).with("PascalCase", () => {
74
- if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) return options.allowAllCaps;
80
+ if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
81
+ return options.allowAllCaps;
82
+ }
75
83
  return RE_PASCAL_CASE.test(normalized);
76
84
  }).otherwise(F.constFalse);
77
85
  }
@@ -97,8 +105,12 @@ var component_name_default = createRule({
97
105
  ...collectorLegacy.listeners,
98
106
  JSXOpeningElement(node) {
99
107
  const name2 = JSX.getElementName(node);
100
- if (/^[a-z]/u.test(name2)) return;
101
- if (validate(name2, options)) return;
108
+ if (/^[a-z]/u.test(name2)) {
109
+ return;
110
+ }
111
+ if (validate(name2, options)) {
112
+ return;
113
+ }
102
114
  context.report({
103
115
  messageId: "componentName",
104
116
  node,
@@ -112,9 +124,13 @@ var component_name_default = createRule({
112
124
  const classComponents = collectorLegacy.ctx.getAllComponents(node);
113
125
  for (const { node: component } of functionComponents.values()) {
114
126
  const mbId = AST.getFunctionIdentifier(component);
115
- if (O.isNone(mbId)) continue;
127
+ if (O.isNone(mbId)) {
128
+ continue;
129
+ }
116
130
  const id = mbId.value;
117
- if (validate(id.name, options)) continue;
131
+ if (validate(id.name, options)) {
132
+ continue;
133
+ }
118
134
  context.report({
119
135
  messageId: "componentName",
120
136
  node: id,
@@ -216,7 +232,9 @@ var filename_default = createRule({
216
232
  context.report({ messageId: "filenameEmpty", node });
217
233
  return;
218
234
  }
219
- if (validate2(basename)) return;
235
+ if (validate2(basename)) {
236
+ return;
237
+ }
220
238
  context.report({
221
239
  messageId: "filenameCaseMismatchSuggestion",
222
240
  node,
@@ -306,7 +324,9 @@ var filename_extension_default = createRule({
306
324
  }
307
325
  const hasCode = node.body.length > 0;
308
326
  const ignoreFilesWithoutCode = isObject(options) && options.ignoreFilesWithoutCode;
309
- if (!hasCode && ignoreFilesWithoutCode) return;
327
+ if (!hasCode && ignoreFilesWithoutCode) {
328
+ return;
329
+ }
310
330
  if (!hasJSXNode && isJSXExt && allow === "as-needed") {
311
331
  context.report({
312
332
  messageId: "filenameExtensionUnexpected",
@@ -347,10 +367,16 @@ var use_state_default = createRule({
347
367
  "Program:exit"(node) {
348
368
  const components = ctx.getAllComponents(node);
349
369
  for (const { hookCalls } of components.values()) {
350
- if (hookCalls.length === 0) continue;
370
+ if (hookCalls.length === 0) {
371
+ continue;
372
+ }
351
373
  for (const hookCall of hookCalls) {
352
- if (!isUseStateCall(hookCall, context) && !alias.some(isReactHookCallWithNameLoose(hookCall))) continue;
353
- if (hookCall.parent.type !== AST_NODE_TYPES.VariableDeclarator) continue;
374
+ if (!isUseStateCall(hookCall, context) && !alias.some(isReactHookCallWithNameLoose(hookCall))) {
375
+ continue;
376
+ }
377
+ if (hookCall.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
378
+ continue;
379
+ }
354
380
  const { id } = hookCall.parent;
355
381
  const descriptor = O.some({ messageId: "useState", node: id });
356
382
  F.pipe(
@@ -364,7 +390,9 @@ var use_state_default = createRule({
364
390
  }
365
391
  const [stateName, setStateName] = [state.name, setState.name];
366
392
  const expectedSetterName = `set${capitalize(stateName)}`;
367
- if (setStateName === expectedSetterName) return O.none();
393
+ if (setStateName === expectedSetterName) {
394
+ return O.none();
395
+ }
368
396
  return descriptor;
369
397
  }).otherwise(O.none),
370
398
  O.map(context.report)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-naming-convention",
3
- "version": "1.23.2-next.6",
3
+ "version": "1.23.3-next.0",
4
4
  "description": "ESLint React's ESLint plugin for naming convention related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "author": "Eva1ent<rel1cx@proton.me>",
24
+ "sideEffects": false,
24
25
  "exports": {
25
26
  ".": {
26
27
  "import": {
@@ -35,6 +36,7 @@
35
36
  "./package.json": "./package.json"
36
37
  },
37
38
  "main": "dist/index.js",
39
+ "module": "dist/index.mjs",
38
40
  "types": "dist/index.d.ts",
39
41
  "files": [
40
42
  "dist",
@@ -47,12 +49,12 @@
47
49
  "@typescript-eslint/utils": "^8.19.1",
48
50
  "string-ts": "^2.2.0",
49
51
  "ts-pattern": "^5.6.0",
50
- "@eslint-react/eff": "1.23.2-next.6",
51
- "@eslint-react/core": "1.23.2-next.6",
52
- "@eslint-react/jsx": "1.23.2-next.6",
53
- "@eslint-react/ast": "1.23.2-next.6",
54
- "@eslint-react/shared": "1.23.2-next.6",
55
- "@eslint-react/types": "1.23.2-next.6"
52
+ "@eslint-react/ast": "1.23.3-next.0",
53
+ "@eslint-react/core": "1.23.3-next.0",
54
+ "@eslint-react/eff": "1.23.3-next.0",
55
+ "@eslint-react/jsx": "1.23.3-next.0",
56
+ "@eslint-react/shared": "1.23.3-next.0",
57
+ "@eslint-react/types": "1.23.3-next.0"
56
58
  },
57
59
  "devDependencies": {
58
60
  "@types/react": "^19.0.3",
@@ -79,8 +81,6 @@
79
81
  "publishConfig": {
80
82
  "access": "public"
81
83
  },
82
- "sideEffects": false,
83
- "module": "dist/index.mjs",
84
84
  "scripts": {
85
85
  "build": "tsup --dts-resolve",
86
86
  "lint:publish": "publint",