eslint-plugin-prettier 2.5.0 → 2.6.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/CHANGELOG.md +6 -0
- package/README.md +18 -0
- package/eslint-plugin-prettier.js +39 -7
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v2.6.0 (2018-02-02)
|
|
4
|
+
|
|
5
|
+
* Update: Add option to skip loading prettierrc ([#83](https://github.com/prettier/eslint-plugin-prettier/issues/83)) ([9e0fb48](https://github.com/prettier/eslint-plugin-prettier/commit/9e0fb48d077214a81ac549731308ab11512c37cd))
|
|
6
|
+
* Build: add Node 8 and 9 to Travis ([e5b5fa7](https://github.com/prettier/eslint-plugin-prettier/commit/e5b5fa74d06a06a53d04c4748b31e24fcd7a41b9))
|
|
7
|
+
* Chore: add test for vue parsing ([1ab43fd](https://github.com/prettier/eslint-plugin-prettier/commit/1ab43fd601a67100cb03bbfe614203fd399d40bb))
|
|
8
|
+
|
|
3
9
|
## v2.5.0 (2018-01-16)
|
|
4
10
|
|
|
5
11
|
* Fix: pass filepath to prettier ([#76](https://github.com/prettier/eslint-plugin-prettier/issues/76)) ([0b6ab55](https://github.com/prettier/eslint-plugin-prettier/commit/0b6ab55e0a48e9c31cfa1d7f3b891100e0580493))
|
package/README.md
CHANGED
|
@@ -141,6 +141,24 @@ You can then set Prettier's own options inside a `.prettierrc` file.
|
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
_This option is useful if you're migrating a large codebase and already use pragmas like `@flow`._
|
|
144
|
+
|
|
145
|
+
- An object with the following options
|
|
146
|
+
|
|
147
|
+
- `pragma`: Also sets the aforementioned `pragma`: a string with a pragma that triggers this rule. By default, this rule applies to all files. However, if you set a pragma (this option), only files with that pragma in the heading docblock will be checked. All pragmas must start with `@`.
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
"prettier/prettier": ["error", null, {
|
|
151
|
+
"pragma": "@prettier"
|
|
152
|
+
}]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- `usePrettierrc`: Enables loading of the Prettier configuration file, (default: `true`). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration.
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
"prettier/prettier": ["error", null, {
|
|
159
|
+
"usePrettierrc": false
|
|
160
|
+
}]
|
|
161
|
+
```
|
|
144
162
|
|
|
145
163
|
* The rule is autofixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
|
|
146
164
|
|
|
@@ -282,6 +282,25 @@ function reportReplace(context, offset, deleteText, insertText) {
|
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Get the pragma from the ESLint rule context.
|
|
287
|
+
* @param {RuleContext} context - The ESLint rule context.
|
|
288
|
+
* @returns {string|null}
|
|
289
|
+
*/
|
|
290
|
+
function getPragma(context) {
|
|
291
|
+
const pluginOptions = context.options[1];
|
|
292
|
+
|
|
293
|
+
if (!pluginOptions) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const pragmaRef =
|
|
298
|
+
typeof pluginOptions === 'string' ? pluginOptions : pluginOptions.pragma;
|
|
299
|
+
|
|
300
|
+
// Remove leading @
|
|
301
|
+
return pragmaRef ? pragmaRef.slice(1) : null;
|
|
302
|
+
}
|
|
303
|
+
|
|
285
304
|
// ------------------------------------------------------------------------------
|
|
286
305
|
// Module Definition
|
|
287
306
|
// ------------------------------------------------------------------------------
|
|
@@ -313,15 +332,26 @@ module.exports = {
|
|
|
313
332
|
{ type: 'object', properties: {}, additionalProperties: true }
|
|
314
333
|
]
|
|
315
334
|
},
|
|
316
|
-
|
|
317
|
-
|
|
335
|
+
{
|
|
336
|
+
anyOf: [
|
|
337
|
+
// Pragma:
|
|
338
|
+
{ type: 'string', pattern: '^@\\w+$' },
|
|
339
|
+
{
|
|
340
|
+
type: 'object',
|
|
341
|
+
properties: {
|
|
342
|
+
pragma: { type: 'string', pattern: '^@\\w+$' },
|
|
343
|
+
usePrettierrc: { type: 'boolean' }
|
|
344
|
+
},
|
|
345
|
+
additionalProperties: true
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
}
|
|
318
349
|
]
|
|
319
350
|
},
|
|
320
351
|
create(context) {
|
|
321
|
-
const pragma = context
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
352
|
+
const pragma = getPragma(context);
|
|
353
|
+
const usePrettierrc =
|
|
354
|
+
!context.options[1] || context.options[1].usePrettierrc !== false;
|
|
325
355
|
const sourceCode = context.getSourceCode();
|
|
326
356
|
const source = sourceCode.text;
|
|
327
357
|
|
|
@@ -365,7 +395,9 @@ module.exports = {
|
|
|
365
395
|
? FB_PRETTIER_OPTIONS
|
|
366
396
|
: context.options[0];
|
|
367
397
|
const prettierRcOptions =
|
|
368
|
-
|
|
398
|
+
usePrettierrc &&
|
|
399
|
+
prettier.resolveConfig &&
|
|
400
|
+
prettier.resolveConfig.sync
|
|
369
401
|
? prettier.resolveConfig.sync(context.getFilename())
|
|
370
402
|
: null;
|
|
371
403
|
const prettierOptions = Object.assign(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-prettier",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Runs prettier as an eslint rule",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"mocha": "^3.1.2",
|
|
43
43
|
"moment": "^2.18.1",
|
|
44
44
|
"prettier": "^1.10.2",
|
|
45
|
-
"semver": "^5.3.0"
|
|
45
|
+
"semver": "^5.3.0",
|
|
46
|
+
"vue-eslint-parser": "^2.0.2"
|
|
46
47
|
},
|
|
47
48
|
"engines": {
|
|
48
49
|
"node": ">=4.0.0"
|