eslint-plugin-react-naming-convention 1.22.1-next.0 → 1.22.1-next.2
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 +4 -83
- package/dist/index.mjs +2 -81
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var JSX = require('@eslint-react/jsx');
|
|
|
7
7
|
var shared = require('@eslint-react/shared');
|
|
8
8
|
var tsPattern = require('ts-pattern');
|
|
9
9
|
var path = require('path');
|
|
10
|
+
var stringTs = require('string-ts');
|
|
10
11
|
var types = require('@typescript-eslint/types');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -35,7 +36,7 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
35
36
|
|
|
36
37
|
// package.json
|
|
37
38
|
var name = "eslint-plugin-react-naming-convention";
|
|
38
|
-
var version = "1.22.1-next.
|
|
39
|
+
var version = "1.22.1-next.2";
|
|
39
40
|
var createRule = shared.createRuleForPlugin("naming-convention");
|
|
40
41
|
|
|
41
42
|
// src/rules/component-name.ts
|
|
@@ -168,86 +169,6 @@ var component_name_default = createRule({
|
|
|
168
169
|
},
|
|
169
170
|
defaultOptions
|
|
170
171
|
});
|
|
171
|
-
|
|
172
|
-
// ../../../node_modules/.pnpm/string-ts@2.2.0/node_modules/string-ts/dist/index.mjs
|
|
173
|
-
function charAt(str, index) {
|
|
174
|
-
return str.charAt(index);
|
|
175
|
-
}
|
|
176
|
-
function join(tuple, delimiter = "") {
|
|
177
|
-
return tuple.join(delimiter);
|
|
178
|
-
}
|
|
179
|
-
function replaceAll(sentence, lookup, replacement = "") {
|
|
180
|
-
if (typeof sentence.replaceAll === "function") {
|
|
181
|
-
return sentence.replaceAll(lookup, replacement);
|
|
182
|
-
}
|
|
183
|
-
const regex = new RegExp(lookup, "g");
|
|
184
|
-
return sentence.replace(regex, replacement);
|
|
185
|
-
}
|
|
186
|
-
function slice(str, start = 0, end = void 0) {
|
|
187
|
-
return str.slice(start, end);
|
|
188
|
-
}
|
|
189
|
-
function toLowerCase(str) {
|
|
190
|
-
return str.toLowerCase();
|
|
191
|
-
}
|
|
192
|
-
function toUpperCase(str) {
|
|
193
|
-
return str.toUpperCase();
|
|
194
|
-
}
|
|
195
|
-
var UNESCAPED_SEPARATORS = [
|
|
196
|
-
"[",
|
|
197
|
-
"]",
|
|
198
|
-
"{",
|
|
199
|
-
"}",
|
|
200
|
-
"(",
|
|
201
|
-
")",
|
|
202
|
-
"|",
|
|
203
|
-
"/",
|
|
204
|
-
"-",
|
|
205
|
-
"\\"
|
|
206
|
-
];
|
|
207
|
-
var SEPARATORS = [...UNESCAPED_SEPARATORS, " ", "_", "."];
|
|
208
|
-
function escapeChar(char) {
|
|
209
|
-
return UNESCAPED_SEPARATORS.includes(char) ? `\\${char}` : char;
|
|
210
|
-
}
|
|
211
|
-
var SEPARATOR_REGEX = new RegExp(
|
|
212
|
-
`[${SEPARATORS.map(escapeChar).join("")}]`,
|
|
213
|
-
"g"
|
|
214
|
-
);
|
|
215
|
-
function words(sentence) {
|
|
216
|
-
return sentence.replace(SEPARATOR_REGEX, " ").replace(/([a-zA-Z])([0-9])/g, "$1 $2").replace(/([0-9])([a-zA-Z])/g, "$1 $2").replace(/([a-zA-Z0-9_\-./])([^a-zA-Z0-9_\-./'])/g, "$1 $2").replace(/([^a-zA-Z0-9_\-./'])([a-zA-Z0-9_\-./])/g, "$1 $2").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").trim().split(/\s+/g);
|
|
217
|
-
}
|
|
218
|
-
function capitalize(str) {
|
|
219
|
-
return join([
|
|
220
|
-
toUpperCase(charAt(str, 0) ?? ""),
|
|
221
|
-
slice(str, 1)
|
|
222
|
-
]);
|
|
223
|
-
}
|
|
224
|
-
function pascalCaseAll(words2) {
|
|
225
|
-
return words2.map((v) => capitalize(toLowerCase(v)));
|
|
226
|
-
}
|
|
227
|
-
function removeApostrophe(str) {
|
|
228
|
-
return replaceAll(str, "'", "");
|
|
229
|
-
}
|
|
230
|
-
function pascalCase(str) {
|
|
231
|
-
return join(pascalCaseAll(words(removeApostrophe(str))));
|
|
232
|
-
}
|
|
233
|
-
function uncapitalize(str) {
|
|
234
|
-
return join([
|
|
235
|
-
toLowerCase(charAt(str, 0) ?? ""),
|
|
236
|
-
slice(str, 1)
|
|
237
|
-
]);
|
|
238
|
-
}
|
|
239
|
-
function camelCase(str) {
|
|
240
|
-
return uncapitalize(pascalCase(removeApostrophe(str)));
|
|
241
|
-
}
|
|
242
|
-
function delimiterCase(str, delimiter) {
|
|
243
|
-
return join(words(removeApostrophe(str)), delimiter);
|
|
244
|
-
}
|
|
245
|
-
function kebabCase(str) {
|
|
246
|
-
return toLowerCase(delimiterCase(removeApostrophe(str), "-"));
|
|
247
|
-
}
|
|
248
|
-
function snakeCase(str) {
|
|
249
|
-
return toLowerCase(delimiterCase(removeApostrophe(str), "_"));
|
|
250
|
-
}
|
|
251
172
|
var RULE_NAME2 = "filename";
|
|
252
173
|
var defaultOptions2 = [
|
|
253
174
|
{
|
|
@@ -312,7 +233,7 @@ var filename_default = createRule({
|
|
|
312
233
|
return tsPattern.match(casing).with("PascalCase", () => shared.RE_PASCAL_CASE.test(name2)).with("camelCase", () => shared.RE_CAMEL_CASE.test(name2)).with("kebab-case", () => shared.RE_KEBAB_CASE.test(name2)).with("snake_case", () => shared.RE_SNAKE_CASE.test(name2)).exhaustive();
|
|
313
234
|
}
|
|
314
235
|
function getSuggestion(name2, casing = rule) {
|
|
315
|
-
return tsPattern.match(casing).with("PascalCase", () => pascalCase(name2)).with("camelCase", () => camelCase(name2)).with("kebab-case", () => kebabCase(name2)).with("snake_case", () => snakeCase(name2)).exhaustive();
|
|
236
|
+
return tsPattern.match(casing).with("PascalCase", () => stringTs.pascalCase(name2)).with("camelCase", () => stringTs.camelCase(name2)).with("kebab-case", () => stringTs.kebabCase(name2)).with("snake_case", () => stringTs.snakeCase(name2)).exhaustive();
|
|
316
237
|
}
|
|
317
238
|
return {
|
|
318
239
|
Program(node) {
|
|
@@ -473,7 +394,7 @@ var use_state_default = createRule({
|
|
|
473
394
|
return eff.O.none();
|
|
474
395
|
}
|
|
475
396
|
const [stateName, setStateName] = [state.name, setState.name];
|
|
476
|
-
const expectedSetterName = `set${capitalize(stateName)}`;
|
|
397
|
+
const expectedSetterName = `set${stringTs.capitalize(stateName)}`;
|
|
477
398
|
if (setStateName === expectedSetterName) return eff.O.none();
|
|
478
399
|
return descriptor;
|
|
479
400
|
}).otherwise(eff.O.none),
|
package/dist/index.mjs
CHANGED
|
@@ -5,11 +5,12 @@ import * as JSX from '@eslint-react/jsx';
|
|
|
5
5
|
import { createRuleForPlugin, decodeSettings, RE_CONSTANT_CASE, RE_PASCAL_CASE, RE_CAMEL_CASE, RE_KEBAB_CASE, RE_SNAKE_CASE } from '@eslint-react/shared';
|
|
6
6
|
import { match } from 'ts-pattern';
|
|
7
7
|
import path from 'node:path';
|
|
8
|
+
import { capitalize, pascalCase, camelCase, kebabCase, snakeCase } from 'string-ts';
|
|
8
9
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
9
10
|
|
|
10
11
|
// package.json
|
|
11
12
|
var name = "eslint-plugin-react-naming-convention";
|
|
12
|
-
var version = "1.22.1-next.
|
|
13
|
+
var version = "1.22.1-next.2";
|
|
13
14
|
var createRule = createRuleForPlugin("naming-convention");
|
|
14
15
|
|
|
15
16
|
// src/rules/component-name.ts
|
|
@@ -142,86 +143,6 @@ var component_name_default = createRule({
|
|
|
142
143
|
},
|
|
143
144
|
defaultOptions
|
|
144
145
|
});
|
|
145
|
-
|
|
146
|
-
// ../../../node_modules/.pnpm/string-ts@2.2.0/node_modules/string-ts/dist/index.mjs
|
|
147
|
-
function charAt(str, index) {
|
|
148
|
-
return str.charAt(index);
|
|
149
|
-
}
|
|
150
|
-
function join(tuple, delimiter = "") {
|
|
151
|
-
return tuple.join(delimiter);
|
|
152
|
-
}
|
|
153
|
-
function replaceAll(sentence, lookup, replacement = "") {
|
|
154
|
-
if (typeof sentence.replaceAll === "function") {
|
|
155
|
-
return sentence.replaceAll(lookup, replacement);
|
|
156
|
-
}
|
|
157
|
-
const regex = new RegExp(lookup, "g");
|
|
158
|
-
return sentence.replace(regex, replacement);
|
|
159
|
-
}
|
|
160
|
-
function slice(str, start = 0, end = void 0) {
|
|
161
|
-
return str.slice(start, end);
|
|
162
|
-
}
|
|
163
|
-
function toLowerCase(str) {
|
|
164
|
-
return str.toLowerCase();
|
|
165
|
-
}
|
|
166
|
-
function toUpperCase(str) {
|
|
167
|
-
return str.toUpperCase();
|
|
168
|
-
}
|
|
169
|
-
var UNESCAPED_SEPARATORS = [
|
|
170
|
-
"[",
|
|
171
|
-
"]",
|
|
172
|
-
"{",
|
|
173
|
-
"}",
|
|
174
|
-
"(",
|
|
175
|
-
")",
|
|
176
|
-
"|",
|
|
177
|
-
"/",
|
|
178
|
-
"-",
|
|
179
|
-
"\\"
|
|
180
|
-
];
|
|
181
|
-
var SEPARATORS = [...UNESCAPED_SEPARATORS, " ", "_", "."];
|
|
182
|
-
function escapeChar(char) {
|
|
183
|
-
return UNESCAPED_SEPARATORS.includes(char) ? `\\${char}` : char;
|
|
184
|
-
}
|
|
185
|
-
var SEPARATOR_REGEX = new RegExp(
|
|
186
|
-
`[${SEPARATORS.map(escapeChar).join("")}]`,
|
|
187
|
-
"g"
|
|
188
|
-
);
|
|
189
|
-
function words(sentence) {
|
|
190
|
-
return sentence.replace(SEPARATOR_REGEX, " ").replace(/([a-zA-Z])([0-9])/g, "$1 $2").replace(/([0-9])([a-zA-Z])/g, "$1 $2").replace(/([a-zA-Z0-9_\-./])([^a-zA-Z0-9_\-./'])/g, "$1 $2").replace(/([^a-zA-Z0-9_\-./'])([a-zA-Z0-9_\-./])/g, "$1 $2").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").trim().split(/\s+/g);
|
|
191
|
-
}
|
|
192
|
-
function capitalize(str) {
|
|
193
|
-
return join([
|
|
194
|
-
toUpperCase(charAt(str, 0) ?? ""),
|
|
195
|
-
slice(str, 1)
|
|
196
|
-
]);
|
|
197
|
-
}
|
|
198
|
-
function pascalCaseAll(words2) {
|
|
199
|
-
return words2.map((v) => capitalize(toLowerCase(v)));
|
|
200
|
-
}
|
|
201
|
-
function removeApostrophe(str) {
|
|
202
|
-
return replaceAll(str, "'", "");
|
|
203
|
-
}
|
|
204
|
-
function pascalCase(str) {
|
|
205
|
-
return join(pascalCaseAll(words(removeApostrophe(str))));
|
|
206
|
-
}
|
|
207
|
-
function uncapitalize(str) {
|
|
208
|
-
return join([
|
|
209
|
-
toLowerCase(charAt(str, 0) ?? ""),
|
|
210
|
-
slice(str, 1)
|
|
211
|
-
]);
|
|
212
|
-
}
|
|
213
|
-
function camelCase(str) {
|
|
214
|
-
return uncapitalize(pascalCase(removeApostrophe(str)));
|
|
215
|
-
}
|
|
216
|
-
function delimiterCase(str, delimiter) {
|
|
217
|
-
return join(words(removeApostrophe(str)), delimiter);
|
|
218
|
-
}
|
|
219
|
-
function kebabCase(str) {
|
|
220
|
-
return toLowerCase(delimiterCase(removeApostrophe(str), "-"));
|
|
221
|
-
}
|
|
222
|
-
function snakeCase(str) {
|
|
223
|
-
return toLowerCase(delimiterCase(removeApostrophe(str), "_"));
|
|
224
|
-
}
|
|
225
146
|
var RULE_NAME2 = "filename";
|
|
226
147
|
var defaultOptions2 = [
|
|
227
148
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "1.22.1-next.
|
|
3
|
+
"version": "1.22.1-next.2",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,18 +47,18 @@
|
|
|
47
47
|
"@typescript-eslint/type-utils": "^8.18.1",
|
|
48
48
|
"@typescript-eslint/types": "^8.18.1",
|
|
49
49
|
"@typescript-eslint/utils": "^8.18.1",
|
|
50
|
+
"string-ts": "^2.2.0",
|
|
50
51
|
"ts-pattern": "^5.6.0",
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/eff": "1.22.1-next.
|
|
54
|
-
"@eslint-react/jsx": "1.22.1-next.
|
|
55
|
-
"@eslint-react/shared": "1.22.1-next.
|
|
56
|
-
"@eslint-react/types": "1.22.1-next.
|
|
52
|
+
"@eslint-react/ast": "1.22.1-next.2",
|
|
53
|
+
"@eslint-react/core": "1.22.1-next.2",
|
|
54
|
+
"@eslint-react/eff": "1.22.1-next.2",
|
|
55
|
+
"@eslint-react/jsx": "1.22.1-next.2",
|
|
56
|
+
"@eslint-react/shared": "1.22.1-next.2",
|
|
57
|
+
"@eslint-react/types": "1.22.1-next.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@types/react": "^19.0.2",
|
|
60
61
|
"@types/react-dom": "^19.0.2",
|
|
61
|
-
"string-ts": "^2.2.0",
|
|
62
62
|
"tsup": "^8.3.5",
|
|
63
63
|
"@workspace/configs": "0.0.0"
|
|
64
64
|
},
|