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.8.2 to 0.9.0

lib/worker.d.ts

8

CHANGELOG.md
# Change Log
## 0.9.0
### Minor Changes
- [#154](https://github.com/rx-ts/prettier/pull/154) [`fd19f3a`](https://github.com/rx-ts/prettier/commit/fd19f3a069f73279f3e98f1b1edac47588548c8c) Thanks [@JounQin](https://github.com/JounQin)! - feat: use wasm for plugin sh
- [#154](https://github.com/rx-ts/prettier/pull/154) [`fd19f3a`](https://github.com/rx-ts/prettier/commit/fd19f3a069f73279f3e98f1b1edac47588548c8c) Thanks [@JounQin](https://github.com/JounQin)! - feat: drop umd format support
## 0.8.2

@@ -4,0 +12,0 @@

27

lib/index.d.ts

@@ -1,24 +0,5 @@

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 ShParseError {
Filename: string;
Pos: Pos;
Text: string;
Incomplete: boolean;
Error(): void;
}
declare const ShPlugin: Plugin<Node>;
import { ParserOptions, Plugin } from 'prettier';
import { ShOptions } from 'sh-syntax';
export declare type ShParserOptions = ParserOptions & ShOptions;
declare const ShPlugin: Plugin;
export default ShPlugin;

@@ -1,4 +0,10 @@

import sh from 'mvdan-sh';
import path from 'path';
import { fileURLToPath } from 'url';
import { createSyncFn } from 'synckit';
import { languages } from './languages.js';
const { syntax } = sh;
const _dirname = typeof __dirname === 'undefined'
? path.dirname(fileURLToPath(import.meta.url))
: __dirname;
const workerPath = path.resolve(_dirname, 'worker.js');
const printSync = createSyncFn(workerPath);
const ShPlugin = {

@@ -8,20 +14,38 @@ languages,

sh: {
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));
}
parse: (_text, _parsers, options) => options,
astFormat: 'sh',
locStart: () => 0,
locEnd: () => 0,
},
},
printers: {
sh: {
print: (_path, { originalText, filepath, useTabs, tabWidth, keepComments, stopAt, variant, indent, binaryNextLine, switchCaseIndent, spaceRedirects, keepPadding, minify, functionNextLine, }) => {
try {
return syntax.NewParser(...parserOptions).Parse(text, filepath);
return printSync(originalText, {
filepath,
useTabs,
tabWidth,
keepComments,
stopAt,
variant,
indent,
binaryNextLine,
switchCaseIndent,
spaceRedirects,
keepPadding,
minify,
functionNextLine,
});
}
catch (e) {
const err = e;
throw Object.assign(new SyntaxError(err.Text), {
catch (err) {
const error = err;
if (typeof error === 'string') {
throw new SyntaxError(error);
}
throw Object.assign(error, {
loc: {
start: {
column: err.Pos.Col(),
line: err.Pos.Line(),
column: error.pos.col,
line: error.pos.line,
},

@@ -32,14 +56,4 @@ },

},
astFormat: 'sh',
locStart: node => node.Pos().Offset(),
locEnd: node => node.End().Offset(),
},
},
printers: {
sh: {
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()),
},
},
options: {

@@ -46,0 +60,0 @@ keepComments: {

@@ -26,24 +26,2 @@ export const languages = [

{
"name": "Altium Designer",
"since": "0.1.0",
"parsers": [
"sh"
],
"aliases": [
"altium"
],
"extensions": [
".OutJob",
".PcbDoc",
".PrjPCB",
".SchDoc"
],
"tmScope": "source.ini",
"aceMode": "ini",
"linguistLanguageId": 187772328,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "CODEOWNERS",

@@ -90,24 +68,2 @@ "since": "0.1.0",

{
"name": "EditorConfig",
"since": "0.1.0",
"parsers": [
"sh"
],
"group": "INI",
"aliases": [
"editor-config"
],
"filenames": [
".editorconfig"
],
"tmScope": "source.editorconfig",
"aceMode": "ini",
"codemirrorMode": "properties",
"codemirrorMimeType": "text/x-properties",
"linguistLanguageId": 96139566,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "Gentoo Ebuild",

@@ -173,61 +129,2 @@ "since": "0.1.0",

{
"name": "Git Config",
"since": "0.1.0",
"parsers": [
"sh"
],
"group": "INI",
"aliases": [
"gitconfig",
"gitmodules"
],
"extensions": [
".gitconfig"
],
"filenames": [
".gitconfig",
".gitmodules"
],
"tmScope": "source.gitconfig",
"aceMode": "ini",
"codemirrorMode": "properties",
"codemirrorMimeType": "text/x-properties",
"linguistLanguageId": 807968997,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "INI",
"since": "0.1.0",
"parsers": [
"sh"
],
"aliases": [
"dosini"
],
"extensions": [
".ini",
".cfg",
".dof",
".lektorproject",
".prefs",
".pro",
".properties",
".url"
],
"filenames": [
".flake8",
"buildozer.spec"
],
"tmScope": "source.ini",
"aceMode": "ini",
"codemirrorMode": "properties",
"codemirrorMimeType": "text/x-properties",
"linguistLanguageId": 163,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "Ignore List",

@@ -400,23 +297,2 @@ "since": "0.1.0",

{
"name": "ShellCheck Config",
"since": "0.1.0",
"parsers": [
"sh"
],
"aliases": [
"shellcheckrc"
],
"filenames": [
".shellcheckrc"
],
"tmScope": "source.shellcheckrc",
"aceMode": "ini",
"codemirrorMode": "properties",
"codemirrorMimeType": "text/x-properties",
"linguistLanguageId": 687511714,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "ShellSession",

@@ -489,38 +365,2 @@ "since": "0.1.0",

{
"name": "Win32 Message File",
"since": "0.1.0",
"parsers": [
"sh"
],
"extensions": [
".mc"
],
"tmScope": "source.win32-messages",
"aceMode": "ini",
"codemirrorMode": "properties",
"codemirrorMimeType": "text/x-properties",
"linguistLanguageId": 950967261,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "Windows Registry Entries",
"since": "0.1.0",
"parsers": [
"sh"
],
"extensions": [
".reg"
],
"tmScope": "source.reg",
"aceMode": "ini",
"codemirrorMode": "properties",
"codemirrorMimeType": "text/x-properties",
"linguistLanguageId": 969674868,
"vscodeLanguageIds": [
"ini"
]
},
{
"name": "JvmOptions",

@@ -527,0 +367,0 @@ "since": "0.1.0",

{
"name": "prettier-plugin-sh",
"version": "0.8.2",
"version": "0.9.0",
"type": "module",

@@ -10,2 +10,5 @@ "description": "An opinionated `shellscript、Dockerfile、properties、gitignore、dotenv、hosts、jvmoptions...` formatter plugin for Prettier",

"license": "MIT",
"engines": {
"node": ">=12.20"
},
"main": "./lib/index.cjs",

@@ -15,6 +18,5 @@ "module": "./lib/index.js",

"import": "./lib/index.js",
"require": "./lib/index.cjs"
"require": "./lib/index.cjs",
"types": "./lib/index.d.ts"
},
"jsdelivr": "./lib/umd.min.js",
"unpkg": "./lib/umd.min.js",
"types": "./lib/index.d.ts",

@@ -39,3 +41,4 @@ "files": [

"dependencies": {
"mvdan-sh": "^0.5.0"
"sh-syntax": "^0.0.2",
"synckit": "^0.6.1"
},

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

Sorry, the diff of this file is not supported yet

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