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

eslint-plugin-userscripts

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-userscripts - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

41

lib/rules/metadata-spacing.js
const parse = require('../utils/parse');
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {

@@ -10,3 +11,4 @@ meta: {

category: 'Best Practices'
}
},
fixable: 'whitespace'
},

@@ -17,14 +19,31 @@ create: (context) => {

if (
result.enteredMetadata !== -1 &&
result.end &&
sourceCode.lines.length !==
result.lines[result.lines.length - 1].lineLoc.end.line &&
sourceCode.lines[
result.lines[result.lines.length - 1].lineLoc.end.line
].trim().length > 0
) {
const hasMetadata = result.enteredMetadata !== -1 && result.end;
if (!hasMetadata) {
return {};
}
const metadataLastLineLoc = result.lines[result.lines.length - 1].lineLoc;
const hasCodeOtherThanMetadata =
sourceCode.lines.length !== metadataLastLineLoc.end.line;
if (!hasCodeOtherThanMetadata) {
return {};
}
const lineNextToMetadata = sourceCode.lines[metadataLastLineLoc.end.line];
if (lineNextToMetadata.trim().length > 0) {
context.report({
message: 'There should be a newline between the metadata and the code',
loc: result.lines[result.lines.length - 1].lineLoc
loc: metadataLastLineLoc,
fix: function (fixer) {
const range = [
sourceCode.getIndexFromLoc(metadataLastLineLoc.start),
sourceCode.getIndexFromLoc(metadataLastLineLoc.end)
];
return fixer.insertTextAfterRange(range, '\n');
}
});

@@ -31,0 +50,0 @@ }

{
"name": "eslint-plugin-userscripts",
"version": "0.2.4",
"version": "0.2.5",
"description": "Implements rules for userscripts metadata in eslint",

@@ -30,3 +30,3 @@ "keywords": [

"eslint-plugin-unicorn": "^42.0.0",
"husky": "^7.0.2",
"husky": "^8.0.1",
"markdownlint-cli": "^0.31.0",

@@ -33,0 +33,0 @@ "mocha": "^10.0.0",

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