SublimeText3配置react語(yǔ)法校驗(yàn)

sublimetext3是一款跨平臺(tái)代碼編輯器軟件,sublimetext3既可以編寫代碼還可以編輯文本,是程序員必不可少的工具。下面由sublime使用教程欄目為大家介紹關(guān)于sublimetext3配置react語(yǔ)法校驗(yàn),希望對(duì)需要的朋友有所幫助!

SublimeText3配置react語(yǔ)法校驗(yàn)

1. 安裝nodejs

2. 打開終端,安裝eslint校驗(yàn)包和react校驗(yàn)插件包:

npm?install?-g?eslint npm?install?-g?eslint-plugin-react

3. 在Sublime中安裝插件:

SublimeLinter SublimeLinter-contrib-eslint

4. 運(yùn)行eslint –init

根據(jù)提示配置初始化文件,生成.json格式的

5. 配置.eslintrc

.eslintrc.json

{ ????????"plugins":?[ ????????????????//?"react", ????????????????"html" ????????], ????????"env":?{ ????????????????"node":?true, ????????????????"jquery":?true, ????????????????"es6":?true, ????????????????"browser":?true ????????}, ????????"globals":?{ ????????????????"angular":?false ????????}, ????????"parser":?"babel-eslint", ????????"rules":?{ ????????????????//官方文檔?http://eslint.org/docs/rules/ ????????????????//參數(shù):0?關(guān)閉,1?警告,2?錯(cuò)誤 ????????????????//?"quotes":?[0,?"single"],??????????????????//建議使用單引號(hào) ????????????????//?"no-inner-declarations":?[0,?"both"],?????//不建議在{}代碼塊內(nèi)部聲明變量或函數(shù) ????????????????"no-extra-boolean-cast":?1,?//多余的感嘆號(hào)轉(zhuǎn)布爾型 ????????????????"no-extra-semi":?1,?//多余的分號(hào) ????????????????"no-extra-parens":?0,?//多余的括號(hào) ????????????????"no-empty":?1,?//空代碼塊 ? ????????????????//使用前未定義 ????????????????"no-use-before-define":?[ ????????????????????????0, ????????????????????????"nofunc" ????????????????], ? ????????????????"complexity":?[0,?10],?//圈復(fù)雜度大于* ? ????????????????//定義數(shù)組或?qū)ο笞詈蠖嘤嗟亩禾?hào) ????????????????"comma-dangle":?[ ????????????????????????0, ????????????????????????"never" ????????????????], ? ????????????????//?不允許對(duì)全局變量賦值,如?window?=?'abc' ????????????????"no-global-assign":?["error",?{ ????????????????????????//?定義例外 ????????????????????????//?"exceptions":?["Object"] ????????????????}], ????????????????"no-var":?0,?//用let或const替代var ????????????????"no-const-assign":?2,?//不允許const重新賦值 ????????????????"no-class-assign":?2,?//不允許對(duì)class重新賦值 ????????????????"no-debugger":?1,?//debugger?調(diào)試代碼未刪除 ????????????????"no-console":?0,?//console?未刪除 ????????????????"no-constant-condition":?2,?//常量作為條件 ????????????????"no-dupe-args":?2,?//參數(shù)重復(fù) ????????????????"no-dupe-keys":?2,?//對(duì)象屬性重復(fù) ????????????????"no-duplicate-case":?2,?//case重復(fù) ????????????????"no-empty-character-class":?2,?//正則無(wú)法匹配任何值 ????????????????"no-invalid-regexp":?2,?//無(wú)效的正則 ????????????????"no-func-assign":?2,?//函數(shù)被賦值 ????????????????"valid-typeof":?1,?//無(wú)效的類型判斷 ????????????????"no-unreachable":?2,?//不可能執(zhí)行到的代碼 ????????????????"no-unexpected-multiline":?2,?//行尾缺少分號(hào)可能導(dǎo)致一些意外情況 ????????????????"no-sparse-arrays":?1,?//數(shù)組中多出逗號(hào) ????????????????"no-shadow-restricted-names":?2,?//關(guān)鍵詞與命名沖突 ????????????????"no-undef":?1,?//變量未定義 ????????????????"no-unused-vars":?1,?//變量定義后未使用 ????????????????"no-cond-assign":?2,?//條件語(yǔ)句中禁止賦值操作 ????????????????"no-native-reassign":?2,?//禁止覆蓋原生對(duì)象 ????????????????"no-mixed-spaces-and-tabs":?0, ? ? ? ????????????????//代碼風(fēng)格優(yōu)化?-------------------------------------- ????????????????"no-irregular-whitespace":?0, ????????????????"no-else-return":?0,?//在else代碼塊中return,else是多余的 ????????????????"no-multi-spaces":?0,?//不允許多個(gè)空格 ? ????????????????//object直接量建議寫法?:?后一個(gè)空格前面不留空格 ????????????????"key-spacing":?[ ????????????????????????0, ????????????????????????{ ????????????????????????????????"beforeColon":?false, ????????????????????????????????"afterColon":?true ????????????????????????} ????????????????], ? ????????????????"block-scoped-var":?1,?//變量應(yīng)在外部上下文中聲明,不應(yīng)在{}代碼塊中 ????????????????"consistent-return":?1,?//函數(shù)返回值可能是不同類型 ????????????????"accessor-pairs":?1,?//object?getter/setter方法需要成對(duì)出現(xiàn) ? ????????????????//換行調(diào)用對(duì)象方法??點(diǎn)操作符應(yīng)寫在行首 ????????????????"dot-location":?[ ????????????????????????1, ????????????????????????"property" ????????????????], ????????????????"no-lone-blocks":?1,?//多余的{}嵌套 ????????????????"no-labels":?1,?//無(wú)用的標(biāo)記 ????????????????"no-extend-native":?1,?//禁止擴(kuò)展原生對(duì)象 ????????????????"no-floating-decimal":?1,?//浮點(diǎn)型需要寫全?禁止.1?或?2.寫法 ????????????????"no-loop-func":?1,?//禁止在循環(huán)體中定義函數(shù) ????????????????"no-new-func":?1,?//禁止new?Function(...)?寫法 ????????????????"no-self-compare":?1,?//不允與自己比較作為條件 ????????????????"no-sequences":?1,?//禁止可能導(dǎo)致結(jié)果不明確的逗號(hào)操作符 ????????????????"no-throw-literal":?1,?//禁止拋出一個(gè)直接量?應(yīng)是Error對(duì)象 ? ????????????????//不允return時(shí)有賦值操作 ????????????????"no-return-assign":?[ ????????????????????????1, ????????????????????????"always" ????????????????], ? ????????????????//不允許重復(fù)聲明 ????????????????"no-redeclare":?[ ????????????????????????1, ????????????????????????{ ????????????????????????????????"builtinGlobals":?true ????????????????????????} ????????????????], ? ????????????????//不執(zhí)行的表達(dá)式 ????????????????"no-unused-expressions":?[ ????????????????????????0, ????????????????????????{ ????????????????????????????????"allowShortCircuit":?true, ????????????????????????????????"allowTernary":?true ????????????????????????} ????????????????], ????????????????"no-useless-call":?1,?//無(wú)意義的函數(shù)call或apply ????????????????"no-useless-concat":?1,?//無(wú)意義的string?concat ????????????????"no-void":?1,?//禁用void ????????????????"no-with":?1,?//禁用with ????????????????"space-infix-ops":?0,?//操作符前后空格 ? ????????????????//jsdoc ????????????????"valid-jsdoc":?[ ????????????????????????0, ????????????????????????{ ????????????????????????????????"requireParamDescription":?true, ????????????????????????????????"requireReturnDescription":?true ????????????????????????} ????????????????], ? ????????????????//標(biāo)記未寫注釋 ????????????????"no-warning-comments":?[ ????????????????????????1, ????????????????????????{ ????????????????????????????????"terms":?[ ????????????????????????????????????????"todo", ????????????????????????????????????????"fixme", ????????????????????????????????????????"any?other?term" ????????????????????????????????], ????????????????????????????????"location":?"anywhere" ????????????????????????} ????????????????], ????????????????"curly":?0?//if、else、while、for代碼塊用{}包圍 ????????} }

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊15 分享