gulp-prettier 3.0.0 → 5.0.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/LICENSE +2 -1
- package/README.md +18 -28
- package/index.js +6 -6
- package/package.json +30 -14
- package/CHANGELOG.md +0 -65
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2016-
|
|
3
|
+
Copyright (c) 2016-2020 Patel, Bhargav R.
|
|
4
|
+
Copyright (c) 2020 Thomas Vantuycom
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gulp-prettier  [](https://www.npmjs.com/package/gulp-prettier) [](https://github.com/semantic-release/semantic-release)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> Prettier is an opinionated JavaScript formatter inspired by refmt with advanced support for language features from ES2017, JSX, and Flow. It removes all original styling and ensures that all outputted JavaScript conforms to a consistent style. (See this blog post)
|
|
6
|
-
|
|
7
|
-
> _NOTE_: To ensure this plugin continues to serve its usefulness, I've added @TheDancingCode as the active collaborator. He will be the active maintainer - BRP (April 26, 2018)
|
|
3
|
+
> Format files with [Prettier](https://github.com/prettier/prettier)
|
|
8
4
|
|
|
9
5
|
## Install
|
|
10
6
|
|
|
@@ -14,29 +10,31 @@ npm install gulp-prettier --save-dev
|
|
|
14
10
|
|
|
15
11
|
## Usage
|
|
16
12
|
|
|
17
|
-
Simply pipe the input, and pass in arguments that you would to the regular format function.
|
|
18
|
-
|
|
19
13
|
```js
|
|
20
|
-
const
|
|
14
|
+
const { src, dest } = require('gulp');
|
|
21
15
|
const prettier = require('gulp-prettier');
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
return
|
|
17
|
+
function format() {
|
|
18
|
+
return src('src/*.js')
|
|
25
19
|
.pipe(prettier({ singleQuote: true }))
|
|
26
|
-
.pipe(
|
|
27
|
-
}
|
|
20
|
+
.pipe(dest('dist'));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.default = format;
|
|
28
24
|
```
|
|
29
25
|
|
|
30
26
|
To check whether or not your files adhere to Prettier's formatting, use `prettier.check`. This can be used as a validation step in CI scenarios.
|
|
31
27
|
|
|
32
28
|
```js
|
|
33
|
-
const
|
|
29
|
+
const { src, dest } = require('gulp');
|
|
34
30
|
const prettier = require('gulp-prettier');
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
return
|
|
32
|
+
function validate() {
|
|
33
|
+
return src('dist/*.js')
|
|
38
34
|
.pipe(prettier.check({ singleQuote: true }));
|
|
39
|
-
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.default = validate;
|
|
40
38
|
```
|
|
41
39
|
|
|
42
40
|
## API
|
|
@@ -51,7 +49,7 @@ Type: `Object`
|
|
|
51
49
|
|
|
52
50
|
Consult the Prettier [options](https://prettier.io/docs/en/options.html).
|
|
53
51
|
|
|
54
|
-
`editorconfig: true` can also be passed to enable [EditorConfig support](https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath
|
|
52
|
+
`editorconfig: true` can also be passed to enable [EditorConfig support](https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath--options).
|
|
55
53
|
|
|
56
54
|
### prettier.check([options])
|
|
57
55
|
|
|
@@ -63,16 +61,8 @@ Type: `Object`
|
|
|
63
61
|
|
|
64
62
|
Consult the Prettier [options](https://prettier.io/docs/en/options.html).
|
|
65
63
|
|
|
66
|
-
`editorconfig: true` can also be passed to enable [EditorConfig support](https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath
|
|
67
|
-
|
|
68
|
-
## Collaborators
|
|
69
|
-
|
|
70
|
-
I'd like to take this oppertunity to thank all of the contributors to this project:
|
|
71
|
-
|
|
72
|
-
\- @akella
|
|
73
|
-
\- @trusktr
|
|
74
|
-
\- @TheDancingCode
|
|
64
|
+
`editorconfig: true` can also be passed to enable [EditorConfig support](https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath--options).
|
|
75
65
|
|
|
76
66
|
## License
|
|
77
67
|
|
|
78
|
-
|
|
68
|
+
MIT © [Bhargav R. Patel](https://github.com/bhargavrpatel), [Thomas Vantuycom](https://github.com/TheDancingCode)
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const PLUGIN_NAME = 'gulp-prettier';
|
|
|
9
9
|
module.exports = function (options) {
|
|
10
10
|
options = options || {};
|
|
11
11
|
|
|
12
|
-
return through.obj(function (file, encoding, callback) {
|
|
12
|
+
return through.obj(async function (file, encoding, callback) {
|
|
13
13
|
if (file.isNull()) {
|
|
14
14
|
return callback(null, file);
|
|
15
15
|
}
|
|
@@ -18,13 +18,13 @@ module.exports = function (options) {
|
|
|
18
18
|
return callback(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const config = prettier.resolveConfig
|
|
21
|
+
const config = await prettier.resolveConfig(file.path, options);
|
|
22
22
|
const fileOptions = { ...config, ...options, filepath: file.path };
|
|
23
23
|
|
|
24
24
|
const unformattedCode = file.contents.toString('utf8');
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
|
-
const formattedCode = prettier.format(unformattedCode, fileOptions);
|
|
27
|
+
const formattedCode = await prettier.format(unformattedCode, fileOptions);
|
|
28
28
|
|
|
29
29
|
if (formattedCode !== unformattedCode) {
|
|
30
30
|
file.isPrettier = true;
|
|
@@ -49,7 +49,7 @@ module.exports.check = function (options) {
|
|
|
49
49
|
const unformattedFiles = [];
|
|
50
50
|
|
|
51
51
|
return through.obj(
|
|
52
|
-
function (file, encoding, callback) {
|
|
52
|
+
async function (file, encoding, callback) {
|
|
53
53
|
if (file.isNull()) {
|
|
54
54
|
return callback(null, file);
|
|
55
55
|
}
|
|
@@ -60,13 +60,13 @@ module.exports.check = function (options) {
|
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const config = prettier.resolveConfig
|
|
63
|
+
const config = await prettier.resolveConfig(file.path, options);
|
|
64
64
|
const fileOptions = { ...config, ...options, filepath: file.path };
|
|
65
65
|
|
|
66
66
|
const unformattedCode = file.contents.toString('utf8');
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
|
-
const isFormatted = prettier.check(unformattedCode, fileOptions);
|
|
69
|
+
const isFormatted = await prettier.check(unformattedCode, fileOptions);
|
|
70
70
|
|
|
71
71
|
if (!isFormatted) {
|
|
72
72
|
const filename = path
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gulp-prettier",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "
|
|
3
|
+
"description": "Format files with Prettier",
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "
|
|
8
|
+
"url": "https://github.com/TheDancingCode/gulp-prettier.git"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"pretest": "npm run lint",
|
|
13
|
-
"test": "mocha"
|
|
11
|
+
"test": "ava"
|
|
14
12
|
},
|
|
15
13
|
"files": [
|
|
16
14
|
"index.js"
|
|
@@ -22,18 +20,36 @@
|
|
|
22
20
|
"gulpplugin"
|
|
23
21
|
],
|
|
24
22
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
23
|
+
"node": ">=16"
|
|
26
24
|
},
|
|
27
|
-
"author": "
|
|
25
|
+
"author": "Thomas Vantuycom",
|
|
28
26
|
"license": "MIT",
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"plugin-error": "^
|
|
31
|
-
"prettier": "^
|
|
32
|
-
"through2": "^
|
|
28
|
+
"plugin-error": "^2.0.0",
|
|
29
|
+
"prettier": "^3.0.0",
|
|
30
|
+
"through2": "^4.0.2"
|
|
33
31
|
},
|
|
34
32
|
"devDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
33
|
+
"@semantic-release/changelog": "^5.0.0",
|
|
34
|
+
"@semantic-release/git": "^9.0.0",
|
|
35
|
+
"ava": "^5.1.0",
|
|
36
|
+
"p-event": "4.2.0",
|
|
37
|
+
"semantic-release": "^17.2.3",
|
|
38
|
+
"vinyl": "^3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"release": {
|
|
41
|
+
"plugins": [
|
|
42
|
+
"@semantic-release/commit-analyzer",
|
|
43
|
+
"@semantic-release/release-notes-generator",
|
|
44
|
+
"@semantic-release/changelog",
|
|
45
|
+
"@semantic-release/npm",
|
|
46
|
+
[
|
|
47
|
+
"@semantic-release/git",
|
|
48
|
+
{
|
|
49
|
+
"message": "release: ${nextRelease.version}"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"@semantic-release/github"
|
|
53
|
+
]
|
|
38
54
|
}
|
|
39
55
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
## [3.0.0](https://github.com/bhargavrpatel/gulp-prettier/compare/v2.3.0...v3.0.0) (2019-03-21)
|
|
6
|
-
|
|
7
|
-
### Features
|
|
8
|
-
|
|
9
|
-
* upgrade Prettier to v2.0.0 ([`af1a07c](https://github.com/bhargavrpatel/gulp-prettier/commit/af1a07c))
|
|
10
|
-
|
|
11
|
-
### BREAKING CHANGES
|
|
12
|
-
|
|
13
|
-
* drop support for Node versions 4, 6 and 8
|
|
14
|
-
* [breaking changes in Prettier](https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## [2.3.0](https://github.com/bhargavrpatel/gulp-prettier/compare/v2.2.0...v2.3.0) (2019-11-11)
|
|
18
|
-
|
|
19
|
-
### Features
|
|
20
|
-
|
|
21
|
-
* show filename on formatting error ([`565f3d3`](https://github.com/bhargavrpatel/gulp-prettier/commit/565f3d3))
|
|
22
|
-
|
|
23
|
-
## [2.2.0](https://github.com/bhargavrpatel/gulp-prettier/compare/v2.1.0...v2.2.0) (2019-10-21)
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* support editorconfig ([`4047a03`](https://github.com/bhargavrpatel/gulp-prettier/commit/4047a03))
|
|
28
|
-
|
|
29
|
-
## [2.1.0](https://github.com/bhargavrpatel/gulp-prettier/compare/v2.0.0...v2.1.0) (2019-02-01)
|
|
30
|
-
|
|
31
|
-
### Bug Fixes
|
|
32
|
-
|
|
33
|
-
* upgrade through2 to v3.0.0 ([`7b16a27`](https://github.com/bhargavrpatel/gulp-prettier/commit/7b16a27))
|
|
34
|
-
|
|
35
|
-
### Features
|
|
36
|
-
|
|
37
|
-
* add `check` method for CI ([`5f67343`](https://github.com/bhargavrpatel/gulp-prettier/commit/5f67343))
|
|
38
|
-
|
|
39
|
-
## [2.0.0](https://github.com/bhargavrpatel/gulp-prettier/compare/v1.1.0...v2.0.0) (2018-05-01)
|
|
40
|
-
|
|
41
|
-
### Bug Fixes
|
|
42
|
-
|
|
43
|
-
* avoid deprecated new Buffer() ([`d007ff9`](https://github.com/bhargavrpatel/gulp-prettier/commit/d007ff9))
|
|
44
|
-
* correct undeclared variable ([`c9abbbe`](https://github.com/bhargavrpatel/gulp-prettier/commit/c9abbbe))
|
|
45
|
-
* use strict mode ([`cf7bec7`](https://github.com/bhargavrpatel/gulp-prettier/commit/cf7bec7))
|
|
46
|
-
|
|
47
|
-
### Features
|
|
48
|
-
|
|
49
|
-
* add support for languages other than js ([`2eb0ed9`](https://github.com/bhargavrpatel/gulp-prettier/commit/2eb0ed9))
|
|
50
|
-
* adhere to .prettierrc ([`d44a6b0`](https://github.com/bhargavrpatel/gulp-prettier/commit/d44a6b0))
|
|
51
|
-
* add `isPrettier` flag ([`7d790fd`](https://github.com/bhargavrpatel/gulp-prettier/commit/7d790fd))
|
|
52
|
-
|
|
53
|
-
### BREAKING CHANGES
|
|
54
|
-
|
|
55
|
-
* Upgrade Prettier to `^1.5.3` ([`7d790fd`](https://github.com/bhargavrpatel/gulp-prettier/commit/7d790fd))
|
|
56
|
-
|
|
57
|
-
## [1.1.0](https://github.com/bhargavrpatel/gulp-prettier/compare/v1.0.0...v1.1.0) (2017-01-16)
|
|
58
|
-
|
|
59
|
-
### Bug fixes
|
|
60
|
-
|
|
61
|
-
* Add dependencies ([`0e4c3f5`](https://github.com/bhargavrpatel/gulp-prettier/commit/0e4c3f5))
|
|
62
|
-
|
|
63
|
-
## [1.0.0](https://github.com/bhargavrpatel/gulp-prettier/compare/86f02f9cdf4bc840624c21e1679dc75fad525de5...v1.0.0) (2017-01-15)
|
|
64
|
-
|
|
65
|
-
Initial release
|