feat: implement new lint prefer-ascii
#837
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a new lint rule
prefer-ascii
that makes sure that the code is composed of only ASCII characters.Rendered doc: https://github.com/magurotuna/deno_lint/blob/ace535166b4f42a603f9ff5c540d104b4e932647/docs/rules/prefer_ascii.md
In addition, moves
display_diagnostics
function intodiagnostics.rs
and adds test cases. The previous logic of this function didn't take multi-byte characters into account, which has been fixed as well. However, to properly display diagnostic annotations for double-width characters, we still need to wait for my patch to land: rust-lang/annotate-snippets-rs#46With the current version of annotate-snippets, displayed diagnostics may point to the wrong position if the snippet contains double-width characters, like:
Closes #832