Posted 鍓嶇瀛︽捣

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相关的知识,希望对你有一定的参考价值。

     鍐欏湪鍓嶉潰
        
       寮虹儓鎺ㄨ崘椤圭洰閰嶇疆ESLint浠g爜妫€鏌ュ伐鍏凤紝杩涜浠g爜妫€鏌ユ槸绉嶅緢濂界殑寮€鍙戜範鎯紝涔熸湁寰堝钁楀悕鐨勯」鐩兘鍦ㄤ娇鐢紝濡侳aceBook銆乂ue@cli銆乵ongo DB 閮藉湪浣跨敤銆?/span>

       鍒濇浣跨敤锛屼細閬囧埌閰嶇疆鍙婁娇鐢ㄧ殑棰橈紝涓烘锛屽皬缂栧湪鏂囩珷鏈熬鎺ㄨ崘浜嗐€奅SLint鐨勯厤缃枃绔犮€嬩互鍙妚scode缂栬緫鍣ㄧ殑eslint鏍煎紡鍖栦唬鐮併€傜櫧瀚栫殑鍚屽锛岃鐩存帴涓嬫粦鍒版枃绔犲簳閮?/span>

馃憞馃憞馃憞馃憞馃憞馃憞
<<<姝f枃寮€濮?gt;>>
 

      JavaScript鐨勫垱浣滄椂闂村彧鏈変袱鍛ㄧ殑鏃堕棿锛屽氨杩濲avaScript涔嬬埗 鈥?span class="mq-30">Brendan Eich鈥欎篃鎵胯JavaScript鏈韩璁捐涓婂瓨鍦ㄨ澶氱己闄枫€傚洜姝わ紝浠g爜涓嶄弗璋ㄤ篃鍙兘灏变細瑙﹀彂绁炲鐨勯敊璇€?/span>

      渚嬪: ==锛堝甫鏈夐殣寮忚浆鎹級 鍜?===锛堢粷瀵圭瓑浜庯級 鐨勬贩鐢ㄣ€佸姩鎬佺被鍨嬬殑杞崲锛堟棦鏄痡s鏈€鏈夐瓍鍔涚殑鍦版柟锛屽悓鏃朵篃閫犳垚浜嗙被鍨嬭浆鎹笉鍙帶锛屾垚涓簀s琚涓烘槸涓嶄弗璋ㄧ殑缂栫▼璇█鐨勪紬澶氱悊鐢变腑鐨勪竴椤癸紝鎵€浠ワ紝TypeScript鎴愪负JavaScript鐨勫己鍖栫増鏈嚭鐜帮級锛屽彲鑳戒細浜х敓Bug锛屽垰鍏ヨ鍓嶇鐨勫垵瀛﹁€呭彲鑳戒笉鏄撳療瑙夛紝骞跺鑷寸▼搴忔渶缁堣繍琛屽嚭閿欍€?/span>

      鎵€浠ワ紝鍦ㄩ」鐩紑鍙戜腑锛岄€夌敤涓€濂椾唬鐮佹鏌ュ伐鍏锋樉寰楅潪甯稿繀瑕併€備笅闈㈡垜浠潵绠€瑕佷簡瑙d竴涓?span class="mq-38">JavaScript浠g爜妫€鏌ュ伐鍏风殑婕斿彉鍘嗙▼銆?/span>

JSLint 鍜?JSHint

        JSLint 锛?/strong>浣滆€匘ouglas Crockford 銆傚府鍔╄澶氬紑鍙戣€呰妭鐪佷簡鎺掓煡浠g爜閿欒鐨勬椂闂淬€備絾鏄?/span> JSLint 鐨勯棶棰樻槸鍑犱箮涓嶅彲閰嶇疆 锛屼唬鐮侀鏍煎拰瑙勫垯閮芥槸鍐呯疆濂界殑锛?br>

      JSHint锛?/strong>浣滆€?Anton Kovalyov 鍦?2011 骞?Fork 鍘熼」鐩紑鍙戜簡 JSHint銆?/span> J SHint 鐨勭壒鐐瑰氨鏄彲閰嶇疆锛屽悓鏃舵枃妗d篃鐩稿瀹屽杽锛岃€屼笖瀵瑰紑鍙戣€呭弸濂姐€?/span>

ESLint 鐨勮癁鐢?span class="mq-59"> 

        Nicholas C. Zakas 2013 骞寸殑 6 鏈堜唤锛?nbsp;鍙戝竷浜?span class="mq-66">鈥斺€擡SLint



       ESLint浣跨敤 AST锛圓bstract Syntax Tree 鎶借薄璇硶鏍戯級 澶勭悊瑙勫垯 锛?/span> 鐢?Esprima 瑙f瀽浠g爜 锛屾墽琛岄€熷害瑕佹瘮鍙渶瑕佷竴姝ユ悶瀹氱殑 JSHint 鎱㈠緢澶氾紝璁?ESLint 閫嗚鐨勬槸 ECMAScript 6 鐨勫嚭鐜帮紱ES2015 瑙勮寖姝e紡鍙戝竷鍚庯紝甯傞潰涓婃祻瑙堝櫒瀵规渶鏂版爣鍑嗙殑鏀寔鎯呭喌鏋佸叾鏈夐檺銆傚鏋滄兂瑕佹彁鍓嶄綋楠屾渶鏂版爣鍑嗙殑璇硶锛屽氨寰楅潬 Babel 涔嬬被鐨勫伐鍏峰皢浠g爜缂栬瘧鎴?ES5 鐢氳嚦鏇翠綆鐨勭増鏈紝鍚屾椂涓€浜涘疄楠屾€х殑鐗规€т篃鑳介潬 Babel 杞崲銆?/span>

       ESLint 鍙墿灞曠殑浼樺娍涓€涓嬪氨浣撶幇鍑烘潵浜嗭紝 涓嶄粎鍙互鎵╁睍瑙勫垯锛岀敋鑷宠繛瑙f瀽鍣ㄤ篃鑳芥浛鎹?/span> 銆侭abel 鍥㈤槦灏变负 ESLint 寮€鍙戜簡 babel-eslint[9] 鏇挎崲榛樿瑙f瀽鍣紝璁?ESLint 鐜囧厛鏀寔 ES2015 璇硶銆?span class="mq-92">ESLint 鏈韩涔熶笉鏀寔 JSX 璇硶銆傝繕鏄洜涓哄彲鎵╁睍鎬э紝eslint-plugin-react[10] 鐨勫嚭鐜拌 ESLint 涔熻兘鏀寔褰撴椂 React 鐗规湁鐨勮鍒欍€?/span>

      2016 骞达紝JSCS锛堜笌eslint鍚屾椂鏈熷嚭鐜扮殑浠g爜妫€鏌ュ伐鍏凤級 寮€鍙戝洟闃熻涓?ESLint 鍜?JSCS 瀹炵幇鍘熺悊澶繃鐩镐技锛岃€屼笖闇€瑕佽В鍐崇殑闂涔熼兘涓€鑷达紝鏈€缁堥€夋嫨鍚堝苟鍒?ESLint

        鑷虫锛孍SLint 鎴愪负鍓嶇涓绘祦宸ュ叿

ESLint瀹樻柟浠嬬粛

        ESLint 鏄竴涓紑婧愮殑 JavaScript 浠g爜妫€鏌ュ伐鍏?/span> 锛岀敱 Nicholas C. Zakas 浜?013骞?鏈堝垱寤恒€?/span> 浠g爜妫€鏌ユ槸涓€绉嶉潤鎬佺殑鍒嗘瀽锛屽父鐢ㄤ簬瀵绘壘鏈夐棶棰樼殑妯″紡鎴栬€呬唬鐮侊紝骞朵笖涓嶄緷璧栦簬鍏蜂綋鐨勭紪鐮侀鏍?/span> 銆傚澶у鏁扮紪绋嬭瑷€鏉ヨ閮戒細鏈変唬鐮佹鏌ワ紝涓€鑸潵璇寸紪璇戠▼搴忎細鍐呯疆妫€鏌ュ伐鍏枫€?/span>
        javascript 鏄竴涓姩鎬佺殑寮辩被鍨嬭瑷€锛屽湪寮€鍙戜腑姣旇緝瀹规槗鍑洪敊銆傚洜涓烘病鏈夌紪璇戠▼搴忥紝 涓轰簡瀵绘壘 JavaScript 浠g爜閿欒閫氬父闇€瑕佸湪鎵ц杩囩▼涓笉鏂皟璇?/span> 銆傚儚 ESLint 杩欐牱鐨勫彲浠ヨ绋嬪簭鍛樺湪缂栫爜鐨勮繃绋嬩腑鍙戠幇闂鑰屼笉鏄湪鎵ц鐨勮繃绋嬩腑銆?/span>


ESLint閰嶇疆

鎺ㄨ崘閰嶇疆ESLint閰嶇疆 https://segmentfault.com/a/1190000012634130


浠ヤ笅鎺ㄨ崘涓€濂梀scode鐨凟SLint鏍煎紡鍖栦唬鐮?nbsp;

{ // vscode榛樿鍚敤浜嗘牴鎹枃浠剁被鍨嬭嚜鍔ㄨ缃畉absize鐨勯€夐」 "editor.detectIndentation": false, // 閲嶆柊璁惧畾tabsize "editor.tabSize": 2, // #姣忔淇濆瓨鐨勬椂鍊欒嚜鍔ㄦ牸寮忓寲  "editor.formatOnSave": true, // #姣忔淇濆瓨鐨勬椂鍊欏皢浠g爜鎸塭slint鏍煎紡杩涜淇 //autoFixedOnSave 璁剧疆宸插簾寮冿紝閲囩敤濡備笅鏂扮殑璁剧疆 "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "eslint.format.enable": true, //autoFix榛樿寮€鍚紝鍙渶杈撳叆瀛楃涓叉暟缁勫嵆鍙?/span> "eslint.validate": [ "javascript", "vue", "html" ], // #鍘绘帀浠g爜缁撳熬鐨勫垎鍙? "prettier.semi": true, // #浣跨敤甯﹀紩鍙锋浛浠e弻寮曞彿  "prettier.singleQuote": true, // #璁╁嚱鏁?鍚?鍜屽悗闈㈢殑鎷彿涔嬮棿鍔犱釜绌烘牸 "javascript.format.insertSpaceBeforeFunctionParenthesis": true, // #杩欎釜鎸夌敤鎴疯嚜韬範鎯€夋嫨  "vetur.format.defaultFormatter.html": "js-beautify-html", // // #璁﹙ue涓殑js鎸夌紪杈戝櫒鑷甫鐨則s鏍煎紡杩涜鏍煎紡鍖? // "vetur.format.defaultFormatter.js": "vscode-typescript", "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_attributes": "auto" // #vue缁勪欢涓環tml浠g爜鏍煎紡鍖栨牱寮?/span> } }, // 鏍煎紡鍖杝tylus, 闇€瀹夎Manta's Stylus Supremacy鎻掍欢  // 杩欓噷浣跨敤鐨勬槸css棰勫鐞嗗櫒锛宻tylus锛屽彲鏍规嵁鑷韩闇€瑕侊紝鍋氬嚭鏇存敼銆?/span> "stylusSupremacy.insertColons": false, // 鏄惁鎻掑叆鍐掑彿 "stylusSupremacy.insertSemicolons": false, // 鏄惁鎻掑叆鍒嗗ソ "stylusSupremacy.insertBraces": false, // 鏄惁鎻掑叆澶ф嫭鍙?/span> "stylusSupremacy.insertNewLineAroundImports": false, // import涔嬪悗鏄惁鎹㈣ "stylusSupremacy.insertNewLineAroundBlocks": false, "task.autoDetect": "off", "files.autoSave": "afterDelay", "window.zoomLevel": -1, "gitlens.gitCommands.closeOnFocusOut": true, "winopacity.opacity": 168, "workbench.startupEditor": "newUntitledFile" // 涓や釜閫夋嫨鍣ㄤ腑鏄惁鎹㈣}


涓嬫锛屾垜浠潵鐪嬩竴涓?span class="mq-132">AST锛圓bstract Syntax Tree 鎶借薄璇硶鏍戯級杩欎釜寮哄ぇ鐨勫伐鍏穨





以上是关于的主要内容,如果未能解决你的问题,请参考以下文章

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数

VSCode自定义代码片段8——声明函数