mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

This adds tests for the custom eslint rules in this repository, using the `RuleTester` test utility bundled with eslint. PR-URL: https://github.com/nodejs/node/pull/16138 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
27 lines
607 B
JavaScript
27 lines
607 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const RuleTester = require('../../tools/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/buffer-constructor');
|
|
|
|
const message = 'Use of the Buffer() constructor has been deprecated. ' +
|
|
'Please use either Buffer.alloc(), Buffer.allocUnsafe(), ' +
|
|
'or Buffer.from()';
|
|
|
|
new RuleTester().run('buffer-constructor', rule, {
|
|
valid: [
|
|
'Buffer.from(foo)'
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'Buffer(foo)',
|
|
errors: [{ message }]
|
|
},
|
|
{
|
|
code: 'new Buffer(foo)',
|
|
errors: [{ message }]
|
|
}
|
|
]
|
|
});
|