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

相關文章
相關標籤/搜索