eslint-plugin-react-naming-convention 1.20.1 → 1.20.2-beta.3

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
@@ -2,9 +2,9 @@
2
2
 
3
3
  var AST = require('@eslint-react/ast');
4
4
  var core = require('@eslint-react/core');
5
+ var eff = require('@eslint-react/eff');
5
6
  var JSX = require('@eslint-react/jsx');
6
7
  var shared = require('@eslint-react/shared');
7
- var tools = require('@eslint-react/tools');
8
8
  var tsPattern = require('ts-pattern');
9
9
  var path = require('path');
10
10
  var types = require('@typescript-eslint/types');
@@ -35,7 +35,7 @@ var path__default = /*#__PURE__*/_interopDefault(path);
35
35
 
36
36
  // package.json
37
37
  var name = "eslint-plugin-react-naming-convention";
38
- var version = "1.20.1";
38
+ var version = "1.20.2-beta.3";
39
39
  var createRule = shared.createRuleForPlugin("naming-convention");
40
40
 
41
41
  // src/rules/component-name.ts
@@ -78,8 +78,8 @@ var schema = [
78
78
  ];
79
79
  function normalizeOptions(options) {
80
80
  const [opts] = options;
81
- if (tools.isNullable(opts)) return defaultOptions[0];
82
- if (tools.isString(opts)) return { ...defaultOptions[0], rule: opts };
81
+ if (eff.isNullable(opts)) return defaultOptions[0];
82
+ if (eff.isString(opts)) return { ...defaultOptions[0], rule: opts };
83
83
  return {
84
84
  ...opts,
85
85
  excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
@@ -98,11 +98,12 @@ function validate(name2, options) {
98
98
  return tsPattern.match(options.rule).with("CONSTANT_CASE", () => shared.RE_CONSTANT_CASE.test(normalized)).with("PascalCase", () => {
99
99
  if ([...normalized].length > 3 && /^[A-Z]+$/u.test(normalized)) return options.allowAllCaps;
100
100
  return shared.RE_PASCAL_CASE.test(normalized);
101
- }).otherwise(tools.F.constFalse);
101
+ }).otherwise(eff.F.constFalse);
102
102
  }
103
103
  var component_name_default = createRule({
104
104
  meta: {
105
105
  type: "problem",
106
+ defaultOptions: [...defaultOptions],
106
107
  docs: {
107
108
  description: "enforce component naming convention to 'PascalCase' or 'CONSTANT_CASE'"
108
109
  },
@@ -136,7 +137,7 @@ var component_name_default = createRule({
136
137
  const classComponents = collectorLegacy.ctx.getAllComponents(node);
137
138
  for (const { node: component } of functionComponents.values()) {
138
139
  const maybeId = AST__namespace.getFunctionIdentifier(component);
139
- if (tools.O.isNone(maybeId)) continue;
140
+ if (eff.O.isNone(maybeId)) continue;
140
141
  const id = maybeId.value;
141
142
  const { name: name2 } = id;
142
143
  if (validate(name2, options)) continue;
@@ -150,7 +151,7 @@ var component_name_default = createRule({
150
151
  }
151
152
  for (const { node: component } of classComponents.values()) {
152
153
  const maybeId = AST__namespace.getClassIdentifier(component);
153
- if (tools.O.isNone(maybeId)) continue;
154
+ if (eff.O.isNone(maybeId)) continue;
154
155
  const id = maybeId.value;
155
156
  const { name: name2 } = id;
156
157
  if (validate(name2, options)) continue;
@@ -287,6 +288,7 @@ var schema2 = [
287
288
  var filename_default = createRule({
288
289
  meta: {
289
290
  type: "problem",
291
+ defaultOptions: [...defaultOptions2],
290
292
  docs: {
291
293
  description: "enforce naming convention for JSX filenames"
292
294
  },
@@ -300,8 +302,8 @@ var filename_default = createRule({
300
302
  name: RULE_NAME2,
301
303
  create(context) {
302
304
  const options = context.options[0] ?? defaultOptions2[0];
303
- const rule = tools.isString(options) ? options : options.rule ?? "PascalCase";
304
- const excepts = tools.isString(options) ? [] : options.excepts ?? [];
305
+ const rule = eff.isString(options) ? options : options.rule ?? "PascalCase";
306
+ const excepts = eff.isString(options) ? [] : options.excepts ?? [];
305
307
  const filename = context.filename;
306
308
  function validate2(name2, casing = rule, ignores = excepts) {
307
309
  if (ignores.map((pattern) => new RegExp(pattern, "u")).some((pattern) => pattern.test(name2))) {
@@ -373,6 +375,7 @@ var schema3 = [
373
375
  var filename_extension_default = createRule({
374
376
  meta: {
375
377
  type: "problem",
378
+ defaultOptions: [...defaultOptions3],
376
379
  docs: {
377
380
  description: "enforce naming convention for JSX file extensions"
378
381
  },
@@ -385,21 +388,21 @@ var filename_extension_default = createRule({
385
388
  name: RULE_NAME3,
386
389
  create(context) {
387
390
  const options = context.options[0] ?? defaultOptions3[0];
388
- const allow = tools.isObject(options) ? options.allow : options;
389
- const extensions = tools.isObject(options) && "extensions" in options ? options.extensions : defaultOptions3[0].extensions;
391
+ const allow = eff.isObject(options) ? options.allow : options;
392
+ const extensions = eff.isObject(options) && "extensions" in options ? options.extensions : defaultOptions3[0].extensions;
390
393
  const filename = context.filename;
391
- const hasJSXNodeRef = tools.MutRef.make(false);
394
+ const hasJSXNodeRef = eff.MutRef.make(false);
392
395
  return {
393
396
  JSXElement() {
394
- tools.MutRef.set(hasJSXNodeRef, true);
397
+ eff.MutRef.set(hasJSXNodeRef, true);
395
398
  },
396
399
  JSXFragment() {
397
- tools.MutRef.set(hasJSXNodeRef, true);
400
+ eff.MutRef.set(hasJSXNodeRef, true);
398
401
  },
399
402
  "Program:exit"(node) {
400
403
  const fileNameExt = filename.slice(filename.lastIndexOf("."));
401
404
  const isJSXExt = extensions.includes(fileNameExt);
402
- const hasJSXCode = tools.MutRef.get(hasJSXNodeRef);
405
+ const hasJSXCode = eff.MutRef.get(hasJSXNodeRef);
403
406
  if (hasJSXCode && !isJSXExt) {
404
407
  context.report({
405
408
  messageId: "filenameExtensionInvalid",
@@ -408,7 +411,7 @@ var filename_extension_default = createRule({
408
411
  return;
409
412
  }
410
413
  const hasCode = node.body.length > 0;
411
- const ignoreFilesWithoutCode = tools.isObject(options) && options.ignoreFilesWithoutCode;
414
+ const ignoreFilesWithoutCode = eff.isObject(options) && options.ignoreFilesWithoutCode;
412
415
  if (!hasCode && ignoreFilesWithoutCode) return;
413
416
  if (!hasJSXCode && isJSXExt && allow === "as-needed") {
414
417
  context.report({
@@ -459,22 +462,22 @@ var use_state_default = createRule({
459
462
  continue;
460
463
  }
461
464
  const { id } = hookCall.parent;
462
- const descriptor = tools.O.some({ messageId: "useState", node: id });
463
- tools.F.pipe(
464
- tsPattern.match(id).with({ type: types.AST_NODE_TYPES.Identifier }, tools.F.constant(descriptor)).with({ type: types.AST_NODE_TYPES.ArrayPattern }, (n) => {
465
+ const descriptor = eff.O.some({ messageId: "useState", node: id });
466
+ eff.F.pipe(
467
+ tsPattern.match(id).with({ type: types.AST_NODE_TYPES.Identifier }, eff.F.constant(descriptor)).with({ type: types.AST_NODE_TYPES.ArrayPattern }, (n) => {
465
468
  const [state, setState] = n.elements;
466
469
  if (state?.type === types.AST_NODE_TYPES.ObjectPattern && setState?.type === types.AST_NODE_TYPES.Identifier) {
467
- return isSetterNameLoose(setState.name) ? tools.O.none() : descriptor;
470
+ return isSetterNameLoose(setState.name) ? eff.O.none() : descriptor;
468
471
  }
469
472
  if (state?.type !== types.AST_NODE_TYPES.Identifier || setState?.type !== types.AST_NODE_TYPES.Identifier) {
470
- return tools.O.none();
473
+ return eff.O.none();
471
474
  }
472
475
  const [stateName, setStateName] = [state.name, setState.name];
473
476
  const expectedSetterName = `set${capitalize(stateName)}`;
474
- if (setStateName === expectedSetterName) return tools.O.none();
477
+ if (setStateName === expectedSetterName) return eff.O.none();
475
478
  return descriptor;
476
- }).otherwise(tools.O.none),
477
- tools.O.map(context.report)
479
+ }).otherwise(eff.O.none),
480
+ eff.O.map(context.report)
478
481
  );
479
482
  }
480
483
  }
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  import * as AST from '@eslint-react/ast';
2
2
  import { useComponentCollector, useComponentCollectorLegacy, isUseStateCall, isReactHookCallWithNameLoose } from '@eslint-react/core';
3
+ import { O, isString, isObject, MutRef, F, isNullable } from '@eslint-react/eff';
3
4
  import * as JSX from '@eslint-react/jsx';
4
5
  import { createRuleForPlugin, decodeSettings, RE_CONSTANT_CASE, RE_PASCAL_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
5
- import { O, isString, isObject, MutRef, F, isNullable } from '@eslint-react/tools';
6
6
  import { match } from 'ts-pattern';
7
7
  import path from 'node:path';
8
8
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
9
9
 
10
10
  // package.json
11
11
  var name = "eslint-plugin-react-naming-convention";
12
- var version = "1.20.1";
12
+ var version = "1.20.2-beta.3";
13
13
  var createRule = createRuleForPlugin("naming-convention");
14
14
 
15
15
  // src/rules/component-name.ts
@@ -77,6 +77,7 @@ function validate(name2, options) {
77
77
  var component_name_default = createRule({
78
78
  meta: {
79
79
  type: "problem",
80
+ defaultOptions: [...defaultOptions],
80
81
  docs: {
81
82
  description: "enforce component naming convention to 'PascalCase' or 'CONSTANT_CASE'"
82
83
  },
@@ -261,6 +262,7 @@ var schema2 = [
261
262
  var filename_default = createRule({
262
263
  meta: {
263
264
  type: "problem",
265
+ defaultOptions: [...defaultOptions2],
264
266
  docs: {
265
267
  description: "enforce naming convention for JSX filenames"
266
268
  },
@@ -347,6 +349,7 @@ var schema3 = [
347
349
  var filename_extension_default = createRule({
348
350
  meta: {
349
351
  type: "problem",
352
+ defaultOptions: [...defaultOptions3],
350
353
  docs: {
351
354
  description: "enforce naming convention for JSX file extensions"
352
355
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-naming-convention",
3
- "version": "1.20.1",
3
+ "version": "1.20.2-beta.3",
4
4
  "description": "ESLint React's ESLint plugin for naming convention related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -48,15 +48,15 @@
48
48
  "@typescript-eslint/types": "^8.18.1",
49
49
  "@typescript-eslint/utils": "^8.18.1",
50
50
  "ts-pattern": "^5.6.0",
51
- "@eslint-react/ast": "1.20.1",
52
- "@eslint-react/core": "1.20.1",
53
- "@eslint-react/shared": "1.20.1",
54
- "@eslint-react/tools": "1.20.1",
55
- "@eslint-react/jsx": "1.20.1",
56
- "@eslint-react/types": "1.20.1"
51
+ "@eslint-react/core": "1.20.2-beta.3",
52
+ "@eslint-react/eff": "1.20.2-beta.3",
53
+ "@eslint-react/jsx": "1.20.2-beta.3",
54
+ "@eslint-react/shared": "1.20.2-beta.3",
55
+ "@eslint-react/types": "1.20.2-beta.3",
56
+ "@eslint-react/ast": "1.20.2-beta.3"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/react": "^19.0.1",
59
+ "@types/react": "^19.0.2",
60
60
  "@types/react-dom": "^19.0.2",
61
61
  "string-ts": "^2.2.0",
62
62
  "tsup": "^8.3.5",