eslint-plugin-jasmine
Advanced tools
Comparing version 2.8.3 to 2.8.4
@@ -8,3 +8,3 @@ # Enforce new line before expect inside a suite | ||
This rule triggers a **warning** (is set to **1** by default) whenever there is no new line before expect. | ||
This rule triggers a **warning** (is set to **1** by default) whenever there is no new line or another except before expect. | ||
@@ -52,1 +52,12 @@ The following pattern is considered a warning: | ||
``` | ||
```js | ||
describe("", function() { | ||
it("", function() { | ||
var a = 1; | ||
expect(a).toBe(1); | ||
expect(a).not.toBe(0); | ||
}); | ||
}); | ||
``` |
@@ -14,7 +14,14 @@ 'use strict' | ||
var suiteDepth = 0 | ||
var lastExpectNode | ||
return { | ||
CallExpression: function (node) { | ||
if (blockRegexp.test(node.callee.name)) { | ||
lastExpectNode = null | ||
suiteDepth++ | ||
} else if (node.callee.name === 'expect' && suiteDepth > 0) { | ||
if (lastExpectNode && linesDelta(node, lastExpectNode) === 1) { | ||
lastExpectNode = node | ||
return | ||
} | ||
lastExpectNode = node | ||
const prevToken = context.getSourceCode().getTokenBefore(node) | ||
@@ -44,1 +51,5 @@ if (prevToken) { | ||
} | ||
function linesDelta (node1, node2) { | ||
return Math.abs(node1.loc.start.line - node2.loc.start.line) | ||
} |
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "2.8.3" | ||
"version": "2.8.4" | ||
} |
@@ -44,2 +44,10 @@ 'use strict' | ||
linesToCode([ | ||
'it("", helper(function() {', | ||
' var a = 1', | ||
'', | ||
' expect(a).toBe(1);', | ||
' expect(a).not.toBe(0);', | ||
'}));' | ||
]), | ||
linesToCode([ | ||
'notJasmineTestSuite()', | ||
@@ -46,0 +54,0 @@ 'expect(a)' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173280
2253