prettier-plugin-sh
Advanced tools
Comparing version 0.13.0 to 0.13.1
import { type Node, type Pos } from 'mvdan-sh'; | ||
import type { ParserOptions, Plugin } from 'prettier'; | ||
import type { File, Node as ShSyntaxNode, 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 { type Node as ShSyntaxNode, type ShOptions } from 'sh-syntax'; | ||
export interface ShParserOptions extends Required<ParserOptions<Node | ShSyntaxNode>>, Required<ShOptions> { | ||
@@ -14,0 +5,0 @@ experimentalWasm: boolean; |
@@ -1,11 +0,5 @@ | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import sh from 'mvdan-sh'; | ||
import { createSyncFn } from 'synckit'; | ||
import { processor, } from 'sh-syntax'; | ||
import { languages } from './languages.js'; | ||
const _dirname = typeof __dirname === 'undefined' | ||
? path.dirname(fileURLToPath(import.meta.url)) | ||
: __dirname; | ||
const { syntax } = sh; | ||
const processor = createSyncFn(path.resolve(_dirname, 'worker.js')); | ||
class ShParseError extends SyntaxError { | ||
@@ -38,6 +32,6 @@ constructor(err) { | ||
sh: { | ||
parse: (text, { filepath, keepComments = true, stopAt, variant, experimentalWasm, }) => { | ||
async parse(text, { filepath, keepComments = true, stopAt, variant, experimentalWasm, }) { | ||
if (experimentalWasm) { | ||
try { | ||
return processor(text, { | ||
return await processor(text, { | ||
filepath, | ||
@@ -74,3 +68,3 @@ keepComments, | ||
sh: { | ||
print: (path, { originalText, filepath, useTabs, tabWidth, indent = useTabs ? 0 : tabWidth, binaryNextLine = true, switchCaseIndent = true, spaceRedirects = true, keepPadding, minify, functionNextLine, experimentalWasm, }) => { | ||
print(path, { originalText, filepath, useTabs, tabWidth, indent = useTabs ? 0 : tabWidth, binaryNextLine = true, switchCaseIndent = true, spaceRedirects = true, keepPadding, minify, functionNextLine, experimentalWasm, }) { | ||
if (experimentalWasm) { | ||
@@ -77,0 +71,0 @@ return processor(path.getNode(), { |
@@ -171,2 +171,27 @@ export const languages = [ | ||
{ | ||
"name": "Nushell", | ||
"aceMode": "sh", | ||
"since": "0.1.0", | ||
"parsers": [ | ||
"sh" | ||
], | ||
"linguistLanguageId": 446573572, | ||
"vscodeLanguageIds": [ | ||
"shellscript" | ||
], | ||
"extensions": [ | ||
".nu" | ||
], | ||
"interpreters": [ | ||
"nu" | ||
], | ||
"aliases": [ | ||
"nu-script", | ||
"nushell-script" | ||
], | ||
"tmScope": "source.nushell", | ||
"codemirrorMode": "shell", | ||
"codemirrorMimeType": "text/x-sh" | ||
}, | ||
{ | ||
"name": "OpenRC runscript", | ||
@@ -194,2 +219,26 @@ "aceMode": "sh", | ||
{ | ||
"name": "Option List", | ||
"aceMode": "sh", | ||
"since": "0.1.0", | ||
"parsers": [ | ||
"sh" | ||
], | ||
"linguistLanguageId": 723589315, | ||
"vscodeLanguageIds": [ | ||
"shellscript" | ||
], | ||
"aliases": [ | ||
"opts", | ||
"ackrc" | ||
], | ||
"filenames": [ | ||
".ackrc", | ||
"ackrc", | ||
"mocha.opts" | ||
], | ||
"tmScope": "source.opts", | ||
"codemirrorMode": "shell", | ||
"codemirrorMimeType": "text/x-sh" | ||
}, | ||
{ | ||
"name": "Shell", | ||
@@ -217,3 +266,2 @@ "aceMode": "sh", | ||
".command", | ||
".env", | ||
".fcgi", | ||
@@ -224,2 +272,3 @@ ".ksh", | ||
".tool", | ||
".trigger", | ||
".zsh", | ||
@@ -230,2 +279,3 @@ ".zsh-theme" | ||
".bash_aliases", | ||
".bash_functions", | ||
".bash_history", | ||
@@ -236,4 +286,2 @@ ".bash_logout", | ||
".cshrc", | ||
".env", | ||
".env.example", | ||
".flaskenv", | ||
@@ -240,0 +288,0 @@ ".kshrc", |
{ | ||
"name": "prettier-plugin-sh", | ||
"version": "0.13.0", | ||
"version": "0.13.1", | ||
"type": "module", | ||
@@ -41,4 +41,3 @@ "description": "An opinionated `shellscript` formatter plugin for Prettier, also support simple format of `Dockerfile`, `properties`, `gitignore`, `dotenv`, `hosts`, `jvmoptions`...", | ||
"mvdan-sh": "^0.10.1", | ||
"sh-syntax": "^0.4.1", | ||
"synckit": "^0.8.5" | ||
"sh-syntax": "^0.4.1" | ||
}, | ||
@@ -45,0 +44,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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64962
3
1927
11
- Removedsynckit@^0.8.5
- Removed@pkgr/core@0.1.1(transitive)
- Removedsynckit@0.8.8(transitive)