eslint-plugin-react-naming-convention 1.20.2-next.2 → 1.20.2-next.5
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 +24 -24
- package/dist/index.mjs +2 -2
- package/package.json +7 -7
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.2-next.
|
|
38
|
+
var version = "1.20.2-next.5";
|
|
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 (
|
|
82
|
-
if (
|
|
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,7 +98,7 @@ 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(
|
|
101
|
+
}).otherwise(eff.F.constFalse);
|
|
102
102
|
}
|
|
103
103
|
var component_name_default = createRule({
|
|
104
104
|
meta: {
|
|
@@ -137,7 +137,7 @@ var component_name_default = createRule({
|
|
|
137
137
|
const classComponents = collectorLegacy.ctx.getAllComponents(node);
|
|
138
138
|
for (const { node: component } of functionComponents.values()) {
|
|
139
139
|
const maybeId = AST__namespace.getFunctionIdentifier(component);
|
|
140
|
-
if (
|
|
140
|
+
if (eff.O.isNone(maybeId)) continue;
|
|
141
141
|
const id = maybeId.value;
|
|
142
142
|
const { name: name2 } = id;
|
|
143
143
|
if (validate(name2, options)) continue;
|
|
@@ -151,7 +151,7 @@ var component_name_default = createRule({
|
|
|
151
151
|
}
|
|
152
152
|
for (const { node: component } of classComponents.values()) {
|
|
153
153
|
const maybeId = AST__namespace.getClassIdentifier(component);
|
|
154
|
-
if (
|
|
154
|
+
if (eff.O.isNone(maybeId)) continue;
|
|
155
155
|
const id = maybeId.value;
|
|
156
156
|
const { name: name2 } = id;
|
|
157
157
|
if (validate(name2, options)) continue;
|
|
@@ -302,8 +302,8 @@ var filename_default = createRule({
|
|
|
302
302
|
name: RULE_NAME2,
|
|
303
303
|
create(context) {
|
|
304
304
|
const options = context.options[0] ?? defaultOptions2[0];
|
|
305
|
-
const rule =
|
|
306
|
-
const excepts =
|
|
305
|
+
const rule = eff.isString(options) ? options : options.rule ?? "PascalCase";
|
|
306
|
+
const excepts = eff.isString(options) ? [] : options.excepts ?? [];
|
|
307
307
|
const filename = context.filename;
|
|
308
308
|
function validate2(name2, casing = rule, ignores = excepts) {
|
|
309
309
|
if (ignores.map((pattern) => new RegExp(pattern, "u")).some((pattern) => pattern.test(name2))) {
|
|
@@ -388,21 +388,21 @@ var filename_extension_default = createRule({
|
|
|
388
388
|
name: RULE_NAME3,
|
|
389
389
|
create(context) {
|
|
390
390
|
const options = context.options[0] ?? defaultOptions3[0];
|
|
391
|
-
const allow =
|
|
392
|
-
const extensions =
|
|
391
|
+
const allow = eff.isObject(options) ? options.allow : options;
|
|
392
|
+
const extensions = eff.isObject(options) && "extensions" in options ? options.extensions : defaultOptions3[0].extensions;
|
|
393
393
|
const filename = context.filename;
|
|
394
|
-
const hasJSXNodeRef =
|
|
394
|
+
const hasJSXNodeRef = eff.MutRef.make(false);
|
|
395
395
|
return {
|
|
396
396
|
JSXElement() {
|
|
397
|
-
|
|
397
|
+
eff.MutRef.set(hasJSXNodeRef, true);
|
|
398
398
|
},
|
|
399
399
|
JSXFragment() {
|
|
400
|
-
|
|
400
|
+
eff.MutRef.set(hasJSXNodeRef, true);
|
|
401
401
|
},
|
|
402
402
|
"Program:exit"(node) {
|
|
403
403
|
const fileNameExt = filename.slice(filename.lastIndexOf("."));
|
|
404
404
|
const isJSXExt = extensions.includes(fileNameExt);
|
|
405
|
-
const hasJSXCode =
|
|
405
|
+
const hasJSXCode = eff.MutRef.get(hasJSXNodeRef);
|
|
406
406
|
if (hasJSXCode && !isJSXExt) {
|
|
407
407
|
context.report({
|
|
408
408
|
messageId: "filenameExtensionInvalid",
|
|
@@ -411,7 +411,7 @@ var filename_extension_default = createRule({
|
|
|
411
411
|
return;
|
|
412
412
|
}
|
|
413
413
|
const hasCode = node.body.length > 0;
|
|
414
|
-
const ignoreFilesWithoutCode =
|
|
414
|
+
const ignoreFilesWithoutCode = eff.isObject(options) && options.ignoreFilesWithoutCode;
|
|
415
415
|
if (!hasCode && ignoreFilesWithoutCode) return;
|
|
416
416
|
if (!hasJSXCode && isJSXExt && allow === "as-needed") {
|
|
417
417
|
context.report({
|
|
@@ -462,22 +462,22 @@ var use_state_default = createRule({
|
|
|
462
462
|
continue;
|
|
463
463
|
}
|
|
464
464
|
const { id } = hookCall.parent;
|
|
465
|
-
const descriptor =
|
|
466
|
-
|
|
467
|
-
tsPattern.match(id).with({ type: types.AST_NODE_TYPES.Identifier },
|
|
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) => {
|
|
468
468
|
const [state, setState] = n.elements;
|
|
469
469
|
if (state?.type === types.AST_NODE_TYPES.ObjectPattern && setState?.type === types.AST_NODE_TYPES.Identifier) {
|
|
470
|
-
return isSetterNameLoose(setState.name) ?
|
|
470
|
+
return isSetterNameLoose(setState.name) ? eff.O.none() : descriptor;
|
|
471
471
|
}
|
|
472
472
|
if (state?.type !== types.AST_NODE_TYPES.Identifier || setState?.type !== types.AST_NODE_TYPES.Identifier) {
|
|
473
|
-
return
|
|
473
|
+
return eff.O.none();
|
|
474
474
|
}
|
|
475
475
|
const [stateName, setStateName] = [state.name, setState.name];
|
|
476
476
|
const expectedSetterName = `set${capitalize(stateName)}`;
|
|
477
|
-
if (setStateName === expectedSetterName) return
|
|
477
|
+
if (setStateName === expectedSetterName) return eff.O.none();
|
|
478
478
|
return descriptor;
|
|
479
|
-
}).otherwise(
|
|
480
|
-
|
|
479
|
+
}).otherwise(eff.O.none),
|
|
480
|
+
eff.O.map(context.report)
|
|
481
481
|
);
|
|
482
482
|
}
|
|
483
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.2-next.
|
|
12
|
+
var version = "1.20.2-next.5";
|
|
13
13
|
var createRule = createRuleForPlugin("naming-convention");
|
|
14
14
|
|
|
15
15
|
// src/rules/component-name.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.20.2-next.
|
|
3
|
+
"version": "1.20.2-next.5",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,12 +48,12 @@
|
|
|
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.2-next.
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/types": "1.20.2-next.
|
|
51
|
+
"@eslint-react/ast": "1.20.2-next.5",
|
|
52
|
+
"@eslint-react/core": "1.20.2-next.5",
|
|
53
|
+
"@eslint-react/eff": "1.20.2-next.5",
|
|
54
|
+
"@eslint-react/jsx": "1.20.2-next.5",
|
|
55
|
+
"@eslint-react/shared": "1.20.2-next.5",
|
|
56
|
+
"@eslint-react/types": "1.20.2-next.5"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^19.0.2",
|