Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 3f2bbc9

Browse files
committed
Release 3.1.0
1 parent a61523e commit 3f2bbc9

File tree

5 files changed

+130
-30
lines changed

5 files changed

+130
-30
lines changed

README.md

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,120 @@
1-
# eslint-config-oraclejet 3.0.0
1+
# eslint-config-oraclejet 3.1.0
22

3-
## About the module
4-
This module contains eslint configuration suitable for Oracle JET web and hybrid mobile applications.
3+
This package contains the ESLint configurations used by the Oracle JET project. These configurations come in two flavors:
54

6-
This is an open source project maintained by Oracle Corp.
5+
* es5: this configuration is used by the JET runtime code base, which is authored in ES5.
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+
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.
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.
11+
12+
## Deltas to the Airbnb ESLint Configurations
13+
14+
The following sections list the modifications that the Oracle JET ESLint configurations apply on top of the base Airbnb configurations.
15+
16+
### 1. Common Deltas
17+
18+
The items in this section apply to both our ES5 and ES6 configurations.
19+
20+
#### 1.1 Underscore prefixes are used for private variables
21+
22+
_ESLint rule change_: [no-underscore-dangle](http://eslint.org/docs/rules/no-underscore-dangle) is disabled.
23+
24+
While the use of underscore prefixes to identify "private" properties (functions and variables) is a [controversial](https://github.com/airbnb/javascript/issues/1024) [topic](https://github.com/airbnb/javascript/issues/1089), the JET code base uses this convention. We understand that naming conventions are not a robust solution for enforcing privacy. To help mitigate some of the risk, the JET runtime code base is run through the [Closure Compiler](https://developers.google.com/closure/compiler/), which mangles private property names.
25+
26+
The JET team is evaluating other [approaches to private properties](https://curiosity-driven.org/private-properties-in-javascript), and would encourage our clients to do the same.
27+
28+
#### 1.2 Anonymous function expressions are allowed
29+
30+
_ESLint rule change_: [func-names](http://eslint.org/docs/rules/func-names) is disabled.
31+
32+
The Airbnb ESLint rules enforce that all function expressions must be named. This requires duplication when assigning function expressions, eg:
33+
34+
```javascript
35+
Foo.prototype.doSomething = function doSomething() { };
36+
```
37+
38+
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+
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).
41+
42+
#### 1.3 Functions may be called before they are defined.
43+
44+
_ESLint rule change_: [no-use-before-define](http://eslint.org/docs/rules/no-use-before-define) is disabled for functions.
45+
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+
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).
49+
50+
#### 1.4. Function declarations are allowed.
51+
52+
_ESLint rule change_: None.
53+
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).
55+
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.
57+
58+
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+
60+
#### 1.5 Platform-specific line breaks are allowed
61+
62+
_ESLint rule change_: [linebreak-style](http://eslint.org/docs/rules/linebreak-style) is disabled.
63+
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).
65+
66+
#### 1.6 The unary increment/decrement operators may be used in for loops.
67+
68+
_ESLint rule change_: [no-plusplus](http://eslint.org/docs/rules/no-plusplus) is disabled for afterthoughts in for loops.
69+
70+
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+
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.
73+
74+
### 2. ES6-specific Deltas
75+
76+
The following changes are specific to the ES6 version of the Oracle JET ESLint configuration, used by JET's Node-based tooling packages.
77+
78+
#### 2.1 Console logging is allowed
79+
80+
_ESLint rule change_: [no-console](http://eslint.org/docs/rules/no-console) is disabled.
81+
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.
83+
84+
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+
86+
#### 2.2 Use strict is allowed
87+
88+
_ESLint rule change_: [strict](http://eslint.org/docs/rules/strict) is disabled.
89+
90+
The Airbnb ESLint config forbids the use of 'use strict' as Airbnb relies on [Babel](https://babeljs.io/) to automatically insert this construct as needed. Since JET's build infrastructure does not automatically insert 'use strict', our ESLint config allows developers to do this manually.
91+
92+
#### 2.3 Dangling commas are not required
93+
94+
_ESLint rule change_: [comma-dangle](http://eslint.org/docs/rules/comma-dangle) is disabled.
95+
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 diff'ing.
97+
98+
#### 2.4 Unresolved imports are (temporarily) allowed
99+
100+
_ESLint rule change_: [import/no-unresolved](http://eslint.org/docs/rules/import/no-unresolved) is disabled.
101+
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.
103+
104+
### 3. ES5-specific Deltas
105+
106+
The following changes are specific to the ES5 version of the Oracle JET ESLint configuration, used by the JET runtime (browser-based) code base. Note that our ES5 config is based on the [ES5 version of the Airbnb style guide](https://github.com/airbnb/javascript/tree/es5-deprecated/es5)
107+
108+
#### 3.1 Quoted properties are allowed
109+
110+
_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+
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.
113+
114+
We would recommend that teams building JET-based applications use dot notation and leave these two rules enabled.
7115

8116
## [Contributing](https://github.com/oracle/eslint-config-oraclejet/tree/master/CONTRIBUTING.md)
9117
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.
10118

11119
## [License](https://github.com/oracle/eslint-config-oraclejet/tree/master/LICENSE.md)
12120
Copyright (c) 2014, 2017 Oracle and/or its affiliates The Universal Permissive License (UPL), Version 1.0
13-

RELEASENOTES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## Release Notes for eslint-config-oraclejet ##
22

3+
### 3.1.0
4+
* No changes
5+
36
### 3.0.0
4-
* Initial release
7+
* Initial version

es5/base.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,12 @@ module.exports = {
1818
},
1919
"rules": {
2020
"comma-dangle": "off",
21-
"no-underscore-dangle": "off", // JET closure complier uses leading underscores to identify private methods
22-
"vars-on-top": "off", // anti-pattern
23-
"quote-props": "off", // JET components explictly quote properties to avoid closure-compiler transformations.
24-
"dot-notation": "off", // related to quote-props
21+
"dot-notation": "off",
2522
"func-names": "off",
26-
27-
"spaced-comment": ["warn", "always", {
28-
"line": {
29-
"markers" : ["/"],
30-
"exceptions" : ["/"],
31-
},
32-
"block": {
33-
"markers" : ["!"],
34-
"exceptions" : ["*"]
35-
}
36-
}],
23+
"linebreak-style": "off",
24+
"no-use-before-define" : ["error", {"functions" : false, "classes" : true}],
25+
"no-plusplus": ["error", {"allowForLoopAfterthoughts": true }],
26+
"no-underscore-dangle": "off",
27+
"quote-props": "off"
3728
}
3829
}

es6/base.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ module.exports = {
1010
"rules": {
1111
"comma-dangle": "off",
1212
"no-underscore-dangle": "off",
13-
"vars-on-top": "off",
1413
"func-names": "off",
15-
"linebreak-style": "off",
16-
"no-console" : "off",
17-
"strict" : "off",
18-
"import/no-unresolved" : [2, {ignore: ['oraclejet-tooling']}], // since oraclejet-tooling is defined as a url, we need it in the ignore list.
19-
"no-use-before-define" : ["error", {"functions" : false, "classes" : true}],
20-
"no-plusplus": ["off", {"allowForLoopAfterthoughts": true }] // allow ++ in loops
14+
"import/no-unresolved" : "off",
15+
"linebreak-style": "off",
16+
"no-console" : "off",
17+
"no-plusplus": ["error", {"allowForLoopAfterthoughts": true }],
18+
"no-use-before-define" : ["error", {"functions" : false, "classes" : true}],
19+
"strict" : "off"
2120
}
2221
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-oraclejet",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"license": "UPL-1.0",
55
"description": "JET Coding standards eslint config files",
66
"keywords": [
@@ -22,5 +22,5 @@
2222
{
2323
"fs-extra": "^2.0.0"
2424
},
25-
"jetdocversion": "300"
25+
"jetdocversion": "310"
2626
}

0 commit comments

Comments
 (0)