eslint-plugin-react-naming-convention 1.29.1-next.6 → 1.29.1-next.7
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 +43 -53
- package/dist/index.mjs +43 -52
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var AST = require('@eslint-react/ast');
|
|
4
4
|
var core = require('@eslint-react/core');
|
|
5
|
-
var JSX = require('@eslint-react/jsx');
|
|
6
5
|
var shared = require('@eslint-react/shared');
|
|
7
6
|
var eff = require('@eslint-react/eff');
|
|
8
7
|
var types = require('@typescript-eslint/types');
|
|
@@ -31,7 +30,6 @@ function _interopNamespace(e) {
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
34
|
-
var JSX__namespace = /*#__PURE__*/_interopNamespace(JSX);
|
|
35
33
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
36
34
|
|
|
37
35
|
var __defProp = Object.defineProperty;
|
|
@@ -54,16 +52,13 @@ var rules = {
|
|
|
54
52
|
|
|
55
53
|
// package.json
|
|
56
54
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
57
|
-
var version = "1.29.1-next.
|
|
55
|
+
var version = "1.29.1-next.7";
|
|
58
56
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
59
57
|
|
|
60
58
|
// src/rules/component-name.ts
|
|
61
|
-
var RULE_NAME = "component-name";
|
|
62
59
|
var defaultOptions = [
|
|
63
60
|
{
|
|
64
61
|
allowAllCaps: false,
|
|
65
|
-
allowLeadingUnderscore: false,
|
|
66
|
-
allowNamespace: false,
|
|
67
62
|
excepts: [],
|
|
68
63
|
rule: "PascalCase"
|
|
69
64
|
}
|
|
@@ -80,7 +75,15 @@ var schema = [
|
|
|
80
75
|
additionalProperties: false,
|
|
81
76
|
properties: {
|
|
82
77
|
allowAllCaps: { type: "boolean" },
|
|
78
|
+
/**
|
|
79
|
+
* @todo Remove in the next major version
|
|
80
|
+
* @deprecated
|
|
81
|
+
*/
|
|
83
82
|
allowLeadingUnderscore: { type: "boolean" },
|
|
83
|
+
/**
|
|
84
|
+
* @todo Remove in the next major version
|
|
85
|
+
* @deprecated
|
|
86
|
+
*/
|
|
84
87
|
allowNamespace: { type: "boolean" },
|
|
85
88
|
excepts: {
|
|
86
89
|
type: "array",
|
|
@@ -95,34 +98,7 @@ var schema = [
|
|
|
95
98
|
]
|
|
96
99
|
}
|
|
97
100
|
];
|
|
98
|
-
|
|
99
|
-
const opts = options[0];
|
|
100
|
-
const defaultOpts = defaultOptions[0];
|
|
101
|
-
if (opts == null) return defaultOpts;
|
|
102
|
-
return {
|
|
103
|
-
...defaultOpts,
|
|
104
|
-
...typeof opts === "string" ? { rule: opts } : {
|
|
105
|
-
...opts,
|
|
106
|
-
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function isValidComponentName(name3, options) {
|
|
111
|
-
if (name3 == null) return true;
|
|
112
|
-
if (options.excepts.some((regex) => regex.test(name3))) return true;
|
|
113
|
-
let normalized = name3.split(".").at(-1) ?? name3;
|
|
114
|
-
if (options.allowNamespace) normalized = normalized.replace(":", "");
|
|
115
|
-
if (options.allowLeadingUnderscore) normalized = normalized.replace(/^_/, "");
|
|
116
|
-
switch (options.rule) {
|
|
117
|
-
case "CONSTANT_CASE":
|
|
118
|
-
return shared.RE_CONSTANT_CASE.test(normalized);
|
|
119
|
-
case "PascalCase":
|
|
120
|
-
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
121
|
-
return options.allowAllCaps;
|
|
122
|
-
}
|
|
123
|
-
return shared.RE_PASCAL_CASE.test(normalized);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
101
|
+
var RULE_NAME = "component-name";
|
|
126
102
|
var component_name_default = createRule({
|
|
127
103
|
meta: {
|
|
128
104
|
type: "problem",
|
|
@@ -144,18 +120,6 @@ var component_name_default = createRule({
|
|
|
144
120
|
return {
|
|
145
121
|
...collector.listeners,
|
|
146
122
|
...collectorLegacy.listeners,
|
|
147
|
-
JSXOpeningElement(node) {
|
|
148
|
-
const name3 = JSX__namespace.getElementName(node.parent);
|
|
149
|
-
if (/^[a-z]/u.test(name3)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (isValidComponentName(name3, options)) return;
|
|
153
|
-
context.report({
|
|
154
|
-
messageId: "invalid",
|
|
155
|
-
node,
|
|
156
|
-
data: { name: name3, rule }
|
|
157
|
-
});
|
|
158
|
-
},
|
|
159
123
|
"Program:exit"(node) {
|
|
160
124
|
const functionComponents = collector.ctx.getAllComponents(node);
|
|
161
125
|
const classComponents = collectorLegacy.ctx.getAllComponents(node);
|
|
@@ -163,7 +127,7 @@ var component_name_default = createRule({
|
|
|
163
127
|
const id = AST__namespace.getFunctionIdentifier(component);
|
|
164
128
|
if (id?.name == null) continue;
|
|
165
129
|
const name3 = id.name;
|
|
166
|
-
if (
|
|
130
|
+
if (isValidName(name3, options)) return;
|
|
167
131
|
context.report({
|
|
168
132
|
messageId: "invalid",
|
|
169
133
|
node: id,
|
|
@@ -174,7 +138,7 @@ var component_name_default = createRule({
|
|
|
174
138
|
const id = AST__namespace.getClassIdentifier(component);
|
|
175
139
|
if (id?.name == null) continue;
|
|
176
140
|
const name3 = id.name;
|
|
177
|
-
if (
|
|
141
|
+
if (isValidName(name3, options)) continue;
|
|
178
142
|
context.report({
|
|
179
143
|
messageId: "invalid",
|
|
180
144
|
node: id,
|
|
@@ -186,6 +150,32 @@ var component_name_default = createRule({
|
|
|
186
150
|
},
|
|
187
151
|
defaultOptions
|
|
188
152
|
});
|
|
153
|
+
function normalizeOptions(options) {
|
|
154
|
+
const opts = options[0];
|
|
155
|
+
const defaultOpts = defaultOptions[0];
|
|
156
|
+
if (opts == null) return defaultOpts;
|
|
157
|
+
return {
|
|
158
|
+
...defaultOpts,
|
|
159
|
+
...typeof opts === "string" ? { rule: opts } : {
|
|
160
|
+
...opts,
|
|
161
|
+
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function isValidName(name3, options) {
|
|
166
|
+
if (name3 == null) return true;
|
|
167
|
+
if (options.excepts.some((regex) => regex.test(name3))) return true;
|
|
168
|
+
const normalized = name3.split(".").at(-1) ?? name3;
|
|
169
|
+
switch (options.rule) {
|
|
170
|
+
case "CONSTANT_CASE":
|
|
171
|
+
return shared.RE_CONSTANT_CASE.test(normalized);
|
|
172
|
+
case "PascalCase":
|
|
173
|
+
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
174
|
+
return options.allowAllCaps;
|
|
175
|
+
}
|
|
176
|
+
return shared.RE_PASCAL_CASE.test(normalized);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
189
179
|
var RULE_NAME2 = "context-name";
|
|
190
180
|
var context_name_default = createRule({
|
|
191
181
|
meta: {
|
|
@@ -464,11 +454,11 @@ var plugin = {
|
|
|
464
454
|
version
|
|
465
455
|
},
|
|
466
456
|
rules: {
|
|
467
|
-
"component-name": component_name_default,
|
|
468
|
-
"context-name": context_name_default,
|
|
469
|
-
filename: filename_default,
|
|
470
|
-
"filename-extension": filename_extension_default,
|
|
471
|
-
"use-state": use_state_default
|
|
457
|
+
["component-name"]: component_name_default,
|
|
458
|
+
["context-name"]: context_name_default,
|
|
459
|
+
["filename"]: filename_default,
|
|
460
|
+
["filename-extension"]: filename_extension_default,
|
|
461
|
+
["use-state"]: use_state_default
|
|
472
462
|
}
|
|
473
463
|
};
|
|
474
464
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
2
|
import { useComponentCollector, useComponentCollectorLegacy, isCreateContextCall, getInstanceId } from '@eslint-react/core';
|
|
3
|
-
import * as JSX from '@eslint-react/jsx';
|
|
4
3
|
import { createRuleForPlugin, RE_PASCAL_CASE, RE_CONSTANT_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
|
|
5
4
|
import { identity, _, isObject } from '@eslint-react/eff';
|
|
6
5
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
@@ -28,16 +27,13 @@ var rules = {
|
|
|
28
27
|
|
|
29
28
|
// package.json
|
|
30
29
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
31
|
-
var version = "1.29.1-next.
|
|
30
|
+
var version = "1.29.1-next.7";
|
|
32
31
|
var createRule = createRuleForPlugin("naming-convention");
|
|
33
32
|
|
|
34
33
|
// src/rules/component-name.ts
|
|
35
|
-
var RULE_NAME = "component-name";
|
|
36
34
|
var defaultOptions = [
|
|
37
35
|
{
|
|
38
36
|
allowAllCaps: false,
|
|
39
|
-
allowLeadingUnderscore: false,
|
|
40
|
-
allowNamespace: false,
|
|
41
37
|
excepts: [],
|
|
42
38
|
rule: "PascalCase"
|
|
43
39
|
}
|
|
@@ -54,7 +50,15 @@ var schema = [
|
|
|
54
50
|
additionalProperties: false,
|
|
55
51
|
properties: {
|
|
56
52
|
allowAllCaps: { type: "boolean" },
|
|
53
|
+
/**
|
|
54
|
+
* @todo Remove in the next major version
|
|
55
|
+
* @deprecated
|
|
56
|
+
*/
|
|
57
57
|
allowLeadingUnderscore: { type: "boolean" },
|
|
58
|
+
/**
|
|
59
|
+
* @todo Remove in the next major version
|
|
60
|
+
* @deprecated
|
|
61
|
+
*/
|
|
58
62
|
allowNamespace: { type: "boolean" },
|
|
59
63
|
excepts: {
|
|
60
64
|
type: "array",
|
|
@@ -69,34 +73,7 @@ var schema = [
|
|
|
69
73
|
]
|
|
70
74
|
}
|
|
71
75
|
];
|
|
72
|
-
|
|
73
|
-
const opts = options[0];
|
|
74
|
-
const defaultOpts = defaultOptions[0];
|
|
75
|
-
if (opts == null) return defaultOpts;
|
|
76
|
-
return {
|
|
77
|
-
...defaultOpts,
|
|
78
|
-
...typeof opts === "string" ? { rule: opts } : {
|
|
79
|
-
...opts,
|
|
80
|
-
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function isValidComponentName(name3, options) {
|
|
85
|
-
if (name3 == null) return true;
|
|
86
|
-
if (options.excepts.some((regex) => regex.test(name3))) return true;
|
|
87
|
-
let normalized = name3.split(".").at(-1) ?? name3;
|
|
88
|
-
if (options.allowNamespace) normalized = normalized.replace(":", "");
|
|
89
|
-
if (options.allowLeadingUnderscore) normalized = normalized.replace(/^_/, "");
|
|
90
|
-
switch (options.rule) {
|
|
91
|
-
case "CONSTANT_CASE":
|
|
92
|
-
return RE_CONSTANT_CASE.test(normalized);
|
|
93
|
-
case "PascalCase":
|
|
94
|
-
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
95
|
-
return options.allowAllCaps;
|
|
96
|
-
}
|
|
97
|
-
return RE_PASCAL_CASE.test(normalized);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
76
|
+
var RULE_NAME = "component-name";
|
|
100
77
|
var component_name_default = createRule({
|
|
101
78
|
meta: {
|
|
102
79
|
type: "problem",
|
|
@@ -118,18 +95,6 @@ var component_name_default = createRule({
|
|
|
118
95
|
return {
|
|
119
96
|
...collector.listeners,
|
|
120
97
|
...collectorLegacy.listeners,
|
|
121
|
-
JSXOpeningElement(node) {
|
|
122
|
-
const name3 = JSX.getElementName(node.parent);
|
|
123
|
-
if (/^[a-z]/u.test(name3)) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (isValidComponentName(name3, options)) return;
|
|
127
|
-
context.report({
|
|
128
|
-
messageId: "invalid",
|
|
129
|
-
node,
|
|
130
|
-
data: { name: name3, rule }
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
98
|
"Program:exit"(node) {
|
|
134
99
|
const functionComponents = collector.ctx.getAllComponents(node);
|
|
135
100
|
const classComponents = collectorLegacy.ctx.getAllComponents(node);
|
|
@@ -137,7 +102,7 @@ var component_name_default = createRule({
|
|
|
137
102
|
const id = AST.getFunctionIdentifier(component);
|
|
138
103
|
if (id?.name == null) continue;
|
|
139
104
|
const name3 = id.name;
|
|
140
|
-
if (
|
|
105
|
+
if (isValidName(name3, options)) return;
|
|
141
106
|
context.report({
|
|
142
107
|
messageId: "invalid",
|
|
143
108
|
node: id,
|
|
@@ -148,7 +113,7 @@ var component_name_default = createRule({
|
|
|
148
113
|
const id = AST.getClassIdentifier(component);
|
|
149
114
|
if (id?.name == null) continue;
|
|
150
115
|
const name3 = id.name;
|
|
151
|
-
if (
|
|
116
|
+
if (isValidName(name3, options)) continue;
|
|
152
117
|
context.report({
|
|
153
118
|
messageId: "invalid",
|
|
154
119
|
node: id,
|
|
@@ -160,6 +125,32 @@ var component_name_default = createRule({
|
|
|
160
125
|
},
|
|
161
126
|
defaultOptions
|
|
162
127
|
});
|
|
128
|
+
function normalizeOptions(options) {
|
|
129
|
+
const opts = options[0];
|
|
130
|
+
const defaultOpts = defaultOptions[0];
|
|
131
|
+
if (opts == null) return defaultOpts;
|
|
132
|
+
return {
|
|
133
|
+
...defaultOpts,
|
|
134
|
+
...typeof opts === "string" ? { rule: opts } : {
|
|
135
|
+
...opts,
|
|
136
|
+
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function isValidName(name3, options) {
|
|
141
|
+
if (name3 == null) return true;
|
|
142
|
+
if (options.excepts.some((regex) => regex.test(name3))) return true;
|
|
143
|
+
const normalized = name3.split(".").at(-1) ?? name3;
|
|
144
|
+
switch (options.rule) {
|
|
145
|
+
case "CONSTANT_CASE":
|
|
146
|
+
return RE_CONSTANT_CASE.test(normalized);
|
|
147
|
+
case "PascalCase":
|
|
148
|
+
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
149
|
+
return options.allowAllCaps;
|
|
150
|
+
}
|
|
151
|
+
return RE_PASCAL_CASE.test(normalized);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
163
154
|
var RULE_NAME2 = "context-name";
|
|
164
155
|
var context_name_default = createRule({
|
|
165
156
|
meta: {
|
|
@@ -438,11 +429,11 @@ var plugin = {
|
|
|
438
429
|
version
|
|
439
430
|
},
|
|
440
431
|
rules: {
|
|
441
|
-
"component-name": component_name_default,
|
|
442
|
-
"context-name": context_name_default,
|
|
443
|
-
filename: filename_default,
|
|
444
|
-
"filename-extension": filename_extension_default,
|
|
445
|
-
"use-state": use_state_default
|
|
432
|
+
["component-name"]: component_name_default,
|
|
433
|
+
["context-name"]: context_name_default,
|
|
434
|
+
["filename"]: filename_default,
|
|
435
|
+
["filename-extension"]: filename_extension_default,
|
|
436
|
+
["use-state"]: use_state_default
|
|
446
437
|
}
|
|
447
438
|
};
|
|
448
439
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.29.1-next.
|
|
3
|
+
"version": "1.29.1-next.7",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"@typescript-eslint/utils": "^8.25.0",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/ast": "1.29.1-next.
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/jsx": "1.29.1-next.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.29.1-next.7",
|
|
53
|
+
"@eslint-react/core": "1.29.1-next.7",
|
|
54
|
+
"@eslint-react/jsx": "1.29.1-next.7",
|
|
55
|
+
"@eslint-react/var": "1.29.1-next.7",
|
|
56
|
+
"@eslint-react/eff": "1.29.1-next.7",
|
|
57
|
+
"@eslint-react/shared": "1.29.1-next.7"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.0.10",
|