Switch from jshint to eslint

This commit is contained in:
yushijinhun 2018-01-06 18:47:07 +08:00
parent a05dc21977
commit 9f30b25d3e
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
12 changed files with 1012 additions and 184 deletions

View File

@ -1,11 +1,18 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
},
"modules": false
}]
[
"env",
{
"targets": {
"browsers": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
},
"modules": false
}
]
],
"plugins": [
"external-helpers"

43
.eslintrc.js Normal file
View File

@ -0,0 +1,43 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"warn",
"tab",
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-console": [
"error",
{
allow: ["warn", "error"]
}
],
"no-unused-vars": [
"error",
{
"args": "none"
}
]
}
};

View File

@ -1,3 +0,0 @@
{
"esversion": 6
}

1077
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
"scripts": {
"build": "rollup -c tools/rollup.default.js && rollup -c tools/rollup.min.js && rollup -c tools/rollup.babel.js && rollup -c tools/rollup.babel.min.js",
"prepare": "npm test && rm -rf build && npm run build",
"test": "jshint src"
"test": "eslint src/** tools/**"
},
"repository": {
"type": "git",
@ -26,7 +26,7 @@
"babel-cli": "^6.26.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.1",
"jshint": "^2.9.5",
"eslint": "^4.14.0",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-uglify": "^2.0.1",

View File

@ -1,5 +1,3 @@
import { SkinObject, CapeObject, PlayerObject } from "./skinview3d";
let WalkAnimation = (player, time) => {
let skin = player.skin;
let angleRot = time + Math.PI / 2;

View File

@ -1,5 +1,5 @@
import THREE from "three";
import { SkinObject, CapeObject, PlayerObject } from "./model";
import { PlayerObject } from "./model";
import { OrbitControls } from "./orbit_controls";
function copyImage(context, sX, sY, w, h, dX, dY, flipHorizontal) {
@ -95,14 +95,14 @@ class SkinViewer {
// texture loading
this.skinImg.crossOrigin = "";
this.skinImg.onerror = () => console.log("Failed loading " + this.skinImg.src);
this.skinImg.onerror = () => console.error("Failed loading " + this.skinImg.src);
this.skinImg.onload = () => {
let isOldFormat = false;
if (this.skinImg.width !== this.skinImg.height) {
if (this.skinImg.width === 2 * this.skinImg.height) {
isOldFormat = true;
} else {
console.log("Bad skin size");
console.error("Bad skin size");
return;
}
}
@ -130,10 +130,10 @@ class SkinViewer {
};
this.capeImg.crossOrigin = "";
this.capeImg.onerror = () => console.log("Failed loading " + this.capeImg.src);
this.capeImg.onerror = () => console.error("Failed loading " + this.capeImg.src);
this.capeImg.onload = () => {
if (this.capeImg.width !== 2 * this.capeImg.height) {
console.log("Bad cape size");
console.error("Bad cape size");
return;
}

View File

@ -1,2 +1,2 @@
import { buildType } from './rollup.common';
export default buildType({ postfix: '.babel', babel: true, uglify: false });
import { buildType } from "./rollup.common";
export default buildType({ postfix: ".babel", babel: true, uglify: false });

View File

@ -1,2 +1,2 @@
import { buildType } from './rollup.common';
export default buildType({ postfix: '.babel.min', babel: true, uglify: true });
import { buildType } from "./rollup.common";
export default buildType({ postfix: ".babel.min", babel: true, uglify: true });

View File

@ -1,23 +1,23 @@
import uglify from 'rollup-plugin-uglify';
import { minify } from 'uglify-es';
import babel from 'rollup-plugin-babel';
import uglify from "rollup-plugin-uglify";
import { minify } from "uglify-es";
import babel from "rollup-plugin-babel";
let buildType = config => {
let options = {
input: 'src/skinview3d.js',
indent: '\t',
input: "src/skinview3d.js",
indent: "\t",
sourcemap: true,
external: ['three'],
external: ["three"],
globals: {
three: 'THREE'
three: "THREE"
},
output: [
{
format: 'umd',
name: 'skinview3d',
format: "umd",
name: "skinview3d",
file: `build/skinview3d${config.postfix}.js`
},
{
format: 'es',
format: "es",
file: `build/skinview3d${config.postfix}.module.js`
}
],
@ -26,7 +26,7 @@ let buildType = config => {
if (config.babel) {
options.plugins.push(
babel({
exclude: 'node_modules/**',
exclude: "node_modules/**",
})
);
}

View File

@ -1,2 +1,2 @@
import { buildType } from './rollup.common';
export default buildType({ postfix: '', babel: false, uglify: false });
import { buildType } from "./rollup.common";
export default buildType({ postfix: "", babel: false, uglify: false });

4
tools/rollup.min.js vendored
View File

@ -1,2 +1,2 @@
import { buildType } from './rollup.common';
export default buildType({ postfix: '.min', babel: false, uglify: true });
import { buildType } from "./rollup.common";
export default buildType({ postfix: ".min", babel: false, uglify: true });