@@ -151,12 +151,103 @@ ruleTester.run('forbid-component-props', rule, {
151151 } ,
152152 ] ,
153153 } ,
154+ {
155+ code : `
156+ const item = (<Foo className="foo" />);
157+ ` ,
158+ options : [
159+ {
160+ forbid : [
161+ {
162+ propName : 'className' ,
163+ disallowedFor : [ 'ReactModal' ] ,
164+ } ,
165+ ] ,
166+ } ,
167+ ] ,
168+ } ,
169+ {
170+ code : `
171+ const item = (<Foo className="foo" />);
172+ ` ,
173+ options : [
174+ {
175+ forbid : [
176+ {
177+ propName : 'className' ,
178+ disallowedFor : [ 'ReactModal' ] ,
179+ } ,
180+ ] ,
181+ } ,
182+ ] ,
183+ } ,
154184 {
155185 code : `
156186 <fbt:param name="Total number of files" number={true} />
157187 ` ,
158188 features : [ 'jsx namespace' ] ,
159189 } ,
190+ {
191+ code : `
192+ const item = (
193+ <Foo className="bar">
194+ <ReactModal style={{color: "red"}} />
195+ </Foo>
196+ );
197+ ` ,
198+ options : [
199+ {
200+ forbid : [
201+ {
202+ propName : 'className' ,
203+ disallowedFor : [ 'OtherModal' , 'ReactModal' ] ,
204+ } ,
205+ {
206+ propName : 'style' ,
207+ disallowedFor : [ 'Foo' ] ,
208+ } ,
209+ ] ,
210+ } ,
211+ ] ,
212+ } ,
213+ {
214+ code : `
215+ const item = (
216+ <Foo className="bar">
217+ <ReactModal style={{color: "red"}} />
218+ </Foo>
219+ );
220+ ` ,
221+ options : [
222+ {
223+ forbid : [
224+ {
225+ propName : 'className' ,
226+ disallowedFor : [ 'OtherModal' , 'ReactModal' ] ,
227+ } ,
228+ {
229+ propName : 'style' ,
230+ allowedFor : [ 'ReactModal' ] ,
231+ } ,
232+ ] ,
233+ } ,
234+ ] ,
235+ } ,
236+ {
237+ code : `
238+ const item = (<this.ReactModal className="foo" />);
239+ ` ,
240+ options : [
241+ {
242+ forbid : [
243+ {
244+ propName : 'className' ,
245+ disallowedFor : [ 'ReactModal' ] ,
246+ } ,
247+ ] ,
248+ } ,
249+ ] ,
250+ } ,
160251 ] ) ,
161252
162253 invalid : parsers . all ( [
@@ -235,6 +326,34 @@ ruleTester.run('forbid-component-props', rule, {
235326 } ,
236327 ] ,
237328 } ,
329+ {
330+ code : `
331+ var First = createReactClass({
332+ propTypes: externalPropTypes,
333+ render: function() {
334+ return <Foo style={{color: "red"}} />;
335+ }
336+ });
337+ ` ,
338+ options : [
339+ {
340+ forbid : [
341+ {
342+ propName : 'style' ,
343+ disallowedFor : [ 'Foo' ] ,
344+ } ,
345+ ] ,
346+ } ,
347+ ] ,
348+ errors : [
349+ {
350+ messageId : 'propIsForbidden' ,
351+ data : { prop : 'style' } ,
352+ line : 5 ,
353+ type : 'JSXAttribute' ,
354+ } ,
355+ ] ,
356+ } ,
238357 {
239358 code : `
240359 const item = (<Foo className="foo" />);
@@ -282,6 +401,78 @@ ruleTester.run('forbid-component-props', rule, {
282401 } ,
283402 ] ,
284403 } ,
404+ {
405+ code : `
406+ const item = (<this.ReactModal className="foo" />);
407+ ` ,
408+ options : [
409+ {
410+ forbid : [
411+ {
412+ propName : 'className' ,
413+ disallowedFor : [ 'this.ReactModal' ] ,
414+ } ,
415+ ] ,
416+ } ,
417+ ] ,
418+ errors : [
419+ {
420+ messageId : 'propIsForbidden' ,
421+ data : { prop : 'className' } ,
422+ line : 2 ,
423+ column : 40 ,
424+ type : 'JSXAttribute' ,
425+ } ,
426+ ] ,
427+ } ,
428+ {
429+ code : `
430+ const item = (<ReactModal className="foo" />);
431+ ` ,
432+ options : [
433+ {
434+ forbid : [
435+ {
436+ propName : 'className' ,
437+ disallowedFor : [ 'ReactModal' ] ,
438+ } ,
439+ ] ,
440+ } ,
441+ ] ,
442+ errors : [
443+ {
444+ messageId : 'propIsForbidden' ,
445+ data : { prop : 'className' } ,
446+ line : 2 ,
447+ column : 35 ,
448+ type : 'JSXAttribute' ,
449+ } ,
450+ ] ,
451+ } ,
452+ {
453+ code : `
454+ const item = (<AntdLayout.Content className="antdFoo" />);
455+ ` ,
456+ options : [
457+ {
458+ forbid : [
459+ {
460+ propName : 'className' ,
461+ disallowedFor : [ 'AntdLayout.Content' ] ,
462+ } ,
463+ ] ,
464+ } ,
465+ ] ,
466+ errors : [
467+ {
468+ messageId : 'propIsForbidden' ,
469+ data : { prop : 'className' } ,
470+ line : 2 ,
471+ column : 43 ,
472+ type : 'JSXAttribute' ,
473+ } ,
474+ ] ,
475+ } ,
285476 {
286477 code : `
287478 const item = (<Foo className="foo" />);
0 commit comments