NEW @W-20485780@ - Add Fixes and Suggestions support in eslint#441
NEW @W-20485780@ - Add Fixes and Suggestions support in eslint#441nikhil-mittal-165 wants to merge 17 commits intodevfrom
Conversation
Define Fix and Suggestion types in engine-api, add core interfaces and implementations, update JSON/SARIF/XML output formats, and pass includeFixes/includeSuggestions flags through RunOptions to all engines.
Convert ESLint native Rule.Fix and Linter.LintSuggestion into the engine-agnostic Fix and Suggestion types. Add byte-offset to line/column conversion, file content caching, and Fixable tag on rule descriptions.
Define Fix and Suggestion types in engine-api, add core interfaces and implementations, update JSON/SARIF/XML output formats, and pass includeFixes/includeSuggestions flags through RunOptions to all engines.
|
implementation treats byte offsets as character indices, which will produce incorrect results for files with multi-byte characters do you agree ? |
|
Assumes UTF-8 encoding. ESLint may analyze files with different encodings? |
we always read the sourxce file in utf-8 encoding see this ( )this gets internally converted to javascript strings and the ranges are calculated based on character indices which will be uniform no matter the source encoding, i have added a test case now for multibyte files as well please check the commit titled "multibyte test case" |
39bfe73 to
d2be5ab
Compare
|
|
||
| function getFileContent(filePath: string, cache: Map<string, string>): string { | ||
| if (!cache.has(filePath)) { | ||
| cache.set(filePath, fsSync.readFileSync(filePath, 'utf8')); |
There was a problem hiding this comment.
This is a big no-no... you will keep the performance and responsiveness of Code Analyzer if you add in sync based operations. Why are you not using promises?
| if (!cache.has(filePath)) { | ||
| cache.set(filePath, fsSync.readFileSync(filePath, 'utf8')); | ||
| } | ||
| return cache.get(filePath)!; |
There was a problem hiding this comment.
If there are a lot of files, your cache is going to get very very large I'm guessing.
All this code is sensitive... so please find the best approach and test on very large projects with lots of violations and measure performance before and after.
No description provided.