-
Notifications
You must be signed in to change notification settings - Fork 198
rewrite formatters not handling paths correctly and adding extra white space #173
Comments
I use them from Grunt. They should work though, your configuration looks good. What I do to debug my build is open up ./node_modules/tslint-microsoft-contrib/fixNoVarKeywordFormatter.js on disk and start adding console.log statements to confirm that the formatter is actually found. |
Good idea. I tried that and my logs were not output to the console! The paths are correct... perhaps this is an issue with gulp-tslint? Should I ask about this on the main tslint project? |
I wonder if verbose mode will help you. |
Can I close this issue? |
Actually it just so happens that gulp-tslint was updated to v6 which now supports custom formatters - I'm surprised to learn that it didn't before! Now it does find the file and prints out my console logs, however I am getting errors from the formatter. I have a file located at However now when I run the gulp task I get this error:
Notice how the Since I only plan to use this formatter once to do the initial fix I was able to get around this by temporarily changing my glob pattern and running the task. I just thought you might want to know. |
Perhaps lines 19 & 20 need to be changed to this const leftSide: string = fileContents.substring(0, start.getPosition() + 1);
const rightSide: string = fileContents.substring(start.getPosition() + 4); Otherwise in the string I did that in my local copy and it seems to work in most cases, but not all.... |
I'm very sorry to hear that these formatters are not working for you. I wrote them for MSE and they worked there with no issues but clearly we have some different configuration. I am going to change the title of this and mark it as a bug so that we fix it. |
I wonder if some of the spacing issues are line ending issues. What are the line endings of your files? |
The fomatters assume that your file is UTF-8 encoded. Is that the case for you? What is your file encoding? |
We use "Windows line endings" and And yes, it appears we also use UTF-8 encoding. Perhaps a better way to go about replacing the string would be to use a regex like the Perhaps: |
Thanks for the patience here @ChrisMBarr I fixed the formatter to handle different line feeds. As for the path issue... I don' t know how I could fix this. The failure object only contains so much information. |
Cool, thanks! Yeah, I guess there's not much that you can do about the path. My workaround was to use a special glob pattern so it would be correct and exclude things in directories I didn't want it to happen in like |
The formatters referenced in the readme file seem be described as actually modifying the source code of the passed in TypeScript files. This seems to be a little different than the original design for the formatters. Is this correct?
I have tried, but I cannot get these formatters to work the way they are described. I am using gulp-tslint and my basic code is below
in my
tslint.json
file theno-var-keyword
rule is enabled. I do get failure messages about thevar
keyword being used, but no code is changed and the message that this formatter should log to the console is not present.Am I misunderstanding something, or do I not have this set up incorrectly?
The text was updated successfully, but these errors were encountered: