Skip to content

Commit

Permalink
yarn eslint --fix .
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed May 9, 2018
1 parent 1ae7502 commit 5ae301c
Show file tree
Hide file tree
Showing 253 changed files with 23,955 additions and 18,292 deletions.
9 changes: 7 additions & 2 deletions addon/-debug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ if (DEBUG) {
return modelClass.detect(addedModelClass);
};

assertPolymorphicType = function assertPolymorphicType(parentInternalModel, relationshipMeta, addedInternalModel, store) {
assertPolymorphicType = function assertPolymorphicType(
parentInternalModel,
relationshipMeta,
addedInternalModel,
store
) {
let addedModelName = addedInternalModel.modelName;
let parentModelName = parentInternalModel.modelName;
let key = relationshipMeta.key;
Expand All @@ -53,4 +58,4 @@ if (DEBUG) {
};
}

export { assertPolymorphicType }
export { assertPolymorphicType };
26 changes: 18 additions & 8 deletions addon/-private/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,17 @@ export default Mixin.create({

if (modelName) {
path = this.pathForType(modelName);
if (path) { url.push(path); }
if (path) {
url.push(path);
}
}

if (id) { url.push(encodeURIComponent(id)); }
if (prefix) { url.unshift(prefix); }
if (id) {
url.push(encodeURIComponent(id));
}
if (prefix) {
url.unshift(prefix);
}

url = url.join('/');
if (!host && url && url.charAt(0) !== '/') {
Expand Down Expand Up @@ -392,19 +398,23 @@ export default Mixin.create({
// Do nothing, the full host is already included.
return path;

// Absolute path
// Absolute path
} else if (path.charAt(0) === '/') {
return `${host}${path}`;
// Relative path
// Relative path
} else {
return `${parentURL}/${path}`;
}
}

// No path provided
let url = [];
if (host) { url.push(host); }
if (namespace) { url.push(namespace); }
if (host) {
url.push(host);
}
if (namespace) {
url.push(namespace);
}
return url.join('/');
},

Expand Down Expand Up @@ -439,5 +449,5 @@ export default Mixin.create({
pathForType(modelName) {
let camelized = camelize(modelName);
return pluralize(camelized);
}
},
});
29 changes: 16 additions & 13 deletions addon/-private/adapters/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export function AdapterError(errors, message = 'Adapter operation failed') {
this.errors = errors || [
{
title: 'Adapter Error',
detail: message
}
detail: message,
},
];
}

Expand Down Expand Up @@ -165,8 +165,10 @@ AdapterError.extend = extendFn(AdapterError);
@class InvalidError
@namespace DS
*/
export const InvalidError = extend(AdapterError,
'The adapter rejected the commit because it was invalid');
export const InvalidError = extend(
AdapterError,
'The adapter rejected the commit because it was invalid'
);

/**
A `DS.TimeoutError` is used by an adapter to signal that a request
Expand Down Expand Up @@ -200,8 +202,7 @@ export const InvalidError = extend(AdapterError,
@class TimeoutError
@namespace DS
*/
export const TimeoutError = extend(AdapterError,
'The adapter operation timed out');
export const TimeoutError = extend(AdapterError, 'The adapter operation timed out');

/**
A `DS.AbortError` is used by an adapter to signal that a request to
Expand All @@ -212,8 +213,7 @@ export const TimeoutError = extend(AdapterError,
@class AbortError
@namespace DS
*/
export const AbortError = extend(AdapterError,
'The adapter operation was aborted');
export const AbortError = extend(AdapterError, 'The adapter operation was aborted');

/**
A `DS.UnauthorizedError` equates to a HTTP `401 Unauthorized` response
Expand Down Expand Up @@ -320,7 +320,10 @@ export const ConflictError = extend(AdapterError, 'The adapter operation failed
@class ServerError
@namespace DS
*/
export const ServerError = extend(AdapterError, 'The adapter operation failed due to a server error');
export const ServerError = extend(
AdapterError,
'The adapter operation failed due to a server error'
);

/**
Convert an hash of errors into an array with errors in JSON-API format.
Expand Down Expand Up @@ -372,7 +375,7 @@ export function errorsHashToArray(errors) {
let out = [];

if (isPresent(errors)) {
Object.keys(errors).forEach((key) => {
Object.keys(errors).forEach(key => {
let messages = makeArray(errors[key]);
for (let i = 0; i < messages.length; i++) {
let title = 'Invalid Attribute';
Expand All @@ -385,8 +388,8 @@ export function errorsHashToArray(errors) {
title: title,
detail: messages[i],
source: {
pointer: pointer
}
pointer: pointer,
},
});
}
});
Expand Down Expand Up @@ -439,7 +442,7 @@ export function errorsArrayToHash(errors) {
let out = {};

if (isPresent(errors)) {
errors.forEach((error) => {
errors.forEach(error => {
if (error.source && error.source.pointer) {
let key = error.source.pointer.match(SOURCE_POINTER_REGEXP);

Expand Down
14 changes: 7 additions & 7 deletions addon/-private/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ function getDefaultValue(record, options, key) {
return options.defaultValue.apply(null, arguments);
} else {
let defaultValue = options.defaultValue;
assert(`Non primitive defaultValues are not supported because they are shared between all instances. If you would like to use a complex object as a default value please provide a function that returns the complex object.`,
typeof defaultValue !== 'object' || defaultValue === null);
assert(
`Non primitive defaultValues are not supported because they are shared between all instances. If you would like to use a complex object as a default value please provide a function that returns the complex object.`,
typeof defaultValue !== 'object' || defaultValue === null
);
return defaultValue;
}
}

function hasValue(record, key) {
return key in record._attributes ||
key in record._inFlightAttributes ||
key in record._data;
return key in record._attributes || key in record._inFlightAttributes || key in record._data;
}

/**
Expand Down Expand Up @@ -118,7 +118,7 @@ export default function attr(type, options) {
let meta = {
type: type,
isAttribute: true,
options: options
options: options,
};

return computed({
Expand All @@ -132,6 +132,6 @@ export default function attr(type, options) {
},
set(key, value) {
return this._internalModel.setDirtyAttribute(key, value);
}
},
}).meta(meta);
}
2 changes: 1 addition & 1 deletion addon/-private/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import VERSION from 'ember-data/version';
*/
const DS = Ember.Namespace.create({
VERSION: VERSION,
name: "DS"
name: 'DS',
});

if (Ember.libraries) {
Expand Down
19 changes: 7 additions & 12 deletions addon/-private/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// public
export { default as Model } from './system/model/model';
export { default as Errors } from './system/model/errors';
export { default as Store } from './system/store';
export { default as Store } from './system/store';
export { default as DS } from './core';
export { default as belongsTo } from './system/relationships/belongs-to';
export { default as hasMany } from './system/relationships/has-many';
Expand All @@ -19,7 +19,7 @@ export {
TimeoutError,
AbortError,
errorsHashToArray,
errorsArrayToHash
errorsArrayToHash,
} from './adapters/errors';

// maybe public ?
Expand All @@ -33,16 +33,9 @@ export { default as isEnabled } from './features';
export { default as RootState } from './system/model/states';
export { default as InternalModel } from './system/model/internal-model';

export {
PromiseArray,
PromiseObject,
PromiseManyArray
} from './system/promise-proxies';
export { PromiseArray, PromiseObject, PromiseManyArray } from './system/promise-proxies';

export {
RecordArray,
AdapterPopulatedRecordArray
} from './system/record-arrays';
export { RecordArray, AdapterPopulatedRecordArray } from './system/record-arrays';

export { default as ManyArray } from './system/many-array';
export { default as RecordArrayManager } from './system/record-array-manager';
Expand All @@ -56,6 +49,8 @@ export { default as DebugAdapter } from './system/debug/debug-adapter';

// Used by tests
export { default as diffArray } from './system/diff-array';
export { default as RelationshipPayloadsManager } from './system/relationships/relationship-payloads-manager';
export {
default as RelationshipPayloadsManager,
} from './system/relationships/relationship-payloads-manager';
export { default as RelationshipPayloads } from './system/relationships/relationship-payloads';
export { default as SnapshotRecordArray } from './system/snapshot-record-array';
6 changes: 5 additions & 1 deletion addon/-private/system/backburner.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Ember from 'ember';
import { DEBUG } from '@glimmer/env';

const backburner = new Ember._Backburner(['normalizeRelationships', 'syncRelationships', 'finished']);
const backburner = new Ember._Backburner([
'normalizeRelationships',
'syncRelationships',
'finished',
]);

if (DEBUG) {
Ember.Test.registerWaiter(() => {
Expand Down
8 changes: 6 additions & 2 deletions addon/-private/system/coerce-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// ID into the URL, and if we later try to deserialize that URL and find the
// corresponding record, we will not know if it is a string or a number.
export default function coerceId(id) {
if (id === null || id === undefined || id === '') { return null; }
if (typeof id === 'string') { return id; }
if (id === null || id === undefined || id === '') {
return null;
}
if (typeof id === 'string') {
return id;
}
return '' + id;
}
35 changes: 21 additions & 14 deletions addon/-private/system/debug/debug-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default DataAdapter.extend({
return [
{ name: 'isNew', desc: 'New' },
{ name: 'isModified', desc: 'Modified' },
{ name: 'isClean', desc: 'Clean' }
{ name: 'isClean', desc: 'Clean' },
];
},

Expand All @@ -32,14 +32,18 @@ export default DataAdapter.extend({
},

columnsForType(typeClass) {
let columns = [{
name: 'id',
desc: 'Id'
}];
let columns = [
{
name: 'id',
desc: 'Id',
},
];
let count = 0;
let self = this;
get(typeClass, 'attributes').forEach((meta, name) => {
if (count++ > self.attributeLimit) { return false; }
if (count++ > self.attributeLimit) {
return false;
}
let desc = capitalize(underscore(name).replace('_', ' '));
columns.push({ name: name, desc: desc });
});
Expand All @@ -57,15 +61,18 @@ export default DataAdapter.extend({
}
}
}
assert("Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support", !!modelName);
assert(
'Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support',
!!modelName
);
return this.get('store').peekAll(modelName);
},

getRecordColumnValues(record) {
let count = 0;
let columnValues = { id: get(record, 'id') };

record.eachAttribute((key) => {
record.eachAttribute(key => {
if (count++ > this.attributeLimit) {
return false;
}
Expand All @@ -77,16 +84,16 @@ export default DataAdapter.extend({
getRecordKeywords(record) {
let keywords = [];
let keys = A(['id']);
record.eachAttribute((key) => keys.push(key));
keys.forEach((key) => keywords.push(get(record, key)));
record.eachAttribute(key => keys.push(key));
keys.forEach(key => keywords.push(get(record, key)));
return keywords;
},

getRecordFilterValues(record) {
return {
isNew: record.get('isNew'),
isModified: record.get('hasDirtyAttributes') && !record.get('isNew'),
isClean: !record.get('hasDirtyAttributes')
isClean: !record.get('hasDirtyAttributes'),
};
},

Expand All @@ -104,7 +111,7 @@ export default DataAdapter.extend({
let releaseMethods = A();
let keysToObserve = A(['id', 'isNew', 'hasDirtyAttributes']);

record.eachAttribute((key) => keysToObserve.push(key));
record.eachAttribute(key => keysToObserve.push(key));
let adapter = this;

keysToObserve.forEach(function(key) {
Expand All @@ -118,9 +125,9 @@ export default DataAdapter.extend({
});

let release = function() {
releaseMethods.forEach((fn) => fn());
releaseMethods.forEach(fn => fn());
};

return release;
}
},
});
Loading

0 comments on commit 5ae301c

Please sign in to comment.