Socket
Socket
Sign inDemoInstall

lint-staged

Package Overview
Dependencies
61
Maintainers
1
Versions
245
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 12.1.1 to 12.1.2

12

lib/index.js

@@ -61,9 +61,5 @@ import debug from 'debug'

debugLog('Loading config using `lilconfig`')
const inputConfig = configObject || (await loadConfig(configPath, logger))
const resolved = configObject
? { config: configObject, filepath: '(input)' }
: await loadConfig(configPath)
if (!resolved) {
if (!inputConfig) {
logger.error(`${ConfigNotFoundError.message}.`)

@@ -73,6 +69,4 @@ throw ConfigNotFoundError

debugLog('Successfully loaded config from `%s`:\n%O', resolved.filepath, resolved.config)
const config = validateConfig(inputConfig, logger)
const config = validateConfig(resolved.config, logger)
if (debug) {

@@ -79,0 +73,0 @@ // Log using logger to be able to test through `consolemock`.

@@ -0,4 +1,9 @@

import { pathToFileURL } from 'url'
import debug from 'debug'
import { lilconfig } from 'lilconfig'
import YAML from 'yaml'
const debugLog = debug('lint-staged:loadConfig')
/**

@@ -23,12 +28,8 @@ * The list of files `lint-staged` will read configuration

/** exported for tests */
export const dynamicImport = (path) =>
import(path)
.then((module) => module.default)
.catch((error) => {
console.error(error)
throw error
})
export const dynamicImport = (path) => import(pathToFileURL(path)).then((module) => module.default)
const jsonParse = (path, content) => JSON.parse(content)
const yamlParse = (path, content) => YAML.parse(content)
/**

@@ -45,5 +46,5 @@ * `lilconfig` doesn't support yaml files by default,

'.cjs': dynamicImport,
'.yaml': YAML.parse,
'.yml': YAML.parse,
noExt: YAML.parse,
'.yaml': yamlParse,
'.yml': yamlParse,
noExt: yamlParse,
}

@@ -61,12 +62,28 @@

* @param {string} [configPath]
* @param {Logger} [logger]
*/
export const loadConfig = async (configPath) => {
const explorer = lilconfig('lint-staged', { searchPlaces, loaders })
const result = await (configPath ? explorer.load(resolveConfig(configPath)) : explorer.search())
if (!result) return null
export const loadConfig = async (configPath, logger) => {
try {
if (configPath) {
debugLog('Loading configuration from `%s`...', configPath)
} else {
debugLog('Searching for configuration...')
}
const { config, filepath } = result
const explorer = lilconfig('lint-staged', { searchPlaces, loaders })
// config is a promise when using the `dynamicImport` loader
return { config: await config, filepath }
const result = await (configPath ? explorer.load(resolveConfig(configPath)) : explorer.search())
if (!result) return null
// config is a promise when using the `dynamicImport` loader
const config = await result.config
debugLog('Successfully loaded config from `%s`:\n%O', result.filepath, config)
return config
} catch (error) {
debugLog('Failed to load configuration from `%s`', configPath)
logger.error(error)
return null
}
}
{
"name": "lint-staged",
"version": "12.1.1",
"version": "12.1.2",
"description": "Lint files staged by git",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc