Remove JSCS

ESLint evolved and become mature enough to completely replace
JSCS. This commit translates JSCS rules into ESLint ones and
fixes the code accordingly.

Also, ESLint config converted to YAML for readability

Change-Id: I2bea5b48284c68ecacd3ec3ac67c5852345f29e3
This commit is contained in:
Vitaly Kramskikh 2015-11-08 17:37:23 +07:00
parent a32537e1fa
commit a7e7f05e12
10 changed files with 291 additions and 1394 deletions

266
.eslintrc
View File

@ -1,109 +1,167 @@
{
"plugins": [
"react"
],
"ecmaFeatures": {
"jsx": true
},
"rules": {
"no-cond-assign": 2,
"no-console": 2,
"no-constant-condition": 2,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-regex-spaces": 2,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-typeof": 2,
"no-unexpected-multiline": 2,
---
plugins:
- react
ecmaFeatures:
arrowFunctions: true
classes: true
defaultParams: true
destructuring: true
jsx: true
objectLiteralComputedProperties: true
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
restParams: true
spread: true
superInFunctions: true
rules:
# possible errors
comma-dangle: 2
no-cond-assign: 2
no-console: 2
no-constant-condition: 2
no-debugger: 2
no-dupe-args: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-empty-character-class: 2
no-ex-assign: 2
no-extra-boolean-cast: 2
no-extra-parens: 0
no-extra-semi: 2
no-func-assign: 2
no-inner-declarations: 2
no-invalid-regexp: 2
no-irregular-whitespace: 2
no-negated-in-lhs: 2
no-obj-calls: 2
no-regex-spaces: 2
no-sparse-arrays: 2
no-unexpected-multiline: 2
no-unreachable: 2
use-isnan: 2
valid-typeof: 2
"block-scoped-var": 2,
"complexity": 0,
"consistent-return": 0,
"dot-location": [2, "property"],
"no-caller": 2,
"no-alert": 2,
"no-else-return": 0,
"no-empty-label": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-implied-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-native-reassign": 2,
"no-new-wrappers": 2,
"no-new-func": 2,
"no-new": 2,
"no-octal-escape": 2,
"no-octal": 2,
"no-param-reassign": 0,
"no-proto": 2,
"no-redeclare": 2,
"no-return-assign": 2,
"no-script-url": 0,
"no-self-compare": 2,
"no-sequences": 2,
"no-throw-literal": 2,
"no-unused-expressions": 2,
"no-useless-call": 2,
"radix": 0,
# best practices
block-scoped-var: 2
complexity: 0
consistent-return: 0
dot-location: [2, property]
dot-notation: 2
no-alert: 2
no-caller: 2
no-else-return: 0
no-empty-label: 2
no-empty-pattern: 2
no-eq-null: 2
no-eval: 2
no-implied-eval: 2
no-extend-native: 2
no-extra-bind: 2
no-fallthrough: 2
no-floating-decimal: 2
no-lone-blocks: 2
no-loop-func: 2
no-multi-spaces: 2
no-native-reassign: 2
no-new-wrappers: 2
no-new-func: 2
no-new: 2
no-octal-escape: 2
no-octal: 2
no-param-reassign: 0
no-proto: 2
no-redeclare: 2
no-return-assign: 2
no-script-url: 0
no-self-compare: 2
no-sequences: 2
no-throw-literal: 2
no-unused-expressions: 2
no-useless-call: 2
no-with: 2
radix: 0
yoda: 2
"strict": 2,
# strict mode
strict: 2
"no-delete-var": 2,
"no-shadow-restricted-names": 2,
"no-undef-init": 2,
"no-undef": 2,
"no-unused-vars": 2,
"no-use-before-define": 2,
# variables
no-delete-var: 2
no-shadow-restricted-names: 2
no-undef-init: 2
no-undef: 2
no-unused-vars: 2
no-use-before-define: 2
"id-length": [0, {"min": 2, "exceptions": ["$", "_", "e"]}],
"max-nested-callbacks": [0, 5],
"no-array-constructor": 2,
"no-new-object": 2,
"no-lonely-if": 2,
"no-unneeded-ternary": 2,
"id-match": [2, "^([A-Za-z\\d_$]+)$", {"properties": true}],
"quotes": [2, "single", "avoid-escape"],
# stylistic issues
array-bracket-spacing: [2, never]
brace-style: [2, 1tbs, {allowSingleLine: true}]
camelcase: [2, {properties: never}]
comma-style: [2, last]
comma-spacing: [2, {before: false, after: true}]
computed-property-spacing: [2, never]
eol-last: 2
id-length: [0, {min: 2, exceptions: ['$', '_', 'e']}]
id-match: [2, '^([A-Za-z\d_$]+)$', {properties: true}]
key-spacing: [2, {beforeColon: false, afterColon: true}]
linebreak-style: [2, unix]
max-nested-callbacks: [0, 5]
new-cap: [2, {newIsCap: true, capIsNew: false}]
no-array-constructor: 2
no-new-object: 2
no-lonely-if: 2
no-spaced-func: 2
no-unneeded-ternary: 2
object-curly-spacing: 2
operator-linebreak: [0, after, {overrides: {':': null}}]
padded-blocks: [2, never]
quote-props: [2, as-needed]
quotes: [2, single, avoid-escape]
semi-spacing: [2, {before: false, after: true}]
semi: [0, always]
space-after-keywords: [2, always]
space-before-blocks: [2, always]
space-before-function-paren: [2, never]
space-before-keywords: [2, always]
space-in-parens: [2, never]
space-infix-ops: 2
space-return-throw-case: 2
space-unary-ops: [2, {words: true, nonwords: false}]
spaced-comment: [0, always]
"react/jsx-curly-spacing": [2, "never"],
"react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2,
"react/jsx-quotes": [2, "single", "avoid-escape"],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-unknown-property": 2,
"react/prop-types": 0,
"react/self-closing-comp": 0,
"react/sort-comp": 0
},
"env": {
"browser": true,
"node": true,
"mocha": true,
"amd": true
},
"globals": {
"app": false,
"assert": false,
"sinon": false
}
}
# es6
arrow-parens: [2, as-needed]
arrow-spacing: [2, {before: true, after: true}]
constructor-super: 2
#no-arrow-condition: 2
no-class-assign: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 2
no-var: 0
object-shorthand: 0
prefer-arrow-callback: 0
prefer-const: 0
prefer-spread: 0
prefer-template: 0
# react
react/jsx-curly-spacing: [2, never]
react/jsx-no-duplicate-props: 2
react/jsx-no-undef: 2
react/jsx-quotes: [2, single, avoid-escape]
react/jsx-uses-react: 2
react/jsx-uses-vars: 2
react/no-unknown-property: 2
react/prop-types: 0
react/self-closing-comp: 0
react/sort-comp: 0
env:
browser: true
node: true
mocha: true
amd: true
globals:
app: false
assert: false
sinon: false

View File

@ -147,26 +147,10 @@ var styleFiles = [
'!static/vendor/**'
];
gulp.task('jscs:fix', function() {
var jscs = require('gulp-jscs');
var jscsConfig = JSON.parse(fs.readFileSync('./.jscsrc'));
return gulp.src(jsFiles, {base: '.'})
.pipe(jscs(_.extend({fix: true}, jscsConfig)))
.pipe(gulp.dest('.'));
});
gulp.task('jscs', function() {
var jscs = require('gulp-jscs');
var jscsConfig = JSON.parse(fs.readFileSync('./.jscsrc'));
return gulp.src(jsFiles)
.pipe(jscs(jscsConfig));
});
gulp.task('eslint', function() {
var eslint = require('gulp-eslint');
var eslintConfig = JSON.parse(fs.readFileSync('./.eslintrc'));
return gulp.src(jsFiles)
.pipe(eslint(eslintConfig))
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
@ -200,7 +184,6 @@ gulp.task('lintspaces:styles', function() {
});
gulp.task('lint', [
'jscs',
'eslint',
'lintspaces:js',
'lintspaces:styles'

1372
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -45,11 +45,10 @@
"devDependencies": {
"chai": "~3.2.0",
"es5-shim": "4.1.11",
"eslint": "1.7.3",
"eslint-plugin-react": "3.1.0",
"esprima-fb": "13001.1001.0-dev-harmony-fb",
"glob": "~5.0.5",
"gulp-eslint": "1.0.0",
"gulp-jscs": "1.6.0",
"gulp-lintspaces": "0.3.1",
"gulp-shell": "0.4.1",
"intern": "2.2.2",

View File

@ -61,7 +61,7 @@ define(['jquery', 'underscore', 'js-cookie'], function($, _, Cookies) {
Cookies.set('token', result.access.token.id);
return deferred;
} catch(e) {
} catch (e) {
return $.Deferred().reject();
}
}, this)).fail(_.bind(function() {
@ -92,7 +92,7 @@ define(['jquery', 'underscore', 'js-cookie'], function($, _, Cookies) {
Cookies.set('token', result.access.token.id);
return deferred;
} catch(e) {
} catch (e) {
return $.Deferred().reject();
}
}, this));

View File

@ -705,7 +705,7 @@ define([
getMaxSize: function() {
var volumes = this.collection.disk.get('volumes'),
diskAllocatedSpace = volumes.reduce(function(total, volume) {return this.get('name') == volume.get('name') ? total : total + volume.get('size');}, 0, this);
return this.collection.disk.get('size') - diskAllocatedSpace ;
return this.collection.disk.get('size') - diskAllocatedSpace;
},
validate: function(attrs, options) {
var min = this.getMinimalSize(options.minimum);
@ -770,7 +770,7 @@ define([
model: models.Interface,
generateBondName: function(base) {
var index, proposedName;
for (index = 0;; index += 1) {
for (index = 0; ; index += 1) {
proposedName = base + index;
if (!this.any({name: proposedName})) return proposedName;
}

View File

@ -147,11 +147,11 @@ define([
var activeFiltersPanelSelector = '.active-filters',
moreControlSelector = '.filters .more-control';
return this.remote
.assertElementNotExists(activeFiltersPanelSelector , 'Environment has no active filters by default')
.assertElementNotExists(activeFiltersPanelSelector, 'Environment has no active filters by default')
.clickByCssSelector(filtersButtonSelector)
.assertElementsExist('.filters .filter-control', 2, 'Filters panel has 2 default filters')
.clickByCssSelector('.filter-by-roles')
.assertElementNotExists('.filter-by-roles [type=checkbox]:checked' , 'There are no active options in Roles filter')
.assertElementNotExists('.filter-by-roles [type=checkbox]:checked', 'There are no active options in Roles filter')
.assertElementNotExists('.filters .filter-control .btn-remove-filter', 'Default filters can not be deleted from filters panel')
.assertElementNotExists('.filters .btn-reset-filters', 'No filters to be reset')
.clickByCssSelector(moreControlSelector + ' button')

View File

@ -214,8 +214,7 @@ define([
event = createEvent('DragEvent');
event.initDragEvent(eventName, true, true, window, 0, screenX, screenY, clientX,
clientY, false, false, false, false, 0, null, dataTransfer);
}
catch (error) {
} catch (error) {
event = createCustomEvent(eventName, screenX, screenY, clientX, clientY);
event.dataTransfer = dataTransfer;
}
@ -234,8 +233,7 @@ define([
event = createEvent('MouseEvent');
event.initMouseEvent(eventName, true, true, window, 0, screenX, screenY, clientX, clientY,
false, false, false, false, 0, null);
}
catch (error) {
} catch (error) {
event = createCustomEvent(eventName, screenX, screenY, clientX, clientY);
}
@ -279,8 +277,7 @@ define([
try {
dragAndDrop(dragFrom, dragTo);
done(null);
}
catch (error) {
} catch (error) {
done(error.message);
}
}, [dragSource, dragTarget]).finally(function(result) {

View File

@ -113,7 +113,7 @@ function($, _, React, i18n, utils) {
}
return excerpt;
} else {
return states[null];
return states.null;
}
},
renderChildModes: function(modes, level) {

View File

@ -432,7 +432,7 @@ function(require, $, _, i18n, Backbone, stickit, utils, models, createClusterWiz
disabled: this.checkRestrictions(_.where(attributeConfig.restrictions, {action: 'disable'})) ? 'disabled' : '',
descriptionClasses: configToUse.descriptionClasses,
label: attributeConfig.label,
hasDescription: _.isUndefined(configToUse.hasDescription) ? false : configToUse.hasDescription ,
hasDescription: _.isUndefined(configToUse.hasDescription) ? false : configToUse.hasDescription,
description: attributeConfig.description
})));
break;