| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1d2c81f commit 804982c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,42 @@ rules: | |||
| 11 | 11 | prefer-const: error | |
| 12 | 12 | symbol-description: off | |
| 13 | 13 | ||
| 14 | + no-restricted-syntax: | ||
| 15 | + # Config copied from .eslintrc.js | ||
| 16 | + - error | ||
| 17 | + - selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal']" | ||
| 18 | + message: "Do not use a literal for the third argument of assert.deepStrictEqual()" | ||
| 19 | + - selector: "CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])" | ||
| 20 | + message: "Do not use `assert.doesNotThrow()`. Write the code without the wrapper and add a comment instead." | ||
| 21 | + - selector: "CallExpression:matches([callee.name='doesNotReject'], [callee.property.name='doesNotReject'])" | ||
| 22 | + message: "Do not use `assert.doesNotReject()`. Write the code without the wrapper and add a comment instead." | ||
| 23 | + - selector: "CallExpression:matches([callee.name='rejects'], [callee.property.name='rejects'])[arguments.length<2]" | ||
| 24 | + message: "`assert.rejects()` must be invoked with at least two arguments." | ||
| 25 | + - selector: "CallExpression[callee.property.name='strictEqual'][arguments.2.type='Literal']" | ||
| 26 | + message: "Do not use a literal for the third argument of assert.strictEqual()" | ||
| 27 | + - selector: "CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.1.type='Literal']:not([arguments.1.regex])" | ||
| 28 | + message: "Use an object as second argument of `assert.throws()`." | ||
| 29 | + - selector: "CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.length<2]" | ||
| 30 | + message: "`assert.throws()` must be invoked with at least two arguments." | ||
| 31 | + - selector: "CallExpression[callee.name='setTimeout'][arguments.length<2]" | ||
| 32 | + message: "`setTimeout()` must be invoked with at least two arguments." | ||
| 33 | + - selector: "CallExpression[callee.name='setInterval'][arguments.length<2]" | ||
| 34 | + message: "`setInterval()` must be invoked with at least two arguments." | ||
| 35 | + - selector: "ThrowStatement > CallExpression[callee.name=/Error$/]" | ||
| 36 | + message: "Use `new` keyword when throwing an `Error`." | ||
| 37 | + - selector: "CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" | ||
| 38 | + message: "The first argument should be the `actual`, not the `expected` value." | ||
| 39 | + - selector: "CallExpression:matches([callee.name='notStrictEqual'], [callee.property.name='notStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" | ||
| 40 | + message: "The first argument should be the `actual`, not the `expected` value." | ||
| 41 | + - selector: "CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" | ||
| 42 | + message: "The first argument should be the `actual`, not the `expected` value." | ||
| 43 | + - selector: "CallExpression:matches([callee.name='strictEqual'], [callee.property.name='strictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])" | ||
| 44 | + message: "The first argument should be the `actual`, not the `expected` value." | ||
| 45 | + - selector: "CallExpression[callee.name='isNaN']" | ||
| 46 | + message: "Use Number.isNaN() instead of the global isNaN() function." | ||
| 47 | + - selector: "VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])" | ||
| 48 | + message: "Use 'test' as debuglog value in tests." | ||
| 49 | + | ||
| 14 | 50 | # Custom rules in tools/eslint-rules | |
| 15 | 51 | node-core/prefer-assert-iferror: error | |
| 16 | 52 | node-core/prefer-assert-methods: error | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,7 @@ function child(section) { | |||
| 117 | 117 | Object.defineProperty(process.stderr, 'hasColors', { | |
| 118 | 118 | value: tty.WriteStream.prototype.hasColors | |
| 119 | 119 | }); | |
| 120 | + // eslint-disable-next-line no-restricted-syntax | ||
| 120 | 121 | const debug = util.debuglog(section); | |
| 121 | 122 | debug('this', { is: 'a' }, /debugging/); | |
| 122 | 123 | debug('num=%d str=%s obj=%j', 1, 'a', { foo: 'bar' }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments