Skip to content

Commit

Permalink
Update Ember CLI to 2.9
Browse files Browse the repository at this point in the history
- fix JSCS errors
  • Loading branch information
cibernox authored and samselikoff committed Feb 2, 2017
1 parent 797a6a4 commit 0104425
Show file tree
Hide file tree
Showing 82 changed files with 324 additions and 371 deletions.
14 changes: 0 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,8 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
extends: [
'eslint:recommended',
'plugin:ember-suave/recommended'
],
env: {
'browser': true
},
rules: {
'camelcase': 0,
'ember-suave/no-direct-property-access': 0,
'ember-suave/prefer-destructuring': 0,
'object-curly-spacing': 0,
'quotes': 0,
'array-bracket-spacing': 0,
'no-var': 0,
'object-shorthand': 0
},
globals: {
faker: true,
server: true,
$: true
}
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
npm-debug.log*
testem.log
.floo
_site
Expand Down
5 changes: 0 additions & 5 deletions .jscsrc

This file was deleted.

33 changes: 0 additions & 33 deletions .jshintrc

This file was deleted.

15 changes: 15 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js
24 changes: 17 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
language: node_js
node_js:
- "4"
<<<<<<< HEAD
- "6"
- "7"
=======
>>>>>>> Update Ember CLI to 2.9

sudo: false

Expand All @@ -13,7 +16,9 @@ cache:
- $HOME/.cache # includes bower's cache

env:
- EMBER_TRY_SCENARIO=default
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-1.13
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
Expand All @@ -24,18 +29,23 @@ matrix:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
<<<<<<< HEAD
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
- "npm install -g npm@^4"
=======
- npm config set spin false
- npm install -g bower
- bower --version
- npm install phantomjs-prebuilt
- node_modules/phantomjs-prebuilt/bin/phantomjs --version
>>>>>>> Update Ember CLI to 2.9

install:
- npm install -g bower
- npm install
- bower install
- mkdir travis-phantomjs
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs:$PATH

script:
- ember try $EMBER_TRY_SCENARIO test && mocha tests/**/*-test-node.js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Update notes:
import { Collection } from 'ember-cli-mirage';
let authors = schema.authors.all().models;
let topPosts = authors.map(a => a.topPost);
let topPosts = authors.map((a) => a.topPost);
return new Collection('post', topPosts);
```
Expand Down
1 change: 1 addition & 0 deletions addon/assert.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-console: 0 */
let errorProps = [
'description',
'fileName',
Expand Down
6 changes: 3 additions & 3 deletions addon/db-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class DbCollection {
* @param attributesForCreate
* @public
*/
firstOrCreate(query, attributesForCreate={}) {
firstOrCreate(query, attributesForCreate = {}) {
let queryResult = this.where(query);
let [ record ] = queryResult;
let [record] = queryResult;

if (record) {
return record;
Expand Down Expand Up @@ -258,7 +258,7 @@ class DbCollection {
_findRecord(id) {
id = id.toString();

let [ record ] = this._records.filter((obj) => obj.id === id);
let [record] = this._records.filter((obj) => obj.id === id);

return record;
}
Expand Down
3 changes: 1 addition & 2 deletions addon/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ let Factory = function() {
let keys = sortAttrs(topLevelAttrs, sequence);

keys.forEach(function(key) {
let buildAttrs;
let buildSingleValue;
let buildAttrs, buildSingleValue;

buildAttrs = function(attrs) {
return _mapValues(attrs, buildSingleValue);
Expand Down
9 changes: 4 additions & 5 deletions addon/orm/associations/has-many.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// jscs:disable requireParenthesesAroundArrowParam
import Association from './association';
import Collection from '../collection';
import _assign from 'lodash/assign';
Expand Down Expand Up @@ -75,7 +74,7 @@ class HasMany extends Association {
children.mergeCollection(savedChildren);
}

return children.models.map(model => model.id);
return children.models.map((model) => model.id);
},

/*
Expand Down Expand Up @@ -143,11 +142,11 @@ class HasMany extends Association {
schema[toCollectionName(association.modelName)].where(query).update(foreignKey, null);

// Save any children that are new
models.filter(model => model.isNew())
.forEach(model => model.save());
models.filter((model) => model.isNew())
.forEach((model) => model.save());

// Associate the new children to this model
schema[toCollectionName(association.modelName)].find(models.map(m => m.id)).update(foreignKey, this.id);
schema[toCollectionName(association.modelName)].find(models.map((m) => m.id)).update(foreignKey, this.id);

// Clear out any old cached children
association._cachedChildren = new Collection(association.modelName);
Expand Down
2 changes: 1 addition & 1 deletion addon/orm/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ export default class Collection {
* @public
*/
toString() {
return `collection:${this.modelName}(${this.models.map(m => m.id).join(',')})`;
return `collection:${this.modelName}(${this.models.map((m) => m.id).join(',')})`;
}
}
12 changes: 6 additions & 6 deletions addon/orm/model.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// jscs:disable requireParenthesesAroundArrowParam
import { toCollectionName } from 'ember-cli-mirage/utils/normalize-name';
import extend from '../utils/extend';
import assert from '../assert';
Expand Down Expand Up @@ -171,11 +170,11 @@ class Model {
_setupAttrs(attrs) {
// Verify no undefined associations are passed in
Object.keys(attrs)
.filter(key => {
.filter((key) => {
let value = attrs[key];
return (value instanceof Model || value instanceof Collection);
})
.forEach(key => {
.forEach((key) => {
let modelOrCollection = attrs[key];

assert(this.associationKeys.indexOf(key) > -1, `You're trying to create a ${this.modelName} model and you passed in a ${modelOrCollection.toString()} under the ${key} key, but you haven't defined that key as an association on your model.`);
Expand Down Expand Up @@ -229,7 +228,8 @@ class Model {
return this.attrs[attr];
},
set(val) {
this.attrs[attr] = val; return this;
this.attrs[attr] = val;
return this;
}
});
}
Expand Down Expand Up @@ -259,7 +259,7 @@ class Model {
* @private
*/
_saveAssociations() {
Object.keys(this.belongsToAssociations).forEach(key => {
Object.keys(this.belongsToAssociations).forEach((key) => {
let association = this.belongsToAssociations[key];
let parent = this[key];
if (parent && parent.isNew()) {
Expand All @@ -269,7 +269,7 @@ class Model {
}
});

Object.keys(this.hasManyAssociations).forEach(key => {
Object.keys(this.hasManyAssociations).forEach((key) => {
let association = this.hasManyAssociations[key];
let children = this[key];
children.update(association.getForeignKey(), this.id);
Expand Down
4 changes: 2 additions & 2 deletions addon/orm/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Schema {

// Update the registry with this association's foreign keys. This is
// essentially our "db migration", since we must know about the fks.
let [ fkHolder, fk ] = association.getForeignKeyArray();
let [fkHolder, fk] = association.getForeignKeyArray();

fksAddedFromThisModel[fkHolder] = fksAddedFromThisModel[fkHolder] || [];
assert(
Expand Down Expand Up @@ -197,7 +197,7 @@ export default class Schema {
*/
first(type) {
let collection = this._collectionForType(type);
let [ record ] = collection;
let [record] = collection;

return this._hydrate(record, dasherize(type));
}
Expand Down
2 changes: 1 addition & 1 deletion addon/response.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default class Response {

constructor(code, headers={}, data={}) {
constructor(code, headers = {}, data = {}) {
this.code = code;
this.headers = headers;
this.data = data;
Expand Down
8 changes: 4 additions & 4 deletions addon/route-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import HeadShorthandHandler from './route-handlers/shorthands/head';
const { RSVP: { Promise }, isBlank, typeOf } = Ember;

function isNotBlankResponse(response) {
return response &&
!(typeOf(response) === 'object' && Object.keys(response).length === 0) &&
(Array.isArray(response) || !isBlank(response));
return response
&& !(typeOf(response) === 'object' && Object.keys(response).length === 0)
&& (Array.isArray(response) || !isBlank(response));
}

const DEFAULT_CODES = { get: 200, put: 204, post: 201, 'delete': 204 };

function createHandler({ verb, schema, serializerOrRegistry, path, rawHandler, options }) {
let handler;
let args = [ schema, serializerOrRegistry, rawHandler, path, options ];
let args = [schema, serializerOrRegistry, rawHandler, path, options];
let type = typeOf(rawHandler);

if (type === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion addon/route-handlers/shorthands/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BaseRouteHandler from '../base';

export default class BaseShorthandRouteHandler extends BaseRouteHandler {

constructor(schema, serializerOrRegistry, shorthand, path, options={}) {
constructor(schema, serializerOrRegistry, shorthand, path, options = {}) {
super();
shorthand = shorthand || this.getModelClassFromPath(path);
this.schema = schema;
Expand Down
3 changes: 1 addition & 2 deletions addon/route-handlers/shorthands/delete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// jscs:disable requireParenthesesAroundArrowParam
import assert from 'ember-cli-mirage/assert';
import BaseShorthandRouteHandler from './base';
import { pluralize, camelize } from 'ember-cli-mirage/utils/inflector';
Expand Down Expand Up @@ -38,7 +37,7 @@ export default class DeleteShorthandRouteHandler extends BaseShorthandRouteHandl
.map((modelClass) => pluralize(modelClass.camelizedModelName));

// Delete related children
childTypes.forEach(type => parent[type].destroy());
childTypes.forEach((type) => parent[type].destroy());
parent.destroy();
}

Expand Down
9 changes: 4 additions & 5 deletions addon/serializer-registry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// jscs:disable requireParenthesesAroundArrowParam
import Model from 'ember-cli-mirage/orm/model';
import Collection from 'ember-cli-mirage/orm/collection';
import Serializer from 'ember-cli-mirage/serializer';
Expand Down Expand Up @@ -53,10 +52,10 @@ export default class SerializerRegistry {
SerializerForResponse = SerializerForResponse || this._serializerMap.application || Serializer;

assert(
!SerializerForResponse ||
(SerializerForResponse.prototype.embed) ||
(SerializerForResponse.prototype.root) ||
(new SerializerForResponse() instanceof JsonApiSerializer),
!SerializerForResponse
|| (SerializerForResponse.prototype.embed)
|| (SerializerForResponse.prototype.root)
|| (new SerializerForResponse() instanceof JsonApiSerializer),
'You cannot have a serializer that sideloads (embed: false) and disables the root (root: false).'
);
}
Expand Down
Loading

0 comments on commit 0104425

Please sign in to comment.