node/tools/eslint.config_utils.mjs
Michaël Zasso 7e6d92c485
tools: update ESLint to v9 and use flat config
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>
2024-05-23 19:45:18 +00:00

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`.',
},
];