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

hapi-scope-start

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-scope-start - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

14

lib/index.js

@@ -23,3 +23,4 @@ 'use strict';

var body = (fnBody.type === 'BlockStatement') ? fnBody.body : [fnBody];
var isBlockBody = fnBody.type === 'BlockStatement';
var body = isBlockBody ? fnBody.body : [fnBody];

@@ -31,13 +32,14 @@ // Allow empty function bodies to be of any size

var bodyStartLine = body[0].loc.start.line;
var openBraceLine = context.getTokenBefore(body[0]).loc.start.line;
var closeBraceLine = context.getTokenAfter(body[0]).loc.start.line;
var stmt = body[0];
var bodyStartLine = stmt.loc.start.line;
var openTokenLine = context.getTokenBefore(stmt).loc.start.line;
var closeTokenLine = isBlockBody ? context.getTokenAfter(stmt).loc.start.line : context.getLastToken(stmt).loc.start.line;
if (allowOneLiners === true &&
body.length <= maxInOneLiner &&
openBraceLine === closeBraceLine) {
openTokenLine === closeTokenLine) {
return;
}
if (bodyStartLine - openBraceLine < 2) {
if (bodyStartLine - openTokenLine < 2) {
context.report(node, 'Missing blank line at beginning of function.');

@@ -44,0 +46,0 @@ }

{
"name": "hapi-scope-start",
"version": "2.1.0",
"version": "2.1.1",
"description": "ESLint rule to enforce new line at the beginning of function scope",

@@ -5,0 +5,0 @@ "author": "Continuation Labs <contact@continuation.io> (http://continuation.io/)",

@@ -15,3 +15,4 @@ # hapi-scope-start

then functions whose bodies contain zero or one statements are allowed to be
written on a single line.
written on a single line. This defaults to `true` for arrow functions, and
`false` otherwise.

@@ -18,0 +19,0 @@ ### `max-in-one-liner`

@@ -183,7 +183,12 @@ 'use strict';

'var foo = () => {\n\nreturn;};',
'var foo = () => {\n\nreturn;}',
'var foo = () => 42;',
'var foo = () => 42\n',
'var foo = () => ({});',
'var foo = () => ({})',
'var foo = () => ({\nbar: 1});',
'var foo = () => [];',
'var foo = () => [\n1,\n2];'
'var foo = () => [\n1,\n2];',
'var foo = (isTrue) ? () => bar()\n: false;',
'var foo = (isTrue) ? true:\n () => 1;'
].map(function (fn) {

@@ -198,3 +203,5 @@ return {

'var foo = () => {var foo = 1; return foo;};',
'var foo = () => {var foo = 1;\nreturn foo;};'
'var foo = () => {var foo = 1;\nreturn foo;};',
'var foo = () => \n12;',
'var foo = () => "1" + \n"2";'
].map(function (fn) {

@@ -201,0 +208,0 @@ return {

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