Socket
Socket
Sign inDemoInstall

eslint-plugin-prettier

Package Overview
Dependencies
159
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-plugin-prettier

Runs prettier as an eslint rule


Version published
Maintainers
1
Install size
8.19 MB
Created

Package description

What is eslint-plugin-prettier?

The eslint-plugin-prettier npm package integrates Prettier, an opinionated code formatter, with ESLint, a tool for identifying and reporting on patterns in JavaScript. It allows you to use Prettier as an ESLint rule and reports differences as individual ESLint issues.

What are eslint-plugin-prettier's main functionalities?

Code Formatting

Automatically format code to match the style specified in your Prettier configuration when you run ESLint with the --fix option.

"scripts": { "lint": "eslint --fix 'src/**/*.js'" }

Integration with ESLint Rules

Use Prettier to enforce a consistent code style while still using ESLint to catch possible errors.

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

Customizable Formatting Rules

Override default Prettier options to tailor the formatting to your project's needs.

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

Other packages similar to eslint-plugin-prettier

Readme

Source

eslint-plugin-prettier

Runs prettier as an eslint rule

Installation

You'll first need to install ESLint:

$ npm install eslint --save-dev

Next, install eslint-plugin-prettier:

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

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-prettier globally.

Usage

Add prettier to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "prettier"
    ]
}

Then configure the prettier rule under the rules section:

{
    "rules": {
        "prettier/prettier": "error"
    }
}

You can also pass prettier configuration as an option:

{
    "rules": {
        "prettier/prettier": ["error", {"trailingComma": true, "singleQuote": true}]
    }
}

The rule will report an error if your code does not match prettier style. The rule is autofixable -- if you run eslint with the --fix flag, your code will be formatted according to prettier style.

Keywords

FAQs

Last updated on 26 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc