mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
870ae72227
Add a custom eslint rule to check for `common.skipIfEslintMissing()` to allow tests to run from source tarballs that do not include eslint. Fix up rule tests that were failing the new check. Refs: https://github.com/nodejs/node/issues/20336 PR-URL: https://github.com/nodejs/node/pull/20372 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
32 lines
921 B
JavaScript
32 lines
921 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfEslintMissing();
|
|
|
|
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/eslint-check');
|
|
|
|
const message = 'Please add a skipIfEslintMissing() call to allow this ' +
|
|
'test to be skipped when Node.js is built ' +
|
|
'from a source tarball.';
|
|
|
|
new RuleTester().run('eslint-check', rule, {
|
|
valid: [
|
|
'foo;',
|
|
'require("common")\n' +
|
|
'common.skipIfEslintMissing();\n' +
|
|
'require("../../tools/node_modules/eslint")'
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'require("common")\n' +
|
|
'require("../../tools/node_modules/eslint").RuleTester',
|
|
errors: [{ message }],
|
|
output: 'require("common")\n' +
|
|
'common.skipIfEslintMissing();\n' +
|
|
'require("../../tools/node_modules/eslint").RuleTester'
|
|
}
|
|
]
|
|
});
|