Eslint简介
eslint是一个被广泛应用的javascript/jsx代码搜检东西。
eslint设置文件能够运用js/yaml/json花样,或许在package.json中增加”eslintConfig”选项。.eslintrc已被烧毁。js花样更加天真,react项目用的是js后缀,即.eslintrc.js。
extends
extends
是指扩大eslint官方支撑的lint划定规矩
extends: 'fbjs',
fbjs
是eslint-config-fbjs
和简写,对应npm模块eslint-config-fbjs。从这个设置中,我们能够看到react没有运用eslint默许的解析器Espree
,而是挑选了babel-eslint
。为何呢?看babel-eslint
官方引见,当且仅当你运用了强范例如(Flow)或许一些eslint不支撑的仍处于试验阶段的js特征时,你才须要运用babel-eslint
。
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)
plugins
plugins
是指经由过程自定义插件,扩大可用的lint划定规矩。比方eslint-react插件,就自定义了跟jsx语法相干的lint划定规矩。
plugins: [
'react',
'react-internal',
],
上面的react
是eslint-plugin-react
的简称。react-internal
是eslint-plugin-react-internal
的简称。
原文:https://github.com/liushuigs/react-source-learning/blob/master/root/what-is-eslint.md