Skip to content
Permalink
Browse files

πŸ‘• Switch to eslint. #18 #30

+ create eslintrc.json; fix lints
+ remove jshint
  • Loading branch information...
desandro committed Jun 3, 2019
1 parent 5d8a7ed commit 8079190c4d3f113de70c8f8da9be413277856118
@@ -0,0 +1,218 @@
{
"env": {
"browser": true,
"commonjs": true
},
"extends": "eslint:recommended",

This comment has been minimized.

Copy link
@lipis

lipis Jun 4, 2019

I'm sure most of the rules are part of the eslint:recommended and could be simplified..

"parserOptions": {
"ecmaVersion": 5
},
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": [ "error", "always" ],
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": [ "error", "always" ],
"arrow-parens": [ "error", "always" ],
"arrow-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": [ "error", "1tbs" ],
"camelcase": "error",
"class-methods-use-this": "error",
"comma-dangle": [ "error", "always-multiline" ],
"comma-spacing": "error",
"comma-style": [ "error", "last" ],
"complexity": [ "error", 12 ],
"consistent-this": [ "error", "_this" ],
"curly": "error",
"default-case": "error",
"dot-location": [ "error", "property" ],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "off",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-style": [ "error", "declaration" ],
"function-paren-newline": [ "error", "consistent" ],
"generator-star-spacing": "error",
"id-blacklist": [ "error", "data", "callback" ],
"id-length": [ "error", {
"min": 3,
"max": 30,
"exceptions": [ "x", "y", "z", "i", "a", "b" ]
}],
"id-match": "error",
"implicit-arrow-linebreak": "error",
"indent": [ "error", 2, {
"VariableDeclarator": 4,
"CallExpression": { "arguments": 2 },
"FunctionExpression": { "body": 1, "parameters": 2 },
"ignoredNodes": [ "CallExpression > FunctionExpression > BlockStatement.body" ]
}],
"key-spacing": "error",
"keyword-spacing": [ "error", {
"before": true,
"after": true
}],
"linebreak-style": [ "error", "unix" ],
"lines-around-comment": "error",
"lines-between-class-members": "error",
"max-classes-per-file": "error",
"max-depth": "error",
"max-len": [ "error", {
"code": 80
}],
"max-lines": [ "error", {
"max": 300
}],
"max-nested-callbacks": "error",
"max-statements-per-line": "error",
"new-cap": "error",
"new-parens": "error",
"newline-per-chained-call": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": [ "error", "all", {
"nestedBinaryExpressions": false
}],
"no-floating-decimal": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inner-declarations": [ "error", "functions" ],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-misleading-character-class": "error",
"no-mixed-requires": "error",
"no-multi-assign": "off",
"no-multi-spaces": [ "error", {
"exceptions": { "Property": true }
}],
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": [ "error", {
"functions": false
}],
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "error",
"one-var": [ "error", {
"initialized": "never",
"uninitialized": "always"
}],
"one-var-declaration-per-line": [ "error", "initializations" ],
"operator-assignment": "error",
"operator-linebreak": [ "error", "after" ],
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-spread": "error",
"quote-props": [ "error", "as-needed" ],
"quotes": [ "error", "single", {
"avoidEscape": true
}],
"radix": "error",
"require-atomic-updates": "error",
"require-await": "error",
"rest-spread-spacing": "error",
"semi": "error",
"semi-spacing": [ "error", {
"after": true,
"before": false
}],
"semi-style": [ "error", "last" ],
"sort-imports": "error",
"space-before-blocks": "error",
"space-before-function-paren": [ "error", "never" ],
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": [ "error", "never" ],
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [ "error", "never" ],
"valid-jsdoc": "error",
"vars-on-top": "off",
"wrap-iife": [ "error", "any" ],
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": [ "error", "never" ]
}
}
@@ -5,7 +5,7 @@ uglify:
npx uglifyjs dist/zdog.dist.js -o dist/zdog.dist.min.js --mangle --comments /^!/

lint:
npx jshint js/*.js demos/**/*.js tasks/*.js
npx eslint js/ demos/ tasks/

dist: bundle uglify

@@ -0,0 +1,14 @@
{
"extends": "../.eslintrc.json",
"globals": {
"Zdog": "readonly"
},
"rules": {
"key-spacing": "off",
"max-lines": "off",
"one-var": [ "error", {
"initialized": "never",
"uninitialized": "consecutive"
}]
}
}

This file was deleted.

@@ -123,7 +123,7 @@ function spin() {
var progress = ticker / cycleCount;
var turn = Math.floor( progress % 4 );
var theta = Zdog.easeInOut( progress % 1, 3 ) * TAU;
if ( turn == 0 || turn == 2 ) {
if ( turn == 0 || turn == 2 ) {
model.rotate.y = theta;
} else if ( turn == 1 ) {
model.rotate.x = theta;
@@ -45,7 +45,7 @@ var cone = new Zdog.Cone({
stroke: false,
});

var colorWheel = [ eggplant, garnet, orange, gold, yellow, ];
var colorWheel = [ eggplant, garnet, orange, gold, yellow ];

[ true, false ].forEach( function( isHemi ) {
var shape = isHemi ? hemi : cone;
@@ -71,9 +71,9 @@ var colorWheel = [ eggplant, garnet, orange, gold, yellow, ];
// ----- animate ----- //

var keyframes = [
{ x: TAU * 0, y: TAU * 0 },
{ x: TAU * 1/2, y: TAU * 1/2 },
{ x: TAU * 1, y: TAU * 1 },
{ x: TAU*0, y: TAU*0 },
{ x: TAU/2, y: TAU/2 },
{ x: TAU*1, y: TAU*1 },
];

var ticker = 0;
@@ -97,7 +97,7 @@ function spin() {
var keyB = keyframes[ turn + 1 ];
var thetaX = Zdog.lerp( keyA.x, keyB.x, tween );
illo.rotate.x = Math.cos( thetaX ) * TAU/12;
illo.rotate.y = Zdog.lerp( keyA.y, keyB.y, tween ) ;
illo.rotate.y = Zdog.lerp( keyA.y, keyB.y, tween );
ticker++;
}

@@ -84,7 +84,7 @@ new Zdog.Shape({
{ x: 2, y: -3 },
{ x: 2, y: -1 },
]},
{ x: 2, y: 3 }
{ x: 2, y: 3 },
],
translate: { x: 2, y: 4 },
color: eggplant,
@@ -127,7 +127,7 @@ new Zdog.Shape({
var innerEarXShift = 4;
new Zdog.Shape({
path: [
{ x: earA.x - innerEarXShift , y: earA.y-3 },
{ x: earA.x - innerEarXShift, y: earA.y-3 },
{ x: earD.x, y: earD.y+5 },
{ x: earE.x + innerEarXShift, y: earE.y+2 },
],
@@ -242,7 +242,7 @@ var cloakSide = new Zdog.Anchor({
});

// top straps
var topCloakStrap = new Zdog.Shape({
var topCloakStrap = new Zdog.Shape({
path: [
{ x: cloakX0, y: cloakY0, z: cloakZ0 },
{ x: cloakX0, y: cloakY1, z: cloakZ1 },
@@ -165,7 +165,7 @@ var rightFoot = new Zdog.Shape({

rightFoot.copy({
translate: { x: 9.5, y: 6, z: -6 },
rotate: { z: -1.1, y: 0.8 }
rotate: { z: -1.1, y: 0.8 },
});

// ----- umbrella ----- //
@@ -102,20 +102,20 @@ var brimBridge = new Zdog.Shape({
{ bezier: [
{ x: -16, y: 4, z: 30 },
brimEdge,
brimTip
brimTip,
]},
],
});
brimBridge.copy({
scale: { x: - 1},
scale: { x: -1},
});

// glasses front top
var glassFront = new Zdog.Shape({
addTo: illo,
path: [
{ x: -16 },
{ x: 16 }
{ x: 16 },
],
translate: { y: 8, z: 12 },
color: eggplant,
@@ -67,7 +67,7 @@ new Zdog.Shape({
{ move: { y: -1 } },
{ y: 1 },
{ move: { z: -1 } },
{ z: 1 }
{ z: 1 },
],
scale: 1.25,
stroke: 1,
@@ -156,7 +156,7 @@ new Zdog.Cone({
var rotor2 = new Zdog.Anchor({
addTo: rotor1,
translate: { z: inradius, y: height/2 },
rotate: { x: Math.acos(1/3) * -1 + TAU/4 },
rotate: { x: Math.acos(1/3) * -1 + TAU/4 },
});
triangle.copy({
addTo: rotor2,
@@ -284,7 +284,7 @@ solids.push( cube );
for ( var i=0; i < 5; i++ ) {
var rotor1 = new Zdog.Anchor({
addTo: dodecahedron,
rotate: { y: TAU/5 * (i) },
rotate: { y: TAU/5 * i },
});
var rotor2 = new Zdog.Anchor({
addTo: rotor1,
@@ -377,7 +377,7 @@ solids.push( cube );
addTo: sideAnchor,
translate: { y: -faceRadius/2 },
rotate: { y: TAU/2 },
color: sideColors[i]
color: sideColors[i],
});

}

0 comments on commit 8079190

Please sign in to comment.
You can’t perform that action at this time.