eslint-plugin-prettier 2.6.2 → 2.7.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 +5 -0
- package/eslint-plugin-prettier.js +48 -2
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v2.7.0 (2018-09-26)
|
|
4
|
+
|
|
5
|
+
* Update: Support prettierignore and custom processors ([#111](https://github.com/prettier/eslint-plugin-prettier/issues/111)) ([38537ba](https://github.com/prettier/eslint-plugin-prettier/commit/38537ba35fc9152852c3b91f3041d72556b43013))
|
|
6
|
+
* Build: switch to release script package ([047dc8f](https://github.com/prettier/eslint-plugin-prettier/commit/047dc8ffdf006c74267df4902fec684c589dad12))
|
|
7
|
+
|
|
3
8
|
## v2.6.2 (2018-07-06)
|
|
4
9
|
|
|
5
10
|
* Fix: Add representation for \r to showInvisibles ([#100](https://github.com/prettier/eslint-plugin-prettier/issues/100)) ([731bbb5](https://github.com/prettier/eslint-plugin-prettier/commit/731bbb576ce422a5c73a1fa9750aa3466c7da928))
|
|
@@ -356,6 +356,7 @@ module.exports = {
|
|
|
356
356
|
const usePrettierrc =
|
|
357
357
|
!context.options[1] || context.options[1].usePrettierrc !== false;
|
|
358
358
|
const sourceCode = context.getSourceCode();
|
|
359
|
+
const filepath = context.getFilename();
|
|
359
360
|
const source = sourceCode.text;
|
|
360
361
|
|
|
361
362
|
// The pragma is only valid if it is found in a block comment at the very
|
|
@@ -397,19 +398,64 @@ module.exports = {
|
|
|
397
398
|
context.options[0] === 'fb'
|
|
398
399
|
? FB_PRETTIER_OPTIONS
|
|
399
400
|
: context.options[0];
|
|
401
|
+
|
|
400
402
|
const prettierRcOptions =
|
|
401
403
|
usePrettierrc &&
|
|
402
404
|
prettier.resolveConfig &&
|
|
403
405
|
prettier.resolveConfig.sync
|
|
404
|
-
? prettier.resolveConfig.sync(
|
|
406
|
+
? prettier.resolveConfig.sync(filepath, {
|
|
405
407
|
editorconfig: true
|
|
406
408
|
})
|
|
407
409
|
: null;
|
|
410
|
+
|
|
411
|
+
// prettier.getFileInfo was added in v1.13
|
|
412
|
+
const prettierFileInfo =
|
|
413
|
+
prettier.getFileInfo && prettier.getFileInfo.sync
|
|
414
|
+
? prettier.getFileInfo.sync(filepath, {
|
|
415
|
+
ignorePath: '.prettierignore'
|
|
416
|
+
})
|
|
417
|
+
: { ignored: false, inferredParser: null };
|
|
418
|
+
|
|
419
|
+
// Skip if file is ignored using a .prettierignore file
|
|
420
|
+
if (prettierFileInfo.ignored) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const initialOptions = {};
|
|
425
|
+
|
|
426
|
+
// ESLint suppports processors that let you extract and lint JS
|
|
427
|
+
// fragments within a non-JS language. In the cases where prettier
|
|
428
|
+
// supports the same language as a processor, we want to process
|
|
429
|
+
// the provided source code as javascript (as ESLint provides the
|
|
430
|
+
// rules with fragments of JS) instead of guessing the parser
|
|
431
|
+
// based off the filename. Otherwise, for instance, on a .md file we
|
|
432
|
+
// end up trying to run prettier over a fragment of JS using the
|
|
433
|
+
// markdown parser, which throws an error.
|
|
434
|
+
// If we can't infer the parser from from the filename, either
|
|
435
|
+
// because no filename was provided or because there is no parser
|
|
436
|
+
// found for the filename, use javascript.
|
|
437
|
+
// This is added to the options first, so that
|
|
438
|
+
// prettierRcOptions and eslintPrettierOptions can still override
|
|
439
|
+
// the parser.
|
|
440
|
+
//
|
|
441
|
+
// `parserBlocklist` should contain the list of prettier parser
|
|
442
|
+
// names for file types where:
|
|
443
|
+
// * Prettier supports parsing the file type
|
|
444
|
+
// * There is an ESLint processor that extracts JavaScript snippets
|
|
445
|
+
// from the file type.
|
|
446
|
+
const parserBlocklist = [null, 'graphql', 'markdown', 'html'];
|
|
447
|
+
if (
|
|
448
|
+
parserBlocklist.indexOf(prettierFileInfo.inferredParser) !== -1
|
|
449
|
+
) {
|
|
450
|
+
initialOptions.parser = 'babylon';
|
|
451
|
+
}
|
|
452
|
+
|
|
408
453
|
const prettierOptions = Object.assign(
|
|
409
454
|
{},
|
|
455
|
+
initialOptions,
|
|
410
456
|
prettierRcOptions,
|
|
411
457
|
eslintPrettierOptions,
|
|
412
|
-
{ filepath
|
|
458
|
+
{ filepath }
|
|
413
459
|
);
|
|
414
460
|
|
|
415
461
|
const prettierSource = prettier.format(source, prettierOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-prettier",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Runs prettier as an eslint rule",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"main": "eslint-plugin-prettier.js",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint .",
|
|
18
|
-
"test": "npm run lint && mocha"
|
|
18
|
+
"test": "npm run lint && mocha",
|
|
19
|
+
"generate-release": "node-release-script"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"prettier": ">= 0.11.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@not-an-aardvark/node-release-script": "^0.1.0",
|
|
36
38
|
"eslint": "^3.14.1",
|
|
37
39
|
"eslint-config-not-an-aardvark": "^2.0.0",
|
|
38
40
|
"eslint-config-prettier": "^1.3.0",
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
"eslint-plugin-self": "^1.0.1",
|
|
42
44
|
"mocha": "^3.1.2",
|
|
43
45
|
"moment": "^2.18.1",
|
|
44
|
-
"prettier": "^1.
|
|
46
|
+
"prettier": "^1.13.0",
|
|
45
47
|
"semver": "^5.3.0",
|
|
46
48
|
"vue-eslint-parser": "^2.0.2"
|
|
47
49
|
},
|