Skip to content

Commit

Permalink
feat(stark-build): tslintLoader - Disable typecheck rules to remove w…
Browse files Browse the repository at this point in the history
…arnings since typeCheck is false

ISSUES CLOSED: #405
  • Loading branch information
SuperITMan committed Apr 8, 2019
1 parent 2e378b4 commit 71f697d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/stark-build/config/build-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,26 @@ function getEnvironmentFile(environment) {
}
}

function get(obj, path, defaultValue) {
let args;
if (typeof path === "string") {
args = path.split(".");
} else {
args = path;
}

for (let i = 0; i < args.length; i++) {
if (!obj || !obj.hasOwnProperty(args[i])) {
return defaultValue;
}
obj = obj[args[i]];
}
return obj;
}

exports.ANGULAR_APP_CONFIG = ANGULAR_APP_CONFIG;
exports.DEFAULT_METADATA = DEFAULT_METADATA;
exports.getEnvironmentFile = getEnvironmentFile;
exports.readTsConfig = readTsConfig;
exports.supportES2015 = supportES2015;
exports.get = get;
43 changes: 43 additions & 0 deletions packages/stark-build/config/tslint-disabled-typecheck-rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"extends": ["TSLINT_CONFIG_PLACEHOLDER"],
"rules": {
"await-promise": false,
"consecutive-overloads": false,
"deprecation": false,
"match-default-export-name": false,
"no-accessor-field-mismatch": false,
"no-alphabetical-sort": false,
"no-array-delete": false,
"no-boolean-literal-compare": false,
"no-collection-size-mischeck": false,
"no-dead-store": false,
"no-element-overwrite": false,
"no-empty-array": false,
"no-floating-promises": false,
"no-for-in-array": false,
"no-gratuitous-expressions": false,
"no-ignored-initial-value": false,
"no-ignored-return": false,
"no-in-misuse": false,
"no-inferred-empty-object-type": false,
"no-invalid-await": false,
"no-misleading-array-reverse": false,
"no-redundant-boolean": false,
"no-return-type-any": false,
"no-self-assignment": false,
"no-try-promise": false,
"no-undefined-argument": false,
"no-unnecessary-qualifier": false,
"no-unused-array": false,
"no-use-of-empty-return-value": false,
"no-useless-cast": false,
"no-useless-intersection": false,
"no-variable-usage-before-declaration": false,
"no-void-expression": false,
"parameters-max-number": false,
"prefer-immediate-return": false,
"return-undefined": false,
"use-default-type-parameter": false,
"use-type-alias": false
}
}
13 changes: 12 additions & 1 deletion packages/stark-build/config/webpack-partial.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fs = require("fs");
const commonData = require("./webpack.common-data.js"); // common configuration between environments
const buildUtils = require("./build-utils");
const ngCliPackageChunkSort = require("@angular-devkit/build-angular/src/angular-cli-files/utilities/package-chunk-sort");
const os = require("os");

/**
* Webpack Plugins
Expand All @@ -24,6 +25,14 @@ const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPl
// const InlineManifestWebpackPlugin = require("inline-manifest-webpack-plugin");
// const ScriptExtHtmlWebpackPlugin = require("script-ext-html-webpack-plugin");

const tslintConfig = buildUtils.get(buildUtils.ANGULAR_APP_CONFIG.config, "architect.lint.options.tslintConfig", "tslint.json");
const tslintConfigPath = helpers.root(tslintConfig).replace(/\\/g, "/");
const tslintLoaderFilePath = `${os.tmpdir()}/national-bank-belgium_stark-build_tslint-${new Date().getTime()}.json`;

const tslintDefault = fs.readFileSync(helpers.rootStark("config/tslint-disabled-typecheck-rules.json"), "utf8");
const tslintDefaultEdited = tslintDefault.replace(/TSLINT_CONFIG_PLACEHOLDER/, tslintConfigPath);
fs.writeFileSync(tslintLoaderFilePath, tslintDefaultEdited, "utf8");

/**
* Webpack configuration
*
Expand Down Expand Up @@ -80,7 +89,9 @@ module.exports = metadata => {
{
loader: "tslint-loader",
options: {
typeCheck: false // FIXME remove this line once the type checking issues are gone (cfr FIXME above)
typeCheck: false, // FIXME remove this line once the type checking issues are gone (cfr FIXME above)
tsconfig: buildUtils.ANGULAR_APP_CONFIG.buildOptions.tsconfig || "tsconfig.json",
configFile: tslintLoaderFilePath
}
}
],
Expand Down

0 comments on commit 71f697d

Please sign in to comment.