lint-staged 7.1.3 → 7.2.0

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/README.md CHANGED
@@ -71,12 +71,12 @@ $ ./node_modules/.bin/lint-staged --help
71
71
  Options:
72
72
 
73
73
  -V, --version output the version number
74
- -c, --config [path] Path to configuration file
74
+ -c, --config [path] Configuration file path or package
75
75
  -d, --debug Enable debug mode
76
76
  -h, --help output usage information
77
77
  ```
78
78
 
79
- * **`--config [path]`**: This can be used to manually specify the `lint-staged` config file location. However, if the specified file cannot be found, it will error out instead of performing the usual search.
79
+ * **`--config [path]`**: This can be used to manually specify the `lint-staged` config file location. However, if the specified file cannot be found, it will error out instead of performing the usual search. You may pass a npm package name for configuration also.
80
80
  * **`--debug`**: Enabling the debug mode does the following:
81
81
  * `lint-staged` uses the [debug](https://github.com/visionmedia/debug) module internally to log information about staged files, commands being executed, location of binaries etc. Debug logs, which are automatically enabled by passing the flag, can also be enabled by setting the environment variable `$DEBUG` to `lint-staged*`.
82
82
  * Use the [`verbose` renderer](https://github.com/SamVerschueren/listr-verbose-renderer) for `listr`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "7.1.3",
3
+ "version": "7.2.0",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
package/src/index.js CHANGED
@@ -18,20 +18,28 @@ if (process.stdout.isTTY) {
18
18
 
19
19
  const errConfigNotFound = new Error('Config could not be found')
20
20
 
21
+ function resolveConfig(configPath) {
22
+ try {
23
+ return require.resolve(configPath)
24
+ } catch (ignore) {
25
+ return configPath
26
+ }
27
+ }
28
+
21
29
  function loadConfig(configPath) {
22
30
  const explorer = cosmiconfig('lint-staged', {
23
31
  searchPlaces: [
24
32
  'package.json',
25
- `.lintstagedrc`,
26
- `.lintstagedrc.json`,
27
- `.lintstagedrc.yaml`,
28
- `.lintstagedrc.yml`,
29
- `.lintstagedrc.js`,
30
- `lint-staged.config.js`
33
+ '.lintstagedrc',
34
+ '.lintstagedrc.json',
35
+ '.lintstagedrc.yaml',
36
+ '.lintstagedrc.yml',
37
+ '.lintstagedrc.js',
38
+ 'lint-staged.config.js'
31
39
  ]
32
40
  })
33
41
 
34
- return configPath ? explorer.load(configPath) : explorer.search()
42
+ return configPath ? explorer.load(resolveConfig(configPath)) : explorer.search()
35
43
  }
36
44
 
37
45
  /**