@savvy-web/lint-staged 0.1.1 → 0.1.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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +20 -16
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -315,7 +315,7 @@ export declare class ConfigSearch {
315
315
  * Check if a config file exists at a specific path.
316
316
  *
317
317
  * @param filepath - Path to check
318
- * @returns true if the file exists and is readable
318
+ * @returns true if the file exists
319
319
  */
320
320
  static exists(filepath: string): boolean;
321
321
  /**
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { execSync } from "node:child_process";
2
2
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { dirname, isAbsolute, join, normalize, relative, resolve } from "node:path";
4
- import { cosmiconfigSync } from "cosmiconfig";
4
+ import { cosmiconfigSync, defaultLoaders } from "cosmiconfig";
5
5
  import sort_package_json from "sort-package-json";
6
6
  import { parse, stringify } from "yaml";
7
7
  import parser from "@typescript-eslint/parser";
@@ -204,17 +204,27 @@ class ConfigSearch {
204
204
  }
205
205
  static findFile(moduleName, options = {}) {
206
206
  const { searchFrom = process.cwd(), stopDir, libConfigFiles = [], standardPlaces = [] } = options;
207
- const searchPlaces = [
208
- ...libConfigFiles.map((file)=>`${ConfigSearch.libConfigDir}/${file}`),
209
- ...standardPlaces
210
- ];
211
- if (0 === searchPlaces.length) return {
207
+ const loaders = {
208
+ ".jsonc": defaultLoaders[".json"],
209
+ ".yaml": defaultLoaders[".yaml"],
210
+ ".yml": defaultLoaders[".yaml"]
211
+ };
212
+ const libConfigDir = join(searchFrom, ConfigSearch.libConfigDir);
213
+ for (const file of libConfigFiles){
214
+ const filepath = join(libConfigDir, file);
215
+ if (existsSync(filepath)) return {
216
+ filepath,
217
+ found: true
218
+ };
219
+ }
220
+ if (0 === standardPlaces.length) return {
212
221
  filepath: void 0,
213
222
  found: false
214
223
  };
215
224
  try {
216
225
  const explorer = cosmiconfigSync(moduleName, {
217
- searchPlaces,
226
+ searchPlaces: standardPlaces,
227
+ loaders,
218
228
  stopDir
219
229
  });
220
230
  const result = explorer.search(searchFrom);
@@ -229,13 +239,7 @@ class ConfigSearch {
229
239
  };
230
240
  }
231
241
  static exists(filepath) {
232
- try {
233
- const explorer = cosmiconfigSync("check");
234
- const result = explorer.load(filepath);
235
- return null !== result;
236
- } catch {
237
- return false;
238
- }
242
+ return existsSync(filepath);
239
243
  }
240
244
  static resolve(filename, fallback) {
241
245
  const libPath = `${ConfigSearch.libConfigDir}/${filename}`;
@@ -292,7 +296,7 @@ class Biome {
292
296
  const biomeCmd = Command.requireTool("biome", "Biome is not available. Install it globally (recommended) or add @biomejs/biome as a dev dependency.");
293
297
  const files = filtered.join(" ");
294
298
  const flags = options.flags ?? [];
295
- const configFlag = config ? `--config=${config}` : "";
299
+ const configFlag = config ? `--config-path=${config}` : "";
296
300
  const cmd = [
297
301
  `${biomeCmd} check --write --no-errors-on-unmatched`,
298
302
  configFlag,
@@ -389,7 +393,7 @@ class PackageJson {
389
393
  writeFileSync(filepath, sorted, "utf-8");
390
394
  }
391
395
  const files = filtered.join(" ");
392
- const biomeCmd = options.biomeConfig ? `biome check --write --max-diagnostics=none --config=${options.biomeConfig} ${files}` : `biome check --write --max-diagnostics=none ${files}`;
396
+ const biomeCmd = options.biomeConfig ? `biome check --write --max-diagnostics=none --config-path=${options.biomeConfig} ${files}` : `biome check --write --max-diagnostics=none ${files}`;
393
397
  return biomeCmd;
394
398
  };
395
399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/lint-staged",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "Composable, configurable lint-staged handlers for pre-commit hooks. Provides reusable handlers for Biome, Markdown, YAML, TypeScript, and more.",
6
6
  "keywords": [