mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 03:07:54 +01:00
2eff28fb7a
Greatly simplify how ESLint and its plugins are installed. PR-URL: https://github.com/nodejs/node/pull/53413 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
27 lines
954 B
JavaScript
27 lines
954 B
JavaScript
import { createRequire } from 'node:module';
|
|
|
|
export const requireEslintTool = createRequire(new URL(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.',
|
|
},
|
|
];
|