-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(inspector): correct filepath cross-references in aggregate messag…
…es; closes #18 - do not hardcode `spec` in `.mocharc.js`; it's impossible to execute a single test file if it's there - add sourcemaps to Rollup config for debugging - fix "way too many subscriptions" to `Observable<Report>` instances - use `_.coerceToArray()` in a couple places - put `NO_FILEPATH` and `MULTIPLE_FILEPATHS` constants where they should be - import `gte` and `__` (placeholder) from `lodash/fp` - sort _before_ instantiating the `Report` object, not after (it will be moved anyway; see #19) - don't use hardcoded JSON in JSON formatter test - add some debugs - fix bad debug namespace in `rule-config.js` - refactor some logic into a new `Message` class in the inspector - rename `context` to `report` anywhere NOT in a Rule impl - remove unused `createReportWithFilepath()` - don't refuse to instantiate a `Report` from a `Report` - actually create a `Report` when inspecting (test harness) - remove dupe of `library-mismatch.spec.js`
- Loading branch information
Showing
17 changed files
with
236 additions
and
212 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
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
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
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
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,15 +1,18 @@ | ||
import {observable} from '@gnostic/common'; | ||
import {createDebugPipe, observable} from '@gnostic/common'; | ||
import {readFile as readFileNodeback} from 'fs'; | ||
const {bindNodeCallback, map, mergeMap, toObjectFromJSON} = observable; | ||
|
||
const readFile = bindNodeCallback(readFileNodeback); | ||
|
||
const debug = createDebugPipe('fs', 'report-loader'); | ||
|
||
export const toObjectFromFilepath = () => observable => | ||
observable.pipe( | ||
mergeMap(filepath => | ||
readFile(filepath, 'utf8').pipe( | ||
toObjectFromJSON(), | ||
map(rawReport => ({filepath, rawReport})) | ||
map(rawReport => ({filepath, rawReport})), | ||
debug(({filepath}) => `parsed raw report from ${filepath}`) | ||
) | ||
) | ||
); |
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,64 @@ | ||
import {_, constants} from '@gnostic/common'; | ||
const {ERROR, MULTIPLE_FILEPATHS} = constants; | ||
|
||
export class Message { | ||
constructor(opts = {}) { | ||
const { | ||
data, | ||
filepath, | ||
id, | ||
isAggregate, | ||
message, | ||
originalError, | ||
config, | ||
severity = ERROR | ||
} = _.omitBy( | ||
_.overEvery([_.negate(_.isError), _.negate(_.isBoolean), _.isEmpty]), | ||
opts | ||
); | ||
|
||
this.message = message.toString(); | ||
this.severity = severity; | ||
this.id = id; | ||
|
||
if (config) { | ||
this.config = config; | ||
} | ||
|
||
if (isAggregate) { | ||
this.filepath = MULTIPLE_FILEPATHS; | ||
} else if (filepath) { | ||
this.filepath = filepath; | ||
} | ||
|
||
if (originalError) { | ||
this.originalError = originalError; | ||
} | ||
|
||
if (data) { | ||
this.data = data; | ||
} | ||
} | ||
|
||
isNonEmpty() { | ||
return Boolean(this.message.trim()); | ||
} | ||
|
||
toString() { | ||
return this.message; | ||
} | ||
} | ||
|
||
export const createMessage = ( | ||
message, | ||
{filepath, id, isAggregate = false, config = {}} | ||
) => { | ||
message = _.isString(message) ? {message} : message; | ||
return new Message({ | ||
...message, | ||
config, | ||
filepath, | ||
id, | ||
isAggregate | ||
}); | ||
}; |
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
Oops, something went wrong.