Skip to content

Commit

Permalink
Merge pull request #472 from steelbrain/greenkeeper/eslint-config-ste…
Browse files Browse the repository at this point in the history
…elbrain-4.0.1

chore(package): update eslint-config-steelbrain to version 4.0.1
  • Loading branch information
Arcanemagus authored Feb 2, 2018
2 parents 6f8c1d3 + 5cafb38 commit 513258e
Show file tree
Hide file tree
Showing 12 changed files with 731 additions and 715 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
"no-underscore-dangle": "off",
"react/no-danger": "off",
"react/no-danger-with-children": "off",
"global-require": "off"
"global-require": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": [
"error",
{
"ignore": [
"atom",
"electron"
]
}
]
}
}
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[ignore]
<PROJECT_ROOT>/node_modules/fbjs
<PROJECT_ROOT>/node_modules/eslint-plugin-jsx-a11y

[include]

Expand Down
2 changes: 1 addition & 1 deletion lib/editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { LinterMessage, MessagesPatch } from './types'
class Editors {
editors: Set<Editor>;
messages: Array<LinterMessage>;
firstRender: bool;
firstRender: boolean;
subscriptions: CompositeDisposable;

constructor() {
Expand Down
56 changes: 28 additions & 28 deletions lib/panel/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,37 @@ import type Delegate from './delegate'
import type { LinterMessage } from '../types'

class PanelComponent extends React.Component {
props: {
delegate: Delegate,
};
state: {
messages: Array<LinterMessage>,
};
static renderRowColumn(row: LinterMessage, column: string): string | Object {
const range = $range(row)

switch (column) {
case 'file':
return getPathOfMessage(row)
case 'line':
return range ? `${range.start.row + 1}:${range.start.column + 1}` : ''
case 'excerpt':
if (row.version === 1) {
if (row.html) {
return <span dangerouslySetInnerHTML={{ __html: row.html }} />
}
return row.text || ''
}
return row.excerpt
case 'severity':
return severityNames[row.severity]
default:
return row[column]
}
}
constructor(props: Object, context: ?Object) {
super(props, context)
this.state = {
messages: this.props.delegate.filteredMessages,
}
}
state: {
messages: Array<LinterMessage>,
};
componentDidMount() {
this.props.delegate.onDidChangeMessages((messages) => {
this.setState({ messages })
Expand All @@ -38,6 +57,9 @@ class PanelComponent extends React.Component {
visitMessage(row)
}
}
props: {
delegate: Delegate,
};
render() {
const { delegate } = this.props
const columns = [
Expand Down Expand Up @@ -71,28 +93,6 @@ class PanelComponent extends React.Component {
</div>
)
}
static renderRowColumn(row: LinterMessage, column: string): string | Object {
const range = $range(row)

switch (column) {
case 'file':
return getPathOfMessage(row)
case 'line':
return range ? `${range.start.row + 1}:${range.start.column + 1}` : ''
case 'excerpt':
if (row.version === 1) {
if (row.html) {
return <span dangerouslySetInnerHTML={{ __html: row.html }} />
}
return row.text || ''
}
return row.excerpt
case 'severity':
return severityNames[row.severity]
default:
return row[column]
}
}
}

module.exports = PanelComponent
1 change: 0 additions & 1 deletion lib/panel/delegate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* @flow */

import { CompositeDisposable, Disposable, Emitter, Range } from 'atom'

import { getActiveTextEditor, filterMessages, filterMessagesByRangeOrPoint } from '../helpers'
import type { LinterMessage } from '../types'

Expand Down
1 change: 0 additions & 1 deletion lib/status-bar/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* @flow */

import { CompositeDisposable, Disposable } from 'atom'

import Element from './element'
import { $file, getActiveTextEditor } from '../helpers'
import type { LinterMessage } from '../types'
Expand Down
15 changes: 8 additions & 7 deletions lib/tooltip/message-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ const NEWLINE = /\r\n|\n/
let MESSAGE_NUMBER = 0

class MessageElement extends React.Component {
props: {
message: MessageLegacy,
delegate: TooltipDelegate,
};
state: {
multiLineShow: boolean,
} = {
Expand All @@ -28,9 +24,10 @@ class MessageElement extends React.Component {
this.setState({ multiLineShow: false })
})
}
render() {
return NEWLINE.test(this.props.message.text || '') ? this.renderMultiLine() : this.renderSingleLine()
}
props: {
message: MessageLegacy,
delegate: TooltipDelegate,
};
renderSingleLine() {
const { message, delegate } = this.props

Expand Down Expand Up @@ -74,6 +71,10 @@ class MessageElement extends React.Component {
{ this.state.multiLineShow && chunks.slice(1) }
</linter-message>)
}

render() {
return NEWLINE.test(this.props.message.text || '') ? this.renderMultiLine() : this.renderSingleLine()
}
}

module.exports = MessageElement
84 changes: 45 additions & 39 deletions lib/tooltip/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ function findHref(el: ?Element): ?string {
}

class MessageElement extends React.Component {
props: {
message: Message,
delegate: TooltipDelegate,
};
state: {
description: string,
descriptionShow: boolean,
} = {
description: '',
descriptionShow: false,
};
descriptionLoading: boolean = false;

componentDidMount() {
this.props.delegate.onShouldUpdate(() => {
Expand All @@ -48,6 +43,44 @@ class MessageElement extends React.Component {
}
})
}

// NOTE: Only handling messages v2 because v1 would be handled by message-legacy component
onFixClick(): void {
const message = this.props.message
const textEditor = getActiveTextEditor()
if (message.version === 2 && message.solutions && message.solutions.length) {
applySolution(textEditor, message.version, sortSolutions(message.solutions)[0])
}
}

openFile = (ev: Event) => {
if (!(ev.target instanceof HTMLElement)) {
return
}
const href = findHref(ev.target)
if (!href) {
return
}
// parse the link. e.g. atom://linter?file=<path>&row=<number>&column=<number>
const { protocol, hostname, query } = url.parse(href, true)
const file = query && query.file
if (protocol !== 'atom:' || hostname !== 'linter' || !file) {
return
}
const row = query && query.row ? parseInt(query.row, 10) : 0
const column = query && query.column ? parseInt(query.column, 10) : 0
openFile(file, { row, column })
}

canBeFixed(message: LinterMessage): boolean {
if (message.version === 1 && message.fix) {
return true
} else if (message.version === 2 && message.solutions && message.solutions.length) {
return true
}
return false
}

toggleDescription(result: ?string = null) {
const newStatus = !this.state.descriptionShow
const description = this.state.description || this.props.message.description
Expand Down Expand Up @@ -83,40 +116,13 @@ class MessageElement extends React.Component {
console.error('[Linter] Invalid description detected, expected string or function but got:', typeof description)
}
}
openFile = (ev: Event) => {
if (!(ev.target instanceof HTMLElement)) {
return
}
const href = findHref(ev.target)
if (!href) {
return
}
// parse the link. e.g. atom://linter?file=<path>&row=<number>&column=<number>
const { protocol, hostname, query } = url.parse(href, true)
const file = query && query.file
if (protocol !== 'atom:' || hostname !== 'linter' || !file) {
return
}
const row = query && query.row ? parseInt(query.row, 10) : 0
const column = query && query.column ? parseInt(query.column, 10) : 0
openFile(file, { row, column })
}
canBeFixed(message: LinterMessage): boolean {
if (message.version === 1 && message.fix) {
return true
} else if (message.version === 2 && message.solutions && message.solutions.length) {
return true
}
return false
}
// NOTE: Only handling messages v2 because v1 would be handled by message-legacy component
onFixClick(): void {
const message = this.props.message
const textEditor = getActiveTextEditor()
if (message.version === 2 && message.solutions && message.solutions.length) {
applySolution(textEditor, message.version, sortSolutions(message.solutions)[0])
}
}

props: {
message: Message,
delegate: TooltipDelegate,
};
descriptionLoading: boolean = false;

render() {
const { message, delegate } = this.props

Expand Down
14 changes: 8 additions & 6 deletions lib/tree-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class TreeView {
const elementCache = {}
const appliedDecorations = {}

for (const filePath in this.decorations) {
Object.keys(this.decorations).forEach((filePath) => {
if (!{}.hasOwnProperty.call(this.decorations, filePath)) {
continue
return
}
if (!decorations[filePath]) {
// Removed
Expand All @@ -78,20 +78,22 @@ class TreeView {
this.removeDecoration(element)
}
}
}
})

for (const filePath in decorations) {
Object.keys(decorations).forEach((filePath) => {
if (!{}.hasOwnProperty.call(decorations, filePath)) {
continue
return
}
const element = elementCache[filePath] || (elementCache[filePath] = TreeView.getElementByPath(treeViewElement, filePath))
if (element) {
this.handleDecoration(element, !!this.decorations[filePath], decorations[filePath])
appliedDecorations[filePath] = decorations[filePath]
}
}
})

this.decorations = appliedDecorations
}

handleDecoration(element: HTMLElement, update: boolean = false, highlights: TreeViewHighlight) {
let decoration
if (update) {
Expand Down
Loading

0 comments on commit 513258e

Please sign in to comment.