-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from IBMStreams/develop
Update to version 0.4.0
- Loading branch information
Showing
36 changed files
with
16,842 additions
and
1,722 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{ | ||
"presets": ["flow", "env", "stage-2"], | ||
"plugins": [ | ||
["babel-plugin-dynamic-import-node"], | ||
["dynamic-import-node"] | ||
], | ||
"sourceMap": "inline" | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"dynamic-import-node" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": "airbnb", | ||
"env": { | ||
"es6": true, | ||
"browser": true, | ||
"node": true, | ||
"jquery": true | ||
}, | ||
"rules": { | ||
"array-callback-return": ["off"], | ||
"arrow-body-style": ["off"], | ||
"arrow-parens": ["off"], | ||
"class-methods-use-this": 0, | ||
"compat/compat": 2, | ||
"consistent-return": "off", | ||
"comma-dangle": "off", | ||
"generator-star-spacing": "off", | ||
"import/no-unresolved": ["error", { "ignore": ["electron", "atom"] }], | ||
"import/no-extraneous-dependencies": "off", | ||
"jsx-a11y/no-static-element-interactions": 0, | ||
"jsx-a11y/label-has-associated-control": [ 2, { | ||
"controlComponents": [ "Field" ] | ||
}], | ||
"jsx-a11y/label-has-for": 0, | ||
"max-len": ["off"], | ||
"no-cond-assign": ["error", "except-parens"], | ||
"no-console": 1, | ||
"no-param-reassign": ["error", { "props": false }], | ||
"no-return-assign": ["off"], | ||
"no-use-before-define": "off", | ||
"no-underscore-dangle": "off", | ||
"no-unused-vars": ["error", { "args": "none" }], | ||
"prefer-destructuring": ["error", {"array": false}], | ||
"promise/param-names": 2, | ||
"promise/always-return": 0, | ||
"promise/catch-or-return": 0, | ||
"promise/no-native": 0, | ||
"react/jsx-no-bind": "off", | ||
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }], | ||
"react/no-find-dom-node": 0, | ||
"react/no-string-refs": 0, | ||
"react/prefer-stateless-function": "off", | ||
"react/sort-comp": "off" | ||
}, | ||
"plugins": [ | ||
"import", | ||
"promise", | ||
"compat", | ||
"react" | ||
], | ||
"globals": { | ||
"atom": "readable", | ||
"electron": "readable" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
npm-debug.log | ||
node_modules | ||
.vscode | ||
package-lock.json | ||
yarn.lock | ||
toolkitsCache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"requireTrailingComma": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,101 @@ | ||
// @flow | ||
"use strict"; | ||
"use babel"; | ||
'use babel'; | ||
'use strict'; | ||
|
||
export class LintHandler { | ||
import { StreamsUtils } from './util'; | ||
|
||
linter = null; | ||
msgRegex = null; | ||
appRoot = null; | ||
const CONF_API_VERSION_V4 = 'v4'; | ||
const CONF_API_VERSION_V5 = 'v5'; | ||
|
||
constructor(linter, msgRegex, appRoot) { | ||
this.linter = linter; | ||
this.msgRegex = msgRegex; | ||
this.appRoot = appRoot; | ||
} | ||
export default class LintHandler { | ||
linter = null; | ||
|
||
msgRegex = null; | ||
|
||
lint(input) { | ||
if (!this.linter || !input) { | ||
return; | ||
} | ||
appRoot = null; | ||
|
||
if (input.output && Array.isArray(input.output)) { | ||
let convertedMessages = input.output.map( | ||
(message) => message.message_text | ||
).filter( | ||
// filter only messages that match expected format | ||
(msg) => msg.match(this.msgRegex) | ||
).map( | ||
(msg) => { | ||
// return objects for each message | ||
let parts = msg.match(this.msgRegex); | ||
let severityCode = parts[4].trim().substr(parts[4].trim().length - 1); | ||
let severity = "info"; | ||
if (severityCode) { | ||
switch (severityCode) { | ||
case "I": | ||
severity = "info"; | ||
break; | ||
case "W": | ||
severity = "warning"; | ||
break; | ||
case "E": | ||
severity = "error"; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
let absolutePath = parts[1]; | ||
if (this.appRoot && typeof(this.appRoot) === "string") { | ||
absolutePath = `${this.appRoot}/${parts[1]}`; | ||
} | ||
apiVersion = null; | ||
|
||
return { | ||
severity: severity, | ||
location: { | ||
constructor(linter, appRoot, apiVersion) { | ||
this.linter = linter; | ||
this.appRoot = appRoot; | ||
this.apiVersion = apiVersion; | ||
this.msgRegex = apiVersion === CONF_API_VERSION_V4 ? StreamsUtils.SPL_MSG_REGEX : StreamsUtils.SPL_MSG_REGEX_V5; | ||
} | ||
|
||
file: absolutePath, | ||
position: [ | ||
[parseInt(parts[2])-1 ,parseInt(parts[3])-1], | ||
[parseInt(parts[2])-1,parseInt(parts[3])] | ||
], // 0-indexed | ||
}, | ||
excerpt: parts[4], | ||
description: parts[5], | ||
}; | ||
} | ||
); | ||
setV5() { | ||
this.apiVersion = CONF_API_VERSION_V5; | ||
this.msgRegex = StreamsUtils.SPL_MSG_REGEX_V5; | ||
} | ||
|
||
this.linter.setAllMessages(convertedMessages); | ||
setV4() { | ||
this.apiVersion = CONF_API_VERSION_V4; | ||
this.msgRegex = StreamsUtils.SPL_MSG_REGEX; | ||
} | ||
|
||
if (Array.isArray(convertedMessages) && convertedMessages.length > 0) { | ||
atom.workspace.open("atom://nuclide/diagnostics"); | ||
} | ||
} | ||
} | ||
lint(input) { | ||
if (!this.linter || !input) { | ||
return; | ||
} | ||
let messages = []; | ||
if (input.output) { | ||
this.setV4(); | ||
messages = input.output.map(message => message.message_text); | ||
} else if (Array.isArray(input)) { | ||
this.setV5(); | ||
messages = input; | ||
} | ||
|
||
if (Array.isArray(messages)) { | ||
const convertedMessages = messages.filter( | ||
// filter only messages that match expected format | ||
(msg) => msg.match(this.msgRegex) | ||
).map( | ||
(msg) => { | ||
// return objects for each message | ||
const parts = msg.match(this.msgRegex); | ||
if (parts && parts.length > 4) { | ||
const severityCode = parts[4].trim().substr(parts[4].trim().length - 1); | ||
let severity = 'info'; | ||
if (severityCode) { | ||
switch (severityCode) { | ||
case 'I': | ||
severity = 'info'; | ||
break; | ||
case 'W': | ||
severity = 'warning'; | ||
break; | ||
case 'E': | ||
severity = 'error'; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
let absolutePath = parts[1]; | ||
if (this.appRoot && typeof (this.appRoot) === 'string') { | ||
absolutePath = `${this.appRoot}/${parts[1]}`; | ||
} | ||
return { | ||
severity, | ||
location: { | ||
file: absolutePath, | ||
position: [ | ||
[parseInt(parts[2], 10) - 1, parseInt(parts[3], 10) - 1], | ||
[parseInt(parts[2], 10) - 1, parseInt(parts[3], 10)] | ||
], // 0-indexed | ||
}, | ||
excerpt: parts[4], | ||
description: parts[5], | ||
}; | ||
} | ||
} | ||
); | ||
|
||
this.linter.setAllMessages(convertedMessages); | ||
|
||
if (Array.isArray(convertedMessages) && convertedMessages.length > 0) { | ||
atom.workspace.open('atom://nuclide/diagnostics'); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.