All Projects β†’ prettier β†’ Eslint Plugin Prettier

prettier / Eslint Plugin Prettier

Licence: mit
ESLint plugin for Prettier formatting

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Eslint Plugin Prettier

ultimate-hot-boilerplate
πŸš€ node-react universal app boilerplate with everything on hot reload, SSR, GraphQL, Flow included
Stars: ✭ 35 (-98.43%)
Mutual labels:  eslint-plugin, prettier
Gatsby V2 Tutorial Starter
Gatsby V2 Starter - product of step by step tutorial
Stars: ✭ 139 (-93.76%)
Mutual labels:  prettier
Lecture Frontend Dev Env
"[μΈν”„λŸ°] ν”„λ‘ νŠΈμ—”λ“œ κ°œλ°œν™˜κ²½μ˜ 이해와 μ‹€μŠ΅" κ°•μ˜ μ‹€μŠ΅ μžλ£Œμž…λ‹ˆλ‹€.
Stars: ✭ 108 (-95.15%)
Mutual labels:  prettier
Prettier Schematic
Add Prettier to an Angular project
Stars: ✭ 129 (-94.21%)
Mutual labels:  prettier
Eslint Plugin Css Modules
Project status: NOT MAINTAINED; Checks that you are using the existent css/scss classes, no more no less
Stars: ✭ 115 (-94.84%)
Mutual labels:  eslint-plugin
Eslint Plugin Unicorn
Various awesome ESLint rules
Stars: ✭ 2,157 (-3.19%)
Mutual labels:  eslint-plugin
Conf
Landing page for event React Conf Brazil
Stars: ✭ 104 (-95.33%)
Mutual labels:  prettier
Eslint Plugin Boundaries
Eslint plugin checking architecture boundaries between elements
Stars: ✭ 157 (-92.95%)
Mutual labels:  eslint-plugin
Prettier Plugin Apex
Code formatter for the Apex Programming Language
Stars: ✭ 138 (-93.81%)
Mutual labels:  prettier
Pretty Quick
⚑ Get Pretty Quick
Stars: ✭ 1,766 (-20.74%)
Mutual labels:  prettier
Eslint Import Resolver Alias
a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
Stars: ✭ 121 (-94.57%)
Mutual labels:  eslint-plugin
Simple Boilerplate
A simple webpack boilerplate for your comfortable work with HTML, JS and CSS.
Stars: ✭ 116 (-94.79%)
Mutual labels:  prettier
Nextjs Ts
Opinionated Next JS project boilerplate with TypeScript and Redux
Stars: ✭ 134 (-93.99%)
Mutual labels:  prettier
Zoe
πŸŒ€ Zero-config ESLint toolchain with sensible defaults.
Stars: ✭ 113 (-94.93%)
Mutual labels:  prettier
Pettier
Prettier config that randomizes options and arbitrarily switches between spaces and tabs πŸ™„
Stars: ✭ 149 (-93.31%)
Mutual labels:  prettier
Prettier
Prettier is an opinionated code formatter.
Stars: ✭ 41,411 (+1758.66%)
Mutual labels:  prettier
Javascriptprettier
A Visual Studio extension
Stars: ✭ 118 (-94.7%)
Mutual labels:  prettier
Expo Disneyplus
Disney+ UI Clone with React Native & Expo
Stars: ✭ 130 (-94.17%)
Mutual labels:  prettier
Prettier Plugin Solidity
Prettier plugin for Solidity
Stars: ✭ 156 (-93%)
Mutual labels:  prettier
Spotless
Keep your code spotless
Stars: ✭ 2,285 (+2.56%)
Mutual labels:  prettier

eslint-plugin-prettier Build Status

Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.

If your desired formatting does not match Prettier’s output, you should use a different tool such as prettier-eslint instead.

Please read Integrating with linters before installing.

Sample

error: Insert `,` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:22:25:
  20 | import {
  21 |   observeActiveEditorsDebounced,
> 22 |   editorChangesDebounced
     |                         ^
  23 | } from './debounced';;
  24 |
  25 | import {observableFromSubscribeFunction} from '../commons-node/event';


error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:23:21:
  21 |   observeActiveEditorsDebounced,
  22 |   editorChangesDebounced
> 23 | } from './debounced';;
     |                     ^
  24 |
  25 | import {observableFromSubscribeFunction} from '../commons-node/event';
  26 | import {cacheWhileSubscribed} from '../commons-node/observable';


2 errors found.

./node_modules/.bin/eslint --format codeframe pkg/commons-atom/ActiveEditorRegistry.js (code from nuclide).

Installation

npm install --save-dev eslint-plugin-prettier
npm install --save-dev --save-exact prettier

eslint-plugin-prettier does not install Prettier or ESLint for you. You must install these yourself.

Then, in your .eslintrc.json:

{
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error"
  }
}

Recommended Configuration

This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect potential bugs. (If another active ESLint rule disagrees with prettier about how code should be formatted, it will be impossible to avoid lint errors.) You can use eslint-config-prettier to disable all formatting-related ESLint rules.

This plugin ships with a plugin:prettier/recommended config that sets up both the plugin and eslint-config-prettier in one go.

  1. In addition to the above installation instructions, install eslint-config-prettier:

    npm install --save-dev eslint-config-prettier
  2. Then you need to add plugin:prettier/recommended as the last extension in your .eslintrc.json:

    {
      "extends": ["plugin:prettier/recommended"]
    }

    You can then set Prettier's own options inside a .prettierrc file.

Exactly what does plugin:prettier/recommended do? Well, this is what it expands to:

{
  "extends": ["prettier"],
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": "error",
    "arrow-body-style": "off",
    "prefer-arrow-callback": "off"
  }
}
  • "extends": ["prettier"] enables the config from eslint-config-prettier, which turns off some ESLint rules that conflict with Prettier.
  • "plugins": ["prettier"] registers this plugin.
  • "prettier/prettier": "error" turns on the rule provided by this plugin, which runs Prettier from within ESLint.
  • "arrow-body-style": "off" and "prefer-arrow-callback": "off" turns off two ESLint core rules that unfortunately are problematic with this plugin – see the next section.

arrow-body-style and prefer-arrow-callback issue

If you use arrow-body-style or prefer-arrow-callback together with the prettier/prettier rule from this plugin, you can in some cases end up with invalid code due to a bug in ESLint’s autofix – see issue #65.

For this reason, it’s recommended to turn off these rules. The plugin:prettier/recommended config does that for you.

You can still use these rules together with this plugin if you want, because the bug does not occur all the time. But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.

If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the prettier/prettier rule and running eslint --fix and prettier --write separately.

Options

Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as prettier-atom and prettier-vscode will read .prettierrc, but won't read settings from ESLint, which can lead to an inconsistent experience.

  • The first option:

    • An object representing options that will be passed into prettier. Example:

      "prettier/prettier": ["error", {"singleQuote": true, "parser": "flow"}]

      NB: This option will merge and override any config set with .prettierrc files

  • The second option:

    • An object with the following options

      • usePrettierrc: Enables loading of the Prettier configuration file, (default: true). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration.

        "prettier/prettier": ["error", {}, {
          "usePrettierrc": false
        }]
      • fileInfoOptions: Options that are passed to prettier.getFileInfo to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located in node_modules directories.

        "prettier/prettier": ["error", {}, {
          "fileInfoOptions": {
            "withNodeModules": true
          }
        }]
  • The rule is autofixable -- if you run eslint with the --fix flag, your code will be formatted according to prettier style.


Contributing

See CONTRIBUTING.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].