ESLint rule enforcing that
@stdlib/string/formatis used instead of string concatenation in benchmark descriptions.
var rule = require( '@stdlib/_tools/eslint/rules/no-bench-string-concat' );ESLint rule enforcing that @stdlib/string/format is used instead of string concatenation in benchmark descriptions.
Bad:
bench( pkg+':len='+len, function benchmark( b ) {
// ...
});Good:
var format = require( '@stdlib/string/format' );
bench( format( '%s:len=%d', pkg, len ), function benchmark( b ) {
// ...
});var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/no-bench-string-concat' );
var linter = new Linter();
linter.defineRule( 'no-bench-string-concat', rule );
var code = 'bench( pkg+\':len=\'+len, f );';
var result = linter.verify( code, {
'rules': {
'no-bench-string-concat': 'error'
}
});
/* returns
[
{
'ruleId': 'no-bench-string-concat',
'severity': 2,
'message': 'Use `@stdlib/string/format` instead of string concatenation for benchmark descriptions.',
'line': 1,
'column': 8,
'nodeType': 'BinaryExpression',
'endLine': 1,
'endColumn': 23
}
]
*/