diff --git a/build/hygiene.js b/build/hygiene.js index f5929a38bb3..3809036dad1 100644 --- a/build/hygiene.js +++ b/build/hygiene.js @@ -41,28 +41,35 @@ function hygiene(some, linting = true) { const unicode = es.through(function (file) { const lines = file.contents.toString('utf8').split(/\r\n|\r|\n/); file.__lines = lines; - const skipAll = lines.some(line => /allow-any-unicode-file/.test(line)); - if (!skipAll) { - let skipNext = false; - lines.forEach((line, i) => { - if (/allow-any-unicode-next-line/.test(line)) { - skipNext = true; - return; + const allowInComments = lines.some(line => /allow-any-unicode-comment-file/.test(line)); + let skipNext = false; + lines.forEach((line, i) => { + if (/allow-any-unicode-next-line/.test(line)) { + skipNext = true; + return; + } + if (skipNext) { + skipNext = false; + return; + } + // If unicode is allowed in comments, trim the comment from the line + if (allowInComments) { + if (line.match(/\s+(\*)/)) { // Naive multi-line comment check + line = ''; + } else { + const index = line.indexOf('\/\/'); + line = index === -1 ? line : line.substring(0, index); } - if (skipNext) { - skipNext = false; - return; - } - // Please do not add symbols that resemble ASCII letters! - const m = /([^\t\n\r\x20-\x7E⊃⊇✔︎✓🎯⚠️🛑🔴🚗🚙🚕🎉✨❗⇧⌥⌘×÷¦⋯…↑↓→→←↔⟷·•●◆▼⟪⟫┌└├⏎↩√φ]+)/g.exec(line); - if (m) { - console.error( - file.relative + `(${i + 1},${m.index + 1}): Unexpected unicode character: "${m[0]}" (charCode: ${m[0].charCodeAt(0)}). To suppress, use // allow-any-unicode-next-line` - ); - errorCount++; - } - }); - } + } + // Please do not add symbols that resemble ASCII letters! + const m = /([^\t\n\r\x20-\x7E⊃⊇✔︎✓🎯⚠️🛑🔴🚗🚙🚕🎉✨❗⇧⌥⌘×÷¦⋯…↑↓→→←↔⟷·•●◆▼⟪⟫┌└├⏎↩√φ]+)/g.exec(line); + if (m) { + console.error( + file.relative + `(${i + 1},${m.index + 1}): Unexpected unicode character: "${m[0]}" (charCode: ${m[0].charCodeAt(0)}). To suppress, use // allow-any-unicode-next-line` + ); + errorCount++; + } + }); this.emit('data', file); }); diff --git a/src/vs/base/common/naturalLanguage/korean.ts b/src/vs/base/common/naturalLanguage/korean.ts index b292b239bbc..37d69eadca4 100644 --- a/src/vs/base/common/naturalLanguage/korean.ts +++ b/src/vs/base/common/naturalLanguage/korean.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -// allow-any-unicode-file +// allow-any-unicode-comment-file /** * Gets alternative Korean characters for the character code. This will return the ascii