Skip to content

Commit ed43e35

Browse files
committed
Remove coding style rules deprecated by scalafmt
1 parent 7fa8592 commit ed43e35

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed

CODINGSTYLE.md

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
The Scala.js project has a strict policy regarding coding style.
44
This is one of the cornerstones that has allowed Scala.js to maintain a clean, consistent and maintainable codebase.
55

6-
This document tries to document the style in use as much as possible to make it easier for everyone to contribute.
6+
Most coding style rules can be applied automatically by scalafmt. It is recommended that you configure your editor to reformat on save; see the [scalafmt instructions](https://scalameta.org/scalafmt/docs/installation.html) for how to configure this.
77

8-
A *few* of these rules are checked automatically using Scalastyle, but most of them are too complex to teach to an automated tool.
8+
While most rules are checked automatically by scalafmt and Scalastyle, but there are also a few rules that are too complex to teach to an automated tool.
9+
This document tries to document the manually enforced rules as much as possible to make it easier for everyone to contribute.
910

1011
The Scala.js core team has decided to designate a single developer to drive and "maintain" the project's coding style.
1112
This allows us to maintain a consistent, yet flexible style.
@@ -32,10 +33,6 @@ In some cases, if breaking a line makes it significantly less readable, it can g
3233
Rationale: when reviewing on GitHub, only 120 characters are visible; when reviewing on a mobile phone, only 80 characters are visible.
3334
And we do review on mobile phone quite a lot.
3435

35-
#### Where to break a line
36-
37-
A line can be broken after either a `,` or a `(`, or possibly after a binary operator in a long expression.
38-
3936
### Indentation
4037

4138
In general, indentation is 2 spaces, except continuation lines, which are indented 4 spaces.
@@ -113,26 +110,6 @@ def abs(x: Int): Int =
113110
-x
114111
```
115112

116-
#### Long expressions with binary operators
117-
118-
Very long expressions consisting of binary operators at their "top-level" can be broken *without indentation* if they are alone in their brace-delimited block or their actual parameter.
119-
This happens mostly for long chains of `&&`s, `||`s, or string concatenations.
120-
Here is an example:
121-
122-
```scala
123-
val isValidIdent = {
124-
ident != "" &&
125-
ident.charAt(0).isUnicodeIdentifierStart &&
126-
ident.tail.forall(_.isUnicodeIdentifierPart)
127-
}
128-
129-
if (!isValidIdent) {
130-
reportError(
131-
"This string is very long and will " +
132-
"span several lines.")
133-
}
134-
```
135-
136113
#### Braces in lambdas
137114

138115
In lambdas (anonymous functions), the opening brace must be placed before the formal arguments, and not after the `=>`:
@@ -160,21 +137,6 @@ val f = (x: Int) => body
160137
val ys = xs.map(x => x + 1)
161138
```
162139

163-
### Spaces
164-
165-
There must not be any space before the following tokens: `:` `,` `;` `)`
166-
167-
There must be exactly one space after the following tokens: `:` `,` `;` `if` `for` `while`
168-
169-
There must be exactly one space before the tokens `=` and `=>`, and either exactly one space or a new line after them.
170-
Exception: `=>` may be vertically aligned instead in some scenarios: see [the "Pattern matching" section](#pattern-matching).
171-
172-
There must be exactly one space before and after `{` and `}`.
173-
With the exception of partial import, where there is no space on either side.
174-
175-
Binary operators must have a single space on both sides.
176-
Unary operators must not be followed by a space.
177-
178140
### Method call style
179141

180142
Usually, parentheses should be used for actual parameters to a method call.
@@ -214,8 +176,6 @@ Procedure syntax must not be used.
214176
Side-effect-free methods without formal parameters should be declared without `()`, unless either a) it overrides a method defined with `()` (such as `toString()`) or b) it implements a Java method in the Java libraries.
215177

216178
The signature of a method is technically a single line, and hence, if it has to be broken due to line length reasons, subsequent lines should be indented 4 spaces.
217-
As a reminder, the line can be broken right after a `,` or a `(` (and not, for example, after `implicit` or `:`).
218-
You should avoid breaking the line between the last parameter and the result type; going over the 80 characters limit is preferred in that case.
219179

220180
### `for` comprehensions
221181

0 commit comments

Comments
 (0)