lint-staged 8.0.2 → 8.1.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
@@ -137,7 +137,7 @@ To extend and customise lint-staged, advanced options are available. To use thes
137
137
  }
138
138
  ```
139
139
 
140
- Notice that the linting commands now are nested into the `linters` object. The following options are available for advance configuration:
140
+ Notice that the linting commands now are nested into the `linters` object. The following options are available for advanced configuration:
141
141
 
142
142
  #### Options
143
143
 
@@ -148,6 +148,7 @@ Notice that the linting commands now are nested into the `linters` object. The f
148
148
  * `ignore` - `['**/docs/**/*.js']` - array of glob patterns to entirely ignore from any task.
149
149
  * `linters` — `Object` — keys (`String`) are glob patterns, values (`Array<String> | String`) are commands to execute.
150
150
  * `subTaskConcurrency` — `1` — Controls concurrency for processing chunks generated for each linter. This option is only applicable on Windows. Execution is **not** concurrent by default(see [#225](https://github.com/okonet/lint-staged/issues/225))
151
+ * `relative` — `false` — if `true` it will give the relative path from your `package.json` directory to your linter arguments.
151
152
 
152
153
  ## Filtering files
153
154
 
@@ -199,7 +200,7 @@ Starting from [v2.0.0](https://github.com/okonet/lint-staged/releases/tag/2.0.0)
199
200
 
200
201
  ## Reformatting the code
201
202
 
202
- Tools like [Prettier](https://prettier.io), ESLint/TSLint, or stylefmt can reformat your code according to an appropriate config by running `prettier --write`/`eslint --fix`/`tslint --fix`. After the code is reformatted, we want it to be added to the same commit. This can be done using following config:
203
+ Tools like [Prettier](https://prettier.io), ESLint/TSLint, or stylelint can reformat your code according to an appropriate config by running `prettier --write`/`eslint --fix`/`tslint --fix`/`stylelint --fix`. After the code is reformatted, we want it to be added to the same commit. This can be done using following config:
203
204
 
204
205
  ```json
205
206
  {
@@ -207,7 +208,7 @@ Tools like [Prettier](https://prettier.io), ESLint/TSLint, or stylefmt can refor
207
208
  }
208
209
  ```
209
210
 
210
- Starting from v8, lint-staged will stash you remaining changes (not added to the index) and restore them from stash afterwards if there are partially staged files detected. This allows you to create partial commits with hunks using `git add --patch`. See the [blog post](https://medium.com/@okonetchnikov/announcing-lint-staged-with-support-for-partially-staged-files-abc24a40d3ff)
211
+ Starting from v8, lint-staged will stash your remaining changes (not added to the index) and restore them from stash afterwards if there are partially staged files detected. This allows you to create partial commits with hunks using `git add --patch`. See the [blog post](https://medium.com/@okonetchnikov/announcing-lint-staged-with-support-for-partially-staged-files-abc24a40d3ff)
211
212
 
212
213
  ## Examples
213
214
 
@@ -267,17 +268,34 @@ The following is equivalent:
267
268
  }
268
269
  ```
269
270
 
270
- ### Automatically fix code style with `prettier` for javascript + flow or typescript
271
+ ### Automatically fix code style with `prettier` for javascript + flow, typescript, markdown or html
271
272
 
272
273
  ```json
273
274
  {
274
- "*.{js,jsx}": ["prettier --parser flow --write", "git add"]
275
+ "*.{js,jsx}": ["prettier --write", "git add"]
275
276
  }
276
277
  ```
277
278
 
278
279
  ```json
279
280
  {
280
- "*.{ts,tsx}": ["prettier --parser typescript --write", "git add"]
281
+ "*.{ts,tsx}": ["prettier --write", "git add"]
282
+ }
283
+ ```
284
+
285
+ ```json
286
+ {
287
+ "*.{md,html}": ["prettier --write", "git add"]
288
+ }
289
+ ```
290
+
291
+ ### Use ng lint with angular cli >= 7.0.0
292
+
293
+ ```json
294
+ {
295
+ "linters": {
296
+ "*.ts": "ng lint myProjectName --files"
297
+ },
298
+ "relative": true
281
299
  }
282
300
  ```
283
301
 
package/index.js CHANGED
@@ -3,7 +3,11 @@
3
3
  'use strict'
4
4
 
5
5
  const pkg = require('./package.json')
6
- require('please-upgrade-node')(pkg)
6
+ require('please-upgrade-node')({
7
+ engines: {
8
+ node: '>=8.6.0'
9
+ }
10
+ })
7
11
 
8
12
  const cmdline = require('commander')
9
13
  const debugLib = require('debug')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "8.0.2",
3
+ "version": "8.1.0",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -9,16 +9,12 @@
9
9
  "Lufty Wiranda <lufty.wiranda@gmail.com>",
10
10
  "Suhas Karanth <sudo.suhas@gmail.com>"
11
11
  ],
12
- "engines": {
13
- "node": ">=8.6.0"
14
- },
15
12
  "bin": "index.js",
16
13
  "files": [
17
14
  "index.js",
18
15
  "src"
19
16
  ],
20
17
  "scripts": {
21
- "precommit": "node index.js",
22
18
  "cz": "git-cz",
23
19
  "lint:base": "eslint --rule \"prettier/prettier: 2\"",
24
20
  "lint": "npm run lint:base -- .",
@@ -27,10 +23,16 @@
27
23
  "test": "jest --coverage",
28
24
  "test:watch": "jest --watch"
29
25
  },
26
+ "husky": {
27
+ "hooks": {
28
+ "pre-commit": "node index.js"
29
+ }
30
+ },
30
31
  "dependencies": {
32
+ "@iamstarkov/listr-update-renderer": "0.4.1",
31
33
  "chalk": "^2.3.1",
32
34
  "commander": "^2.14.1",
33
- "cosmiconfig": "^5.0.2",
35
+ "cosmiconfig": "5.0.6",
34
36
  "debug": "^3.1.0",
35
37
  "dedent": "^0.7.0",
36
38
  "del": "^3.0.0",
@@ -41,7 +43,6 @@
41
43
  "is-windows": "^1.0.2",
42
44
  "jest-validate": "^23.5.0",
43
45
  "listr": "^0.14.2",
44
- "listr-update-renderer": "https://github.com/okonet/listr-update-renderer/tarball/upgrade-log-update",
45
46
  "lodash": "^4.17.5",
46
47
  "log-symbols": "^2.2.0",
47
48
  "micromatch": "^3.1.8",
@@ -50,7 +51,7 @@
50
51
  "path-is-inside": "^1.0.2",
51
52
  "pify": "^3.0.0",
52
53
  "please-upgrade-node": "^3.0.2",
53
- "staged-git-files": "1.1.1",
54
+ "staged-git-files": "1.1.2",
54
55
  "string-argv": "^0.0.2",
55
56
  "stringify-object": "^3.2.2"
56
57
  },
@@ -65,7 +66,7 @@
65
66
  "eslint": "^4.18.1",
66
67
  "eslint-config-okonet": "^5.0.1",
67
68
  "eslint-plugin-node": "^6.0.0",
68
- "husky": "^0.14.3",
69
+ "husky": "^1.1.4",
69
70
  "jest": "^23.6.0",
70
71
  "jest-snapshot-serializer-ansi": "^1.0.0",
71
72
  "jsonlint": "^1.6.2",
@@ -33,9 +33,14 @@ module.exports = function generateTasks(config, stagedRelFiles) {
33
33
  .map(file => path.relative(cwd, file)),
34
34
  patterns,
35
35
  globOptions
36
- )
36
+ ).map(file => {
37
+ // if you set relative option, then the file path will be relative to your package.json
38
+ if (config.relative) {
39
+ return path.normalize(file)
40
+ }
37
41
  // Return absolute path after the filter is run
38
- .map(file => path.resolve(cwd, file))
42
+ return path.resolve(cwd, file)
43
+ })
39
44
 
40
45
  const task = { pattern, commands, fileList }
41
46
  debug('Generated task: \n%O', task)
package/src/getConfig.js CHANGED
@@ -28,7 +28,8 @@ const defaultConfig = {
28
28
  linters: {},
29
29
  ignore: [],
30
30
  subTaskConcurrency: 1,
31
- renderer: 'update'
31
+ renderer: 'update',
32
+ relative: false
32
33
  }
33
34
 
34
35
  /**
@@ -121,12 +122,13 @@ const optRmMsg = (opt, helpMsg) => ` Option ${chalk.bold(opt)} was removed.
121
122
  */
122
123
  function validateConfig(config) {
123
124
  debug('Validating config')
124
- const exampleConfig = Object.assign({}, defaultConfig, {
125
+ const exampleConfig = {
126
+ ...defaultConfig,
125
127
  linters: {
126
128
  '*.js': ['eslint --fix', 'git add'],
127
129
  '*.css': 'stylelint'
128
130
  }
129
- })
131
+ }
130
132
 
131
133
  const deprecatedConfig = {
132
134
  gitDir: () => optRmMsg('gitDir', "lint-staged now automatically resolves '.git' directory."),
@@ -29,7 +29,7 @@ function execLinter(bin, args, execaOptions, pathsToLint) {
29
29
  debug('args: %O', binArgs)
30
30
  debug('opts: %o', execaOptions)
31
31
 
32
- return execa(bin, binArgs, Object.assign({}, execaOptions))
32
+ return execa(bin, binArgs, { ...execaOptions })
33
33
  }
34
34
 
35
35
  const successMsg = linter => `${symbols.success} ${linter} passed!`