| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent be5c293 commit e00bb16
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,3 +6,4 @@ rules: | |||
| 6 | 6 | buffer-constructor: error | |
| 7 | 7 | no-let-in-for-declaration: error | |
| 8 | 8 | lowercase-name-for-primitive: error | |
| 9 | + non-ascii-character: error | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,7 +84,7 @@ function createWriteErrorHandler(stream) { | |||
| 84 | 84 | // If there was an error, it will be emitted on `stream` as | |
| 85 | 85 | // an `error` event. Adding a `once` listener will keep that error | |
| 86 | 86 | // from becoming an uncaught exception, but since the handler is | |
| 87 | - // removed after the event, non-console.* writes won’t be affected. | ||
| 87 | + // removed after the event, non-console.* writes won't be affected. | ||
| 88 | 88 | // we are only adding noop if there is no one else listening for 'error' | |
| 89 | 89 | if (stream.listenerCount('error') === 0) { | |
| 90 | 90 | stream.on('error', noop); | |
@@ -125,7 +125,7 @@ function write(ignoreErrors, stream, string, errorhandler, groupIndent) { | |||
| 125 | 125 | // even in edge cases such as low stack space. | |
| 126 | 126 | if (e.message === MAX_STACK_MESSAGE && e.name === 'RangeError') | |
| 127 | 127 | throw e; | |
| 128 | - // Sorry, there’s no proper way to pass along the error here. | ||
| 128 | + // Sorry, there's no proper way to pass along the error here. | ||
| 129 | 129 | } finally { | |
| 130 | 130 | stream.removeListener('error', noop); | |
| 131 | 131 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1876,7 +1876,7 @@ function processRespondWithFD(self, fd, headers, offset = 0, length = -1, | |||
| 1876 | 1876 | return; | |
| 1877 | 1877 | } | |
| 1878 | 1878 | // exact length of the file doesn't matter here, since the | |
| 1879 | - // stream is closing anyway — just use 1 to signify that | ||
| 1879 | + // stream is closing anyway - just use 1 to signify that | ||
| 1880 | 1880 | // a write does exist | |
| 1881 | 1881 | trackWriteState(self, 1); | |
| 1882 | 1882 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,4 +3,6 @@ | |||
| 3 | 3 | // This module exists entirely for regression testing purposes. | |
| 4 | 4 | // See `test/parallel/test-internal-unicode.js`. | |
| 5 | 5 | ||
| 6 | + /* eslint-disable non-ascii-character */ | ||
| 6 | 7 | module.exports = '✓'; | |
| 8 | + /* eslint-enable non-ascii-character */ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,7 +45,7 @@ try { | |||
| 45 | 45 | try { | |
| 46 | 46 | Stream._isUint8Array = process.binding('util').isUint8Array; | |
| 47 | 47 | } catch (e) { | |
| 48 | - // This throws for Node < 4.2.0 because there’s no util binding and | ||
| 48 | + // This throws for Node < 4.2.0 because there's no util binding and | ||
| 49 | 49 | // returns undefined for Node < 7.4.0. | |
| 50 | 50 | } | |
| 51 | 51 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,6 +90,7 @@ const TIMEOUT_MAX = 2 ** 31 - 1; | |||
| 90 | 90 | // TimerWrap C++ handle, which makes the call after the duration to process the | |
| 91 | 91 | // list it is attached to. | |
| 92 | 92 | // | |
| 93 | + /* eslint-disable non-ascii-character */ | ||
| 93 | 94 | // | |
| 94 | 95 | // ╔════ > Object Map | |
| 95 | 96 | // ║ | |
@@ -111,6 +112,7 @@ const TIMEOUT_MAX = 2 ** 31 - 1; | |||
| 111 | 112 | // ║ | |
| 112 | 113 | // ╚════ > Linked List | |
| 113 | 114 | // | |
| 115 | + /* eslint-enable non-ascii-character */ | ||
| 114 | 116 | // | |
| 115 | 117 | // With this, virtually constant-time insertion (append), removal, and timeout | |
| 116 | 118 | // is possible in the JavaScript layer. Any one list of timers is able to be | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -374,7 +374,7 @@ Zlib.prototype.flush = function flush(kind, callback) { | |||
| 374 | 374 | this._scheduledFlushFlag = maxFlush(kind, this._scheduledFlushFlag); | |
| 375 | 375 | ||
| 376 | 376 | // If a callback was passed, always register a new `drain` + flush handler, | |
| 377 | - // mostly because that’s simpler and flush callbacks piling up is a rare | ||
| 377 | + // mostly because that's simpler and flush callbacks piling up is a rare | ||
| 378 | 378 | // thing anyway. | |
| 379 | 379 | if (!alreadyHadFlushScheduled || callback) { | |
| 380 | 380 | const drainHandler = () => this.flush(this._scheduledFlushFlag, callback); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,61 @@ | |||
| 1 | + /** | ||
| 2 | + * @fileOverview Any non-ASCII characters in lib/ will increase the size | ||
| 3 | + * of the compiled node binary. This linter rule ensures that | ||
| 4 | + * any such character is reported. | ||
| 5 | + * @author Sarat Addepalli <sarat.addepalli@gmail.com> | ||
| 6 | + */ | ||
| 7 | + | ||
| 8 | + 'use strict'; | ||
| 9 | + | ||
| 10 | + //------------------------------------------------------------------------------ | ||
| 11 | + // Rule Definition | ||
| 12 | + //------------------------------------------------------------------------------ | ||
| 13 | + | ||
| 14 | + const nonAsciiRegexPattern = /[^\r\n\x20-\x7e]/; | ||
| 15 | + const suggestions = { | ||
| 16 | + '’': '\'', | ||
| 17 | + '‛': '\'', | ||
| 18 | + '‘': '\'', | ||
| 19 | + '“': '"', | ||
| 20 | + '‟': '"', | ||
| 21 | + '”': '"', | ||
| 22 | + '«': '"', | ||
| 23 | + '»': '"', | ||
| 24 | + '—': '-' | ||
| 25 | + }; | ||
| 26 | + | ||
| 27 | + module.exports = (context) => { | ||
| 28 | + | ||
| 29 | + const reportIfError = (node, sourceCode) => { | ||
| 30 | + | ||
| 31 | + const matches = sourceCode.text.match(nonAsciiRegexPattern); | ||
| 32 | + | ||
| 33 | + if (!matches) return; | ||
| 34 | + | ||
| 35 | + const offendingCharacter = matches[0]; | ||
| 36 | + const offendingCharacterPosition = matches.index; | ||
| 37 | + const suggestion = suggestions[offendingCharacter]; | ||
| 38 | + | ||
| 39 | + let message = `Non-ASCII character '${offendingCharacter}' detected.`; | ||
| 40 | + | ||
| 41 | + message = suggestion ? | ||
| 42 | + `${message} Consider replacing with: ${suggestion}` : | ||
| 43 | + message; | ||
| 44 | + | ||
| 45 | + context.report({ | ||
| 46 | + node, | ||
| 47 | + message, | ||
| 48 | + loc: sourceCode.getLocFromIndex(offendingCharacterPosition), | ||
| 49 | + fix: (fixer) => { | ||
| 50 | + return fixer.replaceText( | ||
| 51 | + node, | ||
| 52 | + suggestion ? `${suggestion}` : '' | ||
| 53 | + ); | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + }; | ||
| 57 | + | ||
| 58 | + return { | ||
| 59 | + Program: (node) => reportIfError(node, context.getSourceCode()) | ||
| 60 | + }; | ||
| 61 | + }; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments