Skip to content

Commit 05628f4

Browse files
committed
chore: apply eslint func-style rule
1 parent cf06b47 commit 05628f4

6 files changed

+166
-168
lines changed

src/run-context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ export class RunContextBase<GeneratorType extends BaseGenerator = DefaultGenerat
760760
.catch(error => {
761761
if (this.listenerCount('end') === 0 && this.listenerCount('error') === 0) {
762762
// When there is no listeners throw a unhandled rejection.
763-
setImmediate(async function () {
763+
setImmediate(async () => {
764764
throw error;
765765
});
766766
} else {

src/run-result.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { type AskedQuestions } from './adapter.js';
1313

1414
const isObject = object => typeof object === 'object' && object !== null && object !== undefined;
1515

16-
function convertArguments(arguments_) {
16+
const convertArguments = arguments_ => {
1717
if (arguments_.length > 1) {
1818
return [[...arguments_]];
1919
}
2020

2121
const [argument] = arguments_;
2222
return Array.isArray(argument) ? argument : [argument];
23-
}
23+
};
2424

2525
/**
2626
* Provides options for `RunResult`s.

test/adapter.spec.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ import assert from 'node:assert';
22
import { describe, expect, it } from 'esmocha';
33
import { TestAdapter } from '../src/adapter.js';
44

5-
describe('TestAdapter', function () {
6-
describe('#prompt()', function () {
7-
it('allows pre-filled answers', async function () {
5+
describe('TestAdapter', () => {
6+
describe('#prompt()', () => {
7+
it('allows pre-filled answers', async () => {
88
const adapter = new TestAdapter();
99
return adapter
1010
.prompt([{ name: 'respuesta', message: 'foo', type: 'input', default: 'bar' }], {
1111
respuesta: 'foo',
1212
})
13-
.then(function (answers) {
13+
.then(answers => {
1414
assert.equal(answers.respuesta, 'foo');
1515
});
1616
});
1717
});
18-
describe('#queue()', function () {
19-
it('should execute the callback', async function () {
18+
describe('#queue()', () => {
19+
it('should execute the callback', async () => {
2020
const adapter = new TestAdapter();
2121
await expect(adapter.queue(() => 2)).resolves.toBe(2);
2222
});
2323
});
24-
describe('#progress()', function () {
25-
it('should execute the callback', async function () {
24+
describe('#progress()', () => {
25+
it('should execute the callback', async () => {
2626
const adapter = new TestAdapter();
2727
await expect(
2828
adapter.progress(({ step }) => {

test/helpers.spec.ts

+39-39
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
1919
const { resolve, join } = path;
2020
const environment = await createEnvironment({ adapter: new TestAdapter() });
2121

22-
describe('yeoman-test', function () {
22+
describe('yeoman-test', () => {
2323
beforeEach(function () {
2424
process.chdir(join(__dirname, './fixtures'));
2525

2626
this.StubGenerator = class extends Generator {};
2727
});
2828

29-
describe('.createGenerator()', function () {
29+
describe('.createGenerator()', () => {
3030
it('create a new generator', async function () {
3131
const generator = await helpers.createGenerator('unicorn:app', {
3232
dependencies: [[this.StubGenerator, { namespace: 'unicorn:app' }]],
@@ -57,79 +57,79 @@ describe('yeoman-test', function () {
5757
});
5858
});
5959

60-
describe('.mockPrompt()', function () {
60+
describe('.mockPrompt()', () => {
6161
beforeEach(async function () {
6262
this.generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
6363
helpers.mockPrompt(this.generator, { answer: 'foo' });
6464
});
6565

6666
it('uses default values', function () {
67-
return this.generator.prompt([{ name: 'respuesta', type: 'input', default: 'bar' }]).then(function (answers) {
67+
return this.generator.prompt([{ name: 'respuesta', type: 'input', default: 'bar' }]).then(answers => {
6868
assert.equal(answers.respuesta, 'bar');
6969
});
7070
});
7171

72-
it('uses default values when no answer is passed', async function () {
72+
it('uses default values when no answer is passed', async () => {
7373
const generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
7474
helpers.mockPrompt(generator);
75-
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'input', default: 'bar' }]).then(function (answers) {
75+
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'input', default: 'bar' }]).then(answers => {
7676
assert.equal(answers.respuesta, 'bar');
7777
});
7878
});
7979

80-
it('supports `null` answer for `list` type', async function () {
80+
it('supports `null` answer for `list` type', async () => {
8181
const generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
8282

8383
helpers.mockPrompt(generator, {
8484
respuesta: null,
8585
});
8686

87-
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'list', default: 'bar' }]).then(function (answers) {
87+
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'list', default: 'bar' }]).then(answers => {
8888
assert.equal(answers.respuesta, null);
8989
});
9090
});
9191

92-
it('treats `null` as no answer for `input` type', async function () {
92+
it('treats `null` as no answer for `input` type', async () => {
9393
const generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
9494

9595
helpers.mockPrompt(generator, {
9696
respuesta: null,
9797
});
9898

99-
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'input', default: 'bar' }]).then(function (answers) {
99+
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'input', default: 'bar' }]).then(answers => {
100100
assert.equal(answers.respuesta, 'bar');
101101
});
102102
});
103103

104-
it('uses `true` as the default value for `confirm` type', async function () {
104+
it('uses `true` as the default value for `confirm` type', async () => {
105105
const generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
106106
helpers.mockPrompt(generator, {});
107107

108-
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'confirm' }]).then(function (answers) {
108+
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'confirm' }]).then(answers => {
109109
assert.equal(answers.respuesta, true);
110110
});
111111
});
112112

113-
it('supports `false` answer for `confirm` type', async function () {
113+
it('supports `false` answer for `confirm` type', async () => {
114114
const generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
115115
helpers.mockPrompt(generator, { respuesta: false });
116116

117-
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'confirm' }]).then(function (answers) {
117+
return generator.prompt([{ name: 'respuesta', message: 'foo', type: 'confirm' }]).then(answers => {
118118
assert.equal(answers.respuesta, false);
119119
});
120120
});
121121

122122
it('prefers mocked values over defaults', function () {
123-
return this.generator.prompt([{ name: 'answer', type: 'input', default: 'bar' }]).then(function (answers) {
123+
return this.generator.prompt([{ name: 'answer', type: 'input', default: 'bar' }]).then(answers => {
124124
assert.equal(answers.answer, 'foo');
125125
});
126126
});
127127

128-
it('can be call multiple time on the same generator', async function () {
128+
it('can be call multiple time on the same generator', async () => {
129129
const generator = await environment.instantiate(helpers.createDummyGenerator(), { generatorArgs: [], generatorOptions: {} });
130130
helpers.mockPrompt(generator, { foo: 1 });
131131
helpers.mockPrompt(generator, { foo: 2 });
132-
return generator.prompt({ message: 'bar', name: 'foo' }).then(function (answers) {
132+
return generator.prompt({ message: 'bar', name: 'foo' }).then(answers => {
133133
assert.equal(answers.foo, 2);
134134
});
135135
});
@@ -148,7 +148,7 @@ describe('yeoman-test', function () {
148148
it('keep prompt method asynchronous', function () {
149149
const spy = mock.fn();
150150

151-
const promise = this.generator.prompt({ name: 'answer', type: 'input' }).then(function () {
151+
const promise = this.generator.prompt({ name: 'answer', type: 'input' }).then(() => {
152152
assert.strictEqual(spy.mock.callCount(), 1);
153153
});
154154

@@ -157,17 +157,17 @@ describe('yeoman-test', function () {
157157
});
158158
});
159159

160-
describe('.run()', function () {
161-
describe('with a generator', function () {
162-
it('return a RunContext object', function (done) {
160+
describe('.run()', () => {
161+
describe('with a generator', () => {
162+
it('return a RunContext object', done => {
163163
const context = helpers.run(helpers.createDummyGenerator());
164164
assert(context instanceof RunContext);
165165
context.on('end', done);
166166
});
167167
});
168168

169-
describe('with a namespace', function () {
170-
it('return a RunContext object', function (done) {
169+
describe('with a namespace', () => {
170+
it('return a RunContext object', done => {
171171
const context = helpers.run('simple:app').withEnvironment(environment => {
172172
environment.register(require.resolve('./fixtures/generator-simple/app'));
173173
});
@@ -176,20 +176,20 @@ describe('yeoman-test', function () {
176176
});
177177
});
178178

179-
it('pass settings to RunContext', function () {
179+
it('pass settings to RunContext', () => {
180180
const runContext = helpers.run(helpers.createDummyGenerator(), {
181181
namespace: 'foo',
182182
});
183183
assert.equal(runContext.settings.namespace, 'foo');
184184
});
185185

186-
it('pass envOptions to RunContext', function () {
186+
it('pass envOptions to RunContext', () => {
187187
const environmentOptions = { foo: 2 };
188188
const runContext = helpers.run(helpers.createDummyGenerator(), undefined, environmentOptions);
189189
assert.equal(runContext.envOptions, environmentOptions);
190190
});
191191

192-
it('catch env errors', function (done) {
192+
it('catch env errors', done => {
193193
helpers
194194
.run(
195195
class extends helpers.createDummyGenerator() {
@@ -203,7 +203,7 @@ describe('yeoman-test', function () {
203203
});
204204
});
205205

206-
it('catch generator emitted errors', function (done) {
206+
it('catch generator emitted errors', done => {
207207
helpers
208208
.run(
209209
class extends helpers.createDummyGenerator() {
@@ -217,7 +217,7 @@ describe('yeoman-test', function () {
217217
});
218218
});
219219

220-
it('catch generator thrown errors', function (done) {
220+
it('catch generator thrown errors', done => {
221221
helpers
222222
.run(
223223
class extends helpers.createDummyGenerator() {
@@ -233,14 +233,14 @@ describe('yeoman-test', function () {
233233

234234
// This is a workaround for corner case were an error is not correctly emitted
235235
// See https://github.com/yeoman/generator/pull/1155
236-
it('catch run errors', function (done) {
236+
it('catch run errors', done => {
237237
helpers.run(class extends Generator {}, {}, { catchGeneratorError: true }).on('error', _ => {
238238
done();
239239
});
240240
});
241241

242-
describe('with files', function () {
243-
it('write files to mem-fs', async function () {
242+
describe('with files', () => {
243+
it('write files to mem-fs', async () => {
244244
const runResult = await helpers.run(helpers.createDummyGenerator()).withFiles({ 'foo.txt': 'foo', 'foo.json': { foo: 'bar' } });
245245
expect(runResult.getSnapshot()).toMatchInlineSnapshot(`
246246
{
@@ -259,7 +259,7 @@ describe('yeoman-test', function () {
259259
`);
260260
});
261261

262-
it('write files with relative path to mem-fs', async function () {
262+
it('write files with relative path to mem-fs', async () => {
263263
const runResult = await helpers
264264
.run(helpers.createDummyGenerator())
265265
.withFiles('sub', { 'foo.txt': 'foo', 'foo.json': { foo: 'bar' } });
@@ -280,7 +280,7 @@ describe('yeoman-test', function () {
280280
`);
281281
});
282282

283-
it('write string .yo-rc.json to mem-fs', async function () {
283+
it('write string .yo-rc.json to mem-fs', async () => {
284284
const runResult = await helpers.run(helpers.createDummyGenerator()).withYoRc('{"foo": "bar"}');
285285
expect(runResult.getSnapshot()).toMatchInlineSnapshot(`
286286
{
@@ -292,7 +292,7 @@ describe('yeoman-test', function () {
292292
`);
293293
});
294294

295-
it('write object .yo-rc.json to mem-fs', async function () {
295+
it('write object .yo-rc.json to mem-fs', async () => {
296296
const runResult = await helpers.run(helpers.createDummyGenerator()).withYoRc({ foo: 'bar' });
297297
expect(runResult.getSnapshot()).toMatchInlineSnapshot(`
298298
{
@@ -307,7 +307,7 @@ describe('yeoman-test', function () {
307307
`);
308308
});
309309

310-
it('merges object .yo-rc.json to mem-fs', async function () {
310+
it('merges object .yo-rc.json to mem-fs', async () => {
311311
const runResult = await helpers.run(helpers.createDummyGenerator()).withYoRc({ foo: 'bar' }).withYoRc({ bar: 'foo' });
312312
expect(runResult.getSnapshot()).toMatchInlineSnapshot(`
313313
{
@@ -323,7 +323,7 @@ describe('yeoman-test', function () {
323323
`);
324324
});
325325

326-
it('writes object GeneratorConfig to mem-fs', async function () {
326+
it('writes object GeneratorConfig to mem-fs', async () => {
327327
const runResult = await helpers
328328
.run(helpers.createDummyGenerator())
329329
.withYoRcConfig('ns', { foo: 'bar' })
@@ -346,7 +346,7 @@ describe('yeoman-test', function () {
346346
`);
347347
});
348348

349-
it('write files to mem-fs', async function () {
349+
it('write files to mem-fs', async () => {
350350
const runResult = await helpers
351351
.run(helpers.createDummyGenerator())
352352
.withFiles({ 'foo.txt': 'foo', 'foo.json': { foo: 'bar' } })
@@ -356,8 +356,8 @@ describe('yeoman-test', function () {
356356
});
357357
});
358358

359-
describe('callbacks', function () {
360-
it('calls in order', async function () {
359+
describe('callbacks', () => {
360+
it('calls in order', async () => {
361361
const order: string[] = [];
362362

363363
const runContext = helpers.run(helpers.createDummyGenerator());

test/run-context-environment.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SimpleApp from './fixtures/generator-simple/app/index.js';
1414
const require = createRequire(import.meta.url);
1515
const __dirname = dirname(fileURLToPath(import.meta.url));
1616

17-
describe('RunContext running environment', function () {
17+
describe('RunContext running environment', () => {
1818
const defaultEnvironmentOptions = { foo: 'bar' };
1919
const defaultRunContextOptions = {};
2020

@@ -25,7 +25,7 @@ describe('RunContext running environment', function () {
2525
let build = true;
2626
let lookups: LookupOptions[] = [];
2727

28-
beforeEach(async function () {
28+
beforeEach(async () => {
2929
process.chdir(__dirname);
3030

3131
if (!gen) {
@@ -40,7 +40,7 @@ describe('RunContext running environment', function () {
4040
}
4141
});
4242

43-
afterEach(function () {
43+
afterEach(() => {
4444
process.chdir(__dirname);
4545
context.cleanTestDirectory();
4646
});

0 commit comments

Comments
 (0)