Repository: prettier/prettier-eslint (ts)

Issue:
Shebang being stripped when run with eslint-plugin-node
<!--
Thanks for your interest in the project. I appreciate bugs filed and PRs submitted!
Please make sure that you are familiar with and follow the Code of Conduct for
this project (found in the CODE_OF_CONDUCT.md file).

Please fill out this template with all the relevant information so we can
understand what's going on and fix the issue.

I'll probably ask you to submit the fix (after giving some direction). If you've
never done that before, that's great! Check this free short video tutorial to
learn how: http://kcd.im/pull-request
-->

**Versions**:

- `prettier-eslint` version: 6.2.2
- `node` version: v7.10.0
- `yarn` version: 0.24.5

**Have you followed [the debugging tips](https://github.com/prettier/prettier-eslint/blob/master/README.md#debugging-issues)?**

Yes

**Relevant code or config**

```javascript
// package.json
"bin": { "bin": "index.js" }
```

```javascript
// index.js
#!/usr/bin/env node
console.log("Hello, world!");
```

```yaml
# .eslintrc.yaml
plugins: [node]
rules: { node/shebang: error }
```

https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/shebang.md
When run with `eslint --fix`, the shebang is correctly added if absent and not removed.
When run with `prettier`, it's not touched at all.
And `prettier-eslint` keeps removing it (but only if the `node/shebang` rule is enabled).
It seems that the rule can't detect if the script is a bin file, i.e. can't read `package.json` or something, so it treats the file as a regular file.

Pull request description:
fix: pass filePath to eslint.executeOnText
Closes #86

Patch:
diff --git a/src/index.js b/src/index.js
index 8211394..4d82453 100644
--- a/src/index.js
+++ b/src/index.js
@@ -81,10 +81,10 @@ function format(options) {
   const eslintFix = createEslintFix(formattingOptions.eslint, eslintPath)
 
   if (prettierLast) {
-    return prettify(eslintFix(text))
+    return prettify(eslintFix(text, filePath))
   }
 
-  return eslintFix(prettify(text))
+  return eslintFix(prettify(text), filePath)
 }
 
 function createPrettify(formatOptions, prettierPath) {
@@ -131,11 +131,11 @@ function createPrettify(formatOptions, prettierPath) {
 }
 
 function createEslintFix(eslintConfig, eslintPath) {
-  return function eslintFix(text) {
+  return function eslintFix(text, filePath) {
     const eslint = getESLintCLIEngine(eslintPath, eslintConfig)
     try {
       logger.trace(`calling eslint.executeOnText with the text`)
-      const report = eslint.executeOnText(text)
+      const report = eslint.executeOnText(text, filePath, true)
       logger.trace(
         `executeOnText returned the following report:`,
         prettyFormat(report),


Test patch:
diff --git a/src/index.test.js b/src/index.test.js
index 299df37..29b8608 100644
--- a/src/index.test.js
+++ b/src/index.test.js
@@ -116,6 +116,18 @@ const tests = [
     },
     output: 'var foo = { bar: { baz: qux }};\nvar fop = { bar: [1, 2, 3]};',
   },
+  {
+    title: 'with a filePath-aware config',
+    input: {
+      text: 'var x = 0;',
+      eslintConfig: {
+        rules: {'no-var': 'error'},
+        ignorePattern: 'should-be-ignored',
+      },
+      filePath: 'should-be-ignored',
+    },
+    output: 'var x = 0;',
+  },
   // if you have a bug report or something,
   // go ahead and add a test case here
   {