Skip to content
Permalink
Browse files
Fix linting issues
  • Loading branch information
alexei committed May 29, 2017
1 parent 180a8a6 commit bfeab902cbf32d570409676da2624dfa8788c43a
Showing with 37 additions and 34 deletions.
  1. +1 −0 .eslintignore
  2. +8 −6 .eslintrc.js
  3. +1 −2 benchmark/benchmark.js
  4. +2 −2 gulpfile.js
  5. +2 −2 src/angular-sprintf.js
  6. +19 −17 src/sprintf.js
  7. +3 −4 test/test.js
  8. +1 −1 test/test_validation.js
@@ -1 +1,2 @@
dist/*
node_modules/*
@@ -5,11 +5,13 @@ module.exports = {
es6: true
},
rules: {
'no-control-regex': 0,
'no-undef': 0,
'no-unused-vars': 0,
indent: ['error', 4, {SwitchCase: 1}],
'quote-props': ['error', 'as-needed'],
'no-cond-assign': 0,
'no-console': 0,
indent: ['error', 4],
'quote-props': ['error', 'as-needed']
'no-control-regex': 0,
'no-undef': 'error',
'no-unused-vars': 'error',
semi: ['error', 'never']
}
};
}
@@ -1,8 +1,7 @@
var Benchmark = require('benchmark'),
suite = new Benchmark.Suite,
sprintfjs = require('../src/sprintf.js'),
sprintf = sprintfjs.sprintf,
vsprintf = sprintfjs.vsprintf
sprintf = sprintfjs.sprintf

suite
.add('%8d', function() {
@@ -15,7 +15,7 @@ gulp.task('benchmark', function () {
return gulp
.src('benchmark/*.js', {read: false})
.pipe(benchmark())
});
})

gulp.task('lint', function() {
return gulp
@@ -27,7 +27,7 @@ gulp.task('lint', function() {
gulp.task('test', ['lint'], function() {
return gulp
.src('test/*.js', {read: false})
.pipe(mocha({reporter: 'nyan'}));
.pipe(mocha({reporter: 'nyan'}))
})

gulp.task('dist', ['test'], function() {
@@ -1,6 +1,6 @@
/* global angular, sprintf, vsprintf */

(function () {
!function () {
'use strict'

angular.
@@ -21,4 +21,4 @@
filter('vfmt', ['$filter', function($filter) {
return $filter('vsprintf')
}])
})();
}()
@@ -1,6 +1,6 @@
/* global window, exports, define */

(function() {
!function() {
'use strict'

var re = {
@@ -69,54 +69,54 @@
switch (match[8]) {
case 'b':
arg = parseInt(arg, 10).toString(2)
break
break
case 'c':
arg = String.fromCharCode(parseInt(arg, 10))
break
break
case 'd':
case 'i':
arg = parseInt(arg, 10)
break
break
case 'j':
arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)
break
break
case 'e':
arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential()
break
break
case 'f':
arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
break
break
case 'g':
arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg)
break
break
case 'o':
arg = (parseInt(arg, 10) >>> 0).toString(8)
break
break
case 's':
arg = String(arg)
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
break
case 't':
arg = String(!!arg)
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
break
case 'T':
arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
break
case 'u':
arg = parseInt(arg, 10) >>> 0
break
break
case 'v':
arg = arg.valueOf()
arg = (match[7] ? arg.substring(0, match[7]) : arg)
break
break
case 'x':
arg = (parseInt(arg, 10) >>> 0).toString(16)
break
break
case 'X':
arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
break
break
}
if (re.json.test(match[8])) {
output += arg
@@ -196,6 +196,7 @@
/**
* export to either browser or node.js
*/
/* eslint-disable quote-props */
if (typeof exports !== 'undefined') {
exports['sprintf'] = sprintf
exports['vsprintf'] = vsprintf
@@ -213,4 +214,5 @@
})
}
}
})();
/* eslint-enable quote-props */
}()
@@ -1,11 +1,10 @@
/* global describe, it */

'use strict';
'use strict'

var assert = require('assert'),
sprintfjs = require('../src/sprintf.js'),
sprintf = sprintfjs.sprintf,
vsprintf = sprintfjs.vsprintf
sprintf = sprintfjs.sprintf

describe('sprintfjs', function() {
var pi = 3.141592653589793
@@ -33,7 +32,7 @@ describe('sprintfjs', function() {
assert.equal('FF', sprintf('%X', 255))
assert.equal('FFFFFF01', sprintf('%X', -255))
assert.equal('Polly wants a cracker', sprintf('%2$s %3$s a %1$s', 'cracker', 'Polly', 'wants'))
assert.equal('Hello world!', sprintf('Hello %(who)s!', {'who': 'world'}))
assert.equal('Hello world!', sprintf('Hello %(who)s!', {who: 'world'}))
assert.equal('true', sprintf('%t', true))
assert.equal('t', sprintf('%.1t', true))
assert.equal('true', sprintf('%t', 'true'))
@@ -1,6 +1,6 @@
/* global describe, it */

'use strict';
'use strict'

var assert = require('assert'),
sprintfjs = require('../src/sprintf.js'),

0 comments on commit bfeab90

Please sign in to comment.