Skip to content

Commit

Permalink
fix: avoid matching prototype keys in special char map
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Aug 19, 2024
1 parent 64c5b5c commit b683362
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rules/punctuation-unification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ const generateHandler = (options: Options): Handler => {

const handlerPunctuationUnified = (token: MutableToken) => {
if (token.type === GroupTokenType.GROUP) {
if (charMap[token.modifiedStartValue]) {
if (Object.prototype.hasOwnProperty.call(charMap, token.modifiedStartValue)) {
checkStartValue(
token,
charMap[token.modifiedStartValue],
PUNCTUATION_UNIFICATION
)
}
if (charMap[token.modifiedEndValue]) {
if (Object.prototype.hasOwnProperty.call(charMap, token.modifiedEndValue)) {
checkEndValue(
token,
charMap[token.modifiedEndValue],
Expand All @@ -112,7 +112,7 @@ const generateHandler = (options: Options): Handler => {
}
return
} else {
if (charMap[token.modifiedValue]) {
if (Object.prototype.hasOwnProperty.call(charMap, token.modifiedValue)) {
checkValue(
token,
charMap[token.modifiedValue],
Expand Down
5 changes: 5 additions & 0 deletions test/uncategorized.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,9 @@ import ApiIndex from './ApiIndex.vue'
`
expect(getOutput(text, options)).toBe(text)
})
// https://github.com/zhlint-project/zhlint/issues/159
test('#159 unexpected function () { [native code] }', () => {
const text = `p.toString() 中文`
expect(getOutput(text, options)).toBe(text)
})
})

0 comments on commit b683362

Please sign in to comment.