Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ecomfe/eslint-config

ecomfe1.4kMIT8.0.0

ESLint config for Baidu EFE.

readme

@ecomfe/eslint-config

EFE 团队使用的 ESLint 配置。

安装

npm i -D eslint @babel/eslint-parser @babel/eslint-plugin @ecomfe/eslint-config

使用

.eslintrc.js 中使用:

module.exports = {
    extends: [
        '@ecomfe/eslint-config',
    ],
};

也可开启严格模式:

module.exports = {
    extends: [
        '@ecomfe/eslint-config/strict',
    ],
};

扩展

import

如果需要检测与 import 相关的规则,需要安装这个插件:

npm i -D eslint-plugin-import

并在 .eslintrc.js 中引用:

module.exports = {
    extends: [
        '@ecomfe/eslint-config',
        '@ecomfe/eslint-config/import',
        // 或者选择严格模式
        // '@ecomfe/eslint-config/import/strict',
    ],
};

注意这些规则会要求使用 ES6 的 import 来引入依赖,如果使用的是 require 则会出现检查错误,可禁用 import/no-commonjsimport/unambiguous 来解决。

React

如果需要检测 React 相关的代码,需要安装相关插件:

npm i -D eslint-plugin-react eslint-plugin-react-hooks

并在 .eslintrc.js 中引用:

module.exports = {
    extends: [
        '@ecomfe/eslint-config',
        '@ecomfe/eslint-config/react',
        // 或者选择严格模式
        // '@ecomfe/eslint-config/react/strict',
    ],
};

会自动检测本地 React 的版本,默认情况下无需其它配置。

Vue

如果需要检测 Vue 相关的代码,需要安装相关插件:

npm i -D eslint-plugin-vue

并在 .eslintrc.js 中引用:

module.exports = {
    extends: [
        '@ecomfe/eslint-config',
        '@ecomfe/eslint-config/vue', // 注意顺序
        // 或者选择严格模式
        // '@ecomfe/eslint-config/vue/strict',
    ],
};

San

如果需要检测 San 相关的代码,需要安装相关插件:

npm i -D eslint-plugin-san

并在 .eslintrc.js 中引用:

module.exports = {
    extends: [
        '@ecomfe/eslint-config',
        '@ecomfe/eslint-config/san', // 注意顺序
        // 或者选择严格模式
        // '@ecomfe/eslint-config/san/strict',
    ],
};

TypeScript

如果需要检测 TypeScript 代码,需要安装相关插件:

npm i -D @typescript-eslint/parser @typescript-eslint/eslint-plugin

除此之外,需要先安装typescript包,并在项目根目录有tsconfig.json文件

并在.eslintrc.js中引用:

module.exports = {
    extends: [
        '@ecomfe/eslint-config',
        '@ecomfe/eslint-config/typescript',
        // 或者选择严格模式
        // '@ecomfe/eslint-config/typescript/strict',
    ],
};

细节

默认配置 @ecomfe/eslint-configFECS 相同,但临时移除了 fecs-* 的规则。

严格版配置 */strict 开启了更严格的规则。

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

8.0.0 (2023-09-15)

⚠ BREAKING CHANGES

  • update to latest eslint-plugin-vue and support vue 2.7

Features

  • update to latest eslint-plugin-vue and support vue 2.7 (5f38ead)

7.5.1 (2023-07-17)

Bug Fixes

  • 兼容新版typescript eslint删除no-duplicate-imports规则 (d9910a0)

7.5.0 (2023-07-17)

Features

  • 兼容typescript-eslint 6.x版本 (dbcc5f1)

7.4.0 (2022-01-01)

Features

  • support eslint 8 (a6c07f4)
  • update eslint-plugin-vue, add more rules and try resolving version from local package.json (105dbfb)

7.3.0 (2021-08-30)

Features

  • update san config and dependence (f63f438)

Bug Fixes

  • Typescript下禁用eslint quotes规则,使用@typescript-eslint/quotes替代 (c4739fc)

7.2.1 (2021-08-10)

Bug Fixes

  • 在TS下关闭no-empty-function规则 (fa1e4fd)
  • 清理一些和默认规则重复的strict规则 (5a361f9)

7.2.0 (2021-08-04)

Features

  • turn off vue/require-default-prop (529ab0b)
  • 用TypeScript处理init-declarations (dd33865)

Bug Fixes

  • 允许命名函数表达式替代箭头函数 (2fee3e4)
  • 去除no-useless-constructor规则,避免与@typescript-eslint/no-useless-constructor规则冲突 (ed9875a), closes #56
  • 禁用dot-notation规则,使用@typescript-eslint/dot-notation规则代替,兼容typescript noPropertyAccessFromIndexSignature配置 (c30434f), closes #56
  • 禁用no-redeclare,启用@typescript-eslint/no-redeclare,屏蔽ts下针对重复定义的错误判断 (a472576), closes #56

7.1.0 (2021-03-29)

Features

  • [max-len] ignore data uris (8807dbe)
  • disable direct-export rule as using defineComponent is actually recommended (011c0e2)
  • export helpers to get config for specific vue version (#44) (4813aaf)
  • implement baidu/vue which honors baidu/default as base js rules (376fa36)
  • ts检查中使用对ts更优的@typescript-eslint/no-duplicate-imports规则替换eslint no-duplicate-imports (4ee4e50)
  • 优化react bind检查,dom元素不再强制bing (8c3e26f)
  • 升级react/jsx-wrap-multilines规则属性,严格模式下强制使用更严格parens-new-line写法, 强化检查 (eec9665)
  • 增加'no-unreachable-loop'规则(#33) (4ad455e)
  • 增加no-extra-non-null-assertion规则 (4991889)
  • 增加经过async修饰过的箭头函数前添加空格的强制要求 (2285708)
  • 更新react/jsx-tag-spacing rule, 增加beforeClosing规则 (9c56efd)
  • 补充ts检查中丢失的对于重复类成员的检查 (7c5a5ec)
  • typescript/strict: raise no-floating-promises to error; allow void floatingPromise in the form of statement only pattern; (9a9fffb)

Bug Fixes

  • make vue config work with typescript config (c9a8cbd)
  • 修改no-use-before-define规则和@typescript-eslint/no-use-before-define的冲突问题(#35) (10f4418)
  • import/extensions: 'never,' => 'never' @typo (0d80f8b)
  • import/extensions: 更正一个配置问题 (fcce9d9)
  • spaced-comment 增加新exception(#31) (7c200c5)
  • 添加react/jsx-props-no-multi-spaces和react/jsx-props-no-multi-spaces两条规则检查(#30) (d34bd22)

7.0.0 (2020-12-28)

⚠ BREAKING CHANGES

  • require eslint-plugin-vue@7

Features

  • update eslint-plugin-vue to v7, add support for new rules and Vue 3, update version declaration for peer deps (885fe21)

Bug Fixes

6.2.1 (2020-12-11)

6.2.0 (2020-12-09)

Features

  • add baidu only rules (91aa59a)
  • add defect detection rules for baidu (93ffdc6)
  • add San support (bc69381)

Bug Fixes

  • disable all default errors in defect rules (c922402)
  • loosen some rules (5fffc72)
  • remove some duplicated rule definitions (31e2233)

6.1.0 (2020-11-13)

Features

  • disable @typescript-eslint/no-parameter-properties (6550893)