lint-staged 12.1.6 → 12.1.7

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/loadConfig.js CHANGED
@@ -6,6 +6,8 @@ import debug from 'debug'
6
6
  import { lilconfig } from 'lilconfig'
7
7
  import YAML from 'yaml'
8
8
 
9
+ import { resolveConfig } from './resolveConfig.js'
10
+
9
11
  const debugLog = debug('lint-staged:loadConfig')
10
12
 
11
13
  /**
@@ -49,14 +51,6 @@ const loaders = {
49
51
  noExt: yamlParse,
50
52
  }
51
53
 
52
- const resolveConfig = (configPath) => {
53
- try {
54
- return require.resolve(configPath)
55
- } catch {
56
- return configPath
57
- }
58
- }
59
-
60
54
  /**
61
55
  * @param {object} options
62
56
  * @param {string} [options.configPath] - Explicit path to a config file
@@ -0,0 +1,15 @@
1
+ import { createRequire } from 'module'
2
+
3
+ /**
4
+ * require() does not exist for ESM, so we must create it to use require.resolve().
5
+ * @see https://nodejs.org/api/module.html#modulecreaterequirefilename
6
+ */
7
+ const require = createRequire(import.meta.url)
8
+
9
+ export function resolveConfig(configPath) {
10
+ try {
11
+ return require.resolve(configPath)
12
+ } catch {
13
+ return configPath
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "12.1.6",
3
+ "version": "12.1.7",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",