lint frontend

This commit is contained in:
Sérgio Ramos 2016-10-24 14:11:50 +01:00
parent 9ab6c5f350
commit ada55f14fd
9 changed files with 21 additions and 25 deletions

View File

@ -1,3 +1,4 @@
/node_modules /node_modules
coverage coverage
.nyc_output .nyc_output
static

View File

@ -14,7 +14,7 @@
"test": "BABEL_DISABLE_CACHE=1 NODE_ENV=test CONFIG=$(pwd)/webpack/index.js nyc ava test/*.js --verbose", "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", "open": "nyc report --reporter=html & open coverage/index.html",
"coverage": "nyc check-coverage --statements 100 --functions 100 --lines 100 --branches 100", "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": { "dependencies": {
"constant-case": "^2.0.0", "constant-case": "^2.0.0",

View File

@ -5,7 +5,6 @@ const Ncp = require('ncp');
const readdir = thenify(fs.readdir); const readdir = thenify(fs.readdir);
const writeFile = thenify(fs.writeFile); const writeFile = thenify(fs.writeFile);
const readFile = thenify(fs.readFile);
const ncp = thenify(Ncp.ncp); const ncp = thenify(Ncp.ncp);
const root = path.join(__dirname, '../locales'); const root = path.join(__dirname, '../locales');
@ -27,7 +26,7 @@ const compile = async () => {
const files = await readdir(root); const files = await readdir(root);
const jsons = files.filter(filename => path.extname(filename) === '.json'); 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 name = path.parse(filename).name;
const json = JSON.stringify(require(path.join(root, filename))); const json = JSON.stringify(require(path.join(root, filename)));
const lang = name.split(/\-/)[0]; const lang = name.split(/\-/)[0];
@ -52,8 +51,6 @@ const compile = async () => {
return ncp(source, destination); return ncp(source, destination);
})); }));
return await Promise.all(Object.keys(locales).map((name) => { return await Promise.all(Object.keys(locales).map((name) => {
console.log(`Writing ${name}.js`); console.log(`Writing ${name}.js`);

View File

@ -25,8 +25,9 @@ module.exports = (({
).toLowerCase(); ).toLowerCase();
const lang = detectedLocale.split(/\-/)[0]; const lang = detectedLocale.split(/\-/)[0];
const locale = ReactIntlLocaleData[lang] ? const locale = ReactIntlLocaleData[lang]
(Locales[detectedLocale] ? detectedLocale : 'en-us') : 'en-us'; ? (Locales[detectedLocale] ? detectedLocale : 'en-us')
: 'en-us';
return { return {
locale, locale,

View File

@ -1,4 +1,3 @@
const qs = require('querystring');
const React = require('react'); const React = require('react');
const ReactIntlRedux = require('react-intl-redux'); const ReactIntlRedux = require('react-intl-redux');
const ReactHotLoader = require('react-hot-loader'); const ReactHotLoader = require('react-hot-loader');

View File

@ -33,7 +33,7 @@ const plugins = {
}) })
}; };
module.exports = { exports.config = {
context: path.join(__dirname, '../src'), context: path.join(__dirname, '../src'),
output: { output: {
path: path.join(__dirname, '../static'), path: path.join(__dirname, '../static'),
@ -76,4 +76,4 @@ module.exports = {
} }
}; };
module.exports.__plugins = plugins; exports.plugins = plugins;

View File

@ -1,12 +1,12 @@
const graphql = require('../../cloudapi-graphql/src/endpoint'); const graphql = require('../../cloudapi-graphql/src/endpoint');
const config = require('./config.js'); const base = require('./base.js');
const webpack = require('webpack'); const webpack = require('webpack');
const devServer = { const devServer = {
hot: true, hot: true,
compress: true, compress: true,
lazy: false, lazy: false,
publicPath: config.output.publicPath, publicPath: base.config.output.publicPath,
setup: (app) => { setup: (app) => {
app.use('/graphql', graphql); app.use('/graphql', graphql);
}, },
@ -15,14 +15,14 @@ const devServer = {
} }
}; };
module.exports = Object.assign(config, { module.exports = Object.assign(base.config, {
entry: [ entry: [
'react-hot-loader/patch', 'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:8080', 'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server', 'webpack/hot/only-dev-server',
'./index.js' './index.js'
], ],
plugins: config.plugins.concat([ plugins: base.config.plugins.concat([
new webpack.HotModuleReplacementPlugin() new webpack.HotModuleReplacementPlugin()
]), ]),
devtool: 'source-map', devtool: 'source-map',

View File

@ -1,11 +1,11 @@
const config = require('./config.js'); const base = require('./base.js');
const webpack = require('webpack'); const webpack = require('webpack');
module.exports = Object.assign(config, { module.exports = Object.assign(base.config, {
entry: [ entry: [
'./index.js' './index.js'
], ],
plugins: config.plugins.concat([ plugins: base.config.concat([
new webpack.optimize.DedupePlugin(), new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(true), new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.optimize.UglifyJsPlugin() new webpack.optimize.UglifyJsPlugin()

View File

@ -1,15 +1,13 @@
const config = require('./config'); const base = require('./base');
const webpack = require('webpack');
const path = require('path');
module.exports = { module.exports = {
output: { output: {
libraryTarget: 'commonjs2' libraryTarget: 'commonjs2'
}, },
plugins: [ plugins: [
config.__plugins['no-errors-plugin'], base.plugins['no-errors-plugin'],
config.__plugins['loader-options-plugin'], base.plugins['loader-options-plugin'],
config.__plugins['define-plugin'] base.plugins['define-plugin']
], ],
module: { module: {
loaders: [{ loaders: [{