파일에서 ESLint react/prop-type 규칙을 비활성화하려면 어떻게 해야 합니까?
사용하고 있다React그리고.ESLint와 함께eslint-plugin-react.
하고싶어disable그prop-types규칙을 1개의 파일로 만듭니다.
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>
);
}
});
하나의 파일만 있는 경우 prop-type 검증을 비활성화하려면 다음을 사용할 수 있습니다.
/* eslint react/prop-types: 0 */
여러 개의 파일이 있는 경우 에 추가할 수 있습니다..eslintrc루트 디렉토리에 있는 파일: 프로펠러 유형 검증을 사용하지 않도록 설정하는 규칙:
{
"plugins": [
"react"
],
"rules": {
"react/prop-types": 0
}
}
자세한 규칙에 대해서는, 이 링크를 체크해 주세요.또, 불편함을 위해서, eslint-disable-disable의 github 메뉴얼을 참조해 주세요.
이 파일을 파일 위에 올려놓기만 하면 됩니다.
/* eslint-disable react/prop-types */
나는 해야만 했다:
/* eslint react/forbid-prop-types: 0 */
나한테는 안 통했어
/* eslint react/prop-types: 0 */
.eslintrc 파일(이전 버전 v6.0 이하)에서 글로벌하게 비활성화하려면:
{
"rules": {
"react/forbid-prop-types": 0
}
}
.eslintrc 파일(v6.0보다 새로운 버전)에서 글로벌하게 비활성화하려면:
{
"rules": {
"react/prop-types": 0
}
}
eslint 무시 댓글로 컴포넌트 전체를 포장해야 했습니다.
var React = require('react');
var Model = require('./ComponentModel');
/* eslint-disable react/prop-types */
var Component = React.createClass({
propTypes: Model.propTypes,
render: function () {
return (
<div className="component">
{this.props.title}
</div>
);
}
});
/* eslint-enable react/prop-types */
메이저 컴포넌트와 같은 파일에 작은 컴포넌트가 있는 경우가 있습니다.PropTypes는 과잉 살상인 것 같습니다.그러면 저는 이런 걸 많이 해요.
// eslint-disable-next-line react/prop-types
const RightArrow = ({ onPress, to }) => (<TouchableOpacity onPress={() => onPress(to)} style={styles.rightArrow}><Chevrons.chevronRight size={25} color="grey" /></TouchableOpacity>);
저는 이렇게 해야 했어요..eslintrcconfig 파일을 사용하여 프로펠러 유형 검증 오류를 해제합니다.
"rules": {
"react/prop-types": "off"
}
경고로 변경할 수 있습니다. 안에 넣으십시오.eslint규칙:
'react/prop-types': ['warn'],
언급URL : https://stackoverflow.com/questions/30948970/how-to-disable-eslint-react-prop-types-rule-in-a-file
'programing' 카테고리의 다른 글
| jq를 사용하여 json의 여러 필드를 순차적으로 구문 분석 및 표시 (0) | 2023.03.28 |
|---|---|
| 서비스에 윈도우를 삽입하는 방법 (0) | 2023.03.28 |
| AngularJS: 렌더링 후 콜백(렌더 후 DOM으로 작업) (0) | 2023.03.28 |
| C++ 클래스의 JSON으로의 변환 (0) | 2023.03.28 |
| Amazon EC2 - PHP GD 이미지 라이브러리 (0) | 2023.03.28 |