react源码剖析003 - 关于eslint

Eslint简介

eslint是一个被广泛应用的javascript/jsx代码搜检东西。

eslint设置文件能够运用js/yaml/json花样,或许在package.json中增加”eslintConfig”选项。.eslintrc已被烧毁。js花样更加天真,react项目用的是js后缀,即.eslintrc.js。

extends

extends是指扩大eslint官方支撑的lint划定规矩

extends: 'fbjs',

fbjseslint-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',
],

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

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

    原文作者:jinling
    原文地址: https://segmentfault.com/a/1190000008943134
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞