eslint-plugin-react-naming-convention 3.0.0-next.48 → 3.0.0-next.50

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +3 -102
  3. package/package.json +6 -6
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,9 @@
1
- import { RE_CONSTANT_CASE, RE_PASCAL_CASE, WEBSITE_URL, defineRuleListener, getConfigAdapters, getSettingsFromContext, toRegExp } from "@eslint-react/shared";
1
+ import { WEBSITE_URL, defineRuleListener, getConfigAdapters } 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
- import { compare } from "compare-versions";
7
5
  import { P, match } from "ts-pattern";
6
+ import { ESLintUtils } from "@typescript-eslint/utils";
8
7
  import * as ast from "@eslint-react/ast";
9
8
 
10
9
  //#region \0rolldown/runtime.js
@@ -39,7 +38,7 @@ const rules = {
39
38
  //#endregion
40
39
  //#region package.json
41
40
  var name = "eslint-plugin-react-naming-convention";
42
- var version = "3.0.0-next.48";
41
+ var version = "3.0.0-next.50";
43
42
 
44
43
  //#endregion
45
44
  //#region src/utils/create-rule.ts
@@ -48,101 +47,6 @@ function getDocsUrl(ruleName) {
48
47
  }
49
48
  const createRule = ESLintUtils.RuleCreator(getDocsUrl);
50
49
 
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
50
  //#endregion
147
51
  //#region src/rules/context-name/context-name.ts
148
52
  const RULE_NAME$2 = "context-name";
@@ -159,8 +63,6 @@ var context_name_default = createRule({
159
63
  });
160
64
  function create$2(context) {
161
65
  if (!context.sourceCode.text.includes("createContext")) return {};
162
- const { version } = getSettingsFromContext(context);
163
- if (compare(version, "19.0.0", "<")) return {};
164
66
  return defineRuleListener({ CallExpression(node) {
165
67
  if (!core.isCreateContextCall(context, node)) return;
166
68
  const [id, name] = match(findEnclosingAssignmentTarget(node)).with({
@@ -256,7 +158,6 @@ const plugin = {
256
158
  version
257
159
  },
258
160
  rules: {
259
- ["component-name"]: component_name_default,
260
161
  ["context-name"]: context_name_default,
261
162
  ["id-name"]: id_name_default,
262
163
  ["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.48",
3
+ "version": "3.0.0-next.50",
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.48",
49
- "@eslint-react/eff": "3.0.0-next.48",
50
- "@eslint-react/shared": "3.0.0-next.48",
51
- "@eslint-react/var": "3.0.0-next.48",
52
- "@eslint-react/core": "3.0.0-next.48"
48
+ "@eslint-react/ast": "3.0.0-next.50",
49
+ "@eslint-react/core": "3.0.0-next.50",
50
+ "@eslint-react/eff": "3.0.0-next.50",
51
+ "@eslint-react/shared": "3.0.0-next.50",
52
+ "@eslint-react/var": "3.0.0-next.50"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",