eslint-plugin-prettier 3.0.0 → 3.1.2
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/CHANGELOG.md +94 -0
- package/README.md +10 -0
- package/eslint-plugin-prettier.js +57 -6
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v3.1.2 (2019-12-15)
|
|
4
|
+
|
|
5
|
+
* Resolve config when getting list of inferred parsers ([1ad45be](git@github.com:prettier/eslint-plugin-prettier/commit/1ad45be48ea1ed16e0eb3ba6247163724b956516))
|
|
6
|
+
* Fix tests now they to stop them inheriting from base prettierrc file ([14840fa](git@github.com:prettier/eslint-plugin-prettier/commit/14840fa4c88c938bf30c1fdf1c26c32b2708a3b6))
|
|
7
|
+
* Move prettier config into dedicated file, so vscode plugins pick it up ([c49334a](git@github.com:prettier/eslint-plugin-prettier/commit/c49334a846afa6f688695a4774f7824ee3a05e1c))
|
|
8
|
+
* build(deps-dev): bump eslint from 6.7.1 to 6.7.2 ([15e6cf9](git@github.com:prettier/eslint-plugin-prettier/commit/15e6cf91509cb5b819d2e1fb19dbe9bc71c87893))
|
|
9
|
+
* build(deps-dev): bump eslint from 6.6.0 to 6.7.1 ([e8ad019](git@github.com:prettier/eslint-plugin-prettier/commit/e8ad0195000af416f3315396e9c02fea261391cc))
|
|
10
|
+
* build(deps-dev): bump eslint-config-prettier from 6.6.0 to 6.7.0 ([44f4bfe](git@github.com:prettier/eslint-plugin-prettier/commit/44f4bfe0b6f63234afeba266928b39b762269282))
|
|
11
|
+
* build(deps-dev): bump eslint-config-prettier from 6.5.0 to 6.6.0 ([46580c5](git@github.com:prettier/eslint-plugin-prettier/commit/46580c55914057dee5089e9c6e525e41996888d1))
|
|
12
|
+
* build(deps-dev): bump prettier from 1.18.2 to 1.19.1 ([10b4676](git@github.com:prettier/eslint-plugin-prettier/commit/10b46763fd007a8f939e43635831aec590717e87))
|
|
13
|
+
* build(deps-dev): bump eslint from 6.5.1 to 6.6.0 ([53eaeae](git@github.com:prettier/eslint-plugin-prettier/commit/53eaeaec91c158b66cc04dbf80f9631bb82285bf))
|
|
14
|
+
* build(deps-dev): bump eslint-config-prettier from 6.4.0 to 6.5.0 ([ad3321c](git@github.com:prettier/eslint-plugin-prettier/commit/ad3321c3ae6e963317fedcdd205ba719bf933d74))
|
|
15
|
+
* build(deps-dev): bump mocha from 6.2.1 to 6.2.2 ([b7280b6](git@github.com:prettier/eslint-plugin-prettier/commit/b7280b68eaae243aa33de364576cddf0844c6848))
|
|
16
|
+
* build(deps-dev): bump eslint-config-prettier from 6.3.0 to 6.4.0 ([4c1d69a](git@github.com:prettier/eslint-plugin-prettier/commit/4c1d69a8022c709cd62e964a82c7dbc7963f0544))
|
|
17
|
+
* build(deps-dev): bump eslint from 6.5.0 to 6.5.1 ([c109a7a](git@github.com:prettier/eslint-plugin-prettier/commit/c109a7a5acca9533feae6258e9ac4934359ed9b3))
|
|
18
|
+
* build(deps-dev): bump mocha from 6.2.0 to 6.2.1 ([3134bea](git@github.com:prettier/eslint-plugin-prettier/commit/3134beab61dee13aa2c73762a55f51f868553e8a))
|
|
19
|
+
* build(deps-dev): bump eslint from 6.4.0 to 6.5.0 ([7c290d7](git@github.com:prettier/eslint-plugin-prettier/commit/7c290d799e319b39519d81a110b62846894bc7ba))
|
|
20
|
+
|
|
21
|
+
## v3.1.1 (2019-09-18)
|
|
22
|
+
|
|
23
|
+
* build(deps-dev): bump eslint from 6.3.0 to 6.4.0 ([8a793eb](git@github.com:prettier/eslint-plugin-prettier/commit/8a793eba54ff01493e3ee83daf4dcb782d039fdd))
|
|
24
|
+
* build(deps-dev): bump eslint-config-prettier from 6.2.0 to 6.3.0 ([88c3f6c](git@github.com:prettier/eslint-plugin-prettier/commit/88c3f6cb510b758e6dc866a1ad1a0484ef074484))
|
|
25
|
+
* build(deps-dev): bump eslint-config-prettier from 6.0.0 to 6.2.0 ([5f9fbc1](git@github.com:prettier/eslint-plugin-prettier/commit/5f9fbc16f91d88a5c77b8b9d942b82424add77a5))
|
|
26
|
+
* build(deps-dev): bump eslint from 6.2.2 to 6.3.0 ([746b66d](git@github.com:prettier/eslint-plugin-prettier/commit/746b66dc701e8226930f6e4d8386bd500dcb303b))
|
|
27
|
+
* build(deps-dev): bump eslint from 6.1.0 to 6.2.2 ([97eedb4](git@github.com:prettier/eslint-plugin-prettier/commit/97eedb4734a4c569d4c24a62cffe024c2a26c178))
|
|
28
|
+
* build(deps-dev): bump eslint from 6.0.1 to 6.1.0 ([afef9d1](git@github.com:prettier/eslint-plugin-prettier/commit/afef9d137c8b7887c63e3f8d51cabf42851f5cf1))
|
|
29
|
+
* build(deps-dev): bump mocha from 6.1.4 to 6.2.0 ([0360a84](git@github.com:prettier/eslint-plugin-prettier/commit/0360a845ce530d8c25f390961d6446b4c58e85ac))
|
|
30
|
+
* build(deps): [security] bump lodash from 4.17.11 to 4.17.14 ([9eceb68](git@github.com:prettier/eslint-plugin-prettier/commit/9eceb6834fcd003c5680c3202b656ca3474c19c2))
|
|
31
|
+
* Fix: When forcing the JS parser, use the modern name ([#212](git@github.com:prettier/eslint-plugin-prettier/issues/212)) ([1385310](git@github.com:prettier/eslint-plugin-prettier/commit/1385310fce778a8c771d0dab0e400725c9f9d82e))
|
|
32
|
+
* Add eslint 6 to test matrix ([#210](git@github.com:prettier/eslint-plugin-prettier/issues/210)) ([bca77e6](git@github.com:prettier/eslint-plugin-prettier/commit/bca77e66ed1eba682eb13055862adc70478d472b))
|
|
33
|
+
* build(deps-dev): bump eslint-config-prettier from 5.0.0 to 6.0.0 ([4c069bd](git@github.com:prettier/eslint-plugin-prettier/commit/4c069bd0f3b907039569964e747479aa06279594))
|
|
34
|
+
* build(deps-dev): bump eslint-config-prettier from 4.3.0 to 5.0.0 ([60bb22f](git@github.com:prettier/eslint-plugin-prettier/commit/60bb22f4ae1d6af001ba55338a7cb08111db23d9))
|
|
35
|
+
* build(deps-dev): bump prettier from 1.18.0 to 1.18.2 ([a183560](git@github.com:prettier/eslint-plugin-prettier/commit/a1835600facebc819e31a0816061e62f8be2cd8b))
|
|
36
|
+
* build(deps-dev): bump prettier from 1.17.1 to 1.18.0 ([0cad479](git@github.com:prettier/eslint-plugin-prettier/commit/0cad4793abb6139eb9d6853b5adef7469aef756d))
|
|
37
|
+
* build(deps-dev): bump eslint-config-prettier from 4.2.0 to 4.3.0 ([6f3c76f](git@github.com:prettier/eslint-plugin-prettier/commit/6f3c76fd75dc4f982d1221e6b4802329b32176a9))
|
|
38
|
+
* build(deps-dev): bump prettier from 1.17.0 to 1.17.1 ([03aecfd](git@github.com:prettier/eslint-plugin-prettier/commit/03aecfd49b96d055ff54ec989c93408a9fb3f3ee))
|
|
39
|
+
|
|
40
|
+
## v3.1.0 (2019-05-11)
|
|
41
|
+
|
|
42
|
+
* New: Allow options to be passed to prettier.getFileInfo ([#187](https://github.com/prettier/eslint-plugin-prettier/issues/187)) ([21fa69a](https://github.com/prettier/eslint-plugin-prettier/commit/21fa69a8ed3b6acfc5461f6c3332444c21e65e28))
|
|
43
|
+
* build(deps-dev): bump eslint-plugin-eslint-plugin from 2.0.1 to 2.1.0 ([bb597e1](https://github.com/prettier/eslint-plugin-prettier/commit/bb597e14aba46211fd4149d0b0f1bdc51fe76452))
|
|
44
|
+
* build(deps-dev): bump eslint-config-prettier from 4.1.0 to 4.2.0 ([0bb7c1d](https://github.com/prettier/eslint-plugin-prettier/commit/0bb7c1d361b581fddebd64bf172b5dedcad5149c))
|
|
45
|
+
* build(deps-dev): bump vue-eslint-parser from 6.0.3 to 6.0.4 ([2f77df4](https://github.com/prettier/eslint-plugin-prettier/commit/2f77df48f151d4975bbdb29ced8c74a72d011428))
|
|
46
|
+
* build(deps-dev): bump mocha from 6.1.3 to 6.1.4 ([222b87a](https://github.com/prettier/eslint-plugin-prettier/commit/222b87a347331b20b3e7f65dcdfaa491bd277b3a))
|
|
47
|
+
* build(deps-dev): bump prettier from 1.16.4 to 1.17.0 ([58d8ff8](https://github.com/prettier/eslint-plugin-prettier/commit/58d8ff8ab2b1f73c904f5492eb523d7ea585ed8f))
|
|
48
|
+
* build(deps-dev): bump mocha from 6.1.2 to 6.1.3 ([e94e56c](https://github.com/prettier/eslint-plugin-prettier/commit/e94e56c36018aab6e08452fbe05bb16a23d64197))
|
|
49
|
+
* build(deps-dev): bump mocha from 6.1.1 to 6.1.2 ([c02244b](https://github.com/prettier/eslint-plugin-prettier/commit/c02244b197893f4e2a214d43f755b726cecbd03c))
|
|
50
|
+
* build(deps-dev): bump mocha from 6.0.2 to 6.1.1 ([a9a2e4e](https://github.com/prettier/eslint-plugin-prettier/commit/a9a2e4e3c0a243ec73061c10d9c4a5ae0c0e6f68))
|
|
51
|
+
* build(deps-dev): bump eslint from 5.15.3 to 5.16.0 ([073c14c](https://github.com/prettier/eslint-plugin-prettier/commit/073c14c2ae5c43d0939fe6f475561f1cf3d7a3e5))
|
|
52
|
+
* build(deps-dev): bump eslint from 5.15.2 to 5.15.3 ([bda931f](https://github.com/prettier/eslint-plugin-prettier/commit/bda931f4f1344f6927fbfd3a35965d1a4d319642))
|
|
53
|
+
* build(deps-dev): bump eslint from 5.15.1 to 5.15.2 ([19f53d6](https://github.com/prettier/eslint-plugin-prettier/commit/19f53d6a94a701e0aab9630bef93051aec4dfd36))
|
|
54
|
+
* build(deps-dev): bump eslint from 5.15.0 to 5.15.1 ([34b39de](https://github.com/prettier/eslint-plugin-prettier/commit/34b39dec2e6e283da1ca6faa0c636c5361efb5b9))
|
|
55
|
+
* build(deps-dev): bump eslint from 5.14.1 to 5.15.0 ([13bcc66](https://github.com/prettier/eslint-plugin-prettier/commit/13bcc66c120d614c17040e329360510feab47e7d))
|
|
56
|
+
* build(deps-dev): bump eslint-plugin-self from 1.1.0 to 1.2.0 ([5b4adb8](https://github.com/prettier/eslint-plugin-prettier/commit/5b4adb8ce683a93feddad07eda17d99b41849342))
|
|
57
|
+
* build(deps-dev): bump vue-eslint-parser from 6.0.2 to 6.0.3 ([e676cd1](https://github.com/prettier/eslint-plugin-prettier/commit/e676cd19387e70102467d9a82014906561f3c225))
|
|
58
|
+
* build(deps-dev): bump eslint-config-prettier from 4.0.0 to 4.1.0 ([b8a9215](https://github.com/prettier/eslint-plugin-prettier/commit/b8a9215515cdcb75faf212caeb00dfbcae11ee42))
|
|
59
|
+
* build(deps-dev): bump mocha from 6.0.1 to 6.0.2 ([cde36e4](https://github.com/prettier/eslint-plugin-prettier/commit/cde36e4db18ac4442eba3c75a20c1a6605e937d4))
|
|
60
|
+
* build(deps-dev): bump mocha from 6.0.0 to 6.0.1 ([eb39699](https://github.com/prettier/eslint-plugin-prettier/commit/eb39699b9bdf7c406a3134cc26c404947534661d))
|
|
61
|
+
* build(deps-dev): bump mocha from 5.2.0 to 6.0.0 ([5d75421](https://github.com/prettier/eslint-plugin-prettier/commit/5d75421d5e3ee5f8293b47a5825e1f2415f7e6b9))
|
|
62
|
+
* build(deps-dev): bump eslint from 5.14.0 to 5.14.1 ([829156e](https://github.com/prettier/eslint-plugin-prettier/commit/829156e467e53f554691afa687c13715086974f7))
|
|
63
|
+
* build(deps-dev): bump eslint from 5.13.0 to 5.14.0 ([b76d0b4](https://github.com/prettier/eslint-plugin-prettier/commit/b76d0b4471845143630b3603b97607665bf66ca0))
|
|
64
|
+
* build(deps-dev): bump vue-eslint-parser from 6.0.0 to 6.0.2 ([15439e8](https://github.com/prettier/eslint-plugin-prettier/commit/15439e8e0dcfa11a19f0cf249a1f4ad5f7fa5b96))
|
|
65
|
+
* build(deps-dev): bump vue-eslint-parser from 5.0.0 to 6.0.0 ([0ea70e5](https://github.com/prettier/eslint-plugin-prettier/commit/0ea70e5161d315ab93e6c4eb93f76d5304b8c162))
|
|
66
|
+
* build(deps-dev): bump eslint from 5.12.1 to 5.13.0 ([5f18729](https://github.com/prettier/eslint-plugin-prettier/commit/5f18729dbe359fe0df10730fd768a1ca6949b0a2))
|
|
67
|
+
* build(deps-dev): bump prettier from 1.16.3 to 1.16.4 ([ef637fe](https://github.com/prettier/eslint-plugin-prettier/commit/ef637fea4d6028b472cfe56dcb4fe30ee7939e0d))
|
|
68
|
+
* build(deps-dev): bump prettier from 1.16.1 to 1.16.3 ([58ab20c](https://github.com/prettier/eslint-plugin-prettier/commit/58ab20cc03f81a7d668998e64168eef7ad5b4365))
|
|
69
|
+
* build(deps-dev): bump eslint-config-prettier from 3.6.0 to 4.0.0 ([14393bd](https://github.com/prettier/eslint-plugin-prettier/commit/14393bdbcfd6114e810c10b4b7f905485474a36f))
|
|
70
|
+
* build(deps-dev): bump prettier from 1.16.0 to 1.16.1 ([00198b9](https://github.com/prettier/eslint-plugin-prettier/commit/00198b9795d1341f4c4a488c83f656e74f6bfdb0))
|
|
71
|
+
* build(deps-dev): bump prettier from 1.15.3 to 1.16.0 ([7890a87](https://github.com/prettier/eslint-plugin-prettier/commit/7890a876fc1c22b1fdee8724296eaa56eb6df1a3))
|
|
72
|
+
* build(deps-dev): bump eslint from 5.12.0 to 5.12.1 ([92a8984](https://github.com/prettier/eslint-plugin-prettier/commit/92a898470fbd88a4f5f4d8e1b15cf53bd7f8a92e))
|
|
73
|
+
* build(deps-dev): bump eslint-config-prettier from 3.5.0 to 3.6.0 ([5292d12](https://github.com/prettier/eslint-plugin-prettier/commit/5292d127dfd4f90ec6695d4060b5f5447a2c0119))
|
|
74
|
+
* build(deps-dev): bump eslint-config-prettier from 3.4.0 to 3.5.0 ([44a2558](https://github.com/prettier/eslint-plugin-prettier/commit/44a2558820d1c733f1572c98503e7b00b16b3fb7))
|
|
75
|
+
* build(deps-dev): bump eslint-config-prettier from 3.3.0 to 3.4.0 ([425cfce](https://github.com/prettier/eslint-plugin-prettier/commit/425cfce1bb712c96dfdd2292b04d89cceb375681))
|
|
76
|
+
* build(deps-dev): bump eslint from 5.11.1 to 5.12.0 ([3e9aa39](https://github.com/prettier/eslint-plugin-prettier/commit/3e9aa399ee3c0394a397f6ed3f8ec7c5e1597991))
|
|
77
|
+
* build(deps-dev): bump eslint-plugin-node from 8.0.0 to 8.0.1 ([e913afd](https://github.com/prettier/eslint-plugin-prettier/commit/e913afdd7291b5e58adf567f5e7a5bb9257dc9e3))
|
|
78
|
+
* build(deps-dev): bump vue-eslint-parser from 4.0.3 to 5.0.0 ([ecfd5ba](https://github.com/prettier/eslint-plugin-prettier/commit/ecfd5bab7bfb36e0203a334808243cb85aaeb512))
|
|
79
|
+
|
|
80
|
+
## v3.0.1 (2018-12-28)
|
|
81
|
+
|
|
82
|
+
* Catch and format SyntaxErrors as eslint violations ([#141](https://github.com/prettier/eslint-plugin-prettier/issues/141)) ([4a0e57d](https://github.com/prettier/eslint-plugin-prettier/commit/4a0e57ddcc0fa2ae8e8f7d8b65ddc4ac93d9f474))
|
|
83
|
+
* build(deps-dev): bump eslint from 5.11.0 to 5.11.1 ([d34daed](https://github.com/prettier/eslint-plugin-prettier/commit/d34daed47fbda09cbd19a73c38323e0aed0c30d5))
|
|
84
|
+
* build(deps-dev): bump eslint from 5.10.0 to 5.11.0 ([7f4f45d](https://github.com/prettier/eslint-plugin-prettier/commit/7f4f45dd132ecd72207b536b86910bebf15693b6))
|
|
85
|
+
* build(deps-dev): bump eslint-plugin-eslint-plugin from 2.0.0 to 2.0.1 ([5be3bcf](https://github.com/prettier/eslint-plugin-prettier/commit/5be3bcfce11b741cd35c92b9c972e457a4038766))
|
|
86
|
+
* build(deps-dev): bump eslint from 5.9.0 to 5.10.0 ([11e7c44](https://github.com/prettier/eslint-plugin-prettier/commit/11e7c447a8ebcfae213afe6ba872f96adb43e6b9))
|
|
87
|
+
* build(deps-dev): bump eslint-plugin-eslint-plugin from 1.4.1 to 2.0.0 ([9e5bf14](https://github.com/prettier/eslint-plugin-prettier/commit/9e5bf140451f82a36c78042315a9f88a12cfe45f))
|
|
88
|
+
* build(deps-dev): bump vue-eslint-parser from 4.0.2 to 4.0.3 ([234583a](https://github.com/prettier/eslint-plugin-prettier/commit/234583a19a97ecd1f996542ccb1178a26d20c0fd))
|
|
89
|
+
* build(deps-dev): bump vue-eslint-parser from 3.3.0 to 4.0.2 ([8675d57](https://github.com/prettier/eslint-plugin-prettier/commit/8675d5713f5171981119b89c2e8a58fda6b81259))
|
|
90
|
+
* Upgrade: Bump vue-eslint-parser from 3.2.2 to 3.3.0 ([2379e93](https://github.com/prettier/eslint-plugin-prettier/commit/2379e93c7fb81ddfe306c1fe6a10d1833cfddf2c))
|
|
91
|
+
* Upgrade: Bump eslint-config-prettier from 3.1.0 to 3.3.0 ([3ea0021](https://github.com/prettier/eslint-plugin-prettier/commit/3ea00218961b75e475def14372f9eab0de5ad05d))
|
|
92
|
+
* Upgrade: Bump eslint from 5.8.0 to 5.9.0 ([c774fb8](https://github.com/prettier/eslint-plugin-prettier/commit/c774fb87fe53d19389964883f05e77309b321139))
|
|
93
|
+
* build(deps-dev): bump eslint-plugin-node from 7.0.1 to 8.0.0 ([#121](https://github.com/prettier/eslint-plugin-prettier/issues/121)) ([2a4fba0](https://github.com/prettier/eslint-plugin-prettier/commit/2a4fba01222f62a576da48478e3dcd832e3bff7e))
|
|
94
|
+
* build(deps-dev): bump eslint-plugin-eslint-plugin from 1.4.0 to 1.4.1 ([#120](https://github.com/prettier/eslint-plugin-prettier/issues/120)) ([29caa29](https://github.com/prettier/eslint-plugin-prettier/commit/29caa299612db8af7a188749a5dd8b9827f51a67))
|
|
95
|
+
* build(deps-dev): bump eslint from 5.6.0 to 5.8.0 ([#119](https://github.com/prettier/eslint-plugin-prettier/issues/119)) ([2836350](https://github.com/prettier/eslint-plugin-prettier/commit/2836350829dc3c19b4c1ebca33a3a7905c1b28a5))
|
|
96
|
+
|
|
3
97
|
## v3.0.0 (2018-10-01)
|
|
4
98
|
|
|
5
99
|
* Chore: Add eslint peer-dependency ([d55d79c](https://github.com/prettier/eslint-plugin-prettier/commit/d55d79c6a64f659f405788fc75f344704619979f))
|
package/README.md
CHANGED
|
@@ -121,6 +121,16 @@ For the list of every available exclusion rule set, please see the [readme of es
|
|
|
121
121
|
}]
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
+
- `fileInfoOptions`: Options that are passed to [prettier.getFileInfo](https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath-options) to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located in `node_modules` directories.
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
"prettier/prettier": ["error", {}, {
|
|
128
|
+
"fileInfoOptions": {
|
|
129
|
+
"withNodeModules": true
|
|
130
|
+
}
|
|
131
|
+
}]
|
|
132
|
+
```
|
|
133
|
+
|
|
124
134
|
- The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
|
|
125
135
|
|
|
126
136
|
---
|
|
@@ -131,7 +131,12 @@ module.exports = {
|
|
|
131
131
|
{
|
|
132
132
|
type: 'object',
|
|
133
133
|
properties: {
|
|
134
|
-
usePrettierrc: { type: 'boolean' }
|
|
134
|
+
usePrettierrc: { type: 'boolean' },
|
|
135
|
+
fileInfoOptions: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {},
|
|
138
|
+
additionalProperties: true
|
|
139
|
+
}
|
|
135
140
|
},
|
|
136
141
|
additionalProperties: true
|
|
137
142
|
}
|
|
@@ -140,6 +145,8 @@ module.exports = {
|
|
|
140
145
|
create(context) {
|
|
141
146
|
const usePrettierrc =
|
|
142
147
|
!context.options[1] || context.options[1].usePrettierrc !== false;
|
|
148
|
+
const eslintFileInfoOptions =
|
|
149
|
+
(context.options[1] && context.options[1].fileInfoOptions) || {};
|
|
143
150
|
const sourceCode = context.getSourceCode();
|
|
144
151
|
const filepath = context.getFilename();
|
|
145
152
|
const source = sourceCode.text;
|
|
@@ -163,9 +170,14 @@ module.exports = {
|
|
|
163
170
|
})
|
|
164
171
|
: null;
|
|
165
172
|
|
|
166
|
-
const prettierFileInfo = prettier.getFileInfo.sync(
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
const prettierFileInfo = prettier.getFileInfo.sync(
|
|
174
|
+
filepath,
|
|
175
|
+
Object.assign(
|
|
176
|
+
{},
|
|
177
|
+
{ resolveConfig: true, ignorePath: '.prettierignore' },
|
|
178
|
+
eslintFileInfoOptions
|
|
179
|
+
)
|
|
180
|
+
);
|
|
169
181
|
|
|
170
182
|
// Skip if file is ignored using a .prettierignore file
|
|
171
183
|
if (prettierFileInfo.ignored) {
|
|
@@ -198,7 +210,13 @@ module.exports = {
|
|
|
198
210
|
if (
|
|
199
211
|
parserBlocklist.indexOf(prettierFileInfo.inferredParser) !== -1
|
|
200
212
|
) {
|
|
201
|
-
|
|
213
|
+
// Prettier v1.16.0 renamed the `babylon` parser to `babel`
|
|
214
|
+
// Use the modern name if available
|
|
215
|
+
const supportBabelParser = prettier
|
|
216
|
+
.getSupportInfo()
|
|
217
|
+
.languages.some(language => language.parsers.includes('babel'));
|
|
218
|
+
|
|
219
|
+
initialOptions.parser = supportBabelParser ? 'babel' : 'babylon';
|
|
202
220
|
}
|
|
203
221
|
|
|
204
222
|
const prettierOptions = Object.assign(
|
|
@@ -209,7 +227,40 @@ module.exports = {
|
|
|
209
227
|
{ filepath }
|
|
210
228
|
);
|
|
211
229
|
|
|
212
|
-
|
|
230
|
+
// prettier.format() may throw a SyntaxError if it cannot parse the
|
|
231
|
+
// source code it is given. Ususally for JS files this isn't a
|
|
232
|
+
// problem as ESLint will report invalid syntax before trying to
|
|
233
|
+
// pass it to the prettier plugin. However this might be a problem
|
|
234
|
+
// for non-JS languages that are handled by a plugin. Notably Vue
|
|
235
|
+
// files throw an error if they contain unclosed elements, such as
|
|
236
|
+
// `<template><div></template>. In this case report an error at the
|
|
237
|
+
// point at which parsing failed.
|
|
238
|
+
let prettierSource;
|
|
239
|
+
try {
|
|
240
|
+
prettierSource = prettier.format(source, prettierOptions);
|
|
241
|
+
} catch (err) {
|
|
242
|
+
if (!(err instanceof SyntaxError)) {
|
|
243
|
+
throw err;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
let message = 'Parsing error: ' + err.message;
|
|
247
|
+
|
|
248
|
+
// Prettier's message contains a codeframe style preview of the
|
|
249
|
+
// invalid code and the line/column at which the error occured.
|
|
250
|
+
// ESLint shows those pieces of information elsewhere already so
|
|
251
|
+
// remove them from the message
|
|
252
|
+
if (err.codeFrame) {
|
|
253
|
+
message = message.replace(`\n${err.codeFrame}`, '');
|
|
254
|
+
}
|
|
255
|
+
if (err.loc) {
|
|
256
|
+
message = message.replace(/ \(\d+:\d+\)$/, '');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
context.report({ message, loc: err.loc });
|
|
260
|
+
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
213
264
|
if (source !== prettierSource) {
|
|
214
265
|
const differences = generateDifferences(source, prettierSource);
|
|
215
266
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-prettier",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Runs prettier as an eslint rule",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@not-an-aardvark/node-release-script": "^0.1.0",
|
|
39
|
-
"eslint": "^
|
|
39
|
+
"eslint": "^6.0.0",
|
|
40
40
|
"eslint-config-not-an-aardvark": "^2.1.0",
|
|
41
|
-
"eslint-config-prettier": "^
|
|
42
|
-
"eslint-plugin-eslint-plugin": "^
|
|
43
|
-
"eslint-plugin-node": "^
|
|
41
|
+
"eslint-config-prettier": "^6.0.0",
|
|
42
|
+
"eslint-plugin-eslint-plugin": "^2.0.0",
|
|
43
|
+
"eslint-plugin-node": "^8.0.0",
|
|
44
44
|
"eslint-plugin-self": "^1.1.0",
|
|
45
|
-
"mocha": "^
|
|
46
|
-
"prettier": "^1.
|
|
47
|
-
"vue-eslint-parser": "^
|
|
45
|
+
"mocha": "^6.0.0",
|
|
46
|
+
"prettier": "^1.15.3",
|
|
47
|
+
"vue-eslint-parser": "^6.0.0"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=6.0.0"
|