Skip to content

Commit

Permalink
lint files (#576)
Browse files Browse the repository at this point in the history
* chore: lint files manually

* chore: remove non used variable

---------

Co-authored-by: Marcelo Shima <[email protected]>
  • Loading branch information
UlisesGascon and mshima authored Feb 7, 2025
1 parent 14ad96a commit 92fa818
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
3 changes: 1 addition & 2 deletions src/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { InputOutputAdapter } from '@yeoman/types';
import { type ConflicterOptions, createConflicterTransform, createYoResolveTransform, forceYoFiles } from '@yeoman/conflicter';
import createdLogger from 'debug';
import type { Store } from 'mem-fs';
import { type MemFsEditorFile, create as createMemFsEditor } from 'mem-fs-editor';
import { type MemFsEditorFile } from 'mem-fs-editor';
import { createCommitTransform } from 'mem-fs-editor/transform';
import { isFilePending } from 'mem-fs-editor/state';

Expand All @@ -21,7 +21,6 @@ export const commitSharedFsTask = async ({
sharedFs: Store<MemFsEditorFile>;
}) => {
debug('Running commitSharedFsTask');
const editor = createMemFsEditor(sharedFs);
await sharedFs.pipeline(
{ filter: (file: MemFsEditorFile) => isFilePending(file) || file.path.endsWith('.yo-resolve') },
createYoResolveTransform(),
Expand Down
6 changes: 3 additions & 3 deletions test/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'node:assert';
import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
import sinon from 'sinon';
import { stub } from 'sinon';
import { beforeEach, describe, it } from 'esmocha';
import { prepareCommand } from '../src/commands.js';
import Environment from '../src/index.js';
Expand All @@ -17,7 +17,7 @@ describe('environment (command)', () => {

beforeEach(async () => {
environment = new Environment([], { skipInstall: true, dryRun: true });
environment.adapter.log = sinon.stub();
environment.adapter.log = stub();
await environment.register(path.join(__dirname, 'fixtures/generator-commands/generators/options'));
});

Expand Down Expand Up @@ -88,7 +88,7 @@ describe('environment (command)', () => {

beforeEach(() => {
environment = new Environment([], { skipInstall: true, dryRun: true });
environment.adapter.log = sinon.stub();
environment.adapter.log = stub();
environment.register(path.join(__dirname, 'fixtures/generator-commands/generators/arguments'));
});

Expand Down
30 changes: 15 additions & 15 deletions test/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
import { after, afterEach, before, beforeEach, describe, expect, it } from 'esmocha';
import { QueuedAdapter } from '@yeoman/adapter';
import sinon from 'sinon';
import { spy, stub } from 'sinon';
import assert from 'yeoman-assert';
import Environment, { createEnv as createEnvironment } from '../src/index.js';
import { resolveModulePath } from '../src/util/resolve.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ for (const generatorVersion of allVersions) {
});

MockedGenerator = class MockedGenerator extends Generator {};
mockedDefault = sinon.stub();
mockedDefault = stub();
MockedGenerator.prototype.mockedDefault = mockedDefault;
});

Expand Down Expand Up @@ -246,15 +246,15 @@ for (const generatorVersion of allVersions) {
});

it('should schedule generator queue', async function () {
this.env.queueTask = sinon.spy();
this.env.queueTask = spy();
await this.env.composeWith('stub');
assert(this.env.queueTask.calledOnce);
assert(this.env.queueTask.getCall(0).firstArg === 'environment:run');
});

describe('passing false schedule parameter', () => {
it('should not schedule generator', async function () {
this.env.queueTask = sinon.spy();
this.env.queueTask = spy();
await this.env.composeWith('stub', { generatorArgs: [], schedule: false });
if (isGreaterThan6(generatorVersion)) {
assert(this.env.queueTask.calledOnce);
Expand All @@ -266,7 +266,7 @@ for (const generatorVersion of allVersions) {
});
describe('passing function schedule parameter', () => {
it('returning false should not schedule generator', async function () {
this.env.queueTask = sinon.spy();
this.env.queueTask = spy();
await this.env.composeWith('stub', { generatorArgs: [], schedule: () => false });
if (isGreaterThan6(generatorVersion)) {
assert(this.env.queueTask.calledOnce);
Expand Down Expand Up @@ -372,7 +372,7 @@ for (const generatorVersion of allVersions) {
};

const runName = isLegacyVersion(generatorVersion) ? 'run' : 'queueTasks';
this.runMethod = sinon.spy(Generator.prototype, runName);
this.runMethod = spy(Generator.prototype, runName);
this.env.registerStub(this.Stub, 'stub:run');
this.env.registerStub(this.WritingStub, 'writingstub:run');
this.env.registerStub(this.PromiseFailingStub, 'promisefailingstub:run');
Expand Down Expand Up @@ -557,7 +557,7 @@ for (const generatorVersion of allVersions) {
describe('#run() a ts generator', () => {
beforeEach(async function () {
await this.env.register(path.join(__dirname, './fixtures/generator-ts/generators/app/index.ts'), 'ts:app');
this.runMethod = sinon.spy((await this.env.get('ts:app')).prototype, 'exec');
this.runMethod = spy((await this.env.get('ts:app')).prototype, 'exec');
});

afterEach(function () {
Expand All @@ -575,8 +575,8 @@ for (const generatorVersion of allVersions) {
beforeEach(async function () {
await this.env.register(path.join(__dirname, './fixtures/generator-common-js/generators/cjs/index.cjs'), 'common-js:cjs');
const Generator = await this.env.get('common-js:cjs');
this.runMethod = sinon.spy(Generator.prototype, 'default');
this.postConstruct = sinon.spy(Generator.prototype, '_postConstruct');
this.runMethod = spy(Generator.prototype, 'default');
this.postConstruct = spy(Generator.prototype, '_postConstruct');
});

afterEach(function () {
Expand Down Expand Up @@ -605,8 +605,8 @@ for (const generatorVersion of allVersions) {
beforeEach(async function () {
await this.env.register(path.join(__dirname, './fixtures/generator-esm/generators/app/index.js'), 'esm:app');
const esmClass = await this.env.get('esm:app');
this.runMethod = sinon.spy(esmClass.prototype, 'default');
this.postConstruct = sinon.spy(esmClass.prototype, '_postConstruct');
this.runMethod = spy(esmClass.prototype, 'default');
this.postConstruct = spy(esmClass.prototype, '_postConstruct');
});

afterEach(function () {
Expand Down Expand Up @@ -634,7 +634,7 @@ for (const generatorVersion of allVersions) {
beforeEach(async function () {
await this.env.register(path.join(__dirname, './fixtures/generator-esm/generators/mjs/index.mjs'), 'esm:mjs');
const esmClass = await this.env.get('esm:mjs');
this.runMethod = sinon.spy(esmClass.prototype, 'default');
this.runMethod = spy(esmClass.prototype, 'default');
});

afterEach(function () {
Expand Down Expand Up @@ -737,7 +737,7 @@ for (const generatorVersion of allVersions) {
describe('#getPackagePath and #getPackagePaths()', () => {
beforeEach(async function () {
this.env.alias(/^prefix-(.*)$/, '$1');
this.simpleDummy = sinon.spy();
this.simpleDummy = spy();
this.simplePath = path.join(__dirname, 'fixtures/generator-simple');
assert.equal(this.env.namespaces().length, 0, 'env should be empty');
await this.env.register(this.simplePath, 'fixtures:generator-simple', this.simplePath);
Expand All @@ -763,8 +763,8 @@ for (const generatorVersion of allVersions) {

describe('#registerStub()', () => {
beforeEach(async function () {
this.simpleDummy = sinon.spy();
this.resolvedDummy = sinon.spy();
this.simpleDummy = spy();
this.resolvedDummy = spy();
this.completeDummy = function () {};
util.inherits(this.completeDummy, Generator);
this.env.registerStub(this.simpleDummy, 'dummy:simple');
Expand Down
10 changes: 5 additions & 5 deletions test/generator-features.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'node:assert';
import sinon from 'sinon';
import { stub } from 'sinon';
import { after, afterEach, before, beforeEach, describe, esmocha, expect, it } from 'esmocha';
import helpers, { getCreateEnv as getCreateEnvironment } from './helpers.js';
import { greaterThan5 } from './generator-versions.js';
Expand Down Expand Up @@ -65,7 +65,7 @@ for (const generatorVersion of greaterThan5) {
let runContext;
let customCommitTask;
before(async () => {
customCommitTask = sinon.stub();
customCommitTask = stub();
runContext = helpers
.create('custom-commit')
.withOptions({ skipInstall: true })
Expand All @@ -82,7 +82,7 @@ for (const generatorVersion of greaterThan5) {
],
])
.withEnvironment(environment => {
environment.commitSharedFs = sinon.stub().returns(Promise.resolve());
environment.commitSharedFs = stub().returns(Promise.resolve());
});
await runContext.run();
});
Expand Down Expand Up @@ -183,7 +183,7 @@ for (const generatorVersion of greaterThan5) {
describe('with function customInstallTask', () => {
let customInstallTask;
before(async () => {
customInstallTask = sinon.stub();
customInstallTask = stub();
await helpers
.run('custom-install')
.withOptions({ skipInstall: false })
Expand Down Expand Up @@ -221,7 +221,7 @@ for (const generatorVersion of greaterThan5) {
let customInstallTask;
let installTask;
beforeEach(async () => {
customInstallTask = sinon.stub();
customInstallTask = stub();
installTask = (pm, defaultTask) => defaultTask(pm);
runContext = helpers
.create('custom-install', undefined, { createEnv: getCreateEnvironment(BasicEnvironment) })
Expand Down
4 changes: 2 additions & 2 deletions test/package-manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import sinon from 'sinon';
import { stub } from 'sinon';
import { after, afterEach, beforeEach, describe, esmocha, expect, it } from 'esmocha';

const { execa } = await esmocha.mock('execa', import('execa'));
Expand Down Expand Up @@ -74,7 +74,7 @@ No change to package.json was detected. No package manager install will be execu

describe('when package.json was committed', () => {
beforeEach(async () => {
memFs.get = sinon.stub().returns({ committed: true });
memFs.get = stub().returns({ committed: true });
});

describe('with skipInstall', () => {
Expand Down

0 comments on commit 92fa818

Please sign in to comment.