Socket
Socket
Sign inDemoInstall

detect-formatting

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-formatting

Detect the indentation, newline style, quotes style, and usage of semicolons of a JavaScript file.


Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

detect-formatting

Detect the indentation, newline style, quotes style, and usage of semicolons of a JavaScript file.

Installation

npm i detect-formatting
pnpm add detect-formatting
yarn add detect-formatting
bun add detect-formatting

Usage

import { detectIndent, detectNewline, detectSemicolon, detectQuotes } from 'detect-formatting';
import { readFileSync } from 'node:fs';

const file = readFileSync('index.js', 'utf-8');

detectIndent(file);
// { type: 'space' | 'tab', amount: number, indent: string } | undefined
detectNewline(file);
// { type: 'lf' | 'crlf', newline: '\n' | '\r\n' } | undefined
detectSemicolon(file);
// boolean | undefined
detectQuotes(file);
// { type: 'single' | 'double', quotes: "'" | '"' } | undefined

License

MIT

[!NOTE] The detectIndent() and detectNewline() functions are largely based on Sindre Sorhus' packages, detect-indent and detect-newline. Licences for the two can be found in COPYING.md.

FAQs

Package last updated on 25 Dec 2023

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