File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,11 @@ export const singletons = async () => {
9292 for ( const file of changedFiles ) {
9393 let diff = await danger . git . diffForFile ( file ) ;
9494 let addedLines = diff ?. added . split ( / \n / ) ;
95- if ( addedLines ?. find ( value => / ^ \+ (? ! \s * \/ \/ ) \s * (?: p u b l i c | p r i v a t e | i n t e r n a l ) ? \s * s t a t i c \s * (?: l e t | v a r ) \s * s h a r e d (?: \s * : .+ ) ? \s * = .* $ / . test ( value ) ) ) {
96- fail ( "New singleton definitions are not allowed." ) ;
95+ const foundSingleton = addedLines ?. find ( value => / ^ \+ (? ! \s * \/ \/ ) \s * (?: p u b l i c | p r i v a t e | i n t e r n a l ) ? \s * s t a t i c \s * (?: l e t | v a r ) \s * s h a r e d (?: \s * : .+ ) ? \s * = .* $ / . test ( value ) ) ;
96+ if ( foundSingleton ) {
97+ // trim leading + and whitespace
98+ const cleanLine = foundSingleton . replace ( / ^ \+ \s * / , '' ) . trim ( ) ;
99+ fail ( `New singleton definitions are not allowed. Found: \`${ cleanLine } \`` ) ;
97100 return ;
98101 }
99102 }
You can’t perform that action at this time.
0 commit comments