I'm using React
and ESLint
with eslint-plugin-react
.
I want to disable
the prop-types
rule in one file.
var React = require('react');
var Model = require('./ComponentModel');
var Component = React.createClass({
/* eslint-disable react/prop-types */
propTypes: Model.propTypes,
/* eslint-enable react/prop-types */
render: function () {
return (
<div className="component">
{this.props.title}
</div>
);
}
});
if you have only one file you want to disable prop-type validation you can use:
/* eslint react/prop-types: 0 */
in cases where you have multiple files you can add to your .eslintrc
file in your root directory a rule to disable prop-type validation:
{
"plugins": [
"react"
],
"rules": {
"react/prop-types": 0
}
}
for further rules you can checkout this link that solved my issue and for inconvenience you can also read up from eslint-plugin-react's github documentation about how to disable or enable it with various options.