Skip to content

Commit e86ae76

Browse files
committed
Update linting dependencies and fix lint errors
1 parent b8a0fc9 commit e86ae76

File tree

97 files changed

+1261
-974
lines changed

Some content is hidden

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

97 files changed

+1261
-974
lines changed

Diff for: packages/ember-cli-fastboot/.eslintrc.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ module.exports = {
1717
'plugin:prettier/recommended',
1818
],
1919
env: {
20-
browser: true
20+
browser: true,
2121
},
2222
rules: {
23+
'ember/no-classic-classes': 'warn',
2324
'ember/no-get': 'warn',
24-
'ember/require-computed-property-dependencies': 'warn'
25+
'ember/require-computed-property-dependencies': 'warn',
2526
},
26-
rules: {},
2727
overrides: [
2828
// node files
2929
{
@@ -37,7 +37,11 @@ module.exports = {
3737
'blueprints/*/index.js',
3838
'config/**/*.js',
3939
'tests/dummy/config/**/*.js',
40-
'lib/**/*.js'
40+
'lib/**/*.js',
41+
'test/*.js',
42+
'test/**/ember-cli-build.js',
43+
'test/**/config/**/*.js',
44+
'test/**/lib/**/*.js',
4145
],
4246
excludedFiles: [
4347
'app/**',
@@ -56,5 +60,11 @@ module.exports = {
5660
plugins: ['node'],
5761
extends: ['plugin:node/recommended'],
5862
},
63+
{
64+
// mocha test files
65+
files: ['test/*-test.{js,ts}'],
66+
plugins: ['mocha'],
67+
extends: ['plugin:mocha/recommended'],
68+
},
5969
],
6070
};

Diff for: packages/ember-cli-fastboot/.template-lintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

33
module.exports = {
4-
extends: 'octane',
4+
extends: 'recommended',
55
};

Diff for: packages/ember-cli-fastboot/addon/instance-initializers/clear-double-boot.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function clearHtml() {
1313
if (current && endMarker) {
1414
let shoeboxNodes = document.querySelectorAll('[type="fastboot/shoebox"]');
1515
let shoeboxNodesArray = []; // Note that IE11 doesn't support more concise options like Array.from, so we have to do something like this
16-
for(let i=0; i < shoeboxNodes.length; i++){
16+
for (let i = 0; i < shoeboxNodes.length; i++) {
1717
shoeboxNodesArray.push(shoeboxNodes[i]);
1818
}
1919
let parent = current.parentElement;
@@ -22,21 +22,25 @@ export function clearHtml() {
2222
nextNode = current.nextSibling;
2323
parent.removeChild(current);
2424
current = nextNode;
25-
} while (nextNode && nextNode !== endMarker && shoeboxNodesArray.indexOf(nextNode) < 0);
25+
} while (
26+
nextNode &&
27+
nextNode !== endMarker &&
28+
shoeboxNodesArray.indexOf(nextNode) < 0
29+
);
2630
endMarker.parentElement.removeChild(endMarker);
2731
}
2832
}
2933
export default {
30-
name: "clear-double-boot",
34+
name: 'clear-double-boot',
3135

3236
initialize(instance) {
3337
if (typeof FastBoot === 'undefined') {
3438
var originalDidCreateRootView = instance.didCreateRootView;
3539

36-
instance.didCreateRootView = function() {
40+
instance.didCreateRootView = function () {
3741
clearHtml();
3842
originalDidCreateRootView.apply(instance, arguments);
3943
};
4044
}
41-
}
42-
}
45+
},
46+
};

Diff for: packages/ember-cli-fastboot/addon/locations/none.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { computed, get } from '@ember/object';
22
import { bool, readOnly } from '@ember/object/computed';
33
import { inject as service } from '@ember/service';
4-
import { getOwner } from '@ember/application'
5-
import NoneLocation from '@ember/routing/none-location'
4+
import { getOwner } from '@ember/application';
5+
import NoneLocation from '@ember/routing/none-location';
66

77
const TEMPORARY_REDIRECT_CODE = 307;
88

@@ -16,17 +16,19 @@ export default NoneLocation.extend({
1616

1717
_fastbootHeadersEnabled: bool('_config.fastboot.fastbootHeaders'),
1818

19-
_redirectCode: computed(function () {
20-
return get(this, '_config.fastboot.redirectCode') || TEMPORARY_REDIRECT_CODE;
19+
_redirectCode: computed('_config.fastboot.redirectCode', function () {
20+
return (
21+
get(this, '_config.fastboot.redirectCode') || TEMPORARY_REDIRECT_CODE
22+
);
2123
}),
2224

2325
_response: readOnly('fastboot.response'),
2426
_request: readOnly('fastboot.request'),
2527

2628
setURL(path) {
2729
if (get(this, 'fastboot.isFastBoot')) {
28-
let response = get(this, '_response');
29-
let currentPath = get(this, 'path');
30+
let response = this._response;
31+
let currentPath = this.path;
3032
let isInitialPath = !currentPath || currentPath.length === 0;
3133

3234
if (!isInitialPath) {
@@ -37,17 +39,17 @@ export default NoneLocation.extend({
3739
let host = get(this, '_request.host');
3840
let redirectURL = `//${host}${path}`;
3941

40-
response.statusCode = this.get('_redirectCode');
42+
response.statusCode = this._redirectCode;
4143
response.headers.set('location', redirectURL);
4244
}
4345
}
4446

4547
// for testing and debugging
46-
if (get(this, '_fastbootHeadersEnabled')) {
48+
if (this._fastbootHeadersEnabled) {
4749
response.headers.set('x-fastboot-path', path);
4850
}
4951
}
5052

5153
this._super(...arguments);
52-
}
54+
},
5355
});

Diff for: packages/ember-cli-fastboot/addon/services/fastboot.js

+38-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* global FastBoot */
2+
import { set } from '@ember/object';
23
import { getOwner } from '@ember/application';
34
import { computed, get } from '@ember/object';
45
import { readOnly } from '@ember/object/computed';
@@ -20,58 +21,72 @@ const RequestObject = EObject.extend({
2021
this.queryParams = request.queryParams;
2122
this.path = request.path;
2223
this.protocol = request.protocol;
23-
this._host = function() {
24+
this._host = function () {
2425
return request.host();
2526
};
2627
},
2728

28-
host: computed(function() {
29+
host: computed(function () {
2930
return this._host();
30-
})
31+
}),
3132
});
3233

3334
const Shoebox = EObject.extend({
3435
put(key, value) {
35-
assert('shoebox.put is only invoked from the FastBoot rendered application', this.get('fastboot.isFastBoot'));
36+
assert(
37+
'shoebox.put is only invoked from the FastBoot rendered application',
38+
this.get('fastboot.isFastBoot')
39+
);
3640
assert('the provided key is a string', typeof key === 'string');
3741

3842
let fastbootInfo = this.get('fastboot._fastbootInfo');
39-
if (!fastbootInfo.shoebox) { fastbootInfo.shoebox = {}; }
43+
if (!fastbootInfo.shoebox) {
44+
fastbootInfo.shoebox = {};
45+
}
4046

4147
fastbootInfo.shoebox[key] = value;
4248
},
4349

4450
retrieve(key) {
4551
if (this.get('fastboot.isFastBoot')) {
4652
let shoebox = this.get('fastboot._fastbootInfo.shoebox');
47-
if (!shoebox) { return; }
53+
if (!shoebox) {
54+
return;
55+
}
4856

4957
return shoebox[key];
5058
}
5159

5260
let shoeboxItem = this.get(key);
53-
if (shoeboxItem) { return shoeboxItem; }
61+
if (shoeboxItem) {
62+
return shoeboxItem;
63+
}
5464

5565
let el = document.querySelector(`#shoebox-${key}`);
56-
if (!el) { return; }
66+
if (!el) {
67+
return;
68+
}
5769
let valueString = el.textContent;
58-
if (!valueString) { return; }
70+
if (!valueString) {
71+
return;
72+
}
5973

6074
shoeboxItem = JSON.parse(valueString);
6175
this.set(key, shoeboxItem);
6276

6377
return shoeboxItem;
64-
}
78+
},
6579
});
6680

6781
const FastBootService = Service.extend({
6882
isFastBoot: typeof FastBoot !== 'undefined',
6983

70-
isFastboot: computed(function() {
84+
isFastboot: computed(function () {
7185
assert(
7286
'The fastboot service does not have an `isFastboot` property. This is likely a typo. Please use `isFastBoot` instead.',
7387
false
7488
);
89+
return;
7590
}),
7691

7792
init() {
@@ -84,13 +99,15 @@ const FastBootService = Service.extend({
8499
response: readOnly('_fastbootInfo.response'),
85100
metadata: readOnly('_fastbootInfo.metadata'),
86101

87-
request: computed(function() {
102+
request: computed('_fastbootInfo.request', 'isFastBoot', function () {
88103
if (!this.isFastBoot) return null;
89-
return RequestObject.create({ request: get(this, '_fastbootInfo.request') });
104+
return RequestObject.create({
105+
request: get(this, '_fastbootInfo.request'),
106+
});
90107
}),
91108

92109
// this getter/setter pair is to avoid deprecation from [RFC - 680](https://github.com/emberjs/rfcs/pull/680)
93-
_fastbootInfo: computed({
110+
_fastbootInfo: computed('__fastbootInfo', {
94111
get() {
95112
if (this.__fastbootInfo) {
96113
return this.__fastbootInfo;
@@ -99,15 +116,18 @@ const FastBootService = Service.extend({
99116
return getOwner(this).lookup('info:-fastboot');
100117
},
101118
set(_key, value) {
102-
this.__fastbootInfo = value;
119+
set(this, '__fastbootInfo', value);
103120
return value;
104-
}
121+
},
105122
}),
106123

107124
deferRendering(promise) {
108-
assert('deferRendering requires a promise or thennable object', typeof promise.then === 'function');
125+
assert(
126+
'deferRendering requires a promise or thennable object',
127+
typeof promise.then === 'function'
128+
);
109129
this._fastbootInfo.deferRendering(promise);
110-
}
130+
},
111131
});
112132

113133
export default FastBootService;

Diff for: packages/ember-cli-fastboot/blueprints/ember-cli-fastboot/index.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@ module.exports = {
99
},
1010

1111
afterInstall() {
12-
let targetsFile = './config/targets.js'
12+
let targetsFile = './config/targets.js';
1313

14-
if(this.project.isEmberCLIAddon()) {
14+
if (this.project.isEmberCLIAddon()) {
1515
targetsFile = './tests/dummy/config/targets.js';
1616
}
1717

1818
const targetsAst = recast.parse(readFileSync(targetsFile));
1919

2020
recast.visit(targetsAst, {
21-
visitAssignmentExpression (path) {
21+
visitAssignmentExpression(path) {
2222
let node = path.node;
2323

24-
if (node.left.object.name === 'module' && node.left.property.name === 'exports') {
25-
let nodeProperty = node.right.properties.find(property => property.key.name === 'node');
24+
if (
25+
node.left.object.name === 'module' &&
26+
node.left.property.name === 'exports'
27+
) {
28+
let nodeProperty = node.right.properties.find(
29+
(property) => property.key.name === 'node'
30+
);
2631

27-
if(!nodeProperty) {
32+
if (!nodeProperty) {
2833
let builders = recast.types.builders;
2934
nodeProperty = builders.property(
3035
'init',
@@ -36,9 +41,12 @@ module.exports = {
3641
}
3742

3843
this.traverse(path);
39-
}
44+
},
4045
});
4146

42-
writeFileSync(targetsFile, recast.print(targetsAst, { tabWidth: 2, quote: 'single' }).code);
43-
}
47+
writeFileSync(
48+
targetsFile,
49+
recast.print(targetsAst, { tabWidth: 2, quote: 'single' }).code
50+
);
51+
},
4452
};
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
/*globals Ember, URL*/
1+
/* globals Ember */
22
export default {
3-
name: "dom-helper-patches",
3+
name: 'dom-helper-patches',
44

5-
initialize: function(App) {
5+
initialize: function () {
66
// TODO: remove me
7-
Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function(url) {
7+
Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function (url) {
88
var protocol = URL.parse(url).protocol;
9-
return (protocol == null) ? ':' : protocol;
9+
return protocol == null ? ':' : protocol;
1010
};
1111

1212
// TODO: remove me https://github.com/tildeio/htmlbars/pull/425
13-
Ember.HTMLBars.DOMHelper.prototype.parseHTML = function(html) {
13+
Ember.HTMLBars.DOMHelper.prototype.parseHTML = function (html) {
1414
return this.document.createRawHTMLSection(html);
1515
};
16-
}
16+
},
1717
};

0 commit comments

Comments
 (0)