From 8ec348ccdf6933469aaa9bf90ecbe72821e467bd Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Mon, 1 May 2017 16:51:36 +0700 Subject: [PATCH] update the style of `eslint` config with some minor changes --- .eslintignore | 4 ++++ .eslintrc | 37 ----------------------------- .eslintrc.js | 35 +++++++++++++++++++++++++++ library/modules/es6.date.to-json.js | 1 + library/modules/es6.promise.js | 1 + modules/es6.date.to-json.js | 1 + modules/es6.promise.js | 1 + modules/library/es6.date.to-json.js | 1 + package.json | 2 +- 9 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 .eslintignore delete mode 100644 .eslintrc create mode 100644 .eslintrc.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000000..3f842a754831 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +node_modules/** +build/index.js +client/** +tests/** diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f88bd008e529..000000000000 --- a/.eslintrc +++ /dev/null @@ -1,37 +0,0 @@ -{ - "env": { - "browser": true, - "node": true - }, - "rules": { - "indent": [2, 2, {"VariableDeclarator": 2, "SwitchCase": 1}], - "max-len": [2, 120, 2], - "eol-last": 0, - "camelcase": 2, - "brace-style": [2, "1tbs", { "allowSingleLine": true }], - "quote-props": [2, "as-needed", {"keywords": true}], - "dot-notation": [2, {"allowKeywords": false}], - "quotes": [2, "single", "avoid-escape"], - "new-parens": 0, - "new-cap": [2, {"newIsCap": true, "capIsNew": false}], - "no-wrap-func": 0, - "no-use-before-define": 0, - "no-cond-assign": 0, - "no-underscore-dangle": 0, - "no-native-reassign": 0, - "no-shadow-restricted-names": 0, - "no-fallthrough": 0, - "eqeqeq": 0, - "comma-spacing": 0, - "no-multi-spaces": 0, - "key-spacing": 0, - "strict": 0, - "no-mixed-requires": 0, - "no-loop-func": 0, - "no-unused-expressions": 0, - "no-unused-vars": [2, {"args": "none"}], - "curly": 0, - "max-nested-callbacks": [2, 4], - "no-multiple-empty-lines": 2 - } -} \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000000..1c8c23b3a2a7 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,35 @@ +module.exports = { + env: { + browser: true, + node: true, + }, + rules: { + // best practices: + // encourages use of dot notation whenever possible + 'dot-notation': ['error', { allowKeywords: false }], + + // variables: + // disallow declaration of variables that are not used in the code + 'no-unused-vars': ['error', { vars: 'local', args: 'after-used', ignoreRestSiblings: true }], + + // stylistic issues: + // enforce one true brace style + 'brace-style': ['error', '1tbs', { allowSingleLine: true }], + // require camel case names + camelcase: ['error', { properties: 'never' }], + // this option sets a specific tab width for your code + indent: ['error', 2, { VariableDeclarator: 2, SwitchCase: 1 }], + // specify the maximum length of a line in your program + 'max-len': ['error', 120, 2], + // enforce a maximum depth that callbacks can be nested + 'max-nested-callbacks': ['error', 4], + // require a capital letter for constructors + 'new-cap': ['error', { newIsCap: true, capIsNew: false }], + // disallow multiple empty lines and only one newline at the end + 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }], + // specify whether double or single quotes should be used + quotes: ['error', 'single', 'avoid-escape'], + // require or disallow use of quotes around object literal property names + 'quote-props': ['error', 'as-needed', { keywords: true }], + } +}; diff --git a/library/modules/es6.date.to-json.js b/library/modules/es6.date.to-json.js index e079c8923ec4..faca934a9469 100644 --- a/library/modules/es6.date.to-json.js +++ b/library/modules/es6.date.to-json.js @@ -8,6 +8,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails')(function(){ return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1; }), 'Date', { + // eslint-disable-next-line no-unused-vars toJSON: function toJSON(key){ var O = toObject(this) , pv = toPrimitive(O); diff --git a/library/modules/es6.promise.js b/library/modules/es6.promise.js index 262a93af140d..60924628e3e3 100644 --- a/library/modules/es6.promise.js +++ b/library/modules/es6.promise.js @@ -193,6 +193,7 @@ if(!USE_NATIVE){ $reject.call(this, err); } }; + // eslint-disable-next-line no-unused-vars Internal = function Promise(executor){ this._c = []; // <- awaiting reactions this._a = undefined; // <- checked in isUnhandled reactions diff --git a/modules/es6.date.to-json.js b/modules/es6.date.to-json.js index eb419d03fe58..85d88e62a9b9 100644 --- a/modules/es6.date.to-json.js +++ b/modules/es6.date.to-json.js @@ -6,6 +6,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails')(function(){ return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1; }), 'Date', { + // eslint-disable-next-line no-unused-vars toJSON: function toJSON(key){ var O = toObject(this) , pv = toPrimitive(O); diff --git a/modules/es6.promise.js b/modules/es6.promise.js index 262a93af140d..60924628e3e3 100644 --- a/modules/es6.promise.js +++ b/modules/es6.promise.js @@ -193,6 +193,7 @@ if(!USE_NATIVE){ $reject.call(this, err); } }; + // eslint-disable-next-line no-unused-vars Internal = function Promise(executor){ this._c = []; // <- awaiting reactions this._a = undefined; // <- checked in isUnhandled reactions diff --git a/modules/library/es6.date.to-json.js b/modules/library/es6.date.to-json.js index e079c8923ec4..faca934a9469 100644 --- a/modules/library/es6.date.to-json.js +++ b/modules/library/es6.date.to-json.js @@ -8,6 +8,7 @@ var $export = require('./_export') $export($export.P + $export.F * require('./_fails')(function(){ return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1; }), 'Date', { + // eslint-disable-next-line no-unused-vars toJSON: function toJSON(key){ var O = toObject(this) , pv = toPrimitive(O); diff --git a/package.json b/package.json index a8598d896fb4..b1bf587ed75c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "scripts": { "grunt": "grunt", - "lint": "eslint es5 es6 es7 stage web core fn modules", + "lint": "eslint ./", "promises-tests": "promises-aplus-tests tests/promises-aplus/adapter", "observables-tests": "node tests/observables/adapter && node tests/observables/adapter-library", "test": "npm run lint && npm run grunt livescript client karma:default && npm run grunt clean copy library karma:library && npm run promises-tests && npm run observables-tests && lsc tests/commonjs"