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

prettier-plugin-sh

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-sh - npm Package Compare versions

Comparing version 0.12.3 to 0.12.4

30

lib/index.d.ts

@@ -1,14 +0,24 @@

import { ParserOptions, Plugin } from 'prettier';
import { File, Node, ShOptions } from 'sh-syntax';
export interface Processor {
(text: string, options?: ShOptions): File;
(text: string, options?: ShOptions & {
print: true;
}): string;
(ast: File, options?: ShOptions & {
originalText: string;
}): string;
import { LangVariant, Node, Pos } from 'mvdan-sh';
import { ParserOptions, Plugin, RequiredOptions } from 'prettier';
export interface ShOptions extends RequiredOptions {
keepComments: boolean;
stopAt: string;
variant: LangVariant;
indent: number;
binaryNextLine: boolean;
switchCaseIndent: boolean;
spaceRedirects: boolean;
keepPadding: boolean;
minify: boolean;
functionNextLine: boolean;
}
export declare type ShParserOptions = ParserOptions<Node> & ShOptions;
export interface IShParseError extends Error {
Filename: string;
Pos: Pos;
Text: string;
Incomplete: boolean;
Error(): void;
}
declare const ShPlugin: Plugin<Node>;
export default ShPlugin;

@@ -1,18 +0,14 @@

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createSyncFn } from 'synckit';
import sh from 'mvdan-sh';
import { languages } from './languages.js';
const _dirname = typeof __dirname === 'undefined'
? path.dirname(fileURLToPath(import.meta.url))
: __dirname;
const processor = createSyncFn(path.resolve(_dirname, 'worker.js'));
const { syntax } = sh;
class ShParseError extends SyntaxError {
constructor(err) {
const error = err;
super(('Text' in error && error.Text) || error.message);
super(err.Text);
this.cause = err;
// `error instanceof ParseError` won't not work because the error is thrown wrapped by `synckit`
if ('Pos' in error && error.Pos != null && typeof error.Pos === 'object') {
this.loc = { start: { column: error.Pos.Col, line: error.Pos.Line } };
}
this.loc = {
start: {
column: err.Pos.Col(),
line: err.Pos.Line(),
},
};
}

@@ -25,9 +21,11 @@ }

parse: (text, _parsers, { filepath, keepComments = true, stopAt, variant }) => {
const parserOptions = [syntax.KeepComments(keepComments)];
if (stopAt != null) {
parserOptions.push(syntax.StopAt(stopAt));
}
if (variant != null) {
parserOptions.push(syntax.Variant(variant));
}
try {
return processor(text, {
filepath,
keepComments,
stopAt,
variant,
});
return syntax.NewParser(...parserOptions).Parse(text, filepath);
}

@@ -39,4 +37,4 @@ catch (err) {

astFormat: 'sh',
locStart: node => node.Pos.Offset,
locEnd: node => node.End.Offset,
locStart: node => node.Pos().Offset(),
locEnd: node => node.End().Offset(),
},

@@ -46,15 +44,5 @@ },

sh: {
print: (path, { originalText, filepath, useTabs, tabWidth, indent = useTabs ? 0 : tabWidth, binaryNextLine = true, switchCaseIndent = true, spaceRedirects = true, keepPadding, minify, functionNextLine, }) => processor(path.getNode(), {
originalText,
filepath,
useTabs,
tabWidth,
indent,
binaryNextLine,
switchCaseIndent,
spaceRedirects,
keepPadding,
minify,
functionNextLine,
}),
print: (path, { useTabs, tabWidth, indent = useTabs ? 0 : tabWidth, binaryNextLine = true, switchCaseIndent = true, spaceRedirects = true, keepPadding, minify, functionNextLine, }) => syntax
.NewPrinter(syntax.Indent(indent), syntax.BinaryNextLine(binaryNextLine), syntax.SwitchCaseIndent(switchCaseIndent), syntax.SpaceRedirects(spaceRedirects), syntax.KeepPadding(keepPadding), syntax.Minify(minify), syntax.FunctionNextLine(functionNextLine))
.Print(path.getValue()),
},

@@ -61,0 +49,0 @@ },

{
"name": "prettier-plugin-sh",
"version": "0.12.3",
"version": "0.12.4",
"type": "module",

@@ -39,4 +39,3 @@ "description": "An opinionated `shellscript` formatter plugin for Prettier, also support simple format of `Dockerfile`, `properties`, `gitignore`, `dotenv`, `hosts`, `jvmoptions`...",

"dependencies": {
"sh-syntax": "^0.3.4",
"synckit": "^0.7.1"
"mvdan-sh": "^0.10.1"
},

@@ -43,0 +42,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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