-
Notifications
You must be signed in to change notification settings - Fork 515
Conversation
Hello! Thank you for your submission.
You only can do this in Also, the base path for the require should be |
Also, there needs to be tests for this, and as well, you need to actually add the esprima option to the |
Thanks again @koistya. I appreciate the effort you've put forth here. Instead of looking for a string type in constructor, you should follow the conventions we have for new options: it needs to work from both .jscsrc and the cli, it needs a module to consume the option and remove it off of the config option, and then you need a set of unit tests to make sure your change works. |
890e096
to
4ae0a5a
Compare
@mikesherov, @mdevils take a look now, is this something you would be willing to merge? If so, I will try to add tests. |
@@ -32,6 +38,11 @@ Checker.prototype.configure = function(config) { | |||
excludeFiles(config, this, cwd); | |||
additionalRules(config, this, cwd); | |||
esnext(config); | |||
esprima(config); | |||
|
|||
if (typeof config.esprima === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done inside the options configuration module.
It's definitely something we'll be merging. However, there are still a few nits to work out. Either way, you should write tests anyway because we know what the external API already is, and it will help us review what work you've done. |
@@ -25,7 +25,8 @@ module.exports = function(program) { | |||
var promise = defer.promise(); | |||
var checker = new Checker({ | |||
verbose: program.verbose, | |||
esnext: program.esnext | |||
esnext: program.esnext, | |||
esprima: program.esprima |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why I need to see some tests :-) Currently, passing a string here will explode, no?
@koistya, thanks again for contributing! Please write the following tests before I review again:
|
I just have tested manually with both CLI and .jscsrc option, works fine. |
4d223f4
to
b5309cc
Compare
85d811a
to
4833995
Compare
I'm wondering, why does this unit test fail with it('should use a custom esprima provided in the config file', function(done) {
var data = 'import { foo } from "bar";\n';
var result = cli({
args: [],
'no-colors': true,
config: 'test/data/cli/esprima.json'
});
process.stdin.emit('data', data);
process.stdin.emit('end');
return result.promise.always(function() {
assert(console.log.getCall(0).args[0] === 'No code style errors found.');
rAfter();
done();
});
}); |
|
||
beforeEach(function() { | ||
sinon.spy(console, 'log'); | ||
process.stdin.isTTY = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just have copied from the existing test above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it then. :-)
Maybe has something to do with setting |
@@ -113,6 +113,12 @@ module.exports = function(program) { | |||
return returnArgs; | |||
} | |||
|
|||
if (program.esprima && typeof program.esprima === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can just be if (typeof program.esprima === 'string') {
Removing |
@@ -113,6 +113,12 @@ module.exports = function(program) { | |||
return returnArgs; | |||
} | |||
|
|||
if (program.esprima && typeof program.esprima === 'string') { | |||
config.esprima = require(program.esprima); | |||
} else if (config.esprima && typeof config.esprima === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can just be } else if (typeof config.esprima === 'string') {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I guess config
is always defined at this point.
@koistya thanks for sticking with this. |
@koistya perhaps it's because you haven't added any rules? |
@mikesherov I just copied a unit test from above and replaced the input string with |
@koistya, no worries. I'll take it the rest of way. Thanks again for contributing! |
Was waiting for config to land. Will pick this up tomorrow. |
Currently you cannot use
csjs
with JSX (ReactJS) files:If you could provide a custom Esprima version via CLI or
.jscsrc
file, that would fix the problem:at the CLI:
jscs --esprima=esprima-fb
in
.jscsrc