Fixed lint errors

This commit is contained in:
Josh Hunt
2017-08-22 09:38:32 +12:00
parent 2ac9343b76
commit dd30e2af0d
3 changed files with 38 additions and 53 deletions
@@ -6,7 +6,7 @@ class DestroyWarn extends Marionette.Behavior {
// just like you can in your Backbone Models
// they will be overriden if you pass in an option with the same key
defaults = {
'message': 'you are destroying!'
message: 'you are destroying!'
};
// behaviors have events that are bound to the views DOM
@@ -22,7 +22,6 @@ class DestroyWarn extends Marionette.Behavior {
}
}
Marionette.Behaviors.getBehaviorClass = (options, key) => {
if (key === 'DestroyWarn')
return DestroyWarn;
@@ -44,7 +43,6 @@ class MyRouter extends Marionette.AppRouter {
someOtherMethod() {
// do something here.
}
}
class MyApplication extends Marionette.Application {
@@ -60,7 +58,7 @@ class MyApplication extends Marionette.Application {
this.mainRegion = new Marionette.Region({ el: '#main' });
this.layoutView.addRegion('main', this.mainRegion);
this.layoutView.render();
this.layoutView.showChildView('main', new MyView(new MyModel));
this.layoutView.showChildView('main', new MyView(new MyModel()));
let view: Backbone.View<Backbone.Model> = this.layoutView.getChildView('main');
let regions: {[key: string]: Marionette.Region} = this.layoutView.getRegions();
let region: Marionette.Region = this.layoutView.removeRegion('main');
@@ -88,7 +86,6 @@ class AppLayoutView extends Marionette.View<Backbone.Model> {
}
class MyModel extends Backbone.Model {
constructor(options?: any) {
super(options);
}
@@ -103,7 +100,6 @@ class MyModel extends Backbone.Model {
}
class MyBaseView extends Marionette.View<MyModel> {
constructor() {
super();
this.getOption('foo');
@@ -111,14 +107,13 @@ class MyBaseView extends Marionette.View<MyModel> {
'click .foo': 'bar'
};
}
}
class MyView extends Marionette.View<MyModel> {
behaviors: any;
constructor(model: MyModel) {
super({ model: model });
super({ model });
this.ui = {
destroy: '.destroy'
@@ -134,8 +129,7 @@ class MyView extends Marionette.View<MyModel> {
template() {
return '<h1>' + this.model.getName() + '</h1> <button class="destroy">Destroy Me</button>';
}
};
}
class MainRegion extends Marionette.Region {
constructor() {
@@ -144,7 +138,6 @@ class MainRegion extends Marionette.Region {
}
}
class MyObject extends Marionette.Object {
name: string;
options: any;
@@ -193,16 +186,16 @@ class MyCollectionView extends Marionette.CollectionView<MyModel, MyView> {
super();
this.childView = MyView;
this.childViewEvents = {
render: function () {
render() {
console.log('a childView has been rendered');
}
};
this.childViewOptions = function (model: any, index: any): any {
this.childViewOptions = (model: any, index: any): any => {
// do some calculations based on the model
return {
id: 'bar'
}
};
};
this.childViewOptions = {
@@ -211,32 +204,30 @@ class MyCollectionView extends Marionette.CollectionView<MyModel, MyView> {
this.childViewEventPrefix = 'some:prefix';
this.on('some:prefix:render', function () {
this.on('some:prefix:render', () => {
});
}
}
var app: MyApplication;
let app: MyApplication;
function ApplicationTests() {
app = new MyApplication();
app.start();
var view = new MyView(new MyModel());
let view = new MyView(new MyModel());
app.mainRegion.show(view);
}
function ObjectTests() {
var obj = new MyObject();
let obj = new MyObject();
console.log(obj.getOption('name'));
obj.destroy('goodbye');
}
function RegionTests() {
var myView: Marionette.View<MyModel> = new MyView(new MyModel());
let myView: Marionette.View<MyModel> = new MyView(new MyModel());
// render and display the view
app.mainRegion.show(myView);
@@ -247,13 +238,13 @@ function RegionTests() {
myView = new MyView(new MyModel());
app.mainRegion.show(myView, { preventDestroy: true });
var hasView: boolean = app.mainRegion.hasView();
let hasView: boolean = app.mainRegion.hasView();
app.mainRegion.reset();
Marionette.Region.prototype.attachHtml = function (view: any): void {
Marionette.Region.prototype.attachHtml = (view: any): void => {
this.$el.empty().append(view.el);
}
};
myView = new Marionette.View<MyModel>({
el: $('#existing-view-stuff')
@@ -261,12 +252,11 @@ function RegionTests() {
app.mainRegion.show(myView);
app.mainRegion.on('empty', function (view: any, region: any, options: any) {
app.mainRegion.on('empty', (view: any, region: any, options: any) => {
// manipulate the `view` or do something extra
// with the `region`
// you also have access to the `options` that were passed to the Region.show call
});
}
function ViewTests() {
@@ -278,7 +268,7 @@ function ViewTests() {
}
function CollectionViewTests() {
var cv = new MyCollectionView();
let cv = new MyCollectionView();
cv.collection.add(new MyModel());
app.mainRegion.show(cv);
cv.emptyView = MyView;
@@ -292,14 +282,13 @@ class MyController {
}
function AppRouterTests() {
var myController = new MyController();
var router = new MyRouter();
let myController = new MyController();
let router = new MyRouter();
router.appRoute('/foo', 'fooThat');
router.processAppRoutes(myController, {
'foo': 'doFoo',
foo: 'doFoo',
'bar/:id': 'doBar'
});
}
+15 -22
View File
@@ -1,10 +1,11 @@
// Type definitions for Marionette v3.3.1
// Type definitions for Marionette 3.3
// Project: https://github.com/marionettejs/
// Definitions by: Zeeshan Hamid <https://github.com/zhamid>, Natan Vivo <https://github.com/nvivo>, Sven Tschui <https://github.com/sventschui>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Backbone from 'backbone';
import * as JQuery from 'jquery';
import * as Radio from 'backbone.radio';
export as namespace Marionette;
@@ -21,7 +22,6 @@ interface CommonMixin {
}
interface RadioMixinOptions {
/**
* Defines the Radio channel that will be used for the requests and/or
* events.
@@ -62,7 +62,6 @@ interface DomMixin {
}
interface ViewMixinOptions {
/**
* Behavior objects to assign to this View.
*/
@@ -143,7 +142,6 @@ interface RegionsMixin {
}
declare class Container<TView> {
/**
* Find a view by it's cid.
*/
@@ -181,7 +179,6 @@ declare class Container<TView> {
}
declare namespace Marionette {
/**
* Alias of Backbones extend function.
*/
@@ -272,7 +269,7 @@ declare namespace Marionette {
* Initialize is called immediately after the Object has been instantiated,
* and is invoked with the same arguments that the constructor received.
*/
initialize?: (options?: ObjectOptions) => void;
initialize?(options?: ObjectOptions): void;
[index: string]: any;
}
@@ -282,7 +279,6 @@ declare namespace Marionette {
* backbone conventions and utilities like initialize and Backbone.Events.
*/
class Object extends Backbone.Events implements CommonMixin, RadioMixin {
constructor(options?: ObjectOptions);
/**
@@ -384,7 +380,6 @@ declare namespace Marionette {
* in your HTML. This will improve the speed of subsequent calls to get a template.
*/
class TemplateCache implements DomMixin {
/**
* Returns a new HTML DOM node instance. The resulting node can be
* passed into the other DOM functions.
@@ -425,7 +420,7 @@ declare namespace Marionette {
* @param el is a jQuery argument: https://api.jquery.com/jQuery/
* @param html is a jQuery.html argument: https://api.jquery.com/html/
*/
setInnerContent(el: any, html: string | Function): void;
setInnerContent(el: any, html: string): void;
/**
* Detach el from the DOM.
@@ -450,7 +445,10 @@ declare namespace Marionette {
findEls(selector: any, context: any): void;
/**
* To use the TemplateCache, call the get method on TemplateCache directly. Internally, instances of the TemplateCache class will be created and stored but you do not have to manually create these instances yourself. get will return a compiled template function.
* To use the TemplateCache, call the get method on TemplateCache
* directly. Internally, instances of the TemplateCache class will be
* created and stored but you do not have to manually create these
* instances yourself. get will return a compiled template function.
*/
static get(templateId: string, options?: any): any;
@@ -526,7 +524,6 @@ declare namespace Marionette {
* views in the correct place.
*/
class Region extends Object implements DomMixin {
/**
* Returns a new HTML DOM node instance. The resulting node can be
* passed into the other DOM functions.
@@ -567,7 +564,7 @@ declare namespace Marionette {
* @param el is a jQuery argument: https://api.jquery.com/jQuery/
* @param html is a jQuery.html argument: https://api.jquery.com/html/
*/
setInnerContent(el: any, html: string | Function): void;
setInnerContent(el: any, html: string): void;
/**
* Detach el from the DOM.
@@ -712,7 +709,6 @@ declare namespace Marionette {
}
interface ViewOptions<TModel extends Backbone.Model> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
/**
* The events attribute binds DOM events to actions to perform on the
* view. It takes DOM event key and a mapping to the handler.
@@ -749,7 +745,6 @@ declare namespace Marionette {
* easily nest multiple views through the regions attribute.
*/
class View<TModel extends Backbone.Model> extends Backbone.View<TModel> implements ViewMixin, RegionsMixin {
constructor(options?: ViewOptions<TModel>);
events(): EventsHash;
@@ -794,7 +789,7 @@ declare namespace Marionette {
* @param el is a jQuery argument: https://api.jquery.com/jQuery/
* @param html is a jQuery.html argument: https://api.jquery.com/html/
*/
setInnerContent(el: any, html: string | Function): void;
setInnerContent(el: any, html: string): void;
/**
* Detach el from the DOM.
@@ -1149,8 +1144,10 @@ declare namespace Marionette {
ui: any;
}
interface CollectionViewOptions<TModel extends Backbone.Model, TCollection extends Backbone.Collection<TModel> = Backbone.Collection<TModel>> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
interface CollectionViewOptions<
TModel extends Backbone.Model,
TCollection extends Backbone.Collection<TModel> = Backbone.Collection<TModel>
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
/**
* Specify a child view to use.
*/
@@ -1171,7 +1168,7 @@ declare namespace Marionette {
* Prevent some of the underlying collection's models from being
* rendered as child views.
*/
filter?: (child?: TModel, index?: number, collection?: TCollection) => boolean;
filter?(child?: TModel, index?: number, collection?: TCollection): boolean;
/**
* Specify a view to use if the collection has no children.
@@ -1211,7 +1208,6 @@ declare namespace Marionette {
* initialize.
*/
class CollectionView<TModel extends Backbone.Model, TView extends View<TModel>, TCollection extends Backbone.Collection<TModel> = Backbone.Collection<TModel>> extends View<TModel> {
constructor(options?: CollectionViewOptions<TModel, TCollection>);
/**
@@ -1457,7 +1453,6 @@ declare namespace Marionette {
* user loads a specific endpoint directly.
*/
class AppRouter extends Backbone.Router {
constructor(options?: AppRouterOptions);
/**
@@ -1499,7 +1494,6 @@ declare namespace Marionette {
* your app
*/
class Application extends Object {
constructor(options?: ApplicationOptions);
/**
@@ -1553,7 +1547,6 @@ declare namespace Marionette {
* allowing you to share common user-facing operations between your views.
*/
class Behavior extends Object {
constructor(options?: any);
options: any;
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}