mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
PR-URL: https://github.com/nodejs/node/pull/61004 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import { createRequire } from 'node:module';
|
|
|
|
export { default as globals } from 'globals';
|
|
|
|
export const importEslintTool = (specifier) => import(specifier);
|
|
|
|
const localRequire = createRequire(new URL(import.meta.url));
|
|
export const resolveEslintTool = (request) => localRequire.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()',
|
|
},
|
|
{
|
|
selector: `CallExpression:matches(${[
|
|
'[callee.name="assert"]',
|
|
'[callee.object.name="assert"][callee.property.name="ok"]',
|
|
]})[arguments.0.type="Literal"]`,
|
|
message: 'Do not use a literal for the first argument of assert(), use assert.fail() instead or remove the call',
|
|
},
|
|
];
|
|
|
|
export const noRestrictedSyntaxCommonLib = [
|
|
{
|
|
selector: "CallExpression[callee.name='setTimeout'][arguments.length<2]",
|
|
message: '`setTimeout()` must be invoked with at least two arguments.',
|
|
},
|
|
];
|