Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
fix(next-steps): removed the todo for the extension that now happens …
Browse files Browse the repository at this point in the history
…programatically
  • Loading branch information
travi committed Dec 9, 2020
1 parent ca5f565 commit b603b2a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 38 deletions.
12 changes: 0 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 2 additions & 10 deletions src/eslint/lift-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,17 @@ suite('eslint lifter', () => {
test('that dependencies are listed for requested simple configs', async () => {
const configs = any.listOf(any.word);

const {nextSteps, devDependencies} = await liftEslint({configs, scope, projectRoot});
const {devDependencies} = await liftEslint({configs, scope, projectRoot});

assert.deepEqual(
nextSteps,
[{summary: `extend the following additional ESLint configs: ${configs.join(', ')}`}]
);
assert.deepEqual(devDependencies, configs.map(cfg => `${scope}/eslint-config-${cfg}`));
assert.calledWith(config.default, {projectRoot, configs, scope});
});

test('that dependencies are listed for requested complex configs', async () => {
const configs = any.listOf(() => ({...any.simpleObject(), name: any.word()}));

const {nextSteps, devDependencies} = await liftEslint({configs, scope, projectRoot});
const {devDependencies} = await liftEslint({configs, scope, projectRoot});

assert.deepEqual(
nextSteps,
[{summary: `extend the following additional ESLint configs: ${configs.join(', ')}`}]
);
assert.deepEqual(devDependencies, configs.map(cfg => `${scope}/eslint-config-${cfg.name}`));
assert.calledWith(config.default, {projectRoot, scope, configs});
});
Expand Down
5 changes: 1 addition & 4 deletions src/eslint/lift.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@ export default async function ({configs, scope, projectRoot}) {

const mapConfigNameToPackageName = getConfigToPackageNameMapper(scope);

return {
devDependencies: configs.map(mapConfigNameToPackageName),
nextSteps: [{summary: `extend the following additional ESLint configs: ${configs.join(', ')}`}]
};
return {devDependencies: configs.map(mapConfigNameToPackageName)};
}
17 changes: 14 additions & 3 deletions test/integration/features/eslint-configs.feature
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
Feature: ESLint Configs

Scenario: No existing config
Scenario: No existing config, but no updates
Given no existing eslint config file is present
When the scaffolder results are processed
Then no eslint config file exists

Scenario: existing yaml config
Scenario: No existing config, but updates provided
Given no existing eslint config file is present
And the results include eslint configs
When the scaffolder results are processed
Then no eslint config file exists

Scenario: existing yaml config without updates
Given an existing eslint config file is present
When the scaffolder results are processed
Then no updates are applied to the existing yaml config file

Scenario: existing yaml config with updates
Given an existing eslint config file is present
And the results include eslint configs
When the scaffolder results are processed
Then the yaml eslint config file contains the expected config
Then the yaml eslint config file is updated with the provided simple configs
20 changes: 11 additions & 9 deletions test/integration/features/step_definitions/eslint-config-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ Then('no eslint config file exists', async function () {
assert.isFalse(await fileExists(pathToYamlConfig));
});

Then('the yaml eslint config file contains the expected config', async function () {
Then('no updates are applied to the existing yaml config file', async function () {
const config = safeLoad(await fs.readFile(pathToYamlConfig));

if (this.eslintConfigs) {
assert.deepEqual(
config.extends,
[eslintConfigScope, ...this.eslintConfigs.map(cfg => `${eslintConfigScope}/${cfg}`)]
);
} else {
assert.deepEqual(config.extends, eslintConfigScope);
}
assert.deepEqual(config.extends, [eslintConfigScope]);
});

Then('the yaml eslint config file is updated with the provided simple configs', async function () {
const config = safeLoad(await fs.readFile(pathToYamlConfig));

assert.deepEqual(
config.extends,
[eslintConfigScope, ...this.eslintConfigs.map(cfg => `${eslintConfigScope}/${cfg}`)]
);
});

0 comments on commit b603b2a

Please sign in to comment.