eslint-plugin-react-naming-convention 3.0.0-next.47 → 3.0.0-next.49

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/README.md CHANGED
@@ -28,7 +28,7 @@ export default defineConfig(
28
28
  ],
29
29
  rules: {
30
30
  // Put rules you want to override here
31
- "react-naming-convention/component-name": "warn",
31
+ "react-naming-convention/context-name": "warn",
32
32
  },
33
33
  },
34
34
  );
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { RE_CONSTANT_CASE, RE_PASCAL_CASE, WEBSITE_URL, defineRuleListener, getConfigAdapters, getSettingsFromContext, toRegExp } from "@eslint-react/shared";
1
+ import { WEBSITE_URL, defineRuleListener, getConfigAdapters, getSettingsFromContext } from "@eslint-react/shared";
2
2
  import * as core from "@eslint-react/core";
3
- import { ESLintUtils } from "@typescript-eslint/utils";
4
3
  import { findEnclosingAssignmentTarget } from "@eslint-react/var";
5
4
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
6
5
  import { compare } from "compare-versions";
7
6
  import { P, match } from "ts-pattern";
7
+ import { ESLintUtils } from "@typescript-eslint/utils";
8
8
  import * as ast from "@eslint-react/ast";
9
9
 
10
10
  //#region \0rolldown/runtime.js
@@ -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 = "3.0.0-next.47";
42
+ var version = "3.0.0-next.49";
43
43
 
44
44
  //#endregion
45
45
  //#region src/utils/create-rule.ts
@@ -48,101 +48,6 @@ function getDocsUrl(ruleName) {
48
48
  }
49
49
  const createRule = ESLintUtils.RuleCreator(getDocsUrl);
50
50
 
51
- //#endregion
52
- //#region src/rules/component-name/component-name.ts
53
- const defaultOptions = [{
54
- allowAllCaps: false,
55
- excepts: [],
56
- rule: "PascalCase"
57
- }];
58
- const schema = [{ anyOf: [{
59
- type: "string",
60
- enum: ["PascalCase", "CONSTANT_CASE"]
61
- }, {
62
- type: "object",
63
- additionalProperties: false,
64
- properties: {
65
- allowAllCaps: { type: "boolean" },
66
- excepts: {
67
- type: "array",
68
- items: {
69
- type: "string",
70
- format: "regex"
71
- }
72
- },
73
- rule: {
74
- type: "string",
75
- enum: ["PascalCase", "CONSTANT_CASE"]
76
- }
77
- }
78
- }] }];
79
- const RULE_NAME$3 = "component-name";
80
- var component_name_default = createRule({
81
- meta: {
82
- type: "problem",
83
- defaultOptions: [...defaultOptions],
84
- docs: { description: "Enforces naming conventions for components." },
85
- messages: { invalidComponentName: "A component name '{{name}}' does not match {{rule}}." },
86
- schema
87
- },
88
- name: RULE_NAME$3,
89
- create: create$3,
90
- defaultOptions
91
- });
92
- function create$3(context) {
93
- const options = normalizeOptions(context.options);
94
- const { rule } = options;
95
- const fCollector = core.useComponentCollector(context);
96
- const cCollector = core.useComponentCollectorLegacy(context);
97
- return defineRuleListener(fCollector.visitor, cCollector.visitor, { "Program:exit"(program) {
98
- for (const { id, name, node: component } of fCollector.ctx.getAllComponents(program)) {
99
- if (isValidName(name, options)) continue;
100
- context.report({
101
- messageId: "invalidComponentName",
102
- node: id ?? component,
103
- data: {
104
- name,
105
- rule
106
- }
107
- });
108
- }
109
- for (const { id, name, node } of cCollector.ctx.getAllComponents(program)) {
110
- if (isValidName(name, options)) continue;
111
- context.report({
112
- messageId: "invalidComponentName",
113
- node: id ?? node,
114
- data: {
115
- name,
116
- rule
117
- }
118
- });
119
- }
120
- } });
121
- }
122
- function normalizeOptions(options) {
123
- const opts = options[0];
124
- const defaultOpts = defaultOptions[0];
125
- if (opts == null) return defaultOpts;
126
- return {
127
- ...defaultOpts,
128
- ...typeof opts === "string" ? { rule: opts } : {
129
- ...opts,
130
- excepts: opts.excepts?.map((s) => toRegExp(s)) ?? []
131
- }
132
- };
133
- }
134
- function isValidName(name, options) {
135
- if (name == null) return true;
136
- if (options.excepts.some((regex) => regex.test(name))) return true;
137
- const normalized = name.split(".").at(-1) ?? name;
138
- switch (options.rule) {
139
- case "CONSTANT_CASE": return RE_CONSTANT_CASE.test(normalized);
140
- case "PascalCase":
141
- if (normalized.length > 3 && /^[A-Z]+$/u.test(normalized)) return options.allowAllCaps;
142
- return RE_PASCAL_CASE.test(normalized);
143
- }
144
- }
145
-
146
51
  //#endregion
147
52
  //#region src/rules/context-name/context-name.ts
148
53
  const RULE_NAME$2 = "context-name";
@@ -256,7 +161,6 @@ const plugin = {
256
161
  version
257
162
  },
258
163
  rules: {
259
- ["component-name"]: component_name_default,
260
164
  ["context-name"]: context_name_default,
261
165
  ["id-name"]: id_name_default,
262
166
  ["ref-name"]: ref_name_default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-naming-convention",
3
- "version": "3.0.0-next.47",
3
+ "version": "3.0.0-next.49",
4
4
  "description": "ESLint React's ESLint plugin for naming convention related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -45,11 +45,11 @@
45
45
  "compare-versions": "^6.1.1",
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "3.0.0-next.47",
49
- "@eslint-react/core": "3.0.0-next.47",
50
- "@eslint-react/eff": "3.0.0-next.47",
51
- "@eslint-react/shared": "3.0.0-next.47",
52
- "@eslint-react/var": "3.0.0-next.47"
48
+ "@eslint-react/ast": "3.0.0-next.49",
49
+ "@eslint-react/core": "3.0.0-next.49",
50
+ "@eslint-react/eff": "3.0.0-next.49",
51
+ "@eslint-react/shared": "3.0.0-next.49",
52
+ "@eslint-react/var": "3.0.0-next.49"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",