Skip to content

Commit

Permalink
[update] Adds DSC style linting (#108)
Browse files Browse the repository at this point in the history
* [init] adds DSC config to linting

* [update] adds linting updates (removes `;` 😁)
  • Loading branch information
yowainwright authored Apr 3, 2018
1 parent 699d2ed commit dc98e47
Show file tree
Hide file tree
Showing 20 changed files with 1,998 additions and 1,687 deletions.
43 changes: 2 additions & 41 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,9 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'dollarshaveclub/ember'
],
env: {
browser: true
},
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
root: true
};
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',
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "ember-router-scroll",
"version": "0.5.0",
"version": "0.6.0",
"description": "Scroll to top with preserved browser history scroll position",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"eslint": "eslint . --fix",
"lint:js": "eslint ./*.js addon addon-test-support app config lib server test-support tests",
"start": "ember serve",
"test": "ember try:each",
Expand Down Expand Up @@ -48,8 +49,8 @@
"ember-source": "~3.0.0",
"ember-source-channel-url": "^1.0.1",
"ember-try": "^0.2.23",
"eslint-plugin-ember": "^5.0.0",
"eslint-plugin-node": "^5.2.1",
"eslint": "^4.19.1",
"eslint-config-dollarshaveclub": "^3.1.0",
"loader.js": "^4.2.3"
},
"engines": {
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
Loading

0 comments on commit dc98e47

Please sign in to comment.