Skip to content

Commit

Permalink
Merge pull request #16 from Realytics/fix/tslint-option
Browse files Browse the repository at this point in the history
Fix tslint: true issue
  • Loading branch information
piotr-oles authored Jun 4, 2017
2 parents 8bce60f + c2aea83 commit 42aa0d2
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.2.1
* Fix for `tslint: true` option issue

## v0.2.0
* tsconfig.json and tslint.json path are not printed anymore.
* `watch` option is not used on 'build' mode
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function ForkTsCheckerWebpackPlugin (options) {
this.options = Object.assign({}, options);

this.tsconfig = options.tsconfig || './tsconfig.json';
this.tslint = options.tslint ? isString(options.tslint) ? options.tslint : './tslint.json' : undefined;
this.tslint = options.tslint ?
options.tslint === true ? './tslint.json' : options.tslint : undefined;
this.watch = isString(options.watch) ? [options.watch] : options.watch || [];
this.ignoreDiagnostics = options.ignoreDiagnostics || [];
this.ignoreLints = options.ignoreLints || [];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fork-ts-checker-webpack-plugin",
"version": "0.2.0",
"version": "0.2.1",
"description": "Runs typescript type checker and linter on separate process.",
"main": "lib/index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions test/integration/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ describe('[INTEGRATION] index', function () {
callback();
}
});

it('should detect tslint path for true option', function () {
expect(function() {
createCompiler({ tslint: true });
}).to.not.throw.error;
});
});
39 changes: 39 additions & 0 deletions test/unit/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var describe = require('mocha').describe;
var it = require('mocha').it;
var expect = require('chai').expect;
var ForkTsCheckerWebpackPlugin = require('../../lib/index');

describe('[UNIT] index', function () {

it('should allow to pass no options', function () {
expect(function () {
new ForkTsCheckerWebpackPlugin();
}).to.not.throw.error;
});

it('should detect paths', function () {
var plugin = new ForkTsCheckerWebpackPlugin({ tslint: true });

expect(plugin.tsconfig).to.be.equal('./tsconfig.json');
expect(plugin.tslint).to.be.equal('./tslint.json');
});

it('should set logger to console by default', function () {
var plugin = new ForkTsCheckerWebpackPlugin({ });

expect(plugin.logger).to.be.equal(console);
});

it('should set watch to empty array by default', function () {
var plugin = new ForkTsCheckerWebpackPlugin({ });

expect(plugin.watch).to.be.deep.equal([]);
});

it('should set watch to one element array for string', function () {
var plugin = new ForkTsCheckerWebpackPlugin({ watch: '/test' });

expect(plugin.watch).to.be.deep.equal(['/test']);
});

});
11 changes: 1 addition & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2493,16 +2493,7 @@ typescript@^2.1.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.2.tgz#f0f045e196f69a72f06b25fd3bd39d01c3ce9984"

uglify-js@^2.6:
version "2.8.22"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.22.tgz#d54934778a8da14903fa29a326fb24c0ab51a1a0"
dependencies:
source-map "~0.5.1"
yargs "~3.10.0"
optionalDependencies:
uglify-to-browserify "~1.0.0"

uglify-js@^2.8.27:
uglify-js@^2.6, uglify-js@^2.8.27:
version "2.8.27"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.27.tgz#47787f912b0f242e5b984343be8e35e95f694c9c"
dependencies:
Expand Down

0 comments on commit 42aa0d2

Please sign in to comment.