Repository: prettier/prettier-eslint
Pull request #749 (2022-05-12 21:33:10)

chore(prettier): Take Prettier 2.4.0's jsxBracketSameLine → bracketSameLine
prettier/prettier@4992d9720, released in 2.4.0, deprecated the
`jsxBracketSameLine` option in favor of a new, more generic option,
`bracketSameLine`. See docs:
  https://prettier.io/docs/en/options.html#bracket-line

This has caused a warning

>  jsxBracketSameLine is deprecated.

for people using Prettier 2.4.0+, if their ESLint config leads us to
infer and use a value for jsxBracketSameLine.

So, instead of inferring and using a value for jsxBracketSameLine,
do so for the new bracketSameLine.

In d8bf1e3dc, which we released in 14.0.0, we stopped supporting
Prettier versions older than 2.5.1. That means we don't need to
maintain backward-compatible code for users with Prettier <2.4.0,
which doesn't have bracketSameLine.

See discussion:
  https://github.com/prettier/prettier-eslint-cli/pull/430#issuecomment-1124449040

idahogurl: LGTM. Let's put this as a breaking change, the need for Prettier 2.4+. If that's the case, we have to bump the package to 15.0.0. 

Patch:
diff --git a/.all-contributorsrc b/.all-contributorsrc
index ee2f3c8..3fe72c8 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -310,6 +310,16 @@
       "contributions": [
         "code"
       ]
+    },
+    {
+      "login": "chrisbobbe",
+      "name": "Chris Bobbe",
+      "avatar_url": "https://avatars.githubusercontent.com/u/22248748?v=4",
+      "profile": "https://github.com/chrisbobbe",
+      "contributions": [
+        "bug",
+        "code"
+      ]
     }
   ],
   "repoType": "github",
diff --git a/README.md b/README.md
index f653315..7114d3c 100644
--- a/README.md
+++ b/README.md
@@ -183,7 +183,7 @@ fall back to the `prettier` defaults:
   // prettier-eslint doesn't currently support
   // inferring these two (Pull Requests welcome):
   parser: 'babylon',
-  jsxBracketSameLine: false,
+  bracketSameLine: false,
 }
 ```
 
@@ -305,12 +305,12 @@ Thanks goes to these people ([emoji key][emojis]):
   <tr>
     <td align="center"><a href="https://github.com/cy6erskunk"><img src="https://avatars3.githubusercontent.com/u/754849?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Igor</b></sub></a><br /><a href="#maintenance-cy6erskunk" title="Maintenance">🚧</a></td>
     <td align="center"><a href="https://campcode.dev/"><img src="https://avatars.githubusercontent.com/u/10620169?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rebecca Vest</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint/commits?author=idahogurl" title="Code">💻</a></td>
+    <td align="center"><a href="https://github.com/chrisbobbe"><img src="https://avatars.githubusercontent.com/u/22248748?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Bobbe</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint/issues?q=author%3Achrisbobbe" title="Bug reports">🐛</a> <a href="https://github.com/prettier/prettier-eslint/commits?author=chrisbobbe" title="Code">💻</a></td>
   </tr>
 </table>
 
 <!-- markdownlint-restore -->
 <!-- prettier-ignore-end -->
-
 <!-- ALL-CONTRIBUTORS-LIST:END -->
 
 This project follows the [all-contributors][all-contributors] specification.
diff --git a/package.json b/package.json
index acbb082..ea85327 100644
--- a/package.json
+++ b/package.json
@@ -3,13 +3,15 @@
   "version": "0.0.0-development",
   "description": "Formats your JavaScript using prettier followed by eslint --fix",
   "main": "dist/index.js",
+  "types": "types/index.d.ts",
   "scripts": {
     "start": "nps",
     "test": "nps test",
     "precommit": "opt --in pre-commit --exec \"npm start validate\""
   },
   "files": [
-    "dist"
+    "dist",
+    "types"
   ],
   "keywords": [],
   "author": "Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)",
@@ -18,6 +20,8 @@
   ],
   "license": "MIT",
   "dependencies": {
+    "@types/eslint": "^8.4.2",
+    "@types/prettier": "^2.6.0",
     "@typescript-eslint/parser": "^5.10.0",
     "common-tags": "^1.4.0",
     "dlv": "^1.1.0",
diff --git a/src/utils.js b/src/utils.js
index 975ea94..02e19ea 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -46,10 +46,10 @@ const OPTION_GETTERS = {
     ruleValue: rules => getRuleValue(rules, 'indent'),
     ruleValueToPrettierOption: getUseTabs
   },
-  jsxBracketSameLine: {
+  bracketSameLine: {
     ruleValue: rules =>
       getRuleValue(rules, 'react/jsx-closing-bracket-location', 'nonEmpty'),
-    ruleValueToPrettierOption: getJsxBracketSameLine
+    ruleValueToPrettierOption: getBracketSameLine
   },
   arrowParens: {
     ruleValue: rules => getRuleValue(rules, 'arrow-parens'),
@@ -263,7 +263,7 @@ function getUseTabs(eslintValue, fallbacks) {
   return makePrettierOption('useTabs', prettierValue, fallbacks);
 }
 
-function getJsxBracketSameLine(eslintValue, fallbacks) {
+function getBracketSameLine(eslintValue, fallbacks) {
   let prettierValue;
 
   if (eslintValue === 'after-props') {
@@ -278,7 +278,7 @@ function getJsxBracketSameLine(eslintValue, fallbacks) {
     prettierValue = eslintValue;
   }
 
-  return makePrettierOption('jsxBracketSameLine', prettierValue, fallbacks);
+  return makePrettierOption('bracketSameLine', prettierValue, fallbacks);
 }
 
 function getArrowParens(eslintValue, fallbacks) {
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..e844e53
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,14 @@
+{
+    "compilerOptions": {
+        "target": "ES2020",
+        "module": "CommonJS",
+        "lib": ["ES2020", "DOM"],
+        "moduleResolution": "Node",
+        "rootDir": ".",
+        "strict": true,
+        "noEmit": true,
+        "esModuleInterop": true,
+        "baseUrl": "./"
+    },
+    "exclude": ["node_modules"]
+}
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..7cf8b65
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,95 @@
+// Type definitions for prettier-eslint 12.0
+// Project: https://github.com/prettier/prettier-eslint
+
+import * as eslint from "eslint";
+import * as prettier from "prettier";
+
+declare namespace format {
+    /**
+     * Logging level for the traceback of the synchronous formatting process.
+     */
+    type LogLevel = "error" | "warn" | "info" | "debug" | "trace";
+
+    /**
+     * Options to format text with Prettier and ESLint.
+     */
+    interface Options {
+        /**
+         * The config to use for formatting with ESLint.
+         */
+        eslintConfig?: eslint.Linter.Config;
+        /**
+         * The path to the eslint module to use.
+         * Will default to require.resolve('eslint')
+         */
+        eslintPath?: string;
+        /**
+         * The options to pass for formatting with `prettier` if the given
+         * option is not inferrable from the `eslintConfig`.
+         */
+        fallbackPrettierOptions?: prettier.Options;
+        /**
+         * The path of the file being formatted can be used in lieu of
+         * `eslintConfig` (eslint will be used to find the relevant
+         * config for the file). Will also be used to load the `text` if
+         * `text` is not provided.
+         */
+        filePath?: string;
+        /**
+         * The level for the logs (`error`, `warn`, `info`, `debug`, `trace`).
+         */
+        logLevel?: LogLevel;
+        /**
+         * The options to pass for formatting with `prettier`. If not provided,
+         * prettier-eslint will attempt to create the options based on the
+         * `eslintConfig` value.
+         */
+        prettierOptions?: prettier.Options;
+        /**
+         * The path to the `prettier` module.
+         * Will default to require.resovlve('prettier')
+         */
+        prettierPath?: string;
+        /**
+         * Run Prettier last.
+         */
+        prettierLast?: boolean;
+        /**
+         * The text (JavaScript code) to format.
+         */
+        text: string;
+    }
+}
+
+/**
+ * Formats the text with Prettier and then ESLint while obeying the user's
+ * configuration.
+ *
+ * @param options Options to format text with Prettier and Eslint.
+ * @param options.eslintConfig The config to use for formatting
+ * with ESLint.
+ * @param options.eslintPath The path to the eslint module to use.
+ * Will default to require.resolve('eslint')
+ * @param options.fallbackPrettierOptions The options to pass for
+ * formatting with `prettier` if the given option is not inferrable from the
+ * eslintConfig.
+ * @param options.filePath The path of the file being formatted
+ * can be used in lieu of `eslintConfig` (eslint will be used to find the
+ * relevant config for the file). Will also be used to load the `text` if
+ * `text` is not provided.
+ * @param options.prettierOptions The options to pass for
+ * formatting with `prettier`. If not provided, prettier-eslint will attempt
+ * to create the options based on the `eslintConfig` value.
+ * @param options.prettierLast Run Prettier last.
+ * @param options.prettierPath The path to the prettier module.
+ * Will default to require.resovlve('prettier')
+ * @param options.logLevel The level for the logs (`error`, `warn`,
+ * `info`, `debug`, `trace`).
+ * @param options.text The text (JavaScript code) to format.
+ * @return Auto-formatted text that is mostly compliant with the
+ * supplied configuration. The auto-formatting is limited to the issues that
+ * Prettier and ESLint can automatically fix.
+ */
+declare function format(options: format.Options): string;
+
+export = format;


Test patch:
diff --git a/src/__tests__/utils.js b/src/__tests__/utils.js
index 458bc0e..9fef968 100644
--- a/src/__tests__/utils.js
+++ b/src/__tests__/utils.js
@@ -113,16 +113,16 @@ const getPrettierOptionsFromESLintRulesTests = [
   },
   {
     rules: {},
-    options: { jsxBracketSameLine: true },
-    fallbackPrettierOptions: { jsxBracketSameLine: true }
+    options: { bracketSameLine: true },
+    fallbackPrettierOptions: { bracketSameLine: true }
   },
   {
     rules: { 'react/jsx-closing-bracket-location': [2, 'after-props'] },
-    options: { jsxBracketSameLine: true }
+    options: { bracketSameLine: true }
   },
   {
     rules: { 'react/jsx-closing-bracket-location': [2, 'tag-aligned'] },
-    options: { jsxBracketSameLine: false }
+    options: { bracketSameLine: false }
   },
   {
     rules: {
@@ -133,7 +133,7 @@ const getPrettierOptionsFromESLintRulesTests = [
         }
       ]
     },
-    options: { jsxBracketSameLine: true }
+    options: { bracketSameLine: true }
   },
   {
     rules: {