From 26e121ad2b50357285addb63be48a567ecbf7ce9 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 2 Aug 2017 10:39:26 -0700 Subject: [PATCH 1/2] Upgrade eslint to 0.9.0. --- .eslintrc | 6 +- package.json | 4 +- packages/eslint-config-kibana/.eslintrc.js | 125 ++++++++++++++++++ packages/eslint-config-kibana/.gitignore | 36 +++++ packages/eslint-config-kibana/.npmignore | 2 + packages/eslint-config-kibana/README.md | 31 +++++ packages/eslint-config-kibana/jest.js | 15 +++ packages/eslint-config-kibana/package.json | 29 ++++ .../eslint-plugin-kibana-custom/README.md | 0 .../eslint-plugin-kibana-custom/index.js | 0 .../eslint-plugin-kibana-custom/package.json | 0 ui_framework/.eslintrc | 13 -- 12 files changed, 244 insertions(+), 17 deletions(-) create mode 100644 packages/eslint-config-kibana/.eslintrc.js create mode 100644 packages/eslint-config-kibana/.gitignore create mode 100644 packages/eslint-config-kibana/.npmignore create mode 100644 packages/eslint-config-kibana/README.md create mode 100644 packages/eslint-config-kibana/jest.js create mode 100644 packages/eslint-config-kibana/package.json rename packages/{@elastic => }/eslint-plugin-kibana-custom/README.md (100%) rename packages/{@elastic => }/eslint-plugin-kibana-custom/index.js (100%) rename packages/{@elastic => }/eslint-plugin-kibana-custom/package.json (100%) delete mode 100644 ui_framework/.eslintrc diff --git a/.eslintrc b/.eslintrc index 86918b9d925b8..334f46159f232 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,10 @@ --- -extends: '@elastic/kibana' +extends: + - '@elastic/eslint-config-kibana' + - '@elastic/eslint-config-kibana/jest' settings: import/resolver: '@elastic/eslint-import-resolver-kibana': rootPackageName: 'kibana' - kibanaPath: . \ No newline at end of file + kibanaPath: . diff --git a/package.json b/package.json index 931c4e984bd8b..5ea074cfa9613 100644 --- a/package.json +++ b/package.json @@ -203,7 +203,7 @@ "yauzl": "2.7.0" }, "devDependencies": { - "@elastic/eslint-config-kibana": "0.6.1", + "@elastic/eslint-config-kibana": "0.9.0", "@elastic/eslint-import-resolver-kibana": "0.8.1", "@elastic/eslint-plugin-kibana-custom": "1.0.3", "angular-mocks": "1.4.7", @@ -222,7 +222,7 @@ "eslint-plugin-import": "2.3.0", "eslint-plugin-jest": "20.0.3", "eslint-plugin-mocha": "4.9.0", - "eslint-plugin-react": "7.0.1", + "eslint-plugin-react": "7.1.0", "event-stream": "3.3.2", "expect.js": "0.3.1", "faker": "1.1.0", diff --git a/packages/eslint-config-kibana/.eslintrc.js b/packages/eslint-config-kibana/.eslintrc.js new file mode 100644 index 0000000000000..91f200949342c --- /dev/null +++ b/packages/eslint-config-kibana/.eslintrc.js @@ -0,0 +1,125 @@ +module.exports = { + parser: 'babel-eslint', + + plugins: [ + 'mocha', + 'babel', + 'react', + 'import', + ], + + env: { + es6: true, + amd: true, + node: true, + mocha: true, + browser: true, + }, + + parserOptions: { + sourceType: 'module', + ecmaVersion: 6, + ecmaFeatures: { experimentalObjectRestSpread: true }, + }, + + rules: { + 'block-scoped-var': 'error', + camelcase: [ 'error', { properties: 'never' } ], + 'comma-dangle': 'off', + 'comma-style': [ 'error', 'last' ], + 'consistent-return': 'off', + curly: [ 'error', 'multi-line' ], + 'dot-location': [ 'error', 'property' ], + 'dot-notation': [ 'error', { allowKeywords: true } ], + eqeqeq: [ 'error', 'allow-null' ], + 'guard-for-in': 'error', + indent: [ 'error', 2, { SwitchCase: 1 } ], + 'key-spacing': [ 'off', { align: 'value' } ], + 'max-len': [ 'error', 140, 2, { ignoreComments: true, ignoreUrls: true } ], + 'new-cap': [ 'error', { capIsNewExceptions: [ 'Private' ] } ], + 'no-bitwise': 'off', + 'no-caller': 'error', + 'no-cond-assign': 'off', + 'no-const-assign': 'error', + 'no-debugger': 'error', + 'no-empty': 'error', + 'no-eval': 'error', + 'no-extend-native': 'error', + 'no-extra-parens': 'off', + 'no-extra-semi': [ 'error' ], + 'no-global-assign': 'error', + 'no-irregular-whitespace': 'error', + 'no-iterator': 'error', + 'no-loop-func': 'error', + 'no-multi-spaces': 'off', + 'no-multi-str': 'error', + 'no-nested-ternary': 'error', + 'no-new': 'off', + 'no-path-concat': 'off', + 'no-proto': 'error', + 'no-redeclare': 'error', + 'no-restricted-globals': [ 'error', 'context' ], + 'no-return-assign': 'off', + 'no-script-url': 'error', + 'no-sequences': 'error', + 'no-shadow': 'off', + 'no-trailing-spaces': 'error', + 'no-undef': 'error', + 'no-underscore-dangle': 'off', + 'no-unused-expressions': 'off', + 'no-unused-vars': [ 'error' ], + 'no-use-before-define': [ 'error', 'nofunc' ], + 'no-var': 'error', + 'no-with': 'error', + 'one-var': [ 'error', 'never' ], + 'prefer-const': 'error', + quotes: [ 'error', 'single', { allowTemplateLiterals: true } ], + 'semi-spacing': [ 'error', { before: false, after: true } ], + semi: [ 'error', 'always' ], + 'space-before-blocks': [ 'error', 'always' ], + 'space-before-function-paren': [ 'error', { anonymous: 'always', named: 'never' } ], + 'space-in-parens': [ 'error', 'never' ], + 'space-infix-ops': [ 'error', { int32Hint: false } ], + 'space-unary-ops': [ 'error' ], + strict: [ 'error', 'never' ], + 'valid-typeof': 'error', + 'wrap-iife': [ 'error', 'outside' ], + yoda: 'off', + + 'object-curly-spacing': 'off', // overriden with babel/object-curly-spacing + 'babel/object-curly-spacing': [ 'error', 'always' ], + + 'react/jsx-uses-react': 'error', + 'react/react-in-jsx-scope': 'error', + 'react/jsx-uses-vars': 'error', + 'react/jsx-no-undef': 'error', + 'react/jsx-pascal-case': 'error', + 'react/jsx-closing-bracket-location': ['error', 'line-aligned'], + 'react/jsx-closing-tag-location': 'error', + 'react/jsx-indent-props': ['error', 2], + 'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }], + 'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }], + 'react/self-closing-comp': 'error', + 'react/jsx-wrap-multilines': ['error', { + declaration: true, + assignment: true, + return: true, + arrow: true, + }], + 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'], + 'react/jsx-equals-spacing': ['error', 'never'], + 'react/jsx-indent': ['error', 2], + + 'mocha/handle-done-callback': 'error', + 'mocha/no-exclusive-tests': 'error', + + 'import/no-unresolved': [ 'error', { 'amd': true, 'commonjs': true } ], + 'import/named': 'error', + 'import/namespace': 'error', + 'import/default': 'error', + 'import/export': 'error', + 'import/no-named-as-default': 'error', + 'import/no-named-as-default-member': 'error', + 'import/no-duplicates': 'error', + } +} diff --git a/packages/eslint-config-kibana/.gitignore b/packages/eslint-config-kibana/.gitignore new file mode 100644 index 0000000000000..7c0c9807a8b7d --- /dev/null +++ b/packages/eslint-config-kibana/.gitignore @@ -0,0 +1,36 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +node_modules + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history +.eslintrc.json + +yarn.lock \ No newline at end of file diff --git a/packages/eslint-config-kibana/.npmignore b/packages/eslint-config-kibana/.npmignore new file mode 100644 index 0000000000000..2ba159593147d --- /dev/null +++ b/packages/eslint-config-kibana/.npmignore @@ -0,0 +1,2 @@ +.eslintrc.yaml +tasks diff --git a/packages/eslint-config-kibana/README.md b/packages/eslint-config-kibana/README.md new file mode 100644 index 0000000000000..68c1639b834a5 --- /dev/null +++ b/packages/eslint-config-kibana/README.md @@ -0,0 +1,31 @@ +# eslint-config-kibana + +The eslint config used by the kibana team + +## Usage + +To use this eslint config, just install the peer dependencies and reference it +in your `.eslintrc`: + +```javascript +{ + extends: [ + '@elastic/eslint-config-kibana' + ] +} +``` + +## Optional jest config + +If the project uses the [jest test runner](https://facebook.github.io/jest/), +the `@elastic/eslint-config-kibana/jest` config can be extended as well to use +`eslint-plugin-jest` and add settings specific to it: + +```javascript +{ + extends: [ + '@elastic/eslint-config-kibana', + '@elastic/eslint-config-kibana/jest' + ] +} +``` diff --git a/packages/eslint-config-kibana/jest.js b/packages/eslint-config-kibana/jest.js new file mode 100644 index 0000000000000..68776bb3db147 --- /dev/null +++ b/packages/eslint-config-kibana/jest.js @@ -0,0 +1,15 @@ +module.exports = { + plugins: [ + 'jest', + ], + + env: { + 'jest/globals': true, + }, + + rules: { + 'jest/no-disabled-tests': 'error', + 'jest/no-focused-tests': 'error', + 'jest/no-identical-title': 'error', + }, +}; diff --git a/packages/eslint-config-kibana/package.json b/packages/eslint-config-kibana/package.json new file mode 100644 index 0000000000000..9c042fe34734f --- /dev/null +++ b/packages/eslint-config-kibana/package.json @@ -0,0 +1,29 @@ +{ + "name": "@elastic/eslint-config-kibana", + "version": "0.9.0", + "description": "The eslint config used by the kibana team", + "main": ".eslintrc.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/elastic/eslint-config-kibana.git" + }, + "keywords": [], + "author": "Spencer Alger ", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/elastic/eslint-config-kibana/issues" + }, + "homepage": "https://github.com/elastic/eslint-config-kibana#readme", + "peerDependencies": { + "babel-eslint": "^7.2.3", + "eslint": "^4.1.0", + "eslint-plugin-babel": "^4.1.1", + "eslint-plugin-import": "^2.6.0", + "eslint-plugin-jest": "^20.0.3", + "eslint-plugin-mocha": "^4.9.0", + "eslint-plugin-react": "^7.1.0" + } +} diff --git a/packages/@elastic/eslint-plugin-kibana-custom/README.md b/packages/eslint-plugin-kibana-custom/README.md similarity index 100% rename from packages/@elastic/eslint-plugin-kibana-custom/README.md rename to packages/eslint-plugin-kibana-custom/README.md diff --git a/packages/@elastic/eslint-plugin-kibana-custom/index.js b/packages/eslint-plugin-kibana-custom/index.js similarity index 100% rename from packages/@elastic/eslint-plugin-kibana-custom/index.js rename to packages/eslint-plugin-kibana-custom/index.js diff --git a/packages/@elastic/eslint-plugin-kibana-custom/package.json b/packages/eslint-plugin-kibana-custom/package.json similarity index 100% rename from packages/@elastic/eslint-plugin-kibana-custom/package.json rename to packages/eslint-plugin-kibana-custom/package.json diff --git a/ui_framework/.eslintrc b/ui_framework/.eslintrc deleted file mode 100644 index e20f525141316..0000000000000 --- a/ui_framework/.eslintrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "plugins": [ - "jest" - ], - "rules": { - "jest/no-disabled-tests": "error", - "jest/no-focused-tests": "error", - "jest/no-identical-title": "error" - }, - "env": { - "jest/globals": true - } -} From 76d452b035e3cc22abd7f6469e4c67754c9b3f0b Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Wed, 2 Aug 2017 10:55:58 -0700 Subject: [PATCH 2/2] Fix linting errors in UI Framework. --- .../guide_sandbox/guide_sandbox_code_toggle.js | 2 +- .../components/guide_section/guide_section.js | 2 +- .../src/views/button/button_with_icon.js | 16 ++++++++-------- ui_framework/doc_site/src/views/header/header.js | 3 +-- .../src/views/not_found/not_found_view.js | 2 +- .../src/views/popover/popover_anchor_position.js | 4 ++-- .../src/views/popover/popover_body_class_name.js | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ui_framework/doc_site/src/components/guide_sandbox/guide_sandbox_code_toggle.js b/ui_framework/doc_site/src/components/guide_sandbox/guide_sandbox_code_toggle.js index bce8c244d148c..88cda5ef0b658 100644 --- a/ui_framework/doc_site/src/components/guide_sandbox/guide_sandbox_code_toggle.js +++ b/ui_framework/doc_site/src/components/guide_sandbox/guide_sandbox_code_toggle.js @@ -19,7 +19,7 @@ export class GuideSandboxCodeToggle extends Component { className="guideSandboxCodeToggle guideSection__sourceButton" onClick={this.onClickSource} > - + ); } diff --git a/ui_framework/doc_site/src/components/guide_section/guide_section.js b/ui_framework/doc_site/src/components/guide_section/guide_section.js index af596a89ae6b6..8957d13de5a28 100644 --- a/ui_framework/doc_site/src/components/guide_section/guide_section.js +++ b/ui_framework/doc_site/src/components/guide_section/guide_section.js @@ -41,7 +41,7 @@ export class GuideSection extends Component { className="guideSection__sourceButton" onClick={this.onClickSource} > - + diff --git a/ui_framework/doc_site/src/views/button/button_with_icon.js b/ui_framework/doc_site/src/views/button/button_with_icon.js index 5cb876123a822..da9168564b3cd 100644 --- a/ui_framework/doc_site/src/views/button/button_with_icon.js +++ b/ui_framework/doc_site/src/views/button/button_with_icon.js @@ -8,7 +8,7 @@ export default () => (
window.alert('Button clicked')} - icon = "arrowUp" + icon="arrowUp" > Default @@ -17,7 +17,7 @@ export default () => ( window.alert('Button clicked')} > Filled @@ -26,7 +26,7 @@ export default () => (    window.alert('Button clicked')} > @@ -36,7 +36,7 @@ export default () => (    window.alert('Button clicked')} @@ -49,7 +49,7 @@ export default () => ( window.alert('Button clicked')} - icon = "arrowUp" + icon="arrowUp" > Default @@ -59,7 +59,7 @@ export default () => ( window.alert('Button clicked')} > Filled @@ -69,7 +69,7 @@ export default () => ( window.alert('Button clicked')} > @@ -80,7 +80,7 @@ export default () => ( window.alert('Button clicked')} diff --git a/ui_framework/doc_site/src/views/header/header.js b/ui_framework/doc_site/src/views/header/header.js index a157d2f3ddad4..943634f7feac4 100644 --- a/ui_framework/doc_site/src/views/header/header.js +++ b/ui_framework/doc_site/src/views/header/header.js @@ -107,8 +107,7 @@ export default class extends Component { >
-
-
+

John Username

diff --git a/ui_framework/doc_site/src/views/not_found/not_found_view.js b/ui_framework/doc_site/src/views/not_found/not_found_view.js index 1a2abb06fab24..472d0a25f57cf 100644 --- a/ui_framework/doc_site/src/views/not_found/not_found_view.js +++ b/ui_framework/doc_site/src/views/not_found/not_found_view.js @@ -20,7 +20,7 @@ export const NotFoundView = () => ( to="/" > home page - ? + ?

diff --git a/ui_framework/doc_site/src/views/popover/popover_anchor_position.js b/ui_framework/doc_site/src/views/popover/popover_anchor_position.js index 171cb70d7a0cc..3310aa3061424 100644 --- a/ui_framework/doc_site/src/views/popover/popover_anchor_position.js +++ b/ui_framework/doc_site/src/views/popover/popover_anchor_position.js @@ -31,7 +31,7 @@ export default class extends Component { return (
Popover anchored to the right. @@ -46,7 +46,7 @@ export default class extends Component {   Popover anchored to the left. diff --git a/ui_framework/doc_site/src/views/popover/popover_body_class_name.js b/ui_framework/doc_site/src/views/popover/popover_body_class_name.js index 6608508edea10..ee7f119fff50b 100644 --- a/ui_framework/doc_site/src/views/popover/popover_body_class_name.js +++ b/ui_framework/doc_site/src/views/popover/popover_body_class_name.js @@ -30,7 +30,7 @@ export default class extends Component { render() { return ( Custom class