mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7e6d92c485
Closes: https://github.com/nodejs/node/issues/52567 PR-URL: https://github.com/nodejs/node/pull/52780 Fixes: https://github.com/nodejs/node/issues/52567 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
import { createRequire } from 'node:module';
|
|
|
|
export const requireEslintTool = createRequire(new URL('./node_modules/eslint/', import.meta.url));
|
|
export const resolveEslintTool = (request) => requireEslintTool.resolve(request);
|
|
|
|
export const noRestrictedSyntaxCommonAll = [
|
|
{
|
|
selector: "CallExpression[callee.name='setInterval'][arguments.length<2]",
|
|
message: '`setInterval()` must be invoked with at least two arguments.',
|
|
},
|
|
{
|
|
selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]',
|
|
message: 'Use `new` keyword when throwing an `Error`.',
|
|
},
|
|
{
|
|
selector: "CallExpression[callee.property.name='substr']",
|
|
message: 'Use String.prototype.slice() or String.prototype.substring() instead of String.prototype.substr()',
|
|
},
|
|
];
|
|
|
|
export const noRestrictedSyntaxCommonLib = [
|
|
{
|
|
selector: "CallExpression[callee.name='setTimeout'][arguments.length<2]",
|
|
message: '`setTimeout()` must be invoked with at least two arguments.',
|
|
},
|
|
];
|
|
|
|
export const noRestrictedSyntaxCommonTest = [
|
|
{
|
|
// TODO(@panva): move this to no-restricted-properties
|
|
// when https://github.com/eslint/eslint/issues/16412 is fixed.
|
|
selector: "Identifier[name='webcrypto']",
|
|
message: 'Use `globalThis.crypto`.',
|
|
},
|
|
];
|