Repository: prettier/prettier-atom (js)

Issue:
Ignored File is written
I have a set of files ignored:
```
dist/
package.json
.babelrc
```

However, when saving the `.babelrc` file prettier is being run against it and the file is being modified.

![prettier-0 55 1-babel](https://user-images.githubusercontent.com/2998575/44487393-d0ab1180-a61b-11e8-82a6-96e6b6133000.gif)

Running `npx prettier .babelrc` does not have this issue (`npx prettier` is running version 1.14.2 if that matters)

Output of the `Prettier: Debug` command:
<details>

```
Atom version: 1.29.0
prettier-atom version: 0.55.1
prettier: bundled
prettier version: 1.13.4
prettier-eslint version: 8.8.2
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "isDisabledIfNoConfigFile": true,
    "isDisabledIfNotInPackageJson": true,
    "showInStatusBar": true,
    "enabled": false,
    "respectEslintignore": true,
    "excludedGlobs": [],
    "whitelistedGlobs": []
  },
  "useEslint": false,
  "useStylelint": false,
  "prettierEslintOptions": {
    "prettierLast": false
  }
}
```

</details>


Pull request description:
fix(prettierignore): properly ignore files again
PR #404 changed to using Prettier's `getFileInfo` and `resolveConfig` functions to determine
whether a file is formattable. We were not correctly invoking the API for `getFileInfo` so every
file was coming up as not ignored.

Fixes #446

Patch:
diff --git a/dist/helpers/isFileFormattable.js b/dist/helpers/isFileFormattable.js
index 1adc13e..fe93f4c 100644
--- a/dist/helpers/isFileFormattable.js
+++ b/dist/helpers/isFileFormattable.js
@@ -3,10 +3,16 @@
 const _ = require('lodash/fp');
 const getPrettierInstance = require('./getPrettierInstance');
 const { getCurrentFilePath, isCurrentFilePathDefined } = require('../editorInterface');
+const { findCachedFromFilePath } = require('./general');
+
+const getNearestPrettierignorePath = filePath => findCachedFromFilePath(filePath, '.prettierignore');
 
 const getPrettierFileInfoForCurrentFilePath = (editor
 // $FlowFixMe: getFileInfo.sync needs to be addded to flow-typed
-) => getPrettierInstance(editor).getFileInfo.sync(getCurrentFilePath(editor), {}, '.prettierignore');
+) => getPrettierInstance(editor).getFileInfo.sync(getCurrentFilePath(editor), {
+  // $FlowIssue: we know filepath is defined at this point
+  ignorePath: getNearestPrettierignorePath(getCurrentFilePath(editor))
+});
 
 const doesFileInfoIndicateFormattable = fileInfo => fileInfo && !fileInfo.ignored && !!fileInfo.inferredParser;
 
diff --git a/src/helpers/isFileFormattable.js b/src/helpers/isFileFormattable.js
index a9ebb6a..b558e28 100644
--- a/src/helpers/isFileFormattable.js
+++ b/src/helpers/isFileFormattable.js
@@ -2,10 +2,17 @@
 const _ = require('lodash/fp');
 const getPrettierInstance = require('./getPrettierInstance');
 const { getCurrentFilePath, isCurrentFilePathDefined } = require('../editorInterface');
+const { findCachedFromFilePath } = require('./general');
+
+const getNearestPrettierignorePath = (filePath: FilePath): ?FilePath =>
+  findCachedFromFilePath(filePath, '.prettierignore');
 
 const getPrettierFileInfoForCurrentFilePath = (editor: TextEditor): Prettier$FileInfo =>
   // $FlowFixMe: getFileInfo.sync needs to be addded to flow-typed
-  getPrettierInstance(editor).getFileInfo.sync(getCurrentFilePath(editor), {}, '.prettierignore');
+  getPrettierInstance(editor).getFileInfo.sync(getCurrentFilePath(editor), {
+    // $FlowIssue: we know filepath is defined at this point
+    ignorePath: getNearestPrettierignorePath(getCurrentFilePath(editor)),
+  });
 
 const doesFileInfoIndicateFormattable = (fileInfo: Prettier$FileInfo): boolean =>
   fileInfo && !fileInfo.ignored && !!fileInfo.inferredParser;


Test patch:
diff --git a/src/helpers/isFileFormattable.test.js b/src/helpers/isFileFormattable.test.js
index 921b470..3ab88ed 100644
--- a/src/helpers/isFileFormattable.test.js
+++ b/src/helpers/isFileFormattable.test.js
@@ -1,16 +1,19 @@
 jest.mock('./getPrettierInstance');
 jest.mock('../editorInterface');
+jest.mock('./general');
 
 const isFileFormattable = require('./isFileFormattable');
 const buildMockEditor = require('../../tests/mocks/textEditor');
 const getPrettierInstance = require('./getPrettierInstance');
 const { getCurrentFilePath, isCurrentFilePathDefined } = require('../editorInterface');
+const { findCachedFromFilePath } = require('./general');
 
 const mockEditor = buildMockEditor();
 
 beforeEach(() => {
   isCurrentFilePathDefined.mockImplementation(() => true);
   getCurrentFilePath.mockImplementation(() => 'xyz.js');
+  findCachedFromFilePath.mockImplementation(() => '.prettierignore');
 });
 
 const mockGetFileInfoSyncFunc = syncFunc =>
@@ -23,7 +26,7 @@ it('calls prettier.getFileInfo.sync with the proper arguments', () => {
 
   isFileFormattable(mockEditor);
 
-  expect(sync).toHaveBeenCalledWith('xyz.js', {}, '.prettierignore');
+  expect(sync).toHaveBeenCalledWith('xyz.js', { ignorePath: '.prettierignore' });
 });
 
 it('returns true if the file is formattable', () => {