diff --git a/src/base.config.ts b/src/base.config.ts index 0190f0a7..7a1c5e3f 100644 --- a/src/base.config.ts +++ b/src/base.config.ts @@ -12,6 +12,7 @@ import * as webpack from 'webpack'; import * as cssnano from 'cssnano'; import * as minimatch from 'minimatch'; import * as ManifestPlugin from 'webpack-manifest-plugin'; +import * as globby from 'globby'; const postcssPresetEnv = require('postcss-preset-env'); const postcssImport = require('postcss-import'); @@ -45,6 +46,13 @@ export const packageName = packageJson.name || ''; const tsLintPath = path.join(basePath, 'tslint.json'); const tsLint = existsSync(tsLintPath) ? require(tsLintPath) : false; +function getTsLintExclusions() { + if (tsLint && tsLint.linterOptions && tsLint.linterOptions.exclude) { + return globby.sync(tsLint.linterOptions.exclude).map((file) => path.resolve(file)); + } + return []; +} + function getLibraryName(name: string) { return name .replace(/[^a-z0-9_]/g, ' ') @@ -560,7 +568,8 @@ export default function webpackConfigFactory(args: any): webpack.Configuration { test: /\.(ts|tsx)$/, enforce: 'pre', loader: 'tslint-loader', - options: { configuration: tsLint, emitErrors: true, failOnHint: true } + options: { configuration: tsLint, emitErrors: true, failOnHint: true }, + exclude: getTsLintExclusions() }, { test: /@dojo(\/|\\).*\.(js|mjs)$/, diff --git a/test-app/src/main.ts b/test-app/src/main.ts index f48d47ff..ace82b13 100644 --- a/test-app/src/main.ts +++ b/test-app/src/main.ts @@ -5,6 +5,7 @@ import { registerRouterInjector } from '@dojo/framework/routing/RouterInjector'; import App from './App'; import * as css from './app.m.css'; import './Bar'; +import './tslintTest'; import LazyApp from './LazyApp'; import routes from './routes'; import test from './test.block'; diff --git a/test-app/src/tslintTest.ts b/test-app/src/tslintTest.ts new file mode 100644 index 00000000..e045e42f --- /dev/null +++ b/test-app/src/tslintTest.ts @@ -0,0 +1,2 @@ +// This would fail linting without `exclude` support from @dojo/cli-build-app +export var thisWouldFailLinting: any; diff --git a/test-app/tslint.json b/test-app/tslint.json new file mode 100644 index 00000000..3a78878b --- /dev/null +++ b/test-app/tslint.json @@ -0,0 +1,40 @@ +{ + "rules": { + "align": false, + "ban": [], + "class-name": true, + "comment-format": [ true, "check-space" ], + "curly": true, + "forin": false, + "interface-name": [ true, "never-prefix" ], + "jsdoc-format": true, + "label-position": true, + "member-access": false, + "member-ordering": false, + "no-any": false, + "no-arg": true, + "no-bitwise": false, + "no-console": false, + "no-construct": false, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-inferrable-types": [ true, "ignore-params" ], + "no-shadowed-variable": false, + "no-string-literal": false, + "no-switch-case-fall-through": false, + "no-unused-expression": false, + "no-use-before-declare": false, + "no-var-keyword": true, + "no-var-requires": false, + "object-literal-sort-keys": false, + "radix": true, + "triple-equals": [ true, "allow-null-check" ], + "typedef": false, + "variable-name": [ true, "check-format", "allow-leading-underscore", "ban-keywords", "allow-pascal-case" ] + }, + "linterOptions": { + "exclude": [ "**/tslint*.ts" ] + } +}