lint frontend
This commit is contained in:
parent
9ab6c5f350
commit
ada55f14fd
@ -1,3 +1,4 @@
|
||||
/node_modules
|
||||
coverage
|
||||
.nyc_output
|
||||
static
|
@ -14,7 +14,7 @@
|
||||
"test": "BABEL_DISABLE_CACHE=1 NODE_ENV=test CONFIG=$(pwd)/webpack/index.js nyc ava test/*.js --verbose",
|
||||
"open": "nyc report --reporter=html & open coverage/index.html",
|
||||
"coverage": "nyc check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
|
||||
"build-locales": "NODE_ENV=test babel-node scripts/build-locales"
|
||||
"build-locales": " CONFIG=$(pwd)/webpack/index.js NODE_ENV=test babel-node scripts/build-locales"
|
||||
},
|
||||
"dependencies": {
|
||||
"constant-case": "^2.0.0",
|
||||
|
@ -5,7 +5,6 @@ const Ncp = require('ncp');
|
||||
|
||||
const readdir = thenify(fs.readdir);
|
||||
const writeFile = thenify(fs.writeFile);
|
||||
const readFile = thenify(fs.readFile);
|
||||
const ncp = thenify(Ncp.ncp);
|
||||
|
||||
const root = path.join(__dirname, '../locales');
|
||||
@ -27,7 +26,7 @@ const compile = async () => {
|
||||
const files = await readdir(root);
|
||||
const jsons = files.filter(filename => path.extname(filename) === '.json');
|
||||
|
||||
const locales = files.reduce((res, filename) => {
|
||||
const locales = jsons.reduce((res, filename) => {
|
||||
const name = path.parse(filename).name;
|
||||
const json = JSON.stringify(require(path.join(root, filename)));
|
||||
const lang = name.split(/\-/)[0];
|
||||
@ -52,8 +51,6 @@ const compile = async () => {
|
||||
return ncp(source, destination);
|
||||
}));
|
||||
|
||||
|
||||
|
||||
return await Promise.all(Object.keys(locales).map((name) => {
|
||||
console.log(`Writing ${name}.js`);
|
||||
|
||||
|
@ -25,8 +25,9 @@ module.exports = (({
|
||||
).toLowerCase();
|
||||
|
||||
const lang = detectedLocale.split(/\-/)[0];
|
||||
const locale = ReactIntlLocaleData[lang] ?
|
||||
(Locales[detectedLocale] ? detectedLocale : 'en-us') : 'en-us';
|
||||
const locale = ReactIntlLocaleData[lang]
|
||||
? (Locales[detectedLocale] ? detectedLocale : 'en-us')
|
||||
: 'en-us';
|
||||
|
||||
return {
|
||||
locale,
|
||||
|
@ -1,4 +1,3 @@
|
||||
const qs = require('querystring');
|
||||
const React = require('react');
|
||||
const ReactIntlRedux = require('react-intl-redux');
|
||||
const ReactHotLoader = require('react-hot-loader');
|
||||
|
@ -33,7 +33,7 @@ const plugins = {
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
exports.config = {
|
||||
context: path.join(__dirname, '../src'),
|
||||
output: {
|
||||
path: path.join(__dirname, '../static'),
|
||||
@ -76,4 +76,4 @@ module.exports = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.__plugins = plugins;
|
||||
exports.plugins = plugins;
|
@ -1,12 +1,12 @@
|
||||
const graphql = require('../../cloudapi-graphql/src/endpoint');
|
||||
const config = require('./config.js');
|
||||
const base = require('./base.js');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const devServer = {
|
||||
hot: true,
|
||||
compress: true,
|
||||
lazy: false,
|
||||
publicPath: config.output.publicPath,
|
||||
publicPath: base.config.output.publicPath,
|
||||
setup: (app) => {
|
||||
app.use('/graphql', graphql);
|
||||
},
|
||||
@ -15,14 +15,14 @@ const devServer = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Object.assign(config, {
|
||||
module.exports = Object.assign(base.config, {
|
||||
entry: [
|
||||
'react-hot-loader/patch',
|
||||
'webpack-dev-server/client?http://localhost:8080',
|
||||
'webpack/hot/only-dev-server',
|
||||
'./index.js'
|
||||
],
|
||||
plugins: config.plugins.concat([
|
||||
plugins: base.config.plugins.concat([
|
||||
new webpack.HotModuleReplacementPlugin()
|
||||
]),
|
||||
devtool: 'source-map',
|
||||
|
@ -1,11 +1,11 @@
|
||||
const config = require('./config.js');
|
||||
const base = require('./base.js');
|
||||
const webpack = require('webpack');
|
||||
|
||||
module.exports = Object.assign(config, {
|
||||
module.exports = Object.assign(base.config, {
|
||||
entry: [
|
||||
'./index.js'
|
||||
],
|
||||
plugins: config.plugins.concat([
|
||||
plugins: base.config.concat([
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new webpack.optimize.OccurrenceOrderPlugin(true),
|
||||
new webpack.optimize.UglifyJsPlugin()
|
||||
|
@ -1,15 +1,13 @@
|
||||
const config = require('./config');
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const base = require('./base');
|
||||
|
||||
module.exports = {
|
||||
output: {
|
||||
libraryTarget: 'commonjs2'
|
||||
},
|
||||
plugins: [
|
||||
config.__plugins['no-errors-plugin'],
|
||||
config.__plugins['loader-options-plugin'],
|
||||
config.__plugins['define-plugin']
|
||||
base.plugins['no-errors-plugin'],
|
||||
base.plugins['loader-options-plugin'],
|
||||
base.plugins['define-plugin']
|
||||
],
|
||||
module: {
|
||||
loaders: [{
|
||||
|
Loading…
Reference in New Issue
Block a user