@bfra.me/eslint-config 0.44.1 → 0.44.2

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/lib/index.d.ts CHANGED
@@ -17416,32 +17416,6 @@ declare function defineConfig<C extends Config = Config, CN extends ConfigNames
17416
17416
  */
17417
17417
  declare const composeConfig: <C extends Config = Config, CN extends ConfigNames = ConfigNames>(...configs: ResolvableFlatConfig<Config extends C ? C : Config>[]) => FlatConfigComposer<Config extends C ? C : Config, CN>;
17418
17418
 
17419
- /**
17420
- * Check if the process is running in a Git hook or under lint-staged.
17421
- *
17422
- * @example
17423
- * ```ts
17424
- * import {isInGitLifecycle} from '@bfra.me/eslint-config'
17425
- *
17426
- * if (isInGitLifecycle) {
17427
- * console.log('Running in a Git hook or under lint-staged')
17428
- * }
17429
- * ```
17430
- */
17431
- declare const isInGitLifecycle: boolean;
17432
- /**
17433
- * Check if the process is running in an editor.
17434
- *
17435
- * @example
17436
- * ```ts
17437
- * import {isInEditor} from '@bfra.me/eslint-config'
17438
- *
17439
- * if (isInEditor) {
17440
- * console.log('Running in an editor')
17441
- * }
17442
- */
17443
- declare const isInEditor: boolean;
17444
-
17445
17419
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
17446
17420
  declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
17447
17421
  declare const GLOB_JS = "**/*.?([cm])js";
@@ -17472,4 +17446,4 @@ declare const GLOB_EXCLUDE: string[];
17472
17446
 
17473
17447
  declare const config: eslint_flat_config_utils.FlatConfigComposer<Config, ConfigNames>;
17474
17448
 
17475
- export { type AstroOptions, type Config, type ConfigNames, type FallbackOptions, type Flatten, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CODE_IN_MARKDOWN_FILES, GLOB_EXCLUDE, GLOB_EXT_IN_MARKDOWN_FILES, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_FILES, GLOB_JSX, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_FILES, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_PACKAGE_JSON_FILES, GLOB_RENOVATE_CONFIG, GLOB_SRC, GLOB_SRC_EXT, GLOB_TESTS, GLOB_TOML, GLOB_TOML_FILES, GLOB_TS, GLOB_TSX, GLOB_TS_CONFIG, GLOB_YAML, GLOB_YAML_FILES, type ImportsOptions, type JSDocOptions, type JavaScriptOptions, type JsoncOptions, type MarkdownCodeBlockOptions, type MarkdownFrontmatterOptions, type MarkdownLanguage, type MarkdownOptions, type NextjsOptions, type Options, type OptionsFiles, type OptionsIsInEditor, type OptionsOverrides, type OptionsPerfectionist, type OptionsStylistic, type OptionsTypeScript, type OptionsTypeScriptErasableSyntaxOnly, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type PackageJsonOptions, type PerfectionistOptions, type PrettierOptions, type ReactOptions, type RegexpOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TomlOptions, type TypeScriptOptions, type UnicornOptions, type VitestOptions, type YamlOptions, astro, command, composeConfig, config, config as default, defineConfig, epilogue, eslintComments, fallback, gitignore, ignores, imports, isInEditor, isInGitLifecycle, javascript, jsdoc, jsonc, markdown, nextjs, node, packageJson, perfectionist, pnpm, prettier, react, regexp, sortPackageJson, sortRenovateConfig, sortTsconfig, stylistic, toml, typescript, unicorn, vitest, yaml };
17449
+ export { type AstroOptions, type Config, type ConfigNames, type FallbackOptions, type Flatten, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CODE_IN_MARKDOWN_FILES, GLOB_EXCLUDE, GLOB_EXT_IN_MARKDOWN_FILES, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSON_FILES, GLOB_JSX, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_FILES, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_PACKAGE_JSON_FILES, GLOB_RENOVATE_CONFIG, GLOB_SRC, GLOB_SRC_EXT, GLOB_TESTS, GLOB_TOML, GLOB_TOML_FILES, GLOB_TS, GLOB_TSX, GLOB_TS_CONFIG, GLOB_YAML, GLOB_YAML_FILES, type ImportsOptions, type JSDocOptions, type JavaScriptOptions, type JsoncOptions, type MarkdownCodeBlockOptions, type MarkdownFrontmatterOptions, type MarkdownLanguage, type MarkdownOptions, type NextjsOptions, type Options, type OptionsFiles, type OptionsIsInEditor, type OptionsOverrides, type OptionsPerfectionist, type OptionsStylistic, type OptionsTypeScript, type OptionsTypeScriptErasableSyntaxOnly, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type PackageJsonOptions, type PerfectionistOptions, type PrettierOptions, type ReactOptions, type RegexpOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TomlOptions, type TypeScriptOptions, type UnicornOptions, type VitestOptions, type YamlOptions, astro, command, composeConfig, config, config as default, defineConfig, epilogue, eslintComments, fallback, gitignore, ignores, imports, javascript, jsdoc, jsonc, markdown, nextjs, node, packageJson, perfectionist, pnpm, prettier, react, regexp, sortPackageJson, sortRenovateConfig, sortTsconfig, stylistic, toml, typescript, unicorn, vitest, yaml };
package/lib/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // src/define-config.ts
2
+ import { isPackageExists as isPackageExists4 } from "local-pkg";
3
+
1
4
  // src/compose-config.ts
2
5
  import { composer } from "eslint-flat-config-utils";
3
6
  var composeConfig = (...configs) => composer(...configs);
@@ -109,7 +112,7 @@ var GLOB_EXCLUDE = [
109
112
  import { fileURLToPath } from "url";
110
113
 
111
114
  // package.json
112
- var version = "0.44.1";
115
+ var version = "0.44.2";
113
116
 
114
117
  // src/parsers/any-parser.ts
115
118
  var lineBreakPattern = /\r\n|[\n\r\u2028\u2029]/u;
@@ -143,7 +146,9 @@ function parseForESLint(text) {
143
146
  var anyParser = { meta, parseForESLint };
144
147
 
145
148
  // src/utils.ts
149
+ import process from "process";
146
150
  import { fileURLToPath as fileURLToPath2 } from "url";
151
+ import isInCI from "is-in-ci";
147
152
  import { isPackageExists } from "local-pkg";
148
153
  var scopeUrl = fileURLToPath2(new URL(".", import.meta.url));
149
154
  // @__NO_SIDE_EFFECTS__
@@ -154,6 +159,14 @@ async function interopDefault(m) {
154
159
  function isPackageInScope(name) {
155
160
  return isPackageExists(name, { paths: [scopeUrl] });
156
161
  }
162
+ function isInGitLifecycle() {
163
+ return !!(typeof process.env.GIT_PARAMS === "string" && process.env.GIT_PARAMS.length > 0 || typeof process.env.VSCODE_GIT_COMMAND === "string" && process.env.VSCODE_GIT_COMMAND.length > 0 || process.env.npm_lifecycle_script?.startsWith("lint-staged") || process.env.npm_lifecycle_script?.startsWith("nano-staged"));
164
+ }
165
+ function isInEditorEnv() {
166
+ if (isInCI) return false;
167
+ if (isInGitLifecycle()) return false;
168
+ return !!(typeof process.env.VSCODE_PID === "string" && process.env.VSCODE_PID.length > 0 || typeof process.env.VSCODE_CWD === "string" && process.env.VSCODE_CWD.length > 0 || typeof process.env.JETBRAINS_IDE === "string" && process.env.JETBRAINS_IDE.length > 0 || typeof process.env.VIM === "string" && process.env.VIM.length > 0 || typeof process.env.NVIM === "string" && process.env.NVIM.length > 0);
169
+ }
157
170
 
158
171
  // src/require-of.ts
159
172
  var packageExistsCache = /* @__PURE__ */ new Map();
@@ -384,7 +397,7 @@ function imports(options = {}) {
384
397
  // src/configs/javascript.ts
385
398
  import globals from "globals";
386
399
  async function javascript(options = {}) {
387
- const { isInEditor: isInEditor2 = false, jsx = true, overrides = {} } = options;
400
+ const { isInEditor = false, jsx = true, overrides = {} } = options;
388
401
  const pluginUnusedImports = await interopDefault(import("eslint-plugin-unused-imports"));
389
402
  return [
390
403
  {
@@ -573,7 +586,7 @@ async function javascript(options = {}) {
573
586
  "prefer-template": "error",
574
587
  "symbol-description": "error",
575
588
  "unicode-bom": ["error", "never"],
576
- "unused-imports/no-unused-imports": isInEditor2 ? "off" : "error",
589
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
577
590
  "unused-imports/no-unused-vars": [
578
591
  "error",
579
592
  {
@@ -1056,7 +1069,7 @@ async function packageJson(options = {}) {
1056
1069
  // src/configs/perfectionist.ts
1057
1070
  async function perfectionist(options = {}) {
1058
1071
  const {
1059
- isInEditor: isInEditor2 = false,
1072
+ isInEditor = false,
1060
1073
  overrides = {},
1061
1074
  sortExports = true,
1062
1075
  sortImports = true,
@@ -1073,22 +1086,22 @@ async function perfectionist(options = {}) {
1073
1086
  rules: {
1074
1087
  ...sortNamedExports && {
1075
1088
  "perfectionist/sort-named-exports": [
1076
- isInEditor2 ? "warn" : "error",
1089
+ isInEditor ? "warn" : "error",
1077
1090
  { groupKind: "values-first", type: "natural" }
1078
1091
  ]
1079
1092
  },
1080
1093
  ...sortNamedImports && {
1081
1094
  "perfectionist/sort-named-imports": [
1082
- isInEditor2 ? "warn" : "error",
1095
+ isInEditor ? "warn" : "error",
1083
1096
  { groupKind: "values-first", type: "natural" }
1084
1097
  ]
1085
1098
  },
1086
1099
  ...sortExports && {
1087
- "perfectionist/sort-exports": [isInEditor2 ? "warn" : "error", { type: "natural" }]
1100
+ "perfectionist/sort-exports": [isInEditor ? "warn" : "error", { type: "natural" }]
1088
1101
  },
1089
1102
  ...sortImports && {
1090
1103
  "perfectionist/sort-imports": [
1091
- isInEditor2 ? "warn" : "error",
1104
+ isInEditor ? "warn" : "error",
1092
1105
  {
1093
1106
  groups: [
1094
1107
  "type",
@@ -1156,14 +1169,14 @@ async function pnpm() {
1156
1169
  }
1157
1170
 
1158
1171
  // src/configs/prettier.ts
1159
- import process from "process";
1172
+ import process2 from "process";
1160
1173
  import { isPackageExists as isPackageExists2 } from "local-pkg";
1161
1174
  async function prettier(options = {}) {
1162
- const { isInEditor: isInEditor2, overrides } = options;
1175
+ const { isInEditor, overrides } = options;
1163
1176
  return requireOf(
1164
1177
  ["eslint-config-prettier", "eslint-plugin-prettier", "prettier"],
1165
1178
  async () => {
1166
- process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED ??= "true";
1179
+ process2.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED ??= "true";
1167
1180
  const [configPrettier, pluginPrettier, pluginJsonc, pluginYaml] = await Promise.all([
1168
1181
  interopDefault(import("eslint-config-prettier")),
1169
1182
  interopDefault(import("eslint-plugin-prettier")),
@@ -1177,7 +1190,7 @@ async function prettier(options = {}) {
1177
1190
  prettier: pluginPrettier
1178
1191
  },
1179
1192
  rules: {
1180
- "prettier/prettier": isInEditor2 ? "warn" : "error",
1193
+ "prettier/prettier": isInEditor ? "warn" : "error",
1181
1194
  ...configPrettier.rules,
1182
1195
  ...pluginJsonc?.configs.prettier.rules,
1183
1196
  "toml/array-bracket-newline": "off",
@@ -1739,7 +1752,7 @@ async function toml(options = {}) {
1739
1752
  }
1740
1753
 
1741
1754
  // src/configs/typescript.ts
1742
- import process2 from "process";
1755
+ import process3 from "process";
1743
1756
  var TypeAwareRules = {
1744
1757
  "@typescript-eslint/await-thenable": "error",
1745
1758
  "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
@@ -1830,7 +1843,7 @@ async function typescript(options = {}) {
1830
1843
  allowDefaultProject: ["./*.js"],
1831
1844
  defaultProject: tsconfigPath
1832
1845
  },
1833
- tsconfigRootDir: process2.cwd()
1846
+ tsconfigRootDir: process3.cwd()
1834
1847
  } : {},
1835
1848
  ...parserOptions
1836
1849
  }
@@ -2034,7 +2047,7 @@ async function unicorn(options = {}) {
2034
2047
 
2035
2048
  // src/configs/vitest.ts
2036
2049
  async function vitest(options = {}) {
2037
- const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {}, tsconfigPath } = options;
2050
+ const { files = GLOB_TESTS, isInEditor = false, overrides = {}, tsconfigPath } = options;
2038
2051
  const isTypeAware = typeof tsconfigPath === "string" && tsconfigPath.trim().length > 0;
2039
2052
  return requireOf(
2040
2053
  ["@vitest/eslint-plugin"],
@@ -2062,7 +2075,7 @@ async function vitest(options = {}) {
2062
2075
  rules: {
2063
2076
  ...vitest2.configs?.recommended.rules ?? {},
2064
2077
  "vitest/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
2065
- "vitest/no-focused-tests": isInEditor2 ? "off" : ["error", { fixable: true }],
2078
+ "vitest/no-focused-tests": isInEditor ? "off" : ["error", { fixable: true }],
2066
2079
  "vitest/no-import-node-test": "error",
2067
2080
  "vitest/prefer-hooks-in-order": "error",
2068
2081
  "vitest/prefer-lowercase-title": "error",
@@ -2135,14 +2148,6 @@ async function yaml(options = {}) {
2135
2148
  ];
2136
2149
  }
2137
2150
 
2138
- // src/env.ts
2139
- import { env } from "process";
2140
- import isInCI from "is-in-ci";
2141
- var isInGitLifecycle = !!(typeof env.GIT_PARAMS === "string" && env.GIT_PARAMS.length > 0 || typeof env.VSCODE_GIT_COMMAND === "string" && env.VSCODE_GIT_COMMAND.length > 0 || env.npm_lifecycle_script?.startsWith("lint-staged") || env.npm_lifecycle_script?.startsWith("nano-staged"));
2142
- var isInEditor = !isInCI && !isInGitLifecycle && Boolean(
2143
- typeof env.VSCODE_PID === "string" && env.VSCODE_PID.length > 0 || typeof env.VSCODE_CWD === "string" && env.VSCODE_CWD.length > 0 || typeof env.JETBRAINS_IDE === "string" && env.JETBRAINS_IDE.length > 0 || typeof env.VIM === "string" && env.VIM.length > 0 || typeof env.NVIM === "string" && env.NVIM.length > 0
2144
- );
2145
-
2146
2151
  // src/define-config.ts
2147
2152
  var AllowedConfigPropertiesForOptions = [
2148
2153
  "name",
@@ -2165,17 +2170,21 @@ async function defineConfig(options = {}, ...userConfigs) {
2165
2170
  packageJson: enablePackageJson = false,
2166
2171
  perfectionist: enablePerfectionist = true,
2167
2172
  pnpm: enableCatalogs = false,
2168
- prettier: enablePrettier = isPackageInScope("prettier"),
2173
+ prettier: enablePrettier = isPackageExists4("prettier"),
2169
2174
  react: enableReact = false,
2170
2175
  regexp: enableRegexp = true,
2171
- typescript: enableTypeScript = isPackageInScope("typescript"),
2176
+ typescript: enableTypeScript = isPackageExists4("typescript"),
2172
2177
  unicorn: enableUnicorn = true
2173
2178
  } = options;
2174
- const isInEditor2 = options.isInEditor ?? isInEditor;
2175
- if (isInEditor2)
2176
- console.log(
2177
- "[@bfra.me/eslint-config] Editor specific config is enabled. Some rules may be disabled."
2178
- );
2179
+ let isInEditor = options.isInEditor;
2180
+ if (isInEditor == null) {
2181
+ isInEditor = isInEditorEnv();
2182
+ if (isInEditor) {
2183
+ console.log(
2184
+ "[@bfra.me/eslint-config] Editor specific config is enabled. Some rules may be disabled."
2185
+ );
2186
+ }
2187
+ }
2179
2188
  const stylisticOptions = options.stylistic === false || enablePrettier ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2180
2189
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
2181
2190
  stylisticOptions.jsx = typeof enableJsx === "object" ? true : enableJsx;
@@ -2186,7 +2195,7 @@ async function defineConfig(options = {}, ...userConfigs) {
2186
2195
  }
2187
2196
  configs.push(
2188
2197
  ignores(options.ignores),
2189
- javascript({ isInEditor: isInEditor2, jsx: enableJsx, overrides: getOverrides(options, "javascript") }),
2198
+ javascript({ isInEditor, jsx: enableJsx, overrides: getOverrides(options, "javascript") }),
2190
2199
  eslintComments(),
2191
2200
  node(),
2192
2201
  jsdoc({ stylistic: stylisticOptions }),
@@ -2199,7 +2208,7 @@ async function defineConfig(options = {}, ...userConfigs) {
2199
2208
  if (enablePerfectionist) {
2200
2209
  configs.push(
2201
2210
  perfectionist({
2202
- isInEditor: isInEditor2,
2211
+ isInEditor,
2203
2212
  overrides: getOverrides(options, "perfectionist"),
2204
2213
  ...resolveSubOptions(options, "perfectionist")
2205
2214
  })
@@ -2240,7 +2249,7 @@ async function defineConfig(options = {}, ...userConfigs) {
2240
2249
  if (options.vitest) {
2241
2250
  configs.push(
2242
2251
  vitest({
2243
- isInEditor: isInEditor2,
2252
+ isInEditor,
2244
2253
  overrides: getOverrides(options, "vitest"),
2245
2254
  tsconfigPath
2246
2255
  })
@@ -2309,7 +2318,7 @@ async function defineConfig(options = {}, ...userConfigs) {
2309
2318
  if (enablePrettier) {
2310
2319
  configs.push(
2311
2320
  prettier({
2312
- isInEditor: isInEditor2,
2321
+ isInEditor,
2313
2322
  overrides: getOverrides(options, "prettier")
2314
2323
  })
2315
2324
  );
@@ -2379,8 +2388,6 @@ export {
2379
2388
  gitignore,
2380
2389
  ignores,
2381
2390
  imports,
2382
- isInEditor,
2383
- isInGitLifecycle,
2384
2391
  javascript,
2385
2392
  jsdoc,
2386
2393
  jsonc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bfra.me/eslint-config",
3
- "version": "0.44.1",
3
+ "version": "0.44.2",
4
4
  "description": "Shared ESLint configuration for bfra.me",
5
5
  "keywords": [
6
6
  "bfra.me",
@@ -1,5 +1,6 @@
1
1
  import type {Config, ConfigNames, FlatConfigComposer, ResolvableFlatConfig} from './config'
2
2
  import type {Options} from './options'
3
+ import {isPackageExists} from 'local-pkg'
3
4
  import {composeConfig} from './compose-config'
4
5
  import {
5
6
  astro,
@@ -31,8 +32,7 @@ import {
31
32
  vitest,
32
33
  yaml,
33
34
  } from './configs'
34
- import * as Env from './env'
35
- import {isPackageInScope} from './utils'
35
+ import {isInEditorEnv} from './utils'
36
36
 
37
37
  // These are merged into the Options interface
38
38
  type AllowedConfigForOptions = Omit<Config, 'files'>
@@ -71,19 +71,23 @@ export async function defineConfig<C extends Config = Config, CN extends ConfigN
71
71
  packageJson: enablePackageJson = false,
72
72
  perfectionist: enablePerfectionist = true,
73
73
  pnpm: enableCatalogs = false,
74
- prettier: enablePrettier = isPackageInScope('prettier'),
74
+ prettier: enablePrettier = isPackageExists('prettier'),
75
75
  react: enableReact = false,
76
76
  regexp: enableRegexp = true,
77
- typescript: enableTypeScript = isPackageInScope('typescript'),
77
+ typescript: enableTypeScript = isPackageExists('typescript'),
78
78
  unicorn: enableUnicorn = true,
79
79
  } = options
80
80
 
81
- const isInEditor = options.isInEditor ?? Env.isInEditor
82
- if (isInEditor)
83
- // eslint-disable-next-line no-console
84
- console.log(
85
- '[@bfra.me/eslint-config] Editor specific config is enabled. Some rules may be disabled.',
86
- )
81
+ let isInEditor = options.isInEditor
82
+ if (isInEditor == null) {
83
+ isInEditor = isInEditorEnv()
84
+ if (isInEditor) {
85
+ // eslint-disable-next-line no-console
86
+ console.log(
87
+ '[@bfra.me/eslint-config] Editor specific config is enabled. Some rules may be disabled.',
88
+ )
89
+ }
90
+ }
87
91
 
88
92
  const stylisticOptions =
89
93
  options.stylistic === false || enablePrettier
package/src/index.ts CHANGED
@@ -4,7 +4,6 @@ export * from './compose-config'
4
4
  export * from './config.d'
5
5
  export * from './configs'
6
6
  export * from './define-config'
7
- export * from './env'
8
7
  export * from './globs'
9
8
  export * from './options'
10
9
  export * from './rules.d'
package/src/utils.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type {Awaitable} from 'eslint-flat-config-utils'
2
+ import process from 'node:process'
2
3
  import {fileURLToPath} from 'node:url'
4
+ import isInCI from 'is-in-ci'
3
5
  import {isPackageExists} from 'local-pkg'
4
6
 
5
7
  const scopeUrl = fileURLToPath(new URL('.', import.meta.url))
@@ -17,3 +19,51 @@ export async function interopDefault<T>(
17
19
  export function isPackageInScope(name: string): boolean {
18
20
  return isPackageExists(name, {paths: [scopeUrl]})
19
21
  }
22
+
23
+ /**
24
+ * Check if the process is running in a Git hook or under lint-staged.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import {isInGitLifecycle} from '@bfra.me/eslint-config'
29
+ *
30
+ * if (isInGitLifecycle) {
31
+ * console.log('Running in a Git hook or under lint-staged')
32
+ * }
33
+ * ```
34
+ */
35
+ export function isInGitLifecycle(): boolean {
36
+ return !!(
37
+ false ||
38
+ (typeof process.env.GIT_PARAMS === 'string' && process.env.GIT_PARAMS.length > 0) ||
39
+ (typeof process.env.VSCODE_GIT_COMMAND === 'string' &&
40
+ process.env.VSCODE_GIT_COMMAND.length > 0) ||
41
+ process.env.npm_lifecycle_script?.startsWith('lint-staged') ||
42
+ process.env.npm_lifecycle_script?.startsWith('nano-staged')
43
+ )
44
+ }
45
+
46
+ /**
47
+ * Check if the process is running in an editor.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import {isInEditor} from '@bfra.me/eslint-config'
52
+ *
53
+ * if (isInEditor) {
54
+ * console.log('Running in an editor')
55
+ * }
56
+ */
57
+ export function isInEditorEnv(): boolean {
58
+ if (isInCI) return false
59
+ if (isInGitLifecycle()) return false
60
+
61
+ return !!(
62
+ false ||
63
+ (typeof process.env.VSCODE_PID === 'string' && process.env.VSCODE_PID.length > 0) ||
64
+ (typeof process.env.VSCODE_CWD === 'string' && process.env.VSCODE_CWD.length > 0) ||
65
+ (typeof process.env.JETBRAINS_IDE === 'string' && process.env.JETBRAINS_IDE.length > 0) ||
66
+ (typeof process.env.VIM === 'string' && process.env.VIM.length > 0) ||
67
+ (typeof process.env.NVIM === 'string' && process.env.NVIM.length > 0)
68
+ )
69
+ }
package/src/env.ts DELETED
@@ -1,43 +0,0 @@
1
- import {env} from 'node:process'
2
- import isInCI from 'is-in-ci'
3
-
4
- /**
5
- * Check if the process is running in a Git hook or under lint-staged.
6
- *
7
- * @example
8
- * ```ts
9
- * import {isInGitLifecycle} from '@bfra.me/eslint-config'
10
- *
11
- * if (isInGitLifecycle) {
12
- * console.log('Running in a Git hook or under lint-staged')
13
- * }
14
- * ```
15
- */
16
- export const isInGitLifecycle = !!(
17
- (typeof env.GIT_PARAMS === 'string' && env.GIT_PARAMS.length > 0) ||
18
- (typeof env.VSCODE_GIT_COMMAND === 'string' && env.VSCODE_GIT_COMMAND.length > 0) ||
19
- env.npm_lifecycle_script?.startsWith('lint-staged') ||
20
- env.npm_lifecycle_script?.startsWith('nano-staged')
21
- )
22
-
23
- /**
24
- * Check if the process is running in an editor.
25
- *
26
- * @example
27
- * ```ts
28
- * import {isInEditor} from '@bfra.me/eslint-config'
29
- *
30
- * if (isInEditor) {
31
- * console.log('Running in an editor')
32
- * }
33
- */
34
- export const isInEditor =
35
- !isInCI &&
36
- !isInGitLifecycle &&
37
- Boolean(
38
- (typeof env.VSCODE_PID === 'string' && env.VSCODE_PID.length > 0) ||
39
- (typeof env.VSCODE_CWD === 'string' && env.VSCODE_CWD.length > 0) ||
40
- (typeof env.JETBRAINS_IDE === 'string' && env.JETBRAINS_IDE.length > 0) ||
41
- (typeof env.VIM === 'string' && env.VIM.length > 0) ||
42
- (typeof env.NVIM === 'string' && env.NVIM.length > 0),
43
- )