]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/dot-location.md
bump version to 8.4.0-3
[pve-eslint.git] / eslint / docs / rules / dot-location.md
1 # Enforce newline before and after dot (dot-location)
2
3 JavaScript allows you to place newlines before or after a dot in a member expression.
4
5 Consistency in placing a newline before or after the dot can greatly increase readability.
6
7 ```js
8 var a = universe.
9 galaxy;
10
11 var b = universe
12 .galaxy;
13 ```
14
15 ## Rule Details
16
17 This rule aims to enforce newline consistency in member expressions. This rule prevents the use of mixed newlines around the dot in a member expression.
18
19 ## Options
20
21 The rule takes one option, a string:
22
23 * If it is `"object"` (default), the dot in a member expression should be on the same line as the object portion.
24 * If it is `"property"`, the dot in a member expression should be on the same line as the property portion.
25
26 ### object
27
28 The default `"object"` option requires the dot to be on the same line as the object.
29
30 Examples of **incorrect** code for the default `"object"` option:
31
32 ```js
33 /*eslint dot-location: ["error", "object"]*/
34
35 var foo = object
36 .property;
37 ```
38
39 Examples of **correct** code for the default `"object"` option:
40
41 ```js
42 /*eslint dot-location: ["error", "object"]*/
43
44 var foo = object.
45 property;
46
47 var bar = (
48 object
49 ).
50 property;
51
52 var baz = object.property;
53 ```
54
55 ### property
56
57 The `"property"` option requires the dot to be on the same line as the property.
58
59 Examples of **incorrect** code for the `"property"` option:
60
61 ```js
62 /*eslint dot-location: ["error", "property"]*/
63
64 var foo = object.
65 property;
66 ```
67
68 Examples of **correct** code for the `"property"` option:
69
70 ```js
71 /*eslint dot-location: ["error", "property"]*/
72
73 var foo = object
74 .property;
75 var bar = object.property;
76 ```
77
78 ## When Not To Use It
79
80 You can turn this rule off if you are not concerned with the consistency of newlines before or after dots in member expressions.
81
82 ## Related Rules
83
84 * [newline-after-var](newline-after-var.md)
85 * [dot-notation](dot-notation.md)