├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── README.md ├── formatters └── customFormatter.js ├── index.js ├── package.json ├── test ├── app │ ├── engine.ts │ └── for-in-array.ts ├── formatters │ └── simpleFormatter.js ├── loader.spec.js ├── tsconfig.json ├── webpack-runner.js └── webpack.config.js ├── tsconfig.json ├── tslint-custom.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # 2 space indentation 12 | [*.{js,ts,json}] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | # 4 space indentation 17 | [*.md] 18 | indent_style = space 19 | indent_size = 4 20 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage/** 2 | node_modules/** 3 | test/dist/** 4 | dist/** 5 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint:recommended", 3 | "env": { 4 | "mocha": true, 5 | "node": true 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | npm-debug.log 4 | *.tgz 5 | dist 6 | test/dist 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | app 2 | dist 3 | tslint* 4 | tsconfig.json 5 | test 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | notifications: 4 | email: 5 | on_failure: always 6 | on_success: change 7 | 8 | node_js: 9 | - '4' 10 | - '5' 11 | - '6' 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### 3.5.3 4 | 5 | Convert legacy rules for Tslint 5, 6 | fixes [#73](https://github.com/wbuchwalter/tslint-loader/issues/73) 7 | 8 | ### 3.5.2 9 | 10 | Remove empty error for Tslint 5, 11 | fixes [#71](https://github.com/wbuchwalter/tslint-loader/issues/71) 12 | 13 | ### 3.5.1 14 | 15 | Enable Tslint versions greater than 4 16 | 17 | ### 3.4.2 18 | 19 | Docs and tests upgrade to Webpack 2 20 | 21 | ### 3.4.1 22 | 23 | - Add explicit version check for Tslint 24 | 25 | ### 3.4.0 26 | 27 | - Add option for automatic style fixing, 28 | fixes [#54](https://github.com/wbuchwalter/tslint-loader/issues/54) 29 | - Enable absolute paths in config file path 30 | 31 | ### 3.3.0 32 | 33 | - Add ability to specify tsconfig.json for type checked rules, 34 | fixes [#45](https://github.com/wbuchwalter/tslint-loader/issues/45) 35 | 36 | ## 3.2.1 37 | 38 | - Fix custom formatters, fixes [#46](https://github.com/wbuchwalter/tslint-loader/issues/46) 39 | 40 | ## 3.2.0 41 | 42 | - Enable custom config file, fixes [#22](https://github.com/wbuchwalter/tslint-loader/issues/22) 43 | 44 | ## 3.1.0 45 | 46 | - Enable type checked rules, fixes [#36](https://github.com/wbuchwalter/tslint-loader/issues/36) 47 | 48 | ## 3.0.0 49 | 50 | - Upgrade to Tslint 4, fixes [#42](https://github.com/wbuchwalter/tslint-loader/issues/42) 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tslint-loader 2 | [![Build Status](https://travis-ci.org/wbuchwalter/tslint-loader.svg?branch=master)](https://travis-ci.org/wbuchwalter/tslint-loader) 3 | [![Dependency Status](https://david-dm.org/wbuchwalter/tslint-loader.svg)](https://david-dm.org/wbuchwalter/tslint-loader) 4 | [![devDependency Status](https://david-dm.org/wbuchwalter/tslint-loader/dev-status.svg)](https://david-dm.org/wbuchwalter/tslint-loader?type=dev) 5 | [![peerDependency Status](https://david-dm.org/wbuchwalter/tslint-loader/peer-status.svg)](https://david-dm.org/wbuchwalter/tslint-loader?type=peer) 6 | 7 | Tslint loader for Webpack. 8 | 9 | :warning: __TSLint will be deprecated some time in 2019__. See this issue for more details: [Roadmap: TSLint → ESLint](https://github.com/palantir/tslint/issues/4534). 10 | As such, users are also encouraged to migrate from tslint-loader to [eslint-webpack-plugin ](https://github.com/webpack-contrib/eslint-webpack-plugin) 11 | 12 | ## Installation 13 | 14 | ``` shell 15 | npm install tslint tslint-loader --save-dev 16 | ``` 17 | 18 | The package depends on Tslint 4.0+, no longer works with 3.* versions. 19 | 20 | ## Usage 21 | 22 | Apply the tslint loader as preLoader in your webpack configuration. 23 | 24 | ### Webpack 4 25 | 26 | ```javascript 27 | module.exports = { 28 | module: { 29 | rules: [ 30 | { 31 | test: /\.ts$/, 32 | enforce: 'pre', 33 | use: [ 34 | { 35 | loader: 'tslint-loader', 36 | options: { /* Loader options go here */ } 37 | } 38 | ] 39 | } 40 | ] 41 | } 42 | } 43 | ``` 44 | 45 | ### Webpack 3 46 | 47 | ```javascript 48 | module.exports = { 49 | module: { 50 | loaders: [ 51 | { 52 | test: /\.ts$/, 53 | enforce: 'pre', 54 | loader: 'tslint-loader', 55 | options: { /* Loader options go here */ } 56 | } 57 | ] 58 | } 59 | } 60 | ``` 61 | 62 | ### Webpack 2 63 | 64 | ```javascript 65 | module.exports = { 66 | module: { 67 | rules: [ 68 | { 69 | test: /\.ts$/, 70 | enforce: 'pre', 71 | loader: 'tslint-loader', 72 | options: { /* Loader options go here */ } 73 | } 74 | ] 75 | } 76 | } 77 | ``` 78 | 79 | ### Webpack 1 80 | 81 | ```javascript 82 | module.exports = { 83 | module: { 84 | preLoaders: [ 85 | { 86 | test: /\.ts$/, 87 | loader: 'tslint-loader' 88 | } 89 | ] 90 | }, 91 | 92 | tslint: { /* Loader options go here */ } 93 | } 94 | ``` 95 | 96 | ### Loader options 97 | 98 | ```javascript 99 | { 100 | configuration: { 101 | rules: { 102 | quotemark: [true, 'double'] 103 | } 104 | }, 105 | 106 | // can specify a custom config file relative to current directory or with absolute path 107 | // 'tslint-custom.json' 108 | configFile: false, 109 | 110 | // tslint errors are displayed by default as warnings 111 | // set emitErrors to true to display them as errors 112 | emitErrors: false, 113 | 114 | // tslint does not interrupt the compilation by default 115 | // if you want any file with tslint errors to fail 116 | // set failOnHint to true 117 | failOnHint: true, 118 | 119 | // enables type checked rules like 'for-in-array' 120 | // uses tsconfig.json from current working directory 121 | typeCheck: false, 122 | 123 | // automatically fix linting errors 124 | fix: false, 125 | 126 | // can specify a custom tsconfig file relative to current directory or with absolute path 127 | // to be used with type checked rules 128 | tsConfigFile: 'tsconfig.json', 129 | 130 | // name of your formatter (optional) 131 | formatter: 'yourformatter', 132 | 133 | // path to directory containing formatter (optional) 134 | formattersDirectory: 'node_modules/tslint-loader/formatters/', 135 | 136 | // These options are useful if you want to save output to files 137 | // for your continuous integration server 138 | fileOutput: { 139 | // The directory where each file's report is saved 140 | dir: './foo/', 141 | 142 | // The extension to use for each report's filename. Defaults to 'txt' 143 | ext: 'xml', 144 | 145 | // If true, all files are removed from the report directory at the beginning of run 146 | clean: true, 147 | 148 | // A string to include at the top of every report file. 149 | // Useful for some report formats. 150 | header: '\n', 151 | 152 | // A string to include at the bottom of every report file. 153 | // Useful for some report formats. 154 | footer: '' 155 | } 156 | } 157 | ``` 158 | 159 | ## License 160 | 161 | [MIT](http://www.opensource.org/licenses/mit-license.php) 162 | 163 | 164 | -------------------------------------------------------------------------------- /formatters/customFormatter.js: -------------------------------------------------------------------------------- 1 | var Lint = require("tslint"); 2 | 3 | var __extends = this.__extends || function (d, b) { 4 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; 5 | function __() { this.constructor = d; } 6 | __.prototype = b.prototype; 7 | d.prototype = new __(); 8 | }; 9 | 10 | var Formatter = (function (_super) { 11 | __extends(Formatter, _super); 12 | function Formatter() { 13 | _super.apply(this, arguments); 14 | } 15 | Formatter.prototype.format = function (failures) { 16 | var outputLines = failures.map(function (failure) { 17 | var failureString = failure.getFailure(); 18 | var lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); 19 | var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character + 1) + "]"; 20 | return positionTuple + ": " + failureString; 21 | }); 22 | return outputLines.join("\n") + "\n"; 23 | }; 24 | return Formatter; 25 | })(Lint.Formatters.AbstractFormatter); 26 | exports.Formatter = Formatter; 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License http://www.opensource.org/licenses/mit-license.php 3 | Author William Buchwalter 4 | based on jshint-loader by Tobias Koppers 5 | */ 6 | 'use strict'; 7 | 8 | var Lint = require('tslint'); 9 | var loaderUtils = require('loader-utils'); 10 | var fs = require('fs'); 11 | var path = require('path'); 12 | var mkdirp = require('mkdirp'); 13 | var rimraf = require('rimraf'); 14 | var objectAssign = require('object-assign'); 15 | var semver = require('semver'); 16 | 17 | function resolveFile(configPath) { 18 | return path.isAbsolute(configPath) 19 | ? configPath 20 | : path.resolve(process.cwd(), configPath) 21 | } 22 | 23 | function resolveOptions(webpackInstance) { 24 | var tslintOptions = webpackInstance.options && webpackInstance.options.tslint ? webpackInstance.options.tslint : {}; 25 | var query = loaderUtils.getOptions(webpackInstance); 26 | 27 | var options = objectAssign({}, tslintOptions, query); 28 | 29 | var configFile = options.configFile 30 | ? resolveFile(options.configFile) 31 | : null; 32 | 33 | options.formatter = options.formatter || 'custom'; 34 | options.formattersDirectory = options.formattersDirectory || __dirname + '/formatters/'; 35 | options.configuration = parseConfigFile(webpackInstance, configFile, options); 36 | options.tsConfigFile = options.tsConfigFile || 'tsconfig.json'; 37 | options.fix = options.fix || false; 38 | 39 | return options; 40 | } 41 | 42 | function parseConfigFile(webpackInstance, configFile, options) { 43 | if (!options.configuration) { 44 | return Lint.Linter.findConfiguration(configFile, webpackInstance.resourcePath).results; 45 | } 46 | 47 | if (semver.satisfies(Lint.Linter.VERSION, '>=5.0.0')) { 48 | return Lint.Configuration.parseConfigFile(options.configuration); 49 | } 50 | 51 | return options.configuration; 52 | } 53 | 54 | function lint(webpackInstance, input, options) { 55 | var lintOptions = { 56 | fix: options.fix, 57 | formatter: options.formatter, 58 | formattersDirectory: options.formattersDirectory, 59 | rulesDirectory: options.rulesDirectory 60 | }; 61 | var bailEnabled = (webpackInstance.options && webpackInstance.options.bail === true); 62 | 63 | var program; 64 | if (options.typeCheck) { 65 | var tsconfigPath = resolveFile(options.tsConfigFile); 66 | program = Lint.Linter.createProgram(tsconfigPath); 67 | } 68 | 69 | var linter = new Lint.Linter(lintOptions, program); 70 | linter.lint(webpackInstance.resourcePath, input, options.configuration); 71 | var result = linter.getResult(); 72 | var emitter = options.emitErrors ? webpackInstance.emitError : webpackInstance.emitWarning; 73 | 74 | report(result, emitter, options.failOnHint, options.fileOutput, webpackInstance.resourcePath, bailEnabled); 75 | } 76 | 77 | function report(result, emitter, failOnHint, fileOutputOpts, filename, bailEnabled) { 78 | if (result.failureCount === 0) return; 79 | if (result.failures && result.failures.length === 0) return; 80 | var err = new Error(result.output); 81 | delete err.stack; 82 | emitter(err); 83 | 84 | if (fileOutputOpts && fileOutputOpts.dir) { 85 | writeToFile(fileOutputOpts, result); 86 | } 87 | 88 | if (failOnHint) { 89 | var messages = ''; 90 | if (bailEnabled){ 91 | messages = '\n\n' + filename + '\n' + result.output; 92 | } 93 | throw new Error('Compilation failed due to tslint errors.' + messages); 94 | } 95 | } 96 | 97 | var cleaned = false; 98 | 99 | function writeToFile(fileOutputOpts, result) { 100 | if (fileOutputOpts.clean === true && cleaned === false) { 101 | rimraf.sync(fileOutputOpts.dir); 102 | cleaned = true; 103 | } 104 | 105 | if (result.failures.length) { 106 | mkdirp.sync(fileOutputOpts.dir); 107 | 108 | var relativePath = path.relative('./', result.failures[0].fileName); 109 | 110 | var targetPath = path.join(fileOutputOpts.dir, path.dirname(relativePath)); 111 | mkdirp.sync(targetPath); 112 | 113 | var extension = fileOutputOpts.ext || 'txt'; 114 | 115 | var targetFilePath = path.join(fileOutputOpts.dir, relativePath + '.' + extension); 116 | 117 | var contents = result.output; 118 | 119 | if (fileOutputOpts.header) { 120 | contents = fileOutputOpts.header + contents; 121 | } 122 | 123 | if (fileOutputOpts.footer) { 124 | contents = contents + fileOutputOpts.footer; 125 | } 126 | 127 | fs.writeFileSync(targetFilePath, contents); 128 | } 129 | } 130 | 131 | module.exports = function(input, map) { 132 | this.cacheable && this.cacheable(); 133 | var callback = this.async(); 134 | 135 | if (!semver.satisfies(Lint.Linter.VERSION, '>=4.0.0')) { 136 | throw new Error('Tslint should be of version 4+'); 137 | } 138 | 139 | var options = resolveOptions(this); 140 | lint(this, input, options); 141 | callback(null, input, map); 142 | }; 143 | 144 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tslint-loader", 3 | "version": "3.5.4", 4 | "description": "tslint loader for webpack", 5 | "main": "index.js", 6 | "scripts": { 7 | "deploy": "np --skip-cleanup", 8 | "lint": "eslint --ext .js .", 9 | "mocha": "mocha ./test/loader.spec.js --timeout 5000", 10 | "test": "npm run mocha && npm run lint" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/wbuchwalter/tslint-loader" 15 | }, 16 | "keywords": [ 17 | "tslint", 18 | "typescript", 19 | "webpack", 20 | "loader", 21 | "linting" 22 | ], 23 | "author": "William Buchwalter", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/wbuchwalter/tslint-loader/issues" 27 | }, 28 | "homepage": "https://github.com/wbuchwalter/tslint-loader", 29 | "peerDependencies": { 30 | "tslint": ">=4.0.0" 31 | }, 32 | "dependencies": { 33 | "loader-utils": "^1.0.2", 34 | "mkdirp": "^0.5.1", 35 | "object-assign": "^4.1.1", 36 | "rimraf": "^2.4.4", 37 | "semver": "^5.3.0" 38 | }, 39 | "devDependencies": { 40 | "awesome-typescript-loader": "^3.0.3", 41 | "chai": "^3.5.0", 42 | "es6-promisify": "^5.0.0", 43 | "eslint": "^3.15.0", 44 | "mocha": "^3.2.0", 45 | "np": "^2.12.0", 46 | "tslint": "^4.4.2", 47 | "typescript": "^2.1.6", 48 | "webpack": "^2.2.1" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/app/engine.ts: -------------------------------------------------------------------------------- 1 | 2 | export class DieselEngine { 3 | public toString() { 4 | return 'Diesel'; 5 | } 6 | } 7 | 8 | console.log(new DieselEngine().toString()); 9 | -------------------------------------------------------------------------------- /test/app/for-in-array.ts: -------------------------------------------------------------------------------- 1 | 2 | let initialArray = [1, 2, 3, 5]; 3 | 4 | for (let val in initialArray) { 5 | console.log(val); 6 | } 7 | -------------------------------------------------------------------------------- /test/formatters/simpleFormatter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function SimpleFormatter() {} 4 | 5 | SimpleFormatter.prototype.format = function (failures) { 6 | var outputLines = failures.map(function (failure) { 7 | return failure.getFailure(); 8 | }); 9 | return outputLines.join("\n") + "\n"; 10 | }; 11 | 12 | module.exports.Formatter = SimpleFormatter; 13 | -------------------------------------------------------------------------------- /test/loader.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var expect = require('chai').expect; 5 | var webpackRunner = require('./webpack-runner'); 6 | 7 | describe('TslintLoader', function() { 8 | it('should lint typescript files and output warning', function() { 9 | return webpackRunner().then(function(stats) { 10 | expect(stats.hasErrors()).to.be.false; 11 | expect(stats.hasWarnings()).to.be.true; 12 | 13 | var result = stats.toJson(); 14 | expect(result.assets.length).to.eql(1); 15 | expect(result.chunks.length).to.eql(1); 16 | expect(result.warnings).to.eql([ 17 | './test/app/engine.ts\n[8, 1]: Calls to \'console.log\' are not allowed.\n' 18 | ]); 19 | }); 20 | }); 21 | 22 | it('should overwrite configuration in tslint json', function() { 23 | return webpackRunner({ 24 | configuration: { 25 | rules: { 26 | 'no-console': [false] 27 | } 28 | } 29 | }).then(function(stats) { 30 | expect(stats.hasErrors()).to.be.false; 31 | expect(stats.hasWarnings()).to.be.false; 32 | }); 33 | }); 34 | 35 | it('should use custom tslint file when option given', function() { 36 | return webpackRunner({ 37 | configFile: 'tslint-custom.json' 38 | }).then(function(stats) { 39 | expect(stats.hasErrors()).to.be.false; 40 | expect(stats.hasWarnings()).to.be.false; 41 | }); 42 | }); 43 | 44 | it('should emit linting failure as error when forced to', function() { 45 | return webpackRunner({ 46 | emitErrors: true 47 | }).then(function(stats) { 48 | expect(stats.hasErrors()).to.be.true; 49 | expect(stats.hasWarnings()).to.be.false; 50 | 51 | var result = stats.toJson(); 52 | expect(result.errors).to.eql([ 53 | './test/app/engine.ts\n[8, 1]: Calls to \'console.log\' are not allowed.\n' 54 | ]); 55 | }); 56 | }); 57 | 58 | it('should accept options from query string also', function() { 59 | return webpackRunner(null, { 60 | module: { 61 | loaders: [ 62 | { 63 | test: /\.ts$/, 64 | enforce: 'pre', 65 | loader: './index?emitErrors=true' 66 | }, 67 | { 68 | test: /\.ts$/, 69 | loader: 'awesome-typescript-loader', 70 | query: { silent: true } 71 | } 72 | ] 73 | } 74 | }).then(function(stats) { 75 | expect(stats.hasErrors()).to.be.true; 76 | expect(stats.hasWarnings()).to.be.false; 77 | 78 | var result = stats.toJson(); 79 | expect(result.errors).to.eql([ 80 | './test/app/engine.ts\n[8, 1]: Calls to \'console.log\' are not allowed.\n' 81 | ]); 82 | }); 83 | }); 84 | 85 | it('should fail on linting failure when forced to', function() { 86 | return webpackRunner({ 87 | failOnHint: true 88 | }).then(function(stats) { 89 | expect(stats.hasErrors()).to.be.true; 90 | expect(stats.hasWarnings()).to.be.true; 91 | 92 | var result = stats.toJson(); 93 | expect(result.errors[0]).to.contain('Module build failed: Error: Compilation failed due to tslint errors.'); 94 | }); 95 | }); 96 | 97 | it('should use type checked rules when forced to', function() { 98 | return webpackRunner({ 99 | typeCheck: true, 100 | configuration: { 101 | rules: { 102 | 'no-for-in-array': true 103 | } 104 | } 105 | }, { 106 | entry: { 107 | engine: path.resolve(__dirname, 'app', 'for-in-array.ts') 108 | } 109 | }).then(function(stats) { 110 | expect(stats.hasErrors()).to.be.false; 111 | expect(stats.hasWarnings()).to.be.true; 112 | 113 | var result = stats.toJson(); 114 | 115 | expect(result.warnings).to.eql([ 116 | './test/app/for-in-array.ts\n[4, 1]: for-in loops over arrays are forbidden. Use for-of or array.forEach instead.\n' 117 | ]); 118 | }); 119 | }); 120 | 121 | it('should use type checked rules also with custom tsconfig file', function() { 122 | return webpackRunner({ 123 | typeCheck: true, 124 | tsConfigFile: 'test/tsconfig.json', 125 | configuration: { 126 | rules: { 127 | 'no-for-in-array': true 128 | } 129 | } 130 | }, { 131 | entry: { 132 | engine: path.resolve(__dirname, 'app', 'for-in-array.ts') 133 | } 134 | }).then(function(stats) { 135 | expect(stats.hasErrors()).to.be.false; 136 | expect(stats.hasWarnings()).to.be.true; 137 | 138 | var result = stats.toJson(); 139 | 140 | expect(result.warnings).to.eql([ 141 | './test/app/for-in-array.ts\n[4, 1]: for-in loops over arrays are forbidden. Use for-of or array.forEach instead.\n' 142 | ]); 143 | }); 144 | }); 145 | 146 | it('should use custom formatter with custom directory', function() { 147 | return webpackRunner({ 148 | formattersDirectory: 'test/formatters/', 149 | formatter: 'simple' 150 | }).then(function(stats) { 151 | var result = stats.toJson(); 152 | expect(result.warnings).to.eql([ 153 | './test/app/engine.ts\nCalls to \'console.log\' are not allowed.\n' 154 | ]); 155 | }); 156 | }); 157 | }); 158 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "target": "es5", 6 | "module": "commonjs", 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "sourceMap": true 10 | }, 11 | "exclude": [ 12 | "node_modules", 13 | "dist" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/webpack-runner.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var webpack = require('webpack'); 4 | var assign = require('object-assign'); 5 | var promisify = require('es6-promisify'); 6 | var webpackConfig = require('./webpack.config'); 7 | 8 | module.exports = function(tslintConfig, additionalConfig) { 9 | var basicConfig = webpackConfig(); 10 | if (tslintConfig) { 11 | basicConfig.module.rules[0].options = tslintConfig; 12 | } 13 | 14 | return promisify(webpack)(assign(basicConfig, additionalConfig)); 15 | }; 16 | -------------------------------------------------------------------------------- /test/webpack.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | 5 | module.exports = function() { 6 | return { 7 | entry: { 8 | engine: path.resolve(__dirname, 'app', 'engine.ts') 9 | }, 10 | resolve: { 11 | extensions: ['.ts'] 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.ts$/, 17 | enforce: 'pre', 18 | loader: './index' 19 | }, 20 | { 21 | test: /\.ts$/, 22 | loader: 'awesome-typescript-loader', 23 | query: { silent: true } 24 | } 25 | ] 26 | }, 27 | output: { 28 | filename: '[name].bundle.js', 29 | path: path.resolve(__dirname, 'dist') 30 | } 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "target": "es5", 6 | "module": "commonjs", 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "sourceMap": true 10 | }, 11 | "exclude": [ 12 | "node_modules", 13 | "dist" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /tslint-custom.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "quotemark": [true, "single", "avoid-escape"], 5 | "no-console": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "quotemark": [true, "single", "avoid-escape"] 5 | } 6 | } 7 | --------------------------------------------------------------------------------