Skip to content

Commit

Permalink
Merge pull request #255 from form8ion/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
travi authored Aug 1, 2022
2 parents c6410bc + 7a95e69 commit 1c493d1
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 154 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"@form8ion/commit-convention": "^3.1.0",
"@form8ion/config-file": "^1.0.1",
"@form8ion/core": "^2.0.0",
"@form8ion/eslint": "^3.1.0",
"@form8ion/eslint": "^4.0.0-alpha.3",
"@form8ion/execa-wrapper": "^1.0.0-alpha.1",
"@form8ion/husky": "^3.0.0",
"@form8ion/javascript-core": "^7.0.0",
Expand Down
4 changes: 0 additions & 4 deletions src/code-style/eslint/index.js

This file was deleted.

60 changes: 0 additions & 60 deletions src/code-style/eslint/lifter-test.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/code-style/eslint/lifter.js

This file was deleted.

39 changes: 0 additions & 39 deletions src/code-style/eslint/scaffolder-test.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/code-style/eslint/scaffolder.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/code-style/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export {lift, test} from '@form8ion/eslint';
export {default as scaffold} from './scaffolder';
export {lift, test} from './eslint';
10 changes: 3 additions & 7 deletions src/code-style/scaffolder-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as prettierPlugin from '@form8ion/prettier';
import * as eslintPlugin from '@form8ion/eslint';
import deepmerge from 'deepmerge';

import sinon from 'sinon';
import any from '@travi/any';
import {assert} from 'chai';

import * as scaffoldEslint from './eslint/scaffolder';
import * as scaffoldRemark from './remark';
import {scaffold} from '.';

Expand All @@ -20,7 +20,6 @@ suite('code-style scaffolder', () => {
const remarkDevDependencies = any.listOf(any.string);
const remarkScripts = any.simpleObject();
const configForRemark = any.simpleObject();
const eslintConfigs = any.listOf(any.word);
const configureLinting = true;
const dialect = any.word();
const remarkResults = any.simpleObject();
Expand All @@ -31,17 +30,15 @@ suite('code-style scaffolder', () => {
setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(scaffoldEslint, 'default');
sandbox.stub(eslintPlugin, 'scaffold');
sandbox.stub(scaffoldRemark, 'default');
sandbox.stub(prettierPlugin, 'scaffold');
sandbox.stub(deepmerge, 'all');

scaffoldRemark.default
.withArgs({projectRoot, projectType, config: configForRemark, vcs, dialect})
.resolves(remarkResults);
scaffoldEslint.default
.withArgs({projectRoot, config: configForEslint, additionalConfiguration: {configs: eslintConfigs}})
.resolves(eslintResults);
eslintPlugin.scaffold.withArgs({projectRoot, config: configForEslint}).resolves(eslintResults);
prettierPlugin.scaffold.withArgs({projectRoot, config: configForPrettier}).resolves(prettierResults);
});

Expand All @@ -56,7 +53,6 @@ suite('code-style scaffolder', () => {
dialect,
configs: {eslint: configForEslint, remark: configForRemark, prettier: configForPrettier},
vcs,
eslint: {configs: eslintConfigs},
configureLinting,
pathWithinParent
});
Expand Down
7 changes: 3 additions & 4 deletions src/code-style/scaffolder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import deepmerge from 'deepmerge';
import {scaffold as scaffoldPrettier} from '@form8ion/prettier';
import {scaffold as scaffoldEslint} from '@form8ion/eslint';

import {scaffold as scaffoldEslint} from './eslint';
import scaffoldRemark from './remark';

export default async function ({
Expand All @@ -10,13 +10,12 @@ export default async function ({
dialect,
configs,
vcs,
configureLinting,
eslint
configureLinting
}) {
return deepmerge.all(await Promise.all([
configs.eslint
&& configureLinting
&& scaffoldEslint({projectRoot, config: configs.eslint, additionalConfiguration: eslint}),
&& scaffoldEslint({projectRoot, config: configs.eslint}),
scaffoldRemark({
projectRoot,
projectType,
Expand Down
8 changes: 2 additions & 6 deletions src/scaffolder/scaffolder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ suite('javascript project scaffolder', () => {
const testingNextSteps = any.listOf(any.simpleObject);
const ciServiceNextSteps = any.listOf(any.simpleObject);
const projectTypeEslintConfigs = any.listOf(any.string);
const verificationResultsEslintConfigs = any.listOf(any.string);
const verificationResultsEslintDetails = {configs: verificationResultsEslintConfigs, ignore: any.simpleObject()};
const projectTypeNextSteps = any.listOf(any.simpleObject);
const hostResults = any.simpleObject();
const npmResults = any.simpleObject();
Expand All @@ -72,8 +70,7 @@ suite('javascript project scaffolder', () => {
const verificationResults = {
...any.simpleObject(),
nextSteps: testingNextSteps,
testFilenamePattern,
eslint: verificationResultsEslintDetails
testFilenamePattern
};
const codeStyleResults = any.simpleObject();
const ciServiceResults = {...any.simpleObject(), nextSteps: ciServiceNextSteps};
Expand Down Expand Up @@ -239,8 +236,7 @@ suite('javascript project scaffolder', () => {
dialect: chosenDialect,
configs,
vcs: vcsDetails,
configureLinting,
eslint: verificationResultsEslintDetails
configureLinting
}).resolves(codeStyleResults);
dialects.default
.withArgs({
Expand Down
10 changes: 1 addition & 9 deletions src/scaffolder/scaffolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,7 @@ export default async function (options) {
projectType,
testFilenamePattern: verificationResults.testFilenamePattern
}),
scaffoldCodeStyle({
projectRoot,
projectType,
dialect,
configs,
vcs,
configureLinting,
eslint: verificationResults.eslint
}),
scaffoldCodeStyle({projectRoot, projectType, dialect, configs, vcs, configureLinting}),
scaffoldProjectTypePlugin({
projectRoot,
projectType,
Expand Down
1 change: 1 addition & 0 deletions test/integration/features/scaffold/monorepo.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Feature: Monorepo
And the npm cli is logged in
And nvm is properly configured
And the project will not be tested
And the project will not be transpiled or linted
When the project is scaffolded
Then no error is thrown
And the monorepo scripts are included
Expand Down
7 changes: 5 additions & 2 deletions test/integration/features/step_definitions/common-steps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ When(/^the project is scaffolded$/, async function () {
foo: {
scaffolder: foo => ({
foo,
eslintConfigs: this.fooApplicationEslintConfigs,
eslint: {
configs: this.fooApplicationEslintConfigs,
ignore: {directories: this.fooApplicationEslintIgnoredDirectories}
},
buildDirectory: this.fooApplicationBuildDirectory
})
}
Expand Down Expand Up @@ -178,7 +181,7 @@ When('the scaffolder results are processed', async function () {
scripts: this.scriptsResults,
tags: this.tagsResults,
packageManager: this.packageManager,
eslintConfigs: this.additionalShareableConfigs
eslint: {configs: this.additionalShareableConfigs}
},
...this.eslintConfigScope && {configs: {eslint: {scope: this.eslintConfigScope}}}
});
Expand Down
9 changes: 8 additions & 1 deletion test/integration/features/step_definitions/eslint-steps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Given('the chosen application plugin defines override ESLint configs', async fun
this.integrationTestAnswer = true;
this.projectTypeChoiceAnswer = 'foo';
this.fooApplicationEslintConfigs = [(() => ({name: any.word(), files: any.word()}))()];
this.fooApplicationEslintIgnoredDirectories = any.listOf(any.word);
});

Then('the base ESLint config is extended', async function () {
Expand All @@ -66,10 +67,16 @@ Then('the additional ESLint configs are extended', async function () {
});

Then('the ESLint overrides are defined', async function () {
const config = load(await fs.readFile(`${process.cwd()}/.eslintrc.yml`));
const [configContents, ignoreFileContents] = await Promise.all([
fs.readFile(`${process.cwd()}/.eslintrc.yml`, 'utf-8'),
fs.readFile(`${process.cwd()}/.eslintignore`, 'utf-8')
]);
const config = load(configContents);
const ignores = ignoreFileContents.split(EOL);

assert.includeDeepMembers(
config.overrides,
this.fooApplicationEslintConfigs.map(cfg => ({files: cfg.files, extends: `${this.eslintScope}/${cfg.name}`}))
);
assert.includeMembers(ignores, this.fooApplicationEslintIgnoredDirectories);
});

0 comments on commit 1c493d1

Please sign in to comment.