replace JSHint with ESLint

This commit is contained in:
Ivan Malopinsky
2021-01-09 14:56:23 -05:00
parent 42c3af697c
commit a2b3c04be2
9 changed files with 1631 additions and 48 deletions

10
.eslintrc.json Normal file
View File

@@ -0,0 +1,10 @@
{
"env": {
"browser": true,
"commonjs": true
},
"extends": "eslint:recommended",
"rules": {
"quotes": ["error", "single"]
}
}

View File

@@ -1,13 +0,0 @@
{
"quotmark": true,
"boss": true,
"eqnull": true,
"expr": true,
"funcscope": true,
"loopfunc": true,
"smarttabs": true,
"node": true,
"browser": true,
"undef": true,
"unused": true
}

View File

@@ -1,14 +1,14 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var todo = require('gulp-todo');
var gulputil = require('gulp-util');
var replace = require('gulp-replace');
var webpack = require('webpack-stream');
var beautify = require('gulp-jsbeautifier');
var concat = require('gulp-concat');
var eslint = require('gulp-eslint');
var gulp = require('gulp');
var gulputil = require('gulp-util');
var header = require('gulp-header');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var todo = require('gulp-todo');
var uglify = require('gulp-uglify');
var webpack = require('webpack-stream');
var moment = require('moment');
var pkg = require('./package.json');
@@ -29,15 +29,16 @@ function generateBuild() {
var build = generateBuild();
gulp.task('jshint', function() {
return gulp.src([
'src/lib/*.js',
'src/lib/renderers/*.js',
'src/renderers/*.js',
'src/index.js'
])
.pipe(jshint())
.pipe(jshint.reporter('default'));
gulp.task('lint', function() {
return gulp.src([
'src/lib/*.js',
'src/lib/renderers/*.js',
'src/renderers/*.js',
'src/index.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('todo', function() {
@@ -51,7 +52,7 @@ gulp.task('todo', function() {
.pipe(gulp.dest('./'));
});
gulp.task('build', ['jshint'], function() {
gulp.task('build', ['lint'], function() {
return gulp.src('src/index.js')
.pipe(webpack({
output: {

1585
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -31,9 +31,9 @@
"component-type": "1.1.0",
"gulp": "3.9.0",
"gulp-concat": "2.2.0",
"gulp-eslint": "6.0.0",
"gulp-header": "1.0.5",
"gulp-jsbeautifier": "0.0.5",
"gulp-jshint": "1.6.1",
"gulp-rename": "1.2.2",
"gulp-replace": "0.5.3",
"gulp-todo": "0.3.8",

View File

@@ -129,7 +129,7 @@ var Holder = {
} else if (holderStringIndex === 1 && rawURL[0] === '?') {
holderURL = rawURL.slice(1);
} else {
var fragment = rawURL.substr(holderStringIndex).match(/([^\"]*)"?\)/);
var fragment = rawURL.substr(holderStringIndex).match(/([^"]*)"?\)/);
if (fragment !== null) {
holderURL = fragment[1];
} else if (rawURL.indexOf('url(') === 0) {
@@ -156,7 +156,9 @@ var Holder = {
try {
objectAttr.data = object.getAttribute('data');
objectAttr.dataSrc = object.getAttribute(App.vars.dataAttr);
} catch (e) {}
} catch (e) {
objectAttr.error = e;
}
var objectHasSrcURL = objectAttr.data != null && objectAttr.data.indexOf(options.domain) === 0;
var objectHasDataSrcURL = objectAttr.dataSrc != null && objectAttr.dataSrc.indexOf(options.domain) === 0;
@@ -175,7 +177,9 @@ var Holder = {
imageAttr.src = image.getAttribute('src');
imageAttr.dataSrc = image.getAttribute(App.vars.dataAttr);
imageAttr.rendered = image.getAttribute('data-holder-rendered');
} catch (e) {}
} catch (e) {
imageAttr.error = e;
}
var imageHasSrc = imageAttr.src != null;
var imageHasDataSrcURL = imageAttr.dataSrc != null && imageAttr.dataSrc.indexOf(options.domain) === 0;
@@ -342,7 +346,7 @@ function parseURL(url, instanceOptions) {
holder.autoFg = true;
}
if (options.theme && holder.instanceOptions.themes.hasOwnProperty(options.theme)) {
if (options.theme && Object.prototype.hasOwnProperty.call(holder.instanceOptions.themes, options.theme)) {
holder.theme = extend(holder.instanceOptions.themes[options.theme], null);
}
@@ -359,7 +363,7 @@ function parseURL(url, instanceOptions) {
if (options.size && parseFloat(options.size)) {
holder.size = parseFloat(options.size);
}
if (options.fixedSize != null) {
holder.fixedSize = utils.truthy(options.fixedSize);
}
@@ -1128,7 +1132,7 @@ function resizeEvent() {
//Set up flags
for (var flag in App.flags) {
if (!App.flags.hasOwnProperty(flag)) continue;
if (!Object.prototype.hasOwnProperty.call(App.flags, flag)) continue;
App.flags[flag].match = function(val) {
return val.match(this.regex);
};

View File

@@ -146,7 +146,7 @@ module.exports = function (sceneGraph, renderSettings) {
var output = String(shaven(svg));
if (/\&(x)?#[0-9A-Fa-f]/.test(output[0])) {
if (/&(x)?#[0-9A-Fa-f]/.test(output[0])) {
output = output.replace(/&#/gm, '&#');
}

View File

@@ -104,6 +104,6 @@ exports.serializeSVG = function(svg, engineSettings) {
}
var svgText = serializer.serializeToString(svg);
svgText = svgText.replace(/\&(\#[0-9]{2,}\;)/g, '&$1');
svgText = svgText.replace(/&(#[0-9]{2,};)/g, '&$1');
return svgCSS + svgText;
};

View File

@@ -8,13 +8,13 @@
exports.extend = function(a, b) {
var c = {};
for (var x in a) {
if (a.hasOwnProperty(x)) {
if (Object.prototype.hasOwnProperty.call(a,x)) {
c[x] = a[x];
}
}
if (b != null) {
for (var y in b) {
if (b.hasOwnProperty(y)) {
if (Object.prototype.hasOwnProperty.call(b, y)) {
c[y] = b[y];
}
}
@@ -30,7 +30,7 @@ exports.extend = function(a, b) {
exports.cssProps = function(props) {
var ret = [];
for (var p in props) {
if (props.hasOwnProperty(p)) {
if (Object.prototype.hasOwnProperty.call(props, p)) {
ret.push(p + ':' + props[p]);
}
}
@@ -146,8 +146,8 @@ exports.parseColor = function(val) {
match = val.match(rgbare);
if (match !== null) {
const normalizeAlpha = function (a) { return '0.' + a.split('.')[1]; };
const fixedMatch = match.slice(1).map(function (e, i) {
var normalizeAlpha = function (a) { return '0.' + a.split('.')[1]; };
var fixedMatch = match.slice(1).map(function (e, i) {
return (i === 3) ? normalizeAlpha(e) : e;
});
retval = 'rgba(' + fixedMatch.join(',') + ')';