From 324755fc37cf354138ef5ffb8fe8ab3e2660f4d4 Mon Sep 17 00:00:00 2001 From: Luca Greco Date: Tue, 30 Jun 2015 13:55:17 +0200 Subject: [PATCH 1/2] extend addon-sdk eslintrc from the project level eslintrc --- lib/.eslintrc | 18 ++++++++++++++++++ lib/inspector-actor.js | 4 ---- lib/inspector-front.js | 3 --- lib/inspector-service.js | 3 --- lib/inspector-window.js | 3 --- lib/main.js | 3 --- lib/start-button.js | 3 --- lib/toolbox-overlay.js | 3 --- lib/transport-observer.js | 3 --- 9 files changed, 18 insertions(+), 25 deletions(-) create mode 100644 lib/.eslintrc diff --git a/lib/.eslintrc b/lib/.eslintrc new file mode 100644 index 0000000..d9616b7 --- /dev/null +++ b/lib/.eslintrc @@ -0,0 +1,18 @@ +// extends common eslintrc config with addon-sdk specific configs +{ + "extends": "../.eslintrc", + "env": { + // commonjs conventions + "node": true + }, + "rules": { + "global-strict": 0, + "dot-notation": 0, + "new-cap": 0, + "no-underscore-dangle": 0 + }, + "globals": { + // firebug.sdk globals + "FBTrace": true + } +} diff --git a/lib/inspector-actor.js b/lib/inspector-actor.js index 6cfc51d..f01101d 100644 --- a/lib/inspector-actor.js +++ b/lib/inspector-actor.js @@ -1,9 +1,5 @@ - /* See license.txt for terms of usage */ -/* globals exports */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; // Add-on SDK diff --git a/lib/inspector-front.js b/lib/inspector-front.js index ce68d0c..2c954fd 100644 --- a/lib/inspector-front.js +++ b/lib/inspector-front.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; module.metadata = { diff --git a/lib/inspector-service.js b/lib/inspector-service.js index cd7db60..d32121f 100644 --- a/lib/inspector-service.js +++ b/lib/inspector-service.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; module.metadata = { diff --git a/lib/inspector-window.js b/lib/inspector-window.js index 01bd33a..6786d7e 100644 --- a/lib/inspector-window.js +++ b/lib/inspector-window.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module, FBTrace */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; module.metadata = { diff --git a/lib/main.js b/lib/main.js index bb8bff4..c1d96df 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; // Firebug.SDK diff --git a/lib/start-button.js b/lib/start-button.js index b1f526c..f1c5e29 100644 --- a/lib/start-button.js +++ b/lib/start-button.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; module.metadata = { diff --git a/lib/toolbox-overlay.js b/lib/toolbox-overlay.js index fcc6ed2..95fcbce 100644 --- a/lib/toolbox-overlay.js +++ b/lib/toolbox-overlay.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; module.metadata = { diff --git a/lib/transport-observer.js b/lib/transport-observer.js index 1b0d0ca..61c49be 100644 --- a/lib/transport-observer.js +++ b/lib/transport-observer.js @@ -1,8 +1,5 @@ /* See license.txt for terms of usage */ -/* globals exports, module */ -/* eslint global-strict: 0, dot-notation: 0, new-cap: 0, no-underscore-dangle: 0 */ - "use strict"; module.metadata = { From 417132ce73ffc5309b751216d4016fc4076c8404 Mon Sep 17 00:00:00 2001 From: Luca Greco Date: Tue, 30 Jun 2015 15:10:39 +0200 Subject: [PATCH 2/2] rework and docs on eslintrc rules files --- .eslintrc | 31 ++++++++----------------------- data/.eslintrc | 35 +++++++++++++++++++++++++++++++++++ data/inspector/config.js | 2 ++ data/inspector/main.js | 3 +++ karma-tests/.eslintrc | 7 +++++++ lib/inspector-service.js | 4 ++-- package.json | 2 +- 7 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 data/.eslintrc create mode 100644 karma-tests/.eslintrc diff --git a/.eslintrc b/.eslintrc index 10dbd6b..e879d8e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,38 +1,23 @@ { - "plugins": [ - "no-tabs", - "react" - ], "rules": { + "indent": [2, 2], // check 2 space indentation "no-mixed-spaces-and-tabs": [2], "quotes": [2, "double"], "semi": [1, "always"], - "no-tabs/at-all": [2], + // disabled rule which enforce unix or windows line breaks + "linebreak-style": [0], - "react/display-name": 2, - "react/prop-types": 0, + // disabled comma-dangle is safe for our use case + "comma-dangle": [0], - "indent": [0, 2], - "linebreak-style": [0], + // disabled eqeqeq and no-use-before-define are safe if you use them correctly "eqeqeq": [0], - "new-cap": [0], - "no-new": [0], - "comma-dangle": [0], - "no-use-before-define": [0] + "no-use-before-define": [0], }, "env": { - "es6": true, - "browser": true, - "amd": true + "es6": true }, "globals": { - "define": true, - "require": true, - "requirejs": true, - - "Str": true, - "Locale": true, - "Options": true } } diff --git a/data/.eslintrc b/data/.eslintrc new file mode 100644 index 0000000..4cd5dc0 --- /dev/null +++ b/data/.eslintrc @@ -0,0 +1,35 @@ +// extends common eslintrc config with "javascript running in a content context" specific configs +{ + "extends": "../.eslintrc", + "plugins": [ + // prevents tab whitespace when 'indent' rule is disabled + "no-tabs", + "react" + ], + "env": { + // enable browser & amd conventions + "browser": true, + "amd": true + }, + "rules": { + // disabled due to conflicts with special indentation in requirejs modules + "indent": 0, + // prevents any usage of tab whitespaces + "no-tabs/at-all": [2], + + // force definition of displayName on React components + "react/display-name": 2, + + // TODO: force propTypes on React Components + "react/prop-types": 0, + + // disabled due to conflicts with capitalized React components names + "new-cap": [0], + }, + "globals": { + // firebug.sdk globals + "Str": true, + "Locale": true, + "Options": true + } +} diff --git a/data/inspector/config.js b/data/inspector/config.js index 3bb5f8f..6f478f2 100644 --- a/data/inspector/config.js +++ b/data/inspector/config.js @@ -1,5 +1,7 @@ /* See license.txt for terms of usage */ +/* globals requirejs */ + // RequireJS configuration require.config({ baseUrl: ".", diff --git a/data/inspector/main.js b/data/inspector/main.js index a55a5a3..9dace39 100644 --- a/data/inspector/main.js +++ b/data/inspector/main.js @@ -156,9 +156,12 @@ theApp = React.render(MainTabbedArea({ // Helper modules for handling application events. packetsStore = new PacketsStore(window, theApp); + +/* eslint-disable no-new */ new ActorsStore(window, theApp); new Resizer(window, theApp); new Search(window, theApp); +/* eslint-enable */ // Send notification about initialization being done. postChromeMessage("initialized"); diff --git a/karma-tests/.eslintrc b/karma-tests/.eslintrc new file mode 100644 index 0000000..9480b1c --- /dev/null +++ b/karma-tests/.eslintrc @@ -0,0 +1,7 @@ +// extends data eslintrc config with karma tests specific configs +{ + "extends": "../data/.eslintrc", + "env": {}, + "rules": {}, + "globals": {} +} diff --git a/lib/inspector-service.js b/lib/inspector-service.js index d32121f..0228f33 100644 --- a/lib/inspector-service.js +++ b/lib/inspector-service.js @@ -105,14 +105,14 @@ const InspectorService = then(({registrar, front}) => { this.globalRegistrar = registrar; return front; - }); + }); // Register as tab actor. let tab = Rdp.registerTabActor(client, config). then(({registrar, front}) => { this.tabRegistrar = registrar; return front; - }); + }); // Wait till both registrations are done. all([global, tab]).then(results => { diff --git a/package.json b/package.json index a18fa17..6eb9dda 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "jpm-tests": "jpm test", "travis-ci": "npm run karma-coverage && npm run lint", "lint-content": "eslint data/inspector && eslint karma-tests/", - "lint-addon": "eslint --env node lib", + "lint-addon": "eslint lib", "lint": "npm run lint-content && npm run lint-addon" }, "engines": {