eslint-plugin-react-naming-convention 1.29.1-next.4 → 1.29.1-next.5
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 +24 -34
- package/dist/index.mjs +25 -35
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ var core = require('@eslint-react/core');
|
|
|
5
5
|
var eff = require('@eslint-react/eff');
|
|
6
6
|
var JSX = require('@eslint-react/jsx');
|
|
7
7
|
var shared = require('@eslint-react/shared');
|
|
8
|
-
var tsPattern = require('ts-pattern');
|
|
9
8
|
var types = require('@typescript-eslint/types');
|
|
9
|
+
var tsPattern = require('ts-pattern');
|
|
10
10
|
var path = require('path');
|
|
11
11
|
var stringTs = require('string-ts');
|
|
12
12
|
|
|
@@ -54,7 +54,7 @@ var rules = {
|
|
|
54
54
|
|
|
55
55
|
// package.json
|
|
56
56
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
57
|
-
var version = "1.29.1-next.
|
|
57
|
+
var version = "1.29.1-next.5";
|
|
58
58
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
59
59
|
|
|
60
60
|
// src/rules/component-name.ts
|
|
@@ -97,43 +97,33 @@ var schema = [
|
|
|
97
97
|
];
|
|
98
98
|
function normalizeOptions(options) {
|
|
99
99
|
const opts = options[0];
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (typeof opts === "string") {
|
|
104
|
-
return { ...defaultOptions[0], rule: opts };
|
|
105
|
-
}
|
|
100
|
+
const defaultOpts = defaultOptions[0];
|
|
101
|
+
if (opts == null) return defaultOpts;
|
|
106
102
|
return {
|
|
107
|
-
...
|
|
108
|
-
|
|
103
|
+
...defaultOpts,
|
|
104
|
+
...typeof opts === "string" ? { rule: opts } : {
|
|
105
|
+
...opts,
|
|
106
|
+
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
|
|
107
|
+
}
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
110
|
function getViolationMessage(name3, options) {
|
|
112
111
|
if (name3 == null) return eff._;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
if (allowLeadingUnderscore) {
|
|
129
|
-
normalized = normalized.replace(/^_/, "");
|
|
112
|
+
if (options.excepts.some((regex) => regex.test(name3))) return eff._;
|
|
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) ? eff._ : "useConstantCase";
|
|
119
|
+
case "PascalCase":
|
|
120
|
+
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
121
|
+
return options.allowAllCaps ? eff._ : "usePascalCase";
|
|
122
|
+
}
|
|
123
|
+
return shared.RE_PASCAL_CASE.test(normalized) ? eff._ : "usePascalCase";
|
|
124
|
+
default:
|
|
125
|
+
return eff._;
|
|
130
126
|
}
|
|
131
|
-
return tsPattern.match(rule).with("CONSTANT_CASE", () => shared.RE_CONSTANT_CASE.test(normalized) ? eff._ : "useConstantCase").with("PascalCase", () => {
|
|
132
|
-
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
133
|
-
return allowAllCaps ? eff._ : "usePascalCase";
|
|
134
|
-
}
|
|
135
|
-
return shared.RE_PASCAL_CASE.test(normalized) ? eff._ : "usePascalCase";
|
|
136
|
-
}).otherwise(() => eff._);
|
|
137
127
|
}
|
|
138
128
|
var component_name_default = createRule({
|
|
139
129
|
meta: {
|
|
@@ -228,7 +218,7 @@ var context_name_default = createRule({
|
|
|
228
218
|
const id = core.getInstanceId(node);
|
|
229
219
|
if (id == null) return;
|
|
230
220
|
const name3 = tsPattern.match(id).with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.select() }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, property: { name: tsPattern.P.select(tsPattern.P.string) } }, eff.identity).otherwise(() => eff._);
|
|
231
|
-
if (name3 != null && /^[A-Z]
|
|
221
|
+
if (name3 != null && /^[A-Z]/u.test(name3) && name3.endsWith("Context")) return;
|
|
232
222
|
context.report({
|
|
233
223
|
messageId: "contextName",
|
|
234
224
|
node: id
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import * as AST from '@eslint-react/ast';
|
|
|
2
2
|
import { useComponentCollector, useComponentCollectorLegacy, isCreateContextCall, getInstanceId } from '@eslint-react/core';
|
|
3
3
|
import { identity, _, isObject } from '@eslint-react/eff';
|
|
4
4
|
import * as JSX from '@eslint-react/jsx';
|
|
5
|
-
import { createRuleForPlugin,
|
|
6
|
-
import { match, P } from 'ts-pattern';
|
|
5
|
+
import { createRuleForPlugin, RE_PASCAL_CASE, RE_CONSTANT_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
|
|
7
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
|
+
import { match, P } from 'ts-pattern';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { snakeCase, pascalCase, camelCase, kebabCase } from 'string-ts';
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ var rules = {
|
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
31
|
-
var version = "1.29.1-next.
|
|
31
|
+
var version = "1.29.1-next.5";
|
|
32
32
|
var createRule = createRuleForPlugin("naming-convention");
|
|
33
33
|
|
|
34
34
|
// src/rules/component-name.ts
|
|
@@ -71,43 +71,33 @@ var schema = [
|
|
|
71
71
|
];
|
|
72
72
|
function normalizeOptions(options) {
|
|
73
73
|
const opts = options[0];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
if (typeof opts === "string") {
|
|
78
|
-
return { ...defaultOptions[0], rule: opts };
|
|
79
|
-
}
|
|
74
|
+
const defaultOpts = defaultOptions[0];
|
|
75
|
+
if (opts == null) return defaultOpts;
|
|
80
76
|
return {
|
|
81
|
-
...
|
|
82
|
-
|
|
77
|
+
...defaultOpts,
|
|
78
|
+
...typeof opts === "string" ? { rule: opts } : {
|
|
79
|
+
...opts,
|
|
80
|
+
excepts: opts.excepts?.map((pattern) => new RegExp(pattern, "u")) ?? []
|
|
81
|
+
}
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
84
|
function getViolationMessage(name3, options) {
|
|
86
85
|
if (name3 == null) return _;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
if (allowLeadingUnderscore) {
|
|
103
|
-
normalized = normalized.replace(/^_/, "");
|
|
86
|
+
if (options.excepts.some((regex) => regex.test(name3))) return _;
|
|
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) ? _ : "useConstantCase";
|
|
93
|
+
case "PascalCase":
|
|
94
|
+
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
95
|
+
return options.allowAllCaps ? _ : "usePascalCase";
|
|
96
|
+
}
|
|
97
|
+
return RE_PASCAL_CASE.test(normalized) ? _ : "usePascalCase";
|
|
98
|
+
default:
|
|
99
|
+
return _;
|
|
104
100
|
}
|
|
105
|
-
return match(rule).with("CONSTANT_CASE", () => RE_CONSTANT_CASE.test(normalized) ? _ : "useConstantCase").with("PascalCase", () => {
|
|
106
|
-
if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) {
|
|
107
|
-
return allowAllCaps ? _ : "usePascalCase";
|
|
108
|
-
}
|
|
109
|
-
return RE_PASCAL_CASE.test(normalized) ? _ : "usePascalCase";
|
|
110
|
-
}).otherwise(() => _);
|
|
111
101
|
}
|
|
112
102
|
var component_name_default = createRule({
|
|
113
103
|
meta: {
|
|
@@ -202,7 +192,7 @@ var context_name_default = createRule({
|
|
|
202
192
|
const id = getInstanceId(node);
|
|
203
193
|
if (id == null) return;
|
|
204
194
|
const name3 = match(id).with({ type: AST_NODE_TYPES.Identifier, name: P.select() }, identity).with({ type: AST_NODE_TYPES.MemberExpression, property: { name: P.select(P.string) } }, identity).otherwise(() => _);
|
|
205
|
-
if (name3 != null && /^[A-Z]
|
|
195
|
+
if (name3 != null && /^[A-Z]/u.test(name3) && name3.endsWith("Context")) return;
|
|
206
196
|
context.report({
|
|
207
197
|
messageId: "contextName",
|
|
208
198
|
node: id
|
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.5",
|
|
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/
|
|
55
|
-
"@eslint-react/jsx": "1.29.1-next.
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
52
|
+
"@eslint-react/ast": "1.29.1-next.5",
|
|
53
|
+
"@eslint-react/eff": "1.29.1-next.5",
|
|
54
|
+
"@eslint-react/shared": "1.29.1-next.5",
|
|
55
|
+
"@eslint-react/jsx": "1.29.1-next.5",
|
|
56
|
+
"@eslint-react/core": "1.29.1-next.5",
|
|
57
|
+
"@eslint-react/var": "1.29.1-next.5"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.0.10",
|