eslint-plugin-react-naming-convention 2.4.1-beta.12 → 2.4.1-beta.13
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 +52 -18
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, getConfigAdapters, toRegExp } from "@eslint-react/shared";
|
|
2
2
|
import * as AST from "@eslint-react/ast";
|
|
3
|
-
import { getInstanceId, isComponentName, isCreateContextCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy } from "@eslint-react/core";
|
|
3
|
+
import { getInstanceId, isComponentName, isCreateContextCall, isUseRefCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy } from "@eslint-react/core";
|
|
4
4
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
5
5
|
import { identity, isObject } from "@eslint-react/eff";
|
|
6
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
@@ -33,13 +33,14 @@ var recommended_exports = /* @__PURE__ */ __exportAll({
|
|
|
33
33
|
const name$1 = "react-naming-convention/recommended";
|
|
34
34
|
const rules = {
|
|
35
35
|
"react-naming-convention/context-name": "warn",
|
|
36
|
+
"react-naming-convention/ref-name": "warn",
|
|
36
37
|
"react-naming-convention/use-state": "warn"
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
//#endregion
|
|
40
41
|
//#region package.json
|
|
41
42
|
var name = "eslint-plugin-react-naming-convention";
|
|
42
|
-
var version = "2.4.1-beta.
|
|
43
|
+
var version = "2.4.1-beta.13";
|
|
43
44
|
|
|
44
45
|
//#endregion
|
|
45
46
|
//#region src/utils/create-rule.ts
|
|
@@ -76,7 +77,7 @@ const schema$3 = [{ anyOf: [{
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}] }];
|
|
79
|
-
const RULE_NAME$
|
|
80
|
+
const RULE_NAME$5 = "component-name";
|
|
80
81
|
var component_name_default = createRule({
|
|
81
82
|
meta: {
|
|
82
83
|
type: "problem",
|
|
@@ -85,11 +86,11 @@ var component_name_default = createRule({
|
|
|
85
86
|
messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
|
|
86
87
|
schema: schema$3
|
|
87
88
|
},
|
|
88
|
-
name: RULE_NAME$
|
|
89
|
-
create: create$
|
|
89
|
+
name: RULE_NAME$5,
|
|
90
|
+
create: create$5,
|
|
90
91
|
defaultOptions: defaultOptions$3
|
|
91
92
|
});
|
|
92
|
-
function create$
|
|
93
|
+
function create$5(context) {
|
|
93
94
|
const options = normalizeOptions(context.options);
|
|
94
95
|
const { rule } = options;
|
|
95
96
|
const fCollector = useComponentCollector(context);
|
|
@@ -155,7 +156,7 @@ function isValidName(name$2, options) {
|
|
|
155
156
|
|
|
156
157
|
//#endregion
|
|
157
158
|
//#region src/rules/context-name.ts
|
|
158
|
-
const RULE_NAME$
|
|
159
|
+
const RULE_NAME$4 = "context-name";
|
|
159
160
|
var context_name_default = createRule({
|
|
160
161
|
meta: {
|
|
161
162
|
type: "problem",
|
|
@@ -163,11 +164,11 @@ var context_name_default = createRule({
|
|
|
163
164
|
messages: { invalidContextName: "A context name must be a valid component name with the suffix 'Context'." },
|
|
164
165
|
schema: []
|
|
165
166
|
},
|
|
166
|
-
name: RULE_NAME$
|
|
167
|
-
create: create$
|
|
167
|
+
name: RULE_NAME$4,
|
|
168
|
+
create: create$4,
|
|
168
169
|
defaultOptions: []
|
|
169
170
|
});
|
|
170
|
-
function create$
|
|
171
|
+
function create$4(context) {
|
|
171
172
|
if (!context.sourceCode.text.includes("createContext")) return {};
|
|
172
173
|
return { CallExpression(node) {
|
|
173
174
|
if (!isCreateContextCall(context, node)) return;
|
|
@@ -190,7 +191,7 @@ function create$3(context) {
|
|
|
190
191
|
|
|
191
192
|
//#endregion
|
|
192
193
|
//#region src/rules/filename.ts
|
|
193
|
-
const RULE_NAME$
|
|
194
|
+
const RULE_NAME$3 = "filename";
|
|
194
195
|
const defaultOptions$2 = [{
|
|
195
196
|
excepts: [
|
|
196
197
|
"index",
|
|
@@ -247,11 +248,11 @@ var filename_default = createRule({
|
|
|
247
248
|
},
|
|
248
249
|
schema: schema$2
|
|
249
250
|
},
|
|
250
|
-
name: RULE_NAME$
|
|
251
|
-
create: create$
|
|
251
|
+
name: RULE_NAME$3,
|
|
252
|
+
create: create$3,
|
|
252
253
|
defaultOptions: defaultOptions$2
|
|
253
254
|
});
|
|
254
|
-
function create$
|
|
255
|
+
function create$3(context) {
|
|
255
256
|
const options = context.options[0] ?? defaultOptions$2[0];
|
|
256
257
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
257
258
|
const excepts = typeof options === "string" ? [] : (options.excepts ?? []).map((s) => toRegExp(s));
|
|
@@ -288,7 +289,7 @@ function create$2(context) {
|
|
|
288
289
|
|
|
289
290
|
//#endregion
|
|
290
291
|
//#region src/rules/filename-extension.ts
|
|
291
|
-
const RULE_NAME$
|
|
292
|
+
const RULE_NAME$2 = "filename-extension";
|
|
292
293
|
const defaultOptions$1 = [{
|
|
293
294
|
allow: "as-needed",
|
|
294
295
|
extensions: [".jsx", ".tsx"],
|
|
@@ -324,11 +325,11 @@ var filename_extension_default = createRule({
|
|
|
324
325
|
},
|
|
325
326
|
schema: schema$1
|
|
326
327
|
},
|
|
327
|
-
name: RULE_NAME$
|
|
328
|
-
create: create$
|
|
328
|
+
name: RULE_NAME$2,
|
|
329
|
+
create: create$2,
|
|
329
330
|
defaultOptions: defaultOptions$1
|
|
330
331
|
});
|
|
331
|
-
function create$
|
|
332
|
+
function create$2(context) {
|
|
332
333
|
const options = context.options[0] ?? defaultOptions$1[0];
|
|
333
334
|
const allow = isObject(options) ? options.allow : options;
|
|
334
335
|
const extensions = isObject(options) && "extensions" in options ? options.extensions : defaultOptions$1[0].extensions;
|
|
@@ -365,6 +366,38 @@ function create$1(context) {
|
|
|
365
366
|
};
|
|
366
367
|
}
|
|
367
368
|
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/rules/ref-name.ts
|
|
371
|
+
const RULE_NAME$1 = "ref-name";
|
|
372
|
+
var ref_name_default = createRule({
|
|
373
|
+
meta: {
|
|
374
|
+
type: "suggestion",
|
|
375
|
+
docs: { description: "Enforces that variables assigned from useRef calls have names ending with 'Ref'." },
|
|
376
|
+
messages: { invalidRefName: "Ref variables should have names ending with 'Ref', e.g., 'inputRef'." },
|
|
377
|
+
schema: []
|
|
378
|
+
},
|
|
379
|
+
name: RULE_NAME$1,
|
|
380
|
+
create: create$1,
|
|
381
|
+
defaultOptions: []
|
|
382
|
+
});
|
|
383
|
+
function create$1(context) {
|
|
384
|
+
if (!context.sourceCode.text.includes("useRef")) return {};
|
|
385
|
+
return { CallExpression(node) {
|
|
386
|
+
if (!isUseRefCall(node)) return;
|
|
387
|
+
const id = getInstanceId(node);
|
|
388
|
+
if (id == null) return;
|
|
389
|
+
const name$2 = match(id).with({
|
|
390
|
+
type: AST_NODE_TYPES.Identifier,
|
|
391
|
+
name: P.select()
|
|
392
|
+
}, identity).otherwise(() => null);
|
|
393
|
+
if (name$2 != null && name$2.endsWith("Ref")) return;
|
|
394
|
+
context.report({
|
|
395
|
+
messageId: "invalidRefName",
|
|
396
|
+
node: id
|
|
397
|
+
});
|
|
398
|
+
} };
|
|
399
|
+
}
|
|
400
|
+
|
|
368
401
|
//#endregion
|
|
369
402
|
//#region src/rules/use-state.ts
|
|
370
403
|
const RULE_NAME = "use-state";
|
|
@@ -474,6 +507,7 @@ const plugin = {
|
|
|
474
507
|
["context-name"]: context_name_default,
|
|
475
508
|
["filename"]: filename_default,
|
|
476
509
|
["filename-extension"]: filename_extension_default,
|
|
510
|
+
["ref-name"]: ref_name_default,
|
|
477
511
|
["use-state"]: use_state_default
|
|
478
512
|
}
|
|
479
513
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "2.4.1-beta.
|
|
3
|
+
"version": "2.4.1-beta.13",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@typescript-eslint/utils": "^8.51.0",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-pattern": "^5.9.0",
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/shared": "2.4.1-beta.
|
|
51
|
-
"@eslint-react/var": "2.4.1-beta.
|
|
47
|
+
"@eslint-react/ast": "2.4.1-beta.13",
|
|
48
|
+
"@eslint-react/core": "2.4.1-beta.13",
|
|
49
|
+
"@eslint-react/eff": "2.4.1-beta.13",
|
|
50
|
+
"@eslint-react/shared": "2.4.1-beta.13",
|
|
51
|
+
"@eslint-react/var": "2.4.1-beta.13"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.7",
|
|
55
55
|
"@types/react-dom": "^19.2.3",
|
|
56
|
-
"tsdown": "^0.18.
|
|
56
|
+
"tsdown": "^0.18.4",
|
|
57
57
|
"@local/configs": "0.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|