Socket
Socket
Sign inDemoInstall

eslint-plugin-jasmine

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jasmine - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

lib/rules/prefer-promise-strategies.js

2

index.js

@@ -25,2 +25,3 @@ 'use strict'

'prefer-jasmine-matcher': require('./lib/rules/prefer-jasmine-matcher'),
'prefer-promise-strategies': require('./lib/rules/prefer-promise-strategies'),
'prefer-toHaveBeenCalledWith': require('./lib/rules/prefer-toHaveBeenCalledWith'),

@@ -51,2 +52,3 @@ 'prefer-toBeUndefined': require('./lib/rules/prefer-toBeUndefined')

'jasmine/prefer-jasmine-matcher': 1,
'jasmine/prefer-promise-strategies': 1,
'jasmine/prefer-toHaveBeenCalledWith': 1,

@@ -53,0 +55,0 @@ 'jasmine/prefer-toBeUndefined': 0

77

lib/rules/new-line-before-expect.js

@@ -14,41 +14,50 @@ 'use strict'

module.exports = function (context) {
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
var sourceCode = context.getSourceCode()
const prevToken = sourceCode.getTokenBefore(node)
if (prevToken) {
if (prevToken.type === 'Punctuator' && prevToken.value === '{') {
module.exports = {
meta: {
fixable: 'whitespace'
},
create: function (context) {
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
}
if (!hasPaddingBetweenTokens(prevToken, node) && isFirstExpectOnLine(node, sourceCode)) {
context.report({
fix (fixer) {
return fixer.replaceTextRange(
[prevToken.range[1], node.range[1]],
['\n\n', withIndentation(node, sourceCode)].join('')
)
},
message: 'No new line before expect',
node
})
lastExpectNode = node
var sourceCode = context.getSourceCode()
let prevToken = sourceCode.getTokenBefore(node)
if (prevToken.value === 'await' || prevToken.value === 'return') {
node = prevToken
prevToken = sourceCode.getTokenBefore(prevToken)
}
if (prevToken) {
if (prevToken.type === 'Punctuator' && prevToken.value === '{') {
return
}
if (!hasPaddingBetweenTokens(prevToken, node) && isFirstExpectOnLine(node, sourceCode)) {
context.report({
fix (fixer) {
return fixer.replaceTextRange(
[prevToken.range[1], node.range[1]],
['\n\n', withIndentation(node, sourceCode)].join('')
)
},
message: 'No new line before expect',
node
})
}
}
}
},
'CallExpression:exit': function (node) {
if (blockRegexp.test(node.callee.name)) {
suiteDepth--
}
}
},
'CallExpression:exit': function (node) {
if (blockRegexp.test(node.callee.name)) {
suiteDepth--
}
}

@@ -55,0 +64,0 @@ }

@@ -12,24 +12,29 @@ 'use strict'

module.exports = function (context) {
return {
CallExpression: function (node) {
var declWithoutPadding = null
if (suiteRegexp.test(node.callee.name)) {
var declarations = getDescribeDeclarationsContent(node)
declarations.forEach((decl, i) => {
var next = declarations[i + 1]
if (next && !hasPaddingBetweenTokens(decl, next)) {
declWithoutPadding = decl
}
})
module.exports = {
meta: {
fixable: 'whitespace'
},
create: function (context) {
return {
CallExpression: function (node) {
var declWithoutPadding = null
if (suiteRegexp.test(node.callee.name)) {
var declarations = getDescribeDeclarationsContent(node)
declarations.forEach((decl, i) => {
var next = declarations[i + 1]
if (next && !hasPaddingBetweenTokens(decl, next)) {
declWithoutPadding = decl
}
})
}
if (declWithoutPadding) {
context.report({
fix (fixer) {
return fixer.insertTextAfter(declWithoutPadding, '\n')
},
message: 'No new line between declarations',
node
})
}
}
if (declWithoutPadding) {
context.report({
fix (fixer) {
return fixer.insertTextAfter(declWithoutPadding, '\n')
},
message: 'No new line between declarations',
node
})
}
}

@@ -36,0 +41,0 @@ }

@@ -68,23 +68,29 @@ 'use strict'

*/
module.exports = function (context) {
var isInsideSpec = false
var asyncParam
return {
CallExpression: function (node) {
if (isSpec(node)) {
isInsideSpec = true
asyncParam = getDoneParamName(node)
}
module.exports = {
meta: {
fixable: 'code'
},
if (isInsideSpec && asyncParam && isPromiseThenWithoutCatch(node, asyncParam)) {
context.report(genReport(node, context))
create: function (context) {
var isInsideSpec = false
var asyncParam
return {
CallExpression: function (node) {
if (isSpec(node)) {
isInsideSpec = true
asyncParam = getDoneParamName(node)
}
if (isInsideSpec && asyncParam && isPromiseThenWithoutCatch(node, asyncParam)) {
context.report(genReport(node, context))
}
},
'CallExpression:exit': function (node) {
if (isSpec(node)) {
isInsideSpec = false
asyncParam = undefined
}
}
},
'CallExpression:exit': function (node) {
if (isSpec(node)) {
isInsideSpec = false
asyncParam = undefined
}
}
}
}
{
"name": "eslint-plugin-jasmine",
"version": "4.1.2",
"version": "4.1.3",
"description": "ESLint rules for Jasmine",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -89,2 +89,3 @@ # eslint-plugin-jasmine

[prefer-jasmine-matcher][] | 1 |
[prefer-promise-strategies][] | 1 |
[prefer-toHaveBeenCalledWith][] | 1 |

@@ -135,2 +136,3 @@ [prefer-toBeUndefined][] | 0 | `['always', 'never']`

[prefer-jasmine-matcher]: docs/rules/prefer-jasmine-matcher.md
[prefer-promise-strategies]: docs/rules/prefer-promise-strategies.md
[prefer-toHaveBeenCalledWith]: docs/rules/prefer-toHaveBeenCalledWith.md

@@ -137,0 +139,0 @@ [prefer-toBeUndefined]: docs/rules/prefer-toBeUndefined.md

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