Merge pull request #6898 from atom/mq-lint-roller

Lint for even more style errors
This commit is contained in:
Kevin Sawicki
2015-05-26 08:54:56 -07:00
14 changed files with 260 additions and 249 deletions

View File

@@ -100,6 +100,9 @@ For more information on how to work with Atom's official packages, see
* Set parameter defaults without spaces around the equal sign
* `clear = (count=1) ->` instead of `clear = (count = 1) ->`
* Use spaces around operators
* `count + 1` instead of `count+1`
* Use spaces after commas (unless separated by newlines)
* Use parentheses if it improves code clarity.
* Prefer alphabetic keywords to symbolic keywords:
* `a is b` instead of `a == b`
@@ -113,6 +116,8 @@ For more information on how to work with Atom's official packages, see
* Use `slice()` to copy an array
* Add an explicit `return` when your function ends with a `for`/`while` loop and
you don't want it to return a collected array.
* Use `this` instead of a standalone `@`
* `return this` instead of `return @`
## Specs Styleguide

View File

@@ -31,7 +31,7 @@ module.exports = (grunt) ->
binDir = path.join(installDir, 'bin')
shareDir = path.join(installDir, 'share', 'atom')
iconName = path.join(shareDir,'resources', 'app', 'resources', 'atom.png')
iconName = path.join(shareDir, 'resources', 'app', 'resources', 'atom.png')
mkdir binDir
cp 'atom.sh', path.join(binDir, 'atom')

View File

@@ -27,5 +27,11 @@
"braces_spacing": {
"spaces": 0,
"level": "error"
},
"spacing_after_comma": {
"level": "error"
},
"no_stand_alone_at": {
"level": "error"
}
}

View File

@@ -44,7 +44,7 @@ describe "DisplayBuffer", ->
it "renders line numbers correctly", ->
originalLineCount = displayBuffer.getLineCount()
oneHundredLines = [0..100].join("\n")
buffer.insert([0,0], oneHundredLines)
buffer.insert([0, 0], oneHundredLines)
expect(displayBuffer.getLineCount()).toBe 100 + originalLineCount
it "reassigns the scrollTop if it exceeds the max possible value after lines are removed", ->
@@ -382,10 +382,10 @@ describe "DisplayBuffer", ->
describe "when creating a fold where one already exists", ->
it "returns existing fold and does't create new fold", ->
fold = displayBuffer.createFold(0,10)
fold = displayBuffer.createFold(0, 10)
expect(displayBuffer.findMarkers(class: 'fold').length).toBe 1
newFold = displayBuffer.createFold(0,10)
newFold = displayBuffer.createFold(0, 10)
expect(newFold).toBe fold
expect(displayBuffer.findMarkers(class: 'fold').length).toBe 1

View File

@@ -134,23 +134,23 @@ describe "LanguageMode", ->
it "will limit paragraph range to comments", ->
range = languageMode.rowRangeForParagraphAtBufferRow(0)
expect(range).toEqual [[0,0], [0,29]]
expect(range).toEqual [[0, 0], [0, 29]]
range = languageMode.rowRangeForParagraphAtBufferRow(10)
expect(range).toEqual [[10,0], [10,14]]
expect(range).toEqual [[10, 0], [10, 14]]
range = languageMode.rowRangeForParagraphAtBufferRow(11)
expect(range).toBeFalsy()
range = languageMode.rowRangeForParagraphAtBufferRow(12)
expect(range).toEqual [[12,0], [13,10]]
expect(range).toEqual [[12, 0], [13, 10]]
range = languageMode.rowRangeForParagraphAtBufferRow(14)
expect(range).toEqual [[14,0], [14,32]]
expect(range).toEqual [[14, 0], [14, 32]]
range = languageMode.rowRangeForParagraphAtBufferRow(15)
expect(range).toEqual [[15,0], [15,26]]
expect(range).toEqual [[15, 0], [15, 26]]
range = languageMode.rowRangeForParagraphAtBufferRow(18)
expect(range).toEqual [[17,0], [19,3]]
expect(range).toEqual [[17, 0], [19, 3]]
describe "coffeescript", ->
beforeEach ->
@@ -305,9 +305,9 @@ describe "LanguageMode", ->
atom.packages.unloadPackages()
it "maintains cursor buffer position when a folding/unfolding", ->
editor.setCursorBufferPosition([5,5])
editor.setCursorBufferPosition([5, 5])
languageMode.foldAll()
expect(editor.getCursorBufferPosition()).toEqual([5,5])
expect(editor.getCursorBufferPosition()).toEqual([5, 5])
describe ".unfoldAll()", ->
it "unfolds every folded line", ->
@@ -359,7 +359,7 @@ describe "LanguageMode", ->
describe "when the bufferRow is in a multi-line comment", ->
it "searches upward and downward for surrounding comment lines and folds them as a single fold", ->
buffer.insert([1,0], " //this is a comment\n // and\n //more docs\n\n//second comment")
buffer.insert([1, 0], " //this is a comment\n // and\n //more docs\n\n//second comment")
languageMode.foldBufferRow(1)
fold = editor.tokenizedLineForScreenRow(1).fold
expect(fold.getStartRow()).toBe 1
@@ -367,7 +367,7 @@ describe "LanguageMode", ->
describe "when the bufferRow is a single-line comment", ->
it "searches upward for the first row that begins a syntatic region containing the folded row (and folds it)", ->
buffer.insert([1,0], " //this is a single line comment\n")
buffer.insert([1, 0], " //this is a single line comment\n")
languageMode.foldBufferRow(1)
fold = editor.tokenizedLineForScreenRow(0).fold
expect(fold.getStartRow()).toBe 0

View File

@@ -14,18 +14,18 @@ describe "Selection", ->
describe ".deleteSelectedText()", ->
describe "when nothing is selected", ->
it "deletes nothing", ->
selection.setBufferRange [[0,3], [0,3]]
selection.setBufferRange [[0, 3], [0, 3]]
selection.deleteSelectedText()
expect(buffer.lineForRow(0)).toBe "var quicksort = function () {"
describe "when one line is selected", ->
it "deletes selected text and clears the selection", ->
selection.setBufferRange [[0,4], [0,14]]
selection.setBufferRange [[0, 4], [0, 14]]
selection.deleteSelectedText()
expect(buffer.lineForRow(0)).toBe "var = function () {"
endOfLine = buffer.lineForRow(0).length
selection.setBufferRange [[0,0], [0, endOfLine]]
selection.setBufferRange [[0, 0], [0, endOfLine]]
selection.deleteSelectedText()
expect(buffer.lineForRow(0)).toBe ""
@@ -33,15 +33,15 @@ describe "Selection", ->
describe "when multiple lines are selected", ->
it "deletes selected text and clears the selection", ->
selection.setBufferRange [[0,1], [2,39]]
selection.setBufferRange [[0, 1], [2, 39]]
selection.deleteSelectedText()
expect(buffer.lineForRow(0)).toBe "v;"
expect(selection.isEmpty()).toBeTruthy()
describe "when the cursor precedes the tail", ->
it "deletes selected text and clears the selection", ->
selection.cursor.setScreenPosition [0,13]
selection.selectToScreenPosition [0,4]
selection.cursor.setScreenPosition [0, 13]
selection.selectToScreenPosition [0, 4]
selection.delete()
expect(buffer.lineForRow(0)).toBe "var = function () {"

View File

@@ -83,7 +83,7 @@ describe "TextEditorElement", ->
editor = new TextEditor
editor.setText('1\n2\n3')
editor.addGutter({name: 'test-gutter'})
marker = editor.markBufferRange([[0,0],[2,0]])
marker = editor.markBufferRange([[0, 0], [2, 0]])
editor.decorateMarker(marker, {type: 'gutter', gutterName: 'test-gutter'})
element = atom.views.getView(editor)

View File

@@ -2227,11 +2227,11 @@ describe "TextEditorPresenter", ->
gutterName: 'test-gutter'
class: 'test-class'
item: decorationItem
marker1 = editor.markBufferRange([[0,0],[1,0]])
marker1 = editor.markBufferRange([[0, 0], [1, 0]])
decoration1 = editor.decorateMarker(marker1, decorationParams)
marker2 = editor.markBufferRange([[9,0],[12,0]])
marker2 = editor.markBufferRange([[9, 0], [12, 0]])
decoration2 = editor.decorateMarker(marker2, decorationParams)
marker3 = editor.markBufferRange([[13,0],[14,0]])
marker3 = editor.markBufferRange([[13, 0], [14, 0]])
decoration3 = editor.decorateMarker(marker3, decorationParams)
# Clear any batched state updates.
@@ -2280,7 +2280,7 @@ describe "TextEditorPresenter", ->
it "updates when the editor's content changes", ->
# This update will add enough lines to push decoration2 out of view.
expectStateUpdate presenter, -> editor.setTextInBufferRange([[8,0],[9,0]],'\n\n\n\n\n')
expectStateUpdate presenter, -> editor.setTextInBufferRange([[8, 0], [9, 0]], '\n\n\n\n\n')
decorationState = getContentForGutterWithName(presenter, 'test-gutter')
expect(decorationState[decoration1.id].top).toBeDefined()
@@ -2290,7 +2290,7 @@ describe "TextEditorPresenter", ->
it "updates when a decoration's marker is modified", ->
# This update will move decoration1 out of view.
expectStateUpdate presenter, ->
newRange = new Range([13,0],[14,0])
newRange = new Range([13, 0], [14, 0])
marker1.setBufferRange(newRange)
decorationState = getContentForGutterWithName(presenter, 'test-gutter')
@@ -2401,7 +2401,7 @@ describe "TextEditorPresenter", ->
type: 'gutter'
gutterName: 'test-gutter-2'
class: 'test-class'
marker4 = editor.markBufferRange([[0,0],[1,0]])
marker4 = editor.markBufferRange([[0, 0], [1, 0]])
decoration4 = editor.decorateMarker(marker4, decorationParams)
expectStateUpdate presenter, -> editor.addGutter({name: 'test-gutter-2'})

File diff suppressed because it is too large Load Diff

View File

@@ -287,7 +287,7 @@ describe "TokenizedBuffer", ->
describe "when there is an insertion that is larger than the chunk size", ->
it "tokenizes the initial chunk synchronously, then tokenizes the remaining lines in the background", ->
commentBlock = _.multiplyString("// a comment\n", tokenizedBuffer.chunkSize + 2)
buffer.insert([0,0], commentBlock)
buffer.insert([0, 0], commentBlock)
expect(tokenizedBuffer.tokenizedLineForRow(0).ruleStack?).toBeTruthy()
expect(tokenizedBuffer.tokenizedLineForRow(4).ruleStack?).toBeTruthy()
expect(tokenizedBuffer.tokenizedLineForRow(5).ruleStack?).toBeFalsy()
@@ -541,7 +541,7 @@ describe "TokenizedBuffer", ->
runs ->
fullyTokenize(tokenizedBuffer)
{tokens} = tokenizedBuffer.tokenizedLineForRow(0)
expect(tokens[0]).toEqual value: '<', scopes: ["text.html.ruby","meta.tag.block.any.html","punctuation.definition.tag.begin.html"]
expect(tokens[0]).toEqual value: '<', scopes: ["text.html.ruby", "meta.tag.block.any.html", "punctuation.definition.tag.begin.html"]
describe ".tokenForPosition(position)", ->
afterEach ->
@@ -552,9 +552,9 @@ describe "TokenizedBuffer", ->
buffer = atom.project.bufferForPathSync('sample.js')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)
expect(tokenizedBuffer.tokenForPosition([1,0]).scopes).toEqual ["source.js"]
expect(tokenizedBuffer.tokenForPosition([1,1]).scopes).toEqual ["source.js"]
expect(tokenizedBuffer.tokenForPosition([1,2]).scopes).toEqual ["source.js", "storage.modifier.js"]
expect(tokenizedBuffer.tokenForPosition([1, 0]).scopes).toEqual ["source.js"]
expect(tokenizedBuffer.tokenForPosition([1, 1]).scopes).toEqual ["source.js"]
expect(tokenizedBuffer.tokenForPosition([1, 2]).scopes).toEqual ["source.js", "storage.modifier.js"]
describe ".bufferRangeForScopeAtPosition(selector, position)", ->
beforeEach ->
@@ -580,20 +580,20 @@ describe "TokenizedBuffer", ->
buffer.setText('\ttest')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)
expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' '
expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' '
atom.config.set('editor.tabLength', 6)
expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' '
expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' '
it "does not allow the tab length to be less than 1", ->
buffer = atom.project.bufferForPathSync('sample.js')
buffer.setText('\ttest')
tokenizedBuffer = new TokenizedBuffer({buffer})
fullyTokenize(tokenizedBuffer)
expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' '
expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' '
atom.config.set('editor.tabLength', 1)
expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' '
expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' '
atom.config.set('editor.tabLength', 0)
expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' '
expect(tokenizedBuffer.tokenForPosition([0, 0]).value).toBe ' '
describe "when the invisibles value changes", ->
beforeEach ->

View File

@@ -1027,7 +1027,7 @@ describe "Workspace", ->
atom.project.open('sample.js').then (o) -> editor = o
runs ->
editor.buffer.setTextInRange([[0,0],[0,0]], 'omg')
editor.buffer.setTextInRange([[0, 0], [0, 0]], 'omg')
expect(editor.isModified()).toBeTruthy()
waitsForPromise ->

View File

@@ -174,7 +174,7 @@ class AtomApplication
@on 'application:open-safe', -> @promptForPathToOpen('all', safeMode: true)
@on 'application:open-api-preview', -> @promptForPathToOpen('all', apiPreviewMode: true)
@on 'application:open-dev-api-preview', -> @promptForPathToOpen('all', {apiPreviewMode: true, devMode: true})
@on 'application:inspect', ({x,y, atomWindow}) ->
@on 'application:inspect', ({x, y, atomWindow}) ->
atomWindow ?= @focusedWindow()
atomWindow?.browserWindow.inspectElement(x, y)

View File

@@ -333,7 +333,7 @@ class Cursor extends Model
# Public: Moves the cursor to the top of the buffer.
moveToTop: ->
@setBufferPosition([0,0])
@setBufferPosition([0, 0])
# Public: Moves the cursor to the bottom of the buffer.
moveToBottom: ->
@@ -673,9 +673,9 @@ class Cursor extends Model
start = @getBufferPosition()
{row, column} = start
scanRange = [[row-1, column], [0,0]]
scanRange = [[row-1, column], [0, 0]]
position = new Point(0, 0)
zero = new Point(0,0)
zero = new Point(0, 0)
@editor.backwardsScanInBufferRange /^\n*$/g, scanRange, ({range, stop}) ->
unless range.start.isEqual(zero)
position = range.start

View File

@@ -120,14 +120,14 @@ class TextEditorView extends View
getEditor: -> @model
Object.defineProperty @::, 'lineHeight', get: -> @model.getLineHeightInPixels()
Object.defineProperty @::, 'charWidth', get: -> @model.getDefaultCharWidth()
Object.defineProperty @::, 'firstRenderedScreenRow', get: -> @component.getRenderedRowRange()[0]
Object.defineProperty @::, 'lastRenderedScreenRow', get: -> @component.getRenderedRowRange()[1]
Object.defineProperty @::, 'active', get: -> @is(@getPaneView()?.activeView)
Object.defineProperty @::, 'isFocused', get: -> document.activeElement is @element or document.activeElement is @element.component?.hiddenInputComponent?.getDomNode()
Object.defineProperty @::, 'mini', get: -> @model?.isMini()
Object.defineProperty @::, 'component', get: -> @element?.component
Object.defineProperty @prototype, 'lineHeight', get: -> @model.getLineHeightInPixels()
Object.defineProperty @prototype, 'charWidth', get: -> @model.getDefaultCharWidth()
Object.defineProperty @prototype, 'firstRenderedScreenRow', get: -> @component.getRenderedRowRange()[0]
Object.defineProperty @prototype, 'lastRenderedScreenRow', get: -> @component.getRenderedRowRange()[1]
Object.defineProperty @prototype, 'active', get: -> @is(@getPaneView()?.activeView)
Object.defineProperty @prototype, 'isFocused', get: -> document.activeElement is @element or document.activeElement is @element.component?.hiddenInputComponent?.getDomNode()
Object.defineProperty @prototype, 'mini', get: -> @model?.isMini()
Object.defineProperty @prototype, 'component', get: -> @element?.component
afterAttach: (onDom) ->
return unless onDom