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

gremlint

Package Overview
Dependencies
Maintainers
9
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gremlint - npm Package Compare versions

Comparing version 3.6.0 to 3.6.1

4

lib/formatQuery/formatSyntaxTrees/formatClosure.js

@@ -44,4 +44,4 @@ "use strict";

var localIndentation = config.localIndentation, horizontalPosition = config.horizontalPosition, maxLineLength = config.maxLineLength, shouldEndWithDot = config.shouldEndWithDot;
var recreatedQuery = recreateQueryOnelinerFromSyntaxTree_1.default(localIndentation)(syntaxTree);
var formattedMethod = formatSyntaxTree(utils_1.withNoEndDotInfo(config))(unformattedMethod);
var recreatedQuery = (0, recreateQueryOnelinerFromSyntaxTree_1.default)(localIndentation)(syntaxTree);
var formattedMethod = formatSyntaxTree((0, utils_1.withNoEndDotInfo)(config))(unformattedMethod);
var methodWidth = formattedMethod.width;

@@ -48,0 +48,0 @@ if (recreatedQuery.length <= maxLineLength) {

@@ -20,6 +20,10 @@ "use strict";

*/
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -34,4 +38,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

var formatMethod = function (formatSyntaxTree) { return function (config) { return function (syntaxTree) {
var recreatedQuery = recreateQueryOnelinerFromSyntaxTree_1.default(config.localIndentation)(syntaxTree);
var method = formatSyntaxTree(utils_2.withNoEndDotInfo(config))(syntaxTree.method);
var recreatedQuery = (0, recreateQueryOnelinerFromSyntaxTree_1.default)(config.localIndentation)(syntaxTree);
var method = formatSyntaxTree((0, utils_2.withNoEndDotInfo)(config))(syntaxTree.method);
var argumentsWillNotBeWrapped = recreatedQuery.length <= config.maxLineLength;

@@ -47,11 +51,11 @@ if (argumentsWillNotBeWrapped) {

syntaxTree.arguments.reduce(function (argumentGroup, syntaxTree) {
return __spreadArray(__spreadArray([], argumentGroup), [
return __spreadArray(__spreadArray([], argumentGroup, true), [
formatSyntaxTree(
// Since the method's arguments will be on the same line, their horizontal position is increased by the
// method's width plus the width of the opening parenthesis
utils_1.pipe(utils_2.withZeroIndentation, utils_2.withZeroDotInfo, utils_2.withIncreasedHorizontalPosition(method.width + 1 + argumentGroup.map(function (_a) {
(0, utils_1.pipe)(utils_2.withZeroIndentation, utils_2.withZeroDotInfo, (0, utils_2.withIncreasedHorizontalPosition)(method.width + 1 + argumentGroup.map(function (_a) {
var width = _a.width;
return width;
}).reduce(utils_1.sum, 0) + argumentGroup.length))(config))(syntaxTree),
]);
], false);
}, []),

@@ -70,5 +74,5 @@ ],

var argumentGroups = syntaxTree.arguments.map(function (step) { return [
formatSyntaxTree(utils_1.pipe(utils_2.withIncreasedIndentation(2), utils_2.withZeroDotInfo, utils_2.withHorizontalPosition(config.localIndentation + 2))(config))(step),
formatSyntaxTree((0, utils_1.pipe)((0, utils_2.withIncreasedIndentation)(2), utils_2.withZeroDotInfo, (0, utils_2.withHorizontalPosition)(config.localIndentation + 2))(config))(step),
]; });
var lastArgumentGroup = utils_1.last(argumentGroups);
var lastArgumentGroup = (0, utils_1.last)(argumentGroups);
// Add the width of the last line of parameters, the dots between them and the indentation of the parameters

@@ -75,0 +79,0 @@ var width = lastArgumentGroup

@@ -35,4 +35,4 @@ "use strict";

var formatNonGremlin = function (_config) { return function (syntaxTree) {
return __assign(__assign({}, syntaxTree), { width: utils_1.count(utils_1.last(syntaxTree.code.split('\n'))) });
return __assign(__assign({}, syntaxTree), { width: (0, utils_1.count)((0, utils_1.last)(syntaxTree.code.split('\n'))) });
}; };
exports.formatNonGremlin = formatNonGremlin;

@@ -29,3 +29,3 @@ "use strict";

var getStepGroups = function (formatSyntaxTree, steps, config) {
return steps.reduce(utils_2.choose(utils_1.shouldStepBeLastStepInStepGroup(config), utils_2.choose(utils_1.isStepFirstStepInStepGroup, reduceSingleStepInStepGroup_1.default(formatSyntaxTree, config), reduceLastStepInStepGroup_1.default(formatSyntaxTree, config)), utils_2.choose(utils_1.isStepFirstStepInStepGroup, reduceFirstStepInStepGroup_1.default(formatSyntaxTree, config), reduceMiddleStepInStepGroup_1.default(formatSyntaxTree, config))), {
return steps.reduce((0, utils_2.choose)((0, utils_1.shouldStepBeLastStepInStepGroup)(config), (0, utils_2.choose)(utils_1.isStepFirstStepInStepGroup, (0, reduceSingleStepInStepGroup_1.default)(formatSyntaxTree, config), (0, reduceLastStepInStepGroup_1.default)(formatSyntaxTree, config)), (0, utils_2.choose)(utils_1.isStepFirstStepInStepGroup, (0, reduceFirstStepInStepGroup_1.default)(formatSyntaxTree, config), (0, reduceMiddleStepInStepGroup_1.default)(formatSyntaxTree, config))), {
stepsInStepGroup: [],

@@ -32,0 +32,0 @@ stepGroups: [],

@@ -28,3 +28,3 @@ "use strict";

var stepsInStepGroup = _a.stepsInStepGroup, stepGroups = _a.stepGroups;
var localIndentation = config.localIndentation + (stepGroups[0] && utils_3.isTraversalSource(stepGroups[0].steps[0]) ? 2 : 0);
var localIndentation = config.localIndentation + (stepGroups[0] && (0, utils_3.isTraversalSource)(stepGroups[0].steps[0]) ? 2 : 0);
var isFirstStepGroup = stepGroups.length === 0;

@@ -39,3 +39,3 @@ // It is the first step in a group and should start with a dot if it is

stepsInStepGroup: [
formatSyntaxTree(utils_1.pipe(utils_2.withIndentation(localIndentation), utils_2.withDotInfo({ shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot }), utils_2.withHorizontalPosition(localIndentation))(config))(step),
formatSyntaxTree((0, utils_1.pipe)((0, utils_2.withIndentation)(localIndentation), (0, utils_2.withDotInfo)({ shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot }), (0, utils_2.withHorizontalPosition)(localIndentation))(config))(step),
],

@@ -42,0 +42,0 @@ stepGroups: stepGroups,

@@ -20,6 +20,10 @@ "use strict";

*/
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -42,6 +46,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

stepsInStepGroup: [],
stepGroups: __spreadArray(__spreadArray([], stepGroups), [
stepGroups: __spreadArray(__spreadArray([], stepGroups, true), [
{
steps: __spreadArray(__spreadArray([], stepsInStepGroup), [
formatSyntaxTree(utils_1.pipe(utils_2.withZeroIndentation, utils_2.withDotInfo({ shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot }), utils_2.withIncreasedHorizontalPosition(
steps: __spreadArray(__spreadArray([], stepsInStepGroup, true), [
formatSyntaxTree((0, utils_1.pipe)(utils_2.withZeroIndentation, (0, utils_2.withDotInfo)({ shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot }), (0, utils_2.withIncreasedHorizontalPosition)(
// If I recall correctly, the + stepsInStepGroup.length handles the horizontal increase caused by the dots joining the steps

@@ -52,7 +56,7 @@ stepsInStepGroup.map(function (_a) {

}).reduce(utils_1.sum, 0) + stepsInStepGroup.length))(config))(step),
]),
], false),
},
]),
], false),
};
}; };
exports.default = reduceLastStepInStepGroup;

@@ -20,6 +20,10 @@ "use strict";

*/
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -36,5 +40,5 @@ Object.defineProperty(exports, "__esModule", { value: true });

return {
stepsInStepGroup: __spreadArray(__spreadArray([], stepsInStepGroup), [
formatSyntaxTree(utils_1.pipe(utils_2.withZeroIndentation, utils_2.withDotInfo({ shouldStartWithDot: false, shouldEndWithDot: false }), utils_2.withHorizontalPosition(horizontalPosition))(config))(step),
]),
stepsInStepGroup: __spreadArray(__spreadArray([], stepsInStepGroup, true), [
formatSyntaxTree((0, utils_1.pipe)(utils_2.withZeroIndentation, (0, utils_2.withDotInfo)({ shouldStartWithDot: false, shouldEndWithDot: false }), (0, utils_2.withHorizontalPosition)(horizontalPosition))(config))(step),
], false),
stepGroups: stepGroups,

@@ -41,0 +45,0 @@ };

@@ -20,6 +20,10 @@ "use strict";

*/
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -37,4 +41,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

var isLastStepGroup = index === steps.length - 1;
var traversalSourceIndentationIncrease = stepGroups[0] && utils_3.isTraversalSource(stepGroups[0].steps[0]) ? 2 : 0;
var modulatorIndentationIncrease = utils_3.isModulator(step) ? 2 : 0;
var traversalSourceIndentationIncrease = stepGroups[0] && (0, utils_3.isTraversalSource)(stepGroups[0].steps[0]) ? 2 : 0;
var modulatorIndentationIncrease = (0, utils_3.isModulator)(step) ? 2 : 0;
var localIndentation = config.localIndentation + traversalSourceIndentationIncrease + modulatorIndentationIncrease;

@@ -51,11 +55,11 @@ // This is the only step in the step group, so it is the first step in

stepsInStepGroup: [],
stepGroups: __spreadArray(__spreadArray([], stepGroups), [
stepGroups: __spreadArray(__spreadArray([], stepGroups, true), [
{
steps: [
formatSyntaxTree(utils_1.pipe(utils_2.withIndentation(localIndentation), utils_2.withDotInfo({ shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot }), utils_2.withHorizontalPosition(localIndentation + +config.shouldPlaceDotsAfterLineBreaks))(config))(step),
formatSyntaxTree((0, utils_1.pipe)((0, utils_2.withIndentation)(localIndentation), (0, utils_2.withDotInfo)({ shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot }), (0, utils_2.withHorizontalPosition)(localIndentation + +config.shouldPlaceDotsAfterLineBreaks))(config))(step),
],
},
]),
], false),
};
}; };
exports.default = reduceSingleStepInStepGroup;

@@ -31,6 +31,10 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -65,17 +69,17 @@ Object.defineProperty(exports, "__esModule", { value: true });

return aggregator;
if (exports.isModulator(step)) {
return __assign(__assign({}, aggregator), { stepsInStepGroup: __spreadArray(__spreadArray([], stepsInStepGroup), [step]) });
if ((0, exports.isModulator)(step)) {
return __assign(__assign({}, aggregator), { stepsInStepGroup: __spreadArray(__spreadArray([], stepsInStepGroup, true), [step], false) });
}
return __assign(__assign({}, aggregator), { hasReachedFinalModulator: true });
}, {
stepsInStepGroup: __spreadArray(__spreadArray([], stepsInStepGroup), [step]),
stepsInStepGroup: __spreadArray(__spreadArray([], stepsInStepGroup, true), [step], false),
hasReachedFinalModulator: false,
}).stepsInStepGroup;
var stepGroupIndentationIncrease = (function () {
var traversalSourceIndentationIncrease = stepGroups[0] && exports.isTraversalSource(stepGroups[0].steps[0]) ? 2 : 0;
var modulatorIndentationIncrease = exports.isModulator(__spreadArray(__spreadArray([], stepsInStepGroup), [step])[0]) ? 2 : 0;
var traversalSourceIndentationIncrease = stepGroups[0] && (0, exports.isTraversalSource)(stepGroups[0].steps[0]) ? 2 : 0;
var modulatorIndentationIncrease = (0, exports.isModulator)(__spreadArray(__spreadArray([], stepsInStepGroup, true), [step], false)[0]) ? 2 : 0;
var indentationIncrease = traversalSourceIndentationIncrease + modulatorIndentationIncrease;
return indentationIncrease;
})();
var recreatedQueryWithSubsequentModulators = recreateQueryOnelinerFromSyntaxTree_1.default(config.localIndentation + stepGroupIndentationIncrease)({
var recreatedQueryWithSubsequentModulators = (0, recreateQueryOnelinerFromSyntaxTree_1.default)(config.localIndentation + stepGroupIndentationIncrease)({
type: types_1.TokenType.Traversal,

@@ -92,7 +96,7 @@ steps: stepsWithSubsequentModulators,

var isLastStep = index === steps.length - 1;
var nextStepIsModulator = !isLastStep && exports.isModulator(steps[index + 1]);
var nextStepIsModulator = !isLastStep && (0, exports.isModulator)(steps[index + 1]);
var lineIsTooLongWithSubsequentModulators = isLineTooLongWithSubsequentModulators(config)({ stepsInStepGroup: stepsInStepGroup, stepGroups: stepGroups }, step, index, steps);
// If the first step in a group is a modulator, then it must also be the last step in the group
var stepShouldBeLastStepInStepGroup = isLastStep ||
(isFirstStepInStepGroup && exports.isModulator(step)) ||
(isFirstStepInStepGroup && (0, exports.isModulator)(step)) ||
((step.type === types_1.TokenType.Method || step.type === types_1.TokenType.Closure) &&

@@ -99,0 +103,0 @@ !(nextStepIsModulator && !lineIsTooLongWithSubsequentModulators));

@@ -20,6 +20,10 @@ "use strict";

*/
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -36,4 +40,4 @@ Object.defineProperty(exports, "__esModule", { value: true });

var formatTraversal = function (formatSyntaxTree) { return function (config) { return function (syntaxTree) {
var initialHorizontalPositionIndentationIncrease = syntaxTree.steps[0] && utils_3.isTraversalSource(syntaxTree.steps[0]) ? syntaxTree.initialHorizontalPosition : 0;
var recreatedQuery = recreateQueryOnelinerFromSyntaxTree_1.default(config.localIndentation + initialHorizontalPositionIndentationIncrease)(syntaxTree);
var initialHorizontalPositionIndentationIncrease = syntaxTree.steps[0] && (0, utils_3.isTraversalSource)(syntaxTree.steps[0]) ? syntaxTree.initialHorizontalPosition : 0;
var recreatedQuery = (0, recreateQueryOnelinerFromSyntaxTree_1.default)(config.localIndentation + initialHorizontalPositionIndentationIncrease)(syntaxTree);
if (recreatedQuery.length <= config.maxLineLength) {

@@ -50,3 +54,3 @@ return {

// steps's width plus the width of the dots between them
formatSyntaxTree(utils_1.pipe(utils_2.withZeroIndentation, utils_2.withIncreasedHorizontalPosition(syntaxTree.initialHorizontalPosition +
formatSyntaxTree((0, utils_1.pipe)(utils_2.withZeroIndentation, (0, utils_2.withIncreasedHorizontalPosition)(syntaxTree.initialHorizontalPosition +
steps.map(function (_a) {

@@ -57,3 +61,3 @@ var width = _a.width;

steps.length))(config))(step);
return __spreadArray(__spreadArray([], steps), [formattedStep]);
return __spreadArray(__spreadArray([], steps, true), [formattedStep], false);
}, []),

@@ -67,4 +71,4 @@ },

}
var stepGroups = getStepGroups_1.getStepGroups(formatSyntaxTree, syntaxTree.steps, config);
var lastStepGroup = utils_1.last(stepGroups);
var stepGroups = (0, getStepGroups_1.getStepGroups)(formatSyntaxTree, syntaxTree.steps, config);
var lastStepGroup = (0, utils_1.last)(stepGroups);
var width = lastStepGroup

@@ -71,0 +75,0 @@ ? lastStepGroup.steps.map(function (_a) {

@@ -32,13 +32,13 @@ "use strict";

case types_1.TokenType.NonGremlinCode:
return formatNonGremlin_1.formatNonGremlin(config)(syntaxTree);
return (0, formatNonGremlin_1.formatNonGremlin)(config)(syntaxTree);
case types_1.TokenType.Traversal:
return formatTraversal_1.formatTraversal(formatSyntaxTree)(config)(syntaxTree);
return (0, formatTraversal_1.formatTraversal)(formatSyntaxTree)(config)(syntaxTree);
case types_1.TokenType.Method:
return formatMethod_1.formatMethod(formatSyntaxTree)(config)(syntaxTree);
return (0, formatMethod_1.formatMethod)(formatSyntaxTree)(config)(syntaxTree);
case types_1.TokenType.Closure:
return formatClosure_1.formatClosure(formatSyntaxTree)(config)(syntaxTree);
return (0, formatClosure_1.formatClosure)(formatSyntaxTree)(config)(syntaxTree);
case types_1.TokenType.String:
return formatString_1.formatString(config)(syntaxTree);
return (0, formatString_1.formatString)(config)(syntaxTree);
case types_1.TokenType.Word:
return formatWord_1.formatWord(config)(syntaxTree);
return (0, formatWord_1.formatWord)(config)(syntaxTree);
}

@@ -45,0 +45,0 @@ }; };

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

exports.withIndentation = withIndentation;
exports.withZeroIndentation = exports.withIndentation(0);
exports.withZeroIndentation = (0, exports.withIndentation)(0);
var withIncreasedIndentation = function (indentationIncrease) { return function (config) { return (__assign(__assign({}, config), { localIndentation: config.localIndentation + indentationIncrease })); }; };

@@ -41,4 +41,3 @@ exports.withIncreasedIndentation = withIncreasedIndentation;

var shouldStartWithDot = _a.shouldStartWithDot, shouldEndWithDot = _a.shouldEndWithDot;
return function (config) { return (__assign(__assign({}, config), { shouldStartWithDot: shouldStartWithDot,
shouldEndWithDot: shouldEndWithDot })); };
return function (config) { return (__assign(__assign({}, config), { shouldStartWithDot: shouldStartWithDot, shouldEndWithDot: shouldEndWithDot })); };
};

@@ -45,0 +44,0 @@ exports.withDotInfo = withDotInfo;

import { GremlintUserConfig } from './types';
export declare const formatQuery: (query: string, config?: Partial<GremlintUserConfig> | undefined) => string;
export declare const formatQuery: (query: string, config?: Partial<GremlintUserConfig>) => string;

@@ -52,4 +52,4 @@ "use strict";

var internalConfig = getInternalGremlintConfig(withDefaults(config !== null && config !== void 0 ? config : {}));
return utils_1.pipe(parseToSyntaxTrees_1.parseToSyntaxTrees, formatSyntaxTrees_1.formatSyntaxTrees(internalConfig), recreateQueryStringFromFormattedSyntaxTrees_1.recreateQueryStringFromFormattedSyntaxTrees(internalConfig))(query);
return (0, utils_1.pipe)(parseToSyntaxTrees_1.parseToSyntaxTrees, (0, formatSyntaxTrees_1.formatSyntaxTrees)(internalConfig), (0, recreateQueryStringFromFormattedSyntaxTrees_1.recreateQueryStringFromFormattedSyntaxTrees)(internalConfig))(query);
};
exports.formatQuery = formatQuery;

@@ -125,8 +125,8 @@ "use strict";

var DOT = "\\.";
var METHOD_STEP = "\\w+" + HORIZONTAL_SPACE + "*\\([^\\)]*\\)";
var CLOSURE_STEP = "\\w+" + HORIZONTAL_SPACE + "*\\{[^\\}]*\\}";
var METHOD_STEP = "\\w+".concat(HORIZONTAL_SPACE, "*\\([^\\)]*\\)");
var CLOSURE_STEP = "\\w+".concat(HORIZONTAL_SPACE, "*\\{[^\\}]*\\}");
var WORD_STEP = "\\w+";
var GREMLIN_STEP = "(" + METHOD_STEP + "|" + CLOSURE_STEP + "|" + WORD_STEP + ")";
var STEP_CONNECTOR = "(" + SPACE + "*" + DOT + SPACE + "*)";
var GREMLIN_QUERY = "g(" + STEP_CONNECTOR + GREMLIN_STEP + ")+";
var GREMLIN_STEP = "(".concat(METHOD_STEP, "|").concat(CLOSURE_STEP, "|").concat(WORD_STEP, ")");
var STEP_CONNECTOR = "(".concat(SPACE, "*").concat(DOT).concat(SPACE, "*)");
var GREMLIN_QUERY = "g(".concat(STEP_CONNECTOR).concat(GREMLIN_STEP, ")+");
var gremlinQueryRegExp = new RegExp(GREMLIN_QUERY, 'g');

@@ -133,0 +133,0 @@ var extractGremlinQueries = function (code) {

@@ -20,6 +20,10 @@ "use strict";

*/
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -275,6 +279,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

var isMethodInvocation = function (token) {
return utils_1.pipe(tokenizeOnTopLevelParentheses, utils_1.last, isWrappedInParentheses)(token);
return (0, utils_1.pipe)(tokenizeOnTopLevelParentheses, utils_1.last, isWrappedInParentheses)(token);
};
var isClosureInvocation = function (token) {
return utils_1.pipe(tokenizeOnTopLevelCurlyBrackets, utils_1.last, isWrappedInCurlyBrackets)(token);
return (0, utils_1.pipe)(tokenizeOnTopLevelCurlyBrackets, utils_1.last, isWrappedInCurlyBrackets)(token);
};

@@ -291,6 +295,6 @@ var trimParentheses = function (expression) { return expression.slice(1, -1); };

methodToken: tokens.slice(0, -1).join(''),
argumentTokens: utils_1.pipe(trimParentheses, tokenizeOnTopLevelComma)(tokens.slice(-1)[0]),
argumentTokens: (0, utils_1.pipe)(trimParentheses, tokenizeOnTopLevelComma)(tokens.slice(-1)[0]),
};
};
var getIndentation = function (lineOfCode) { return lineOfCode.split('').findIndex(utils_1.neq(' ')); };
var getIndentation = function (lineOfCode) { return lineOfCode.split('').findIndex((0, utils_1.neq)(' ')); };
var getMethodTokenAndClosureCodeBlockFromClosureInvocation = function (token, fullQuery) {

@@ -363,3 +367,3 @@ // The word before the first curly bracket is the method name

var parseToSyntaxTrees = function (code) {
var queries = extractGremlinQueries_1.extractGremlinQueries(code);
var queries = (0, extractGremlinQueries_1.extractGremlinQueries)(code);
var _a = queries.reduce(function (state, query) {

@@ -369,6 +373,6 @@ var indexOfQuery = state.remainingCode.indexOf(query);

return {
syntaxTrees: __spreadArray(__spreadArray([], state.syntaxTrees), [
exports.parseNonGremlinCodeToSyntaxTree(nonGremlinCode),
syntaxTrees: __spreadArray(__spreadArray([], state.syntaxTrees, true), [
(0, exports.parseNonGremlinCodeToSyntaxTree)(nonGremlinCode),
parseCodeBlockToSyntaxTree(code, true)(query),
]),
], false),
remainingCode: state.remainingCode.substr(indexOfQuery + query.length),

@@ -379,4 +383,4 @@ };

return syntaxTrees;
return __spreadArray(__spreadArray([], syntaxTrees), [exports.parseNonGremlinCodeToSyntaxTree(remainingCode)]);
return __spreadArray(__spreadArray([], syntaxTrees, true), [(0, exports.parseNonGremlinCodeToSyntaxTree)(remainingCode)], false);
};
exports.parseToSyntaxTrees = parseToSyntaxTrees;

@@ -31,5 +31,5 @@ "use strict";

case types_1.TokenType.Traversal:
return utils_1.spaces(localIndentation) + syntaxTree.steps.map(recreateQueryOnelinerFromSyntaxTree()).join('.');
return (0, utils_1.spaces)(localIndentation) + syntaxTree.steps.map(recreateQueryOnelinerFromSyntaxTree()).join('.');
case types_1.TokenType.Method:
return (utils_1.spaces(localIndentation) +
return ((0, utils_1.spaces)(localIndentation) +
recreateQueryOnelinerFromSyntaxTree()(syntaxTree.method) +

@@ -40,14 +40,14 @@ '(' +

case types_1.TokenType.Closure:
return (utils_1.spaces(localIndentation) +
return ((0, utils_1.spaces)(localIndentation) +
recreateQueryOnelinerFromSyntaxTree()(syntaxTree.method) +
'{' +
utils_1.last(syntaxTree.closureCodeBlock.map(function (_a) {
(0, utils_1.last)(syntaxTree.closureCodeBlock.map(function (_a) {
var lineOfCode = _a.lineOfCode, relativeIndentation = _a.relativeIndentation;
return "" + utils_1.spaces(Math.max(relativeIndentation, 0)) + lineOfCode;
return "".concat((0, utils_1.spaces)(Math.max(relativeIndentation, 0))).concat(lineOfCode);
})) +
'}');
case types_1.TokenType.String:
return utils_1.spaces(localIndentation) + syntaxTree.string;
return (0, utils_1.spaces)(localIndentation) + syntaxTree.string;
case types_1.TokenType.Word:
return utils_1.spaces(localIndentation) + syntaxTree.word;
return (0, utils_1.spaces)(localIndentation) + syntaxTree.word;
}

@@ -54,0 +54,0 @@ };

@@ -51,3 +51,3 @@ "use strict";

var lineOfCode = _a.lineOfCode, localIndentation = _a.localIndentation;
return "" + utils_1.spaces(localIndentation) + lineOfCode;
return "".concat((0, utils_1.spaces)(localIndentation)).concat(lineOfCode);
})

@@ -59,6 +59,6 @@ .join('\n') +

if (syntaxTree.type === types_1.TokenType.String) {
return utils_1.spaces(syntaxTree.localIndentation) + syntaxTree.string;
return (0, utils_1.spaces)(syntaxTree.localIndentation) + syntaxTree.string;
}
if (syntaxTree.type === types_1.TokenType.Word) {
return (utils_1.spaces(syntaxTree.localIndentation) +
return ((0, utils_1.spaces)(syntaxTree.localIndentation) +
(syntaxTree.shouldStartWithDot ? '.' : '') +

@@ -75,6 +75,6 @@ syntaxTree.word +

return lineOfCode;
return utils_1.spaces(indentation) + lineOfCode;
return (0, utils_1.spaces)(indentation) + lineOfCode;
}; };
var lineIsEmpty = function (lineOfCode) {
return lineOfCode.split('').every(utils_1.eq(' '));
return lineOfCode.split('').every((0, utils_1.eq)(' '));
};

@@ -81,0 +81,0 @@ var removeIndentationFromEmptyLines = function (lineOfCode) {

{
"name": "gremlint",
"version": "3.6.0",
"version": "3.6.1",
"description": "Linter/code formatter for Gremlin",

@@ -38,9 +38,9 @@ "main": "lib/index.js",

"devDependencies": {
"@types/jest": "^26.0.15",
"@types/jest": "^27.5.0",
"jest": "^26.6.1",
"prettier": "^2.1.2",
"prettier": "^2.7.1",
"ts-jest": "^26.4.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.0.3"
"typescript": "^4.7.4"
},

@@ -47,0 +47,0 @@ "files": [

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