eslint-plugin-jasmine
Advanced tools
Comparing version 2.6.2 to 2.7.0
@@ -19,3 +19,4 @@ 'use strict' | ||
'new-line-between-declarations': require('./lib/rules/new-line-between-declarations'), | ||
'new-line-before-expect': require('./lib/rules/new-line-before-expect') | ||
'new-line-before-expect': require('./lib/rules/new-line-before-expect'), | ||
'prefer-jasmine-matcher': require('./lib/rules/prefer-jasmine-matcher') | ||
}, | ||
@@ -39,3 +40,4 @@ configs: { | ||
'jasmine/new-line-between-declarations': 1, | ||
'jasmine/new-line-before-expect': 1 | ||
'jasmine/new-line-before-expect': 1, | ||
'jasmine/prefer-jasmine-matcher': 1 | ||
} | ||
@@ -42,0 +44,0 @@ } |
@@ -25,3 +25,9 @@ 'use strict' | ||
if (!hasPaddingBetweenTokens(prevToken, node)) { | ||
context.report(node, 'No new line before expect') | ||
context.report({ | ||
node, | ||
message: 'No new line before expect', | ||
fix (fixer) { | ||
return fixer.insertTextBefore(node, '\n') | ||
} | ||
}) | ||
} | ||
@@ -28,0 +34,0 @@ } |
@@ -15,21 +15,21 @@ 'use strict' | ||
CallExpression: function (node) { | ||
var pass = true | ||
var declWithoutPadding = null | ||
if (suiteRegexp.test(node.callee.name)) { | ||
var declarations = getDescribeDeclarationsContent(node) | ||
pass = declarations.every((token, i) => { | ||
declarations.forEach((decl, i) => { | ||
var next = declarations[i + 1] | ||
if (next) { | ||
return hasPaddingBetweenTokens(token, next) | ||
} else { | ||
return true | ||
if (next && !hasPaddingBetweenTokens(decl, next)) { | ||
declWithoutPadding = decl | ||
} | ||
}) | ||
} | ||
if (!pass) { | ||
if (declWithoutPadding) { | ||
context.report({ | ||
node, | ||
message: 'No new line between declarations' | ||
message: 'No new line between declarations', | ||
fix (fixer) { | ||
return fixer.insertTextAfter(declWithoutPadding, '\n') | ||
} | ||
}) | ||
}; | ||
} | ||
} | ||
@@ -36,0 +36,0 @@ } |
@@ -54,3 +54,3 @@ { | ||
}, | ||
"version": "2.6.2" | ||
"version": "2.7.0" | ||
} |
@@ -84,2 +84,3 @@ # eslint-plugin-jasmine | ||
[valid-expect][] | 1 | | ||
[prefer-jasmine-matcher][] | 1 | | ||
@@ -123,2 +124,3 @@ | ||
[valid-expect]: docs/rules/valid-expect.md | ||
[prefer-jasmine-matcher]: docs/rules/prefer-jasmine-matcher.md | ||
@@ -125,0 +127,0 @@ [configuring rules]: http://eslint.org/docs/user-guide/configuring#configuring-rules |
@@ -74,3 +74,11 @@ 'use strict' | ||
} | ||
] | ||
], | ||
output: linesToCode([ | ||
'describe("", function() {', | ||
' it("", function(){', | ||
' var a = 1', | ||
' \nexpect(1).toBe(1)', | ||
' });', | ||
'});' | ||
]) | ||
}, | ||
@@ -88,5 +96,11 @@ { | ||
} | ||
] | ||
], | ||
output: linesToCode([ | ||
'it("", helper(function() {', | ||
' var a = 1', | ||
' \nexpect(a).toEqual(1);', | ||
'}));' | ||
]) | ||
} | ||
] | ||
}) |
@@ -56,3 +56,12 @@ 'use strict' | ||
} | ||
] | ||
], | ||
output: linesToCode([ | ||
'describe("", function() {', | ||
' describe("", function() {', | ||
' it("", function(){});', | ||
' });', | ||
' it("", function(){});\n', | ||
' it("", function(){});', | ||
'});' | ||
]) | ||
}, | ||
@@ -70,3 +79,9 @@ { | ||
} | ||
] | ||
], | ||
output: linesToCode([ | ||
'describe("", function() {', | ||
' beforeEach(function(){});\n', | ||
' it("", function(){});', | ||
'});' | ||
]) | ||
}, | ||
@@ -84,5 +99,11 @@ { | ||
} | ||
] | ||
], | ||
output: linesToCode([ | ||
'describe("", function() {', | ||
' describe("", function() {})\n', | ||
' describe("", function() {})', | ||
'})' | ||
]) | ||
} | ||
] | ||
}) |
165902
59
2020
136