]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/function-call-argument-newline.md
baba38c858ed50dce1409248e786f209cb749df6
[pve-eslint.git] / eslint / docs / src / rules / function-call-argument-newline.md
1 ---
2 title: function-call-argument-newline
3 layout: doc
4 rule_type: layout
5 related_rules:
6 - function-paren-newline
7 - func-call-spacing
8 - object-property-newline
9 - array-element-newline
10 ---
11
12
13
14 A number of style guides require or disallow line breaks between arguments of a function call.
15
16 ## Rule Details
17
18 This rule enforces line breaks between arguments of a function call.
19
20 ## Options
21
22 This rule has a string option:
23
24 * `"always"` (default) requires line breaks between arguments
25 * `"never"` disallows line breaks between arguments
26 * `"consistent"` requires consistent usage of line breaks between arguments
27
28 ### always
29
30 Examples of **incorrect** code for this rule with the default `"always"` option:
31
32 ::: incorrect
33
34 ```js
35 /*eslint function-call-argument-newline: ["error", "always"]*/
36
37 foo("one", "two", "three");
38
39 bar("one", "two", {
40 one: 1,
41 two: 2
42 });
43
44 baz("one", "two", (x) => {
45 console.log(x);
46 });
47 ```
48
49 :::
50
51 Examples of **correct** code for this rule with the default `"always"` option:
52
53 ::: correct
54
55 ```js
56 /*eslint function-call-argument-newline: ["error", "always"]*/
57
58 foo(
59 "one",
60 "two",
61 "three"
62 );
63
64 bar(
65 "one",
66 "two",
67 { one: 1, two: 2 }
68 );
69 // or
70 bar(
71 "one",
72 "two",
73 {
74 one: 1,
75 two: 2
76 }
77 );
78
79 baz(
80 "one",
81 "two",
82 (x) => {
83 console.log(x);
84 }
85 );
86 ```
87
88 :::
89
90 ### never
91
92 Examples of **incorrect** code for this rule with the `"never"` option:
93
94 ::: incorrect
95
96 ```js
97 /*eslint function-call-argument-newline: ["error", "never"]*/
98
99 foo(
100 "one",
101 "two", "three"
102 );
103
104 bar(
105 "one",
106 "two", {
107 one: 1,
108 two: 2
109 }
110 );
111
112 baz(
113 "one",
114 "two", (x) => {
115 console.log(x);
116 }
117 );
118 ```
119
120 :::
121
122 Examples of **correct** code for this rule with the `"never"` option:
123
124 ::: correct
125
126 ```js
127 /*eslint function-call-argument-newline: ["error", "never"]*/
128
129 foo("one", "two", "three");
130 // or
131 foo(
132 "one", "two", "three"
133 );
134
135 bar("one", "two", { one: 1, two: 2 });
136 // or
137 bar("one", "two", {
138 one: 1,
139 two: 2
140 });
141
142 baz("one", "two", (x) => {
143 console.log(x);
144 });
145 ```
146
147 :::
148
149 ### consistent
150
151 Examples of **incorrect** code for this rule with the `"consistent"` option:
152
153 ::: incorrect
154
155 ```js
156 /*eslint function-call-argument-newline: ["error", "consistent"]*/
157
158 foo("one", "two",
159 "three");
160 //or
161 foo("one",
162 "two", "three");
163
164 bar("one", "two",
165 { one: 1, two: 2}
166 );
167
168 baz("one", "two",
169 (x) => { console.log(x); }
170 );
171 ```
172
173 :::
174
175 Examples of **correct** code for this rule with the `"consistent"` option:
176
177 ::: correct
178
179 ```js
180 /*eslint function-call-argument-newline: ["error", "consistent"]*/
181
182 foo("one", "two", "three");
183 // or
184 foo(
185 "one",
186 "two",
187 "three"
188 );
189
190 bar("one", "two", {
191 one: 1,
192 two: 2
193 });
194 // or
195 bar(
196 "one",
197 "two",
198 { one: 1, two: 2 }
199 );
200 // or
201 bar(
202 "one",
203 "two",
204 {
205 one: 1,
206 two: 2
207 }
208 );
209
210 baz("one", "two", (x) => {
211 console.log(x);
212 });
213 // or
214 baz(
215 "one",
216 "two",
217 (x) => {
218 console.log(x);
219 }
220 );
221 ```
222
223 :::
224
225 ## When Not To Use It
226
227 If you don't want to enforce line breaks between arguments, don't enable this rule.