eslint-plugin-react-naming-convention 2.4.0-beta.1 → 2.4.0-beta.12
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 +50 -48
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ const rules = {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region package.json
|
|
41
41
|
var name = "eslint-plugin-react-naming-convention";
|
|
42
|
-
var version = "2.4.0-beta.
|
|
42
|
+
var version = "2.4.0-beta.12";
|
|
43
43
|
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/utils/create-rule.ts
|
|
@@ -50,12 +50,12 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/rules/component-name.ts
|
|
53
|
-
const defaultOptions$
|
|
53
|
+
const defaultOptions$3 = [{
|
|
54
54
|
allowAllCaps: false,
|
|
55
55
|
excepts: [],
|
|
56
56
|
rule: "PascalCase"
|
|
57
57
|
}];
|
|
58
|
-
const schema$
|
|
58
|
+
const schema$3 = [{ anyOf: [{
|
|
59
59
|
type: "string",
|
|
60
60
|
enum: ["PascalCase", "CONSTANT_CASE"]
|
|
61
61
|
}, {
|
|
@@ -77,21 +77,17 @@ const schema$2 = [{ anyOf: [{
|
|
|
77
77
|
}
|
|
78
78
|
}] }];
|
|
79
79
|
const RULE_NAME$4 = "component-name";
|
|
80
|
-
const RULE_FEATURES$4 = ["CFG"];
|
|
81
80
|
var component_name_default = createRule({
|
|
82
81
|
meta: {
|
|
83
82
|
type: "problem",
|
|
84
|
-
defaultOptions: [...defaultOptions$
|
|
85
|
-
docs: {
|
|
86
|
-
description: "Enforces naming conventions for components.",
|
|
87
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$4
|
|
88
|
-
},
|
|
83
|
+
defaultOptions: [...defaultOptions$3],
|
|
84
|
+
docs: { description: "Enforces naming conventions for components." },
|
|
89
85
|
messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
|
|
90
|
-
schema: schema$
|
|
86
|
+
schema: schema$3
|
|
91
87
|
},
|
|
92
88
|
name: RULE_NAME$4,
|
|
93
89
|
create: create$4,
|
|
94
|
-
defaultOptions: defaultOptions$
|
|
90
|
+
defaultOptions: defaultOptions$3
|
|
95
91
|
});
|
|
96
92
|
function create$4(context) {
|
|
97
93
|
const options = normalizeOptions(context.options);
|
|
@@ -135,7 +131,7 @@ function create$4(context) {
|
|
|
135
131
|
}
|
|
136
132
|
function normalizeOptions(options) {
|
|
137
133
|
const opts = options[0];
|
|
138
|
-
const defaultOpts = defaultOptions$
|
|
134
|
+
const defaultOpts = defaultOptions$3[0];
|
|
139
135
|
if (opts == null) return defaultOpts;
|
|
140
136
|
return {
|
|
141
137
|
...defaultOpts,
|
|
@@ -160,14 +156,10 @@ function isValidName(name$2, options) {
|
|
|
160
156
|
//#endregion
|
|
161
157
|
//#region src/rules/context-name.ts
|
|
162
158
|
const RULE_NAME$3 = "context-name";
|
|
163
|
-
const RULE_FEATURES$3 = [];
|
|
164
159
|
var context_name_default = createRule({
|
|
165
160
|
meta: {
|
|
166
161
|
type: "problem",
|
|
167
|
-
docs: {
|
|
168
|
-
description: "Enforces context name to be a valid component name with the suffix `Context`.",
|
|
169
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$3
|
|
170
|
-
},
|
|
162
|
+
docs: { description: "Enforces context name to be a valid component name with the suffix `Context`." },
|
|
171
163
|
messages: { invalidContextName: "A context name must be a valid component name with the suffix 'Context'." },
|
|
172
164
|
schema: []
|
|
173
165
|
},
|
|
@@ -199,8 +191,7 @@ function create$3(context) {
|
|
|
199
191
|
//#endregion
|
|
200
192
|
//#region src/rules/filename.ts
|
|
201
193
|
const RULE_NAME$2 = "filename";
|
|
202
|
-
const
|
|
203
|
-
const defaultOptions$1 = [{
|
|
194
|
+
const defaultOptions$2 = [{
|
|
204
195
|
excepts: [
|
|
205
196
|
"index",
|
|
206
197
|
String.raw`/^_/`,
|
|
@@ -210,7 +201,7 @@ const defaultOptions$1 = [{
|
|
|
210
201
|
],
|
|
211
202
|
rule: "PascalCase"
|
|
212
203
|
}];
|
|
213
|
-
const schema$
|
|
204
|
+
const schema$2 = [{ anyOf: [{
|
|
214
205
|
type: "string",
|
|
215
206
|
enum: [
|
|
216
207
|
"PascalCase",
|
|
@@ -248,23 +239,20 @@ const schema$1 = [{ anyOf: [{
|
|
|
248
239
|
var filename_default = createRule({
|
|
249
240
|
meta: {
|
|
250
241
|
type: "problem",
|
|
251
|
-
defaultOptions: [...defaultOptions$
|
|
252
|
-
docs: {
|
|
253
|
-
description: "Enforces consistent file naming conventions.",
|
|
254
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$2
|
|
255
|
-
},
|
|
242
|
+
defaultOptions: [...defaultOptions$2],
|
|
243
|
+
docs: { description: "Enforces consistent file naming conventions." },
|
|
256
244
|
messages: {
|
|
257
245
|
empty: "A file must have non-empty name.",
|
|
258
246
|
invalidCase: "A file with name '{{name}}' does not match {{rule}}. Rename it to '{{suggestion}}'."
|
|
259
247
|
},
|
|
260
|
-
schema: schema$
|
|
248
|
+
schema: schema$2
|
|
261
249
|
},
|
|
262
250
|
name: RULE_NAME$2,
|
|
263
251
|
create: create$2,
|
|
264
|
-
defaultOptions: defaultOptions$
|
|
252
|
+
defaultOptions: defaultOptions$2
|
|
265
253
|
});
|
|
266
254
|
function create$2(context) {
|
|
267
|
-
const options = context.options[0] ?? defaultOptions$
|
|
255
|
+
const options = context.options[0] ?? defaultOptions$2[0];
|
|
268
256
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
269
257
|
const excepts = typeof options === "string" ? [] : (options.excepts ?? []).map((s) => toRegExp(s));
|
|
270
258
|
function validate(name$2, casing = rule, ignores = excepts) {
|
|
@@ -301,13 +289,12 @@ function create$2(context) {
|
|
|
301
289
|
//#endregion
|
|
302
290
|
//#region src/rules/filename-extension.ts
|
|
303
291
|
const RULE_NAME$1 = "filename-extension";
|
|
304
|
-
const
|
|
305
|
-
const defaultOptions = [{
|
|
292
|
+
const defaultOptions$1 = [{
|
|
306
293
|
allow: "as-needed",
|
|
307
294
|
extensions: [".jsx", ".tsx"],
|
|
308
295
|
ignoreFilesWithoutCode: false
|
|
309
296
|
}];
|
|
310
|
-
const schema = [{ anyOf: [{
|
|
297
|
+
const schema$1 = [{ anyOf: [{
|
|
311
298
|
type: "string",
|
|
312
299
|
enum: ["always", "as-needed"]
|
|
313
300
|
}, {
|
|
@@ -329,25 +316,22 @@ const schema = [{ anyOf: [{
|
|
|
329
316
|
var filename_extension_default = createRule({
|
|
330
317
|
meta: {
|
|
331
318
|
type: "problem",
|
|
332
|
-
defaultOptions: [...defaultOptions],
|
|
333
|
-
docs: {
|
|
334
|
-
description: "Enforces consistent file naming conventions.",
|
|
335
|
-
[Symbol.for("rule_features")]: RULE_FEATURES$1
|
|
336
|
-
},
|
|
319
|
+
defaultOptions: [...defaultOptions$1],
|
|
320
|
+
docs: { description: "Enforces consistent file naming conventions." },
|
|
337
321
|
messages: {
|
|
338
322
|
missingJSXExtension: "Use {{extensions}} file extension for JSX files.",
|
|
339
323
|
unnecessaryJSXExtension: "Do not use {{extensions}} file extension for files without JSX."
|
|
340
324
|
},
|
|
341
|
-
schema
|
|
325
|
+
schema: schema$1
|
|
342
326
|
},
|
|
343
327
|
name: RULE_NAME$1,
|
|
344
328
|
create: create$1,
|
|
345
|
-
defaultOptions
|
|
329
|
+
defaultOptions: defaultOptions$1
|
|
346
330
|
});
|
|
347
331
|
function create$1(context) {
|
|
348
|
-
const options = context.options[0] ?? defaultOptions[0];
|
|
332
|
+
const options = context.options[0] ?? defaultOptions$1[0];
|
|
349
333
|
const allow = isObject(options) ? options.allow : options;
|
|
350
|
-
const extensions = isObject(options) && "extensions" in options ? options.extensions : defaultOptions[0].extensions;
|
|
334
|
+
const extensions = isObject(options) && "extensions" in options ? options.extensions : defaultOptions$1[0].extensions;
|
|
351
335
|
const extensionsString = extensions.map((ext) => `'${ext}'`).join(", ");
|
|
352
336
|
const filename = context.filename;
|
|
353
337
|
let hasJSXNode = false;
|
|
@@ -384,28 +368,44 @@ function create$1(context) {
|
|
|
384
368
|
//#endregion
|
|
385
369
|
//#region src/rules/use-state.ts
|
|
386
370
|
const RULE_NAME = "use-state";
|
|
387
|
-
const
|
|
371
|
+
const defaultOptions = [{
|
|
372
|
+
enforceAssignment: false,
|
|
373
|
+
enforceSetterName: true
|
|
374
|
+
}];
|
|
375
|
+
const schema = [{
|
|
376
|
+
type: "object",
|
|
377
|
+
additionalProperties: false,
|
|
378
|
+
properties: {
|
|
379
|
+
enforceAssignment: {
|
|
380
|
+
type: "boolean",
|
|
381
|
+
default: false
|
|
382
|
+
},
|
|
383
|
+
enforceSetterName: {
|
|
384
|
+
type: "boolean",
|
|
385
|
+
default: true
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}];
|
|
388
389
|
var use_state_default = createRule({
|
|
389
390
|
meta: {
|
|
390
391
|
type: "problem",
|
|
391
|
-
docs: {
|
|
392
|
-
description: "Enforces destructuring and symmetric naming of `useState` hook value and setter.",
|
|
393
|
-
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
394
|
-
},
|
|
392
|
+
docs: { description: "Enforces destructuring and symmetric naming of `useState` hook value and setter." },
|
|
395
393
|
messages: {
|
|
396
394
|
invalidAssignment: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
|
|
397
395
|
invalidSetterName: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'."
|
|
398
396
|
},
|
|
399
|
-
schema
|
|
397
|
+
schema
|
|
400
398
|
},
|
|
401
399
|
name: RULE_NAME,
|
|
402
400
|
create,
|
|
403
|
-
defaultOptions
|
|
401
|
+
defaultOptions
|
|
404
402
|
});
|
|
405
403
|
function create(context) {
|
|
404
|
+
const { enforceAssignment = false, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
|
|
406
405
|
return { CallExpression(node) {
|
|
407
406
|
if (!isUseStateCall(node)) return;
|
|
408
407
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
408
|
+
if (!enforceAssignment) return;
|
|
409
409
|
context.report({
|
|
410
410
|
messageId: "invalidAssignment",
|
|
411
411
|
node
|
|
@@ -414,6 +414,7 @@ function create(context) {
|
|
|
414
414
|
}
|
|
415
415
|
const id = getInstanceId(node);
|
|
416
416
|
if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
|
|
417
|
+
if (!enforceAssignment) return;
|
|
417
418
|
context.report({
|
|
418
419
|
messageId: "invalidAssignment",
|
|
419
420
|
node: id ?? node
|
|
@@ -422,13 +423,14 @@ function create(context) {
|
|
|
422
423
|
}
|
|
423
424
|
const [value, setter] = id.elements;
|
|
424
425
|
if (value == null) {
|
|
426
|
+
if (!enforceAssignment) return;
|
|
425
427
|
context.report({
|
|
426
428
|
messageId: "invalidAssignment",
|
|
427
429
|
node: id
|
|
428
430
|
});
|
|
429
431
|
return;
|
|
430
432
|
}
|
|
431
|
-
if (setter == null) return;
|
|
433
|
+
if (setter == null || !enforceSetterName) return;
|
|
432
434
|
const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id$1) => id$1.name).otherwise(() => null);
|
|
433
435
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
434
436
|
context.report({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "2.4.0-beta.
|
|
3
|
+
"version": "2.4.0-beta.12",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
"./package.json"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
42
|
-
"@typescript-eslint/type-utils": "^8.
|
|
43
|
-
"@typescript-eslint/types": "^8.
|
|
44
|
-
"@typescript-eslint/utils": "^8.
|
|
41
|
+
"@typescript-eslint/scope-manager": "^8.50.0",
|
|
42
|
+
"@typescript-eslint/type-utils": "^8.50.0",
|
|
43
|
+
"@typescript-eslint/types": "^8.50.0",
|
|
44
|
+
"@typescript-eslint/utils": "^8.50.0",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-pattern": "^5.9.0",
|
|
47
|
-
"@eslint-react/ast": "2.4.0-beta.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
47
|
+
"@eslint-react/ast": "2.4.0-beta.12",
|
|
48
|
+
"@eslint-react/core": "2.4.0-beta.12",
|
|
49
|
+
"@eslint-react/shared": "2.4.0-beta.12",
|
|
50
|
+
"@eslint-react/var": "2.4.0-beta.12",
|
|
51
|
+
"@eslint-react/eff": "2.4.0-beta.12"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.7",
|
|
55
55
|
"@types/react-dom": "^19.2.3",
|
|
56
|
-
"tsdown": "^0.
|
|
56
|
+
"tsdown": "^0.18.1",
|
|
57
57
|
"@local/configs": "0.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|