Skip to content
This repository was archived by the owner on Jul 2, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions generators/linting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# linting

Installs linter dependencies and creates lint configuration files.

## Usage

Run generator from root of the project that needs linting.

```
$ yo springworks:linting
```

## Result

NPM modules will be installed and `.eslintrc` created in `.` and `./test` dir.
49 changes: 49 additions & 0 deletions generators/linting/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

const path = require('path');
const generators = require('yeoman-generator');

module.exports = generators.Base.extend({

constructor: function() {
generators.Base.apply(this, arguments);
},

initializing: function() {
const welcomeMessage = [
'\nSetting up linting\n',
];
this.log(welcomeMessage.join(''));
},

writing: {

linterConfigs: function() {
this.copy('.eslintrc', '.eslintrc');
this.copy(path.join('test', '.eslintrc'), path.join('test', '.eslintrc'));
},

linterIgnoreFile: function() {
this.copy('.eslintignore', '.eslintignore');
},

},

install: {

installDependencies: function() {
const dependencies = [
'babel-eslint',
'eslint',
'eslint-config-springworks',
'eslint-plugin-import',
'eslint-plugin-mocha',
'eslint-plugin-should-promised',
'eslint-plugin-springworks',
];
this.npmInstall(dependencies, { saveDev: true });
},

},

});
5 changes: 5 additions & 0 deletions generators/linting/templates/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
.iml
coverage
node_modules
packages/**
5 changes: 5 additions & 0 deletions generators/linting/templates/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "springworks/babel",
"rules": {
}
}
13 changes: 13 additions & 0 deletions generators/linting/templates/test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "springworks/mocha",
"globals": {
"should": false,
"sinon": false
},
"plugins": [
"should-promised"
],
"rules": {
"should-promised/return-promise": 2
}
}
30 changes: 30 additions & 0 deletions test/linting-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');

describe('test/linting-test.js', () => {

before(done => {
helpers.run(path.join(__dirname, '..', 'generators', 'linting'))
.withOptions({
'skip-install': true,
})
.withPrompts()
.on('end', done);
});

it('should copy .eslintrc to root dir', () => {
assert.file('.eslintrc');
});

it('should copy .eslintrc to test dir', () => {
assert.file(path.join('test', '.eslintrc'));
});

it('should copy .eslintignore to root dir', () => {
assert.file('.eslintignore');
});

});