Skip to content

Commit 0c804bb

Browse files
committed
[Refactor] context comes first
1 parent 90068a4 commit 0c804bb

22 files changed

+46
-36
lines changed

lib/rules/button-has-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ module.exports = {
135135
checkValue(node, propValue);
136136
},
137137
CallExpression(node) {
138-
if (!isCreateElement(node, context) || node.arguments.length < 1) {
138+
if (!isCreateElement(context, node) || node.arguments.length < 1) {
139139
return;
140140
}
141141

lib/rules/checked-requires-onchange-or-readonly.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module.exports = {
115115
checkAttributesAndReport(node, propSet);
116116
},
117117
CallExpression(node) {
118-
if (!isCreateElement(node, context)) {
118+
if (!isCreateElement(context, node)) {
119119
return;
120120
}
121121

lib/rules/forbid-elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module.exports = {
9595
},
9696

9797
CallExpression(node) {
98-
if (!isCreateElement(node, context)) {
98+
if (!isCreateElement(context, node)) {
9999
return;
100100
}
101101

lib/rules/iframe-missing-sandbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module.exports = {
131131
},
132132

133133
CallExpression(node) {
134-
if (isCreateElement(node, context) && node.arguments && node.arguments.length > 0) {
134+
if (isCreateElement(context, node) && node.arguments && node.arguments.length > 0) {
135135
const tag = node.arguments[0];
136136
if (tag.type === 'Literal' && tag.value === 'iframe') {
137137
checkProps(context, node);

lib/rules/jsx-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ module.exports = {
425425
}
426426
if (
427427
!fn
428-
|| !jsxUtil.isReturningJSX(node, context, true)
428+
|| !jsxUtil.isReturningJSX(context, node, true)
429429
) {
430430
return;
431431
}

lib/rules/jsx-no-comment-textnodes.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ const messages = {
1717
putCommentInBraces: 'Comments inside children section of tag should be placed inside braces',
1818
};
1919

20-
function checkText(node, context) {
20+
/**
21+
* @param {Context} context
22+
* @param {ASTNode} node
23+
* @returns {void}
24+
*/
25+
function checkText(context, node) {
2126
// since babel-eslint has the wrong node.raw, we'll get the source text
2227
const rawValue = getSourceCode(context).getText(node);
2328
if (/^\s*\/(\/|\*)/m.test(rawValue)) {
@@ -56,10 +61,10 @@ module.exports = {
5661

5762
return {
5863
Literal(node) {
59-
checkText(node, context);
64+
checkText(context, node);
6065
},
6166
JSXText(node) {
62-
checkText(node, context);
67+
checkText(context, node);
6368
},
6469
};
6570
},

lib/rules/jsx-sort-default-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module.exports = {
112112
*/
113113
function checkSorted(declarations) {
114114
// function fix(fixer) {
115-
// return propTypesSortUtil.fixPropTypesSort(fixer, context, declarations, ignoreCase);
115+
// return propTypesSortUtil.fixPropTypesSort(context, fixer, declarations, ignoreCase);
116116
// }
117117

118118
declarations.reduce((prev, curr, idx, decls) => {

lib/rules/no-adjacent-inline-elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = {
111111
validate(node, node.children);
112112
},
113113
CallExpression(node) {
114-
if (!isCreateElement(node, context)) {
114+
if (!isCreateElement(context, node)) {
115115
return;
116116
}
117117
if (node.arguments.length < 2 || !node.arguments[2]) {

lib/rules/no-children-prop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const report = require('../util/report');
2121
* object literal, False if not.
2222
*/
2323
function isCreateElementWithProps(node, context) {
24-
return isCreateElement(node, context)
24+
return isCreateElement(context, node)
2525
&& node.arguments.length > 1
2626
&& node.arguments[1].type === 'ObjectExpression';
2727
}

lib/rules/no-namespace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
create(context) {
3737
return {
3838
CallExpression(node) {
39-
if (isCreateElement(node, context) && node.arguments.length > 0 && node.arguments[0].type === 'Literal') {
39+
if (isCreateElement(context, node) && node.arguments.length > 0 && node.arguments[0].type === 'Literal') {
4040
const name = node.arguments[0].value;
4141
if (typeof name !== 'string' || name.indexOf(':') === -1) return undefined;
4242
report(context, messages.noNamespace, 'noNamespace', {

0 commit comments

Comments
 (0)