Improve eslint rules (#3147)
* Add semi to ESLint rules * Add padded-blocks to ESLint rules * Add comma-dangle to ESLint rules * add config/webpack and storyboard * add streaming/ * yarn test:lint -- --fix
This commit is contained in:
		
				
					committed by
					
						
						Eugen Rochko
					
				
			
			
				
	
			
			
			
						parent
						
							812fe90eca
						
					
				
				
					commit
					2e112e2406
				
			@@ -1,20 +1,20 @@
 | 
			
		||||
// Common configuration for webpacker loaded from config/webpack/paths.yml
 | 
			
		||||
 | 
			
		||||
const { join, resolve } = require('path')
 | 
			
		||||
const { env } = require('process')
 | 
			
		||||
const { safeLoad } = require('js-yaml')
 | 
			
		||||
const { readFileSync } = require('fs')
 | 
			
		||||
const { join, resolve } = require('path');
 | 
			
		||||
const { env } = require('process');
 | 
			
		||||
const { safeLoad } = require('js-yaml');
 | 
			
		||||
const { readFileSync } = require('fs');
 | 
			
		||||
 | 
			
		||||
const configPath = resolve('config', 'webpack')
 | 
			
		||||
const loadersDir = join(__dirname, 'loaders')
 | 
			
		||||
const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[env.NODE_ENV || 'development']
 | 
			
		||||
const devServer = safeLoad(readFileSync(join(configPath, 'development.server.yml'), 'utf8'))[env.NODE_ENV || 'development']
 | 
			
		||||
const configPath = resolve('config', 'webpack');
 | 
			
		||||
const loadersDir = join(__dirname, 'loaders');
 | 
			
		||||
const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[env.NODE_ENV || 'development'];
 | 
			
		||||
const devServer = safeLoad(readFileSync(join(configPath, 'development.server.yml'), 'utf8'))[env.NODE_ENV || 'development'];
 | 
			
		||||
 | 
			
		||||
// Compute public path based on environment and CDN_HOST in production
 | 
			
		||||
const ifHasCDN = env.CDN_HOST !== undefined && env.NODE_ENV === 'production'
 | 
			
		||||
const devServerUrl = `http://${devServer.host}:${devServer.port}/${paths.entry}/`
 | 
			
		||||
const publicUrl = ifHasCDN ? `${env.CDN_HOST}/${paths.entry}/` : `/${paths.entry}/`
 | 
			
		||||
const publicPath = env.NODE_ENV !== 'production' ? devServerUrl : publicUrl
 | 
			
		||||
const ifHasCDN = env.CDN_HOST !== undefined && env.NODE_ENV === 'production';
 | 
			
		||||
const devServerUrl = `http://${devServer.host}:${devServer.port}/${paths.entry}/`;
 | 
			
		||||
const publicUrl = ifHasCDN ? `${env.CDN_HOST}/${paths.entry}/` : `/${paths.entry}/`;
 | 
			
		||||
const publicPath = env.NODE_ENV !== 'production' ? devServerUrl : publicUrl;
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  devServer,
 | 
			
		||||
@@ -22,5 +22,5 @@ module.exports = {
 | 
			
		||||
  paths,
 | 
			
		||||
  loadersDir,
 | 
			
		||||
  publicUrl,
 | 
			
		||||
  publicPath
 | 
			
		||||
}
 | 
			
		||||
  publicPath,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,16 @@
 | 
			
		||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
 | 
			
		||||
 | 
			
		||||
const merge = require('webpack-merge')
 | 
			
		||||
const sharedConfig = require('./shared.js')
 | 
			
		||||
const merge = require('webpack-merge');
 | 
			
		||||
const sharedConfig = require('./shared.js');
 | 
			
		||||
 | 
			
		||||
module.exports = merge(sharedConfig, {
 | 
			
		||||
  devtool: 'cheap-module-eval-source-map',
 | 
			
		||||
 | 
			
		||||
  stats: {
 | 
			
		||||
    errorDetails: true
 | 
			
		||||
    errorDetails: true,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  output: {
 | 
			
		||||
    pathinfo: true
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
    pathinfo: true,
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
 | 
			
		||||
 | 
			
		||||
const { resolve } = require('path')
 | 
			
		||||
const merge = require('webpack-merge')
 | 
			
		||||
const devConfig = require('./development.js')
 | 
			
		||||
const { devServer, publicPath, paths } = require('./configuration.js')
 | 
			
		||||
const { resolve } = require('path');
 | 
			
		||||
const merge = require('webpack-merge');
 | 
			
		||||
const devConfig = require('./development.js');
 | 
			
		||||
const { devServer, publicPath, paths } = require('./configuration.js');
 | 
			
		||||
 | 
			
		||||
module.exports = merge(devConfig, {
 | 
			
		||||
  devServer: {
 | 
			
		||||
@@ -14,6 +14,6 @@ module.exports = merge(devConfig, {
 | 
			
		||||
    historyApiFallback: true,
 | 
			
		||||
    contentBase: resolve(paths.output, paths.entry),
 | 
			
		||||
    publicPath,
 | 
			
		||||
    disableHostCheck: true
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
    disableHostCheck: true,
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
const { env, publicPath } = require('../configuration.js')
 | 
			
		||||
const { env, publicPath } = require('../configuration.js');
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,
 | 
			
		||||
@@ -6,7 +6,7 @@ module.exports = {
 | 
			
		||||
    loader: 'file-loader',
 | 
			
		||||
    options: {
 | 
			
		||||
      publicPath,
 | 
			
		||||
      name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]'
 | 
			
		||||
    }
 | 
			
		||||
  }]
 | 
			
		||||
}
 | 
			
		||||
      name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]',
 | 
			
		||||
    },
 | 
			
		||||
  }],
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,6 @@ module.exports = {
 | 
			
		||||
  exclude: /node_modules/,
 | 
			
		||||
  loader: 'babel-loader',
 | 
			
		||||
  options: {
 | 
			
		||||
    forceEnv: process.env.NODE_ENV || 'development'
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
    forceEnv: process.env.NODE_ENV || 'development',
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
module.exports = {
 | 
			
		||||
  test: /\.coffee(\.erb)?$/,
 | 
			
		||||
  loader: 'coffee-loader'
 | 
			
		||||
}
 | 
			
		||||
  loader: 'coffee-loader',
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,6 @@ module.exports = {
 | 
			
		||||
  exclude: /node_modules/,
 | 
			
		||||
  loader: 'rails-erb-loader',
 | 
			
		||||
  options: {
 | 
			
		||||
    runner: 'bin/rails runner'
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
    runner: 'bin/rails runner',
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
 | 
			
		||||
const { env } = require('../configuration.js')
 | 
			
		||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
 | 
			
		||||
const { env } = require('../configuration.js');
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  test: /\.(scss|sass|css)$/i,
 | 
			
		||||
@@ -8,7 +8,7 @@ module.exports = {
 | 
			
		||||
    use: [
 | 
			
		||||
      { loader: 'css-loader', options: { minimize: env.NODE_ENV === 'production' } },
 | 
			
		||||
      'postcss-loader',
 | 
			
		||||
      'sass-loader'
 | 
			
		||||
    ]
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
      'sass-loader',
 | 
			
		||||
    ],
 | 
			
		||||
  }),
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
 | 
			
		||||
/* eslint global-require: 0 */
 | 
			
		||||
 | 
			
		||||
const webpack = require('webpack')
 | 
			
		||||
const merge = require('webpack-merge')
 | 
			
		||||
const CompressionPlugin = require('compression-webpack-plugin')
 | 
			
		||||
const sharedConfig = require('./shared.js')
 | 
			
		||||
const webpack = require('webpack');
 | 
			
		||||
const merge = require('webpack-merge');
 | 
			
		||||
const CompressionPlugin = require('compression-webpack-plugin');
 | 
			
		||||
const sharedConfig = require('./shared.js');
 | 
			
		||||
 | 
			
		||||
module.exports = merge(sharedConfig, {
 | 
			
		||||
 | 
			
		||||
@@ -19,15 +19,15 @@ module.exports = merge(sharedConfig, {
 | 
			
		||||
      mangle: true,
 | 
			
		||||
 | 
			
		||||
      output: {
 | 
			
		||||
        comments: false
 | 
			
		||||
        comments: false,
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      sourceMap: true
 | 
			
		||||
      sourceMap: true,
 | 
			
		||||
    }),
 | 
			
		||||
    new CompressionPlugin({
 | 
			
		||||
      asset: '[path].gz[query]',
 | 
			
		||||
      algorithm: 'gzip',
 | 
			
		||||
      test: /\.(js|css|svg|eot|ttf|woff|woff2)$/
 | 
			
		||||
    })
 | 
			
		||||
  ]
 | 
			
		||||
})
 | 
			
		||||
      test: /\.(js|css|svg|eot|ttf|woff|woff2)$/,
 | 
			
		||||
    }),
 | 
			
		||||
  ],
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -3,24 +3,24 @@
 | 
			
		||||
/* eslint global-require: 0 */
 | 
			
		||||
/* eslint import/no-dynamic-require: 0 */
 | 
			
		||||
 | 
			
		||||
const webpack = require('webpack')
 | 
			
		||||
const { basename, dirname, join, relative, resolve } = require('path')
 | 
			
		||||
const { sync } = require('glob')
 | 
			
		||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
 | 
			
		||||
const ManifestPlugin = require('webpack-manifest-plugin')
 | 
			
		||||
const extname = require('path-complete-extname')
 | 
			
		||||
const { env, paths, publicPath, loadersDir } = require('./configuration.js')
 | 
			
		||||
const webpack = require('webpack');
 | 
			
		||||
const { basename, dirname, join, relative, resolve } = require('path');
 | 
			
		||||
const { sync } = require('glob');
 | 
			
		||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
 | 
			
		||||
const ManifestPlugin = require('webpack-manifest-plugin');
 | 
			
		||||
const extname = require('path-complete-extname');
 | 
			
		||||
const { env, paths, publicPath, loadersDir } = require('./configuration.js');
 | 
			
		||||
 | 
			
		||||
const extensionGlob = `**/*{${paths.extensions.join(',')}}*`
 | 
			
		||||
const packPaths = sync(join(paths.source, paths.entry, extensionGlob))
 | 
			
		||||
const extensionGlob = `**/*{${paths.extensions.join(',')}}*`;
 | 
			
		||||
const packPaths = sync(join(paths.source, paths.entry, extensionGlob));
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  entry: packPaths.reduce(
 | 
			
		||||
    (map, entry) => {
 | 
			
		||||
      const localMap = map
 | 
			
		||||
      const namespace = relative(join(paths.source, paths.entry), dirname(entry))
 | 
			
		||||
      localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry)
 | 
			
		||||
      return localMap
 | 
			
		||||
      const localMap = map;
 | 
			
		||||
      const namespace = relative(join(paths.source, paths.entry), dirname(entry));
 | 
			
		||||
      localMap[join(namespace, basename(entry, extname(entry)))] = resolve(entry);
 | 
			
		||||
      return localMap;
 | 
			
		||||
    }, {}
 | 
			
		||||
  ),
 | 
			
		||||
 | 
			
		||||
@@ -28,11 +28,11 @@ module.exports = {
 | 
			
		||||
    filename: '[name].js',
 | 
			
		||||
    chunkFilename: '[name]-[chunkhash].js',
 | 
			
		||||
    path: resolve(paths.output, paths.entry),
 | 
			
		||||
    publicPath
 | 
			
		||||
    publicPath,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  module: {
 | 
			
		||||
    rules: sync(join(loadersDir, '*.js')).map(loader => require(loader))
 | 
			
		||||
    rules: sync(join(loadersDir, '*.js')).map(loader => require(loader)),
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  plugins: [
 | 
			
		||||
@@ -41,25 +41,25 @@ module.exports = {
 | 
			
		||||
    new ManifestPlugin({ fileName: paths.manifest, publicPath, writeToFileEmit: true }),
 | 
			
		||||
    new webpack.optimize.CommonsChunkPlugin({
 | 
			
		||||
      name: 'common',
 | 
			
		||||
      minChunks: 2
 | 
			
		||||
    })
 | 
			
		||||
      minChunks: 2,
 | 
			
		||||
    }),
 | 
			
		||||
  ],
 | 
			
		||||
 | 
			
		||||
  resolve: {
 | 
			
		||||
    extensions: paths.extensions,
 | 
			
		||||
    modules: [
 | 
			
		||||
      resolve(paths.source),
 | 
			
		||||
      resolve(paths.node_modules)
 | 
			
		||||
    ]
 | 
			
		||||
      resolve(paths.node_modules),
 | 
			
		||||
    ],
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  resolveLoader: {
 | 
			
		||||
    modules: [paths.node_modules]
 | 
			
		||||
    modules: [paths.node_modules],
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  node: {
 | 
			
		||||
    // Called by http-link-header in an API we never use, increases
 | 
			
		||||
    // bundle size unnecessarily
 | 
			
		||||
    Buffer: false
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
    Buffer: false,
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
// Note: You must restart bin/webpack-dev-server for changes to take effect
 | 
			
		||||
 | 
			
		||||
const merge = require('webpack-merge')
 | 
			
		||||
const sharedConfig = require('./shared.js')
 | 
			
		||||
const merge = require('webpack-merge');
 | 
			
		||||
const sharedConfig = require('./shared.js');
 | 
			
		||||
 | 
			
		||||
module.exports = merge(sharedConfig, {})
 | 
			
		||||
module.exports = merge(sharedConfig, {});
 | 
			
		||||
 
 | 
			
		||||
@@ -7,16 +7,16 @@ const testRFC5626 = function (reRFC5646) {
 | 
			
		||||
    if (!language.match(reRFC5646)) {
 | 
			
		||||
      throw new Error('Not RFC5626 name');
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const testAvailability = function (availableLanguages) {
 | 
			
		||||
  return function (language) {
 | 
			
		||||
    if ((argv.force !== true) && availableLanguages.indexOf(language) < 0) {
 | 
			
		||||
      throw new Error('Not an available language');
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const validateLanguages = function (languages, validators) {
 | 
			
		||||
  let invalidLanguages = languages.reduce((acc, language) => {
 | 
			
		||||
@@ -41,7 +41,7 @@ const validateLanguages = function (languages, validators) {
 | 
			
		||||
    console.log(`\nUse yarn "manage:translations -- --help" for usage information\n`);
 | 
			
		||||
    process.exit(1);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const printHelpMessages = function () {
 | 
			
		||||
  console.log(
 | 
			
		||||
@@ -62,13 +62,13 @@ to input multiple languages, separate them with space.
 | 
			
		||||
Available languages:
 | 
			
		||||
${availableLanguages}
 | 
			
		||||
`);
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// parse arguments
 | 
			
		||||
const argv = require('minimist')(process.argv.slice(2), {
 | 
			
		||||
  'boolean': [
 | 
			
		||||
    'force',
 | 
			
		||||
    'help'
 | 
			
		||||
    'help',
 | 
			
		||||
  ],
 | 
			
		||||
  'alias': {
 | 
			
		||||
    'f': 'force',
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user