Skip to content

NEW @W-20485780@ - Add Fixes and Suggestions support in eslint#441

Open
nikhil-mittal-165 wants to merge 17 commits intodevfrom
feature/eslint-fixes-suggestions
Open

NEW @W-20485780@ - Add Fixes and Suggestions support in eslint#441
nikhil-mittal-165 wants to merge 17 commits intodevfrom
feature/eslint-fixes-suggestions

Conversation

@nikhil-mittal-165
Copy link
Contributor

No description provided.

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.
@aruntyagiTutu
Copy link
Contributor

implementation treats byte offsets as character indices, which will produce incorrect results for files with multi-byte characters

do you agree ?

@aruntyagiTutu
Copy link
Contributor

Assumes UTF-8 encoding. ESLint may analyze files with different encodings?

@nikhil-mittal-165
Copy link
Contributor Author

implementation treats byte offsets as character indices, which will produce incorrect results for files with multi-byte characters

do you agree ?

we always read the sourxce file in utf-8 encoding see this (

const packageJson: {version: string} = JSON.parse(await fs.readFile(pathToPackageJson, 'utf-8'));
)

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"

@nikhil-mittal-165 nikhil-mittal-165 force-pushed the feature/fixes-suggestion-data-modelling branch 5 times, most recently from 39bfe73 to d2be5ab Compare March 20, 2026 04:54
@nikhil-mittal-165 nikhil-mittal-165 changed the base branch from feature/fixes-suggestion-data-modelling to dev March 20, 2026 06:24

function getFileContent(filePath: string, cache: Map<string, string>): string {
if (!cache.has(filePath)) {
cache.set(filePath, fsSync.readFileSync(filePath, 'utf8'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)!;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants