You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -8,5 +8,5 @@ The Universal Permissive License (UPL), Version 1.0*
8
8
We plan to provide this functionality in the future. At that time, you will need to follow [The Oracle Contributor Agreement](https://www.oracle.com/technetwork/community/oca-486395.html)
9
9
(OCA).
10
10
11
-
If you have ideas, comments, or issues related to generator, swing on by the [Oracle JET discussion forum.](https://community.oracle.com/community/development_tools/oracle-jet/generators)
11
+
If you have ideas, comments, or issues to discuss, swing on by the [Oracle JET discussion forum.](https://community.oracle.com/community/development_tools/oracle-jet/generators)
Copy file name to clipboardExpand all lines: README.md
+47-19
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
-
# eslint-config-oraclejet 3.2.0
1
+
# @oracle/eslint-config-oraclejet4.0.0
2
2
3
3
This package contains the ESLint configurations used by the Oracle JET project. These configurations come in two flavors:
4
4
5
5
* es5: this configuration is used by the JET runtime code base, which is authored in ES5.
6
6
* es6: this configuration is used by the JET tooling code base, which consists of a collection of Node-based packages that are authored in ES6.
7
7
8
-
These ESLint configurations are based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), which defines thorough JavaScript coding guidelines with the goal of ensuring a clean, consistent code base. The Oracle JET configurations introduce some deltas on top of the base ESLint configurations defined by Airbnb, as explained below.
8
+
These ESLint configurations are based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript), which defines thorough JavaScript coding guidelines with the goal of ensuring a clean, consistent code base. The Oracle JET configurations introduce some deltas on top of the base ESLint configurations provided by Airbnb, as explained below.
9
9
10
-
Application developers are welcome to use the Oracle JET ESLint configurations with their own code bases, though be aware that several of the changes are fairly specific to JET (eg. use of underscore prefixes), so please review the changes below before adoption. A better option for JET-based applications that want to follow a similar coding standard without picking up the JET-specific quirks would be to use [Airbnb's ESLint configurations](https://www.npmjs.com/package/eslint-config-airbnb) directly.
10
+
Application developers are welcome to use the Oracle JET ESLint configurations with their own code bases, though be aware that several of the changes are fairly specific to JET (e.g. use of underscore prefixes), so please review the information below before adoption. A better option for JET-based applications that want to follow a similar coding standard without picking up the JET-specific quirks would be to use [Airbnb's ESLint configurations](https://www.npmjs.com/package/eslint-config-airbnb) directly.
11
11
12
12
## Deltas to the Airbnb ESLint Configurations
13
13
14
14
The following sections list the modifications that the Oracle JET ESLint configurations apply on top of the base Airbnb configurations.
15
15
16
16
### 1. Common Deltas
17
17
18
-
The items in this section apply to both our ES5 and ES6 configurations.
18
+
The items in this section apply to both of our configurations (ES5 and ES6).
19
19
20
20
#### 1.1 Underscore prefixes are used for private variables
21
21
@@ -29,47 +29,75 @@ The JET team is evaluating other [approaches to private properties](https://curi
29
29
30
30
_ESLint rule change_: [func-names](http://eslint.org/docs/rules/func-names) is disabled.
31
31
32
-
The Airbnb ESLint rules enforce that all function expressions must be named. This requires duplication when assigning function expressions, eg:
32
+
The Airbnb ESLint rules enforce that all function expressions must be named. This requires duplication when assigning function expressions, e.g.:
Given that ES6 specifies new rules for [function name inference](http://www.ecma-international.org/ecma-262/6.0/#sec-assignment-operators-runtime-semantics-evaluation), the JET code base allows anonymous function expressions.
39
39
40
-
Note that while modern browsers support function name inference, the use of anonymous function expressions can make debugging more challenging on older browsers (eg. IE11).
40
+
Note that while modern browsers support function name inference, the use of anonymous function expressions can make debugging more challenging on older browsers (e.g. IE11).
41
41
42
-
#### 1.3 Functions may be called before they are defined.
42
+
#### 1.3 Functions may be used before they are defined (in non-hoisting situations)
43
43
44
44
_ESLint rule change_: [no-use-before-define](http://eslint.org/docs/rules/no-use-before-define) is disabled for functions.
45
45
46
46
Robert Martin's [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882) promotes the notion that code should read like a top-down narrative, where higher level functions appear at the top of the module, followed by functions of increasingly lower levels of abstraction that are used to implement the preceding higher level functions. This approach to code organization is dubbed "The Stepdown Rule".
47
47
48
-
The JET team likes this rule enough to justify disabling the no-use-before-define rule defined by Airbnb's ESLint config. (We disable the rule just for functions, not for variables).
48
+
Unfortunately, the no-use-before-define ESLint rule is not compatible with this approach.
49
49
50
-
#### 1.4. Function declarations are allowed.
50
+
In theory, no-use-before-define intends to protect developers from relying on function hoisting behavior like this:
51
+
52
+
```javascript
53
+
// Call function that has not yet been defined
54
+
doSomething();
55
+
56
+
// Define function somewhere later in the same scope
57
+
functiondoSomething() { }
58
+
```
59
+
The above code relies on the fact that the definition of the doSomething function will be hoisted to the top of the scope, above the doSomething() call. This is reasonable to flag.
60
+
61
+
However, the no-use-before-define rule additionally reports the following code as a violation:
62
+
63
+
```javascript
64
+
functiondoSomething() {
65
+
doSomeLowerLevelThing();
66
+
}
67
+
68
+
functiondoSomeLowerLevelThing() {}
69
+
```
70
+
71
+
Although the above code does not rely on function hoisting, no-use-before-define still considers this code to be invalid, which prohibits the use of Martin's Stepdown Rule.
72
+
73
+
The JET team likes the Stepdown Rule enough to justify disabling the no-use-before-define rule defined by Airbnb's ESLint config. (We disable the rule just for functions, not for variables.)
74
+
75
+
If in the future we find (or implement) an ESLint rule that can distinguish between hoisting-dependent vs. hoisting-independent usages, we may start treating hoisting-dependent use-before-define cases as violations. As such, we encourage JET developers to limit reliance on function hoisting, even though this is not currently enforced.
76
+
77
+
78
+
#### 1.4. Function declarations are allowed
51
79
52
80
_ESLint rule change_: None.
53
81
54
-
The Airbnb style guide prefers the use of [function expressions instead of function declarations](https://github.com/airbnb/javascript#functions--declarations) due to concerns over confusion relating to function [hoisting](http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html).
82
+
The Airbnb style guide prefers the use of [function expressions instead of function declarations](https://github.com/airbnb/javascript#functions--declarations) due to concerns over function [hoisting](http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html) confusion.
55
83
56
-
We have found function declarations to be reasonably readable and have not had problems with function declaration hoisting confusion. As such, we continue to use this language feature.
84
+
We have found function declarations to be readable and have increased complexity in our code base. As such, we continue to leverage this language feature.
57
85
58
86
Note that it appears that Airbnb eventually plans to enforce the use of function expressions via the [func-style](http://eslint.org/docs/rules/func-style) rule. However, this is not yet enforced, so JET does not yet make any rule changes relating to this.
59
87
60
88
#### 1.5 Platform-specific line breaks are allowed
61
89
62
90
_ESLint rule change_: [linebreak-style](http://eslint.org/docs/rules/linebreak-style) is disabled.
63
91
64
-
Rather than enforce a consistent line break style via ESLint, we prefer to deal with this at the source control layer. This allows our developers to do development on their platform of choice (including running ESLint).
92
+
Rather than enforce a consistent line break style via ESLint, we prefer to deal with this at the source control layer. This allows our developers to do development (including running ESLint) on their platform of choice without having to worry about line breaks.
65
93
66
-
#### 1.6 The unary increment/decrement operators may be used in for loops.
94
+
#### 1.6 The unary increment/decrement operators may be used in for loops
67
95
68
96
_ESLint rule change_: [no-plusplus](http://eslint.org/docs/rules/no-plusplus) is disabled for afterthoughts in for loops.
69
97
70
98
The Airbnb style guide raises various [concerns about the use of ++ and --](https://github.com/airbnb/javascript#variables--unary-increment-decrement). While we agree with these concerns, we are comfortable with allowing these operators in for loops.
71
99
72
-
Note that, like Airbnb, we prefer [higher-order functions instead of loops](https://github.com/airbnb/javascript#iterators--nope). But for the few places where we do loop, we are okay with seeing increment/decrement operators.
100
+
Note that, like Airbnb, we prefer [higher-order functions instead of loops](https://github.com/airbnb/javascript#iterators--nope).
73
101
74
102
### 2. ES6-specific Deltas
75
103
@@ -79,7 +107,7 @@ The following changes are specific to the ES6 version of the Oracle JET ESLint c
79
107
80
108
_ESLint rule change_: [no-console](http://eslint.org/docs/rules/no-console) is disabled.
81
109
82
-
For the moment, our ES6 configuration is exclusively used by JET's Node-based tooling modules. These modules use console logging to communicate with the end user.
110
+
For the moment, our ES6 configuration is exclusively used by JET's Node-based tooling modules. These modules use console logging to communicate with the end user.
83
111
84
112
Note we are considering generalizing our ES6 rules to apply to browser code as well, in which case we would change to (globally) disallowing console logging.
85
113
@@ -93,13 +121,13 @@ The Airbnb ESLint config forbids the use of 'use strict' as Airbnb relies on [Ba
93
121
94
122
_ESLint rule change_: [comma-dangle](http://eslint.org/docs/rules/comma-dangle) is disabled.
95
123
96
-
Airbnb's (ES6) style guide mandates the use of dangling commas for the purpose of having cleaner git diffs. We find that dangling commas can be slightly less readable/more confusing for developers, so we prefer to optimize for reading over dif'fing.
124
+
Airbnb's (ES6) style guide mandates the use of dangling commas for the purpose of having cleaner git diffs. We find that dangling commas can be slightly less readable and slightly more confusing for developers, so we prefer to optimize for reading over diff'ing.
97
125
98
126
#### 2.4 Unresolved imports are (temporarily) allowed
99
127
100
128
_ESLint rule change_: [import/no-unresolved](http://eslint.org/docs/rules/import/no-unresolved) is disabled.
101
129
102
-
While we would like to leave this rule enabled, we are currently seeing some seemingly false positives trigger by this rule. We are temporarily disabling this while we get to the bottom of the violations.
130
+
While we would like to leave this rule enabled, we are currently seeing some false positives triggered by this rule. As such, we are temporarily disabling this while we get to the bottom of the violations. We plan to re-enable this rule in a future version of our eslint-config-oraclejet.
103
131
104
132
### 3. ES5-specific Deltas
105
133
@@ -109,9 +137,9 @@ The following changes are specific to the ES5 version of the Oracle JET ESLint c
109
137
110
138
_ESLint rule change_: [quote-props](http://eslint.org/docs/rules/import/quote-props) and [dot-notation](http://eslint.org/docs/rules/dot-notation) are disabled.
111
139
112
-
Like Airbnb, we strongly prefer dot notation over quoting. However, the JET code base uses quoting as a way to ensure that the Closure Compiler does not mangle certain property names. Rather than suppress each of these violations locally each time the quoted property is referenced, we decided to disable these two ESLint rules.
140
+
Like Airbnb, we strongly prefer dot notation over quoting. However, the JET runtime code base uses quoting as a way to ensure that the Closure Compiler does not mangle certain property names. Rather than suppress each of these violations locally each time the quoted property is referenced, we decided to disable these two ESLint rules globally.
113
141
114
-
We would recommend that teams building JET-based applications use dot notation and leave these two rules enabled.
142
+
We may re-enable both of these rules in the future, and as such encourage the use of dot notation wherever possible.
Oracle JET is an open source project. Pull Requests are currently not being accepted. See [CONTRIBUTING](https://github.com/oracle/eslint-config-oraclejet/tree/master/CONTRIBUTING.md) for details.
0 commit comments