-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
coverage/ | ||
test/fixtures/enzyme-example-mocha/ | ||
test/fixtures/check-eggache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "plugin:eggache/recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const Command = require('../command'); | ||
const path = require('path'); | ||
|
||
class CheckCommand extends Command { | ||
constructor(rawArgv) { | ||
super(rawArgv); | ||
this.usage = 'Usage: egg-bin check'; | ||
this.options = { | ||
baseDir: { | ||
description: 'directory of application, default to `process.cwd()`', | ||
type: 'string', | ||
}, | ||
}; | ||
} | ||
|
||
get description() { | ||
return 'Check egg project for collect useful infomation to report issue'; | ||
} | ||
|
||
* run({ cwd, argv }) { | ||
/* istanbul ignore next */ | ||
let baseDir = argv._[0] || argv.baseDir || cwd; | ||
/* istanbul ignore next */ | ||
if (!path.isAbsolute(baseDir)) baseDir = path.join(cwd, baseDir); | ||
|
||
// check eggache | ||
const eslintBin = require.resolve('eslint/bin/eslint'); | ||
const eslintArgs = this.helper.unparseArgv({ | ||
_: [ '.' ], | ||
config: require.resolve('../check-eslintrc'), | ||
'no-eslintrc': true, | ||
format: 'codeframe', | ||
}); | ||
console.info('[egg-bin] run check: %s %s', eslintBin, eslintArgs.join(' ')); | ||
yield this.helper.forkNode(eslintBin, eslintArgs, { cwd: baseDir }); | ||
} | ||
} | ||
|
||
module.exports = CheckCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = appInfo => { | ||
const config = exports = {}; | ||
config.keys = appInfo.name; | ||
return config; | ||
}; | ||
|
||
exports.test = '12345'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
exports.view = { | ||
enable: true, | ||
package: '', | ||
foo: 'bar', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = ''; | ||
|
||
exports.test = '12345'; | ||
|
||
let a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "check-eggache" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const coffee = require('coffee'); | ||
|
||
const eggBin = require.resolve('../../../bin/egg-bin.js'); | ||
|
||
describe('test/lib/cmd/check.test.js', () => { | ||
it('should check eggache', function* () { | ||
const cwd = path.join(__dirname, '../../fixtures/check-eggache'); | ||
yield coffee.fork(eggBin, [ 'check' ], { cwd }) | ||
// .debug() | ||
.expect('stdout', /eggache\/no-override-exports/) | ||
.expect('stdout', /eggache\/no-unexpected-plugin-keys/) | ||
.notExpect('stdout', /no-unused-vars/) | ||
.notExpect('stdout', /\/other.js/) | ||
.expect('code', 1) | ||
.end(); | ||
}); | ||
|
||
it('should check eggache with --baseDir', function* () { | ||
const cwd = path.join(__dirname, '../../fixtures/check-eggache'); | ||
yield coffee.fork(eggBin, [ 'check', '--baseDir', cwd ]) | ||
// .debug() | ||
.expect('stdout', /eggache\/no-override-exports/) | ||
.expect('stdout', /eggache\/no-unexpected-plugin-keys/) | ||
.notExpect('stdout', /no-unused-vars/) | ||
.notExpect('stdout', /\/other.js/) | ||
.expect('code', 1) | ||
.end(); | ||
}); | ||
}); |