You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
privategetSourceFile(fileName: string,source: string){if(this.program!==undefined){constsourceFile=this.program.getSourceFile(fileName);if(sourceFile===undefined){constINVALID_SOURCE_ERROR=dedent` Invalid source file: ${fileName}. Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension. `;thrownewFatalError(INVALID_SOURCE_ERROR);}returnsourceFile;}else{returnutils.getSourceFile(fileName,source);}}
As an experiment, I tried editing the compiled JavaScript to make the SourceFileObject use the properties utils.getSourceFile creates, and that made the API work (although the CLI didn't quite work, it seems changing statements property was the problem).
Linter.prototype.getSourceFile=function(fileName,source){if(this.program!==undefined){varsourceFile=this.program.getSourceFile(fileName);if(sourceFile===undefined){varINVALID_SOURCE_ERROR=utils_1.dedent(templateObject_1||(templateObject_1=tslib_1.__makeTemplateObject(["\n Invalid source file: ",". Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.\n "],["\n Invalid source file: ",". Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.\n "])),fileName);thrownewerror_1.FatalError(INVALID_SOURCE_ERROR);}// ADDED CODE:constother=utils.getSourceFile(fileName,source);Object.keys(other).forEach(function(p){sourceFile[p]=other[p];});returnsourceFile;}else{returnutils.getSourceFile(fileName,source);}};
Any thoughts on this issue, or suggestions on a good way to solve it?
The text was updated successfully, but these errors were encountered:
Solid investigation and solid writeup, thanks for this!
IMO Linter and Runner have grown a bit out of hand and we could probably do with swapping into revamped versions of them. The current Linter would have to be kept around for legacy API compatibility, but I don't see a clean way around fixing the existing code in-place.
seems changing statements property was the problem
Sorry, which statements property are you referring to?
Bug Report
I don't know if this is the intended behavior as it's not really documented, but using the Node.js API with the
program
argument like this:Discards the
source
string argument:(source)
(source)
This means the code is read from disk and cannot be supplied dynamically, and linters like Atom's linter-tslint are not as useful as they could be because they cannot lint the file while the user types.
As an experiment, I tried editing the compiled JavaScript to make the
SourceFileObject
use the propertiesutils.getSourceFile
creates, and that made the API work (although the CLI didn't quite work, it seems changingstatements
property was the problem).Any thoughts on this issue, or suggestions on a good way to solve it?
The text was updated successfully, but these errors were encountered: