From b52606ea75316eeb26bb3f251bbbe22d1458e584 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Tue, 18 Aug 2020 15:21:14 -0700 Subject: [PATCH 1/4] eslint-setup: Adds logic to create simplified eslintrc.js file. --- .../src/generators/app/index.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/generator-particle-base/src/generators/app/index.ts b/packages/generator-particle-base/src/generators/app/index.ts index c3479636dc..efcaaa06e2 100644 --- a/packages/generator-particle-base/src/generators/app/index.ts +++ b/packages/generator-particle-base/src/generators/app/index.ts @@ -1,6 +1,7 @@ import Generator from 'yeoman-generator' import merge from 'lodash.merge' import fs from 'fs' +import _ from 'lodash'; import { Answers, @@ -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) @@ -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( From e48dc7f6afb63e6478579157f0ce800e9b815587 Mon Sep 17 00:00:00 2001 From: Ian Goodrich <11083407+LeeMellon@users.noreply.github.com> Date: Tue, 18 Aug 2020 15:52:17 -0700 Subject: [PATCH 2/4] Update packages/generator-particle-base/src/generators/app/index.ts Co-authored-by: Shawn Mealey --- packages/generator-particle-base/src/generators/app/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/generator-particle-base/src/generators/app/index.ts b/packages/generator-particle-base/src/generators/app/index.ts index efcaaa06e2..2dfb30d377 100644 --- a/packages/generator-particle-base/src/generators/app/index.ts +++ b/packages/generator-particle-base/src/generators/app/index.ts @@ -94,7 +94,7 @@ module.exports = class extends Generator { **/ _eslintCompile(configuration: Answers ) { - const {frontendFramework, testingLibraries, hasTypescript } = configuration.options; + 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}'`); From 07c997f13110c8e126d13688a3a16231c582624c Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Tue, 18 Aug 2020 16:25:37 -0700 Subject: [PATCH 3/4] eslint-setup: minor cleanup. --- packages/generator-particle-base/src/generators/app/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/generator-particle-base/src/generators/app/index.ts b/packages/generator-particle-base/src/generators/app/index.ts index efcaaa06e2..448fbd1e06 100644 --- a/packages/generator-particle-base/src/generators/app/index.ts +++ b/packages/generator-particle-base/src/generators/app/index.ts @@ -94,8 +94,8 @@ module.exports = class extends Generator { **/ _eslintCompile(configuration: Answers ) { - const {frontendFramework, testingLibraries, hasTypescript } = configuration.options; - const validPackages: string[] = ['react', 'vue', 'cypress', 'jest', 'typescript'] + 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}'`); From 72c14b130fdbcee19c91e485eec31334b52be694 Mon Sep 17 00:00:00 2001 From: IMGoodrich Date: Tue, 18 Aug 2020 16:26:29 -0700 Subject: [PATCH 4/4] eslint-setup: Remove refs to index.js in supplemental eslint-config files. --- packages/eslint-config/cypress.js | 1 - packages/eslint-config/jest.js | 2 +- packages/eslint-config/react.js | 2 +- packages/eslint-config/typescript.js | 2 +- packages/eslint-config/vue.js | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config/cypress.js b/packages/eslint-config/cypress.js index 56aba59916..796566c23c 100644 --- a/packages/eslint-config/cypress.js +++ b/packages/eslint-config/cypress.js @@ -1,5 +1,4 @@ module.exports = { - extends: ['.index.js'], plugins: ['cypress'], env: { 'cypress/globals': true, diff --git a/packages/eslint-config/jest.js b/packages/eslint-config/jest.js index b4b504cb15..de5b91ed6a 100644 --- a/packages/eslint-config/jest.js +++ b/packages/eslint-config/jest.js @@ -1,5 +1,5 @@ module.exports = { - extends: ['plugin:jest/recommended', './index.js'], + extends: ['plugin:jest/recommended'], rules: { 'jest/expect-expect': 'off', }, diff --git a/packages/eslint-config/react.js b/packages/eslint-config/react.js index 73101bd646..271def1043 100644 --- a/packages/eslint-config/react.js +++ b/packages/eslint-config/react.js @@ -1,5 +1,5 @@ module.exports = { - extends: ['prettier/react', './index.js'], + extends: ['prettier/react'], rules: { 'react/jsx-filename-extension': 'off', 'import/extensions': [ diff --git a/packages/eslint-config/typescript.js b/packages/eslint-config/typescript.js index 445d4a0787..c5c695d2d0 100644 --- a/packages/eslint-config/typescript.js +++ b/packages/eslint-config/typescript.js @@ -1,5 +1,5 @@ module.exports = { - extends: ['prettier/@typescript', './index.js'], + extends: ['prettier/@typescript'], overrides: [ { files: ['**/*.ts?(x)'], diff --git a/packages/eslint-config/vue.js b/packages/eslint-config/vue.js index 74567d5783..c2988ac90a 100644 --- a/packages/eslint-config/vue.js +++ b/packages/eslint-config/vue.js @@ -1,3 +1,3 @@ module.exports = { - extends: ['plugin:vue/recommended', 'prettier/vue', './index.js'], + extends: ['plugin:vue/recommended', 'prettier/vue'], }