eslint-plugin-react-naming-convention 2.4.0-beta.0 → 2.4.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 +23 -37
- package/package.json +6 -6
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.1";
|
|
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$2 = [{
|
|
54
54
|
allowAllCaps: false,
|
|
55
55
|
excepts: [],
|
|
56
56
|
rule: "PascalCase"
|
|
57
57
|
}];
|
|
58
|
-
const schema$
|
|
58
|
+
const schema$2 = [{ anyOf: [{
|
|
59
59
|
type: "string",
|
|
60
60
|
enum: ["PascalCase", "CONSTANT_CASE"]
|
|
61
61
|
}, {
|
|
@@ -81,17 +81,17 @@ const RULE_FEATURES$4 = ["CFG"];
|
|
|
81
81
|
var component_name_default = createRule({
|
|
82
82
|
meta: {
|
|
83
83
|
type: "problem",
|
|
84
|
-
defaultOptions: [...defaultOptions$
|
|
84
|
+
defaultOptions: [...defaultOptions$2],
|
|
85
85
|
docs: {
|
|
86
86
|
description: "Enforces naming conventions for components.",
|
|
87
87
|
[Symbol.for("rule_features")]: RULE_FEATURES$4
|
|
88
88
|
},
|
|
89
89
|
messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
|
|
90
|
-
schema: schema$
|
|
90
|
+
schema: schema$2
|
|
91
91
|
},
|
|
92
92
|
name: RULE_NAME$4,
|
|
93
93
|
create: create$4,
|
|
94
|
-
defaultOptions: defaultOptions$
|
|
94
|
+
defaultOptions: defaultOptions$2
|
|
95
95
|
});
|
|
96
96
|
function create$4(context) {
|
|
97
97
|
const options = normalizeOptions(context.options);
|
|
@@ -135,7 +135,7 @@ function create$4(context) {
|
|
|
135
135
|
}
|
|
136
136
|
function normalizeOptions(options) {
|
|
137
137
|
const opts = options[0];
|
|
138
|
-
const defaultOpts = defaultOptions$
|
|
138
|
+
const defaultOpts = defaultOptions$2[0];
|
|
139
139
|
if (opts == null) return defaultOpts;
|
|
140
140
|
return {
|
|
141
141
|
...defaultOpts,
|
|
@@ -200,7 +200,7 @@ function create$3(context) {
|
|
|
200
200
|
//#region src/rules/filename.ts
|
|
201
201
|
const RULE_NAME$2 = "filename";
|
|
202
202
|
const RULE_FEATURES$2 = ["CFG"];
|
|
203
|
-
const defaultOptions$
|
|
203
|
+
const defaultOptions$1 = [{
|
|
204
204
|
excepts: [
|
|
205
205
|
"index",
|
|
206
206
|
String.raw`/^_/`,
|
|
@@ -210,7 +210,7 @@ const defaultOptions$2 = [{
|
|
|
210
210
|
],
|
|
211
211
|
rule: "PascalCase"
|
|
212
212
|
}];
|
|
213
|
-
const schema$
|
|
213
|
+
const schema$1 = [{ anyOf: [{
|
|
214
214
|
type: "string",
|
|
215
215
|
enum: [
|
|
216
216
|
"PascalCase",
|
|
@@ -248,7 +248,7 @@ const schema$2 = [{ anyOf: [{
|
|
|
248
248
|
var filename_default = createRule({
|
|
249
249
|
meta: {
|
|
250
250
|
type: "problem",
|
|
251
|
-
defaultOptions: [...defaultOptions$
|
|
251
|
+
defaultOptions: [...defaultOptions$1],
|
|
252
252
|
docs: {
|
|
253
253
|
description: "Enforces consistent file naming conventions.",
|
|
254
254
|
[Symbol.for("rule_features")]: RULE_FEATURES$2
|
|
@@ -257,14 +257,14 @@ var filename_default = createRule({
|
|
|
257
257
|
empty: "A file must have non-empty name.",
|
|
258
258
|
invalidCase: "A file with name '{{name}}' does not match {{rule}}. Rename it to '{{suggestion}}'."
|
|
259
259
|
},
|
|
260
|
-
schema: schema$
|
|
260
|
+
schema: schema$1
|
|
261
261
|
},
|
|
262
262
|
name: RULE_NAME$2,
|
|
263
263
|
create: create$2,
|
|
264
|
-
defaultOptions: defaultOptions$
|
|
264
|
+
defaultOptions: defaultOptions$1
|
|
265
265
|
});
|
|
266
266
|
function create$2(context) {
|
|
267
|
-
const options = context.options[0] ?? defaultOptions$
|
|
267
|
+
const options = context.options[0] ?? defaultOptions$1[0];
|
|
268
268
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
269
269
|
const excepts = typeof options === "string" ? [] : (options.excepts ?? []).map((s) => toRegExp(s));
|
|
270
270
|
function validate(name$2, casing = rule, ignores = excepts) {
|
|
@@ -302,12 +302,12 @@ function create$2(context) {
|
|
|
302
302
|
//#region src/rules/filename-extension.ts
|
|
303
303
|
const RULE_NAME$1 = "filename-extension";
|
|
304
304
|
const RULE_FEATURES$1 = ["CFG"];
|
|
305
|
-
const defaultOptions
|
|
305
|
+
const defaultOptions = [{
|
|
306
306
|
allow: "as-needed",
|
|
307
307
|
extensions: [".jsx", ".tsx"],
|
|
308
308
|
ignoreFilesWithoutCode: false
|
|
309
309
|
}];
|
|
310
|
-
const schema
|
|
310
|
+
const schema = [{ anyOf: [{
|
|
311
311
|
type: "string",
|
|
312
312
|
enum: ["always", "as-needed"]
|
|
313
313
|
}, {
|
|
@@ -329,7 +329,7 @@ const schema$1 = [{ anyOf: [{
|
|
|
329
329
|
var filename_extension_default = createRule({
|
|
330
330
|
meta: {
|
|
331
331
|
type: "problem",
|
|
332
|
-
defaultOptions: [...defaultOptions
|
|
332
|
+
defaultOptions: [...defaultOptions],
|
|
333
333
|
docs: {
|
|
334
334
|
description: "Enforces consistent file naming conventions.",
|
|
335
335
|
[Symbol.for("rule_features")]: RULE_FEATURES$1
|
|
@@ -338,16 +338,16 @@ var filename_extension_default = createRule({
|
|
|
338
338
|
missingJSXExtension: "Use {{extensions}} file extension for JSX files.",
|
|
339
339
|
unnecessaryJSXExtension: "Do not use {{extensions}} file extension for files without JSX."
|
|
340
340
|
},
|
|
341
|
-
schema
|
|
341
|
+
schema
|
|
342
342
|
},
|
|
343
343
|
name: RULE_NAME$1,
|
|
344
344
|
create: create$1,
|
|
345
|
-
defaultOptions
|
|
345
|
+
defaultOptions
|
|
346
346
|
});
|
|
347
347
|
function create$1(context) {
|
|
348
|
-
const options = context.options[0] ?? defaultOptions
|
|
348
|
+
const options = context.options[0] ?? defaultOptions[0];
|
|
349
349
|
const allow = isObject(options) ? options.allow : options;
|
|
350
|
-
const extensions = isObject(options) && "extensions" in options ? options.extensions : defaultOptions
|
|
350
|
+
const extensions = isObject(options) && "extensions" in options ? options.extensions : defaultOptions[0].extensions;
|
|
351
351
|
const extensionsString = extensions.map((ext) => `'${ext}'`).join(", ");
|
|
352
352
|
const filename = context.filename;
|
|
353
353
|
let hasJSXNode = false;
|
|
@@ -385,12 +385,6 @@ function create$1(context) {
|
|
|
385
385
|
//#region src/rules/use-state.ts
|
|
386
386
|
const RULE_NAME = "use-state";
|
|
387
387
|
const RULE_FEATURES = [];
|
|
388
|
-
const defaultOptions = [{ enforceSetterExistence: false }];
|
|
389
|
-
const schema = [{
|
|
390
|
-
type: "object",
|
|
391
|
-
additionalProperties: false,
|
|
392
|
-
properties: { enforceSetterExistence: { type: "boolean" } }
|
|
393
|
-
}];
|
|
394
388
|
var use_state_default = createRule({
|
|
395
389
|
meta: {
|
|
396
390
|
type: "problem",
|
|
@@ -402,14 +396,13 @@ var use_state_default = createRule({
|
|
|
402
396
|
invalidAssignment: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
|
|
403
397
|
invalidSetterName: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'."
|
|
404
398
|
},
|
|
405
|
-
schema
|
|
399
|
+
schema: []
|
|
406
400
|
},
|
|
407
401
|
name: RULE_NAME,
|
|
408
402
|
create,
|
|
409
|
-
defaultOptions
|
|
403
|
+
defaultOptions: []
|
|
410
404
|
});
|
|
411
405
|
function create(context) {
|
|
412
|
-
const enforceSetterExistence = (context.options[0] ?? defaultOptions[0]).enforceSetterExistence ?? false;
|
|
413
406
|
return { CallExpression(node) {
|
|
414
407
|
if (!isUseStateCall(node)) return;
|
|
415
408
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
|
|
@@ -435,14 +428,7 @@ function create(context) {
|
|
|
435
428
|
});
|
|
436
429
|
return;
|
|
437
430
|
}
|
|
438
|
-
if (setter == null)
|
|
439
|
-
if (!enforceSetterExistence) return;
|
|
440
|
-
context.report({
|
|
441
|
-
messageId: "invalidAssignment",
|
|
442
|
-
node: id
|
|
443
|
-
});
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
431
|
+
if (setter == null) return;
|
|
446
432
|
const setterName = match(setter).with({ type: AST_NODE_TYPES.Identifier }, (id$1) => id$1.name).otherwise(() => null);
|
|
447
433
|
if (setterName == null || !setterName.startsWith("set")) {
|
|
448
434
|
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.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@typescript-eslint/utils": "^8.49.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.1",
|
|
48
|
+
"@eslint-react/eff": "2.4.0-beta.1",
|
|
49
|
+
"@eslint-react/core": "2.4.0-beta.1",
|
|
50
|
+
"@eslint-react/shared": "2.4.0-beta.1",
|
|
51
|
+
"@eslint-react/var": "2.4.0-beta.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.7",
|