Skip to content

Commit b1c256b

Browse files
authored
Merge pull request #763 from ember-learn/jw-ct-refactor
Update this app to latest Ember and Ember Data
2 parents 1a56b06 + e4f9c4d commit b1c256b

File tree

153 files changed

+6892
-5843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+6892
-5843
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# misc
1414
/coverage/
1515
!.*
16+
.eslintcache
1617

1718
# ember-try
1819
/.node_modules.ember-try/

.eslintrc.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,38 @@ module.exports = {
77
ecmaVersion: 2018,
88
sourceType: 'module',
99
ecmaFeatures: {
10-
legacyDecorators: true
11-
}
10+
legacyDecorators: true,
11+
},
1212
},
13-
plugins: [
14-
'ember'
15-
],
13+
plugins: ['ember'],
1614
extends: [
1715
'eslint:recommended',
18-
'plugin:ember/recommended'
16+
'plugin:ember/recommended',
17+
'plugin:prettier/recommended',
1918
],
2019
env: {
21-
browser: true
20+
browser: true,
2221
},
2322
rules: {
2423
'ember/no-jquery': 'off',
2524
'no-console': 'off',
26-
'ember/no-new-mixins': 'off'
25+
'ember/no-new-mixins': 'off',
26+
'ember/no-mixins': 'off',
27+
'ember/native-classes': 'off',
28+
'ember/require-tagless-components': 'off',
29+
'ember/no-test-this-render': 'off',
30+
'ember/no-classic-classes': 'off',
31+
'ember/no-get': 'off',
32+
'ember/no-actions-hash': 'off',
33+
'ember/no-classic-components': 'off',
34+
'ember/no-private-routing-service': 'off',
2735
},
2836
overrides: [
2937
// node files
3038
{
3139
files: [
3240
'.eslintrc.js',
41+
'.prettierrc.js',
3342
'.template-lintrc.js',
3443
'ember-cli-build.js',
3544
'testem.js',
@@ -43,20 +52,19 @@ module.exports = {
4352
excludedFiles: ['config/deprecation-workflow.js'],
4453
parserOptions: {
4554
sourceType: 'script',
46-
ecmaVersion: 2017
55+
ecmaVersion: 2017,
4756
},
4857
env: {
4958
browser: false,
50-
node: true
59+
node: true,
5160
},
5261
plugins: ['node'],
53-
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
54-
// add your custom rules and overrides for node files here
55-
62+
extends: ['plugin:node/recommended'],
63+
rules: {
5664
// this can be removed once the following is fixed
5765
// https://github.com/mysticatea/eslint-plugin-node/issues/77
58-
'node/no-unpublished-require': 'off'
59-
})
60-
}
61-
]
66+
'node/no-unpublished-require': 'off',
67+
},
68+
},
69+
],
6270
};

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ jobs:
7979
if: steps.cache-dependencies.outputs.cache-hit != 'true'
8080

8181
- name: Test
82-
uses: percy/[email protected]
83-
with:
84-
custom-command: yarn test:ember
8582
env:
8683
PERCY_PARALLEL_NONCE: ${{ env.PERCY_PARALLEL_NONCE }}
8784
PERCY_PARALLEL_TOTAL: ${{ env.PERCY_PARALLEL_TOTAL }}
8885
PERCY_TOKEN: 5ad6687f6b1ad3dec2b964f94d3d59ff3880baccf1492c0663e85c1ce79c1a52
86+
run: yarn run percy exec -- yarn test:ember

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ terraform.tfstate.backup
2121
/.env*
2222
/.pnp*
2323
/.sass-cache
24+
/.eslintcache
2425
/connect.lock
2526
/coverage/
2627
/libpeerconnection.log

.prettierignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# unconventional js
2+
/blueprints/*/files/
3+
/vendor/
4+
5+
# compiled output
6+
/dist/
7+
/tmp/
8+
9+
# dependencies
10+
/bower_components/
11+
/node_modules/
12+
13+
# misc
14+
/coverage/
15+
!.*
16+
.eslintcache
17+
18+
# ember-try
19+
/.node_modules.ember-try/
20+
/bower.json.ember-try
21+
/package.json.ember-try

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
singleQuote: true,
5+
};

.template-lintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module.exports = {
1010
'no-implicit-this': false,
1111
'no-curly-component-invocation': false,
1212
'no-action': false,
13-
quotes: false
14-
}
13+
quotes: false,
14+
'no-link-to-positional-params': false,
15+
'require-input-label': false,
16+
},
1517
};

app/adapters/application.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { pluralize } from 'ember-inflector';
66
import { isBlank } from '@ember/utils';
77

88
export default JSONAPIAdapter.extend({
9-
109
host: ENV.API_HOST,
1110

1211
currentProject: '',
@@ -26,7 +25,9 @@ export default JSONAPIAdapter.extend({
2625
}
2726
return; // return undefined so auto determinated
2827
},
29-
shouldBackgroundReloadAll() { return false; },
28+
shouldBackgroundReloadAll() {
29+
return false;
30+
},
3031
shouldBackgroundReloadRecord(store, { modelName, id }) {
3132
let key = `${modelName}-${id}`;
3233
let hasId = this.ids[key];
@@ -59,14 +60,18 @@ export default JSONAPIAdapter.extend({
5960

6061
if (typeof revId !== 'undefined') {
6162
let encodedRevId = encodeURIComponent(revId);
62-
url = `json-docs/${projectName}/${version}/${pluralize(modelNameToUse)}/${encodedRevId}`;
63+
url = `json-docs/${projectName}/${version}/${pluralize(
64+
modelNameToUse
65+
)}/${encodedRevId}`;
6366
} else {
6467
throw new Error('Documentation item not found');
6568
}
6669
} else if (modelName === 'missing') {
6770
let version = this.get('projectService.version');
6871
let revId = this.metaStore.getRevId(projectName, version, modelName, id);
69-
url = `json-docs/${projectName}/${version}/${pluralize(modelName)}/${revId}`;
72+
url = `json-docs/${projectName}/${version}/${pluralize(
73+
modelName
74+
)}/${revId}`;
7075
} else if (modelName === 'project') {
7176
this.currentProject = id;
7277
url = `rev-index/${id}`;
@@ -82,6 +87,5 @@ export default JSONAPIAdapter.extend({
8287
let response = await fetch(url);
8388
let json = await response.json();
8489
return json;
85-
}
86-
90+
},
8791
});

app/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Application from '@ember/application';
22
import Resolver from 'ember-resolver';
33
import loadInitializers from 'ember-load-initializers';
4-
import config from './config/environment';
4+
import config from 'ember-api-docs/config/environment';
55

66
export default class App extends Application {
77
modulePrefix = config.modulePrefix;

app/components/api-index-filter.js

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,78 @@ import { computed } from '@ember/object';
22
import Component from '@ember/component';
33
import sortBy from 'lodash.sortby';
44

5-
const filterDataComputedParams = 'filterData.{showInherited,showProtected,showPrivate,showDeprecated}';
5+
const filterDataComputedParams =
6+
'filterData.{showInherited,showProtected,showPrivate,showDeprecated}';
67

78
export default Component.extend({
89
classNames: ['api-index-filter'],
910

10-
filteredMethods: computed('model.methods.[]', filterDataComputedParams,
11-
function() {
11+
filteredMethods: computed(
12+
'model.methods.[]',
13+
filterDataComputedParams,
14+
function () {
1215
return this.filterItems('methods');
13-
}),
16+
}
17+
),
1418

15-
filteredEvents: computed('model.events.[]', filterDataComputedParams,
16-
function() {
19+
filteredEvents: computed(
20+
'model.events.[]',
21+
filterDataComputedParams,
22+
function () {
1723
return this.filterItems('events');
18-
}),
24+
}
25+
),
1926

20-
filteredProperties: computed('model.properties.[]', filterDataComputedParams,
21-
function() {
27+
filteredProperties: computed(
28+
'model.properties.[]',
29+
filterDataComputedParams,
30+
function () {
2231
return this.filterItems('properties');
23-
}),
32+
}
33+
),
2434

2535
filterItems(itemType) {
26-
let items = this.getWithDefault(`model.${itemType}`, []);
36+
let items =
37+
this.get(`model.${itemType}`) === undefined
38+
? []
39+
: this.get(`model.${itemType}`);
2740
if (!this.get('filterData.showInherited')) {
28-
items = items.filter(item => item.inherited !== true);
41+
items = items.filter((item) => item.inherited !== true);
2942
}
3043
if (!this.get('filterData.showProtected')) {
31-
items = items.filter(item => item.access !== 'protected');
44+
items = items.filter((item) => item.access !== 'protected');
3245
}
3346
if (!this.get('filterData.showPrivate')) {
34-
items = items.filter(item => item.access !== 'private');
47+
items = items.filter((item) => item.access !== 'private');
3548
}
3649
if (!this.get('filterData.showDeprecated')) {
37-
items = items.filter(item => item.deprecated !== true);
50+
items = items.filter((item) => item.deprecated !== true);
3851
}
3952

40-
let sortedItems = sortBy(items, (item => item.name));
53+
let sortedItems = sortBy(items, (item) => item.name);
4154
return this.filterMultipleInheritance(sortedItems);
4255
},
4356

44-
filteredData: computed('filteredMethods', 'filteredProperties', 'filteredEvents', function() {
45-
return {
46-
methods: this.filteredMethods,
47-
properties: this.filteredProperties,
48-
events: this.filteredEvents
49-
};
50-
}),
57+
filteredData: computed(
58+
'filteredMethods',
59+
'filteredProperties',
60+
'filteredEvents',
61+
function () {
62+
return {
63+
methods: this.filteredMethods,
64+
properties: this.filteredProperties,
65+
events: this.filteredEvents,
66+
};
67+
}
68+
),
5169

5270
/**
53-
* Returns an array where duplicate methods (by name) are removed.
54-
* The docs for the nearest inheritance are typically more helpful to users,
55-
* so in cases of duplicates, "more local" is preferred.
56-
* Without this, multiple entries for some methods will show up.
57-
* @method filterMultipleInheritance
58-
*/
71+
* Returns an array where duplicate methods (by name) are removed.
72+
* The docs for the nearest inheritance are typically more helpful to users,
73+
* so in cases of duplicates, "more local" is preferred.
74+
* Without this, multiple entries for some methods will show up.
75+
* @method filterMultipleInheritance
76+
*/
5977
filterMultipleInheritance(items) {
6078
let dedupedArray = [];
6179
for (let i = 0; i < items.length; i++) {
@@ -67,7 +85,7 @@ export default Component.extend({
6785
let nextItem = items[i + 1];
6886
if (currentItem.name === nextItem.name) {
6987
// if the method would be listed twice, find the more local documentation
70-
let mostLocal = this.findMostLocal(currentItem, nextItem)
88+
let mostLocal = this.findMostLocal(currentItem, nextItem);
7189
dedupedArray.push(mostLocal);
7290
i += 1; // skip the next item with duplicate name
7391
} else {
@@ -78,11 +96,11 @@ export default Component.extend({
7896
return dedupedArray;
7997
},
8098
/**
81-
* Returns whichever item is most local.
82-
* What is "most local" is determined by looking at the file path for the
83-
* method, the file path for the class being viewed, and the parent if needed.
84-
* @method findMostLocal
85-
*/
99+
* Returns whichever item is most local.
100+
* What is "most local" is determined by looking at the file path for the
101+
* method, the file path for the class being viewed, and the parent if needed.
102+
* @method findMostLocal
103+
*/
86104
findMostLocal(currentItem, nextItem) {
87105
let currentScope = this.get('model.file');
88106
let parentClassScope = this.get('model.parentClass.file');
@@ -96,5 +114,5 @@ export default Component.extend({
96114
// otherwise, the next item must be "more local"
97115
return nextItem;
98116
}
99-
}
100-
})
117+
},
118+
});

app/components/api-index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,29 @@ import { computed } from '@ember/object';
22
import Component from '@ember/component';
33

44
export default Component.extend({
5-
65
sections: computed('itemData.{methods,properties,events}', function () {
76
return [
87
{
98
title: 'Methods',
109
tab: 'methods',
1110
items: this.get('itemData.methods'),
1211
class: 'spec-method-list',
13-
routeSuffix: '.methods.method'
12+
routeSuffix: '.methods.method',
1413
},
1514
{
1615
title: 'Properties',
1716
tab: 'properties',
1817
items: this.get('itemData.properties'),
1918
class: 'spec-property-list',
20-
routeSuffix: '.properties.property'
19+
routeSuffix: '.properties.property',
2120
},
2221
{
2322
title: 'Events',
2423
tab: 'events',
2524
items: this.get('itemData.events'),
2625
class: 'spec-event-list',
27-
routeSuffix: '.events.event'
28-
}
26+
routeSuffix: '.events.event',
27+
},
2928
];
30-
})
29+
}),
3130
});

app/components/class-field-description.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ export default Component.extend({
66
legacyModuleMappings: service(),
77

88
hasImportExample: computed('field.{name,class}', function () {
9-
return this.legacyModuleMappings.hasFunctionMapping(this.get('field.name'), this.get('field.class'));
9+
return this.legacyModuleMappings.hasFunctionMapping(
10+
this.get('field.name'),
11+
this.get('field.class')
12+
);
1013
}),
1114

1215
/**
@@ -15,5 +18,5 @@ export default Component.extend({
1518
* @method updateAnchor
1619
* @method fieldName String The name representing the field that was clicked.
1720
*/
18-
updateAnchor() {}
21+
updateAnchor() {},
1922
});

0 commit comments

Comments
 (0)