Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ad0fae

Browse filesBrowse files
andiemontoyeahdanielleadams
authored andcommitted
tools: update eslint-check.js to object style
Updated rule from deprecated function-style format to object-style format. Refs: https://eslint.org/docs/latest/developer-guide/working-with-rules PR-URL: #44706 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent fd5c26b commit 3ad0fae
Copy full SHA for 3ad0fae

File tree

Expand file treeCollapse file tree

1 file changed

+40
-39
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+40
-39
lines changed
Open diff view settings
Collapse file

‎tools/eslint-rules/eslint-check.js‎

Copy file name to clipboardExpand all lines: tools/eslint-rules/eslint-check.js
+40-39Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,54 @@ const utils = require('./rules-utils.js');
1212
const msg = 'Please add a skipIfEslintMissing() call to allow this test to ' +
1313
'be skipped when Node.js is built from a source tarball.';
1414

15-
module.exports = function(context) {
16-
const missingCheckNodes = [];
17-
let commonModuleNode = null;
18-
let hasEslintCheck = false;
15+
module.exports = {
16+
meta: {
17+
fixable: 'code',
18+
},
19+
create: function(context) {
20+
const missingCheckNodes = [];
21+
let commonModuleNode = null;
22+
let hasEslintCheck = false;
1923

20-
function testEslintUsage(context, node) {
21-
if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) {
22-
missingCheckNodes.push(node);
23-
}
24+
function testEslintUsage(context, node) {
25+
if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) {
26+
missingCheckNodes.push(node);
27+
}
2428

25-
if (utils.isCommonModule(node)) {
26-
commonModuleNode = node;
29+
if (utils.isCommonModule(node)) {
30+
commonModuleNode = node;
31+
}
2732
}
28-
}
2933

30-
function checkMemberExpression(context, node) {
31-
if (utils.usesCommonProperty(node, ['skipIfEslintMissing'])) {
32-
hasEslintCheck = true;
34+
function checkMemberExpression(context, node) {
35+
if (utils.usesCommonProperty(node, ['skipIfEslintMissing'])) {
36+
hasEslintCheck = true;
37+
}
3338
}
34-
}
3539

36-
function reportIfMissing(context) {
37-
if (!hasEslintCheck) {
38-
missingCheckNodes.forEach((node) => {
39-
context.report({
40-
node,
41-
message: msg,
42-
fix: (fixer) => {
43-
if (commonModuleNode) {
44-
return fixer.insertTextAfter(
45-
commonModuleNode,
46-
'\ncommon.skipIfEslintMissing();'
47-
);
40+
function reportIfMissing(context) {
41+
if (!hasEslintCheck) {
42+
missingCheckNodes.forEach((node) => {
43+
context.report({
44+
node,
45+
message: msg,
46+
fix: (fixer) => {
47+
if (commonModuleNode) {
48+
return fixer.insertTextAfter(
49+
commonModuleNode,
50+
'\ncommon.skipIfEslintMissing();'
51+
);
52+
}
4853
}
49-
}
54+
});
5055
});
51-
});
56+
}
5257
}
53-
}
5458

55-
return {
56-
'CallExpression': (node) => testEslintUsage(context, node),
57-
'MemberExpression': (node) => checkMemberExpression(context, node),
58-
'Program:exit': () => reportIfMissing(context)
59-
};
60-
};
61-
62-
module.exports.meta = {
63-
fixable: 'code'
59+
return {
60+
'CallExpression': (node) => testEslintUsage(context, node),
61+
'MemberExpression': (node) => checkMemberExpression(context, node),
62+
'Program:exit': () => reportIfMissing(context)
63+
};
64+
}
6465
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.