Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
feat(generator-atlas): move generated ESLint config to the new packages
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrossmann committed Jun 21, 2019
1 parent c345182 commit f871a87
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ 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

## License

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
4 changes: 2 additions & 2 deletions packages/generator/generators/eslint/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}]

Expand All @@ -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 })
}

Expand Down
12 changes: 4 additions & 8 deletions packages/generator/generators/eslint/templates/eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -33,10 +33,6 @@ module.exports = {
'**/*.test.mjs',
],

env: {
mocha: true,
},

globals: {
expect: true,
sinon: true,
Expand Down
29 changes: 19 additions & 10 deletions packages/generator/generators/testsuite/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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() {
Expand Down

0 comments on commit f871a87

Please sign in to comment.