New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@teleporthq/teleport-postprocessor-prettier-js

Package Overview
Dependencies
Maintainers
5
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teleporthq/teleport-postprocessor-prettier-js - npm Package Compare versions

Comparing version

to
0.9.0

dist/cjs/index.d.ts

21

package.json
{
"name": "@teleporthq/teleport-postprocessor-prettier-js",
"version": "0.8.1",
"version": "0.9.0",
"description": "A post-processing function that formats js code chunks using prettier and the prettier-js plugin",

@@ -8,4 +8,5 @@ "author": "teleportHQ",

"homepage": "https://teleporthq.io/",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/esm/index.js",
"repository": {

@@ -22,13 +23,13 @@ "type": "git",

"scripts": {
"clean": "rimraf lib",
"build": "tsc",
"build:watch": "tsc -w",
"build:watch:component": "tsc -w"
"clean": "rimraf dist",
"build": "npm run build:cjs & npm run build:esm",
"build:cjs": "tsc -p tsconfig-cjs.json",
"build:esm": "tsc -p tsconfig-esm.json"
},
"dependencies": {
"@teleporthq/teleport-shared": "^0.8.1",
"@teleporthq/teleport-types": "^0.8.1",
"@teleporthq/teleport-shared": "^0.9.0",
"@teleporthq/teleport-types": "^0.9.0",
"prettier": "^1.17.0"
},
"gitHead": "73055f1b260190a3848f91fd6ce342e17a971369"
"gitHead": "596c96d8a650d6a7a91d34e16e4d21b03db58096"
}

@@ -6,19 +6,31 @@ import { format } from 'prettier/standalone'

import { PRETTIER_CONFIG, FILE_TYPE } from '@teleporthq/teleport-shared/lib/constants'
import { PostProcessingFunction } from '@teleporthq/teleport-types'
import { PRETTIER_CONFIG, FILE_TYPE } from '@teleporthq/teleport-shared/dist/cjs/constants'
import { PostProcessor, PrettierFormatOptions } from '@teleporthq/teleport-types'
const processor: PostProcessingFunction = (codeChunks) => {
if (codeChunks[FILE_TYPE.JS]) {
codeChunks[FILE_TYPE.JS] = format(codeChunks[FILE_TYPE.JS], {
...PRETTIER_CONFIG,
plugins: [parserBabylon, parserPostCSS],
parser: 'babel',
})
} else {
console.warn('No code chunk of type JS found, prettier-js did not perform any operation')
interface PostProcessorFactoryOptions {
fileType?: string
formatOptions?: PrettierFormatOptions
}
export const createPostProcessor = (options: PostProcessorFactoryOptions = {}) => {
const fileType = options.fileType || FILE_TYPE.JS
const formatOptions = { ...PRETTIER_CONFIG, ...options.formatOptions }
const processor: PostProcessor = (codeChunks) => {
if (codeChunks[fileType]) {
codeChunks[fileType] = format(codeChunks[fileType], {
...formatOptions,
plugins: [parserBabylon, parserPostCSS],
parser: 'babel',
})
} else {
console.warn('No code chunk of type JS found, prettier-js did not perform any operation')
}
return codeChunks
}
return codeChunks
return processor
}
export default processor
export default createPostProcessor()