JS(预期换行符为“LF”,但发现“CRLF”.eslintlinebreak-style)问题

kir*_*ior 3 html javascript css frontend visual-studio-code

我是JS新手。我创建了带有复选框行的表格。现在我想测试一下。但我的 index.js 文件出现错误。

我的代码

import React from 'react';
import { Spin, Table } from 'antd';
import { useFetch } from 'innroad.common.ui';
import * as apiService from 'services/ApiService';

const AccountType = (onSelectingItems) => {
  const [data, isLoading] = useFetch(apiService.accountType);

  return (
    <Spin spinning={isLoading}>
      <Table
        key="id"
        bordered="true"
        rowKey="id"
        dataSource={data}
        rowSelection={{ onChange: onSelectingItems }}
        pagination={false}
      >
        <Table.Column title="Account Type" dataIndex="accountType" />
      </Table>

    </Spin>
  );
};

/* AccountType.propTypes = {
  selectionType: PropTypes.string,
  onSelectingLineItems: PropTypes.func,
}; */

AccountType.defaultProps = {
  selectionType: 'checkbox',
  onSelectingLineItems: () => { },
};

export default AccountType;
Run Code Online (Sandbox Code Playgroud)

还有一个问题:我应该使用AccountType.propTypes - 注释块吗?如果是,我需要如何更改它?因为现在我在这个块中遇到错误 - 我声明但没有使用。

Index.JS(这是错误)

export { default } from './AccountType';
Run Code Online (Sandbox Code Playgroud)

预期换行符为“LF”,但在“;”之后发现“CRLF”。eslintlinebreak-style

The*_*ool 10

单击右下角的 LF / CLRF 图标并将其更改为您需要的内容。

右下角图标

选择面板

或者你可以改变 eslint 中的规则

"linebreak-style": ["error", "windows"]
or
"linebreak-style": ["error", "unix"]
Run Code Online (Sandbox Code Playgroud)

https://eslint.org/docs/rules/linebreak-style

您还可以将 git 配置为使用选定的行结束样式进行结帐。这往往是“问题”再次出现的原因。

例如

"linebreak-style": ["error", "windows"]
or
"linebreak-style": ["error", "unix"]
Run Code Online (Sandbox Code Playgroud)

https://docs.github.com/en/free-pro-team@latest/github/using-git/configuring-git-to-handle-line-endings