Skip to content

Commit 4d12158

Browse files
committed
Respect .prettierignore config
1 parent bc33780 commit 4d12158

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v2.6.3 (2018-07-17)
4+
5+
* Fix: respect .prettierignore settings ([#88](https://github.com/prettier/eslint-plugin-prettier/issues/88))
6+
37
## v2.6.2 (2018-07-06)
48

59
* 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))

eslint-plugin-prettier.js

Lines changed: 12 additions & 3 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,27 @@ 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
);
414415

416+
const sourceFileInfo =
417+
prettier &&
418+
prettier.getFileInfo &&
419+
prettier.getFileInfo.sync &&
420+
prettier.getFileInfo.sync(sourceFileName, {
421+
ignorePath: '.prettierignore'
422+
});
415423
const prettierSource = prettier.format(source, prettierOptions);
416-
if (source !== prettierSource) {
424+
425+
if (!sourceFileInfo.ignored && source !== prettierSource) {
417426
const differences = generateDifferences(source, prettierSource);
418427

419428
differences.forEach(difference => {

package.json

Lines changed: 1 addition & 1 deletion
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",

0 commit comments

Comments
 (0)