eslint-plugin-react-naming-convention 2.13.0-beta.0 → 2.13.0-beta.1
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 +53 -17
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var recommended_exports = /* @__PURE__ */ __exportAll({
|
|
|
35
35
|
const name$1 = "react-naming-convention/recommended";
|
|
36
36
|
const rules = {
|
|
37
37
|
"react-naming-convention/context-name": "warn",
|
|
38
|
+
"react-naming-convention/id-name": "warn",
|
|
38
39
|
"react-naming-convention/ref-name": "warn",
|
|
39
40
|
"react-naming-convention/use-state": "warn"
|
|
40
41
|
};
|
|
@@ -42,7 +43,7 @@ const rules = {
|
|
|
42
43
|
//#endregion
|
|
43
44
|
//#region package.json
|
|
44
45
|
var name = "eslint-plugin-react-naming-convention";
|
|
45
|
-
var version = "2.13.0-beta.
|
|
46
|
+
var version = "2.13.0-beta.1";
|
|
46
47
|
|
|
47
48
|
//#endregion
|
|
48
49
|
//#region src/utils/create-rule.ts
|
|
@@ -79,7 +80,7 @@ const schema$3 = [{ anyOf: [{
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}] }];
|
|
82
|
-
const RULE_NAME$
|
|
83
|
+
const RULE_NAME$6 = "component-name";
|
|
83
84
|
var component_name_default = createRule({
|
|
84
85
|
meta: {
|
|
85
86
|
type: "problem",
|
|
@@ -88,11 +89,11 @@ var component_name_default = createRule({
|
|
|
88
89
|
messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
|
|
89
90
|
schema: schema$3
|
|
90
91
|
},
|
|
91
|
-
name: RULE_NAME$
|
|
92
|
-
create: create$
|
|
92
|
+
name: RULE_NAME$6,
|
|
93
|
+
create: create$6,
|
|
93
94
|
defaultOptions: defaultOptions$3
|
|
94
95
|
});
|
|
95
|
-
function create$
|
|
96
|
+
function create$6(context) {
|
|
96
97
|
const options = normalizeOptions(context.options);
|
|
97
98
|
const { rule } = options;
|
|
98
99
|
const fCollector = core.useComponentCollector(context);
|
|
@@ -148,7 +149,7 @@ function isValidName(name, options) {
|
|
|
148
149
|
|
|
149
150
|
//#endregion
|
|
150
151
|
//#region src/rules/context-name.ts
|
|
151
|
-
const RULE_NAME$
|
|
152
|
+
const RULE_NAME$5 = "context-name";
|
|
152
153
|
var context_name_default = createRule({
|
|
153
154
|
meta: {
|
|
154
155
|
type: "suggestion",
|
|
@@ -156,11 +157,11 @@ var context_name_default = createRule({
|
|
|
156
157
|
messages: { invalidContextName: "A context name must be a valid component name with the suffix 'Context'." },
|
|
157
158
|
schema: []
|
|
158
159
|
},
|
|
159
|
-
name: RULE_NAME$
|
|
160
|
-
create: create$
|
|
160
|
+
name: RULE_NAME$5,
|
|
161
|
+
create: create$5,
|
|
161
162
|
defaultOptions: []
|
|
162
163
|
});
|
|
163
|
-
function create$
|
|
164
|
+
function create$5(context) {
|
|
164
165
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
165
166
|
const { version } = getSettingsFromContext(context);
|
|
166
167
|
if (compare(version, "19.0.0", "<")) return {};
|
|
@@ -184,7 +185,7 @@ function create$4(context) {
|
|
|
184
185
|
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region src/rules/file-name.ts
|
|
187
|
-
const RULE_NAME$
|
|
188
|
+
const RULE_NAME$4 = "file-name";
|
|
188
189
|
const defaultOptions$2 = [{
|
|
189
190
|
excepts: [
|
|
190
191
|
"index",
|
|
@@ -241,11 +242,11 @@ var file_name_default = createRule({
|
|
|
241
242
|
},
|
|
242
243
|
schema: schema$2
|
|
243
244
|
},
|
|
244
|
-
name: RULE_NAME$
|
|
245
|
-
create: create$
|
|
245
|
+
name: RULE_NAME$4,
|
|
246
|
+
create: create$4,
|
|
246
247
|
defaultOptions: defaultOptions$2
|
|
247
248
|
});
|
|
248
|
-
function create$
|
|
249
|
+
function create$4(context) {
|
|
249
250
|
const options = context.options[0] ?? defaultOptions$2[0];
|
|
250
251
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
251
252
|
const excepts = typeof options === "string" ? [] : (options.excepts ?? []).map((s) => toRegExp(s));
|
|
@@ -282,7 +283,7 @@ function create$3(context) {
|
|
|
282
283
|
|
|
283
284
|
//#endregion
|
|
284
285
|
//#region src/rules/file-name-extension.ts
|
|
285
|
-
const RULE_NAME$
|
|
286
|
+
const RULE_NAME$3 = "file-name-extension";
|
|
286
287
|
const defaultOptions$1 = [{
|
|
287
288
|
allow: "as-needed",
|
|
288
289
|
extensions: [".jsx", ".tsx"],
|
|
@@ -318,11 +319,11 @@ var file_name_extension_default = createRule({
|
|
|
318
319
|
},
|
|
319
320
|
schema: schema$1
|
|
320
321
|
},
|
|
321
|
-
name: RULE_NAME$
|
|
322
|
-
create: create$
|
|
322
|
+
name: RULE_NAME$3,
|
|
323
|
+
create: create$3,
|
|
323
324
|
defaultOptions: defaultOptions$1
|
|
324
325
|
});
|
|
325
|
-
function create$
|
|
326
|
+
function create$3(context) {
|
|
326
327
|
const options = context.options[0] ?? defaultOptions$1[0];
|
|
327
328
|
const allow = isObject(options) ? options.allow : options;
|
|
328
329
|
const extensions = isObject(options) && "extensions" in options ? options.extensions : defaultOptions$1[0].extensions;
|
|
@@ -359,6 +360,40 @@ function create$2(context) {
|
|
|
359
360
|
};
|
|
360
361
|
}
|
|
361
362
|
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/rules/id-name.ts
|
|
365
|
+
const RULE_NAME$2 = "id-name";
|
|
366
|
+
var id_name_default = createRule({
|
|
367
|
+
meta: {
|
|
368
|
+
type: "suggestion",
|
|
369
|
+
docs: { description: "Enforces identifier names assigned from 'useId' calls to be either 'id' or end with 'Id'." },
|
|
370
|
+
messages: { invalidIdName: "An identifier assigned from 'useId' must be named 'id' or end with 'Id'." },
|
|
371
|
+
schema: []
|
|
372
|
+
},
|
|
373
|
+
name: RULE_NAME$2,
|
|
374
|
+
create: create$2,
|
|
375
|
+
defaultOptions: []
|
|
376
|
+
});
|
|
377
|
+
function create$2(context) {
|
|
378
|
+
if (!context.sourceCode.text.includes("useId")) return {};
|
|
379
|
+
return { CallExpression(node) {
|
|
380
|
+
if (!core.isUseIdCall(node)) return;
|
|
381
|
+
const [id, name] = match(findEnclosingAssignmentTarget(node)).with({
|
|
382
|
+
type: AST_NODE_TYPES.Identifier,
|
|
383
|
+
name: P.string
|
|
384
|
+
}, (id) => [id, id.name]).with({
|
|
385
|
+
type: AST_NODE_TYPES.MemberExpression,
|
|
386
|
+
property: { name: P.string }
|
|
387
|
+
}, (id) => [id, id.property.name]).otherwise(() => [null, null]);
|
|
388
|
+
if (id == null) return;
|
|
389
|
+
if (name.endsWith("Id") || name === "id") return;
|
|
390
|
+
context.report({
|
|
391
|
+
messageId: "invalidIdName",
|
|
392
|
+
node: id
|
|
393
|
+
});
|
|
394
|
+
} };
|
|
395
|
+
}
|
|
396
|
+
|
|
362
397
|
//#endregion
|
|
363
398
|
//#region src/rules/ref-name.ts
|
|
364
399
|
const RULE_NAME$1 = "ref-name";
|
|
@@ -505,6 +540,7 @@ const plugin = {
|
|
|
505
540
|
["file-name-extension"]: file_name_extension_default,
|
|
506
541
|
["filename"]: file_name_default,
|
|
507
542
|
["filename-extension"]: file_name_extension_default,
|
|
543
|
+
["id-name"]: id_name_default,
|
|
508
544
|
["ref-name"]: ref_name_default,
|
|
509
545
|
["use-state"]: use_state_default
|
|
510
546
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "2.13.0-beta.
|
|
3
|
+
"version": "2.13.0-beta.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"compare-versions": "^6.1.1",
|
|
46
46
|
"string-ts": "^2.3.1",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "2.13.0-beta.
|
|
49
|
-
"@eslint-react/core": "2.13.0-beta.
|
|
50
|
-
"@eslint-react/eff": "2.13.0-beta.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "2.13.0-beta.1",
|
|
49
|
+
"@eslint-react/core": "2.13.0-beta.1",
|
|
50
|
+
"@eslint-react/eff": "2.13.0-beta.1",
|
|
51
|
+
"@eslint-react/var": "2.13.0-beta.1",
|
|
52
|
+
"@eslint-react/shared": "2.13.0-beta.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.14",
|