Skip to content

Commit e7d46c7

Browse files
committed
Respect .prettierignore config
1 parent bc33780 commit e7d46c7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

eslint-plugin-prettier.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ module.exports = {
357357
!context.options[1] || context.options[1].usePrettierrc !== false;
358358
const sourceCode = context.getSourceCode();
359359
const source = sourceCode.text;
360+
const sourceFileName = context.getFilename();
360361

361362
// The pragma is only valid if it is found in a block comment at the very
362363
// start of the file.
@@ -401,19 +402,22 @@ module.exports = {
401402
usePrettierrc &&
402403
prettier.resolveConfig &&
403404
prettier.resolveConfig.sync
404-
? prettier.resolveConfig.sync(context.getFilename(), {
405+
? prettier.resolveConfig.sync(sourceFileName, {
405406
editorconfig: true
406407
})
407408
: null;
408409
const prettierOptions = Object.assign(
409410
{},
410411
prettierRcOptions,
411412
eslintPrettierOptions,
412-
{ filepath: context.getFilename() }
413+
{ filepath: sourceFileName }
413414
);
414-
415415
const prettierSource = prettier.format(source, prettierOptions);
416-
if (source !== prettierSource) {
416+
const sourceFileInfo = prettier.getFileInfo.sync(sourceFileName, {
417+
ignorePath: '.prettierignore'
418+
});
419+
420+
if (!sourceFileInfo.ignored && source !== prettierSource) {
417421
const differences = generateDifferences(source, prettierSource);
418422

419423
differences.forEach(difference => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-prettier",
3-
"version": "2.6.2",
3+
"version": "2.6.3",
44
"description": "Runs prettier as an eslint rule",
55
"keywords": [
66
"eslint",
@@ -41,7 +41,7 @@
4141
"eslint-plugin-self": "^1.0.1",
4242
"mocha": "^3.1.2",
4343
"moment": "^2.18.1",
44-
"prettier": "^1.10.2",
44+
"prettier": "^1.13.0",
4545
"semver": "^5.3.0",
4646
"vue-eslint-parser": "^2.0.2"
4747
},

0 commit comments

Comments
 (0)