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

yaml-eslint-parser

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaml-eslint-parser - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

95

lib/convert.js

@@ -17,5 +17,10 @@ "use strict";

});
const stripCommentCode = comments.reduce((text, comment) => text.slice(0, comment.range[0]) +
text.slice(...comment.range).replace(/\S/gu, " ") +
text.slice(comment.range[1]), code);
let stripCommentCode = "";
let startIndex = 0;
for (const comment of comments) {
stripCommentCode += code.slice(startIndex, comment.range[0]);
stripCommentCode += code.slice(...comment.range).replace(/\S/gu, " ");
startIndex = comment.range[1];
}
stripCommentCode += code.slice(startIndex);
const tokens = [];

@@ -26,9 +31,9 @@ const ast = Object.assign({ type: "Program", body: [], comments, sourceType: "module", tokens, parent: null }, getConvertLocation(node));

}
const stripTokensCode = tokens.reduce((text, token) => text.slice(0, token.range[0]) +
text.slice(...token.range).replace(/\S/gu, " ") +
text.slice(token.range[1]), stripCommentCode);
const useRanges = sort(tokens).map((t) => t.range);
let range = useRanges.shift();
let line = 1;
let column = 0;
for (let index = 0; index < stripTokensCode.length; index++) {
const c = stripTokensCode[index];
const len = stripCommentCode.length;
for (let index = 0; index < len; index++) {
const c = stripCommentCode[index];
if (c === "\n") {

@@ -39,36 +44,29 @@ line++;

}
else if (c.trim()) {
if (isPunctuator(c)) {
addToken(tokens, "Punctuator", {
range: [index, index + 1],
loc: {
start: {
line,
column,
},
end: {
line,
column: column + 1,
},
},
}, stripTokensCode);
if (range) {
while (range && range[1] <= index) {
range = useRanges.shift();
}
if (range && range[0] <= index) {
column++;
continue;
}
}
if (isPunctuator(c)) {
addToken(tokens, "Punctuator", {
range: [index, index + 1],
loc: {
start: {
line,
column,
},
end: {
line,
column: column + 1,
},
},
}, stripCommentCode);
}
column++;
}
tokens.sort((a, b) => {
if (a.range[0] > b.range[0]) {
return 1;
}
if (a.range[0] < b.range[0]) {
return -1;
}
if (a.range[1] > b.range[1]) {
return 1;
}
if (a.range[1] < b.range[1]) {
return -1;
}
return 0;
});
sort(tokens);
return ast;

@@ -86,3 +84,2 @@ /**

c === "]" ||
//
c === "?");

@@ -729,1 +726,21 @@ }

}
/**
* Sort tokens
*/
function sort(tokens) {
return tokens.sort((a, b) => {
if (a.range[0] > b.range[0]) {
return 1;
}
if (a.range[0] < b.range[0]) {
return -1;
}
if (a.range[1] > b.range[1]) {
return 1;
}
if (a.range[1] < b.range[1]) {
return -1;
}
return 0;
});
}
{
"name": "yaml-eslint-parser",
"version": "0.2.1",
"version": "0.2.2",
"description": "A YAML parser that produces output compatible with ESLint",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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