0.0.1 • Published 2 years ago

eslint-config-recommended-ts v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

eslint-config-recommended-ts

一个包含 prettier,eslint 的 typescript 配置文件合集, 全部启用推荐配置。

  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
  ]

eslint-config-recommended-ts 中关闭的配置和一些额外配置

  '@typescript-eslint/explicit-module-boundary-types': 0,
  '@typescript-eslint/no-explicit-any': 0,
  'no-empty': [1, { allowEmptyCatch: true }],

  'no-debugger': 2,

安装

npm i eslint-config-recommended-ts --save-dev
yarn add eslint-config-recommended-ts -D

使用

.eslintrc.js

module.exports = {
  extends: ['recommended-ts'],

  rules: {
    // your rules
  },
};
- 安装 Eslint 插件

- 保存代码即可修复错误和格式化代码

## FAQ

- 代码检查或者保存代码时格式化未生效
  - 是否安装 `prettier` 
  - vs code 的 EsLint 插件版本 >= 2.2.0
  - 安装依赖配置完成之后,重启 vscode
  - 检查 EsLint 插件配置是否开启 `source.fixAll.eslint": true`