Commit 5337caa 1 parent a7b91f7 commit 5337caa Copy full SHA for 5337caa
File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const ruleTester = new TSESLint.RuleTester({
12
12
ruleTester . run ( 'title-must-be-string' , rule , {
13
13
valid : [
14
14
'it("is a string", () => {});' ,
15
+ 'it("is" + " a " + " string", () => {});' ,
15
16
'test("is a string", () => {});' ,
16
17
'xtest("is a string", () => {});' ,
17
18
'xtest(`${myFunc} is a string`, () => {});' ,
Original file line number Diff line number Diff line change @@ -16,6 +16,20 @@ import {
16
16
const trimFXprefix = ( word : string ) =>
17
17
[ 'f' , 'x' ] . includes ( word . charAt ( 0 ) ) ? word . substr ( 1 ) : word ;
18
18
19
+ const doesBinaryExpressionContainStringNode = (
20
+ binaryExp : TSESTree . BinaryExpression ,
21
+ ) : boolean => {
22
+ if ( isStringNode ( binaryExp . right ) ) {
23
+ return true ;
24
+ }
25
+
26
+ if ( binaryExp . left . type === AST_NODE_TYPES . BinaryExpression ) {
27
+ return doesBinaryExpressionContainStringNode ( binaryExp . left ) ;
28
+ }
29
+
30
+ return isStringNode ( binaryExp . left ) ;
31
+ } ;
32
+
19
33
export default createRule ( {
20
34
name : __filename ,
21
35
meta : {
@@ -56,6 +70,13 @@ export default createRule({
56
70
const [ argument ] = node . arguments ;
57
71
58
72
if ( ! isStringNode ( argument ) ) {
73
+ if (
74
+ argument . type === AST_NODE_TYPES . BinaryExpression &&
75
+ doesBinaryExpressionContainStringNode ( argument )
76
+ ) {
77
+ return ;
78
+ }
79
+
59
80
if (
60
81
argument . type !== AST_NODE_TYPES . TemplateLiteral &&
61
82
! ( ignoreTypeOfDescribeName && isDescribe ( node ) )
You can’t perform that action at this time.
0 commit comments