如何在 eslint 上禁用错误(更漂亮/更漂亮)? [英] How can I disable the error (prettier/prettier) on eslint?

查看:48
本文介绍了如何在 eslint 上禁用错误(更漂亮/更漂亮)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编码时,我没有使用 eslint.现在我安装了它,它让我的编辑器充满了更漂亮/更漂亮的错误,这绝不像是它们使我的代码更漂亮.我正在寻找解决此问题的方法.

While coding, I was not using eslint. Now I installed it and it has flooded my editor with prettier/prettier errors, which by no way seem like they make my code prettier. I am looking to find a way to solve this.

prettierrc.js:

prettierrc.js:

module.exports = {
  bracketSpacing: true,
  jsxBracketSameLine: false,
  singleQuote: true,
  trailingComma: 'all',
};

eslintrc.js:

eslintrc.js:

module.exports = {
  root: true,
  extends: '@react-native-community',
};

最后,一些示例代码:

import React, {Component} from 'react';
import {View, Text, Picker} from 'react-native';
import {connect} from 'react-redux';
import {employeeUpdate} from '../actions';
import {CardSection,  Input} from './common';

class EmployeeForm extends Component {
  render(){
    return (
      <View>
      <CardSection>
        <Input
          label="Name"
          placeholder="Marco"
          value={this.props.name}
          onChangeText={value => this.props.employeeUpdate({prop: 'name', value})}
        />
      </CardSection>

      <CardSection>
        <Input
          label="Phone"
          placeholder="555-5555"
          value={this.props.phone}
          onChangeText={value => this.props.employeeUpdate({prop: 'phone', value })}
        />
      </CardSection>

      <CardSection style={{ flexDirection: 'row'}}>
        <Text style={styles.pickerTextStyle}>Shift</Text>
        <Picker
        style={{flex: 1}}
        selectedValue={this.props.shift}
        onValueChange={value => this.props.employeeUpdate({prop: 'shift', value})}
        >
          <Picker.Item label="Monday" value="Monday" />
          <Picker.Item label="Tuesday" value="Tuesday"/>
          <Picker.Item label="Wednesday" value="Wednesday"/>
          <Picker.Item label="Thursday" value="Thursday"/>
          <Picker.Item label="Friday" value="Friday"/>
          <Picker.Item label="Saturday" value="Saturday"/>
          <Picker.Item label="Sunday" value="Sunday"/>
        </Picker>
      </CardSection>
      </View>
    );
  }
}

我只是想消除错误,因为有成千上万个红点想让我的代码更漂亮",这很烦人,但没有实现.

I am simply trying to remove the error since it is annoying to have thousands of red dots looking to make my code "prettier", which is not achieving.

推荐答案

您可以在 eslintrc.js 配置文件中禁用 prettier,而不是禁用文件的 linting:

Instead of disabling linting for the file, you can instead disable prettier within the eslintrc.js config file:

module.exports = {
  root: true,
  extends: '@react-native-community',
  rules: {
    'prettier/prettier': 0,
  },
};

这篇关于如何在 eslint 上禁用错误(更漂亮/更漂亮)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆