| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1eac1d7 commit d795865
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,8 +137,11 @@ rules: | |||
| 137 | 137 | no-mixed-spaces-and-tabs: error | |
| 138 | 138 | no-multiple-empty-lines: [error, {max: 2, maxEOF: 0, maxBOF: 0}] | |
| 139 | 139 | no-restricted-syntax: [error, { | |
| 140 | + selector: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']", | ||
| 141 | + message: "Please replace `assert.doesNotThrow()` and add a comment next to the code instead." | ||
| 142 | + }, { | ||
| 140 | 143 | selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])", | |
| 141 | - message: "use a regular expression for second argument of assert.throws()" | ||
| 144 | + message: "Use a regular expression for second argument of assert.throws()" | ||
| 142 | 145 | }, { | |
| 143 | 146 | selector: "CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.length<2]", | |
| 144 | 147 | message: "assert.throws() must be invoked with at least two arguments." | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ function main({ n, method }) { | |||
| 26 | 26 | case 'doesNotThrow': | |
| 27 | 27 | bench.start(); | |
| 28 | 28 | for (i = 0; i < n; ++i) { | |
| 29 | + // eslint-disable-next-line no-restricted-syntax | ||
| 29 | 30 | assert.doesNotThrow(doesNotThrow); | |
| 30 | 31 | } | |
| 31 | 32 | bench.end(n); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -346,6 +346,7 @@ to the caller. | |||
| 346 | 346 | The following, for instance, will throw the [`TypeError`][] because there is no | |
| 347 | 347 | matching error type in the assertion: | |
| 348 | 348 | ||
| 349 | + <!-- eslint-disable no-restricted-syntax --> | ||
| 349 | 350 | ```js | |
| 350 | 351 | assert.doesNotThrow( | |
| 351 | 352 | () => { | |
@@ -358,6 +359,7 @@ assert.doesNotThrow( | |||
| 358 | 359 | However, the following will result in an `AssertionError` with the message | |
| 359 | 360 | 'Got unwanted exception (TypeError)..': | |
| 360 | 361 | ||
| 362 | + <!-- eslint-disable no-restricted-syntax --> | ||
| 361 | 363 | ```js | |
| 362 | 364 | assert.doesNotThrow( | |
| 363 | 365 | () => { | |
@@ -371,6 +373,7 @@ If an `AssertionError` is thrown and a value is provided for the `message` | |||
| 371 | 373 | parameter, the value of `message` will be appended to the `AssertionError` | |
| 372 | 374 | message: | |
| 373 | 375 | ||
| 376 | + <!-- eslint-disable no-restricted-syntax --> | ||
| 374 | 377 | ```js | |
| 375 | 378 | assert.doesNotThrow( | |
| 376 | 379 | () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,7 +120,7 @@ assert.ifError(null); | |||
| 120 | 120 | assert.ifError(); | |
| 121 | 121 | ||
| 122 | 122 | common.expectsError( | |
| 123 | - () => assert.doesNotThrow(() => thrower(Error), 'user message'), | ||
| 123 | + () => a.doesNotThrow(() => thrower(Error), 'user message'), | ||
| 124 | 124 | { | |
| 125 | 125 | type: a.AssertionError, | |
| 126 | 126 | code: 'ERR_ASSERTION', | |
@@ -130,15 +130,15 @@ common.expectsError( | |||
| 130 | 130 | ); | |
| 131 | 131 | ||
| 132 | 132 | common.expectsError( | |
| 133 | - () => assert.doesNotThrow(() => thrower(Error), 'user message'), | ||
| 133 | + () => a.doesNotThrow(() => thrower(Error), 'user message'), | ||
| 134 | 134 | { | |
| 135 | 135 | code: 'ERR_ASSERTION', | |
| 136 | 136 | message: /Got unwanted exception: user message\n\[object Object\]/ | |
| 137 | 137 | } | |
| 138 | 138 | ); | |
| 139 | 139 | ||
| 140 | 140 | common.expectsError( | |
| 141 | - () => assert.doesNotThrow(() => thrower(Error)), | ||
| 141 | + () => a.doesNotThrow(() => thrower(Error)), | ||
| 142 | 142 | { | |
| 143 | 143 | code: 'ERR_ASSERTION', | |
| 144 | 144 | message: /Got unwanted exception\.\n\[object Object\]/ | |
@@ -307,7 +307,7 @@ try { | |||
| 307 | 307 | ||
| 308 | 308 | // Verify AssertionError is the result from doesNotThrow with custom Error. | |
| 309 | 309 | try { | |
| 310 | - assert.doesNotThrow(() => { | ||
| 310 | + a.doesNotThrow(() => { | ||
| 311 | 311 | throw new TypeError('wrong type'); | |
| 312 | 312 | }, TypeError, rangeError); | |
| 313 | 313 | } catch (e) { | |
@@ -645,7 +645,7 @@ common.expectsError( | |||
| 645 | 645 | ); | |
| 646 | 646 | ||
| 647 | 647 | common.expectsError( | |
| 648 | - () => assert.doesNotThrow(() => { throw new Error(); }, { foo: 'bar' }), | ||
| 648 | + () => a.doesNotThrow(() => { throw new Error(); }, { foo: 'bar' }), | ||
| 649 | 649 | { | |
| 650 | 650 | type: TypeError, | |
| 651 | 651 | code: 'ERR_INVALID_ARG_TYPE', | |
@@ -676,7 +676,7 @@ common.expectsError( | |||
| 676 | 676 | assert.throws(() => { throw undefined; }, /undefined/); | |
| 677 | 677 | common.expectsError( | |
| 678 | 678 | // eslint-disable-next-line no-throw-literal | |
| 679 | - () => assert.doesNotThrow(() => { throw undefined; }), | ||
| 679 | + () => a.doesNotThrow(() => { throw undefined; }), | ||
| 680 | 680 | { | |
| 681 | 681 | type: assert.AssertionError, | |
| 682 | 682 | code: 'ERR_ASSERTION', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments