react源码解析003 - 关于eslint

Eslint简介

eslint是一个被普遍应用的javascript/jsx代码检查工具。javascript

eslint配置文件可使用js/yaml/json格式,或者在package.json中添加"eslintConfig"选项。.eslintrc已被废弃。js格式更为灵活,react项目用的是js后缀,即.eslintrc.js。java

extends

extends是指扩展eslint官方支持的lint规则react

extends: 'fbjs',

fbjseslint-config-fbjs和简写,对应npm模块eslint-config-fbjs。从这个配置中,咱们能够看到react没有使用eslint默认的解析器Espree,而是选择了babel-eslint。为何呢?看babel-eslint官方介绍,当且仅当你使用了强类型如(Flow)或者一些eslint不支持的仍处于实验阶段的js特性时,你才须要使用babel-eslintgit

You only need to use babel-eslint if you are using types (Flow) or experimental features not supported in ESLint itself yet. Otherwise try the default parser (you don't have to use it just because you are using Babel)github

plugins

plugins是指经过自定义插件,扩展可用的lint规则。好比eslint-react插件,就自定义了跟jsx语法相关的lint规则。npm

plugins: [
    'react',
    'react-internal',
],

上面的reacteslint-plugin-react的简称。react-internaleslint-plugin-react-internal的简称。json

原文:https://github.com/liushuigs/react-source-learning/blob/master/root/what-is-eslint.mdbabel

相关文章
相关标签/搜索