From f7971301b08d8fc870a127167804059ab2b7c71b Mon Sep 17 00:00:00 2001 From: Thomas Shafer Date: Wed, 16 Dec 2015 20:21:38 -0800 Subject: [PATCH] update examples for style add link to no-param-reassign rule documentation --- README.md | 16 ++++++++-------- .../eslint-config-airbnb/rules/best-practices.js | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f64fe911..ba2bcd0a 100644 --- a/README.md +++ b/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; }; ``` diff --git a/packages/eslint-config-airbnb/rules/best-practices.js b/packages/eslint-config-airbnb/rules/best-practices.js index e511f9b1..82e5f9e2 100644 --- a/packages/eslint-config-airbnb/rules/best-practices.js +++ b/packages/eslint-config-airbnb/rules/best-practices.js @@ -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,