Skip to content

Commit f15e30a

Browse files
committed
fix: update prettier to allow optional chaining
Current version of prettier complains about optional chaining with ``` Parsing error: Expression expected ``` See prettier/prettier#7088 This prevents the last commit from passing the test suite The suggested fix of upgrading prettier fixes this issue. After upgrading ran `yarn eslint --ext js,ts --fix .` to fix new linting errors.
1 parent cb7aea1 commit f15e30a

File tree

23 files changed

+78
-80
lines changed

23 files changed

+78
-80
lines changed

config/deploy.js

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

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

config/environment.js

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

3-
module.exports = function(/* environment, appConfig */) {
3+
module.exports = function (/* environment, appConfig */) {
44
return {};
55
};

ember-cli-build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
44

5-
module.exports = function(defaults) {
5+
module.exports = function (defaults) {
66
let app = new EmberAddon(defaults, {
77
'ember-cli-babel': {
88
throwUnlessParallelizable: true,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"in-repo-b": "link:tests/dummy/lib/in-repo-b",
127127
"loader.js": "4.7.0",
128128
"mocha": "7.1.0",
129-
"prettier": "1.18.2",
129+
"prettier": "2.0.5",
130130
"prettier-eslint": "9.0.1",
131131
"qunit-dom": "1.1.0",
132132
"testdouble": "3.13.0",

tests/dummy/app/router.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ const Router = AddonDocsRouter.extend({
66
rootURL: config.rootURL,
77
});
88

9-
Router.map(function() {
10-
docsRoute(this, function() {
9+
Router.map(function () {
10+
docsRoute(this, function () {
1111
this.route('upgrade-notes');
1212
this.route('configuration');
13-
this.route('ts-guide', function() {
13+
this.route('ts-guide', function () {
1414
this.route('with-addons');
1515
this.route('using-ts-effectively');
1616
this.route('current-limitations');
1717
});
18-
this.route('troubleshooting', function() {
18+
this.route('troubleshooting', function () {
1919
this.route('conflicting-types');
2020
});
21-
this.route('type-defs', function() {
21+
this.route('type-defs', function () {
2222
this.route('package-names');
2323
});
2424
});

tests/dummy/config/environment.js

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

3-
module.exports = function(environment) {
3+
module.exports = function (environment) {
44
let ENV = {
55
modulePrefix: 'dummy',
66
environment,

tests/integration/components/js-importing-ts-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { setupRenderingTest } from 'ember-qunit';
33
import { render } from '@ember/test-helpers';
44
import hbs from 'htmlbars-inline-precompile';
55

6-
module('Integration | Component | js importing ts', function(hooks) {
6+
module('Integration | Component | js importing ts', function (hooks) {
77
setupRenderingTest(hooks);
88

9-
test('it renders', async function(assert) {
9+
test('it renders', async function (assert) {
1010
// Set any properties with this.set('myProperty', 'value');
1111
// Handle any actions with this.on('myAction', function(val) { ... });
1212

tests/integration/components/ts-component-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { setupRenderingTest } from 'ember-qunit';
33
import { render } from '@ember/test-helpers';
44
import hbs from 'htmlbars-inline-precompile';
55

6-
module('Integration | Component | ts component', function(hooks) {
6+
module('Integration | Component | ts component', function (hooks) {
77
setupRenderingTest(hooks);
88

9-
test('it renders', async function(assert) {
9+
test('it renders', async function (assert) {
1010
// Set any properties with this.set('myProperty', 'value');
1111
// Handle any actions with this.on('myAction', function(val) { ... });
1212

tests/unit/build-test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ import fileB from 'dummy/b';
77
import { description as fromAts } from 'in-repo-a/test-support/from-ats';
88
import { description as fromTs } from 'dummy/tests/from-ts';
99

10-
module('Unit | Build', function() {
11-
test("in-repo addons' addon trees wind up in the right place", function(assert) {
10+
module('Unit | Build', function () {
11+
test("in-repo addons' addon trees wind up in the right place", function (assert) {
1212
assert.equal(addonFileA, 'in-repo-a/test-file');
1313
assert.equal(addonFileB, 'in-repo-b/test-file');
1414
});
1515

16-
test("in-repo addons' app trees wind up in the right place", function(assert) {
16+
test("in-repo addons' app trees wind up in the right place", function (assert) {
1717
assert.equal(fileA, 'dummy/a');
1818
assert.equal(fileB, 'dummy/b');
1919
});
2020

21-
test("addon's addon-test-support files end up in <addon-name>/test-support/*", function(assert) {
21+
test("addon's addon-test-support files end up in <addon-name>/test-support/*", function (assert) {
2222
assert.ok(fromAts);
2323
assert.equal(fromAts, 'From addon-test-support');
2424
});
2525

26-
test("addon's test-support files end up in dummy/tests/*", function(assert) {
26+
test("addon's test-support files end up in dummy/tests/*", function (assert) {
2727
assert.ok(fromTs);
2828
assert.equal(fromTs, 'From test-support');
2929
});
3030

31-
test('property initialization occurs in the right order', function(assert) {
31+
test('property initialization occurs in the right order', function (assert) {
3232
class TestClass {
3333
// we shouldn't encourage folks to write code like this, but tsc ensures
3434
// that constructor param fields are set before field initializers run

tests/unit/helpers/js-help-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { jsHelp } from 'dummy/helpers/js-help';
22
import { module, test } from 'qunit';
33

4-
module('Unit | Helper | js help', function() {
4+
module('Unit | Helper | js help', function () {
55
// Replace this with your real tests.
6-
test('it works', function(assert) {
6+
test('it works', function (assert) {
77
let result = jsHelp([42]);
88
assert.ok(result);
99
});

tests/unit/helpers/typed-help-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { typedHelp } from 'dummy/helpers/typed-help';
22
import { module, test } from 'qunit';
33

4-
module('Unit | Helper | typed help', function() {
4+
module('Unit | Helper | typed help', function () {
55
// Replace this with your real tests.
6-
test('it works', function(assert) {
6+
test('it works', function (assert) {
77
let result = typedHelp([42]);
88
assert.ok(result);
99
});

ts/addon.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default addon({
120120
let checked = false;
121121
let stew = require('broccoli-stew') as typeof import('broccoli-stew');
122122

123-
return stew.afterBuild(input, function() {
123+
return stew.afterBuild(input, function () {
124124
if (!checked) {
125125
checked = true;
126126
addon._checkForFileCollisions(this.inputPaths[0]);
@@ -152,7 +152,7 @@ export default addon({
152152
},
153153

154154
_checkBabelVersion() {
155-
let babel = this.parent.addons.find(addon => addon.name === 'ember-cli-babel');
155+
let babel = this.parent.addons.find((addon) => addon.name === 'ember-cli-babel');
156156
let version = babel && babel.pkg.version;
157157
if (!babel || !(semver.gte(version!, '7.7.3') && semver.lt(version!, '8.0.0'))) {
158158
let versionString = babel ? `version ${babel.pkg.version}` : `no instance of ember-cli-babel`;
@@ -263,7 +263,7 @@ export default addon({
263263
let childProcess = fork(`${__dirname}/lib/typechecking/worker/launch`);
264264
let worker = await connect<TypecheckWorker>(childProcess);
265265

266-
await worker.onTypecheck(status => {
266+
await worker.onTypecheck((status) => {
267267
for (let error of status.errors) {
268268
this.ui.writeLine(error);
269269
}

ts/blueprints/ember-cli-typescript/index.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ module.exports = {
6868
}
6969

7070
return {
71-
includes: JSON.stringify(includes.map(include => `${include}/**/*`), null, 2).replace(
72-
/\n/g,
73-
'\n '
74-
),
75-
pathsFor: dasherizedName => {
71+
includes: JSON.stringify(
72+
includes.map((include) => `${include}/**/*`),
73+
null,
74+
2
75+
).replace(/\n/g, '\n '),
76+
pathsFor: (dasherizedName) => {
7677
// We need to wait to use this module until `ember-cli-typescript-blueprints` has been installed
7778
let updatePathsForAddon = require('ember-cli-typescript-blueprints/lib/utilities/update-paths-for-addon');
7879
let appName = isAddon ? 'dummy' : dasherizedName;
@@ -105,12 +106,12 @@ module.exports = {
105106

106107
return JSON.stringify(paths, null, 2).replace(/\n/g, '\n ');
107108
},
108-
indexDeclarations: dasherizedName => {
109+
indexDeclarations: (dasherizedName) => {
109110
const isDummyApp = dasherizedName === 'dummy';
110111
const useAppDeclarations = !(isAddon || isDummyApp);
111112
return useAppDeclarations ? APP_DECLARATIONS : '';
112113
},
113-
globalDeclarations: dasherizedName => {
114+
globalDeclarations: (dasherizedName) => {
114115
/** @type {'classic' | 'pods'} */
115116
let projectLayout;
116117
if (isPods) projectLayout = 'pods';
@@ -179,7 +180,7 @@ module.exports = {
179180
let files = this._super.files.apply(this, arguments);
180181

181182
if (!this._has('ember-data')) {
182-
files = files.filter(file => file !== 'types/ember-data/types/registries/model.d.ts');
183+
files = files.filter((file) => file !== 'types/ember-data/types/registries/model.d.ts');
183184
}
184185

185186
return files;

ts/lib/commands/precompile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default command({
5353
// Ensure that if we are dealing with an addon that is using a different
5454
// addon name from its package name, we use the addon name, since that is
5555
// how it will be written for imports.
56-
let addon = this.project.addons.find(addon => addon.root === this.project.root);
56+
let addon = this.project.addons.find((addon) => addon.root === this.project.root);
5757
if (addon && addon.name !== packageName) {
5858
packageName = addon.name;
5959
}

ts/lib/typechecking/worker/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class TypecheckWorker {
112112

113113
private formatDiagnostic(diagnostic: Diagnostic) {
114114
return this.ts.formatDiagnosticsWithColorAndContext([diagnostic], {
115-
getCanonicalFileName: path => path,
115+
getCanonicalFileName: (path) => path,
116116
getCurrentDirectory: this.ts.sys.getCurrentDirectory,
117117
getNewLine: () => this.ts.sys.newLine,
118118
});
@@ -174,7 +174,7 @@ export default class TypecheckWorker {
174174
return createProgram.apply(host, params);
175175
};
176176

177-
host.afterProgramCreate = program => {
177+
host.afterProgramCreate = (program) => {
178178
// The `afterProgramCreate` callback will be invoked synchronously when we first call
179179
// `createWatchProgram`, meaning we can enter `didTypecheck` before we're fully set up
180180
// (e.g. before `compilerOptions` has been set). We use `nextTick` to ensure that
@@ -188,7 +188,7 @@ export default class TypecheckWorker {
188188
}
189189

190190
private makeStatus(diagnostics: ReadonlyArray<Diagnostic>): TypecheckStatus {
191-
let errors = diagnostics.map(d => this.formatDiagnostic(d));
191+
let errors = diagnostics.map((d) => this.formatDiagnostic(d));
192192
let failed = !!(this.compilerOptions.noEmitOnError && errors.length);
193193
return { errors, failed };
194194
}

ts/lib/utilities/copy-declarations.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ export default function copyDeclarations(
1515
logicalPath.startsWith(`${packageName}/`) &&
1616
logicalPath.indexOf('/*') === logicalPath.length - 2
1717
) {
18-
let subdirectory = logicalPath
19-
.replace(packageName, '')
20-
.replace('/*', '')
21-
.replace(/^\//, '');
18+
let subdirectory = logicalPath.replace(packageName, '').replace('/*', '').replace(/^\//, '');
2219

2320
copySubpathDeclarations(output, pathRoots, path.join(destDir, subdirectory), physicalPaths);
2421
}

ts/tests/acceptance/build-test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import {
1313

1414
const { expect } = chai;
1515

16-
describe('Acceptance: build', function() {
16+
describe('Acceptance: build', function () {
1717
this.timeout(60 * 1000);
1818
let app: SkeletonApp;
19-
beforeEach(function() {
19+
beforeEach(function () {
2020
app = new SkeletonApp();
2121
});
2222

23-
afterEach(function() {
23+
afterEach(function () {
2424
app.teardown();
2525
});
2626

@@ -104,7 +104,7 @@ describe('Acceptance: build', function() {
104104

105105
it('emits a warning when .js and .ts files conflict in the app/ tree', async () => {
106106
// Set up an in-repo addon
107-
app.updatePackageJSON(pkg => {
107+
app.updatePackageJSON((pkg) => {
108108
pkg['ember-addon'].paths.push('lib/in-repo-addon');
109109
});
110110

@@ -153,9 +153,9 @@ function extractModuleBody(script: string, moduleName: string) {
153153
let parsed = esprima.parseScript(script);
154154
let [definition] = parsed.body
155155
.filter(isExpressionStatement)
156-
.map(stmt => stmt.expression)
156+
.map((stmt) => stmt.expression)
157157
.filter(isSpecialCallExpression)
158-
.filter(expr => expr.arguments[0].value === moduleName);
158+
.filter((expr) => expr.arguments[0].value === moduleName);
159159
if (!definition) throw new Error('Definition for call expression not found');
160160
let moduleDef = definition.arguments[2].body;
161161

ts/tests/blueprints/ember-cli-typescript-test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ import ects from '../../blueprints/ember-cli-typescript/index';
1111
const expect = chaiHelpers.expect;
1212
const file = chaiHelpers.file;
1313

14-
describe('Acceptance: ember-cli-typescript generator', function() {
14+
describe('Acceptance: ember-cli-typescript generator', function () {
1515
helpers.setupTestHooks(this, {
1616
disabledTasks: ['addon-install', 'bower-install'],
1717
});
1818

1919
const originalTaskForFn = Blueprint.prototype.taskFor;
2020

21-
beforeEach(function() {
22-
Blueprint.prototype.taskFor = function(taskName) {
21+
beforeEach(function () {
22+
Blueprint.prototype.taskFor = function (taskName) {
2323
if (taskName === 'npm-install') {
2424
// Mock npm-install that only modifies package.json
2525
return {
26-
run: function(options: { packages: string[] }) {
26+
run: function (options: { packages: string[] }) {
2727
let pkgJson = fs.readJsonSync('package.json');
28-
options.packages.forEach(function(pkg) {
28+
options.packages.forEach(function (pkg) {
2929
let pkgName = pkg.match(/^(.*)@[^@]*$/);
3030
if (!pkgName) throw new Error(`Improperly-formatted package name: ${pkgName}`);
3131
pkgJson['devDependencies'][pkgName[1]] = '*';
@@ -38,7 +38,7 @@ describe('Acceptance: ember-cli-typescript generator', function() {
3838
};
3939
});
4040

41-
afterEach(function() {
41+
afterEach(function () {
4242
Blueprint.prototype.taskFor = originalTaskForFn;
4343
});
4444

@@ -149,7 +149,7 @@ describe('Acceptance: ember-cli-typescript generator', function() {
149149
expect(emberDataCatchallTypes).not.to.exist;
150150
});
151151

152-
it('moves from devDependencies to dependencies for addons', async function() {
152+
it('moves from devDependencies to dependencies for addons', async function () {
153153
const args = ['ember-cli-typescript'];
154154

155155
await helpers.emberNew({ target: 'addon' });
@@ -280,7 +280,7 @@ describe('Acceptance: ember-cli-typescript generator', function() {
280280
]);
281281
});
282282

283-
describe('ember-mocha', function() {
283+
describe('ember-mocha', function () {
284284
it('app with ember-cli-mocha', async () => {
285285
const args = ['ember-cli-typescript'];
286286

ts/tests/commands/clean-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const emberNew = blueprintHelpers.emberNew;
99
const chai = require('ember-cli-blueprint-test-helpers/chai');
1010
const expect = chai.expect;
1111

12-
describe('Acceptance: ts:clean command', function() {
12+
describe('Acceptance: ts:clean command', function () {
1313
setupTestHooks(this);
1414

1515
beforeEach(async () => {

0 commit comments

Comments
 (0)