Improve TSLint rules and fix issues

This commit is contained in:
Jan Tuomi
2018-07-03 12:08:02 +03:00
parent e22335dbfc
commit 2bdcf9424c
8 changed files with 82 additions and 78 deletions
+28 -28
View File
@@ -1,60 +1,60 @@
// shared config (dev and prod)
const {resolve} = require('path');
const {CheckerPlugin} = require('awesome-typescript-loader');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const Dotenv = require('dotenv-webpack');
// Shared config (dev and prod)
const {resolve} = require("path");
const {CheckerPlugin} = require("awesome-typescript-loader");
const StyleLintPlugin = require("stylelint-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const Dotenv = require("dotenv-webpack");
module.exports = {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
extensions: [".ts", ".tsx", ".js", ".jsx"]
},
context: resolve(__dirname, '../../src'),
context: resolve(__dirname, "../../src"),
module: {
rules: [
{
test: /\.js$/,
use: ['babel-loader', 'source-map-loader'],
exclude: /node_modules/,
use: ["babel-loader", "source-map-loader"],
exclude: /node_modules/
},
{
test: /\.tsx?$/,
use: ['babel-loader', 'awesome-typescript-loader'],
use: ["babel-loader", "awesome-typescript-loader"]
},
{
test: /\.css$/,
use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }, 'postcss-loader',],
use: ["style-loader", {loader: "css-loader", options: {importLoaders: 1}}, "postcss-loader"]
},
{
test: /\.scss$/,
loaders: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
'sass-loader',
],
"style-loader",
{loader: "css-loader", options: {importLoaders: 1}},
"postcss-loader",
"sass-loader"
]
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
],
},
],
"file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]",
"image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false"
]
}
]
},
plugins: [
new CheckerPlugin(),
new StyleLintPlugin(),
new HtmlWebpackPlugin({template: 'index.html.ejs',}),
new HtmlWebpackPlugin({template: "index.html.ejs"}),
new Dotenv({
path: './.env.sample',
path: "./.env.sample"
}),
new Dotenv({
path: './.env',
}),
path: "./.env"
})
],
performance: {
hints: false,
},
hints: false
}
};
+17 -17
View File
@@ -1,26 +1,26 @@
// development config
const merge = require('webpack-merge');
const webpack = require('webpack');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
// Development config
const merge = require("webpack-merge");
const webpack = require("webpack");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const commonConfig = require('./common');
const commonConfig = require("./common");
module.exports = merge(commonConfig, {
mode: 'development',
mode: "development",
entry: [
'react-hot-loader/patch', // activate HMR for React
'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint
'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates
'./index.tsx' // the entry point of our app
"react-hot-loader/patch", // Activate HMR for React
"webpack-dev-server/client?http://localhost:8080", // Bundle the client for webpack-dev-server and connect to the provided endpoint
"webpack/hot/only-dev-server", // Bundle the client for hot reloading, only- means to only hot reload for successful updates
"./index.tsx" // The entry point of our app
],
devServer: {
hot: true, // enable HMR on the server
historyApiFallback: true,
hot: true, // Enable HMR on the server
historyApiFallback: true
},
devtool: 'cheap-module-eval-source-map',
devtool: "cheap-module-eval-source-map",
plugins: [
new FaviconsWebpackPlugin({
logo: './assets/img/favicon.png',
logo: "./assets/img/favicon.png",
icons: {
android: false,
appleIcon: false,
@@ -34,7 +34,7 @@ module.exports = merge(commonConfig, {
windows: false
}
}),
new webpack.HotModuleReplacementPlugin(), // enable HMR globally
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
],
new webpack.HotModuleReplacementPlugin(), // Enable HMR globally
new webpack.NamedModulesPlugin() // Prints more readable module names in the browser console on HMR updates
]
});
+18 -17
View File
@@ -1,30 +1,31 @@
// production config
const merge = require('webpack-merge');
const path = require('path')
// Production config
const path = require("path");
const merge = require("webpack-merge");
const resolve = path.resolve;
const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin');
const PrerenderSPAPlugin = require('prerender-spa-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const DynamicCdnWebpackPlugin = require("dynamic-cdn-webpack-plugin");
const PrerenderSPAPlugin = require("prerender-spa-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
/* NOTE: This is a list of all routes that are prerendered for production use.
Please list all routes that contain search engine accessible content, i.e.,
stuff that you would like to find with a Google Search. */
const PRERENDERED_ROUTES = ["/", "/404"];
const commonConfig = require('./common');
const commonConfig = require("./common");
module.exports = merge(commonConfig, {
mode: 'production',
entry: './index.tsx',
mode: "production",
entry: "./index.tsx",
output: {
filename: 'js/bundle.[hash].min.js',
path: resolve(__dirname, '../../dist'),
publicPath: '/',
filename: "js/bundle.[hash].min.js",
path: resolve(__dirname, "../../dist"),
publicPath: "/"
},
devtool: 'source-map',
devtool: "source-map",
plugins: [
new FaviconsWebpackPlugin({
logo: './assets/img/favicon.png',
logo: "./assets/img/favicon.png",
icons: {
android: true,
appleIcon: true,
@@ -41,9 +42,9 @@ module.exports = merge(commonConfig, {
new DynamicCdnWebpackPlugin(),
new PrerenderSPAPlugin({
// Required - The path to the webpack-outputted app to prerender.
staticDir: resolve(__dirname, '../../dist'),
staticDir: resolve(__dirname, "../../dist"),
// Required - Routes to render.
routes: PRERENDERED_ROUTES,
routes: PRERENDERED_ROUTES
})
],
]
});
+2 -1
View File
@@ -19,7 +19,8 @@
"build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js",
"clean-dist": "rm -f -r -d dist",
"lint": "npm run lint:ts && npm run lint:sass",
"lint:ts": "tslint './src/**/**/*.ts*' './src/**/*.ts*' './src/*.ts*' './*.ts*' --format stylish --force",
"lint:ts": "tslint -p tsconfig.json --format stylish --exclude node_modules",
"lint:ts:fix": "tslint -p tsconfig.json --format stylish --exclude node_modules --fix",
"lint:sass": "stylelint ./src/**/**/*.scss ./src/**/*.scss ./src/*.scss",
"start": "npm run start-dev",
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
+2
View File
@@ -5,6 +5,7 @@
true,
"check-space"
],
"eofline": true,
"indent": [
true,
"spaces",
@@ -50,6 +51,7 @@
true,
"check-space"
],
"eofline": true,
"indent": [
true,
"spaces",