Skip to content

Commit

Permalink
[infrastructure] Configure ESLint, fix any existing errors
Browse files Browse the repository at this point in the history
Additional work:

* Add postinstall command which runs `lerna bootstrap`

Part of #4464
  • Loading branch information
traviskaufman committed Jul 14, 2016
1 parent 87495e3 commit 1a0bc9e
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 103 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends: google
globals:
goog: false
env:
browser: true
rules:
max-len: [error, 120]
no-new: warn
quotes: [error, single]
no-var: error
curly: error
no-floating-decimal: error
no-unused-vars: error
# Disabling jsdoc rules for the time being, but should be discussed as to whether or not this is
# something we should add in. For closure compatibility, we can investigate using something like
# https://github.com/angular/tsickle with .dts files.
require-jsdoc: off
valid-jsdoc: off
prefer-const: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.DS_Store
/build
packages/*/dist
*.log
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"build": "mkdir -p build && webpack",
"build:min": "mkdir -p build && MDL_ENV=production webpack -p",
"dist": "npm run clean && npm run build && npm run build:min",
"dev": "npm run clean && MDL_ENV=development webpack-dev-server --content-base demos --inline --hot"
"dev": "npm run clean && MDL_ENV=development webpack-dev-server --content-base demos --inline --hot",
"lint:js": "eslint --fix packages webpack.config.js",
"postinstall": "lerna bootstrap"
},
"devDependencies": {
"autoprefixer": "^6.3.6",
Expand Down
15 changes: 6 additions & 9 deletions packages/mdl-ripple/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ export default class SequentialAnimation {
this.reject_ = null;
}


start(...sequence) {
let promise = sequence.reduce((acc, cur) => {
const promise = sequence.reduce((acc, cur) => {
let clsName;
let useNamedFinish = Array.isArray(cur);
const useNamedFinish = Array.isArray(cur);
if (useNamedFinish) {
clsName = cur[0];
} else {
Expand All @@ -32,11 +31,11 @@ export default class SequentialAnimation {

let listener;
let rejecter;
let promise = new Promise((resolve, reject) => {
const promise = new Promise((resolve, reject) => {
rejecter = reject;
listener = (ev) => {
if (!this.isAnimation_ && (!useNamedFinish || useNamedFinish && ev.propertyName == cur[1])
|| this.isAnimation_ && ev.animationName == cur[1]) {
listener = ev => {
if (!this.isAnimation_ && (!useNamedFinish || useNamedFinish && ev.propertyName === cur[1]) ||
this.isAnimation_ && ev.animationName === cur[1]) {
// Cleanup current animation and trigger next.
this.renderer_.removeEventListener(this.elementRef_, this.eventName_, listener);
this.renderer_.removeClass(this.elementRef_, clsName);
Expand Down Expand Up @@ -64,12 +63,10 @@ export default class SequentialAnimation {
});
}


stop() {
if (this.reject_) {
this.reject_();
this.reject_ = null;
}
}
}

28 changes: 11 additions & 17 deletions packages/mdl-ripple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import MDLRippleMixin, {
Class,
Identifier,
MAX_RIPPLES,
getNormalizedEventCoords,
getNormalizedEventCoords
} from './mixin';


export default class MDLRipple extends MDLBaseComponent {
/**
* Convenience helper to build required DOM.
Expand All @@ -31,26 +30,25 @@ export default class MDLRipple extends MDLBaseComponent {
return root;
}


/**
* Bind to a root element and parent surface.
*/
static attachTo(surface, root) {
let elements = {
const elements = {
[Identifier.SURFACE]: surface,
[Identifier.ROOT]: root,
[Identifier.BACKGROUND]: root.getElementsByClassName(Class.BACKGROUND)[0]
};

let foregrounds = root.getElementsByClassName(Class.FOREGROUND);
let foregroundCircles = root.getElementsByClassName(Class.FOREGROUND_CIRCLE);
const foregrounds = root.getElementsByClassName(Class.FOREGROUND);
const foregroundCircles = root.getElementsByClassName(Class.FOREGROUND_CIRCLE);
for (let i = 0; i < foregrounds.length; i++) {
elements[ref(Identifier.FOREGROUND, i)] = foregrounds[i];
elements[ref(Identifier.FOREGROUND_CIRCLE, i)] = foregroundCircles[i];
}

let options = {
bounded: surface.getAttribute('bounded') != 'false'
const options = {
bounded: surface.getAttribute('bounded') !== 'false'
};

if (surface.hasAttribute('max-radius')) {
Expand All @@ -60,33 +58,31 @@ export default class MDLRipple extends MDLBaseComponent {
return new MDLRipple(elements, options);
}


constructor(elements, options = {}) {
super(elements[Identifier.ROOT]);

this.elements_ = elements;

this.initMdlRipple_();

this.isBounded = options.bounded != false;
this.isBounded = options.bounded !== false;

this.maxRadius = typeof options.maxRadius == 'number' ? options.maxRadius : 0;
this.maxRadius = typeof options.maxRadius === 'number' ? options.maxRadius : 0;

// TODO(mtlin): Might not be the best place for this..
this.addEventListeners();
}


addEventListeners() {
const surface = this.elements_[Identifier.SURFACE];

surface.addEventListener('mousedown', ev => {
let {top, left} = getNormalizedEventCoords(ev, surface);
const {top, left} = getNormalizedEventCoords(ev, surface);

this.startTouchBeganAnimationAtPoint(top, left);
});
surface.addEventListener('mouseup', ev => {
let {top, left} = getNormalizedEventCoords(ev, surface);
const {top, left} = getNormalizedEventCoords(ev, surface);

this.startTouchEndedAnimationAtPoint(top, left);
});
Expand All @@ -96,7 +92,6 @@ export default class MDLRipple extends MDLBaseComponent {
}
}


MDLRippleMixin.call(MDLRipple.prototype, {
getRootElement() {
return this.elements_[this.get(Identifier.ROOT)];
Expand All @@ -111,7 +106,7 @@ MDLRippleMixin.call(MDLRipple.prototype, {
},

forceLayout(id) {
this.elements_[id].offsetWidth;
return this.elements_[id].offsetWidth;
},

addClass(id, cls) {
Expand Down Expand Up @@ -139,7 +134,6 @@ MDLRippleMixin.call(MDLRipple.prototype, {
}
});


/**
* Element refs are concatenated symbol paths of arbitrary length.
* e.g.
Expand Down
Loading

0 comments on commit 1a0bc9e

Please sign in to comment.