国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Vue項目中ESlint規(guī)范示例代碼

2024-05-06 15:37:13
字體:
供稿:網(wǎng)友

前言

eslint是一種代碼風(fēng)格管理的工具,可以制定一些代碼編寫規(guī)范,在vue項目中經(jīng)常用到,本文就給大家分享了開發(fā)項目中使用的eslint校驗規(guī)范,供參考:

示例代碼

module.exports = { root: true, parserOptions: { parser: 'babel-eslint', sourceType: 'module' }, env: { browser: true, node: true, es6: true, }, extends: ['plugin:vue/essential', 'eslint:recommended'], rules: { // 等級分為三級: 0-不顯示;1-顯示警告warning; 2-顯示錯誤error //////////////////// ///// vue.規(guī)范 ///// /////////////////// "vue/max-attributes-per-line": [1, {    //多個特性的元素應(yīng)該分多行撰寫,每個特性一行  "singleline": 10,  "multiline": {  "max": 1,  "allowFirstLine": false  } }], "vue/singleline-html-element-content-newline": 0, // 在單行元素的內(nèi)容前后需要換行符 "vue/multiline-html-element-content-newline": 0, // 在多行元素的內(nèi)容之前和之后需要換行符 "vue/name-property-casing": [1, "PascalCase"], // JS/JSX中的組件名應(yīng)該始終是帕斯卡命名法 "vue/no-v-html": 0, "vue/prop-name-casing": [1, "camelCase"],   // 在聲明prop的時候,其命名應(yīng)該始終使用駝峰命名 "vue/require-v-for-key": 1,      // 給v-for設(shè)置鍵值,與key結(jié)合使用,可以高效的更新虛擬DOM "vue/no-use-v-if-with-v-for": [2, {  "allowUsingIterationVar": false }],            // 不要把 v-if 和 v-for 用在同一個元素上——因為v-for 比 v-if 具有更高的優(yōu)先級 "vue/order-in-components": [0, {     // 組件/實例的選項的順序  "order": [  "el",  "name",  "parent",  "functional",  ["delimiters", "comments"],  ["components", "directives", "filters"],  "extends",  "mixins",  "inheritAttrs",  "model",  ["props", "propsData"],  "data",  "computed",  "watch",  "LIFECYCLE_HOOKS",  "methods",  ["template", "render"],  "renderError"  ] }], //////////////////// ///// js.規(guī)范 ///// /////////////////// 'accessor-pairs': 2,    // 在對象中強制使用getter/setter 'arrow-spacing': [2, {   // 在箭頭函數(shù)之前/之后需要空格  'before': true,  'after': true }], 'block-spacing': [2, 'always'], // 在打開塊之后和關(guān)閉塊之前,禁止或強制執(zhí)行塊內(nèi)部的空格 'brace-style': [1, '1tbs', {  // 需要大括號樣式  'allowSingleLine': true }], 'camelcase': [0, {    // 需要駝峰命名  'properties': 'always' }], 'comma-dangle': [2, 'never'],  // 要求或禁止使用尾隨逗號;最后一個屬性是不需要逗號 'comma-spacing': [2, {   // 強制逗號旁邊的間距: 左右一個空格  'before': false,  'after': true }], 'comma-style': [2, 'last'],  // 逗號風(fēng)格 'constructor-super': 2,   // 構(gòu)建方法中使用super方法 'curly': [2, 'multi-line'],   'dot-location': [1, 'property'], // 在dot之前和之后強制換行 'eol-last': 2,     // 在文件末尾要求或禁止換行 'eqeqeq': [0, "always", { "null": "ignore" }], // 是否使用全等  'generator-star-spacing': [2, { // 在生成器函數(shù)中強制執(zhí)行*周圍的間距  'before': true,  'after': true }], 'handle-callback-err': [1, '^(err|error)$'], // 強制執(zhí)行回調(diào)錯誤處理 'indent': [2, 2, {     // 強制執(zhí)行一致的縮進  'SwitchCase': 1 }], 'jsx-quotes': [2, 'prefer-single'], // 強制在JSX文件中一致使用單引號 'key-spacing': [2, {    // 在對象屬性中強制鍵和值之間的一致間距  'beforeColon': false,  'afterColon': true }], 'keyword-spacing': [2, {   // 關(guān)鍵字前后強制執(zhí)行一致的間距  'before': true,  'after': true }], 'new-cap': [2, {     // 要求構(gòu)造函數(shù)名稱以大寫字母開頭  'newIsCap': true,  'capIsNew': false }], 'new-parens': 2,     // 調(diào)用不帶參數(shù)的函數(shù)時需要括號 'no-array-constructor': 2,   // 禁止陣列構(gòu)建器 'no-caller': 2,      // 禁止使用來電者/被叫者 'no-console': 'off',    // 不允許使用控制臺 'no-class-assign': 2,    // 禁止修改類聲明的變量 'no-cond-assign': 2,    // 在條件語句中禁止賦值運算符 'no-const-assign': 2,    // 禁止修改使用const聲明的變量 'no-control-regex': 0,    // 禁止正則表達式中的控制字符 'no-delete-var': 2,     // 禁止刪除變量 'no-dupe-args': 2,     // 在函數(shù)定義中禁止重復(fù)參數(shù)  'no-dupe-class-members': 2,   // 禁止在類成員中重復(fù)名稱 'no-dupe-keys': 2,     // 禁止對象重復(fù)聲明屬性 'no-duplicate-case': 2,    // 規(guī)則禁止重復(fù)案例標簽 'no-empty-character-class': 2,  // 禁止在正則表達式中使用空字符類 'no-empty-pattern': 2,    // 不允許空的解構(gòu)模式 'no-eval': 2,      // 禁止使用eval() 'no-ex-assign': 2,     // 禁止在catch子句中重新分配異常 'no-extend-native': 2,    // 禁止擴展原生對象 'no-extra-bind': 2,     // 禁止不必要的功能綁定 'no-extra-boolean-cast': 2,   // 禁止不必要的布爾類型轉(zhuǎn)換 'no-extra-parens': [2, 'functions'], // 禁止不必要的括號 'no-fallthrough': 2,     // 禁止太多陳述描述 'no-floating-decimal': 2,   // 禁止浮動小數(shù) 'no-func-assign': 2,     // 禁止重新分配函數(shù)聲明  'no-implied-eval': 2,     'no-inner-declarations': [2, 'functions'], // 禁止嵌套塊中的變量或函數(shù)聲明 'no-invalid-regexp': 2,    // 禁止在RegExp中使用無效的正則表達式字符串 'no-irregular-whitespace': 2,  // 不允許不規(guī)則的空白 'no-iterator': 2,     // 禁止迭代器 'no-label-var': 2,     // 禁止變量名稱的標簽 'no-labels': [2, {       'allowLoop': false,  'allowSwitch': false }], 'no-lone-blocks': 2,     // 禁止不必要的嵌套塊 'no-mixed-spaces-and-tabs': 2,  // 禁止使用混合空格和制表符進行縮進 'no-multi-spaces': 2,    // 禁止多個空格 'no-multi-str': 2,     // 禁止多行字符串 'no-multiple-empty-lines': [2, {  // 禁止多個空行  'max': 1 }], 'no-native-reassign': 2,     'no-negated-in-lhs': 2, 'no-new-object': 2, 'no-new-require': 2, 'no-new-symbol': 2, 'no-new-wrappers': 2, 'no-obj-calls': 2, 'no-octal': 2, 'no-octal-escape': 2, 'no-path-concat': 2, 'no-proto': 2, 'no-redeclare': 2, 'no-regex-spaces': 2, 'no-return-assign': [2, 'except-parens'], 'no-self-assign': 2, 'no-self-compare': 2, 'no-sequences': 2, 'no-shadow-restricted-names': 2, 'no-spaced-func': 2, 'no-sparse-arrays': 2, 'no-this-before-super': 2, 'no-throw-literal': 2, 'no-trailing-spaces': 2, 'no-undef': 0, 'no-undef-init': 2, 'no-unexpected-multiline': 2, 'no-unmodified-loop-condition': 2, // 禁止未修改的循環(huán)條件 'no-unneeded-ternary': [2, {   // 當(dāng)存在更簡單的替代方案時,不允許三元運算符  'defaultAssignment': false }], 'no-unreachable': 2,     // 返回,拋出,繼續(xù)和中斷語句后禁止無法訪問的代碼 'no-unsafe-finally': 2,    // 禁止finally塊中的控制流語句 'no-unused-vars': [1, {    // 禁止使用未聲明的變量  'vars': 'all',  'args': 'none' }], 'no-useless-call': 2,     // 禁止不必要的call()和apply()方法 'no-useless-computed-key': 2,   // 禁止在對象上使用不必要的計算屬性鍵 'no-useless-constructor': 2,   // 禁止不必要的構(gòu)造方法 'no-useless-escape': 0,    // 禁止不必要的轉(zhuǎn)義用法 'no-whitespace-before-property': 2, // 在屬性之前禁止空格 'no-with': 2, 'one-var': [2, {  'initialized': 'never' }], 'operator-linebreak': [2, 'after', { // 為維護強制執(zhí)行一致的換行方式  'overrides': {  '?': 'before',  ':': 'before'  } }], 'padded-blocks': [2, 'never'],   // 在塊內(nèi)要求或禁止填充 'quotes': [2, 'single', {  'avoidEscape': true,  'allowTemplateLiterals': true }], 'semi': [2, 'never'], 'semi-spacing': [2, {  'before': false,  'after': true }], 'space-before-blocks': [2, 'always'], // 不要存在多余的塊空間 'space-before-function-paren': [2, 'never'], 'space-in-parens': [2, 'never'], 'space-infix-ops': 2, 'space-unary-ops': [2, {  'words': true,  'nonwords': false }], 'spaced-comment': [2, 'always', {  'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }], 'template-curly-spacing': [2, 'never'], 'use-isnan': 2, 'valid-typeof': 2, 'wrap-iife': [2, 'any'], 'yield-star-spacing': [2, 'both'], 'yoda': [2, 'never'], 'prefer-const': 1, 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 'object-curly-spacing': [2, 'always', {  objectsInObjects: false }], 'array-bracket-spacing': [2, 'never'] }}            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 东光县| 山丹县| 广宁县| 那坡县| 乌兰县| 安化县| 四会市| 杨浦区| 普定县| 隆林| 通渭县| 弥渡县| 云南省| 临沧市| 苍梧县| 泗水县| 平泉县| 界首市| 慈溪市| 治多县| 延边| 建始县| 西盟| 祁阳县| 保山市| 贵南县| 东光县| 朝阳区| 南通市| 平遥县| 浮山县| 深州市| 徐水县| 绥德县| 鄢陵县| 苗栗市| 襄垣县| 宣武区| 沾益县| 恩施市| 依安县|