Skip to content

Commit

Permalink
[update] adds linting updates (removes ; 😁)
Browse files Browse the repository at this point in the history
  • Loading branch information
yowainwright committed Apr 2, 2018
1 parent d41d7b5 commit fb0846c
Show file tree
Hide file tree
Showing 20 changed files with 333 additions and 337 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
],
env: {
browser: true
}
},
root: true
};
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ install:
- yarn install --no-lockfile --non-interactive

script:
- yarn eslint:ci
- yarn lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
68 changes: 34 additions & 34 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
import Mixin from '@ember/object/mixin';
import { get, computed } from '@ember/object';
import { inject } from '@ember/service';
import { getOwner } from '@ember/application';
import Mixin from '@ember/object/mixin'
import { get, computed } from '@ember/object'
import { inject } from '@ember/service'
import { getOwner } from '@ember/application'

export default Mixin.create({
scheduler: inject('scheduler'),
service: inject('router-scroll'),

isFastBoot: computed(function() {
const fastboot = getOwner(this).lookup('service:fastboot');
return fastboot ? fastboot.get('isFastBoot') : false;
isFastBoot: computed(function () {
const fastboot = getOwner(this).lookup('service:fastboot')
return fastboot ? fastboot.get('isFastBoot') : false
}),

willTransition(...args) {
this._super(...args);
willTransition (...args) {
this._super(...args)

if (get(this, 'isFastBoot')) { return; }
if (get(this, 'isFastBoot')) { return }

get(this, 'service').update();
get(this, 'service').update()
},

didTransition(transitions, ...args) {
this._super(transitions, ...args);
didTransition (transitions, ...args) {
this._super(transitions, ...args)

if (get(this, 'isFastBoot')) { return; }
if (get(this, 'isFastBoot')) { return }

this.get('scheduler').scheduleWork('afterContentPaint', () => {
this.updateScrollPosition(transitions);
});
this.updateScrollPosition(transitions)
})
},

updateScrollPosition(transitions) {
const lastTransition = transitions[transitions.length - 1];
const url = get(lastTransition, 'handler.router.currentURL');
const hashElement = url ? document.getElementById(url.split('#').pop()) : null;
updateScrollPosition (transitions) {
const lastTransition = transitions[transitions.length - 1]
const url = get(lastTransition, 'handler.router.currentURL')
const hashElement = url ? document.getElementById(url.split('#').pop()) : null

let scrollPosition;
let scrollPosition

if(url && url.indexOf('#') > -1 && hashElement) {
scrollPosition = { x: hashElement.offsetLeft, y: hashElement.offsetTop };
if (url && url.indexOf('#') > -1 && hashElement) {
scrollPosition = { x: hashElement.offsetLeft, y: hashElement.offsetTop }
} else {
scrollPosition = get(this, 'service.position');
scrollPosition = get(this, 'service.position')
}
const scrollElement = get(this, 'service.scrollElement');
const scrollElement = get(this, 'service.scrollElement')

const preserveScrollPosition = get(lastTransition, 'handler.controller.preserveScrollPosition');
const preserveScrollPosition = get(lastTransition, 'handler.controller.preserveScrollPosition')

if (!preserveScrollPosition) {
if ('window' === scrollElement) {
window.scrollTo(scrollPosition.x, scrollPosition.y);
} else if ('#' === scrollElement.charAt(0)) {
const element = document.getElementById(scrollElement.substring(1));
if (scrollElement === 'window') {
window.scrollTo(scrollPosition.x, scrollPosition.y)
} else if (scrollElement.charAt(0) === '#') {
const element = document.getElementById(scrollElement.substring(1))

if (element) {
element.scrollLeft = scrollPosition.x;
element.scrollTop = scrollPosition.y;
element.scrollLeft = scrollPosition.x
element.scrollTop = scrollPosition.y
}
}
}
}
});
},
})
56 changes: 28 additions & 28 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
'use strict'

const getChannelURL = require('ember-source-channel-url');
const getChannelURL = require('ember-source-channel-url')

module.exports = function() {
module.exports = function () {
return Promise.all([
getChannelURL('release'),
getChannelURL('beta'),
Expand All @@ -15,57 +15,57 @@ module.exports = function() {
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0'
}
}
'ember-source': '~2.12.0',
},
},
},
{
name: 'ember-lts-2.16',
npm: {
devDependencies: {
'ember-source': '~2.16.0'
}
}
'ember-source': '~2.16.0',
},
},
},
{
name: 'ember-lts-2.18',
npm: {
devDependencies: {
'ember-source': '~2.18.0'
}
}
'ember-source': '~2.18.0',
},
},
},
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': urls[0]
}
}
'ember-source': urls[0],
},
},
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'ember-source': urls[1]
}
}
'ember-source': urls[1],
},
},
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'ember-source': urls[2]
}
}
'ember-source': urls[2],
},
},
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
};
});
};
devDependencies: {},
},
},
],
}
})
}
8 changes: 4 additions & 4 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
'use strict'

module.exports = function(/* environment, appConfig */) {
return { };
};
module.exports = function (/* environment, appConfig */) {
return { }
}
14 changes: 7 additions & 7 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
'use strict'

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon')

module.exports = function(defaults) {
let app = new EmberAddon(defaults, {
module.exports = function (defaults) {
const app = new EmberAddon(defaults, {
// Add options here
});
})

/*
This build file specifies the options for the dummy test app of this
Expand All @@ -14,5 +14,5 @@ module.exports = function(defaults) {
behave. You most likely want to be modifying `./index.js` or app's build file
*/

return app.toTree();
};
return app.toTree()
}
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
'use strict'

module.exports = {
name: 'ember-router-scroll'
};
name: 'ember-router-scroll',
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scripts": {
"build": "ember build",
"eslint": "eslint . --fix",
"lint:ci": "eslint .",
"lint:js": "eslint .",
"start": "ember serve",
"test": "ember try:each",
"changelog": "lerna-changelog",
Expand Down
18 changes: 7 additions & 11 deletions testem.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
'Chrome'
],
launch_in_ci: ['Chrome'],
launch_in_dev: ['Chrome'],
browser_args: {
Chrome: {
mode: 'ci',
Expand All @@ -17,8 +13,8 @@ module.exports = {
'--disable-gpu',
'--headless',
'--remote-debugging-port=0',
'--window-size=1440,900'
].filter(Boolean)
}
}
};
'--window-size=1440,900',
].filter(Boolean),
},
},
}
22 changes: 11 additions & 11 deletions tests/acceptance/basic-functionality-test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { visit, click, currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit'
import { setupApplicationTest } from 'ember-qunit'
import { visit, click, currentURL } from '@ember/test-helpers'

module('Acceptance | basic functionality', function(hooks) {
setupApplicationTest(hooks);
module('Acceptance | basic functionality', function (hooks) {
setupApplicationTest(hooks)

test('The application should work when loading a page and clicking a link', async function(assert) {
await visit('/');
test('The application should work when loading a page and clicking a link', async function (assert) {
await visit('/')

await click('a[href="/next-page"]');
await click('a[href="/next-page"]')

assert.equal(currentURL(), '/next-page');
});
});
assert.equal(currentURL(), '/next-page')
})
})
16 changes: 8 additions & 8 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
import Application from '@ember/application'
import Resolver from './resolver'
import loadInitializers from 'ember-load-initializers'
import config from './config/environment'

const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
});
Resolver,
})

loadInitializers(App, config.modulePrefix);
loadInitializers(App, config.modulePrefix)

export default App;
export default App
4 changes: 2 additions & 2 deletions tests/dummy/app/resolver.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Resolver from 'ember-resolver';
import Resolver from 'ember-resolver'

export default Resolver;
export default Resolver
16 changes: 8 additions & 8 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import EmberRouter from '@ember/routing/router';
import RouterScroll from 'ember-router-scroll';
import config from './config/environment';
import EmberRouter from '@ember/routing/router'
import RouterScroll from 'ember-router-scroll'
import config from './config/environment'

const Router = EmberRouter.extend(RouterScroll, {
location: config.locationType,
rootURL: config.rootURL
});
rootURL: config.rootURL,
})

Router.map(function () {
this.route('next-page');
});
this.route('next-page')
})

export default Router;
export default Router
Loading

0 comments on commit fb0846c

Please sign in to comment.