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

@mongosh/js-multiline-to-singleline

Package Overview
Dependencies
Maintainers
13
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongosh/js-multiline-to-singleline - npm Package Compare versions

Comparing version 1.10.1 to 1.10.2

.depcheckrc

11

.eslintrc.js

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

module.exports = require('../../config/eslintrc.base');
const { fixCygwinPath } = require('@mongodb-js/eslint-config-mongosh/utils');
module.exports = {
root: true,
extends: ['@mongodb-js/eslint-config-mongosh'],
parserOptions: {
tsconfigRootDir: fixCygwinPath(__dirname),
project: ['./tsconfig-lint.json'],
},
};

68

lib/index.js

@@ -35,3 +35,6 @@ "use strict";

}
const replacement = { ...original, type: 'CommentBlock' };
const replacement = {
...original,
type: 'CommentBlock',
};
visitedComments.set(original, replacement);

@@ -43,3 +46,7 @@ return replacement;

const node = path.node;
const keys = ['leadingComments', 'trailingComments', 'innerComments'];
const keys = [
'leadingComments',
'trailingComments',
'innerComments',
];
for (const key of keys) {

@@ -56,9 +63,9 @@ node[key] = (_b = (_a = node[key]) === null || _a === void 0 ? void 0 : _a.map(turnCommentIntoBlock)) !== null && _b !== void 0 ? _b : null;

transformComments(path);
}
},
});
}
}
},
},
};
}
function multilineTemplateStringToSingleLine({ types: t }) {
function multilineTemplateStringToSingleLine({ types: t, }) {
return {

@@ -68,14 +75,16 @@ visitor: {

var _a, _b;
if (!path.node.quasis.some(({ value }) => value.raw.match(/[\r\n]/))) {
if (!path.node.quasis.some(({ value }) => /[\r\n]/.exec(value.raw))) {
return;
}
if (path.parentPath.isTaggedTemplateExpression()) {
path.parentPath.replaceWith(t.callExpression(t.identifier('eval'), [t.stringLiteral(this.file.code.slice((_a = path.parent.start) !== null && _a !== void 0 ? _a : undefined, (_b = path.parent.end) !== null && _b !== void 0 ? _b : undefined))]));
path.parentPath.replaceWith(t.callExpression(t.identifier('eval'), [
t.stringLiteral(this.file.code.slice((_a = path.parent.start) !== null && _a !== void 0 ? _a : undefined, (_b = path.parent.end) !== null && _b !== void 0 ? _b : undefined)),
]));
return;
}
path.replaceWith(t.templateLiteral(path.node.quasis.map(el => t.templateElement({
raw: el.value.raw.replace(/\n|\r\n?/g, '\\n')
path.replaceWith(t.templateLiteral(path.node.quasis.map((el) => t.templateElement({
raw: el.value.raw.replace(/\n|\r\n?/g, '\\n'),
}, el.tail)), path.node.expressions));
}
}
},
},
};

@@ -87,13 +96,17 @@ }

try {
postASI = (_b = (_a = babel.transformSync(src, {
retainLines: true,
compact: false,
code: true,
comments: true,
configFile: false,
babelrc: false,
browserslistConfigFile: false,
plugins: [lineCommentToBlockComment, multilineTemplateStringToSingleLine],
sourceType: 'script'
})) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : src;
postASI =
(_b = (_a = babel.transformSync(src, {
retainLines: true,
compact: false,
code: true,
comments: true,
configFile: false,
babelrc: false,
browserslistConfigFile: false,
plugins: [
lineCommentToBlockComment,
multilineTemplateStringToSingleLine,
],
sourceType: 'script',
})) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : src;
}

@@ -103,9 +116,12 @@ catch (_c) {

}
const asSingleLine = postASI.split(/[\r\n]+/g)
.map(line => line.trim())
const asSingleLine = postASI
.split(/[\r\n]+/g)
.map((line) => line.trim())
.join(' ')
.trim();
return src.trim().endsWith(';') ? asSingleLine : asSingleLine.replace(/;$/, '');
return src.trim().endsWith(';')
? asSingleLine
: asSingleLine.replace(/;$/, '');
}
exports.makeMultilineJSIntoSingleLine = makeMultilineJSIntoSingleLine;
//# sourceMappingURL=index.js.map
{
"name": "@mongosh/js-multiline-to-singleline",
"version": "1.10.1",
"version": "1.10.2",
"description": "Make multiline JS into a single line",

@@ -16,6 +16,10 @@ "main": "./lib/index.js",

"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"lint": "eslint --report-unused-disable-directives \"./{src,test}/**/*.{js,ts,tsx}\"",
"check": "npm run lint && depcheck --skip-missing=true",
"compile-ts": "tsc -p tsconfig.json",
"prepublish": "npm run compile-ts"
"eslint": "eslint",
"lint": "npm run eslint . && npm run prettier -- --check .",
"check": "npm run lint && npm run depcheck",
"depcheck": "depcheck",
"compile": "tsc -p tsconfig.json",
"prepublish": "npm run compile",
"prettier": "prettier",
"reformat": "npm run prettier -- --write . && npm run eslint --fix"
},

@@ -33,8 +37,15 @@ "license": "Apache-2.0",

"dependencies": {
"@babel/core": "^7.16.12"
"@babel/core": "^7.16.12",
"@babel/types": "^7.21.2"
},
"devDependencies": {
"@types/babel__core": "^7.1.18"
"@mongodb-js/eslint-config-mongosh": "1.10.2",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "1.10.2",
"@types/babel__core": "^7.1.18",
"depcheck": "^1.4.3",
"eslint": "^7.25.0",
"prettier": "^2.8.8"
},
"gitHead": "05ad91b4dd40382a13f27abe1ae8c3f9f52a38f7"
"gitHead": "9351a54cc24def10a97fe7f8c7b455c02fdce62e"
}

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