@eslint-react/kit 1.38.0 → 1.38.1-beta.3

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.mts CHANGED
@@ -59,7 +59,22 @@ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
59
59
  */
60
60
  declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
61
61
 
62
- declare function isInEditorEnv(): boolean;
63
- declare function isInGitHooksOrLintStaged(): boolean;
62
+ /**
63
+ * Convert a string to the `RegExp`.
64
+ * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
65
+ * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
66
+ *
67
+ * @param string The string to convert.
68
+ * @returns Returns the `RegExp`.
69
+ */
70
+ declare function toRegExp(string: string): {
71
+ test(s: string): boolean;
72
+ };
73
+ /**
74
+ * Checks whether given string is regexp string
75
+ * @param string The string to check
76
+ * @returns boolean
77
+ */
78
+ declare function isRegExp(string: string): boolean;
64
79
 
65
- export { REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isInEditorEnv, isInGitHooksOrLintStaged };
80
+ export { REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
package/dist/index.d.ts CHANGED
@@ -59,7 +59,22 @@ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
59
59
  */
60
60
  declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
61
61
 
62
- declare function isInEditorEnv(): boolean;
63
- declare function isInGitHooksOrLintStaged(): boolean;
62
+ /**
63
+ * Convert a string to the `RegExp`.
64
+ * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
65
+ * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
66
+ *
67
+ * @param string The string to convert.
68
+ * @returns Returns the `RegExp`.
69
+ */
70
+ declare function toRegExp(string: string): {
71
+ test(s: string): boolean;
72
+ };
73
+ /**
74
+ * Checks whether given string is regexp string
75
+ * @param string The string to check
76
+ * @returns boolean
77
+ */
78
+ declare function isRegExp(string: string): boolean;
64
79
 
65
- export { REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isInEditorEnv, isInGitHooksOrLintStaged };
80
+ export { REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
package/dist/index.js CHANGED
@@ -36,18 +36,15 @@ function createReport(context) {
36
36
  };
37
37
  }
38
38
 
39
- // src/env.ts
40
- function isInEditorEnv() {
41
- if (process.env["CI"]) {
42
- return false;
43
- }
44
- if (isInGitHooksOrLintStaged()) {
45
- return false;
46
- }
47
- return !!(process.env["VSCODE_PID"] || process.env["VSCODE_CWD"] || process.env["JETBRAINS_IDE"] || process.env["VIM"] || process.env["NVIM"]);
39
+ // src/regexp.ts
40
+ var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
41
+ function toRegExp(string) {
42
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
43
+ if (pattern) return new RegExp(pattern, flags);
44
+ return { test: (s) => s === string };
48
45
  }
49
- function isInGitHooksOrLintStaged() {
50
- return !!(process.env["GIT_PARAMS"] || process.env["VSCODE_GIT_COMMAND"] || process.env["npm_lifecycle_script"]?.startsWith("lint-staged"));
46
+ function isRegExp(string) {
47
+ return Boolean(RE_REGEXP_STR.test(string));
51
48
  }
52
49
 
53
50
  exports.REACT_BUILD_IN_HOOKS = REACT_BUILD_IN_HOOKS;
@@ -58,5 +55,5 @@ exports.RE_KEBAB_CASE = RE_KEBAB_CASE;
58
55
  exports.RE_PASCAL_CASE = RE_PASCAL_CASE;
59
56
  exports.RE_SNAKE_CASE = RE_SNAKE_CASE;
60
57
  exports.createReport = createReport;
61
- exports.isInEditorEnv = isInEditorEnv;
62
- exports.isInGitHooksOrLintStaged = isInGitHooksOrLintStaged;
58
+ exports.isRegExp = isRegExp;
59
+ exports.toRegExp = toRegExp;
package/dist/index.mjs CHANGED
@@ -34,18 +34,15 @@ function createReport(context) {
34
34
  };
35
35
  }
36
36
 
37
- // src/env.ts
38
- function isInEditorEnv() {
39
- if (process.env["CI"]) {
40
- return false;
41
- }
42
- if (isInGitHooksOrLintStaged()) {
43
- return false;
44
- }
45
- return !!(process.env["VSCODE_PID"] || process.env["VSCODE_CWD"] || process.env["JETBRAINS_IDE"] || process.env["VIM"] || process.env["NVIM"]);
37
+ // src/regexp.ts
38
+ var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
39
+ function toRegExp(string) {
40
+ const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
41
+ if (pattern) return new RegExp(pattern, flags);
42
+ return { test: (s) => s === string };
46
43
  }
47
- function isInGitHooksOrLintStaged() {
48
- return !!(process.env["GIT_PARAMS"] || process.env["VSCODE_GIT_COMMAND"] || process.env["npm_lifecycle_script"]?.startsWith("lint-staged"));
44
+ function isRegExp(string) {
45
+ return Boolean(RE_REGEXP_STR.test(string));
49
46
  }
50
47
 
51
- export { REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, createReport, isInEditorEnv, isInGitHooksOrLintStaged };
48
+ export { REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, createReport, isRegExp, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "1.38.0",
3
+ "version": "1.38.1-beta.3",
4
4
  "description": "ESLint React's Plugin Kit for building plugins and rules.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@typescript-eslint/utils": "^8.28.0",
39
39
  "ts-pattern": "^5.6.2",
40
- "@eslint-react/eff": "1.38.0"
40
+ "@eslint-react/eff": "1.38.1-beta.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@tsconfig/node22": "^22.0.1",