You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

tslint-lines-between-class-members

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tslint-lines-between-class-members - npm Package Compare versions

Comparing version

to
1.3.1

test/fixtures/passes/export.ts

10

linesBetweenClassMembersRule.js

@@ -47,3 +47,4 @@ "use strict";

var isPrevLineOpeningBrace = this.isPrevLineOpeningBrace(node, this.getSourceFile());
if (!arePrevLinesBlank && !isPrevLineClassDec && !isPrevLineOpeningBrace) {
var isClassMethod = this.isClassMethod(node);
if (!arePrevLinesBlank && !isPrevLineClassDec && !isPrevLineOpeningBrace && isClassMethod) {
this.onRuleLintFail(node);

@@ -115,2 +116,9 @@ }

/**
* Tests whether method is within a class (as opposed to within an object literal)
*/
LinesBetweenClassMembersWalker.prototype.isClassMethod = function (node) {
var parentType = node.parent && node.parent.kind;
return parentType === ts.SyntaxKind.ClassDeclaration;
};
/**
* Gets the text content of a line above the method

@@ -117,0 +125,0 @@ * Any documenting comments are ignored and we start from the first line above those

2

package.json
{
"name": "tslint-lines-between-class-members",
"version": "1.3.0",
"version": "1.3.1",
"description": "Custom rule for TSLint to enforce blank lines between class methods - achieves a similar thing to lines-between-class-members in ESLint",

@@ -5,0 +5,0 @@ "scripts": {

@@ -214,1 +214,21 @@ import test, {AssertContext} from 'ava';

});
test('ignores default exported object', (t: AssertContext) => {
const results = TestHelpers.lint('passes/exportDefault.ts');
t.is(results.errorCount, 0);
});
test('ignores default exported object with multiple methods', (t: AssertContext) => {
const results = TestHelpers.lint('passes/exportDefaultMultipleMethods.ts');
t.is(results.errorCount, 0);
});
test('ignores exported object', (t: AssertContext) => {
const results = TestHelpers.lint('passes/export.ts');
t.is(results.errorCount, 0);
});
test('ignores exported object with multiple methods', (t: AssertContext) => {
const results = TestHelpers.lint('passes/exportMultipleMethods.ts');
t.is(results.errorCount, 0);
});

@@ -38,3 +38,4 @@ import * as Lint from 'tslint';

const isPrevLineOpeningBrace = this.isPrevLineOpeningBrace(node, this.getSourceFile());
if (!arePrevLinesBlank && !isPrevLineClassDec && !isPrevLineOpeningBrace) {
const isClassMethod = this.isClassMethod(node);
if (!arePrevLinesBlank && !isPrevLineClassDec && !isPrevLineOpeningBrace && isClassMethod) {
this.onRuleLintFail(node);

@@ -113,2 +114,10 @@ }

/**
* Tests whether method is within a class (as opposed to within an object literal)
*/
private isClassMethod(node: ts.FunctionLikeDeclaration): boolean {
const parentType = node.parent && node.parent.kind;
return parentType === ts.SyntaxKind.ClassDeclaration;
}
/**
* Gets the text content of a line above the method

@@ -115,0 +124,0 @@ * Any documenting comments are ignored and we start from the first line above those

Sorry, the diff of this file is not supported yet