lint-staged 4.2.3 → 4.3.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
@@ -57,6 +57,7 @@ Starting with v3.1 you can now use different ways of configuring it:
57
57
  * `lint-staged` object in your `package.json`
58
58
  * `.lintstagedrc` file in JSON or YML format
59
59
  * `lint-staged.config.js` file in JS format
60
+ * Pass a configuration file using the `--config` or `-c` flag
60
61
 
61
62
  See [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for more details on what formats are supported.
62
63
 
package/index.js CHANGED
@@ -2,4 +2,12 @@
2
2
 
3
3
  'use strict'
4
4
 
5
- require('./src')()
5
+ const cmdline = require('commander')
6
+ const pkg = require('./package.json')
7
+
8
+ cmdline
9
+ .version(pkg.version)
10
+ .option('-c, --config [path]', 'Path to configuration file')
11
+ .parse(process.argv)
12
+
13
+ require('./src')(console, cmdline.config)
package/package.json CHANGED
@@ -1,90 +1 @@
1
- {
2
- "name": "lint-staged",
3
- "version": "4.2.3",
4
- "description": "Lint files staged by git",
5
- "license": "MIT",
6
- "repository": "https://github.com/okonet/lint-staged",
7
- "author": "Andrey Okonetchnikov <andrey@okonet.ru>",
8
- "maintainers": [
9
- "Lufty Wiranda <lufty.wiranda@gmail.com",
10
- "Suhas Karanth <sudo.suhas@gmail.com"
11
- ],
12
- "engines": {
13
- "node": ">=4.2.0"
14
- },
15
- "bin": "index.js",
16
- "files": [
17
- "index.js",
18
- "src"
19
- ],
20
- "scripts": {
21
- "precommit": "remove-lockfiles && node index.js",
22
- "cz": "git-cz",
23
- "lint": "eslint .",
24
- "lint:fix": "npm run lint -- --fix",
25
- "pretest": "npm run lint",
26
- "test": "jest --coverage",
27
- "test:watch": "jest --watch"
28
- },
29
- "dependencies": {
30
- "app-root-path": "^2.0.0",
31
- "chalk": "^2.1.0",
32
- "cosmiconfig": "^1.1.0",
33
- "execa": "^0.8.0",
34
- "is-glob": "^4.0.0",
35
- "jest-validate": "^21.1.0",
36
- "listr": "^0.12.0",
37
- "lodash": "^4.17.4",
38
- "log-symbols": "^2.0.0",
39
- "minimatch": "^3.0.0",
40
- "npm-which": "^3.0.1",
41
- "p-map": "^1.1.1",
42
- "staged-git-files": "0.0.4",
43
- "stringify-object": "^3.2.0"
44
- },
45
- "devDependencies": {
46
- "babel-jest": "^21.0.2",
47
- "babel-preset-env": "^1.6.0",
48
- "commitizen": "^2.9.6",
49
- "consolemock": "^0.2.2",
50
- "cz-conventional-changelog": "^2.0.0",
51
- "eslint": "^4.5.0",
52
- "eslint-config-okonet": "^5.0.1",
53
- "eslint-plugin-node": "^5.1.1",
54
- "husky": "^0.14.3",
55
- "jest": "^21.1.0",
56
- "jest-cli": "^21.1.0",
57
- "jsonlint": "^1.6.2",
58
- "prettier": "1.5.3",
59
- "remove-lockfiles": "^1.1.1"
60
- },
61
- "config": {
62
- "commitizen": {
63
- "path": "./node_modules/cz-conventional-changelog"
64
- }
65
- },
66
- "jest": {
67
- "testEnvironment": "node",
68
- "setupFiles": [
69
- "./testSetup.js"
70
- ]
71
- },
72
- "greenkeeper": {
73
- "ignore": [
74
- "cosmiconfig"
75
- ]
76
- },
77
- "keywords": [
78
- "lint",
79
- "git",
80
- "staged",
81
- "eslint",
82
- "prettier",
83
- "stylelint",
84
- "code",
85
- "quality",
86
- "check",
87
- "format",
88
- "validate"
89
- ]
90
- }
1
+ {"name":"lint-staged","version":"4.3.0","description":"Lint files staged by git","license":"MIT","repository":"https://github.com/okonet/lint-staged","author":"Andrey Okonetchnikov <andrey@okonet.ru>","maintainers":["Lufty Wiranda <lufty.wiranda@gmail.com","Suhas Karanth <sudo.suhas@gmail.com"],"engines":{"node":">=4.2.0"},"bin":"index.js","files":["index.js","src"],"scripts":{"precommit":"remove-lockfiles && node index.js","cz":"git-cz","lint":"eslint .","lint:fix":"npm run lint -- --fix","pretest":"npm run lint","test":"jest --coverage","test:watch":"jest --watch"},"dependencies":{"app-root-path":"^2.0.0","chalk":"^2.1.0","commander":"^2.11.0","cosmiconfig":"^1.1.0","execa":"^0.8.0","is-glob":"^4.0.0","jest-validate":"^21.1.0","listr":"^0.12.0","lodash":"^4.17.4","log-symbols":"^2.0.0","minimatch":"^3.0.0","npm-which":"^3.0.1","p-map":"^1.1.1","staged-git-files":"0.0.4","stringify-object":"^3.2.0"},"devDependencies":{"babel-jest":"^21.0.2","babel-preset-env":"^1.6.0","commitizen":"^2.9.6","consolemock":"^0.3.0","cz-conventional-changelog":"^2.0.0","eslint":"^4.5.0","eslint-config-okonet":"^5.0.1","eslint-plugin-node":"^5.1.1","husky":"^0.14.3","jest":"^21.1.0","jest-cli":"^21.1.0","jsonlint":"^1.6.2","prettier":"1.5.3","remove-lockfiles":"^1.1.1"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"jest":{"testEnvironment":"node","setupFiles":["./testSetup.js"]},"greenkeeper":{"ignore":["cosmiconfig"]},"keywords":["lint","git","staged","eslint","prettier","stylelint","code","quality","check","format","validate"]}
package/src/findBin.js CHANGED
@@ -4,6 +4,8 @@ const npmWhich = require('npm-which')(process.cwd())
4
4
 
5
5
  module.exports = function findBin(cmd, scripts, options) {
6
6
  const npmArgs = (bin, args) =>
7
+ // We always add `--` even if args are not defined. This is required
8
+ // because we pass filenames later.
7
9
  ['run', options && options.verbose ? undefined : '--silent', bin, '--']
8
10
  // args could be undefined but we filter that out.
9
11
  .concat(args)
package/src/index.js CHANGED
@@ -25,8 +25,11 @@ const errConfigNotFound = new Error('Config could not be found')
25
25
  /**
26
26
  * Root lint-staged function that is called from .bin
27
27
  */
28
- module.exports = function lintStaged() {
28
+ module.exports = function lintStaged(injectedLogger, configPath) {
29
+ const logger = injectedLogger || console
30
+
29
31
  return cosmiconfig('lint-staged', {
32
+ configPath,
30
33
  rc: '.lintstagedrc',
31
34
  rcExtensions: true
32
35
  })
@@ -38,7 +41,7 @@ module.exports = function lintStaged() {
38
41
  const config = validateConfig(getConfig(result.config))
39
42
 
40
43
  if (config.verbose) {
41
- console.log(`
44
+ logger.log(`
42
45
  Running lint-staged with the following config:
43
46
  ${stringifyObject(config)}
44
47
  `)
@@ -59,15 +62,15 @@ ${stringifyObject(config)}
59
62
  })
60
63
  .catch(err => {
61
64
  if (err === errConfigNotFound) {
62
- console.error(`${err.message}.`)
65
+ logger.error(`${err.message}.`)
63
66
  } else {
64
67
  // It was probably a parsing error
65
- console.error(`Could not parse lint-staged config.
68
+ logger.error(`Could not parse lint-staged config.
66
69
 
67
70
  ${err}`)
68
71
  }
69
72
  // Print helpful message for all errors
70
- console.error(`
73
+ logger.error(`
71
74
  Please make sure you have created it correctly.
72
75
  See https://github.com/okonet/lint-staged#configuration.
73
76
  `)