eslint-plugin-react-naming-convention 2.0.0-next.14 → 2.0.0-next.140
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.d.ts +0 -6
- package/dist/index.js +15 -19
- package/package.json +16 -17
package/dist/index.d.ts
CHANGED
|
@@ -19,15 +19,12 @@ declare const _default: {
|
|
|
19
19
|
readonly rules: {
|
|
20
20
|
readonly "component-name": _typescript_eslint_utils_ts_eslint.RuleModule<"invalid", readonly [("CONSTANT_CASE" | "PascalCase") | {
|
|
21
21
|
allowAllCaps?: boolean;
|
|
22
|
-
allowLeadingUnderscore?: boolean;
|
|
23
|
-
allowNamespace?: boolean;
|
|
24
22
|
excepts?: readonly string[];
|
|
25
23
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
26
24
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
27
25
|
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"invalid", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
28
26
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
29
27
|
excepts?: readonly string[];
|
|
30
|
-
extensions?: readonly string[];
|
|
31
28
|
rule?: "PascalCase" | "camelCase" | "kebab-case" | "snake_case";
|
|
32
29
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
33
30
|
readonly "filename-extension": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("always" | "as-needed") | {
|
|
@@ -54,15 +51,12 @@ declare const _default: {
|
|
|
54
51
|
rules: {
|
|
55
52
|
readonly "component-name": _typescript_eslint_utils_ts_eslint.RuleModule<"invalid", readonly [("CONSTANT_CASE" | "PascalCase") | {
|
|
56
53
|
allowAllCaps?: boolean;
|
|
57
|
-
allowLeadingUnderscore?: boolean;
|
|
58
|
-
allowNamespace?: boolean;
|
|
59
54
|
excepts?: readonly string[];
|
|
60
55
|
rule?: "CONSTANT_CASE" | "PascalCase";
|
|
61
56
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
62
57
|
readonly "context-name": _typescript_eslint_utils_ts_eslint.RuleModule<"invalid", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
63
58
|
readonly filename: _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, readonly [("PascalCase" | "camelCase" | "kebab-case" | "snake_case") | {
|
|
64
59
|
excepts?: readonly string[];
|
|
65
|
-
extensions?: readonly string[];
|
|
66
60
|
rule?: "PascalCase" | "camelCase" | "kebab-case" | "snake_case";
|
|
67
61
|
} | undefined], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
68
62
|
readonly "filename-extension": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, readonly [("always" | "as-needed") | {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
6
6
|
import { identity, isObject } from '@eslint-react/eff';
|
|
7
7
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
8
8
|
import { match, P } from 'ts-pattern';
|
|
9
|
-
import path from '
|
|
9
|
+
import path from 'path';
|
|
10
10
|
import { snakeCase, pascalCase, camelCase, kebabCase } from 'string-ts';
|
|
11
11
|
|
|
12
12
|
var __defProp = Object.defineProperty;
|
|
@@ -29,7 +29,7 @@ var rules = {
|
|
|
29
29
|
|
|
30
30
|
// package.json
|
|
31
31
|
var name2 = "eslint-plugin-react-naming-convention";
|
|
32
|
-
var version = "2.0.0-next.
|
|
32
|
+
var version = "2.0.0-next.140";
|
|
33
33
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("naming-convention"));
|
|
34
34
|
|
|
35
35
|
// src/rules/component-name.ts
|
|
@@ -52,16 +52,6 @@ var schema = [
|
|
|
52
52
|
additionalProperties: false,
|
|
53
53
|
properties: {
|
|
54
54
|
allowAllCaps: { type: "boolean" },
|
|
55
|
-
/**
|
|
56
|
-
* @todo Remove in the next major version
|
|
57
|
-
* @deprecated
|
|
58
|
-
*/
|
|
59
|
-
allowLeadingUnderscore: { type: "boolean" },
|
|
60
|
-
/**
|
|
61
|
-
* @todo Remove in the next major version
|
|
62
|
-
* @deprecated
|
|
63
|
-
*/
|
|
64
|
-
allowNamespace: { type: "boolean" },
|
|
65
55
|
excepts: {
|
|
66
56
|
type: "array",
|
|
67
57
|
items: { type: "string", format: "regex" }
|
|
@@ -107,7 +97,7 @@ function create(context) {
|
|
|
107
97
|
const id = AST.getFunctionId(component);
|
|
108
98
|
if (id?.name == null) continue;
|
|
109
99
|
const name3 = id.name;
|
|
110
|
-
if (isValidName(name3, options))
|
|
100
|
+
if (isValidName(name3, options)) continue;
|
|
111
101
|
context.report({
|
|
112
102
|
messageId: "invalid",
|
|
113
103
|
node: id,
|
|
@@ -189,8 +179,13 @@ function create2(context) {
|
|
|
189
179
|
var RULE_NAME3 = "filename";
|
|
190
180
|
var defaultOptions2 = [
|
|
191
181
|
{
|
|
192
|
-
excepts: [
|
|
193
|
-
|
|
182
|
+
excepts: [
|
|
183
|
+
"index",
|
|
184
|
+
"/^_/",
|
|
185
|
+
"/^\\$/",
|
|
186
|
+
"/^[0-9]+$/",
|
|
187
|
+
"/^\\[[^\\]]+\\]$/"
|
|
188
|
+
],
|
|
194
189
|
rule: "PascalCase"
|
|
195
190
|
}
|
|
196
191
|
];
|
|
@@ -243,11 +238,12 @@ var filename_default = createRule({
|
|
|
243
238
|
function create3(context) {
|
|
244
239
|
const options = context.options[0] ?? defaultOptions2[0];
|
|
245
240
|
const rule = typeof options === "string" ? options : options.rule ?? "PascalCase";
|
|
246
|
-
const excepts = typeof options === "string" ? [] : options.excepts ?? [];
|
|
241
|
+
const excepts = typeof options === "string" ? [] : (options.excepts ?? []).map((s) => RegExp.toRegExp(s));
|
|
247
242
|
function validate(name3, casing = rule, ignores = excepts) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
243
|
+
if (ignores.some((pattern) => pattern.test(name3))) return true;
|
|
244
|
+
const filteredName = name3.match(/[\w-]/gu)?.join("") ?? "";
|
|
245
|
+
if (filteredName.length === 0) return true;
|
|
246
|
+
return match(casing).with("PascalCase", () => RegExp.PASCAL_CASE.test(filteredName)).with("camelCase", () => RegExp.CAMEL_CASE.test(filteredName)).with("kebab-case", () => RegExp.KEBAB_CASE.test(filteredName)).with("snake_case", () => RegExp.SNAKE_CASE.test(filteredName)).exhaustive();
|
|
251
247
|
}
|
|
252
248
|
function getSuggestion(name3, casing = rule) {
|
|
253
249
|
return match(casing).with("PascalCase", () => pascalCase(name3)).with("camelCase", () => camelCase(name3)).with("kebab-case", () => kebabCase(name3)).with("snake_case", () => snakeCase(name3)).exhaustive();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-naming-convention",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.140",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for naming convention related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,27 +35,27 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
39
|
-
"@typescript-eslint/type-utils": "^8.
|
|
40
|
-
"@typescript-eslint/types": "^8.
|
|
41
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/scope-manager": "^8.40.0",
|
|
39
|
+
"@typescript-eslint/type-utils": "^8.40.0",
|
|
40
|
+
"@typescript-eslint/types": "^8.40.0",
|
|
41
|
+
"@typescript-eslint/utils": "^8.40.0",
|
|
42
42
|
"string-ts": "^2.2.1",
|
|
43
|
-
"ts-pattern": "^5.
|
|
44
|
-
"@eslint-react/ast": "2.0.0-next.
|
|
45
|
-
"@eslint-react/core": "2.0.0-next.
|
|
46
|
-
"@eslint-react/eff": "2.0.0-next.
|
|
47
|
-
"@eslint-react/kit": "2.0.0-next.
|
|
48
|
-
"@eslint-react/shared": "2.0.0-next.
|
|
49
|
-
"@eslint-react/var": "2.0.0-next.
|
|
43
|
+
"ts-pattern": "^5.8.0",
|
|
44
|
+
"@eslint-react/ast": "2.0.0-next.140",
|
|
45
|
+
"@eslint-react/core": "2.0.0-next.140",
|
|
46
|
+
"@eslint-react/eff": "2.0.0-next.140",
|
|
47
|
+
"@eslint-react/kit": "2.0.0-next.140",
|
|
48
|
+
"@eslint-react/shared": "2.0.0-next.140",
|
|
49
|
+
"@eslint-react/var": "2.0.0-next.140"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/react": "^19.1.
|
|
53
|
-
"@types/react-dom": "^19.1.
|
|
54
|
-
"tsup": "^8.
|
|
52
|
+
"@types/react": "^19.1.10",
|
|
53
|
+
"@types/react-dom": "^19.1.7",
|
|
54
|
+
"tsup": "^8.5.0",
|
|
55
55
|
"@local/configs": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"eslint": "^9.
|
|
58
|
+
"eslint": "^9.33.0",
|
|
59
59
|
"typescript": "^4.9.5 || ^5.4.5"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
@@ -67,7 +67,6 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
|
-
"bun": ">=1.0.15",
|
|
71
70
|
"node": ">=20.19.0"
|
|
72
71
|
},
|
|
73
72
|
"publishConfig": {
|