@eslint-react/kit
Advanced tools
Comparing version
@@ -62,5 +62,20 @@ import { _ } from '@eslint-react/eff'; | ||
declare function isInEditorEnv(): boolean; | ||
declare function isInGitHooksOrLintStaged(): boolean; | ||
/** | ||
* Convert a string to the `RegExp`. | ||
* Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`. | ||
* Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`. | ||
* | ||
* @param string The string to convert. | ||
* @returns Returns the `RegExp`. | ||
*/ | ||
declare function toRegExp(string: string): { | ||
test(s: string): boolean; | ||
}; | ||
/** | ||
* Checks whether given string is regexp string | ||
* @param string The string to check | ||
* @returns boolean | ||
*/ | ||
declare function isRegExp(string: string): boolean; | ||
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 }; | ||
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 }; |
@@ -39,14 +39,11 @@ 'use strict'; | ||
// src/env.ts | ||
function isInEditorEnv() { | ||
if (process.env["CI"]) { | ||
return false; | ||
} | ||
if (isInGitHooksOrLintStaged()) { | ||
return false; | ||
} | ||
return !!(process.env["VSCODE_PID"] || process.env["VSCODE_CWD"] || process.env["JETBRAINS_IDE"] || process.env["VIM"] || process.env["NVIM"]); | ||
// src/regexp.ts | ||
var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u; | ||
function toRegExp(string) { | ||
const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? []; | ||
if (pattern) return new RegExp(pattern, flags); | ||
return { test: (s) => s === string }; | ||
} | ||
function isInGitHooksOrLintStaged() { | ||
return !!(process.env["GIT_PARAMS"] || process.env["VSCODE_GIT_COMMAND"] || process.env["npm_lifecycle_script"]?.startsWith("lint-staged")); | ||
function isRegExp(string) { | ||
return Boolean(RE_REGEXP_STR.test(string)); | ||
} | ||
@@ -62,3 +59,3 @@ | ||
exports.createReport = createReport; | ||
exports.isInEditorEnv = isInEditorEnv; | ||
exports.isInGitHooksOrLintStaged = isInGitHooksOrLintStaged; | ||
exports.isRegExp = isRegExp; | ||
exports.toRegExp = toRegExp; |
{ | ||
"name": "@eslint-react/kit", | ||
"version": "1.38.0", | ||
"version": "1.38.1-beta.1", | ||
"description": "ESLint React's Plugin Kit for building plugins and rules.", | ||
@@ -40,3 +40,3 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"ts-pattern": "^5.6.2", | ||
"@eslint-react/eff": "1.38.0" | ||
"@eslint-react/eff": "1.38.1-beta.1" | ||
}, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11201
3.92%176
4.76%1
Infinity%+ Added
- Removed