Skip to content

Commit e68a982

Browse files
authored
Merge pull request #737 from Turbo87/prettier
Use `prettier` to format JS files
2 parents 1fc03d2 + 03e58dc commit e68a982

Some content is hidden

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

68 files changed

+1490
-1174
lines changed

.eslintrc.js

+16-21
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ 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
overrides: [
2524
// node files
2625
{
2726
files: [
2827
'.eslintrc.js',
28+
'.prettierrc.js',
2929
'.template-lintrc.js',
3030
'ember-cli-build.js',
3131
'index.js',
@@ -36,7 +36,7 @@ module.exports = {
3636
'blueprints/*/index.js',
3737
'config/**/*.js',
3838
'tests/dummy/config/**/*.js',
39-
'lib/**/*'
39+
'lib/**/*',
4040
],
4141
excludedFiles: [
4242
'addon/**',
@@ -45,31 +45,26 @@ module.exports = {
4545
'tests/dummy/app/**',
4646
],
4747
parserOptions: {
48-
sourceType: 'script'
48+
sourceType: 'script',
4949
},
5050
env: {
5151
browser: false,
52-
node: true
52+
node: true,
5353
},
5454
plugins: ['node'],
55-
extends: ['plugin:node/recommended']
55+
extends: ['plugin:node/recommended'],
5656
},
5757
{
58-
files: [
59-
'node-tests/**/*',
60-
],
61-
excludedFiles: [
62-
'testem.multiple-test-page.js'
63-
],
58+
files: ['node-tests/**/*'],
59+
excludedFiles: ['testem.multiple-test-page.js'],
6460
parserOptions: {
6561
ecmaVersion: 2018,
6662
},
6763
env: {
6864
node: true,
6965
mocha: true,
7066
},
71-
rules: {
72-
}
73-
}
74-
]
67+
rules: {},
68+
},
69+
],
7570
};

.prettierignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
.lint-todo/
18+
19+
# ember-try
20+
/.node_modules.ember-try/
21+
/bower.json.ember-try
22+
/npm-shrinkwrap.json.ember-try
23+
/package.json.ember-try
24+
/package-lock.json.ember-try
25+
/yarn.lock.ember-try

.prettierrc.js

+5
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

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

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

addon-test-support/-private/async-iterator.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ export default class AsyncIterator {
3939
* @return {String} the stringified value of the iterator.
4040
*/
4141
toString() {
42-
return `<AsyncIterator (request: ${this._request} response: ${
43-
this._response
44-
})>`;
42+
return `<AsyncIterator (request: ${this._request} response: ${this._response})>`;
4543
}
4644

4745
/**
@@ -113,16 +111,14 @@ export default class AsyncIterator {
113111

114112
if (this._emberExamExitOnError) {
115113
let err = new Error(
116-
`EmberExam: Promise timed out after ${
117-
this._timeout
118-
} s while waiting for response for ${this._request}`
114+
`EmberExam: Promise timed out after ${this._timeout} s while waiting for response for ${this._request}`
119115
);
120116
reject(err);
121117
} else {
122118
// eslint-disable-next-line no-console
123-
console.error(`EmberExam: Promise timed out after ${
124-
this._timeout
125-
} s while waiting for response for ${this._request}. Closing browser to exit gracefully.`);
119+
console.error(
120+
`EmberExam: Promise timed out after ${this._timeout} s while waiting for response for ${this._request}. Closing browser to exit gracefully.`
121+
);
126122
resolve(iteratorCompleteResponse);
127123
}
128124
}, this._timeout * 1000);
@@ -153,7 +149,7 @@ export default class AsyncIterator {
153149
this._current = {
154150
resolve,
155151
reject,
156-
promise
152+
promise,
157153
};
158154

159155
this._makeNextRequest();

addon-test-support/-private/ember-exam-mocha-test-loader.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import getUrlParams from './get-url-params';
22
import splitTestModules from './split-test-modules';
3-
import { filterTestModules} from './filter-test-modules';
3+
import { filterTestModules } from './filter-test-modules';
44
import { TestLoader } from 'ember-mocha/test-loader';
55

66
/**
@@ -28,7 +28,7 @@ export default class EmberExamMochaTestLoader extends TestLoader {
2828
* @method load
2929
*/
3030
static load() {
31-
throw new Error('`EmberExamMochaTestLoader` doesn\'t support `load()`.');
31+
throw new Error("`EmberExamMochaTestLoader` doesn't support `load()`.");
3232
}
3333

3434
/**

addon-test-support/-private/ember-exam-qunit-test-loader.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class EmberExamQUnitTestLoader extends TestLoader {
3333
* @method load
3434
*/
3535
static load() {
36-
throw new Error('`EmberExamQUnitTestLoader` doesn\'t support `load()`.');
36+
throw new Error("`EmberExamQUnitTestLoader` doesn't support `load()`.");
3737
}
3838

3939
/**
@@ -178,8 +178,13 @@ export default class EmberExamQUnitTestLoader extends TestLoader {
178178
return nextModuleHandler();
179179
}
180180
}
181-
}).catch(e => {
182-
if (typeof e === 'object' && e !== null && typeof e.message === 'string') {
181+
})
182+
.catch((e) => {
183+
if (
184+
typeof e === 'object' &&
185+
e !== null &&
186+
typeof e.message === 'string'
187+
) {
183188
e.message = `EmberExam: Failed to get next test module: ${e.message}`;
184189
}
185190
throw new Error(`EmberExam: Failed to get next test module: ${e}`);

addon-test-support/-private/filter-test-modules.js

+31-13
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const TEST_PATH_REGEX = /\/tests\/(.*?)$/;
1010
* @param {*} modulePath
1111
*/
1212
function getRegexFilter(modulePath) {
13-
return MODULE_PATH_REGEXP.exec( modulePath );
13+
return MODULE_PATH_REGEXP.exec(modulePath);
1414
}
1515

1616
/**
@@ -23,7 +23,11 @@ function getRegexFilter(modulePath) {
2323
*/
2424
function wildcardFilter(module, moduleFilter) {
2525
// Generate a regular expression to handle wildcard from path filter
26-
const moduleFilterRule = ['^.*', moduleFilter.split('*').join('.*'), '$'].join('');
26+
const moduleFilterRule = [
27+
'^.*',
28+
moduleFilter.split('*').join('.*'),
29+
'$',
30+
].join('');
2731
return new RegExp(moduleFilterRule).test(module);
2832
}
2933

@@ -35,7 +39,10 @@ function wildcardFilter(module, moduleFilter) {
3539
* @param {string} moduleFilter
3640
*/
3741
function stringFilter(modules, moduleFilter) {
38-
return modules.filter( module => module.includes(moduleFilter) || wildcardFilter(module, moduleFilter) );
42+
return modules.filter(
43+
(module) =>
44+
module.includes(moduleFilter) || wildcardFilter(module, moduleFilter)
45+
);
3946
}
4047

4148
/**
@@ -49,7 +56,9 @@ function regexFilter(modules, modulePathRegexFilter) {
4956
const re = new RegExp(modulePathRegexFilter[2], modulePathRegexFilter[3]);
5057
const exclude = modulePathRegexFilter[1];
5158

52-
return modules.filter( module => !exclude && re.test(module) || exclude && !re.test(module) );
59+
return modules.filter(
60+
(module) => (!exclude && re.test(module)) || (exclude && !re.test(module))
61+
);
5362
}
5463

5564
/**
@@ -60,7 +69,7 @@ function regexFilter(modules, modulePathRegexFilter) {
6069
*/
6170
function convertFilePathToModulePath(filePath) {
6271
const filePathWithNoExtension = filePath.replace(/\.[^/.]+$/, '');
63-
const testFilePathMatch = TEST_PATH_REGEX.exec( filePathWithNoExtension );
72+
const testFilePathMatch = TEST_PATH_REGEX.exec(filePathWithNoExtension);
6473
if (typeof filePath !== 'undefined' && testFilePathMatch !== null) {
6574
return testFilePathMatch[0];
6675
}
@@ -78,26 +87,35 @@ function convertFilePathToModulePath(filePath) {
7887
*/
7988
function filterTestModules(modules, modulePath, filePath) {
8089
// Generates an array with module filter value seperated by comma (,).
81-
const moduleFilters = (filePath || modulePath).split(',').map( value => value.trim());
90+
const moduleFilters = (filePath || modulePath)
91+
.split(',')
92+
.map((value) => value.trim());
8293

8394
const filteredTestModules = moduleFilters.reduce((result, moduleFilter) => {
8495
const modulePath = convertFilePathToModulePath(moduleFilter);
8596
const modulePathRegex = getRegexFilter(modulePath);
8697

8798
if (modulePathRegex) {
88-
return result.concat(regexFilter(modules, modulePathRegex).filter( module => result.indexOf(module) === -1 ));
99+
return result.concat(
100+
regexFilter(modules, modulePathRegex).filter(
101+
(module) => result.indexOf(module) === -1
102+
)
103+
);
89104
} else {
90-
return result.concat(stringFilter(modules, modulePath).filter( module => result.indexOf(module) === -1 ));
105+
return result.concat(
106+
stringFilter(modules, modulePath).filter(
107+
(module) => result.indexOf(module) === -1
108+
)
109+
);
91110
}
92111
}, []);
93112

94113
if (filteredTestModules.length === 0) {
95-
throw new Error(`No tests matched with the filter: ${modulePath || filePath}.`);
114+
throw new Error(
115+
`No tests matched with the filter: ${modulePath || filePath}.`
116+
);
96117
}
97118
return filteredTestModules;
98119
}
99120

100-
export {
101-
convertFilePathToModulePath,
102-
filterTestModules
103-
}
121+
export { convertFilePathToModulePath, filterTestModules };

addon-test-support/-private/get-test-loader.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { dependencySatisfies, macroCondition, importSync } from '@embroider/macros';
1+
import {
2+
dependencySatisfies,
3+
macroCondition,
4+
importSync,
5+
} from '@embroider/macros';
26

37
/**
48
* Returns ember-exam-qunit-test-loader or ember-exam-mocha-test-loader
@@ -8,11 +12,15 @@ import { dependencySatisfies, macroCondition, importSync } from '@embroider/macr
812
* @return {Object}
913
*/
1014
export default function getTestLoader() {
11-
if (macroCondition(dependencySatisfies('ember-qunit', '*'))){
12-
const EmberExamQUnitTestLoader = importSync('./ember-exam-qunit-test-loader');
15+
if (macroCondition(dependencySatisfies('ember-qunit', '*'))) {
16+
const EmberExamQUnitTestLoader = importSync(
17+
'./ember-exam-qunit-test-loader'
18+
);
1319
return EmberExamQUnitTestLoader['default'];
14-
} else if (macroCondition(dependencySatisfies('ember-mocha', '*'))){
15-
const EmberExamMochaTestLoader = importSync('./ember-exam-mocha-test-loader');
20+
} else if (macroCondition(dependencySatisfies('ember-mocha', '*'))) {
21+
const EmberExamMochaTestLoader = importSync(
22+
'./ember-exam-mocha-test-loader'
23+
);
1624
return EmberExamMochaTestLoader['default'];
1725
}
1826

addon-test-support/-private/split-test-modules.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ export default function splitTestModules(modules, split, partitions) {
5151
const partition = parseInt(partitions[i], 10);
5252
if (isNaN(partition)) {
5353
throw new Error(
54-
'You must specify numbers for partition (you specified \'' +
54+
"You must specify numbers for partition (you specified '" +
5555
partitions +
56-
'\')'
56+
"')"
5757
);
5858
}
5959

addon-test-support/-private/weight-test-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const TEST_TYPE_WEIGHT = {
22
eslint: 1,
33
unit: 10,
44
integration: 20,
5-
acceptance: 150
5+
acceptance: 150,
66
};
77
const WEIGHT_REGEX = /\/(eslint|unit|integration|acceptance)\//;
88
const DEFAULT_WEIGHT = 50;

addon-test-support/start.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import loadEmberExam from 'ember-exam/test-support/load';
2-
import { dependencySatisfies, macroCondition, importSync } from '@embroider/macros';
2+
import {
3+
dependencySatisfies,
4+
macroCondition,
5+
importSync,
6+
} from '@embroider/macros';
37

48
/**
59
* Equivalent to ember-qunit or ember-mocha's loadTest() except this does not create a new TestLoader instance
@@ -32,7 +36,7 @@ export default function start(qunitOptions) {
3236
loadTests(testLoader);
3337

3438
let emberTestFramework;
35-
if (macroCondition(dependencySatisfies('ember-qunit', '*'))){
39+
if (macroCondition(dependencySatisfies('ember-qunit', '*'))) {
3640
emberTestFramework = importSync('ember-qunit');
3741
} else if (macroCondition(dependencySatisfies('ember-mocha', '*'))) {
3842
emberTestFramework = importSync('ember-mocha');

config/deploy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-env node */
22
'use strict';
33

4-
module.exports = function(deployTarget) {
4+
module.exports = function (deployTarget) {
55
let ENV = {
6-
build: {}
6+
build: {},
77
// include other plugin configuration that applies to all deploy targets here
88
};
99

0 commit comments

Comments
 (0)