You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

eslint-plugin-pug

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-pug - npm Package Compare versions

Comparing version

to
1.2.2

{
"name": "eslint-plugin-pug",
"description": "An ESLint plugin for linting inline scripts in Pug files",
"version": "1.2.1",
"version": "1.2.2",
"author": "Greg V <greg@unrelenting.technology>",

@@ -24,2 +24,3 @@ "license": "Unlicense",

"scripts": {
"repl": "node --experimental-repl-await repl.js",
"test": "jest"

@@ -33,3 +34,3 @@ },

"vfile": "^4.0.2",
"vfile-location": "^2.0.6"
"vfile-location": "^3.0.0"
},

@@ -39,3 +40,3 @@ "devDependencies": {

"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",

@@ -42,0 +43,0 @@ "eslint-plugin-promise": "^4.2.1",

@@ -51,2 +51,21 @@ const _ = require('lodash')

exports.nodesToOrigsAndText = (ctx, nodes) => {
const origs = []
const lines = []
let lastLine = null
_.each(nodes, (node, i) => {
if (node.val === '\n') return
if (node.line === lastLine) return
lastLine = node.line
origs.push([node.line, node.column - 1])
const indexStart = exports.positionToOffset(ctx.vfileLoc, node)
const indexEnd = exports.positionToOffset(ctx.vfileLoc, { line: node.line + 1, column: 1 })
lines.push(ctx.src.substring(indexStart, indexEnd === -1 ? undefined : indexEnd - 1))
})
return {
origs,
text: lines.join('\n')
}
}
exports.preprocess = (src, filename) => {

@@ -57,10 +76,9 @@ const ast = exports.parsePug(src)

if (!exports.isJsNode(node)) return
const lines = _.filter(node.block.nodes, n => n.val !== '\n')
const text = _.map(lines, 'val').join('\n')
const { origs, text } = exports.nodesToOrigsAndText(ctx, node.block.nodes)
ctx.blocks.push({
column: node.column,
filename: '0.js',
fixMultiline: node.line !== _.get(node, 'block.nodes.0.line'),
fixMultiline: node.line !== _.first(origs)[0],
line: node.line,
origs: _.map(lines, n => [n.line, n.column - 1]),
origs,
text,

@@ -67,0 +85,0 @@ vfileLoc: vfileLocation(vfile(text)),