Skip to content

Commit 5a0444d

Browse files
committed
Update forbid-component-props to new ESLint rule format
I updated this via the codemod from eslint-transforms. [I ran into some errors getting eslint-transforms to run correctly as described][0], but I was able to find a workaround by running the jscodeshift command directly. [0]: eslint/eslint-transforms#2 (comment) This is a completely automated change.
1 parent ba83fd9 commit 5a0444d

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

lib/rules/forbid-component-props.js

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,52 @@ var DEFAULTS = ['className', 'style'];
1414
// Rule Definition
1515
// ------------------------------------------------------------------------------
1616

17-
module.exports = function(context) {
17+
module.exports = {
18+
meta: {
19+
docs: {},
1820

19-
function isForbidden(prop) {
20-
var configuration = context.options[0] || {};
21+
schema: [{
22+
type: 'object',
23+
properties: {
24+
forbid: {
25+
type: 'array',
26+
items: {
27+
type: 'string'
28+
}
29+
}
30+
},
31+
additionalProperties: true
32+
}]
33+
},
2134

22-
var forbid = configuration.forbid || DEFAULTS;
23-
return forbid.indexOf(prop) >= 0;
24-
}
35+
create: function(context) {
2536

26-
return {
27-
JSXAttribute: function(node) {
28-
var tag = node.parent.name.name;
29-
if (tag[0] !== tag[0].toUpperCase()) {
30-
// This is a DOM node, not a Component, so exit.
31-
return;
32-
}
37+
function isForbidden(prop) {
38+
var configuration = context.options[0] || {};
3339

34-
var prop = node.name.name;
40+
var forbid = configuration.forbid || DEFAULTS;
41+
return forbid.indexOf(prop) >= 0;
42+
}
3543

36-
if (!isForbidden(prop)) {
37-
return;
38-
}
44+
return {
45+
JSXAttribute: function(node) {
46+
var tag = node.parent.name.name;
47+
if (tag[0] !== tag[0].toUpperCase()) {
48+
// This is a DOM node, not a Component, so exit.
49+
return;
50+
}
3951

40-
context.report({
41-
node: node,
42-
message: 'Prop `' + prop + '` is forbidden on Components'
43-
});
44-
}
45-
};
46-
};
52+
var prop = node.name.name;
53+
54+
if (!isForbidden(prop)) {
55+
return;
56+
}
4757

48-
module.exports.schema = [{
49-
type: 'object',
50-
properties: {
51-
forbid: {
52-
type: 'array',
53-
items: {
54-
type: 'string'
58+
context.report({
59+
node: node,
60+
message: 'Prop `' + prop + '` is forbidden on Components'
61+
});
5562
}
56-
}
57-
},
58-
additionalProperties: true
59-
}];
63+
};
64+
}
65+
};

0 commit comments

Comments
 (0)