Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-format

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-format

Format various languages with formatters in ESLint

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

eslint-plugin-format

npm version npm downloads bundle JSDocs License

Format various languages with formatters in ESLint. Supports Prettier and dprint. Side-effects-free and fully configurable.

Usages

Install

npm i -D eslint-plugin-format

Configure

This plugin does not do language detection or reading configure files, you need to specify the language for each file type you want to format along with other formatting options. We recommend using ESLint's Flat Config format.

// eslint.config.js
import format from 'eslint-plugin-format'

export default [
  // ...other flat configs

  // use Prettier to format CSS
  {
    files: ['**/*.css'],
    languageOptions: {
      parser: format.parserPlain,
    },
    plugins: {
      format,
    },
    rules: {
      'format/prettier': ['error', { parser: 'css', tabWidth: 2 }],
    },
  },

  // use dprint to format TOML
  {
    files: ['**/*.toml'],
    languageOptions: {
      parser: format.parserPlain,
    },
    plugins: {
      format,
    },
    rules: {
      'format/dprint': ['error', { language: 'toml', languageOptions: { indentWidth: 2 } }],
    },
  },
]

Rules

format/prettier

Use Prettier to format files.

Options
  • parser (required) - the language to format, Supported languages
  • The rest options are passed as Prettier options

format/dprint

Use dprint to format files.

Options
  • language (required) - the language to format, or can be a filepath or URL to the WASM binary. Supported languages
  • languageOptions - the options for the language
  • The rest options are passed as dprint's general options

Sponsors

FAQ

What's the difference between this and eslint-plugin-prettier?

While this plugin provides Prettier as one of the formatters, the main difference is that eslint-plugin-prettier is much more opinionated toward the Prettier CLI ecosystem. While this plugin only treats Prettier as the side-effects-free formatter and gives you full control in ESLint.

Credits

Thanks to the existing works for references and inspiration.

License

MIT License © 2023-PRESENT Anthony Fu

Keywords

FAQs

Package last updated on 15 Jun 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc