日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

linebreak_operator-linebreak

發布時間:2024/1/1 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linebreak_operator-linebreak 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

operator-linebreak

在命令行上的--fix選項可以自動修復一些被這條規則反映的問題。

當一條語句太長而不適合單行時,通常會在分隔表達式的運算符旁邊插入換行符。想到的第一種方式是按照英文標點符號將操作員放在行的末尾。

var fullHeight = borderTop +

innerHeight +

borderBottom;

一些開發人員發現,將行號放置在行首會使代碼更具可讀性。

var fullHeight = borderTop

+ innerHeight

+ borderBottom;

規則細節

此規則為運營商實施一致的換行樣式。

選項

此規則有一個選項,可以是字符串選項或對象選項。

字符串選項:

"after" 需要將換行符置于操作員之后

"before" 需要將換行符放在操作員面前

"none" 不允許在運營商的任何一方進行換行

對象選項:

"overrides" 覆蓋用于指定operatorsThe默認配置的全局設置是 "after", { "overrides": { "?": "before", ":": "before" } }的afterExamples 不正確代碼此規則與默認"after"選項:

/*eslint operator-linebreak: ["error", "after"]*/

foo = 1

+

2;

foo = 1

+ 2;

foo

= 5;

if (someCondition

|| otherCondition) {

}

answer = everything

? 42

: foo;Examples of correct code for this rule with the default "after" option:/*eslint operator-linebreak: ["error", "after"]*/

foo = 1 + 2;

foo = 1 +

2;

foo =

5;

if (someCondition ||

otherCondition) {

}

answer = everything ?

42 :

foo;beforeExamples of incorrect code for this rule with the "before" option:/*eslint operator-linebreak: ["error", "before"]*/

foo = 1 +

2;

foo =

5;

if (someCondition ||

otherCondition) {

}

answer = everything ?

42 :

foo;

之前的這個規則的代碼不正確"before"選項:

/*eslint operator-linebreak: ["error", "before"]*/

foo = 1 + 2;

foo = 1

+ 2;

foo

= 5;

if (someCondition

|| otherCondition) {

}

answer = everything

? 42

: foo;none

此規則的代碼不正確,代碼如下"none"選項:

/*eslint operator-linebreak: ["error", "none"]*/

foo = 1 +

2;

foo = 1

+ 2;

if (someCondition ||

otherCondition) {

}

if (someCondition

|| otherCondition) {

}

answer = everything

? 42

: foo;

answer = everything ?

42 :

foo;

此規則的代碼不正確,帶有"none"選項的代碼如下:

/*eslint operator-linebreak: ["error", "none"]*/

foo = 1 + 2;

foo = 5;

if (someCondition || otherCondition) {

}

answer = everything ? 42 : foo;overrides

此規則附加正確代碼的示例,其中包含以下{ "overrides": { "+=": "before" } }選項:

/*eslint operator-linebreak: ["error", "after", { "overrides": { "+=": "before" } }]*/

var thing

+= 'thing';

這個規則的附加正確代碼示例包含以下{ "overrides": { "?": "ignore", ":": "ignore" } }選項:

/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]*/

answer = everything ?

42

: foo;

answer = everything

?

42

:

foo;

When Not To Use It

If your project will not be using a common operator line break style, turn this rule off.Related Rules

comma-style

版本

該規則在 ESLint 0.19.0中引入。

資源

總結

以上是生活随笔為你收集整理的linebreak_operator-linebreak的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。