Permalink
Browse files

Merge pull request #3241 from RomanovRoman/eslint_imports

Eslint imports
  • Loading branch information...
2 parents 6a72aff + e887d16 commit c72e95ae58c7de3572eb04c49859a59c082684fe @paulfalgout paulfalgout committed on GitHub Oct 25, 2016
View
@@ -45,6 +45,7 @@
"no-multi-str": 2,
"no-multiple-empty-lines": 2,
"no-new": 2,
+ "no-multi-spaces": "error",
"no-proto": 2,
"no-script-url": 2,
"no-sequences": 2,
View
@@ -3,6 +3,7 @@ import eslint from 'gulp-eslint';
import lintspaces from 'gulp-lintspaces';
import plumber from 'gulp-plumber';
import util from 'gulp-util';
+import gulpIf from 'gulp-if';
function onError() {
util.beep();
@@ -19,14 +20,33 @@ function lint(files) {
.on('error', onError);
}
+function isFixed(file) {
+ return file.eslint && file.eslint.fixed;
+}
+
+function lintFix(folder) {
+ return gulp.src(folder + '/**/*.js')
+ .pipe(eslint({ fix: true }))
+ .pipe(eslint.format())
+ .pipe(gulpIf(isFixed, gulp.dest(folder)));
+}
+
function lintSrc() {
return lint(['src/**/*.js']);
}
+function lintSrcFix() {
+ return lintFix('src');
+}
+
function lintTest() {
return lint(['test/**/*.js']);
}
+function lintTestFix() {
+ return lintFix('test');
+}
+
function lintMd() {
return gulp.src('docs/*.md')
.pipe(plumber())
@@ -37,10 +57,16 @@ function lintMd() {
gulp.task('lint-src', lintSrc);
+gulp.task('lint-src-fix', lintSrcFix);
+
gulp.task('lint-test', lintTest);
+gulp.task('lint-test-fix', lintTestFix);
+
gulp.task('lint-code', ['lint-src', 'lint-test']);
gulp.task('lint-docs', lintMd);
gulp.task('lint', ['lint-code', 'lint-docs']);
+
+gulp.task('esfix', ['lint-src-fix', 'lint-test-fix']);
View
@@ -19,6 +19,7 @@
"license": "MIT",
"scripts": {
"build": "gulp build",
+ "esfix": "gulp esfix",
"coverage": "gulp coverage",
"coveralls": "gulp coveralls",
"test": "gulp",
@@ -62,6 +63,7 @@
"gulp-eslint": "3.0.1",
"gulp-file": "0.3.0",
"gulp-filter": "4.0.0",
+ "gulp-if": "^2.0.1",
"gulp-istanbul": "1.1.1",
"gulp-lintspaces": "0.5.0",
"gulp-livereload": "3.8.1",
View
@@ -17,11 +17,11 @@
//
// You can also add standard routes to an AppRouter.
-import Backbone from 'backbone';
-import _ from 'underscore';
-import { triggerMethod } from './common/trigger-method';
-import MarionetteError from './error';
-import CommonMixin from './mixins/common';
+import Backbone from 'backbone';
+import _ from 'underscore';
+import { triggerMethod } from './common/trigger-method';
+import MarionetteError from './error';
+import CommonMixin from './mixins/common';
const ClassOptions = [
'appRoutes',
@@ -1,15 +1,15 @@
-import Backbone from 'backbone';
-import {version} from '../package.json';
+import Backbone from 'backbone';
+import {version} from '../package.json';
-import proxy from './utils/proxy';
-import extend from './utils/extend';
-import deprecate from './utils/deprecate';
+import proxy from './utils/proxy';
+import extend from './utils/extend';
+import deprecate from './utils/deprecate';
-import isNodeAttached from './common/is-node-attached';
-import mergeOptions from './common/merge-options';
-import getOption from './common/get-option';
-import normalizeMethods from './common/normalize-methods';
-import monitorViewEvents from './common/monitor-view-events';
+import isNodeAttached from './common/is-node-attached';
+import mergeOptions from './common/merge-options';
+import getOption from './common/get-option';
+import normalizeMethods from './common/normalize-methods';
+import monitorViewEvents from './common/monitor-view-events';
import {
bindEvents,
@@ -27,19 +27,19 @@ import {
} from './common/trigger-method';
-import MarionetteObject from './object';
-import TemplateCache from './template-cache';
-import View from './view';
-import CollectionView from './collection-view';
-import CompositeView from './composite-view';
-import Behavior from './behavior';
-import Region from './region';
-import Application from './application';
-import AppRouter from './app-router';
-import MarionetteError from './error';
+import MarionetteObject from './object';
+import TemplateCache from './template-cache';
+import View from './view';
+import CollectionView from './collection-view';
+import CompositeView from './composite-view';
+import Behavior from './behavior';
+import Region from './region';
+import Application from './application';
+import AppRouter from './app-router';
+import MarionetteError from './error';
-import behaviorsLookup from './config/behaviors-lookup';
-import Renderer from './config/renderer';
+import behaviorsLookup from './config/behaviors-lookup';
+import Renderer from './config/renderer';
import {
FEATURES,
View
@@ -6,12 +6,12 @@
// Behaviors allow you to blackbox View specific interactions
// into portable logical chunks, keeping your views simple and your code DRY.
-import _ from 'underscore';
+import _ from 'underscore';
import getUniqueEventName from './utils/get-unique-event-name';
-import MarionetteObject from './object';
-import DelegateEntityEventsMixin from './mixins/delegate-entity-events';
-import TriggersMixin from './mixins/triggers';
-import UIMixin from './mixins/ui';
+import MarionetteObject from './object';
+import DelegateEntityEventsMixin from './mixins/delegate-entity-events';
+import TriggersMixin from './mixins/triggers';
+import UIMixin from './mixins/ui';
const ClassOptions = [
'collectionEvents',
@@ -1,15 +1,15 @@
// Collection View
// ---------------
-import _ from 'underscore';
-import Backbone from 'backbone';
+import _ from 'underscore';
+import Backbone from 'backbone';
import destroyBackboneView from './utils/destroy-backbone-view';
-import isNodeAttached from './common/is-node-attached';
-import monitorViewEvents from './common/monitor-view-events';
+import isNodeAttached from './common/is-node-attached';
+import monitorViewEvents from './common/monitor-view-events';
import { triggerMethodOn } from './common/trigger-method';
import ChildViewContainer from './child-view-container';
-import MarionetteError from './error';
-import ViewMixin from './mixins/view';
+import MarionetteError from './error';
+import ViewMixin from './mixins/view';
const ClassOptions = [
'behaviors',
@@ -13,7 +13,7 @@
// configuration. Multiple handlers can be separated by a space. A
// function can be supplied instead of a string handler name.
-import _ from 'underscore';
+import _ from 'underscore';
import MarionetteError from '../error';
// Bind/unbind the event to handlers specified as a string of
@@ -1,7 +1,7 @@
// Trigger Method
// --------------
-import _ from 'underscore';
+import _ from 'underscore';
import getOption from './get-option';
// split the event name on the ":"
@@ -1,11 +1,11 @@
// Composite View
// --------------
-import _ from 'underscore';
-import deprecate from './utils/deprecate';
+import _ from 'underscore';
+import deprecate from './utils/deprecate';
import MarionetteError from './error';
-import CollectionView from './collection-view';
-import View from './view';
+import CollectionView from './collection-view';
+import View from './view';
const ClassOptions = [
'childViewContainer',
@@ -1,4 +1,4 @@
-import MarionetteError from '../error';
+import MarionetteError from '../error';
// Placeholder method to be extended by the user.
// The method should define the object that stores the behaviors.
@@ -1,9 +1,9 @@
// Renderer
// --------
-import _ from 'underscore';
+import _ from 'underscore';
import MarionetteError from '../error';
-import TemplateCache from '../template-cache';
+import TemplateCache from '../template-cache';
// Render a template with data by passing in the template
// selector and the data to render.
View
@@ -1,7 +1,7 @@
// Error
// -----
-import _ from 'underscore';
+import _ from 'underscore';
import extend from './utils/extend';
import {version} from '../package.json';
@@ -1,7 +1,7 @@
-import _ from 'underscore';
-import _invoke from '../utils/invoke';
-import { triggerMethod } from '../common/trigger-method';
-import Marionette from '../backbone.marionette';
+import _ from 'underscore';
+import _invoke from '../utils/invoke';
+import { triggerMethod } from '../common/trigger-method';
+import Marionette from '../backbone.marionette';
// MixinOptions
// - behaviors
View
@@ -1,11 +1,11 @@
-import _setOptions from '../utils/set-options';
-import getOption from '../common/get-option';
-import mergeOptions from '../common/merge-options';
-import normalizeMethods from '../common/normalize-methods';
+import _setOptions from '../utils/set-options';
+import getOption from '../common/get-option';
+import mergeOptions from '../common/merge-options';
+import normalizeMethods from '../common/normalize-methods';
import {
bindEvents,
unbindEvents
-} from '../common/bind-events';
+} from '../common/bind-events';
export default {
@@ -15,7 +15,7 @@ export default {
_initRegions() {
// init regions hash
- this.regions = this.regions || {};
+ this.regions = this.regions || {};
this._regions = {};
this.addRegions(_.result(this, 'regions'));
View
@@ -248,6 +248,6 @@ const ViewMixin = {
}
};
-_.extend(ViewMixin, BehaviorsMixin, CommonMixin, DelegateEntityEventsMixin, TriggersMixin, UIMixin);
+_.extend(ViewMixin, BehaviorsMixin, CommonMixin, DelegateEntityEventsMixin, TriggersMixin, UIMixin);
export default ViewMixin;
@@ -1,8 +1,8 @@
// Template Cache
// --------------
-import _ from 'underscore';
-import Backbone from 'backbone';
+import _ from 'underscore';
+import Backbone from 'backbone';
import MarionetteError from './error';
// Manage templates stored in `<script>` blocks,
View
@@ -1,13 +1,13 @@
// View
// ---------
-import _ from 'underscore';
-import Backbone from 'backbone';
-import isNodeAttached from './common/is-node-attached';
-import monitorViewEvents from './common/monitor-view-events';
-import ViewMixin from './mixins/view';
-import RegionsMixin from './mixins/regions';
-import Renderer from './config/renderer';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import isNodeAttached from './common/is-node-attached';
+import monitorViewEvents from './common/monitor-view-events';
+import ViewMixin from './mixins/view';
+import RegionsMixin from './mixins/regions';
+import Renderer from './config/renderer';
const ClassOptions = [
'behaviors',
View
@@ -40,7 +40,7 @@ module.exports = function(mochaRunner) {
$fixtures = $('<div id="fixtures">');
$('body').append($fixtures);
this.checkProperties = checkProperties;
- this.setFixtures = setFixtures;
+ this.setFixtures = setFixtures;
this.clearFixtures = clearFixtures;
});
Oops, something went wrong.

0 comments on commit c72e95a

Please sign in to comment.