Skip to content

Commit

Permalink
add eslint
Browse files Browse the repository at this point in the history
add eslint
  • Loading branch information
a-jie committed May 25, 2018
1 parent 0f5900e commit 9699111
Show file tree
Hide file tree
Showing 60 changed files with 794 additions and 646 deletions.
704 changes: 348 additions & 356 deletions build/proton.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/proton.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/proton.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/proton.min.js.map

Large diffs are not rendered by default.

183 changes: 183 additions & 0 deletions eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 9,
"ecmaFeatures": {
},
"sourceType": "module"
},

"env": {
"es6": true
},

"plugins": [
"import",
"promise",
"standard"
],

"globals": {
"document": false,
"navigator": false,
"window": false
},

"rules": {
"accessor-pairs": "error",
"arrow-spacing": ["error", { "before": true, "after": true }],
"block-spacing": ["error", "always"],
"brace-style": 0,
"camelcase": ["error", { "properties": "never" }],
"comma-dangle": ["error", {
"arrays": "never",
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "never"
}],
"comma-spacing": ["error", { "before": false, "after": true }],
"comma-style": ["error", "last"],
"constructor-super": "error",
"curly": 0,
"dot-location": ["error", "property"],
"eol-last": 0,
"eqeqeq": ["error", "always", { "null": "ignore" }],
"func-call-spacing": ["error", "never"],
"generator-star-spacing": ["error", { "before": true, "after": true }],
"handle-callback-err": ["error", "^(err|error)$" ],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"keyword-spacing": ["error", { "before": true, "after": true }],
"new-cap": ["error", { "newIsCap": true, "capIsNew": false }],
"new-parens": 0,
"no-array-constructor": "error",
"no-caller": "error",
"no-class-assign": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-const-assign": "error",
"no-constant-condition": ["error", { "checkLoops": false }],
"no-control-regex": "error",
"no-debugger": "error",
"no-delete-var": "error",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-empty-character-class": "error",
"no-empty-pattern": "error",
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-boolean-cast": 0,
"no-extra-parens": ["error", "functions"],
"no-fallthrough": "error",
"no-floating-decimal": 0,
"no-func-assign": "error",
"no-global-assign": "error",
"no-implied-eval": "error",
"no-inner-declarations": ["error", "functions"],
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": ["error", { "allowLoop": false, "allowSwitch": false }],
"no-lone-blocks": "error",
"no-mixed-operators": ["error", {
"groups": [
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"]
],
"allowSamePrecedence": true
}],
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
"no-negated-in-lhs": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-symbol": "error",
"no-new-wrappers": "error",
"no-obj-calls": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-path-concat": "error",
"no-proto": "error",
"no-redeclare": "error",
"no-regex-spaces": "error",
"no-return-assign": ["error", "except-parens"],
"no-return-await": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-tabs": "off",
"no-template-curly-in-string": "error",
"no-this-before-super": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef": 0,
"no-undef-init": "error",
"no-unexpected-multiline": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": 0,
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true, "allowTaggedTemplates": true }],
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
"no-use-before-define": ["error", { "functions": false, "classes": false, "variables": false }],
"no-useless-call": 0,
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
"one-var": 0,
"operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": 0,
"prefer-promise-reject-errors": "error",
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"rest-spread-spacing": ["error", "never"],
"semi": 0,
"semi-spacing": ["error", { "before": false, "after": true }],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": 0,
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"spaced-comment": ["error", "always", {
"line": { "markers": ["*package", "!", "/", ",", "="] },
"block": { "balanced": true, "markers": ["*package", "!", ",", ":", "::", "flow-include"], "exceptions": ["*"] }
}],
"symbol-description": "error",
"template-curly-spacing": ["error", "never"],
"template-tag-spacing": ["error", "never"],
"unicode-bom": ["error", "never"],
"use-isnan": "error",
"valid-typeof": ["error", { "requireStringLiterals": true }],
"wrap-iife": ["error", "any", { "functionPrototypeMethods": true }],
"yield-star-spacing": ["error", "both"],
"yoda": ["error", "never"],

"import/export": "error",
"import/first": "error",
"import/no-duplicates": "error",
"import/no-webpack-loader-syntax": "error",

"promise/param-names": "error",

"standard/array-bracket-even-spacing": ["error", "either"],
"standard/computed-property-even-spacing": ["error", "even"],
"standard/object-curly-even-spacing": ["error", "either"]
}
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "proton-js",
"version": "3.1.2",
"version": "3.3.0",
"description": "Proton is an easily customizable html5 particle engine including six different types of renderers.",
"main": "./build/proton.min.js",
"scripts": {
"start": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c -w -m inline\" \"serve --port 3001\"",
"page": "node ./script/makeexamplepage",
"lint": "eslint ./src --config=eslintrc.json",
"build": "rollup -c --pub"
},
"repository": {
Expand All @@ -22,10 +23,15 @@
"homepage": "http://a-jie.github.io/Proton",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2015-rollup": "^3.0.0",
"babel-preset-stage-0": "^6.24.1",
"concurrently": "^3.5.1",
"eslint": "^4.19.1",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"rollup": "^0.54.0",
"rollup-plugin-babel": "^3.0.3",
"rollup-plugin-license": "^0.5.0",
Expand Down
5 changes: 2 additions & 3 deletions src/behaviour/Alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Alpha extends Behaviour {
super(life, easing);

this.reset(a, b);
this.name = "Alpha";
this.name = 'Alpha';
}

/**
Expand All @@ -46,7 +46,7 @@ export default class Alpha extends Behaviour {

life && super.reset(life, easing);
}

/**
* Sets the new alpha value of the particle
*
Expand Down Expand Up @@ -76,7 +76,6 @@ export default class Alpha extends Behaviour {
*/
applyBehaviour(particle, time, index) {
this.calculate(particle, time, index);

particle.alpha = particle.transform.alphaB + (particle.transform.alphaA - particle.transform.alphaB) * this.energy;
if (particle.alpha < 0.001) particle.alpha = 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/behaviour/Attraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class Attraction extends Behaviour {
this.attractionForce = new Vector2D();
this.lengthSq = 0;

this.name = "Attraction";
this.name = 'Attraction';
}

/**
Expand Down Expand Up @@ -95,5 +95,4 @@ export default class Attraction extends Behaviour {
particle.a.add(this.attractionForce);
}
}
}

}
2 changes: 1 addition & 1 deletion src/behaviour/Behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class Behaviour {
* @memberof Proton.Behaviour
* @instance
*
* @param {Proton.Vector2D} force
* @param {Proton.Vector2D} force
*/
normalizeForce(force) {
return force.multiplyScalar(Proton.MEASURE);
Expand Down
12 changes: 5 additions & 7 deletions src/behaviour/Collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Util from '../utils/Util';
import Vector2D from '../math/Vector2D';
import Behaviour from './Behaviour';

//can use Collision(emitter,true,function(){}) or Collision();
export default class Collision extends Behaviour {

/**
Expand All @@ -22,7 +21,7 @@ export default class Collision extends Behaviour {
* @todo add description to mass
*
* @param {Proton.Emitter} [emitter=null] the attraction point coordinates
* @param {Boolean} [mass=true]
* @param {Boolean} [mass=true]
* @param {Callback} [callback=null] the callback after the collision
* @param {Number} [life=Infinity] this behaviour's life
* @param {String} [easing=ease.easeLinear] this behaviour's easing
Expand All @@ -33,7 +32,7 @@ export default class Collision extends Behaviour {
super(life, easing);

this.reset(emitter, mass, callback);
this.name = "Collision";
this.name = 'Collision';
}

/**
Expand All @@ -46,7 +45,7 @@ export default class Collision extends Behaviour {
* @todo add description to mass
*
* @param {Proton.Emitter} [emitter=null] the attraction point coordinates
* @param {Boolean} [mass=true]
* @param {Boolean} [mass=true]
* @param {Callback} [callback=null] the callback after the collision
* @param {Number} [life=Infinity] this behaviour's life
* @param {String} [easing=ease.easeLinear] this behaviour's easing
Expand Down Expand Up @@ -101,7 +100,7 @@ export default class Collision extends Behaviour {
totalMass = particle.mass + otherParticle.mass;
averageMass1 = this.mass ? otherParticle.mass / totalMass : 0.5;
averageMass2 = this.mass ? particle.mass / totalMass : 0.5;

particle.p.add(this.delta.clone().normalize().multiplyScalar(overlap * -averageMass1));
otherParticle.p.add(this.delta.normalize().multiplyScalar(overlap * averageMass2));

Expand All @@ -110,5 +109,4 @@ export default class Collision extends Behaviour {
}
}
}
}

}
3 changes: 1 addition & 2 deletions src/behaviour/Color.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Util from '../utils/Util';
import ColorUtil from '../utils/ColorUtil';
import ArraySpan from '../math/ArraySpan';
import Behaviour from './Behaviour';
Expand All @@ -22,7 +21,7 @@ export default class Color extends Behaviour {
super(life, easing);

this.reset(a, b);
this.name = "Color";
this.name = 'Color';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/behaviour/CrossZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class CrossZone extends Behaviour {
super(life, easing);

this.reset(zone, crossType);
this.name = "CrossZone";
this.name = 'CrossZone';
}

/**
Expand All @@ -39,7 +39,7 @@ export default class CrossZone extends Behaviour {
*/
reset(zone, crossType, life, easing) {
this.zone = zone;
this.zone.crossType = Util.initValue(crossType, "dead");
this.zone.crossType = Util.initValue(crossType, 'dead');

life && super.reset(life, easing);
}
Expand Down
3 changes: 1 addition & 2 deletions src/behaviour/Force.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Util from '../utils/Util';
import Vector2D from '../math/Vector2D';
import Behaviour from './Behaviour';

Expand All @@ -21,7 +20,7 @@ export default class Force extends Behaviour {
super(life, easing);

this.force = this.normalizeForce(new Vector2D(fx, fy));
this.name = "Force";
this.name = 'Force';
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/behaviour/Gravity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Util from '../utils/Util';
import Vector2D from '../math/Vector2D';
import Force from './Force';

export default class Gravity extends Force {
Expand All @@ -18,7 +16,7 @@ export default class Gravity extends Force {
*/
constructor(g, life, easing) {
super(0, g, life, easing);
this.name = "Gravity";
this.name = 'Gravity';
}

/**
Expand Down
Loading

0 comments on commit 9699111

Please sign in to comment.