是否可以关闭整个文件的eslint规则?像这样的东西:
// eslint-disable-file no-use-before-define
Run Code Online (Sandbox Code Playgroud)
(类似于eslint-disable-line.)它经常发生在我身上,在某个文件中,我打破了许多地方的特定规则,对于该文件被认为是正常的,但我不想禁用整个项目的规则,我也不想禁用该特定文件的其他规则.
使用此代码:
import React from 'react';
import { Link } from 'react-router';
import { View, NavBar } from 'amazeui-touch';
import * as Pages from '../components';
const { Home, ...Components } = Pages;
Run Code Online (Sandbox Code Playgroud)
我得到这个eslint错误:
7:16 error Parsing error: Unexpected token .. Why?
Run Code Online (Sandbox Code Playgroud)
这是我的eslint配置:
{
"extends": "airbnb",
"rules": {
/* JSX */
"react/prop-types": [1, {
"ignore": ["className", "children", "location", "params", "location*"]
}],
"no-param-reassign": [0, {
"props": false
}],
"prefer-rest-params": 1,
"arrow-body-style": 0,
"prefer-template": 0,
"react/prefer-stateless-function": 1,
"react/jsx-no-bind": [0, {
"ignoreRefs": false,
"allowArrowFunctions": false, …Run Code Online (Sandbox Code Playgroud) 在以下代码的第4行,ESLint给我一个解析错误说:
意外的令牌=
我想知道为什么会这样?代码运行正常.我究竟做错了什么?
import { Component, PropTypes } from 'react';
export default class MainApp extends Component {
static propTypes = {
children: PropTypes.any.isRequired
}
componentWillMount() {
require('./styles/main.styl');
}
render() {
return (
<div>
{this.props.children}
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)