Coffeelint next level.

This commit is contained in:
Martin Edenhofer 2015-09-24 08:54:23 +02:00
parent a5cbe9148a
commit e73a5762b7
44 changed files with 203 additions and 24 deletions

View file

@ -218,7 +218,7 @@ class App.Controller extends Spine.Controller
update = => update = =>
ui = @ ui = @
$('.humanTimeFromNow').each( -> $('.humanTimeFromNow').each( ->
item = $(this) item = $(@)
currentVal = item.text() currentVal = item.text()
ui.frontendTimeUpdateItem(item, currentVal) ui.frontendTimeUpdateItem(item, currentVal)
) )
@ -267,7 +267,7 @@ class App.Controller extends Spine.Controller
) )
html = $(html) html = $(html)
html.find('.humanTimeFromNow').each( -> html.find('.humanTimeFromNow').each( ->
item = $(this) item = $(@)
ui.frontendTimeUpdateItem(item) ui.frontendTimeUpdateItem(item)
) )
html html
@ -427,7 +427,7 @@ class App.Controller extends Spine.Controller
) )
html = $( html ) html = $( html )
html.find('.humanTimeFromNow').each( -> html.find('.humanTimeFromNow').each( ->
item = $(this) item = $(@)
ui.frontendTimeUpdateItem(item) ui.frontendTimeUpdateItem(item)
) )
html html

View file

@ -133,7 +133,7 @@ class Index extends App.Controller
onUpload: (event) => onUpload: (event) =>
callback = @storeImage callback = @storeImage
EXIF.getData event.target.files[0], -> EXIF.getData event.target.files[0], ->
orientation = this.exifdata.Orientation orientation = @exifdata.Orientation
reader = new FileReader() reader = new FileReader()
reader.onload = (e) -> reader.onload = (e) ->
new ImageCropper new ImageCropper
@ -141,7 +141,7 @@ class Index extends App.Controller
callback: callback callback: callback
orientation: orientation orientation: orientation
reader.readAsDataURL(this) reader.readAsDataURL(@)
App.Config.set( 'Avatar', { prio: 1100, name: 'Avatar', parent: '#profile', target: '#profile/avatar', controller: Index }, 'NavBarProfile' ) App.Config.set( 'Avatar', { prio: 1100, name: 'Avatar', parent: '#profile', target: '#profile/avatar', controller: Index }, 'NavBarProfile' )

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.active extends App.UiElement.ApplicationUiElement class App.UiElement.active extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.autocompletion class App.UiElement.autocompletion
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.autocompletion_ajax class App.UiElement.autocompletion_ajax
@render: (attribute, params = {}) -> @render: (attribute, params = {}) ->
if params[attribute.name] if params[attribute.name]

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.boolean extends App.UiElement.ApplicationUiElement class App.UiElement.boolean extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.business_hours class App.UiElement.business_hours
@render: (attributeOrig) -> @render: (attributeOrig) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.checkbox extends App.UiElement.ApplicationUiElement class App.UiElement.checkbox extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.date class App.UiElement.date
@render: (attributeOrig) -> @render: (attributeOrig) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.datetime class App.UiElement.datetime
@render: (attributeOrig) -> @render: (attributeOrig) ->

View file

@ -0,0 +1,7 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.datetime_search
@render: (attributeOrig) ->
attribute = _.clone(attributeOrig)
attribute.disable_feature = true
attribute.null = false
App.UiElement.datetime.render(attribute)

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.holiday_selector class App.UiElement.holiday_selector
@render: (attribute, params) -> @render: (attribute, params) ->
console.log('aa', attribute) console.log('aa', attribute)

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.ical_feed extends App.UiElement.ApplicationUiElement class App.UiElement.ical_feed extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->
console.log('A', attribute) console.log('A', attribute)

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.input class App.UiElement.input
@render: (attribute) -> @render: (attribute) ->
$( App.view('generic/input')( attribute: attribute ) ) $( App.view('generic/input')( attribute: attribute ) )

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.postmaster_match class App.UiElement.postmaster_match
@defaults: -> @defaults: ->
groups = groups =

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.postmaster_set class App.UiElement.postmaster_set
@defaults: -> @defaults: ->
groups = groups =

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.radio extends App.UiElement.ApplicationUiElement class App.UiElement.radio extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.richtext class App.UiElement.richtext
@render: (attribute) -> @render: (attribute) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.searchable_select extends App.UiElement.ApplicationUiElement class App.UiElement.searchable_select extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.select extends App.UiElement.ApplicationUiElement class App.UiElement.select extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.sla_times class App.UiElement.sla_times
@render: (attribute, params = {}) -> @render: (attribute, params = {}) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.tag class App.UiElement.tag
@render: (attribute) -> @render: (attribute) ->
item = $( App.view('generic/input')( attribute: attribute ) ) item = $( App.view('generic/input')( attribute: attribute ) )

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.textarea class App.UiElement.textarea
@render: (attribute) -> @render: (attribute) ->
fileUploaderId = 'file-uploader-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 ) fileUploaderId = 'file-uploader-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 )

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.ticket_perform_action class App.UiElement.ticket_perform_action
@defaults: -> @defaults: ->
defaults = ['ticket.state_id'] defaults = ['ticket.state_id']

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.ticket_selector class App.UiElement.ticket_selector
@defaults: -> @defaults: ->
defaults = ['ticket.state_id'] defaults = ['ticket.state_id']

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.timezone extends App.UiElement.ApplicationUiElement class App.UiElement.timezone extends App.UiElement.ApplicationUiElement
@render: (attribute, params) -> @render: (attribute, params) ->

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.UiElement.user_autocompletion class App.UiElement.user_autocompletion
@render: (attribute) -> @render: (attribute) ->
new App.UserOrganizationAutocompletion( attribute: attribute ).element() new App.UserOrganizationAutocompletion( attribute: attribute ).element()

View file

@ -205,7 +205,7 @@ class Index extends App.ControllerContent
done: -> done: ->
# redirect to zoom # redirect to zoom
ui.navigate '#ticket/zoom/' + this.id ui.navigate '#ticket/zoom/' + @id
fail: -> fail: ->
ui.log 'CustomerTicketCreate', 'error', 'can not create' ui.log 'CustomerTicketCreate', 'error', 'can not create'

View file

@ -790,7 +790,7 @@ class ErrorRef extends App.ControllerContent
App.Config.set( 'layout_ref/error', ErrorRef, 'Routes' ) App.Config.set( 'layout_ref/error', ErrorRef, 'Routes' )
class ticketZoomRef extends App.ControllerContent class TicketZoomRef extends App.ControllerContent
elements: elements:
'.article-text': 'articles' '.article-text': 'articles'
'.js-highlight-icon': 'highlightIcon' '.js-highlight-icon': 'highlightIcon'
@ -939,7 +939,7 @@ class ticketZoomRef extends App.ControllerContent
@storeHighlights() @storeHighlights()
App.Config.set( 'layout_ref/ticket_zoom', ticketZoomRef, 'Routes' ) App.Config.set( 'layout_ref/ticket_zoom', TicketZoomRef, 'Routes' )
class CluesRef extends App.ControllerContent class CluesRef extends App.ControllerContent

View file

@ -121,7 +121,7 @@ class App.Navigation extends App.ControllerWidgetPermanent
# start oorganization popups # start oorganization popups
@organizationPopups() @organizationPopups()
render: () -> render: ->
# reset result cache # reset result cache
@searchResultCache = {} @searchResultCache = {}

View file

@ -280,7 +280,7 @@ class TranslationList extends App.Controller
ui = @ ui = @
@changesAvailable = false @changesAvailable = false
@$('.js-Item').each( (e) -> @$('.js-Item').each( (e) ->
id = $(this).data('id') id = $(@).data('id')
ui.updateRow(id) ui.updateRow(id)
) )
if @changesAvailable if @changesAvailable

View file

@ -65,7 +65,7 @@ class App.OnlineNotificationWidget extends App.Controller
processData: true processData: true
) )
removeClickCatcher: () => removeClickCatcher: =>
return if !@clickCatcher return if !@clickCatcher
@clickCatcher.remove() @clickCatcher.remove()
@clickCatcher = null @clickCatcher = null

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_backticks
class App.Track class App.Track
_instance = undefined _instance = undefined

View file

@ -1,3 +1,4 @@
# coffeelint: disable=camel_case_classes
class App.i18n class App.i18n
_instance = undefined _instance = undefined
@ -69,6 +70,11 @@ class App.i18n
_instance ?= new _i18nSingleton() _instance ?= new _i18nSingleton()
_instance.setNotTranslated( locale, key ) _instance.setNotTranslated( locale, key )
@timeFormat: (locale, key) ->
if _instance == undefined
_instance ?= new _i18nSingleton()
_instance.mapTime
class _i18nSingleton extends Spine.Module class _i18nSingleton extends Spine.Module
@include App.LogInclude @include App.LogInclude
@ -85,7 +91,7 @@ class _i18nSingleton extends Spine.Module
# observe if text has been translated # observe if text has been translated
$('body') $('body')
.delegate '.translation', 'focus', (e) => .delegate '.translation', 'focus', (e) ->
$this = $(e.target) $this = $(e.target)
$this.data 'before', $this.html() $this.data 'before', $this.html()
return $this return $this
@ -276,7 +282,7 @@ class _i18nSingleton extends Spine.Module
else else
@mapString[source] = target @mapString[source] = target
notTranslatedFeatureEnabled: (locale) => notTranslatedFeatureEnabled: (locale) ->
if locale.substr(0,2) is 'en' if locale.substr(0,2) is 'en'
return false return false
true true
@ -296,10 +302,10 @@ class _i18nSingleton extends Spine.Module
timestamp: ( time, offset ) => timestamp: ( time, offset ) =>
@convert(time, offset, @mapTime['timestamp'] || @timestampFormat) @convert(time, offset, @mapTime['timestamp'] || @timestampFormat)
convert: ( time, offset, format ) => convert: ( time, offset, format ) ->
s = ( num, digits ) -> s = ( num, digits ) ->
while num.toString().length < digits while num.toString().length < digits
num = "0" + num num = '0' + num
num num
timeObject = new Date(time) timeObject = new Date(time)

View file

@ -145,7 +145,7 @@ class App.SearchableSelect extends Spine.Controller
@shadowInput.trigger('change') @shadowInput.trigger('change')
@toggle() @toggle()
onBlur: => onBlur: ->
# @clearAutocomplete() # @clearAutocomplete()
onInput: (event) => onInput: (event) =>
@ -160,7 +160,7 @@ class App.SearchableSelect extends Spine.Controller
@option_items @option_items
.addClass 'is-hidden' .addClass 'is-hidden'
.filter -> .filter ->
this.textContent.match(regex) @textContent.match(regex)
.removeClass 'is-hidden' .removeClass 'is-hidden'
@highlightFirst() @highlightFirst()

View file

@ -23,7 +23,7 @@ class App.Store
_instance ?= new _storeSingleton _instance ?= new _storeSingleton
_instance.clear() _instance.clear()
@list: () -> @list: ->
if _instance == undefined if _instance == undefined
_instance ?= new _storeSingleton _instance ?= new _storeSingleton
_instance.list() _instance.list()

View file

@ -162,14 +162,14 @@ class App.Utils
# Replace all x tags with the type of replacementTag # Replace all x tags with the type of replacementTag
html.find('h1, h2, h3, h4, h5, h6, textarea').each( -> html.find('h1, h2, h3, h4, h5, h6, textarea').each( ->
outer = this.outerHTML; outer = @outerHTML;
# Replace opening tag # Replace opening tag
regex = new RegExp('<' + this.tagName, 'i') regex = new RegExp('<' + @tagName, 'i')
newTag = outer.replace(regex, '<' + replacementTag) newTag = outer.replace(regex, '<' + replacementTag)
# Replace closing tag # Replace closing tag
regex = new RegExp('</' + this.tagName, 'i') regex = new RegExp('</' + @tagName, 'i')
newTag = newTag.replace(regex, '</' + replacementTag) newTag = newTag.replace(regex, '</' + replacementTag)
$(@).replaceWith(newTag) $(@).replaceWith(newTag)

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_this,indentation
Spine = @Spine or require('spine') Spine = @Spine or require('spine')
$ = Spine.$ $ = Spine.$
Model = Spine.Model Model = Spine.Model

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_this
BindingsClass = BindingsClass =
model: 'model' model: 'model'

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_this
Spine = @Spine or require('spine') Spine = @Spine or require('spine')
$ = Spine.$ $ = Spine.$

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_this,indentation,no_unnecessary_fat_arrows
Spine = @Spine or require('spine') Spine = @Spine or require('spine')
class Collection extends Spine.Module class Collection extends Spine.Module

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_this,indentation
Spine = @Spine or require('spine') Spine = @Spine or require('spine')
$ = Spine.$ $ = Spine.$

View file

@ -1,3 +1,4 @@
# coffeelint: disable=no_this
### ###
Spine.js MVC library Spine.js MVC library
Released under the MIT License Released under the MIT License

135
coffeelint.json Normal file
View file

@ -0,0 +1,135 @@
{
"arrow_spacing": {
"level": "ignore"
},
"braces_spacing": {
"level": "ignore",
"spaces": 0,
"empty_object_spaces": 0
},
"camel_case_classes": {
"level": "error"
},
"coffeescript_error": {
"level": "error"
},
"colon_assignment_spacing": {
"level": "ignore",
"spacing": {
"left": 0,
"right": 0
}
},
"cyclomatic_complexity": {
"value": 10,
"level": "ignore"
},
"duplicate_key": {
"level": "error"
},
"empty_constructor_needs_parens": {
"level": "ignore"
},
"ensure_comprehensions": {
"level": "warn"
},
"eol_last": {
"level": "ignore"
},
"indentation": {
"value": 2,
"level": "error"
},
"line_endings": {
"level": "ignore",
"value": "unix"
},
"max_line_length": {
"value": 800,
"level": "error",
"limitComments": true
},
"missing_fat_arrows": {
"level": "ignore",
"is_strict": false
},
"newlines_after_classes": {
"value": 3,
"level": "ignore"
},
"no_backticks": {
"level": "error"
},
"no_debugger": {
"level": "warn",
"console": false
},
"no_empty_functions": {
"level": "ignore"
},
"no_empty_param_list": {
"level": "warn"
},
"no_implicit_braces": {
"level": "ignore",
"strict": true
},
"no_implicit_parens": {
"strict": true,
"level": "ignore"
},
"no_interpolation_in_single_quotes": {
"level": "warn"
},
"no_nested_string_interpolation": {
"level": "warn"
},
"no_plusplus": {
"level": "ignore"
},
"no_private_function_fat_arrows": {
"level": "warn"
},
"no_stand_alone_at": {
"level": "ignore"
},
"no_tabs": {
"level": "error"
},
"no_this": {
"level": "warn"
},
"no_throwing_strings": {
"level": "ignore"
},
"no_trailing_semicolons": {
"level": "error"
},
"no_trailing_whitespace": {
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": true
},
"no_unnecessary_double_quotes": {
"level": "ignore"
},
"no_unnecessary_fat_arrows": {
"level": "warn"
},
"non_empty_constructor_needs_parens": {
"level": "ignore"
},
"prefer_english_operator": {
"level": "ignore",
"doubleNotLevel": "ignore"
},
"space_operators": {
"level": "ignore"
},
"spacing_after_comma": {
"level": "ignore"
},
"transform_messes_up_line_numbers": {
"level": "warn"
}
}