Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/generator-particle-base/src/generators/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Generator from 'yeoman-generator'
import merge from 'lodash.merge'
import fs from 'fs'
import _ from 'lodash';

import {
Answers,
Expand Down Expand Up @@ -88,6 +89,26 @@ module.exports = class extends Generator {
)
}

/**
* Create eslintrc file
**/

_eslintCompile(configuration: Answers ) {
const {frontendFramework, testingLibraries, hasTypescript } = configuration.options;
const validPackages: string[] = ['react', 'vue', 'cypress', 'jest', 'typescript']
const extend: string[] = [...frontendFramework, ...testingLibraries, hasTypescript ? 'typescript': ''];
const elements: string[] = _.filter(extend, (el)=> validPackages.includes(el)).map(el => `\n'@phase2/eslint-config/${el}'`);

const esModule = `module.exports = {
extends: [
'@phase2/eslint-config', ${elements}
]
}`

fs.writeFileSync(`${process.cwd()}/.eslintrc.js`, esModule)

}

async _promptUser() {
// Initialize storybook
const results: ConfigurationAnswers = await this.prompt(configurationPrompt)
Expand Down Expand Up @@ -115,6 +136,7 @@ module.exports = class extends Generator {
async initializing() {
await this._promptUser()

this._eslintCompile(this.configuration)
// All composed generators must be imported following this syntax https://yeoman.io/authoring/composability.html
if (
this.configuration.options.frontendFramework.includes(
Expand Down