Enable linting for node.js files and split .eslintrc

This commit enables linting for node.js files (gulpfile and
helpers, webpack and karma configs) and also splits .eslintrc
into 2 files. This is needed because our node.js files don't
support ES6 syntax, so nailgun/.eslintrc now contains common
linting rules and nailgun/static/.eslintrc contains JSX
and ES6-specific rules.

Implements: blueprint converge-to-eslint-config-openstack

Change-Id: I1956f2022475b39724dfb49f98bdc8e6e5d898e9
This commit is contained in:
Vitaly Kramskikh 2016-01-17 17:51:58 +03:00
parent 631ad02db8
commit faa6d71c09
6 changed files with 165 additions and 161 deletions

View File

@ -1,21 +1,6 @@
---
root: true
extends: openstack
plugins:
- react
ecmaFeatures:
arrowFunctions: true
classes: true
defaultParams: true
destructuring: true
jsx: true
modules: true
objectLiteralComputedProperties: true
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
restParams: true
spread: true
superInFunctions: true
rules:
# disabled rules from openstack config
no-empty: 0 # we use empty blocks with try-catch
@ -59,43 +44,5 @@
quotes: [2, single, avoid-escape]
space-before-function-paren: [2, never]
space-before-keywords: 2
# es6
arrow-parens: 2
arrow-spacing: 2
constructor-super: 2
no-class-assign: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 2
no-var: 0
object-shorthand: [2, methods]
prefer-arrow-callback: 2
prefer-const: 0
prefer-spread: 2
prefer-template: 0
# react
react/jsx-boolean-value: [2, never]
react/jsx-closing-bracket-location: [2, {nonEmpty: false, selfClosing: line-aligned}]
react/jsx-curly-spacing: [2, never]
react/jsx-indent: [2, 2]
react/jsx-indent-props: [2, 2]
react/jsx-key: 2
react/jsx-no-duplicate-props: 2
react/jsx-no-literals: 0
react/jsx-no-undef: 2
react/jsx-pascal-case: 2
react/jsx-uses-react: 2
react/jsx-uses-vars: 2
react/no-deprecated: 2
react/no-unknown-property: 2
react/prefer-es6-class: [2, never]
react/prop-types: 0
react/react-in-jsx-scope: 2
react/self-closing-comp: 2
react/sort-comp: 0
env:
browser: true
globals:
app: false
node: true

View File

@ -1,6 +1,7 @@
/*eslint-disable strict*/
'use strict';
var fs = require('fs');
var gutil = require('gulp-util');
var _ = require('lodash');

View File

@ -14,7 +14,7 @@
* under the License.
**/
/*eslint-env node*/
/*eslint-disable strict*/
'use strict';
@ -92,7 +92,7 @@ gulp.task('selenium', ['selenium:fetch'], function(cb) {
gulp.task('karma', function(cb) {
var Server = require('karma').Server;
new Server({
configFile: __dirname + '/karma.config.js',
configFile: path.join(__dirname, '/karma.config.js'),
browsers: [argv.browser || process.env.BROWSER || 'firefox']
}, cb).start();
});
@ -148,7 +148,7 @@ gulp.task('jison', function() {
gulp.task('license', function(cb) {
require('nlf').find({production: true, depth: 0}, function(err, data) {
if (err) cb(err);
if (err) return cb(err);
// https://github.com/openstack/requirements#for-new-requirements
// Is the library license compatible?
// Preferably Apache2, BSD, MIT licensed. LGPL is ok.
@ -171,25 +171,25 @@ gulp.task('license', function(cb) {
_.each(errors, function(error) {
gutil.log(gutil.colors.red(error.libraryName, 'has', error.license, 'license'));
});
cb('Issues with licenses found');
return cb('Issues with licenses found');
} else {
cb();
return cb();
}
});
});
var jsFiles = [
'*.js',
'gulp/*.js',
'static/**/*.js',
'!static/build/**',
'!static/vendor/**',
'!static/expression/parser.js',
'static/tests/**/*.js'
'!static/expression/parser.js'
];
var styleFiles = [
'static/**/*.less',
'static/**/*.css',
'!static/build/**',
'!static/vendor/**'
'!static/build/**'
];
gulp.task('eslint', function() {
@ -323,7 +323,7 @@ gulp.task('build', function(cb) {
.pipe(gulp.dest(targetDir))
.on('end', cb);
} else if (!config.watch) {
cb();
return cb();
}
});
});

View File

@ -1,7 +1,5 @@
/*eslint-disable strict*/
var webpackConfig = require('./webpack.config');
module.exports = function(config) {
config.set({
browsers: ['firefox'],
@ -44,7 +42,7 @@ module.exports = function(config) {
browserName: 'phantomjs'
}
},
webpack: webpackConfig,
webpack: require('./webpack.config'),
webpackMiddleware: {
noInfo: true
}

57
static/.eslintrc Normal file
View File

@ -0,0 +1,57 @@
---
plugins:
- react
ecmaFeatures:
arrowFunctions: true
classes: true
defaultParams: true
destructuring: true
jsx: true
modules: true
objectLiteralComputedProperties: true
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
restParams: true
spread: true
superInFunctions: true
rules:
# es6
arrow-parens: 2
arrow-spacing: 2
constructor-super: 2
no-class-assign: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 2
no-var: 0
object-shorthand: [2, methods]
prefer-arrow-callback: 2
prefer-const: 0
prefer-spread: 2
prefer-template: 0
# react
react/jsx-boolean-value: [2, never]
react/jsx-closing-bracket-location: [2, {nonEmpty: false, selfClosing: line-aligned}]
react/jsx-curly-spacing: [2, never]
react/jsx-indent: [2, 2]
react/jsx-indent-props: [2, 2]
react/jsx-key: 2
react/jsx-no-duplicate-props: 2
react/jsx-no-literals: 0
react/jsx-no-undef: 2
react/jsx-pascal-case: 2
react/jsx-uses-react: 2
react/jsx-uses-vars: 2
react/no-deprecated: 2
react/no-unknown-property: 2
react/prefer-es6-class: [2, never]
react/prop-types: 0
react/react-in-jsx-scope: 2
react/self-closing-comp: 2
react/sort-comp: 0
env:
browser: true
node: false
globals:
app: false

View File

@ -1,11 +1,12 @@
/*eslint-disable strict*/
module.exports = {
entry: [
'babel-core/polyfill',
'./static/app.js'
],
output: {
path: __dirname + '/static/build/',
path: require('path').join(__dirname, '/static/build/'),
publicPath: '/static/build/',
filename: 'bundle.js',
chunkFilename: null,