Add more linter rules and de-lint

This commit is contained in:
gconsidine
2017-09-18 17:31:06 -04:00
parent cec9507504
commit 777ef3fe90
14 changed files with 186 additions and 159 deletions

View File

@@ -3,8 +3,8 @@ const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CLIENT_PATH = path.resolve(__dirname, '../client');
const LIB_PATH = path.join(CLIENT_PATH, 'lib');
@@ -20,6 +20,7 @@ const NODE_MODULES_PATH = path.join(UI_PATH, 'node_modules');
const SERVICES_PATH = path.join(LIB_PATH, 'services');
const SOURCE_PATH = path.join(CLIENT_PATH, 'src');
const STATIC_PATH = path.join(UI_PATH, 'static');
const THEME_PATH = path.join(LIB_PATH, 'theme');
const APP_ENTRY = path.join(SOURCE_PATH, 'app.js');
const VENDOR_ENTRY = path.join(SOURCE_PATH, 'vendor.js');
@@ -32,7 +33,7 @@ const CHUNKS = ['vendor', 'app'];
const VENDOR = VENDOR_ENTRY;
const APP = [THEME_ENTRY, APP_ENTRY];
let base = {
const base = {
entry: {
vendor: VENDOR,
app: APP
@@ -42,7 +43,17 @@ let base = {
publicPath: '',
filename: OUTPUT
},
stats: 'minimal',
stats: {
children: false,
modules: false,
chunks: false,
excludeAssets: name => {
const chunkNames = `(${CHUNKS.join('|')})`;
const outputPattern = new RegExp(`${chunkNames}\.[a-f0-9]+\.(js|css)$`, 'i');
return !outputPattern.test(name);
}
},
module: {
rules: [
{
@@ -50,7 +61,13 @@ let base = {
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['env']
presets: [
['env', {
targets: {
browsers: ['last 2 versions']
}
}]
]
}
},
{
@@ -81,10 +98,6 @@ let base = {
/node_modules\/d3\/d3\.min.js$/
]
},
{
test: /\.js$/,
use: 'imports-loader?define=>false'
},
{
test: /\.html$/,
use: ['ngtemplate-loader', 'html-loader'],
@@ -169,11 +182,12 @@ let base = {
filename: INDEX_OUTPUT,
inject: false,
chunks: CHUNKS,
chunksSortMode: (moduleA, moduleB) => {
moduleA.files.sort((fileA, fileB) => fileA.includes('js') ? -1 : 1)
moduleB.files.sort((fileA, fileB) => fileA.includes('js') ? -1 : 1)
chunksSortMode: (chunk) => {
if (chunk.names[0] === 'polyfill' || chunk.names[0] === 'vendor') {
return -1;
}
return moduleA.names[0] === 'vendor' ? -1 : 1
return 1;
}
})
],
@@ -183,12 +197,13 @@ let base = {
'~models': MODELS_PATH,
'~services': SERVICES_PATH,
'~components': COMPONENTS_PATH,
'~theme': THEME_PATH,
'~modules': NODE_MODULES_PATH,
'~assets': ASSETS_PATH,
'd3$': '~modules/d3/d3.min.js',
d3$: '~modules/d3/d3.min.js',
'codemirror.jsonlint$': '~modules/codemirror/addon/lint/json-lint.js',
'jquery-resize$': '~modules/javascript-detect-element-resize/jquery.resize.js',
'select2$': '~modules/select2/dist/js/select2.full.min.js',
select2$: '~modules/select2/dist/js/select2.full.min.js',
'js-yaml$': '~modules/js-yaml/dist/js-yaml.min.js',
'lr-infinite-scroll$': '~modules/lr-infinite-scroll/lrInfiniteScroll.js',
'angular-ui-router$': '~modules/angular-ui-router/release/angular-ui-router.js',

View File

@@ -2,27 +2,10 @@ const path = require('path');
const _ = require('lodash');
const ESLINTRC_PATH = path.resolve(__dirname, '..', '.eslintrc.js');
const LINTED_PATHS = [
/.js$/
];
const base = require('./webpack.base');
let base = require('./webpack.base');
let development = {
devtool: 'cheap-source-map',
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader'
}
]
}
const development = {
devtool: 'cheap-source-map'
};
development.module.rules = base.module.rules.concat(development.module.rules)
module.exports = _.merge(base, development);

View File

@@ -5,15 +5,15 @@ const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
let base = require('./webpack.base');
const base = require('./webpack.base');
const CLIENT_PATH = path.resolve(__dirname, '../client');
const UI_PATH = path.resolve(__dirname, '..');
const INSTALL_RUNNING_ENTRY = path.join(CLIENT_PATH, 'installing.template.ejs')
const INSTALL_RUNNING_ENTRY = path.join(CLIENT_PATH, 'installing.template.ejs');
const INSTALL_RUNNING_OUTPUT = path.join(UI_PATH, 'templates/ui/installing.html');
const CHUNKS = ['vendor', 'app'];
let production = {
const production = {
plugins: [
new UglifyJSPlugin({
compress: true,
@@ -25,16 +25,17 @@ let production = {
filename: INSTALL_RUNNING_OUTPUT,
inject: false,
chunks: CHUNKS,
chunksSortMode: (moduleA, moduleB) => {
moduleA.files.sort((fileA, fileB) => fileA.includes('js') ? -1 : 1);
moduleB.files.sort((fileA, fileB) => fileA.includes('js') ? -1 : 1);
chunksSortMode: (chunk) => {
if (chunk.names[0] === 'polyfill' || chunk.names[0] === 'vendor') {
return -1;
}
return moduleA.names[0] === 'vendor' ? -1 : 1;
return 1;
}
})
]
};
production.plugins = base.plugins.concat(production.plugins)
production.plugins = base.plugins.concat(production.plugins);
module.exports = _.merge(base, production);

View File

@@ -5,9 +5,9 @@ const webpack = require('webpack');
const STATIC_URL = '/static/';
let development = require('./webpack.development');
const development = require('./webpack.development');
let test = {
const test = {
plugins: [
new webpack.DefinePlugin({
$basePath: STATIC_URL
@@ -15,7 +15,7 @@ let test = {
]
};
test.plugins = development.plugins.concat(test.plugins)
test.plugins = development.plugins.concat(test.plugins);
module.exports = _.merge(development, test);

View File

@@ -8,9 +8,19 @@ const TARGET_PORT = _.get(process.env, 'npm_package_config_django_port', 8043);
const TARGET_HOST = _.get(process.env, 'npm_package_config_django_host', 'https://localhost');
const TARGET = `https://${TARGET_HOST}:${TARGET_PORT}`;
let development = require('./webpack.development');
const development = require('./webpack.development');
let watch = {
const watch = {
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader'
}
]
},
plugins: [
new HtmlWebpackHarddiskPlugin(),
new webpack.HotModuleReplacementPlugin()
@@ -36,7 +46,8 @@ let watch = {
}
};
watch.plugins = development.plugins.concat(watch.plugins)
watch.module.rules = development.module.rules.concat(watch.module.rules);
watch.plugins = development.plugins.concat(watch.plugins);
module.exports = _.merge(development, watch);