mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 13:47:55 -05:00
update examples for style
add link to no-param-reassign rule documentation
This commit is contained in:
16
README.md
16
README.md
@@ -637,24 +637,24 @@ Other Style Guides
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
function f(a){
|
||||
function f1(a) {
|
||||
a = 1;
|
||||
}
|
||||
function f(a){
|
||||
function f2(a) {
|
||||
if (!a) { a = 1; }
|
||||
}
|
||||
function f(obj){
|
||||
function f3(obj) {
|
||||
obj.key = 1;
|
||||
};
|
||||
|
||||
// good
|
||||
function f(a){
|
||||
const b = (a || 1);
|
||||
function f4(a) {
|
||||
const b = a || 1;
|
||||
}
|
||||
function f(a = 1){
|
||||
function f5(a = 1) {
|
||||
}
|
||||
function f(obj){
|
||||
const key = obj.hasOwnProperty('key') ? obj.key ? 1;
|
||||
function f6(obj) {
|
||||
const key = Object.prototype.hasOwnProperty.call(obj, 'key') ? obj.key : 1;
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ module.exports = {
|
||||
'no-octal-escape': 2,
|
||||
// disallow reassignment of function parameters
|
||||
// disallow parameter object manipulation
|
||||
// rule: http://eslint.org/docs/rules/no-param-reassign.html
|
||||
'no-param-reassign': [2, { 'props': true }],
|
||||
// disallow use of process.env
|
||||
'no-process-env': 0,
|
||||
|
||||
Reference in New Issue
Block a user