diff --git a/packages/generator/README.md b/packages/generator/README.md index b972250..a96a953 100644 --- a/packages/generator/README.md +++ b/packages/generator/README.md @@ -20,7 +20,7 @@ This generator will create the following for you: - A recommended file & folder structure for working with Atlas.js - Various configuration files following a pattern most commonly encountered when working on backend services/APIs - A makefile with all the necessary build targets to work efficiently on the project -- _(optional)_ ESLint configuration, including the [@strv/eslint-config-javascript][strv-ruleset] ruleset +- _(optional)_ ESLint configuration, including the [@strv/eslint-config-node][strv-ruleset] ruleset - _(optional)_ Test suite, consisting of Mocha, Chai.js, Sinon.js and NYC, plus some Chai.js plugins - _(optional)_ VS Code settings & launch configuration files with recommended options @@ -28,6 +28,6 @@ This generator will create the following for you: See the [LICENSE](LICENSE) file for information. -[strv-ruleset]: https://github.com/strvcom/eslint-config-javascript +[strv-ruleset]: https://github.com/strvcom/code-quality-tools/tree/master/packages/eslint-config-node [class-fields-proposal]: https://babeljs.io/docs/en/next/babel-plugin-proposal-class-properties [esmodules-plugin]: https://babeljs.io/docs/en/next/babel-plugin-transform-modules-commonjs diff --git a/packages/generator/generators/eslint/index.mjs b/packages/generator/generators/eslint/index.mjs index 9b2d865..94e6f98 100644 --- a/packages/generator/generators/eslint/index.mjs +++ b/packages/generator/generators/eslint/index.mjs @@ -9,7 +9,7 @@ class ESLint extends Generator { prompts = [{ type: 'confirm', name: 'eslint', - message: 'Install ESLint with @strv/eslint-config-javascript ruleset? 🎨', + message: 'Install ESLint with @strv/eslint-config-node ruleset? 🎨', default: true, }] @@ -27,7 +27,7 @@ class ESLint extends Generator { this.npmInstall([ 'eslint@latest', 'babel-eslint@latest', - '@strv/eslint-config-javascript@latest', + '@strv/eslint-config-node@latest', ], { 'save-dev': true }) } diff --git a/packages/generator/generators/eslint/templates/eslintrc.js b/packages/generator/generators/eslint/templates/eslintrc.js index e421f3c..ecbf720 100644 --- a/packages/generator/generators/eslint/templates/eslintrc.js +++ b/packages/generator/generators/eslint/templates/eslintrc.js @@ -4,10 +4,10 @@ module.exports = { parser: 'babel-eslint', extends: [ - '@strv/javascript/environments/nodejs/v10', - '@strv/javascript/environments/nodejs/optional',<%_ if (config.testsuite) { %> - '@strv/javascript/environments/mocha/recommended',<%_ } %> - '@strv/javascript/coding-styles/recommended', + '@strv/node/v10', + '@strv/node/optional', + '@strv/node/style',<%_ if (config.testsuite) { %> + '@strv/mocha',<%_ } %> ], rules: { @@ -33,10 +33,6 @@ module.exports = { '**/*.test.mjs', ], - env: { - mocha: true, - }, - globals: { expect: true, sinon: true, diff --git a/packages/generator/generators/testsuite/index.mjs b/packages/generator/generators/testsuite/index.mjs index 2650575..6e3f5fc 100644 --- a/packages/generator/generators/testsuite/index.mjs +++ b/packages/generator/generators/testsuite/index.mjs @@ -8,6 +8,17 @@ const files = [ ['nycrc.json', '.nycrc.json'], ] +const packages = [ + 'mocha@latest', + 'chai@latest', + 'chai-as-promised@latest', + 'dirty-chai@latest', + 'sinon@latest', + 'sinon-chai@latest', + 'nyc@latest', + 'source-map-support@latest', +] + class Testsuite extends Generator { prompts = [{ type: 'confirm', @@ -27,16 +38,14 @@ class Testsuite extends Generator { return } - this.npmInstall([ - 'mocha@latest', - 'chai@latest', - 'chai-as-promised@latest', - 'dirty-chai@latest', - 'sinon@latest', - 'sinon-chai@latest', - 'nyc@latest', - 'source-map-support@latest', - ], { 'save-dev': true }) + const packagesToInstall = [ + ...packages, + ] + + // @TODO: We should only do this when the user decided to add ESLint setup ⚠️ + packagesToInstall.push('@strv/eslint-config-mocha@latest') + + this.npmInstall(packagesToInstall, { 'save-dev': true }) } writing() {