@eslint-react/shared 2.1.2-next.1 → 2.2.0-beta.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import { unit } from "@eslint-react/eff";
2
- import * as _eslint_react_kit0 from "@eslint-react/kit";
3
- import { CompatibleConfig, CompatiblePlugin, RuleContext } from "@eslint-react/kit";
4
2
  import { z } from "zod/v4";
3
+ import * as tseslint from "@typescript-eslint/utils/ts-eslint";
4
+ import { ReportDescriptor } from "@typescript-eslint/utils/ts-eslint";
5
5
  import { PartialDeep } from "type-fest";
6
6
 
7
7
  //#region src/_id.d.ts
@@ -29,6 +29,138 @@ declare const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
29
29
  * The URL to the project's website.
30
30
  */
31
31
  declare const WEBSITE_URL = "https://eslint-react.xyz";
32
+ /**
33
+ * Regular expressions for matching a HTML tag name
34
+ */
35
+ declare const RE_HTML_TAG: RegExp;
36
+ /**
37
+ * Regular expression for matching a TypeScript file extension.
38
+ */
39
+ declare const RE_TS_EXT: RegExp;
40
+ /**
41
+ * Regular expression for matching a JavaScript file extension.
42
+ */
43
+ declare const RE_JS_EXT: RegExp;
44
+ /**
45
+ * Regular expression for matching a PascalCase string.
46
+ */
47
+ declare const RE_PASCAL_CASE: RegExp;
48
+ /**
49
+ * Regular expression for matching a camelCase string.
50
+ */
51
+ declare const RE_CAMEL_CASE: RegExp;
52
+ /**
53
+ * Regular expression for matching a kebab-case string.
54
+ */
55
+ declare const RE_KEBAB_CASE: RegExp;
56
+ /**
57
+ * Regular expression for matching a snake_case string.
58
+ */
59
+ declare const RE_SNAKE_CASE: RegExp;
60
+ /**
61
+ * Regular expression for matching a CONSTANT_CASE string.
62
+ */
63
+ declare const RE_CONSTANT_CASE: RegExp;
64
+ declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
65
+ /**
66
+ * Regular expression for matching a valid JavaScript identifier.
67
+ */
68
+ declare const RE_JS_IDENTIFIER: RegExp;
69
+ /**
70
+ * Regular expression for matching a RegExp string.
71
+ */
72
+ declare const RE_REGEXP_STR: RegExp;
73
+ /**
74
+ * Regular expression for matching a `@jsx` annotation comment.
75
+ */
76
+ declare const RE_ANNOTATION_JSX: RegExp;
77
+ /**
78
+ * Regular expression for matching a `@jsxFrag` annotation comment.
79
+ */
80
+ declare const RE_ANNOTATION_JSX_FRAG: RegExp;
81
+ /**
82
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
83
+ */
84
+ declare const RE_ANNOTATION_JSX_RUNTIME: RegExp;
85
+ /**
86
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
87
+ */
88
+ declare const RE_ANNOTATION_JSX_IMPORT_SOURCE: RegExp;
89
+ /**
90
+ * Regular expression for matching a React component name.
91
+ */
92
+ declare const RE_COMPONENT_NAME: RegExp;
93
+ /**
94
+ * Regular expression for matching a React component name (loose).
95
+ */
96
+ declare const RE_COMPONENT_NAME_LOOSE: RegExp;
97
+ /**
98
+ * Regular expression for matching a React Hook name.
99
+ */
100
+ declare const RE_HOOK_NAME: RegExp;
101
+ //#endregion
102
+ //#region src/types.d.ts
103
+ /**
104
+ * Rule severity.
105
+ * @since 0.0.1
106
+ */
107
+ type SeverityName = "off" | "warn" | "error";
108
+ /**
109
+ * The numeric severity level for a rule.
110
+ *
111
+ * - `0` means off.
112
+ * - `1` means warn.
113
+ * - `2` means error.
114
+ */
115
+ type SeverityLevel = 0 | 1 | 2;
116
+ /**
117
+ * The severity of a rule in a configuration.
118
+ */
119
+ type Severity = SeverityName | SeverityLevel;
120
+ /**
121
+ * Rule declaration.
122
+ * @internal
123
+ * @since 0.0.1
124
+ */
125
+ type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
126
+ /**
127
+ * Rule context.
128
+ * @since 0.0.1
129
+ */
130
+ type RuleContext<MessageIds extends string = string, Options extends readonly unknown[] = readonly unknown[]> = tseslint.RuleContext<MessageIds, Options>;
131
+ /**
132
+ * Rule feature.
133
+ * @since 1.20.0
134
+ */
135
+ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
136
+ type RulePolicy = number;
137
+ type RuleSuggest<MessageIds extends string = string> = {
138
+ messageId: MessageIds;
139
+ data?: Record<string, unknown>;
140
+ fix: tseslint.ReportFixFunction;
141
+ };
142
+ /**
143
+ * A collection of settings.
144
+ */
145
+ interface SettingsConfig {
146
+ [key: string]: unknown;
147
+ }
148
+ interface CompatibleRule {
149
+ meta: Record<string, any>;
150
+ create: (...args: any[]) => any;
151
+ }
152
+ interface CompatiblePlugin {
153
+ meta: {
154
+ name: string;
155
+ version: string;
156
+ };
157
+ rules: Record<string, CompatibleRule>;
158
+ }
159
+ interface CompatibleConfig {
160
+ name?: string;
161
+ rules?: Record<string, RuleConfig>;
162
+ settings?: SettingsConfig;
163
+ }
32
164
  //#endregion
33
165
  //#region src/get-config-adapters.d.ts
34
166
  declare function getConfigAdapters(pluginName: string, plugin: CompatiblePlugin): {
@@ -37,14 +169,14 @@ declare function getConfigAdapters(pluginName: string, plugin: CompatiblePlugin)
37
169
  [pluginName]: CompatiblePlugin;
38
170
  };
39
171
  name?: string;
40
- rules?: Record<string, _eslint_react_kit0.RuleConfig>;
41
- settings?: _eslint_react_kit0.SettingsConfig;
172
+ rules?: Record<string, RuleConfig>;
173
+ settings?: SettingsConfig;
42
174
  };
43
175
  readonly toLegacyConfig: ({
44
176
  rules
45
177
  }: CompatibleConfig) => {
46
178
  plugins: string[];
47
- rules: Record<string, _eslint_react_kit0.RuleConfig<unknown[]>> | undefined;
179
+ rules: Record<string, RuleConfig<unknown[]>> | undefined;
48
180
  };
49
181
  };
50
182
  //#endregion
@@ -60,6 +192,28 @@ declare const getDocsUrl: (pluginName: string) => (ruleName: string) => string;
60
192
  //#region src/get-react-version.d.ts
61
193
  declare function getReactVersion(fallback: string): string;
62
194
  //#endregion
195
+ //#region src/regexp.d.ts
196
+ /**
197
+ * Convert a string to the `RegExp`.
198
+ * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
199
+ * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
200
+ * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
201
+ * @param string The string to convert.
202
+ * @returns Returns the `RegExp`.
203
+ */
204
+ declare function toRegExp(string: string): {
205
+ test(s: string): boolean;
206
+ };
207
+ /**
208
+ * Checks whether given string is regexp string
209
+ * @param string The string to check
210
+ * @returns boolean
211
+ */
212
+ declare function isRegExp(string: string): boolean;
213
+ //#endregion
214
+ //#region src/report.d.ts
215
+ declare function report(context: RuleContext): (descriptor?: null | ReportDescriptor<string>) => void;
216
+ //#endregion
63
217
  //#region src/settings.d.ts
64
218
  /**
65
219
  * Schema for ESLint React settings configuration
@@ -166,4 +320,4 @@ declare module "@typescript-eslint/utils/ts-eslint" {
166
320
  }
167
321
  }
168
322
  //#endregion
169
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
323
+ export { CompatibleConfig, CompatiblePlugin, CompatibleRule, DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettings, ESLintReactSettingsNormalized, ESLintReactSettingsSchema, ESLintSettings, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, RuleConfig, RuleContext, RuleFeature, RulePolicy, RuleSuggest, SettingsConfig, Severity, SeverityLevel, SeverityName, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@ import module from "node:module";
2
2
  import path from "node:path";
3
3
  import { getOrElseUpdate, identity } from "@eslint-react/eff";
4
4
  import { P, match } from "ts-pattern";
5
- import "@eslint-react/kit";
6
5
  import { z } from "zod/v4";
7
6
 
8
7
  //#region src/_id.ts
@@ -33,6 +32,75 @@ const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
33
32
  * The URL to the project's website.
34
33
  */
35
34
  const WEBSITE_URL = "https://eslint-react.xyz";
35
+ /**
36
+ * Regular expressions for matching a HTML tag name
37
+ */
38
+ const RE_HTML_TAG = /^[a-z][^-]*$/u;
39
+ /**
40
+ * Regular expression for matching a TypeScript file extension.
41
+ */
42
+ const RE_TS_EXT = /^[cm]?tsx?$/u;
43
+ /**
44
+ * Regular expression for matching a JavaScript file extension.
45
+ */
46
+ const RE_JS_EXT = /^[cm]?jsx?$/u;
47
+ /**
48
+ * Regular expression for matching a PascalCase string.
49
+ */
50
+ const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
51
+ /**
52
+ * Regular expression for matching a camelCase string.
53
+ */
54
+ const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
55
+ /**
56
+ * Regular expression for matching a kebab-case string.
57
+ */
58
+ const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
59
+ /**
60
+ * Regular expression for matching a snake_case string.
61
+ */
62
+ const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
63
+ /**
64
+ * Regular expression for matching a CONSTANT_CASE string.
65
+ */
66
+ const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
67
+ const RE_JAVASCRIPT_PROTOCOL = /^[\u0000-\u001F ]*j[\t\n\r]*a[\t\n\r]*v[\t\n\r]*a[\t\n\r]*s[\t\n\r]*c[\t\n\r]*r[\t\n\r]*i[\t\n\r]*p[\t\n\r]*t[\t\n\r]*:/iu;
68
+ /**
69
+ * Regular expression for matching a valid JavaScript identifier.
70
+ */
71
+ const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
72
+ /**
73
+ * Regular expression for matching a RegExp string.
74
+ */
75
+ const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
76
+ /**
77
+ * Regular expression for matching a `@jsx` annotation comment.
78
+ */
79
+ const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
80
+ /**
81
+ * Regular expression for matching a `@jsxFrag` annotation comment.
82
+ */
83
+ const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
84
+ /**
85
+ * Regular expression for matching a `@jsxRuntime` annotation comment.
86
+ */
87
+ const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
88
+ /**
89
+ * Regular expression for matching a `@jsxImportSource` annotation comment.
90
+ */
91
+ const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
92
+ /**
93
+ * Regular expression for matching a React component name.
94
+ */
95
+ const RE_COMPONENT_NAME = /^[A-Z]/u;
96
+ /**
97
+ * Regular expression for matching a React component name (loose).
98
+ */
99
+ const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
100
+ /**
101
+ * Regular expression for matching a React Hook name.
102
+ */
103
+ const RE_HOOK_NAME = /^use/u;
36
104
 
37
105
  //#endregion
38
106
  //#region src/get-config-adapters.ts
@@ -78,6 +146,39 @@ function getReactVersion(fallback) {
78
146
  }
79
147
  }
80
148
 
149
+ //#endregion
150
+ //#region src/regexp.ts
151
+ /**
152
+ * Convert a string to the `RegExp`.
153
+ * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
154
+ * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
155
+ * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
156
+ * @param string The string to convert.
157
+ * @returns Returns the `RegExp`.
158
+ */
159
+ function toRegExp(string) {
160
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
161
+ if (pattern != null) return new RegExp(pattern, flags);
162
+ return { test: (s) => s === string };
163
+ }
164
+ /**
165
+ * Checks whether given string is regexp string
166
+ * @param string The string to check
167
+ * @returns boolean
168
+ */
169
+ function isRegExp(string) {
170
+ return RE_REGEXP_STR.test(string);
171
+ }
172
+
173
+ //#endregion
174
+ //#region src/report.ts
175
+ function report(context) {
176
+ return (descriptor) => {
177
+ if (descriptor == null) return;
178
+ return context.report(descriptor);
179
+ };
180
+ }
181
+
81
182
  //#endregion
82
183
  //#region src/settings.ts
83
184
  /**
@@ -179,4 +280,4 @@ function getSettingsFromContext(context) {
179
280
  const defineSettings = identity;
180
281
 
181
282
  //#endregion
182
- export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, normalizeSettings };
283
+ export { DEFAULT_ESLINT_REACT_SETTINGS, DEFAULT_ESLINT_SETTINGS, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_CAMEL_CASE, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_CONSTANT_CASE, RE_HOOK_NAME, RE_HTML_TAG, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, WEBSITE_URL, _require, coerceESLintSettings, coerceSettings, decodeESLintSettings, decodeSettings, defineSettings, getConfigAdapters, getDocsUrl, getId, getReactVersion, getSettingsFromContext, isESLintReactSettings, isESLintSettings, isRegExp, normalizeSettings, report, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "2.1.2-next.1",
3
+ "version": "2.2.0-beta.0",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -30,14 +30,13 @@
30
30
  "@typescript-eslint/utils": "^8.46.0",
31
31
  "ts-pattern": "^5.8.0",
32
32
  "zod": "^4.1.12",
33
- "@eslint-react/eff": "2.1.2-next.1",
34
- "@eslint-react/kit": "2.1.2-next.1"
33
+ "@eslint-react/eff": "2.2.0-beta.0"
35
34
  },
36
35
  "devDependencies": {
37
36
  "@tsconfig/node22": "^22.0.2",
38
37
  "@types/picomatch": "^4.0.2",
39
38
  "tsdown": "^0.15.6",
40
- "type-fest": "^5.0.1",
39
+ "type-fest": "^5.1.0",
41
40
  "@local/configs": "0.0.0"
42
41
  },
43
42
  "engines": {