eslint-plugin-react-naming-convention 1.24.0-next.0 → 1.24.0-next.2
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 +9 -8
- package/dist/index.mjs +10 -9
- package/package.json +9 -9
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.24.0-next.
|
|
39
|
+
var version = "1.24.0-next.2";
|
|
40
40
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
41
41
|
|
|
42
42
|
// src/rules/component-name.ts
|
|
@@ -91,21 +91,22 @@ function normalizeOptions(options) {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
function validate(name2, options) {
|
|
94
|
-
if (name2
|
|
94
|
+
if (name2 == null) return false;
|
|
95
95
|
if (options.excepts.some((regex) => regex.test(name2))) {
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
98
|
let normalized = name2.normalize("NFKD").replace(/[\u0300-\u036F]/g, "");
|
|
99
99
|
normalized = normalized.split(".").at(-1) ?? normalized;
|
|
100
|
-
|
|
100
|
+
const { allowLeadingUnderscore = false, allowNamespace = false } = options;
|
|
101
|
+
if (allowNamespace) {
|
|
101
102
|
normalized = normalized.replace(":", "");
|
|
102
103
|
}
|
|
103
|
-
if (
|
|
104
|
+
if (allowLeadingUnderscore) {
|
|
104
105
|
normalized = normalized.replace(/^_/, "");
|
|
105
106
|
}
|
|
106
107
|
return tsPattern.match(options.rule).with("CONSTANT_CASE", () => shared.RE_CONSTANT_CASE.test(normalized)).with("PascalCase", () => {
|
|
107
108
|
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
108
|
-
return
|
|
109
|
+
return options.allowAllCaps ?? false;
|
|
109
110
|
}
|
|
110
111
|
return shared.RE_PASCAL_CASE.test(normalized);
|
|
111
112
|
}).otherwise(eff.returnFalse);
|
|
@@ -151,7 +152,7 @@ var component_name_default = createRule({
|
|
|
151
152
|
const classComponents = collectorLegacy.ctx.getAllComponents(node);
|
|
152
153
|
for (const { node: component } of functionComponents.values()) {
|
|
153
154
|
const id = AST__namespace.getFunctionIdentifier(component);
|
|
154
|
-
if (id?.name
|
|
155
|
+
if (id?.name == null) continue;
|
|
155
156
|
if (validate(id.name, options)) {
|
|
156
157
|
continue;
|
|
157
158
|
}
|
|
@@ -165,7 +166,7 @@ var component_name_default = createRule({
|
|
|
165
166
|
}
|
|
166
167
|
for (const { node: component } of classComponents.values()) {
|
|
167
168
|
const id = AST__namespace.getClassIdentifier(component);
|
|
168
|
-
if (id?.name
|
|
169
|
+
if (id?.name == null) continue;
|
|
169
170
|
if (!validate(id.name, options)) {
|
|
170
171
|
context.report({
|
|
171
172
|
messageId: "componentName",
|
|
@@ -343,7 +344,7 @@ var filename_extension_default = createRule({
|
|
|
343
344
|
return;
|
|
344
345
|
}
|
|
345
346
|
const hasCode = node.body.length > 0;
|
|
346
|
-
const ignoreFilesWithoutCode = eff.isObject(options) && options.ignoreFilesWithoutCode;
|
|
347
|
+
const ignoreFilesWithoutCode = eff.isObject(options) && options.ignoreFilesWithoutCode === true;
|
|
347
348
|
if (!hasCode && ignoreFilesWithoutCode) {
|
|
348
349
|
return;
|
|
349
350
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
2
|
import { useComponentCollector, useComponentCollectorLegacy, isUseStateCall, isReactHookCallWithNameLoose } from '@eslint-react/core';
|
|
3
|
-
import {
|
|
3
|
+
import { isObject, returnFalse } from '@eslint-react/eff';
|
|
4
4
|
import * as JSX from '@eslint-react/jsx';
|
|
5
5
|
import { createRuleForPlugin, getSettingsFromContext, RE_CONSTANT_CASE, RE_PASCAL_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
|
|
6
6
|
import { match } from 'ts-pattern';
|
|
@@ -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.24.0-next.
|
|
13
|
+
var version = "1.24.0-next.2";
|
|
14
14
|
var createRule = createRuleForPlugin("naming-convention");
|
|
15
15
|
|
|
16
16
|
// src/rules/component-name.ts
|
|
@@ -65,21 +65,22 @@ function normalizeOptions(options) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
function validate(name2, options) {
|
|
68
|
-
if (name2
|
|
68
|
+
if (name2 == null) return false;
|
|
69
69
|
if (options.excepts.some((regex) => regex.test(name2))) {
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
72
72
|
let normalized = name2.normalize("NFKD").replace(/[\u0300-\u036F]/g, "");
|
|
73
73
|
normalized = normalized.split(".").at(-1) ?? normalized;
|
|
74
|
-
|
|
74
|
+
const { allowLeadingUnderscore = false, allowNamespace = false } = options;
|
|
75
|
+
if (allowNamespace) {
|
|
75
76
|
normalized = normalized.replace(":", "");
|
|
76
77
|
}
|
|
77
|
-
if (
|
|
78
|
+
if (allowLeadingUnderscore) {
|
|
78
79
|
normalized = normalized.replace(/^_/, "");
|
|
79
80
|
}
|
|
80
81
|
return match(options.rule).with("CONSTANT_CASE", () => RE_CONSTANT_CASE.test(normalized)).with("PascalCase", () => {
|
|
81
82
|
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
82
|
-
return
|
|
83
|
+
return options.allowAllCaps ?? false;
|
|
83
84
|
}
|
|
84
85
|
return RE_PASCAL_CASE.test(normalized);
|
|
85
86
|
}).otherwise(returnFalse);
|
|
@@ -125,7 +126,7 @@ var component_name_default = createRule({
|
|
|
125
126
|
const classComponents = collectorLegacy.ctx.getAllComponents(node);
|
|
126
127
|
for (const { node: component } of functionComponents.values()) {
|
|
127
128
|
const id = AST.getFunctionIdentifier(component);
|
|
128
|
-
if (id?.name
|
|
129
|
+
if (id?.name == null) continue;
|
|
129
130
|
if (validate(id.name, options)) {
|
|
130
131
|
continue;
|
|
131
132
|
}
|
|
@@ -139,7 +140,7 @@ var component_name_default = createRule({
|
|
|
139
140
|
}
|
|
140
141
|
for (const { node: component } of classComponents.values()) {
|
|
141
142
|
const id = AST.getClassIdentifier(component);
|
|
142
|
-
if (id?.name
|
|
143
|
+
if (id?.name == null) continue;
|
|
143
144
|
if (!validate(id.name, options)) {
|
|
144
145
|
context.report({
|
|
145
146
|
messageId: "componentName",
|
|
@@ -317,7 +318,7 @@ var filename_extension_default = createRule({
|
|
|
317
318
|
return;
|
|
318
319
|
}
|
|
319
320
|
const hasCode = node.body.length > 0;
|
|
320
|
-
const ignoreFilesWithoutCode = isObject(options) && options.ignoreFilesWithoutCode;
|
|
321
|
+
const ignoreFilesWithoutCode = isObject(options) && options.ignoreFilesWithoutCode === true;
|
|
321
322
|
if (!hasCode && ignoreFilesWithoutCode) {
|
|
322
323
|
return;
|
|
323
324
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.2",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"@typescript-eslint/utils": "^8.19.1",
|
|
48
48
|
"string-ts": "^2.2.0",
|
|
49
49
|
"ts-pattern": "^5.6.0",
|
|
50
|
-
"@eslint-react/ast": "1.24.0-next.
|
|
51
|
-
"@eslint-react/core": "1.24.0-next.
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
50
|
+
"@eslint-react/ast": "1.24.0-next.2",
|
|
51
|
+
"@eslint-react/core": "1.24.0-next.2",
|
|
52
|
+
"@eslint-react/jsx": "1.24.0-next.2",
|
|
53
|
+
"@eslint-react/shared": "1.24.0-next.2",
|
|
54
|
+
"@eslint-react/types": "1.24.0-next.2",
|
|
55
|
+
"@eslint-react/eff": "1.24.0-next.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@types/react": "^19.0.
|
|
59
|
-
"@types/react-dom": "^19.0.
|
|
58
|
+
"@types/react": "^19.0.6",
|
|
59
|
+
"@types/react-dom": "^19.0.3",
|
|
60
60
|
"tsup": "^8.3.5",
|
|
61
61
|
"@workspace/configs": "0.0.0"
|
|
62
62
|
},
|